immersedBoundaryPolyPatch.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | foam-extend: Open Source CFD
4  \\ / O peration | Version: 3.2
5  \\ / A nd | Web: http://www.foam-extend.org
6  \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9  This file is part of foam-extend.
10 
11  foam-extend 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  foam-extend is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "polyBoundaryMesh.H"
28 #include "polyMesh.H"
29 #include "foamTime.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(immersedBoundaryPolyPatch, 0);
37 
38  addToRunTimeSelectionTable(polyPatch, immersedBoundaryPolyPatch, word);
40  (
41  polyPatch,
42  immersedBoundaryPolyPatch,
43  dictionary
44  );
45 }
46 
47 
48 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
49 
51 {
52  if (debug)
53  {
54  Info<< "void immersedBoundaryPolyPatch::makeTriSurfSearch() const : "
55  << "creating triSurface search algorithm"
56  << endl;
57  }
58 
59  // It is an error to attempt to recalculate
60  // if the pointer is already
62  {
63  FatalErrorIn("immersedBoundaryPolyPatch::makeTriSurfSearch() const")
64  << "triSurface search algorithm already exist"
65  << abort(FatalError);
66  }
67 
69 }
70 
71 
73 {
74  deleteDemandDrivenData(triSurfSearchPtr_);
75 }
76 
77 
78 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
79 
81 {
82  // Handle motion of immersed boundary
83  clearOut();
84 
86 }
87 
88 
89 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
90 
92 (
93  const word& name,
94  const label size,
95  const label start,
96  const label index,
97  const polyBoundaryMesh& bm
98 )
99 :
100  polyPatch(name, size, start, index, bm),
101  ibMesh_
102  (
103  IOobject
104  (
105  name + ".ftr",
106  bm.mesh().time().constant(), // instance
107  "triSurface", // local
108  bm.mesh(), // registry
111  )
112  ),
113  internalFlow_(false),
114  triSurfSearchPtr_(NULL),
115  movingIb_(false)
116 {}
117 
118 
120 (
121  const word& name,
122  const dictionary& dict,
123  const label index,
124  const polyBoundaryMesh& bm
125 )
126 :
127  polyPatch(name, dict, index, bm),
128  ibMesh_
129  (
130  IOobject
131  (
132  name + ".ftr",
133  bm.mesh().time().constant(), // instance
134  "triSurface", // local
135  bm.mesh(), // registry
138  )
139  ),
140  internalFlow_(dict.lookup("internalFlow")),
141  triSurfSearchPtr_(NULL),
142  movingIb_(false)
143 {
144  if (size() > 0)
145  {
147  (
148  "immersedBoundaryPolyPatch::immersedBoundaryPolyPatch\n"
149  "(\n"
150  " const word& name,\n"
151  " const dictionary& dict,\n"
152  " const label index,\n"
153  " const polyBoundaryMesh& bm\n"
154  ")",
155  dict
156  ) << "Faces detected in the immersedBoundaryPolyPatch. "
157  << "This is not allowed: please make sure that the patch size "
158  << "equals zero."
159  << abort(FatalIOError);
160  }
161 }
162 
163 
165 (
166  const immersedBoundaryPolyPatch& pp,
167  const polyBoundaryMesh& bm
168 )
169 :
170  polyPatch(pp, bm),
171  ibMesh_
172  (
173  IOobject
174  (
175  pp.name() + ".ftr",
176  bm.mesh().time().constant(), // instance
177  "triSurface", // local
178  bm.mesh(), // registry
181  )
182  ),
183  internalFlow_(pp.internalFlow_),
184  triSurfSearchPtr_(NULL),
185  movingIb_(false)
186 {}
187 
188 
190 (
191  const immersedBoundaryPolyPatch& pp,
192  const polyBoundaryMesh& bm,
193  const label index,
194  const label newSize,
195  const label newStart
196 )
197 :
198  polyPatch(pp, bm, index, newSize, newStart),
199  ibMesh_
200  (
201  IOobject
202  (
203  pp.name() + ".ftr",
204  bm.mesh().time().constant(), // instance
205  "triSurface", // local
206  bm.mesh(), // registry
209  )
210  ),
211  internalFlow_(pp.internalFlow_),
212  triSurfSearchPtr_(NULL),
213  movingIb_(false)
214 {}
215 
216 
217 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
218 
220 {
221  clearOut();
222 }
223 
224 
225 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
226 
229 {
230  if (!triSurfSearchPtr_)
231  {
232  makeTriSurfSearch();
233  }
234 
235  return *triSurfSearchPtr_;
236 }
237 
238 
240 (
241  const pointField& p
242 )
243 {
244  // Record the motion of the patch
245  movingIb_ = true;
246 
247  // Move points of the triSurface
248  const pointField& oldPoints = ibMesh_.points();
249 
250  if (oldPoints.size() != p.size())
251  {
253  (
254  "void immersedBoundaryPolyPatch::moveTriSurfacePoints\n"
255  "(\n"
256  " const pointField& p\n"
257  ")"
258  ) << "Incorrect size of motion points for patch " << name()
259  << ". oldPoints = "
260  << oldPoints.size() << " p = " << p.size()
261  << abort(FatalError);
262  }
263 
264  Info<< "Moving immersed boundary points for patch " << name()
265  << endl;
266 
267  ibMesh_.movePoints(p);
268 
269  fileName path(boundaryMesh().mesh().time().path()/"VTK");
270 
271  mkDir(path);
272  ibMesh_.triSurface::write
273  (
274  path/
275  word
276  (
277  name() + "_"
278  + Foam::name(boundaryMesh().mesh().time().timeIndex())
279  + ".stl"
280  )
281  );
282 
283  clearOut();
284 }
285 
286 
288 {
289  polyPatch::write(os);
290  os.writeKeyword("internalFlow") << internalFlow_
291  << token::END_STATEMENT << nl;
292 }
293 
294 
295 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::immersedBoundaryPolyPatch::makeTriSurfSearch
void makeTriSurfSearch() const
Make triSurface search algorithm.
Definition: immersedBoundaryPolyPatch.C:50
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
foamTime.H
Foam::immersedBoundaryPolyPatch::triSurfSearch
const triSurfaceSearch & triSurfSearch() const
Return triSurface search object.
Definition: immersedBoundaryPolyPatch.C:228
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::objectRegistry::time
const Time & time() const
Return time.
Definition: objectRegistry.H:117
Foam::polyPatch::write
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: polyPatch.C:382
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::immersedBoundaryPolyPatch
Immersed boundary patch.
Definition: immersedBoundaryPolyPatch.H:56
Foam::immersedBoundaryPolyPatch::write
virtual void write(Ostream &) const
Write.
Definition: immersedBoundaryPolyPatch.C:287
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:108
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
polyMesh.H
Foam::immersedBoundaryPolyPatch::ibMesh_
triSurfaceMesh ibMesh_
Triangular surface representing immersed boundary.
Definition: immersedBoundaryPolyPatch.H:64
Foam::triSurfaceSearch
Helper class to search on triSurface.
Definition: triSurfaceSearch.H:55
Foam::immersedBoundaryPolyPatch::internalFlow_
Switch internalFlow_
Internal or external flow calculation.
Definition: immersedBoundaryPolyPatch.H:67
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
Foam::immersedBoundaryPolyPatch::immersedBoundaryPolyPatch
immersedBoundaryPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Construct from components.
Definition: immersedBoundaryPolyPatch.C:92
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:40
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::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
FatalIOErrorIn
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:324
Foam::PrimitivePatch::movePoints
virtual void movePoints(const Field< PointType > &)
Correct patch after moving points.
Definition: PrimitivePatchTemplate.C:187
Foam::polyBoundaryMesh::mesh
const polyMesh & mesh() const
Return the mesh reference.
Definition: polyBoundaryMesh.H:140
timeIndex
label timeIndex
Definition: getTimeIndex.H:4
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
immersedBoundaryPolyPatch.H
Foam::immersedBoundaryPolyPatch::~immersedBoundaryPolyPatch
virtual ~immersedBoundaryPolyPatch()
Destructor.
Definition: immersedBoundaryPolyPatch.C:219
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::immersedBoundaryPolyPatch::triSurfSearchPtr_
triSurfaceSearch * triSurfSearchPtr_
Triangular surface search algorithm.
Definition: immersedBoundaryPolyPatch.H:73
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePaths.H:130
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::immersedBoundaryPolyPatch::clearOut
void clearOut()
Clear all demand-driven data.
Definition: immersedBoundaryPolyPatch.C:72
Foam::immersedBoundaryPolyPatch::moveTriSurfacePoints
void moveTriSurfacePoints(const pointField &p)
Correct patches after moving points.
Definition: immersedBoundaryPolyPatch.C:240
path
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
polyBoundaryMesh.H
Foam::boundaryMesh
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:59
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::mkDir
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Definition: POSIX.C:419
Foam::immersedBoundaryPolyPatch::movePoints
virtual void movePoints(const pointField &p)
Correct patches after moving points.
Definition: immersedBoundaryPolyPatch.C:80
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::patchIdentifier::name
const word & name() const
Return name.
Definition: patchIdentifier.H:109
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47