82 void createDummyFvMeshFiles(
const polyMesh& mesh,
const word& regionName)
97 Info<<
"Testing:" << io.objectPath() <<
endl;
101 Info<<
"Writing dummy " << regionName/io.name() <<
endl;
104 dummyDict.
add(
"divSchemes", divDict);
106 dummyDict.
add(
"gradSchemes", gradDict);
108 dummyDict.
add(
"laplacianSchemes", laplDict);
117 mesh.time().system(),
127 Info<<
"Writing dummy " << regionName/io.name() <<
endl;
142 <<
"Cannot find patch " << name
143 <<
" in the source mesh.\n" 144 <<
"Valid patch names are " << patches.
names()
157 const polyPatch& pp = patches[findPatchID(patches, names[i])];
165 const polyPatch& pp = patches[findPatchID(patches, names[i])];
169 faceLabels[n++] = pp.
start()+j;
186 label oldFacei = faceLabels[i];
188 if (reverseMap[oldFacei] >= 0)
190 newFaceLabels[newI++] = reverseMap[oldFacei];
206 label oldCelli = cellLabels[i];
208 if (reverseMap[oldCelli] >= 0)
210 newCellLabels.
insert(reverseMap[oldCelli]);
217 template<
class PatchType>
218 void changeFrontBackPatches
221 const word& frontPatchName,
222 const word& backPatchName
227 label frontPatchi = findPatchID(patches, frontPatchName);
228 label backPatchi = findPatchID(patches, backPatchName);
236 if (patchi == frontPatchi || patchi == backPatchi)
263 int main(
int argc,
char *argv[])
275 Info<<
"Create mesh " << regionName <<
" for time = " 276 << runTimeExtruded.timeName() <<
nl <<
endl;
281 Info<<
"Create mesh for time = " 282 << runTimeExtruded.timeName() <<
nl <<
endl;
291 runTimeExtruded.system(),
304 const ExtrudeMode mode = ExtrudeModeNames.
read 312 Info<<
"Extruding from " << ExtrudeModeNames[
mode]
313 <<
" using model " << model().type() <<
endl;
316 Info<<
"Flipping normals before extruding" <<
endl;
320 Info<<
"Collapsing edges < " << mergeTol <<
" of bounding box" <<
endl;
324 Info<<
"Not collapsing any edges after extrusion" <<
endl;
342 if (mode == PATCH || mode == MESH)
344 if (flipNormals && mode == MESH)
347 <<
"Flipping normals not supported for extrusions from mesh." 362 dict.
lookup(
"sourcePatches") >> sourcePatches;
364 if (sourcePatches.
size() == 1)
366 frontPatchName = sourcePatches[0];
369 Info<<
"Extruding patches " << sourcePatches
370 <<
" on mesh " << sourceCasePath <<
nl 389 const labelList meshFaces(patchFaces(patches, sourcePatches));
391 if (mode == PATCH && flipNormals)
398 label meshFacei = meshFaces[i];
409 bool zoneFlip =
false;
413 zoneFlip = mesh.
faceZones()[zoneI].flipMap()[index];
418 mesh.
faces()[meshFacei].reverseFace(),
436 if (map().hasMotionPoints())
464 extrudePatch.meshEdges
519 Info<<
"Adding overall " << nAdded <<
" processor patches." <<
endl;
543 Pout<<
"Adding patch " << patchi
545 <<
" and " << nbrProci
563 mesh.removeFvBoundary();
564 mesh.addFvPatches(newPatches,
true);
573 dict.
lookup(
"exposedPatchName") >> backPatchName;
577 findPatchID(patches, backPatchName)
582 pointField layer0Points(extrudePatch.nPoints());
583 pointField displacement(extrudePatch.nPoints());
584 forAll(displacement, pointi)
586 const vector& patchNormal = extrudePatchPointNormals[pointi];
589 layer0Points[pointi] = model()
591 extrudePatch.localPoints()[pointi],
596 point extrudePt = model()
598 extrudePatch.localPoints()[pointi],
602 displacement[pointi] = extrudePt - layer0Points[pointi];
608 if (
gMax(
mag(layer0Points-extrudePatch.localPoints())) > small)
610 Info<<
"Moving mesh to layer0 points since differ from original" 611 <<
" points - this can happen for wedge extrusions." <<
nl 615 forAll(extrudePatch.meshPoints(), i)
617 newPoints[extrudePatch.meshPoints()[i]] = layer0Points[i];
624 labelList nFaceLayers(extrudePatch.size(), model().nLayers());
627 labelList nPointLayers(extrudePatch.nPoints(), model().nLayers());
630 vectorField firstLayerDisp(displacement*model().sumThickness(1));
646 layerExtrude.setRefinement
662 forAll(layerExtrude.addedPoints(), pointi)
664 const labelList& pPoints = layerExtrude.addedPoints()[pointi];
667 label meshPointi = pPoints[pPointi];
673 extrudePatch.localPoints()[pointi],
674 extrudePatchPointNormals[pointi],
682 )[meshPointi] = modelPt;
691 forAll(backPatchFaces, patchFacei)
693 backPatchFaces[patchFacei] = layerFaces[patchFacei].
first();
694 frontPatchFaces[patchFacei] = layerFaces[patchFacei].
last();
699 createDummyFvMeshFiles(mesh, regionDir);
708 runTimeExtruded.constant(),
717 layerExtrude.updateMesh
727 map().reverseFaceMap(),
732 map().reverseFaceMap(),
741 layerExtrude.addedCells
744 layerExtrude.layerFaces()
749 const labelList& aCells = addedCells[facei];
752 addedCellsSet.
insert(aCells[i]);
763 Info<<
"Extruding surfaceMesh read from file " << surfName <<
nl 774 faces[i] = fMesh[i].reverseFace();
778 Info<<
"Extruding surface with :" <<
nl 779 <<
" points : " << fMesh.points().size() <<
nl 780 <<
" faces : " << fMesh.size() <<
nl 781 <<
" normals[0] : " << fMesh.faceNormals()[0]
785 meshFromSurface.
reset 792 runTimeExtruded.constant(),
802 frontPatchName =
"originalPatch";
803 frontPatchFaces = patchFaces
808 backPatchName =
"otherSide";
809 backPatchFaces = patchFaces
827 const scalar mergeDim = mergeTol * bb.
minDim();
829 Info<<
"Mesh bounding box : " << bb <<
nl 830 <<
" with span : " << span <<
nl 831 <<
"Merge distance : " << mergeDim <<
nl 840 Pout<<
"Collapsing edges < " << mergeDim <<
" ..." <<
nl <<
endl;
853 const edge& e = edges[edgeI];
855 scalar d = e.
mag(points);
859 Pout<<
"Merging edge " << e <<
" since length " << d
860 <<
" << " << mergeDim <<
nl;
863 collapsePointToLocation.set(e[1], points[e[0]]);
871 collapser.consistentCollapse
875 collapsePointToLocation,
884 bool anyChange = collapser.setRefinement(allPointInfo, meshMod);
896 updateFaceLabels(map(), frontPatchFaces);
897 updateFaceLabels(map(), backPatchFaces);
898 updateCellSet(map(), addedCellsSet);
901 if (map().hasMotionPoints())
914 if (isType<extrudeModels::wedge>(model()))
916 changeFrontBackPatches<wedgePolyPatch>
923 else if (isType<extrudeModels::plane>(model()))
925 changeFrontBackPatches<emptyPolyPatch>
943 <<
"Cannot stitch front and back of extrusion since" 944 <<
" in 'mesh' mode (extrusion appended to mesh)." 948 Info<<
"Assuming full 360 degree axisymmetric case;" 949 <<
" stitching faces on patches " 950 << frontPatchName <<
" and " 951 << backPatchName <<
" together ..." <<
nl <<
endl;
953 if (frontPatchFaces.
size() != backPatchFaces.
size())
956 <<
"Differing number of faces on front (" 957 << frontPatchFaces.
size() <<
") and back (" 958 << backPatchFaces.
size() <<
")" 967 const word cutZoneName(
"originalCutFaceZone");
998 perfectStitcher.setRefinement
1028 updateCellSet(map(), addedCellsSet);
1031 if (map().hasMotionPoints())
1050 cellSet addedCells(mesh,
"addedCells", addedCellsSet);
1051 Info<<
"Writing added cells to cellSet " << addedCells.name()
1053 if (!addedCells.write())
1056 << addedCells.name()
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
autoPtr< IOobject > clone() const
Clone.
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
#define forAll(list, i)
Loop across all elements in list.
mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file mode.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
A class for handling file names.
const faceZoneMesh & faceZones() const
Return face zone mesh.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
const labelListList & pointEdges() const
void size(const label)
Override size to be inconsistent with allocated storage.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
static word defaultRegion
Return the default region name.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Does polyTopoChanges to remove edges. Can remove faces due to edge collapse but can not remove cells ...
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
label findPatchID(const word &patchName) const
Find patch index given a name.
label collapseEdge(triSurface &surf, const scalar minLen)
Keep collapsing all edges < minLen.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
A bounding box defined in terms of the points at its extremities.
void transfer(HashTable< T, Key, Hash > &)
Transfer the contents of the argument table into this table.
bool insert(const Key &key)
Insert a new entry.
T & first()
Return the first element of the list.
Initialise the NamedEnum HashTable from the static list of names.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
label size() const
Return number of elements in table.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Neighbour processor patch.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
virtual const pointField & points() const
Return raw points.
List< bool > boolList
Bool container classes.
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
A list of faces which address into the list of points.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
const word & regionDir(const word ®ionName)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
static autoPtr< extrudeModel > New(const dictionary &)
Select null constructed.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
virtual void updateMesh(const mapPolyMesh &mpm)
Update the mesh corresponding to given map.
List of mesh modifiers defining the mesh dynamics.
Adds layers of cells to outside of polyPatch. Can optionally create stand-alone extruded mesh (addToM...
A class for handling words, derived from string.
wordList names() const
Return a list of patch names.
word name() const
Return file name (part beyond last /)
virtual const labelList & faceOwner() const
Return face owner.
static const word null
An empty word.
fileName localObjectPath() const
Return complete localPath + object name.
scalar mag(const pointField &) const
Return scalar magnitude.
virtual const faceList & faces() const
Return raw faces.
void addZones(const List< pointZone *> &pz, const List< faceZone *> &fz, const List< cellZone *> &cz)
Add mesh zones.
static word controlDictName
The default control dictionary name (normally "controlDict")
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
void addPatches(const List< polyPatch *> &, const bool validBoundary=true)
Add boundary patches.
const word & system() const
Return system name.
void removeBoundary()
Remove boundary patches.
const labelList & reverseCellMap() const
Reverse cell map.
Type gMax(const FieldField< Field, Type > &f)
const Time & time() const
Return time.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
word name(const complex &)
Return a string representation of a complex.
void setInstance(const fileName &)
Set the instance for mesh files.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
label size() const
Return the number of elements in the UPtrList.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
List< word > wordList
A List of words.
Calculates points shared by more than two processor patches or cyclic patches.
void setSize(const label)
Reset size of List.
const boundBox & bounds() const
Return mesh bounding box.
static bool & parRun()
Is this a parallel run?
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
string & expand(const bool allowEmpty=false)
Expand initial tildes and all occurrences of environment variables.
A collection of cell labels.
prefixOSstream Pout(cout, "Pout")
label index() const
Return the index of this patch in the boundaryMesh.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label start() const
Return start label of this patch in the polyMesh face list.
vector span() const
The bounding box span (from minimum to maximum)
dimensioned< scalar > mag(const dimensioned< Type > &)
static labelListList globalEdgeFaces(const polyMesh &, const globalIndex &globalFaces, const indirectPrimitivePatch &pp)
Per patch edge the pp faces (in global indices) using it. Uses.
Enum read(Istream &) const
Read a word from Istream and return the corresponding.
fileName path() const
Return directory path name (part before last /)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Mesh consisting of general polyhedral cells.
A subset of mesh faces organised as a primitive patch.
Hack of attachDetach to couple patches when they perfectly align. Does not decouple. Used by stitchMesh app. Does geometric matching.
virtual bool write(const bool write=true) const
Write using setting from DB.
A patch is a list of labels that address the faces in the global face list.
T & last()
Return the last element of the list.
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
static void calcSidePatch(const polyMesh &, const globalIndex &globalFaces, const labelListList &globalEdgeFaces, const indirectPrimitivePatch &pp, labelList &sidePatchID, label &nPatches, Map< label > &nbrProcToPatch, Map< label > &patchToNbrProc)
Boundary edges get extruded into boundary faces. Determine patch.
A List with indirect addressing.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
scalar minDim() const
Smallest length/height/width dimension.
const labelList & reverseFaceMap() const
Reverse face map.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.