1 /*---------------------------------------------------------------------------*\
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 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
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.
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.
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/>.
26 Mesh needed to do edge-based addressing.
28 \*---------------------------------------------------------------------------*/
31 #include "demandDrivenData.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 defineTypeNameAndDebug(eMesh, 0);
42 word eMesh::meshSubDir = "eMesh";
44 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
46 void eMesh::clearGeom() const
50 Info<< "void eMesh::clearGeom() const : "
51 << "Clearing geometry" << endl;
56 void eMesh::clearAddressing() const
60 Info<< "void eMesh::clearAddressing() const : "
61 << "Clearing addressing" << endl;
66 deleteDemandDrivenData(fePtr_);
67 deleteDemandDrivenData(efPtr_);
71 // Helper function to isolate points on triangular faces
72 label eMesh::findIsolatedPoint(const face& f, const edge& e) const
74 // Check the first point
75 if ( f[0] != e.start() && f[0] != e.end() )
80 // Check the second point
81 if ( f[1] != e.start() && f[1] != e.end() )
86 // Check the third point
87 if ( f[2] != e.start() && f[2] != e.end() )
96 //- Helper function to determine the orientation of a triangular face
97 label eMesh::edgeDirection(const face& f, const edge& e) const
101 (f[0] == e.start() && f[1] == e.end())
102 || (f[1] == e.start() && f[2] == e.end())
103 || (f[2] == e.start() && f[0] == e.end())
106 // Return counter-clockwise
117 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
119 eMesh::eMesh(const polyMesh& pMesh, const word& subDir)
121 objectRegistry(pMesh.time()),
128 mesh_.facesInstance(),
131 IOobject::READ_IF_PRESENT,
140 mesh_.facesInstance(),
143 IOobject::READ_IF_PRESENT,
153 Info << "eMesh::eMesh(const polyMesh&, const word&) : "
154 << "Creating eMesh from polyMesh"
158 // Re-initialize / override meshSubDir
161 // Try to read from disk.
162 if (edges_.headerOk() && boundary_.headerOk())
165 nEdges_ = edges_.size();
166 nInternalEdges_ = boundary_[0].start();
170 // Could not read ordered edges, so calculate it instead.
171 calcOrderedEdgeList();
176 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
183 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
185 fileName eMesh::meshDir() const
187 return mesh_.dbDir();
191 fileName eMesh::meshSubDirectory() const
193 return mesh_.dbDir()/meshSubDir;
197 const Time& eMesh::time() const
203 label eMesh::nEdges() const
209 label eMesh::nInternalEdges() const
211 return nInternalEdges_;
215 const edgeList& eMesh::edges() const
221 void eMesh::addEdgePatches(const List<ePatch*>& p)
225 Info << "void eMesh::addEdgePatches(const List<ePatch*>& p) : "
226 << "Adding patches to eMesh" << endl;
229 if (boundary().size() > 0)
233 "void eMesh::addEdgePatches(const List<ePatch*>& p)"
235 << "Boundary already exists"
236 << abort(FatalError);
239 boundary_.setSize(p.size());
243 boundary_.set(patchI, p[patchI]);
248 const objectRegistry& eMesh::db() const
254 const eBoundaryMesh& eMesh::boundary() const
260 void eMesh::resetPrimitives
263 labelListList& faceEdges,
264 labelListList& edgeFaces,
265 const labelList& patchSizes,
266 const labelList& patchStarts,
268 const bool storePrimitives
271 // Clear out geometry and addressing
274 // Initialize pointers for storage
284 mesh_.facesInstance(),
300 mesh_.facesInstance(),
311 edges_.transfer(edges);
312 fePtr_->transfer(faceEdges);
313 efPtr_->transfer(edgeFaces);
318 fePtr_->operator=(faceEdges);
319 efPtr_->operator=(edgeFaces);
323 // Reset patch sizes and starts
324 forAll(boundary_, patchI)
326 boundary_[patchI] = ePatch
328 boundary_[patchI].name(),
336 // Reset size information
337 nEdges_ = edges.size();
338 nInternalEdges_ = boundary_[0].start();
340 // Set mesh files as changed
341 setInstance(time().timeName());
345 //- Clear demand-driven data
346 void eMesh::clearOut() const
353 //- Set the instance for mesh files
354 void eMesh::setInstance(const fileName& inst)
358 Info<< "void eMesh::setInstance(const fileName& inst) : "
359 << "Resetting file instance to " << inst << endl;
364 edges_.writeOpt() = IOobject::AUTO_WRITE;
365 edges_.instance() = inst;
370 efPtr_->writeOpt() = IOobject::AUTO_WRITE;
371 efPtr_->instance() = inst;
376 fePtr_->writeOpt() = IOobject::AUTO_WRITE;
377 fePtr_->instance() = inst;
380 // Write out boundary information only
381 // if all others are being written out
382 if (edges_.size() && efPtr_ && fePtr_)
384 boundary_.writeOpt() = IOobject::AUTO_WRITE;
385 boundary_.instance() = inst;
390 const labelListList& eMesh::faceEdges() const
401 const labelListList& eMesh::edgeFaces() const
412 bool eMesh::write() const
429 if (edges_.size() && efPtr_ && fePtr_)
438 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
440 bool eMesh::operator!=(const eMesh& m) const
445 bool eMesh::operator==(const eMesh& m) const
451 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
453 } // End namespace Foam
455 // ************************************************************************* //