59 enum class extrudeSurfaceType
81 <<
"Cannot find patch " <<
name
82 <<
" in the source mesh.\n"
83 <<
"Valid patch names are " <<
patches.names()
151 faceLabels[
n] = pp.
start()+j;
172 faceLabels[i] = pp.
start() + i;
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
264 int main(
int argc,
char *argv[])
284 const extrudeSurfaceType
mode = extrudeSurfaceTypeNames.read
292 Info<<
"Extruding from " << extrudeSurfaceTypeNames[
mode]
293 <<
" using model " << model().type() <<
endl;
296 Info<<
"Flipping normals before extruding" <<
endl;
300 Info<<
"Collapsing edges < " << mergeTol <<
" of bounding box" <<
endl;
304 Info<<
"Not collapsing any edges after extrusion" <<
endl;
327 <<
"Flipping normals not supported for extrusions from mesh."
332 sourceCasePath.expand();
343 if (sourcePatches.size() == 1)
345 frontPatchName = sourcePatches[0];
349 if (zoneNames.
size() == 1)
351 if (zoneNames[0] ==
"patchNames")
353 zoneNames = sourcePatches;
357 zoneNames =
wordList(sourcePatches.size(), zoneNames[0]);
360 else if (zoneNames.
size() && zoneNames.
size() != sourcePatches.size())
363 <<
"Number of zoneNames "
364 "does not equal the number of sourcePatches"
368 Info<<
"Extruding patches " << sourcePatches
369 <<
" on mesh " << sourceCasePath <<
nl
386 ? findPatchZones(
mesh, zoneNames)
407 if (
mode == extrudeSurfaceType::patch && flipNormals)
414 label patchFacei = patchFaces[i];
463 extrudePatch.meshEdges
518 Info<<
"Adding overall " << nAdded <<
" processor patches." <<
endl;
544 <<
" and " << nbrProci
570 if (
mode == extrudeSurfaceType::patch)
572 dict.
lookup(
"exposedPatchName") >> backPatchName;
581 pointField layer0Points(extrudePatch.nPoints());
582 pointField displacement(extrudePatch.nPoints());
583 forAll(displacement, pointi)
585 const vector& patchNormal = extrudePatchPointNormals[pointi];
588 layer0Points[pointi] = model()
590 extrudePatch.localPoints()[pointi],
595 point extrudePt = model()
597 extrudePatch.localPoints()[pointi],
601 displacement[pointi] = extrudePt - layer0Points[pointi];
607 if (
gMax(
mag(layer0Points-extrudePatch.localPoints())) > small)
609 Info<<
"Moving mesh to layer0 points since differ from original"
610 <<
" points - this can happen for wedge extrusions." <<
nl
614 forAll(extrudePatch.meshPoints(), i)
616 newPoints[extrudePatch.meshPoints()[i]] = layer0Points[i];
623 labelList nFaceLayers(extrudePatch.size(), model().nLayers());
626 labelList nPointLayers(extrudePatch.nPoints(), model().nLayers());
629 vectorField firstLayerDisp(displacement*model().sumThickness(1));
645 layerExtrude.setRefinement
663 forAll(layerExtrude.addedPoints(), pointi)
665 const labelList& pPoints = layerExtrude.addedPoints()[pointi];
668 label meshPointi = pPoints[pPointi];
674 extrudePatch.localPoints()[pointi],
675 extrudePatchPointNormals[pointi],
683 )[meshPointi] = modelPt;
692 forAll(backPatchFaces, patchFacei)
694 backPatchFaces[patchFacei] = layerFaces[patchFacei].
first();
695 frontPatchFaces[patchFacei] = layerFaces[patchFacei].
last();
706 runTimeExtruded.constant(),
715 layerExtrude.updateZones(meshFromMesh());
717 meshFromMesh().topoChange(map);
719 layerExtrude.topoChange
729 map().reverseFaceMap(),
734 map().reverseFaceMap(),
743 layerExtrude.addedCells
746 layerExtrude.layerFaces()
751 const labelList& aCells = addedCells[facei];
754 addedCellsSet.
insert(aCells[i]);
765 Info<<
"Extruding surfaceMesh read from file " << surfName <<
nl
776 faces[i] = fMesh[i].reverseFace();
780 Info<<
"Extruding surface with :" <<
nl
781 <<
" points : " << fMesh.points().size() <<
nl
782 <<
" faces : " << fMesh.size() <<
nl
783 <<
" normals[0] : " << fMesh.faceNormals()[0]
787 meshFromSurface.
reset
794 runTimeExtruded.constant(),
804 frontPatchName =
"originalPatch";
805 frontPatchFaces = findPatchFaces
810 backPatchName =
"otherSide";
811 backPatchFaces = findPatchFaces
829 const scalar mergeDim = mergeTol * bb.
minDim();
831 Info<<
"Mesh bounding box : " << bb <<
nl
832 <<
" with span : " << span <<
nl
833 <<
"Merge distance : " << mergeDim <<
nl
842 Pout<<
"Collapsing edges < " << mergeDim <<
" ..." <<
nl <<
endl;
855 const edge&
e = edges[edgeI];
861 Pout<<
"Merging edge " <<
e <<
" since length " << d
862 <<
" << " << mergeDim <<
nl;
865 collapsePointToLocation.set(
e[1],
points[
e[0]]);
873 collapser.consistentCollapse
877 collapsePointToLocation,
886 bool anyChange = collapser.setRefinement(allPointInfo, meshMod);
898 updateFaceLabels(map(), frontPatchFaces);
899 updateFaceLabels(map(), backPatchFaces);
900 updateCellSet(map(), addedCellsSet);
910 if (isType<extrudeModels::wedge>(model()))
912 changeFrontBackPatches<wedgePolyPatch>
919 else if (isType<extrudeModels::plane>(model()))
921 changeFrontBackPatches<emptyPolyPatch>
939 <<
"Cannot stitch front and back of extrusion since"
940 <<
" in 'mesh' mode (extrusion appended to mesh)."
944 Info<<
"Assuming full 360 degree axisymmetric case;"
945 <<
" stitching faces on patches "
946 << frontPatchName <<
" and "
947 << backPatchName <<
" together ..." <<
nl <<
endl;
949 if (frontPatchFaces.
size() != backPatchFaces.
size())
952 <<
"Differing number of faces on front ("
953 << frontPatchFaces.
size() <<
") and back ("
954 << backPatchFaces.
size() <<
")"
970 perfectStitcher.setRefinement
1000 updateCellSet(map(), addedCellsSet);
1005 const fileName meshInstanceExtruded =
1011 runTimeExtruded.name(),
1039 <<
"Failed writing " <<
mesh.
name()
1047 cellSet addedCells(
mesh,
"addedCells", addedCellsSet);
1048 Info<<
"Writing added cells to cellSet " << addedCells.name()
1050 if (!addedCells.write())
1053 <<
"Failed writing " << addedCells.name()
#define forAll(list, i)
Loop across all elements in list.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
bool insert(const Key &key)
Insert a new entry.
void transfer(HashTable< T, Key, Hash > &)
Transfer the contents of the argument table into this table.
label size() const
Return number of elements in table.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
fileName relativeObjectPath() const
Return complete relativePath + object name.
autoPtr< IOobject > clone() const
Clone.
A List with indirect addressing.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
void size(const label)
Override size to be inconsistent with allocated storage.
static const List< word > & null()
Return a null List.
void setSize(const label)
Reset size of List.
Initialise the NamedEnum HashTable from the static list of names.
autoPtr< T > set(const label, const word &key, T *)
Set element to pointer provided and return old element.
label findIndex(const word &key) const
Return the index of the given the key or -1 if not found.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static word controlDictName
The default control dictionary name (normally "controlDict")
T & first()
Return the first element of the list.
label size() const
Return the number of elements in the UList.
T & last()
Return the last element of the list.
static bool & parRun()
Is this a parallel run?
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
label size() const
Return the number of elements in the UPtrList.
Adds layers of cells to outside of polyPatch. Can optionally create stand-alone extruded mesh (addToM...
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.
static labelListList globalEdgeFaces(const polyMesh &, const globalIndex &globalFaces, const indirectPrimitivePatch &pp)
Per patch edge the pp faces (in global indices) using it. Uses.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
A bounding box defined in terms of the points at its extremities.
scalar minDim() const
Smallest length/height/width dimension.
vector span() const
The bounding box span (from minimum to maximum)
A collection of cell labels.
Named list of cell indices representing a sub-set of the mesh.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
T lookupOrDefault(const word &, const T &) const
Find and return a T, if not found return the given default.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Does polyTopoChanges to remove edges. Can remove faces due to edge collapse but can not remove cells ...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
static autoPtr< extrudeModel > New(const dictionary &)
Select null constructed.
A class for handling file names.
word name() const
Return file name (part beyond last /)
static const fileName null
An empty fileName.
fileName path() const
Return directory path name (part before last /)
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
void addFvPatches(const List< polyPatch * > &, const bool validBoundary=true)
Add boundary patches. Constructor helper.
void removeFvBoundary()
Remove boundary patches. Warning: fvPatchFields hold ref to.
const word & name() const
Return reference to name.
virtual void topoChange(const polyTopoChangeMap &map)
Update mesh corresponding to the given map.
virtual void setPoints(const pointField &)
Reset the points.
const polyMesh & poly() const
Return reference to polyMesh.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Calculates points shared by more than two processor patches or cyclic patches.
label index() const
Return the index of this patch in the boundaryMesh.
const word & name() const
Return name.
Calculates zone number for every face of patch.
Hack of attachDetach to couple patches when they perfectly align. Does not decouple....
Mesh consisting of general polyhedral cells.
const cellZoneList & cellZones() const
Return cell zones.
static word defaultRegion
Return the default region name.
const polyBoundaryMesh & boundary() const
Return boundary mesh.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
void addPatches(const List< polyPatch * > &, const bool validBoundary=true)
Add boundary patches.
virtual const pointField & points() const
Return raw points.
void removeBoundary()
Remove boundary patches.
void setInstance(const fileName &)
Set the instance for mesh files.
static fileName meshDirInstance(const IOobject &io)
Return the instance of the polyMesh directory. Returns.
const boundBox & bounds() const
Return mesh bounding box.
A patch is a list of labels that address the faces in the global face list.
label start() const
Return start label of this patch in the polyMesh face list.
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reverseCellMap() const
Reverse cell map.
const labelList & reverseFaceMap() const
Reverse face map.
Direct mesh changes based on v1.3 polyTopoChange syntax.
const labelListList & pointEdges() const
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
Neighbour processor patch.
virtual bool write(const bool write=true) const
Write using setting from DB.
A class for handling words, derived from string.
static const word null
An empty word.
label collapseEdge(triSurface &surf, const scalar minLen)
Keep collapsing all edges < minLen.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
const fvPatchList & patches
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< word > wordList
A List of words.
mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file mode.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const word & regionName(const solver ®ion)
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Type gMax(const UList< Type > &f, const label comm)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
IOdictionary systemDict(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion, const fileName &path=fileName::null)
wordList patchNames(nPatches)
faceListList boundary(nPatches)
Foam::argList args(argc, argv)