80 { ExtrudeMode::MESH,
"mesh" },
82 { ExtrudeMode::SURFACE,
"surface" },
93 <<
"Cannot find patch " <<
name 94 <<
" in the source mesh.\n" 153 faceFlip[
n] = ppFlip[i];
171 if (reverseMap[oldFacei] >= 0)
173 newFaceLabels[newI++] = reverseMap[oldFacei];
189 label oldCelli = cellLabels[i];
191 if (reverseMap[oldCelli] >= 0)
193 newCellLabels.
insert(reverseMap[oldCelli]);
200 template<
class PatchType>
201 void changeFrontBackPatches
204 const word& frontPatchName,
205 const word& backPatchName
210 label frontPatchi = findPatchID(
patches, frontPatchName);
211 label backPatchi = findPatchID(
patches, backPatchName);
219 if (patchi == frontPatchi || patchi == backPatchi)
246 int main(
int argc,
char *argv[])
250 "Extrude mesh from existing patch." 262 Info<<
"Create mesh";
267 Info<<
" for time = " << runTimeExtruded.timeName() <<
nl <<
nl;
277 runTimeExtruded.system(),
290 const bool flipNormals(
dict.
get<
bool>(
"flipNormals"));
293 const ExtrudeMode
mode = ExtrudeModeNames.get(
"constructFrom",
dict);
298 Info<<
"Extruding from " << ExtrudeModeNames[
mode]
299 <<
" using model " << model().type() <<
endl;
302 Info<<
"Flipping normals before extruding" <<
endl;
306 Info<<
"Collapsing edges < " << mergeTol <<
" of bounding box" <<
endl;
310 Info<<
"Not collapsing any edges after extrusion" <<
endl;
333 if (flipNormals &&
mode == MESH)
336 <<
"Flipping normals not supported for extrusions from mesh." 360 if (sourcePatches.
size() == 1)
362 frontPatchName = sourcePatches[0];
365 Info<<
"Extruding patches " << sourcePatches
366 <<
" on mesh " << sourceCasePath <<
nl 372 Info<<
"Extruding faceZones " << sourceFaceZones
373 <<
" on mesh " << sourceCasePath <<
nl 396 if (sourceFaceZones.
size())
398 zoneFaces(
mesh.
faceZones(), sourceFaceZones, meshFaces, faceFlips);
402 meshFaces = patchFaces(
patches, sourcePatches);
413 label meshFacei = meshFaces[i];
424 bool zoneFlip =
false;
451 if (map().hasMotionPoints())
478 extrudePatch.meshEdges
545 Info<<
"Adding overall " << nAdded <<
" processor patches." <<
endl;
567 label nbrProci = patchToNbrProc[patchi];
569 Pout<<
"Adding patch " << patchi
571 <<
" and " << nbrProci
603 findPatchID(
patches, backPatchName)
608 pointField layer0Points(extrudePatch.nPoints());
609 pointField displacement(extrudePatch.nPoints());
610 forAll(displacement, pointi)
612 const vector& patchNormal = extrudePatchPointNormals[pointi];
615 layer0Points[pointi] = model()
617 extrudePatch.localPoints()[pointi],
622 point extrudePt = model()
624 extrudePatch.localPoints()[pointi],
628 displacement[pointi] = extrudePt - layer0Points[pointi];
634 if (
gMax(
mag(layer0Points-extrudePatch.localPoints())) > SMALL)
636 Info<<
"Moving mesh to layer0 points since differ from original" 637 <<
" points - this can happen for wedge extrusions." <<
nl 641 forAll(extrudePatch.meshPoints(), i)
643 newPoints[extrudePatch.meshPoints()[i]] = layer0Points[i];
650 labelList nFaceLayers(extrudePatch.size(), model().nLayers());
653 labelList nPointLayers(extrudePatch.nPoints(), model().nLayers());
656 vectorField firstLayerDisp(displacement*model().sumThickness(1));
698 layerExtrude.setRefinement
720 forAll(layerExtrude.addedPoints(), pointi)
722 const labelList& pPoints = layerExtrude.addedPoints()[pointi];
725 label meshPointi = pPoints[pPointi];
731 extrudePatch.localPoints()[pointi],
732 extrudePatchPointNormals[pointi],
740 )[meshPointi] = modelPt;
749 forAll(backPatchFaces, patchFacei)
751 backPatchFaces[patchFacei] = layerFaces[patchFacei].
first();
752 frontPatchFaces[patchFacei] = layerFaces[patchFacei].
last();
771 runTimeExtruded.constant(),
780 layerExtrude.updateMesh
790 map().reverseFaceMap(),
795 map().reverseFaceMap(),
810 layerExtrude.addedCells
813 layerExtrude.layerFaces()
818 const labelList& aCells = addedCells[facei];
819 addedCellsSet.
insert(aCells);
828 Info<<
"Extruding surfaceMesh read from file " << surfName <<
nl 839 faces[i] = fMesh[i].reverseFace();
843 Info<<
"Extruding surface with :" <<
nl 844 <<
" points : " << fMesh.points().size() <<
nl 845 <<
" faces : " << fMesh.size() <<
nl 846 <<
" normals[0] : " << fMesh.faceNormals()[0]
850 meshFromSurface.
reset 857 runTimeExtruded.constant(),
867 frontPatchName =
"originalPatch";
868 frontPatchFaces = patchFaces
873 backPatchName =
"otherSide";
874 backPatchFaces = patchFaces
891 const scalar mergeDim = mergeTol * bb.
minDim();
893 Info<<
"Mesh bounding box : " << bb <<
nl 894 <<
" with span : " << bb.
span() <<
nl 895 <<
"Merge distance : " << mergeDim <<
nl 904 Info<<
"Collapsing edges < " << mergeDim <<
" ..." <<
nl <<
endl;
917 const edge&
e = edges[edgeI];
923 Info<<
"Merging edge " <<
e <<
" since length " << d
924 <<
" << " << mergeDim <<
nl;
927 collapsePointToLocation.set(
e[1],
points[
e[0]]);
935 collapser.consistentCollapse
939 collapsePointToLocation,
948 bool anyChange = collapser.setRefinement(allPointInfo, meshMod);
959 updateFaceLabels(map(), frontPatchFaces);
960 updateFaceLabels(map(), backPatchFaces);
961 updateCellSet(map(), addedCellsSet);
969 if (map().hasMotionPoints())
982 if (isType<extrudeModels::wedge>(model()))
984 changeFrontBackPatches<wedgePolyPatch>
991 else if (isType<extrudeModels::plane>(model()))
993 changeFrontBackPatches<emptyPolyPatch>
1005 if (
dict.
get<
bool>(
"mergeFaces"))
1010 <<
"Cannot stitch front and back of extrusion since" 1011 <<
" in 'mesh' mode (extrusion appended to mesh)." 1015 Info<<
"Assuming full 360 degree axisymmetric case;" 1016 <<
" stitching faces on patches " 1017 << frontPatchName <<
" and " 1018 << backPatchName <<
" together ..." <<
nl <<
endl;
1020 if (frontPatchFaces.
size() != backPatchFaces.
size())
1023 <<
"Differing number of faces on front (" 1024 << frontPatchFaces.
size() <<
") and back (" 1025 << backPatchFaces.
size() <<
")" 1031 stitcher.setSize(1);
1033 const word cutZoneName(
"originalCutFaceZone");
1064 perfectStitcher.setRefinement
1094 updateCellSet(map(), addedCellsSet);
1102 if (map().hasMotionPoints())
1122 cellSet addedCells(
mesh,
"addedCells", addedCellsSet);
1123 Info<<
"Writing added cells to cellSet " << addedCells.name()
1125 if (!addedCells.write())
1128 << addedCells.name()
1135 refDataPtr->
write();
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
void removeFvBoundary()
Remove boundary patches. Warning: fvPatchFields hold ref to these fvPatches.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const fileName & facesInstance() const
Return the current instance directory for faces.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
label nPoints() const noexcept
Number of mesh points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
const word & regionName() const
The mesh region name or word::null if polyMesh::defaultRegion.
const labelListList & pointEdges() const
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values within a list.
PtrList< T > clone(Args &&... args) const
Make a copy by cloning each of the list elements.
constexpr char nl
The newline '\n' character (0x0a)
void setSize(const label n, unsigned int val=0u)
Alias for resize()
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
T & first()
Access first element of the list, position [0].
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
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:
static bool & parRun() noexcept
Test if this a parallel run.
Does polyTopoChanges to remove edges. Can remove faces due to edge collapse but can not remove cells ...
label collapseEdge(triSurface &surf, const scalar minLen)
Keep collapsing all edges < minLen.
A bounding box defined in terms of min/max extrema points.
static std::string path(const std::string &str)
Return directory path name (part before last /)
Ignore writing from objectRegistry::writeObject()
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
label nFaces() const noexcept
Number of mesh faces.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
labelList faceLabels(nFaceLabels)
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
fileName objectPath() const
The complete path + object name.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
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.
#define forAll(list, i)
Loop across all elements in list.
const labelList & reverseFaceMap() const noexcept
Reverse face map.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
label size() const noexcept
The number of elements in table.
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 dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning 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...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
static word defaultRegion
Return the default region name.
wordList names() const
Return a list of patch names.
label size() const noexcept
The number of entries in the list.
const labelList & reverseCellMap() const noexcept
Reverse cell map.
void addZones(PtrList< pointZone > &&pz, PtrList< faceZone > &&fz, PtrList< cellZone > &&cz)
Add mesh zones.
virtual const labelList & faceOwner() const
Return face owner.
Reading is optional [identical to LAZY_READ].
static const word null
An empty word.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
virtual const faceList & faces() const
Return raw faces.
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
static word controlDictName
The default control dictionary name (normally "controlDict")
void updateMesh(const mapPolyMesh &)
Update local numbering for changed mesh.
label nEdges() const
Number of mesh edges.
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
void removeBoundary()
Remove boundary patches.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
Type gMax(const FieldField< Field, Type > &f)
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
void addFvPatches(polyPatchList &plist, const bool validBoundary=true)
Add boundary patches. Constructor helper.
static autoPtr< extrudeModel > New(const dictionary &dict)
Select null constructed.
T & last()
Access last element of the list, position [size()-1].
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
List< word > wordList
List of word.
Calculates points shared by more than two processor patches or cyclic patches.
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
string & expand(const bool allowEmpty=false)
Inplace expand initial tags, tildes, and all occurrences of environment variables as per stringOps::e...
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
A collection of cell labels.
Direct mesh changes based on v1.3 polyTopoChange syntax.
void transfer(HashTable< T, Key, Hash > &rhs)
Transfer contents into this table.
const polyBoundaryMesh & patches
Automatically write from objectRegistry::writeObject()
vector span() const
The bounding box span (from minimum to maximum)
messageStream Info
Information stream (stdout output on master, null elsewhere)
const boundBox & bounds() const noexcept
Return mesh bounding box.
static labelListList globalEdgeFaces(const polyMesh &, const globalIndex &globalFaces, const indirectPrimitivePatch &pp)
Per patch edge the pp faces (in global indices) using it.
Various for reading/decomposing/reconstructing/distributing refinement data.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Mesh consisting of general polyhedral cells.
A subset of mesh faces organised as a primitive patch.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
Hack of attachDetach to couple patches when they perfectly align. Does not decouple. Used by stitchMesh app. Does geometric matching.
A patch is a list of labels that address the faces in the global face list.
void addPatches(polyPatchList &plist, const bool validBoundary=true)
Add boundary patches.
Foam::argList args(argc, argv)
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
Defines the attributes of an object for which implicit objectRegistry management is supported...
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Bookkeeping for patch definitions.
A List with indirect addressing.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
scalar minDim() const
Smallest length/height/width dimension.
Do not request registration (bool: false)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static IOobject selectIO(const IOobject &io, const fileName &altFile, const word &ioName="")
Return the IOobject, but also consider an alternative file name.
static constexpr const zero Zero
Global zero (0)