80 { ExtrudeMode::MESH,
"mesh" },
82 { ExtrudeMode::SURFACE,
"surface" },
93 <<
"Cannot find patch " <<
name 94 <<
" in the source mesh.\n" 120 faceLabels[
n++] = pp.
start()+j;
149 const boolList& ppFlip = pp.flipMap();
152 faceLabels[
n] = pp[i];
153 faceFlip[
n] = ppFlip[i];
169 label oldFacei = faceLabels[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." 263 << runTimeExtruded.timeName() <<
nl <<
endl;
267 Info<<
"Create mesh for time = " 268 << runTimeExtruded.timeName() <<
nl <<
endl;
279 runTimeExtruded.system(),
292 const bool flipNormals(
dict.
get<
bool>(
"flipNormals"));
295 const ExtrudeMode
mode = ExtrudeModeNames.get(
"constructFrom",
dict);
300 Info<<
"Extruding from " << ExtrudeModeNames[
mode]
301 <<
" using model " << model().type() <<
endl;
304 Info<<
"Flipping normals before extruding" <<
endl;
308 Info<<
"Collapsing edges < " << mergeTol <<
" of bounding box" <<
endl;
312 Info<<
"Not collapsing any edges after extrusion" <<
endl;
335 if (flipNormals &&
mode == MESH)
338 <<
"Flipping normals not supported for extrusions from mesh." 362 if (sourcePatches.
size() == 1)
364 frontPatchName = sourcePatches[0];
367 Info<<
"Extruding patches " << sourcePatches
368 <<
" on mesh " << sourceCasePath <<
nl 374 Info<<
"Extruding faceZones " << sourceFaceZones
375 <<
" on mesh " << sourceCasePath <<
nl 398 if (sourceFaceZones.
size())
400 zoneFaces(
mesh.
faceZones(), sourceFaceZones, meshFaces, faceFlips);
404 meshFaces = patchFaces(
patches, sourcePatches);
415 label meshFacei = meshFaces[i];
426 bool zoneFlip =
false;
453 if (map().hasMotionPoints())
480 extrudePatch.meshEdges
547 Info<<
"Adding overall " << nAdded <<
" processor patches." <<
endl;
569 label nbrProci = patchToNbrProc[patchi];
571 Pout<<
"Adding patch " << patchi
573 <<
" and " << nbrProci
605 findPatchID(
patches, backPatchName)
610 pointField layer0Points(extrudePatch.nPoints());
611 pointField displacement(extrudePatch.nPoints());
612 forAll(displacement, pointi)
614 const vector& patchNormal = extrudePatchPointNormals[pointi];
617 layer0Points[pointi] = model()
619 extrudePatch.localPoints()[pointi],
624 point extrudePt = model()
626 extrudePatch.localPoints()[pointi],
630 displacement[pointi] = extrudePt - layer0Points[pointi];
636 if (
gMax(
mag(layer0Points-extrudePatch.localPoints())) > SMALL)
638 Info<<
"Moving mesh to layer0 points since differ from original" 639 <<
" points - this can happen for wedge extrusions." <<
nl 643 forAll(extrudePatch.meshPoints(), i)
645 newPoints[extrudePatch.meshPoints()[i]] = layer0Points[i];
652 labelList nFaceLayers(extrudePatch.size(), model().nLayers());
655 labelList nPointLayers(extrudePatch.nPoints(), model().nLayers());
658 vectorField firstLayerDisp(displacement*model().sumThickness(1));
700 layerExtrude.setRefinement
722 forAll(layerExtrude.addedPoints(), pointi)
724 const labelList& pPoints = layerExtrude.addedPoints()[pointi];
727 label meshPointi = pPoints[pPointi];
733 extrudePatch.localPoints()[pointi],
734 extrudePatchPointNormals[pointi],
742 )[meshPointi] = modelPt;
751 forAll(backPatchFaces, patchFacei)
753 backPatchFaces[patchFacei] = layerFaces[patchFacei].
first();
754 frontPatchFaces[patchFacei] = layerFaces[patchFacei].
last();
773 runTimeExtruded.constant(),
782 layerExtrude.updateMesh
792 map().reverseFaceMap(),
797 map().reverseFaceMap(),
812 layerExtrude.addedCells
815 layerExtrude.layerFaces()
820 const labelList& aCells = addedCells[facei];
821 addedCellsSet.
insert(aCells);
830 Info<<
"Extruding surfaceMesh read from file " << surfName <<
nl 841 faces[i] = fMesh[i].reverseFace();
845 Info<<
"Extruding surface with :" <<
nl 846 <<
" points : " << fMesh.points().size() <<
nl 847 <<
" faces : " << fMesh.size() <<
nl 848 <<
" normals[0] : " << fMesh.faceNormals()[0]
852 meshFromSurface.
reset 859 runTimeExtruded.constant(),
869 frontPatchName =
"originalPatch";
870 frontPatchFaces = patchFaces
875 backPatchName =
"otherSide";
876 backPatchFaces = patchFaces
893 const scalar mergeDim = mergeTol * bb.
minDim();
895 Info<<
"Mesh bounding box : " << bb <<
nl 896 <<
" with span : " << bb.
span() <<
nl 897 <<
"Merge distance : " << mergeDim <<
nl 906 Info<<
"Collapsing edges < " << mergeDim <<
" ..." <<
nl <<
endl;
919 const edge&
e = edges[edgeI];
925 Info<<
"Merging edge " <<
e <<
" since length " << d
926 <<
" << " << mergeDim <<
nl;
929 collapsePointToLocation.set(
e[1],
points[
e[0]]);
937 collapser.consistentCollapse
941 collapsePointToLocation,
950 bool anyChange = collapser.setRefinement(allPointInfo, meshMod);
961 updateFaceLabels(map(), frontPatchFaces);
962 updateFaceLabels(map(), backPatchFaces);
963 updateCellSet(map(), addedCellsSet);
971 if (map().hasMotionPoints())
984 if (isType<extrudeModels::wedge>(model()))
986 changeFrontBackPatches<wedgePolyPatch>
993 else if (isType<extrudeModels::plane>(model()))
995 changeFrontBackPatches<emptyPolyPatch>
1007 if (
dict.
get<
bool>(
"mergeFaces"))
1012 <<
"Cannot stitch front and back of extrusion since" 1013 <<
" in 'mesh' mode (extrusion appended to mesh)." 1017 Info<<
"Assuming full 360 degree axisymmetric case;" 1018 <<
" stitching faces on patches " 1019 << frontPatchName <<
" and " 1020 << backPatchName <<
" together ..." <<
nl <<
endl;
1022 if (frontPatchFaces.
size() != backPatchFaces.
size())
1025 <<
"Differing number of faces on front (" 1026 << frontPatchFaces.
size() <<
") and back (" 1027 << backPatchFaces.
size() <<
")" 1033 stitcher.setSize(1);
1035 const word cutZoneName(
"originalCutFaceZone");
1066 perfectStitcher.setRefinement
1096 updateCellSet(map(), addedCellsSet);
1104 if (map().hasMotionPoints())
1124 cellSet addedCells(
mesh,
"addedCells", addedCellsSet);
1125 Info<<
"Writing added cells to cellSet " << addedCells.name()
1127 if (!addedCells.write())
1130 << addedCells.name()
1137 refDataPtr->
write();
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
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.
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
const labelListList & pointEdges() const
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values (not the indices) of 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.
label size() const noexcept
The number of elements in table.
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)
Number of this process (starting from masterNo() = 0)
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.
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.
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...
Foam::word regionName(Foam::polyMesh::defaultRegion)
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 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 point labels. The functionality it provides supports the discretisation on a...
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
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 Foam::string.
Reading required, file watched for runTime modification.
static word defaultRegion
Return the default region name.
wordList names() const
Return a list of patch names.
label size() const noexcept
The number of elements in the list.
void addZones(PtrList< pointZone > &&pz, PtrList< faceZone > &&fz, PtrList< cellZone > &&cz)
Add mesh zones.
virtual const labelList & faceOwner() const
Return face owner.
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.
virtual autoPtr< polyPatch > clone(const labelList &faceCells) const
Construct and return a clone, setting faceCells.
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.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
void removeBoundary()
Remove boundary patches.
const word & name() const noexcept
The patch name.
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.
const labelList & reverseCellMap() const
Reverse cell map.
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
A List of words.
Calculates points shared by more than two processor patches or cyclic patches.
const boundBox & bounds() const
Return mesh bounding box.
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...
A collection of cell labels.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label whichPatch(const label faceIndex) const
Return patch index for a given mesh face index.
void transfer(HashTable< T, Key, Hash > &rhs)
Transfer contents into this table.
label start() const
Return start label of this patch in the polyMesh face list.
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)
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.
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
label index() const noexcept
The index of this patch in the boundaryMesh.
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.
const labelList & reverseFaceMap() const
Reverse face map.
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)