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]);
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(),
734 if (refDataPtr.
valid())
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);
899 if (refDataPtr.
valid())
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);
1032 if (refDataPtr.
valid())
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()
1070 if (refDataPtr.
valid())
1072 refDataPtr().write();
void addPatches(PtrList< polyPatch > &plist, const bool validBoundary=true)
Add boundary patches.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
label size() const noexcept
The number of elements in table.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
virtual const pointField & points() const
Return raw points.
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
Write mesh using IO settings from time.
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
Return the default region name.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
static std::string path(const std::string &str)
Return directory path name (part before last /)
static constexpr const zero Zero
Global zero (0)
static labelListList globalEdgeFaces(const polyMesh &, const globalIndex &globalFaces, const indirectPrimitivePatch &pp)
Per patch edge the pp faces (in global indices) using it.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
label nFaces() const
Number of mesh faces.
List of mesh modifiers defining the mesh dynamics.
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
static bool & parRun()
Is this a parallel run?
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)
Add extra notes for the usage information.
label nEdges() const
Number of mesh edges.
const fileName & facesInstance() const
Return the current instance directory for faces.
void removeFvBoundary()
Remove boundary patches. Warning: fvPatchFields hold ref to.
bool valid() const noexcept
True if the managed pointer is non-null.
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
const labelListList & pointEdges() const
static word controlDictName
The default control dictionary name (normally "controlDict")
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Mesh consisting of general polyhedral cells.
wordList names() const
Return a list of patch names.
#define forAll(list, i)
Loop across all elements in list.
const faceZoneMesh & faceZones() const
Return face zone mesh.
List< word > wordList
A List of words.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Does polyTopoChanges to remove edges. Can remove faces due to edge collapse but can not remove cells ...
vector span() const
The bounding box span (from minimum to maximum)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
A subset of mesh faces organised as a primitive patch.
messageStream Info
Information stream (uses stdout - output is on the master only)
A patch is a list of labels that address the faces in the global face list.
word name(const complex &c)
Return string representation of complex.
virtual const labelList & faceOwner() const
Return face owner.
void transfer(List< T > &list)
A List with indirect addressing.
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
scalar minDim() const
Smallest length/height/width dimension.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
static autoPtr< extrudeModel > New(const dictionary &dict)
Select null constructed.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
Neighbour processor patch.
static IOobject selectIO(const IOobject &io, const fileName &altFile, const word &ioName="")
Return the IOobject, but also consider an alternative file name.
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
Various for reading/decomposing/reconstructing/distributing refinement data.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
void addFvPatches(PtrList< polyPatch > &plist, const bool validBoundary=true)
Add boundary patches. Constructor helper.
PtrList< T > clone(Args &&... args) const
Make a copy by cloning each of the list elements.
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...
A collection of cell labels.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
label start() const
Return start label of this patch in the polyMesh face list.
void transfer(HashTable< T, Key, Hash > &rhs)
Transfer contents into this table.
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void removeBoundary()
Remove boundary patches.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
const labelList & reverseFaceMap() const
Reverse face map.
const boundBox & bounds() const
Return mesh bounding box.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values (not the indices) of a list.
const labelList & reverseCellMap() const
Reverse cell map.
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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)
Determine extrude information per patch edge:
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
string & expand(const bool allowEmpty=false)
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
const dimensionedScalar e
Elementary charge.
Bookkeeping for patch definitions.
label nPoints() const
Number of mesh points.
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
static const word null
An empty word.
const polyBoundaryMesh & patches
A bounding box defined in terms of min/max extrema points.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
label collapseEdge(triSurface &surf, const scalar minLen)
Keep collapsing all edges < minLen.
fileName objectPath() const
The complete path + object name.
void setSize(const label newSize)
Alias for resize(const label)
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)
Add an option to validOptions with usage information.
Foam::argList args(argc, argv)
const word & name() const
The patch name.
label index() const
The index of this patch in the boundaryMesh.
void addZones(const List< pointZone * > &pz, const List< faceZone * > &fz, const List< cellZone * > &cz)
Add mesh zones.
Type gMax(const FieldField< Field, Type > &f)
void setInstance(const fileName &instance, const IOobject::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
virtual const labelList & faceNeighbour() const
Return face neighbour.
A list of faces which address into the list of points.