surfaceMeshGeometryModification.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 \*---------------------------------------------------------------------------*/
25 
27 #include "demandDrivenData.H"
28 #include "dictionary.H"
29 #include "triSurf.H"
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * Private member functions* * * * * * * * * * * //
35 
37 {
38  if( meshDict_.found("anisotropicSources") )
39  {
40  modificationActive_ = true;
41 
42  const dictionary& anisotropicDict =
43  meshDict_.subDict("anisotropicSources");
44 
45  coordinateModifierPtr_ = new coordinateModifier(anisotropicDict);
46  }
47 }
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
52 (
53  const triSurf& surf,
54  const dictionary& meshDict
55 )
56 :
57  surf_(surf),
58  meshDict_(meshDict),
59  coordinateModifierPtr_(NULL),
60  modificationActive_(false)
61 {
62  checkModification();
63 }
64 
66 {
68 }
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
73 {
74  return modificationActive_;
75 }
76 
78 {
79  if( !modificationActive_ )
80  {
81  WarningIn
82  (
83  "const triSurf* surfaceMeshGeometryModification"
84  "::modifyGeometry() const"
85  ) << "Modification is not active" << endl;
86 
87  return NULL;
88  }
89 
90  const pointField& pts = surf_.points();
91 
92  pointField newPts(pts.size());
93 
94  # ifdef USE_OMP
95  # pragma omp parallel for schedule(dynamic, 50)
96  # endif
97  forAll(pts, pointI)
98  newPts[pointI] = coordinateModifierPtr_->modifiedPoint(pts[pointI]);
99 
100  triSurf* newSurf =
101  new triSurf
102  (
103  surf_.facets(),
104  surf_.patches(),
106  newPts
107  );
108 
109  //- copy subsets
110  DynList<label> sIds;
111 
112  //- copy facet subsets
114  forAll(sIds, i)
115  {
116  const label newId =
117  newSurf->addFacetSubset(surf_.facetSubsetName(sIds[i]));
118 
119  labelLongList facetsInSubset;
120  surf_.facetsInSubset(sIds[i], facetsInSubset);
121 
122  forAll(facetsInSubset, fI)
123  newSurf->addFacetToSubset(newId, facetsInSubset[fI]);
124  }
125 
126  //- copy point subsets
128  forAll(sIds, i)
129  {
130  const label newId =
131  newSurf->addPointSubset(surf_.pointSubsetName(sIds[i]));
132 
133  labelLongList pointsInSubset;
134  surf_.pointsInSubset(sIds[i], pointsInSubset);
135 
136  forAll(pointsInSubset, pI)
137  newSurf->addPointToSubset(newId, pointsInSubset[pI]);
138  }
139 
140  //- copy subsets of feature edges
141  surf_.edgeSubsetIndices(sIds);
142  forAll(sIds, i)
143  {
144  const label newId =
145  newSurf->addEdgeSubset(surf_.edgeSubsetName(sIds[i]));
146 
147  labelLongList edgesInSubset;
148  surf_.edgesInSubset(sIds[i], edgesInSubset);
149 
150  forAll(edgesInSubset, eI)
151  newSurf->addEdgeToSubset(newId, edgesInSubset[eI]);
152  }
153 
154  return newSurf;
155 }
156 
159 {
160  if( !modificationActive_ )
161  {
162  WarningIn
163  (
164  "const triSurf* surfaceMeshGeometryModification"
165  "::revertGeometryModification() const"
166  ) << "Modification is not active" << endl;
167 
168  return NULL;
169  }
170 
171  const pointField& pts = surf_.points();
172 
173  pointField newPts(pts.size());
174 
175  # ifdef USE_OMP
176  # pragma omp parallel for schedule(dynamic, 50)
177  # endif
178  forAll(pts, pointI)
179  newPts[pointI] =
181 
182  triSurf* newSurf =
183  new triSurf
184  (
185  surf_.facets(),
186  surf_.patches(),
188  newPts
189  );
190 
191  //- copy subsets
192  DynList<label> sIds;
193 
194  //- copy facet subsets
196  forAll(sIds, i)
197  {
198  const label newId =
199  newSurf->addFacetSubset(surf_.facetSubsetName(sIds[i]));
200 
201  labelLongList facetsInSubset;
202  surf_.facetsInSubset(sIds[i], facetsInSubset);
203 
204  forAll(facetsInSubset, fI)
205  newSurf->addFacetToSubset(newId, facetsInSubset[fI]);
206  }
207 
208  //- copy point subsets
210  forAll(sIds, i)
211  {
212  const label newId =
213  newSurf->addPointSubset(surf_.pointSubsetName(sIds[i]));
214 
215  labelLongList pointsInSubset;
216  surf_.pointsInSubset(sIds[i], pointsInSubset);
217 
218  forAll(pointsInSubset, pI)
219  newSurf->addPointToSubset(newId, pointsInSubset[pI]);
220  }
221 
222  //- copy subsets of feature edges
223  surf_.edgeSubsetIndices(sIds);
224  forAll(sIds, i)
225  {
226  const label newId =
227  newSurf->addEdgeSubset(surf_.edgeSubsetName(sIds[i]));
228 
229  labelLongList edgesInSubset;
230  surf_.edgesInSubset(sIds[i], edgesInSubset);
231 
232  forAll(edgesInSubset, eI)
233  newSurf->addEdgeToSubset(newId, edgesInSubset[eI]);
234  }
235 
236  return newSurf;
237 }
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 } // End namespace Foam
242 
243 // ************************************************************************* //
Foam::triSurfPoints::pointsInSubset
void pointsInSubset(const label, ListType &) const
Definition: triSurfPointsI.H:117
triSurf.H
Foam::surfaceMeshGeometryModification::surfaceMeshGeometryModification
surfaceMeshGeometryModification(const surfaceMeshGeometryModification &)
disallow bitwise copy construct
Foam::triSurfPoints::pointSubsetName
word pointSubsetName(const label) const
Definition: triSurfPoints.C:84
Foam::triSurfFeatureEdges::addEdgeSubset
label addEdgeSubset(const word &)
point subsets
Definition: triSurfFeatureEdges.C:54
Foam::surfaceMeshGeometryModification::meshDict_
const dictionary & meshDict_
length of box sides
Definition: surfaceMeshGeometryModification.H:62
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::coordinateModifier::modifiedPoint
point modifiedPoint(const point &) const
calculate the modified coordinate of the point
Definition: coordinateModifier.C:193
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::triSurfPoints::points
const pointField & points() const
access to points
Definition: triSurfPointsI.H:44
Foam::triSurfFeatureEdges::edgesInSubset
void edgesInSubset(const label, ListType &) const
Definition: triSurfFeatureEdgesI.H:118
Foam::surfaceMeshGeometryModification::surf_
const triSurf & surf_
reference to triSurf
Definition: surfaceMeshGeometryModification.H:59
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::surfaceMeshGeometryModification::activeModification
bool activeModification() const
is geometry modification active
Definition: surfaceMeshGeometryModification.C:72
Foam::surfaceMeshGeometryModification::~surfaceMeshGeometryModification
~surfaceMeshGeometryModification()
Definition: surfaceMeshGeometryModification.C:65
Foam::triSurfFeatureEdges::addEdgeToSubset
void addEdgeToSubset(const label, const label)
Definition: triSurfFeatureEdgesI.H:55
Foam::triSurfPoints::addPointSubset
label addPointSubset(const word &)
point subsets
Definition: triSurfPoints.C:54
Foam::triSurfFeatureEdges::featureEdges
const edgeLongList & featureEdges() const
access to feature edges
Definition: triSurfFeatureEdgesI.H:44
Foam::LongList< label >
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:40
Foam::surfaceMeshGeometryModification::revertGeometryModification
const triSurf * revertGeometryModification() const
revert geometry modification
Definition: surfaceMeshGeometryModification.C:158
Foam::triSurfFacets::addFacetToSubset
void addFacetToSubset(const label, const label)
Definition: triSurfFacetsI.H:60
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::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::triSurfPoints::addPointToSubset
void addPointToSubset(const label, const label)
Definition: triSurfPointsI.H:57
Foam::surfaceMeshGeometryModification::checkModification
void checkModification()
check existence of geometry modifiers
Definition: surfaceMeshGeometryModification.C:36
Foam::triSurfFacets::patches
const geometricSurfacePatchList & patches() const
access to patches
Definition: triSurfFacetsI.H:49
Foam::triSurfFacets::addFacetSubset
label addFacetSubset(const word &)
point subsets
Definition: triSurfFacets.C:105
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::DynList< label >
Foam::triSurfPoints::pointSubsetIndices
void pointSubsetIndices(DynList< label > &) const
Definition: triSurfPointsI.H:102
Foam::triSurfFeatureEdges::edgeSubsetIndices
void edgeSubsetIndices(DynList< label > &) const
Definition: triSurfFeatureEdgesI.H:101
Foam::triSurfFacets::facetSubsetIndices
void facetSubsetIndices(DynList< label > &) const
Definition: triSurfFacetsI.H:105
Foam::surfaceMeshGeometryModification::modifyGeometry
const triSurf * modifyGeometry() const
modify coordinates
Definition: surfaceMeshGeometryModification.C:77
dictionary.H
Foam::triSurfFacets::facets
const LongList< labelledTri > & facets() const
access to facets
Definition: triSurfFacetsI.H:44
Foam::triSurfFacets::facetSubsetName
word facetSubsetName(const label) const
Definition: triSurfFacets.C:135
WarningIn
#define WarningIn(functionName)
Report a warning using Foam::Warning.
Definition: messageStream.H:254
Foam::triSurfFacets::facetsInSubset
void facetsInSubset(const label, ListType &) const
Definition: triSurfFacetsI.H:120
Foam::coordinateModifier
Definition: coordinateModifier.H:54
Foam::triSurfFeatureEdges::edgeSubsetName
word edgeSubsetName(const label) const
Definition: triSurfFeatureEdges.C:84
Foam::coordinateModifier::backwardModifiedPoint
point backwardModifiedPoint(const point &) const
calculate the displacement vector for the backward modification
Definition: coordinateModifier.C:205
Foam::dictionary::subDict
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:631
Foam::triSurf
Definition: triSurf.H:59
Foam::surfaceMeshGeometryModification::coordinateModifierPtr_
coordinateModifier * coordinateModifierPtr_
contruct coordinate modification
Definition: surfaceMeshGeometryModification.H:65
Foam::surfaceMeshGeometryModification::modificationActive_
bool modificationActive_
is mofdification active
Definition: surfaceMeshGeometryModification.H:68
surfaceMeshGeometryModification.H