Go to the documentation of this file.
79 { ExtrudeMode::MESH,
"mesh" },
81 { ExtrudeMode::SURFACE,
"surface" },
92 <<
"Cannot find patch " <<
name
93 <<
" in the source mesh.\n"
119 faceLabels[
n++] = pp.
start()+j;
131 labelList newFaceLabels(faceLabels.size());
136 label oldFacei = faceLabels[i];
138 if (reverseMap[oldFacei] >= 0)
140 newFaceLabels[newI++] = reverseMap[oldFacei];
156 label oldCelli = cellLabels[i];
158 if (reverseMap[oldCelli] >= 0)
160 newCellLabels.
insert(reverseMap[oldCelli]);
163 cellLabels.transfer(newCellLabels);
167 template<
class PatchType>
168 void changeFrontBackPatches
171 const word& frontPatchName,
172 const word& backPatchName
177 label frontPatchi = findPatchID(
patches, frontPatchName);
178 label backPatchi = findPatchID(
patches, backPatchName);
186 if (patchi == frontPatchi || patchi == backPatchi)
213 int main(
int argc,
char *argv[])
217 "Extrude mesh from existing patch."
232 << runTimeExtruded.timeName() <<
nl <<
endl;
237 Info<<
"Create mesh for time = "
238 << runTimeExtruded.timeName() <<
nl <<
endl;
248 runTimeExtruded.system(),
261 const bool flipNormals(
dict.
get<
bool>(
"flipNormals"));
264 const ExtrudeMode
mode = ExtrudeModeNames.get(
"constructFrom",
dict);
269 Info<<
"Extruding from " << ExtrudeModeNames[
mode]
270 <<
" using model " << model().type() <<
endl;
273 Info<<
"Flipping normals before extruding" <<
endl;
277 Info<<
"Collapsing edges < " << mergeTol <<
" of bounding box" <<
endl;
281 Info<<
"Not collapsing any edges after extrusion" <<
endl;
304 if (flipNormals &&
mode == MESH)
307 <<
"Flipping normals not supported for extrusions from mesh."
322 if (sourcePatches.size() == 1)
324 frontPatchName = sourcePatches[0];
327 Info<<
"Extruding patches " << sourcePatches
328 <<
" on mesh " << sourceCasePath <<
nl
356 label meshFacei = meshFaces[i];
367 bool zoneFlip =
false;
394 if (map().hasMotionPoints())
421 extrudePatch.meshEdges
485 Info<<
"Adding overall " << nAdded <<
" processor patches." <<
endl;
507 label nbrProci = patchToNbrProc[patchi];
509 Pout<<
"Adding patch " << patchi
511 <<
" and " << nbrProci
543 findPatchID(
patches, backPatchName)
548 pointField layer0Points(extrudePatch.nPoints());
549 pointField displacement(extrudePatch.nPoints());
550 forAll(displacement, pointi)
552 const vector& patchNormal = extrudePatchPointNormals[pointi];
555 layer0Points[pointi] = model()
557 extrudePatch.localPoints()[pointi],
562 point extrudePt = model()
564 extrudePatch.localPoints()[pointi],
568 displacement[pointi] = extrudePt - layer0Points[pointi];
574 if (
gMax(
mag(layer0Points-extrudePatch.localPoints())) > SMALL)
576 Info<<
"Moving mesh to layer0 points since differ from original"
577 <<
" points - this can happen for wedge extrusions." <<
nl
581 forAll(extrudePatch.meshPoints(), i)
583 newPoints[extrudePatch.meshPoints()[i]] = layer0Points[i];
590 labelList nFaceLayers(extrudePatch.size(), model().nLayers());
593 labelList nPointLayers(extrudePatch.nPoints(), model().nLayers());
596 vectorField firstLayerDisp(displacement*model().sumThickness(1));
638 layerExtrude.setRefinement
659 forAll(layerExtrude.addedPoints(), pointi)
661 const labelList& pPoints = layerExtrude.addedPoints()[pointi];
664 label meshPointi = pPoints[pPointi];
670 extrudePatch.localPoints()[pointi],
671 extrudePatchPointNormals[pointi],
679 )[meshPointi] = modelPt;
686 backPatchFaces.
setSize(layerFaces.size());
687 frontPatchFaces.
setSize(layerFaces.size());
688 forAll(backPatchFaces, patchFacei)
690 backPatchFaces[patchFacei] = layerFaces[patchFacei].first();
691 frontPatchFaces[patchFacei] = layerFaces[patchFacei].last();
705 runTimeExtruded.constant(),
714 layerExtrude.updateMesh
724 map().reverseFaceMap(),
729 map().reverseFaceMap(),
736 refDataPtr->updateMesh(map());
744 layerExtrude.addedCells
747 layerExtrude.layerFaces()
752 const labelList& aCells = addedCells[facei];
753 addedCellsSet.
insert(aCells);
762 Info<<
"Extruding surfaceMesh read from file " << surfName <<
nl
773 faces[i] = fMesh[i].reverseFace();
777 Info<<
"Extruding surface with :" <<
nl
778 <<
" points : " << fMesh.points().size() <<
nl
779 <<
" faces : " << fMesh.size() <<
nl
780 <<
" normals[0] : " << fMesh.faceNormals()[0]
784 meshFromSurface.
reset
791 runTimeExtruded.constant(),
801 frontPatchName =
"originalPatch";
802 frontPatchFaces = patchFaces
807 backPatchName =
"otherSide";
808 backPatchFaces = patchFaces
826 const scalar mergeDim = mergeTol * bb.
minDim();
828 Info<<
"Mesh bounding box : " << bb <<
nl
829 <<
" with span : " << span <<
nl
830 <<
"Merge distance : " << mergeDim <<
nl
839 Info<<
"Collapsing edges < " << mergeDim <<
" ..." <<
nl <<
endl;
852 const edge&
e = edges[edgeI];
858 Info<<
"Merging edge " <<
e <<
" since length " << d
859 <<
" << " << mergeDim <<
nl;
862 collapsePointToLocation.set(
e[1],
points[
e[0]]);
870 collapser.consistentCollapse
874 collapsePointToLocation,
883 bool anyChange = collapser.setRefinement(allPointInfo, meshMod);
895 updateFaceLabels(map(), frontPatchFaces);
896 updateFaceLabels(map(), backPatchFaces);
897 updateCellSet(map(), addedCellsSet);
901 refDataPtr->updateMesh(map());
905 if (map().hasMotionPoints())
918 if (isType<extrudeModels::wedge>(model()))
920 changeFrontBackPatches<wedgePolyPatch>
927 else if (isType<extrudeModels::plane>(model()))
929 changeFrontBackPatches<emptyPolyPatch>
941 if (
dict.
get<
bool>(
"mergeFaces"))
946 <<
"Cannot stitch front and back of extrusion since"
947 <<
" in 'mesh' mode (extrusion appended to mesh)."
951 Info<<
"Assuming full 360 degree axisymmetric case;"
952 <<
" stitching faces on patches "
953 << frontPatchName <<
" and "
954 << backPatchName <<
" together ..." <<
nl <<
endl;
956 if (frontPatchFaces.size() != backPatchFaces.size())
959 <<
"Differing number of faces on front ("
960 << frontPatchFaces.size() <<
") and back ("
961 << backPatchFaces.size() <<
")"
969 const word cutZoneName(
"originalCutFaceZone");
1000 perfectStitcher.setRefinement
1030 updateCellSet(map(), addedCellsSet);
1034 refDataPtr->updateMesh(map());
1038 if (map().hasMotionPoints())
1059 cellSet addedCells(
mesh,
"addedCells", addedCellsSet);
1060 Info<<
"Writing added cells to cellSet " << addedCells.name()
1062 if (!addedCells.write())
1065 << addedCells.name()
1072 refDataPtr->write();
void addPatches(PtrList< polyPatch > &plist, const bool validBoundary=true)
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
virtual const pointField & points() const
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Calculates points shared by more than two processor patches or cyclic patches.
A class for handling words, derived from Foam::string.
A class for handling file names.
virtual bool write(const bool valid=true) const
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
static word defaultRegion
T getOrDefault(const word &optName, const T &deflt) const
static std::string path(const std::string &str)
static constexpr const zero Zero
static labelListList globalEdgeFaces(const polyMesh &, const globalIndex &globalFaces, const indirectPrimitivePatch &pp)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
List of mesh modifiers defining the mesh dynamics.
static std::string name(const std::string &str)
Direct mesh changes based on v1.3 polyTopoChange syntax.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
static void addNote(const string ¬e)
const fileName & facesInstance() const
virtual tmp< scalarField > movePoints(const pointField &)
const polyBoundaryMesh & boundaryMesh() const
Ostream & endl(Ostream &os)
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
const edgeList & edges() const
const labelListList & pointEdges() const
A HashTable with keys but without contents that is similar to std::unordered_set.
static word controlDictName
bool readIfPresent(const word &optName, T &val) const
Mesh consisting of general polyhedral cells.
label nPoints() const noexcept
List< word > wordList
A List of words.
mode_t mode(const fileName &name, const bool followLink=true)
Does polyTopoChanges to remove edges. Can remove faces due to edge collapse but can not remove cells ...
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Generic templated field type.
A subset of mesh faces organised as a primitive patch.
A patch is a list of labels that address the faces in the global face list.
void setSize(const label n)
virtual const labelList & faceOwner() const
void transfer(List< T > &list)
A List with indirect addressing.
virtual void updateMesh(const mapPolyMesh &mpm)
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
const faceZoneMesh & faceZones() const noexcept
static autoPtr< extrudeModel > New(const dictionary &dict)
label whichPatch(const label faceIndex) const
Neighbour processor patch.
static IOobject selectIO(const IOobject &io, const fileName &altFile, const word &ioName="")
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Various for reading/decomposing/reconstructing/distributing refinement data.
label whichZone(const label objectIndex) const
void addFvPatches(PtrList< polyPatch > &plist, const bool validBoundary=true)
PtrList< T > clone(Args &&... args) const
Hack of attachDetach to couple patches when they perfectly align. Does not decouple....
Adds layers of cells to outside of polyPatch. Can optionally create stand-alone extruded mesh (addToM...
label index() const noexcept
A collection of cell labels.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
errorManipArg< error, int > exit(error &err, const int errNo=1)
const labelList & reverseFaceMap() const
const boundBox & bounds() const
void reset(autoPtr< T > &&other) noexcept
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
const labelList & reverseCellMap() const
virtual const faceList & faces() const
#define FatalErrorInFunction
static int myProcNo(const label communicator=worldComm)
static bool & parRun() noexcept
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static void calcExtrudeInfo(const bool zoneFromAnyFace, const polyMesh &, const globalIndex &globalFaces, const labelListList &globalEdgeFaces, const indirectPrimitivePatch &pp, labelList &edgePatchID, label &nPatches, Map< label > &nbrProcToPatch, Map< label > &patchToNbrProc, labelList &edgeZoneID, boolList &edgeFlip, labelList &inflateFaceID)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
string & expand(const bool allowEmpty=false)
static void removeFiles(const polyMesh &mesh)
const dimensionedScalar e
Bookkeeping for patch definitions.
labelList identity(const label len, label start=0)
bool insert(const Key &key)
const polyBoundaryMesh & patches
A bounding box defined in terms of min/max extrema points.
virtual autoPtr< polyPatch > clone(const labelList &faceCells) const
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
word name(const expressions::valueTypeCode typeCode)
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
label nFaces() const noexcept
const word & name() const noexcept
label collapseEdge(triSurface &surf, const scalar minLen)
fileName objectPath() const
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Foam::argList args(argc, argv)
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
void addZones(const List< pointZone * > &pz, const List< faceZone * > &fz, const List< cellZone * > &cz)
Type gMax(const FieldField< Field, Type > &f)
void setInstance(const fileName &instance, const IOobject::writeOption wOpt=IOobject::AUTO_WRITE)
virtual const labelList & faceNeighbour() const
A list of faces which address into the list of points.