84 void createDummyFvMeshFiles(
const polyMesh& mesh,
const word& regionName)
99 Info<<
"Testing:" << io.objectPath() <<
endl;
103 Info<<
"Writing dummy " << regionName/io.name() <<
endl;
106 dummyDict.
add(
"divSchemes", divDict);
108 dummyDict.
add(
"gradSchemes", gradDict);
110 dummyDict.
add(
"laplacianSchemes", laplDict);
119 mesh.time().system(),
129 Info<<
"Writing dummy " << regionName/io.name() <<
endl;
144 <<
"Cannot find patch " << name
145 <<
" in the source mesh.\n" 146 <<
"Valid patch names are " << patches.
names()
159 const polyPatch& pp = patches[findPatchID(patches, names[i])];
167 const polyPatch& pp = patches[findPatchID(patches, names[i])];
171 faceLabels[n++] = pp.
start()+j;
188 label oldFacei = faceLabels[i];
190 if (reverseMap[oldFacei] >= 0)
192 newFaceLabels[newI++] = reverseMap[oldFacei];
208 label oldCelli = cellLabels[i];
210 if (reverseMap[oldCelli] >= 0)
212 newCellLabels.
insert(reverseMap[oldCelli]);
219 template<
class PatchType>
220 void changeFrontBackPatches
223 const word& frontPatchName,
224 const word& backPatchName
229 label frontPatchi = findPatchID(patches, frontPatchName);
230 label backPatchi = findPatchID(patches, backPatchName);
238 if (patchi == frontPatchi || patchi == backPatchi)
265 int main(
int argc,
char *argv[])
279 Info<<
"Create mesh " << regionName <<
" for time = " 280 << runTimeExtruded.timeName() <<
nl <<
endl;
285 Info<<
"Create mesh for time = " 286 << runTimeExtruded.timeName() <<
nl <<
endl;
298 const ExtrudeMode mode = ExtrudeModeNames.
read 306 Info<<
"Extruding from " << ExtrudeModeNames[
mode]
307 <<
" using model " << model().type() <<
endl;
310 Info<<
"Flipping normals before extruding" <<
endl;
314 Info<<
"Collapsing edges < " << mergeTol <<
" of bounding box" <<
endl;
318 Info<<
"Not collapsing any edges after extrusion" <<
endl;
336 if (mode == PATCH || mode == MESH)
338 if (flipNormals && mode == MESH)
341 <<
"Flipping normals not supported for extrusions from mesh." 356 dict.
lookup(
"sourcePatches") >> sourcePatches;
358 if (sourcePatches.
size() == 1)
360 frontPatchName = sourcePatches[0];
363 Info<<
"Extruding patches " << sourcePatches
364 <<
" on mesh " << sourceCasePath <<
nl 383 const labelList meshFaces(patchFaces(patches, sourcePatches));
385 if (mode == PATCH && flipNormals)
392 label meshFacei = meshFaces[i];
403 bool zoneFlip =
false;
407 zoneFlip = mesh.
faceZones()[zoneI].flipMap()[index];
412 mesh.
faces()[meshFacei].reverseFace(),
430 if (map().hasMotionPoints())
458 extrudePatch.meshEdges
513 Info<<
"Adding overall " << nAdded <<
" processor patches." <<
endl;
537 Pout<<
"Adding patch " << patchi
539 <<
" and " << nbrProci
557 mesh.removeFvBoundary();
558 mesh.addFvPatches(newPatches,
true);
567 dict.
lookup(
"exposedPatchName") >> backPatchName;
571 findPatchID(patches, backPatchName)
576 pointField layer0Points(extrudePatch.nPoints());
577 pointField displacement(extrudePatch.nPoints());
578 forAll(displacement, pointi)
580 const vector& patchNormal = extrudePatchPointNormals[pointi];
583 layer0Points[pointi] = model()
585 extrudePatch.localPoints()[pointi],
590 point extrudePt = model()
592 extrudePatch.localPoints()[pointi],
596 displacement[pointi] = extrudePt - layer0Points[pointi];
602 if (
gMax(
mag(layer0Points-extrudePatch.localPoints())) > small)
604 Info<<
"Moving mesh to layer0 points since differ from original" 605 <<
" points - this can happen for wedge extrusions." <<
nl 609 forAll(extrudePatch.meshPoints(), i)
611 newPoints[extrudePatch.meshPoints()[i]] = layer0Points[i];
618 labelList nFaceLayers(extrudePatch.size(), model().nLayers());
621 labelList nPointLayers(extrudePatch.nPoints(), model().nLayers());
624 vectorField firstLayerDisp(displacement*model().sumThickness(1));
640 layerExtrude.setRefinement
656 forAll(layerExtrude.addedPoints(), pointi)
658 const labelList& pPoints = layerExtrude.addedPoints()[pointi];
661 label meshPointi = pPoints[pPointi];
667 extrudePatch.localPoints()[pointi],
668 extrudePatchPointNormals[pointi],
676 )[meshPointi] = modelPt;
685 forAll(backPatchFaces, patchFacei)
687 backPatchFaces[patchFacei] = layerFaces[patchFacei].
first();
688 frontPatchFaces[patchFacei] = layerFaces[patchFacei].
last();
693 createDummyFvMeshFiles(mesh, regionDir);
702 runTimeExtruded.constant(),
711 layerExtrude.topoChange
721 map().reverseFaceMap(),
726 map().reverseFaceMap(),
735 layerExtrude.addedCells
738 layerExtrude.layerFaces()
743 const labelList& aCells = addedCells[facei];
746 addedCellsSet.
insert(aCells[i]);
757 Info<<
"Extruding surfaceMesh read from file " << surfName <<
nl 768 faces[i] = fMesh[i].reverseFace();
772 Info<<
"Extruding surface with :" <<
nl 773 <<
" points : " << fMesh.points().size() <<
nl 774 <<
" faces : " << fMesh.size() <<
nl 775 <<
" normals[0] : " << fMesh.faceNormals()[0]
779 meshFromSurface.
reset 786 runTimeExtruded.constant(),
796 frontPatchName =
"originalPatch";
797 frontPatchFaces = patchFaces
799 meshFromSurface().boundaryMesh(),
802 backPatchName =
"otherSide";
803 backPatchFaces = patchFaces
805 meshFromSurface().boundaryMesh(),
821 const scalar mergeDim = mergeTol * bb.
minDim();
823 Info<<
"Mesh bounding box : " << bb <<
nl 824 <<
" with span : " << span <<
nl 825 <<
"Merge distance : " << mergeDim <<
nl 834 Pout<<
"Collapsing edges < " << mergeDim <<
" ..." <<
nl <<
endl;
847 const edge& e = edges[edgeI];
849 scalar d = e.
mag(points);
853 Pout<<
"Merging edge " << e <<
" since length " << d
854 <<
" << " << mergeDim <<
nl;
857 collapsePointToLocation.set(e[1], points[e[0]]);
865 collapser.consistentCollapse
869 collapsePointToLocation,
878 bool anyChange = collapser.setRefinement(allPointInfo, meshMod);
890 updateFaceLabels(map(), frontPatchFaces);
891 updateFaceLabels(map(), backPatchFaces);
892 updateCellSet(map(), addedCellsSet);
895 if (map().hasMotionPoints())
908 if (isType<extrudeModels::wedge>(model()))
910 changeFrontBackPatches<wedgePolyPatch>
917 else if (isType<extrudeModels::plane>(model()))
919 changeFrontBackPatches<emptyPolyPatch>
937 <<
"Cannot stitch front and back of extrusion since" 938 <<
" in 'mesh' mode (extrusion appended to mesh)." 942 Info<<
"Assuming full 360 degree axisymmetric case;" 943 <<
" stitching faces on patches " 944 << frontPatchName <<
" and " 945 << backPatchName <<
" together ..." <<
nl <<
endl;
947 if (frontPatchFaces.
size() != backPatchFaces.
size())
950 <<
"Differing number of faces on front (" 951 << frontPatchFaces.
size() <<
") and back (" 952 << backPatchFaces.
size() <<
")" 961 const word cutZoneName(
"originalCutFaceZone");
992 perfectStitcher.setRefinement
1022 updateCellSet(map(), addedCellsSet);
1025 if (map().hasMotionPoints())
1027 mesh.
setPoints(map().preMotionPoints());
1044 cellSet addedCells(mesh,
"addedCells", addedCellsSet);
1045 Info<<
"Writing added cells to cellSet " << addedCells.name()
1047 if (!addedCells.write())
1050 << 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.
#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.
const word & name() const
Return name.
A class for handling file names.
fileName relativeObjectPath() const
Return complete relativePath + object name.
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
Templated form of IOobject providing type information for file reading and header type checking...
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)
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.
IOdictionary systemDict(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion)
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.
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.
const labelList & reverseFaceMap() const
Reverse face map.
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...
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.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
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.
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.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
void removeBoundary()
Remove boundary patches.
Type gMax(const FieldField< Field, Type > &f)
const Time & time() const
Return time.
const labelList & reverseCellMap() const
Reverse cell map.
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 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.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
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")
const meshFaceZones & faceZones() const
Return face zones.
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.
virtual void setPoints(const pointField &)
Reset the points.
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.
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.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.