triSurfaceExtrude2DEdges.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "triSurfModifier.H"
30 #include "boundBox.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
40 :
41  surf_(surface)
42 {}
43 
45 {}
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
50 {
51  triSurfModifier sMod(newSurf);
52 
53  //- set patches
55 
56  patches.setSize(1);
57  patches[0].name() = "patch0";
58  patches[0].geometricType() = "patch";
59 
60  //- check if the edges are in the x-y plane
61  const pointField& sPoints = surf_.points();
62  const boundBox bb(sPoints);
63 
64  if( Foam::mag(bb.max().z() - bb.min().z()) > SMALL )
66  (
67  "void triSurfaceExtrude2DEdges::extrudeSurface(triSurf&) const"
68  ) << "Cannot extrude edges which are not in the x-y plane!"
69  << exit(FatalError);
70 
71  //- copy points
72  pointField& pts = sMod.pointsAccess();
73  pts.setSize(2 * sPoints.size());
74 
75  const label nOffset = sPoints.size();
76  const scalar zOffset = 0.1 * bb.mag();
77 
78  forAll(sPoints, pI)
79  {
80  pts[pI] = pts[pI+nOffset] = sPoints[pI];
81  pts[pI+sPoints.size()].z() += zOffset;
82  }
83 
84  //- create triangles from feature edges
85  LongList<labelledTri>& triangles = sMod.facetsAccess();
86  const edgeLongList& edges = surf_.featureEdges();
87 
88  triangles.setSize(2 * edges.size());
89  forAll(edges, eI)
90  {
91  const edge& e = edges[eI];
92  const label tI = 2 * eI;
93  triangles[tI] = labelledTri(e[0], e[1], e[1]+nOffset, 0);
94  triangles[tI + 1] = labelledTri(e[0], e[1]+nOffset, e[0]+nOffset, 0);
95  }
96 }
97 
99 {
100  triSurf* sPtr = new triSurf();
101 
102  extrudeSurface(*sPtr);
103 
104  return sPtr;
105 }
106 
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 
109 } // End namespace Foam
110 
111 // ************************************************************************* //
Foam::boundBox::mag
scalar mag() const
The magnitude of the bounding box span.
Definition: boundBoxI.H:90
triSurfaceExtrude2DEdges.H
Foam::boundBox::max
const point & max() const
Maximum describing the bounding box.
Definition: boundBoxI.H:60
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::triSurfPoints::points
const pointField & points() const
access to points
Definition: triSurfPointsI.H:44
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
triSurfModifier.H
Foam::triSurfModifier
Definition: triSurfModifier.H:48
Foam::LongList::size
label size() const
Size of the active part of the list.
Definition: LongListI.H:203
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::triSurfFeatureEdges::featureEdges
const edgeLongList & featureEdges() const
access to feature edges
Definition: triSurfFeatureEdgesI.H:44
Foam::triSurfModifier::patchesAccess
geometricSurfacePatchList & patchesAccess()
access to patches
Definition: triSurfModifierI.H:52
Foam::LongList::setSize
void setSize(const label)
Reset size of List.
Definition: LongListI.H:223
Foam::triSurfaceExtrude2DEdges::triSurfaceExtrude2DEdges
triSurfaceExtrude2DEdges(const triSurfaceExtrude2DEdges &)
Disallow default bitwise copy construct.
Foam::LongList
Definition: LongList.H:55
Foam::triSurfaceExtrude2DEdges::extrudeSurface
const triSurf * extrudeSurface() const
Definition: triSurfaceExtrude2DEdges.C:98
Foam::triSurfaceExtrude2DEdges::~triSurfaceExtrude2DEdges
~triSurfaceExtrude2DEdges()
Definition: triSurfaceExtrude2DEdges.C:44
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::triSurfModifier::pointsAccess
pointField & pointsAccess()
non-const access to points
Definition: triSurfModifierI.H:37
Foam::triSurfModifier::facetsAccess
LongList< labelledTri > & facetsAccess()
access to facets
Definition: triSurfModifierI.H:42
Foam::boundBox::min
const point & min() const
Minimum describing the bounding box.
Definition: boundBoxI.H:54
Foam::FatalError
error FatalError
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::Vector::z
const Cmpt & z() const
Definition: VectorI.H:77
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::triSurfaceExtrude2DEdges::surf_
const triSurf & surf_
reference to triSurf
Definition: triSurfaceExtrude2DEdges.H:53
boundBox.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::surface
Definition: surface.H:55
Foam::labelledTri
Triangle with additional region number.
Definition: labelledTri.H:49
Foam::boundBox
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
patches
patches[0]
Definition: createSingleCellMesh.H:36
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::triSurf
Definition: triSurf.H:59