Go to the documentation of this file.
48 #include "extrudedMesh.H"
105 dummyDict.
add(
"divSchemes", divDict);
107 dummyDict.
add(
"gradSchemes", gradDict);
109 dummyDict.
add(
"laplacianSchemes", laplDict);
143 <<
"Cannot find patch " <<
name
144 <<
" in the source mesh.\n"
145 <<
"Valid patch names are " <<
patches.names()
170 faceLabels[
n++] = pp.
start()+j;
187 label oldFaceI = faceLabels[i];
189 if (reverseMap[oldFaceI] >= 0)
191 newFaceLabels[newI++] = reverseMap[oldFaceI];
207 label oldCellI = cellLabels[i];
209 if (reverseMap[oldCellI] >= 0)
211 newCellLabels.
insert(reverseMap[oldCellI]);
218 template<
class PatchType>
222 const word& frontPatchName,
223 const word& backPatchName
237 if (patchI == frontPatchI || patchI == backPatchI)
269 const word modelType(
"linearDirection");
271 Info<<
"Selecting extrudeModel " << modelType <<
endl;
273 dictionaryConstructorTable::iterator cstrIter =
274 dictionaryConstructorTablePtr_->find(modelType);
276 if (cstrIter == dictionaryConstructorTablePtr_->end())
279 <<
"Unknown extrudeModel type "
280 << modelType <<
nl <<
nl
281 <<
"Valid extrudeModel types are :" <<
nl
282 << dictionaryConstructorTablePtr_->sortedToc() <<
nl
289 std::string
replaceChar(std::string & SourceString,
const std::string & strsrc,
const std::string & strdst)
295 std::string stringsource_new = SourceString;
297 while ((
pos = stringsource_new.find(strsrc,
pos)) != std::string::npos)
299 stringsource_new.replace(
pos, srclen, strdst);
302 return stringsource_new;
316 s.erase(0,
s.find_first_not_of(
" "));
317 s.erase(
s.find_last_not_of(
" ") + 1);
318 s.erase(0,
s.find_first_not_of(
"\t"));
319 s.erase(
s.find_last_not_of(
"\t") + 1);
323 std::vector<std::string>
splitstring (std::string SourceString, std::string strSplit =
" ",
int nSkip = 0 )
325 std::vector<std::string> vecStr;
332 std::string stringsource_new;
333 for (
int i = 0; i < (int)SourceString.length(); i++)
335 if (SourceString[i] == aa || SourceString[i] == bb || SourceString[i] == cc || SourceString[i] == dd)
339 stringsource_new.push_back(SourceString[i]);
344 while (ePos != std::string::npos)
346 if (sPos != ePos) vecStr.push_back(stringsource_new.substr(sPos, ePos - sPos).c_str());
347 sPos = ePos + strSplit.size();
348 ePos = stringsource_new.find(strSplit, sPos);
350 if (sPos < stringsource_new.size()) vecStr.push_back(
trim(stringsource_new.substr(sPos, stringsource_new.size() - sPos)).c_str());
361 int main(
int argc,
char *argv[])
375 << runTimeExtruded.timeName() <<
nl <<
endl;
380 Info<<
"Create mesh for time = "
381 << runTimeExtruded.timeName() <<
nl <<
endl;
389 std::string dictPara =
"";
393 dictPara =
args[
"dict"];
394 std::vector<std::string> paraList =
splitstring(dictPara,
" ");
395 if (paraList[0]==
"pkpmchenjia1008")
415 std::vector<std::string> nameList =
splitstring(paraList[2],
" ");
417 for (
int i=0;i<nameList.size();i++)
419 patchestmp.
append(nameList[i]);
421 dict.
add(
"sourcePatches", patchestmp);
424 dict.
add(
"nLayers", std::atoi(paraList[3].c_str()));
425 dict.
add(
"expansionRatio", std::atof(paraList[4].c_str()));
430 subDict.
add(
"axisPt",axisPt);
432 std::vector<std::string> vectorlist =
splitstring(paraList[5],
" ");
433 v1=std::atof(vectorlist[0].c_str());
434 v2=std::atof(vectorlist[1].c_str());
435 v3=std::atof(vectorlist[2].c_str());
437 subDict.
add(
"direction",directionCom);
438 subDict.
add(
"thickness",std::atoi(paraList[6].c_str()));
439 dict.
add(
"linearDirectionCoeffs",subDict);
482 Info<<
"Flipping normals before extruding" <<
endl;
486 Info<<
"Collapsing edges < " << mergeTol <<
" of bounding box" <<
endl;
490 Info<<
"Not collapsing any edges after extrusion" <<
endl;
513 <<
"Flipping normals not supported for extrusions from mesh."
532 dict.
lookup(
"sourcePatches") >> sourcePatches;
534 if (sourcePatches.
size() == 1)
536 frontPatchName = sourcePatches[0];
568 label meshFaceI = meshFaces[i];
579 bool zoneFlip =
false;
606 if (map().hasMotionPoints())
698 Info<<
"Adding overall " << nAdded <<
" processor patches." <<
endl;
720 label nbrProcI = patchToNbrProc[patchI];
728 Pout<<
"Adding patch " << patchI
731 <<
" and " << nbrProcI
761 dict.
lookup(
"exposedPatchName") >> backPatchName;
772 forAll(displacement, pointI)
774 const vector& patchNormal = extrudePatchPointNormals[pointI];
777 layer0Points[pointI] = model()
784 point extrudePt = model()
790 displacement[pointI] = extrudePt - layer0Points[pointI];
798 Info<<
"Moving mesh to layer0 points since differ from original"
799 <<
" points - this can happen for wedge extrusions." <<
nl
805 newPoints[extrudePatch.
meshPoints()[i]] = layer0Points[i];
812 labelList nFaceLayers(extrudePatch.size(), model().nLayers());
818 vectorField firstLayerDisp(displacement*model().sumThickness(1));
860 label meshPointI = pPoints[pPointI];
867 extrudePatchPointNormals[pointI],
875 )[meshPointI] = modelPt;
884 forAll(backPatchFaces, patchFaceI)
886 backPatchFaces[patchFaceI] = layerFaces[patchFaceI].first();
887 frontPatchFaces[patchFaceI] = layerFaces[patchFaceI].last();
901 runTimeExtruded.constant(),
920 map().reverseFaceMap(),
925 map().reverseFaceMap(),
942 const labelList& aCells = addedCells[faceI];
945 addedCellsSet.
insert(aCells[i]);
956 Info<<
"Extruding surfaceMesh read from file " << surfName <<
nl
967 faces[i] = fMesh[i].reverseFace();
971 Info<<
"Extruding surface with :" <<
nl
972 <<
" points : " << fMesh.points().
size() <<
nl
973 <<
" faces : " << fMesh.
size() <<
nl
974 <<
" normals[0] : " << fMesh.faceNormals()[0]
978 meshFromSurface.
reset
985 runTimeExtruded.constant(),
995 frontPatchName =
"originalPatch";
1001 backPatchName =
"otherSide";
1012 meshFromMesh.
valid()
1020 const scalar mergeDim = mergeTol * bb.
minDim();
1022 Info<<
"Mesh bounding box : " << bb <<
nl
1023 <<
" with span : " << span <<
nl
1024 <<
"Merge distance : " << mergeDim <<
nl
1033 Info<<
"Collapsing edges < " << mergeDim <<
" ..." <<
nl <<
endl;
1046 const edge&
e = edges[edgeI];
1052 Info<<
"Merging edge " <<
e <<
" since length " << d
1053 <<
" << " << mergeDim <<
nl;
1056 collapsePointToLocation.set(
e[1],
points[
e[0]]);
1068 collapsePointToLocation,
1077 bool anyChange = collapser.
setRefinement(allPointInfo, meshMod);
1093 if (map().hasMotionPoints())
1106 if (isType<extrudeModels::wedge>(model()))
1108 changeFrontBackPatches<wedgePolyPatch>
1115 else if (isType<extrudeModels::plane>(model()))
1117 changeFrontBackPatches<emptyPolyPatch>
1135 <<
"Cannot stitch front and back of extrusion since"
1136 <<
" in 'mesh' mode (extrusion appended to mesh)."
1140 Info<<
"Assuming full 360 degree axisymmetric case;"
1141 <<
" stitching faces on patches "
1142 << frontPatchName <<
" and "
1143 << backPatchName <<
" together ..." <<
nl <<
endl;
1145 if (frontPatchFaces.
size() != backPatchFaces.
size())
1148 <<
"Differing number of faces on front ("
1149 << frontPatchFaces.
size() <<
") and back ("
1150 << backPatchFaces.
size() <<
")"
1159 const word cutZoneName(
"originalCutFaceZone");
1223 if (map().hasMotionPoints())
1242 cellSet addedCells(
mesh,
"addedCells", addedCellsSet);
1243 Info<<
"Writing added cells to cellSet " << addedCells.
name()
1245 if (!addedCells.
write())
1248 << addedCells.
name()
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
virtual const pointField & points() const
Return raw points.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
double doubleScalar
Double precision floating point scalar type.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
int main(int argc, char *argv[])
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
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.
void createDummyFvMeshFiles(const polyMesh &mesh, const word ®ionName)
A class for handling words, derived from string.
A class for handling file names.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
static word defaultRegion
Return the default region name.
#define forAll(list, i)
Loop across all elements in list.
void transfer(HashTable< T, Key, Hash > &)
Transfer the contents of the argument table into this table.
std::vector< std::string > splitstring(std::string SourceString, std::string strSplit=" ", int nSkip=0)
static labelListList globalEdgeFaces(const polyMesh &, const globalIndex &globalFaces, const indirectPrimitivePatch &pp)
Per patch edge the pp faces (in global indices) using it. Uses.
autoPtr< mapPolyMesh > changeMesh(polyMesh &mesh, const bool inflate, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void addFvPatches(const List< polyPatch * > &, const bool validBoundary=true)
Add boundary patches. Constructor helper.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
List of mesh modifiers defining the mesh dynamics.
void modifyFace(const face &f, const label faceI, const label own, const label nei, const bool flipFaceFlux, const label patchID, const label zoneID, const bool zoneFlip)
Modify vertices or cell of face.
static bool & parRun()
Is this a parallel run?
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Return labels of patch edges in the global edge list using.
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...
fileName path() const
Return directory path name (part before last /)
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
virtual bool write() const
Write using setting from DB.
void removeFvBoundary()
Remove boundary patches. Warning: fvPatchFields hold ref to.
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.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
dimensioned< scalar > mag(const dimensioned< Type > &)
const labelListList & pointEdges() const
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
const labelListList & addedPoints() const
Added points per patch point.
labelList patchFaces(const polyBoundaryMesh &patches, const wordList &names)
static autoPtr< extrudeModel > New(const dictionary &)
Select null constructed.
const List< Face > & faces() const
Return const access to the faces.
mode_t mode(const fileName &)
Return the file mode.
Mesh consisting of general polyhedral cells.
word name() const
Return file name (part beyond last /)
void changeFrontBackPatches(polyMesh &mesh, const word &frontPatchName, const word &backPatchName)
const faceZoneMesh & faceZones() const
Return face zone mesh.
List< word > wordList
A List of words.
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
Does polyTopoChanges to remove edges. Can remove faces due to edge collapse but can not remove cells ...
fileName objectPath() const
Return complete path + object name.
vector span() const
The bounding box span (from minimum to maximum)
virtual bool write() const
Write mesh using IO settings from time.
bool headerOk()
Read and check header info.
const word dictName("particleTrackDict")
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void updateFaceLabels(const mapPolyMesh &map, labelList &faceLabels)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
const word & system() const
Return system name.
A subset of mesh faces organised as a primitive patch.
void append(const T &)
Append an element at the end of the list.
A patch is a list of labels that address the faces in the global face list.
virtual const labelList & faceOwner() const
Return face owner.
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.
const word & name() const
Return name.
Neighbour processor patch.
graph_traits< Graph >::vertices_size_type size_type
label findPatchID(const polyBoundaryMesh &patches, const word &name)
void consistentCollapse(const globalIndex &globalPoints, const labelList &pointPriority, const Map< point > &collapsePointToLocation, PackedBoolList &collapseEdge, List< pointEdgeCollapse > &allPointInfo, const bool allowCellCollapse=false) const
Ensure that the collapse is parallel consistent and update.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
label nPoints() const
Return number of points supporting patch faces.
A list of keyword definitions, which are a keyword followed by any number of values (e....
label size() const
Return number of elements in table.
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...
bool setRefinement(const List< pointEdgeCollapse > &allPointInfo, polyTopoChange &meshMod) const
Play commands into polyTopoChange to create mesh.
A collection of cell labels.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
const double e
Elementary charge.
List< bool > boolList
Bool container classes.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
label start() const
Return start label of this patch in the polyMesh face list.
void updateMesh(const mapPolyMesh &, const labelList &faceMap, const labelList &pointMap)
Update any locally stored mesh information. Gets additional.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
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 labelListList & layerFaces() const
Layer faces per patch face. See above.
const labelList & reverseFaceMap() const
Reverse face map.
void setInstance(const fileName &)
Set the instance for mesh files.
const boundBox & bounds() const
Return mesh bounding box.
void setSize(const label)
Reset size of List.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
const labelList & reverseCellMap() const
Reverse cell map.
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
prefixOSstream Pout(cout, "Pout")
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
void addPatches(const List< polyPatch * > &, const bool validBoundary=true)
Add boundary patches.
void updateCellSet(const mapPolyMesh &map, labelHashSet &cellLabels)
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)
Determine extrude information per patch edge:
Foam::autoPtr< IOobject > clone() const
Clone.
string & expand(const bool allowEmpty=false)
Expand initial tildes and all occurences of environment variables.
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set).
label size() const
Return the number of elements in the PtrList.
bool insert(const Key &key)
Insert a new entry.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
static const word null
An empty word.
bool optionFound(const word &opt) const
Return true if the named option is found.
A bounding box defined in terms of the points at its extremities.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
void reset(T *=0)
If object pointer already set, delete object and set to given.
const Time & time() const
Return the top-level database.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
void size(const label)
Override size to be inconsistent with allocated storage.
label collapseEdge(triSurface &surf, const scalar minLen)
Keep collapsing all edges < minLen.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Foam::argList args(argc, argv)
static word controlDictName
The default control dictionary name (normally "controlDict")
label size() const
The surface size is the number of faces.
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
const word & name() const
Return name.
label index() const
Return 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.
std::string trim(std::string s)
static const NamedEnum< ExtrudeMode, 3 > ExtrudeModeNames
Type gMax(const FieldField< Field, Type > &f)
std::string replaceChar(std::string &SourceString, const std::string &strsrc, const std::string &strdst)
word name(const complex &)
Return a string representation of a complex.
virtual const labelList & faceNeighbour() const
Return face neighbour.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
static labelListList addedCells(const polyMesh &, const labelListList &layerFaces)
Helper: get added cells per patch face.
Initialise the NamedEnum HashTable from the static list of names.
A list of faces which address into the list of points.
void setRefinement(const globalIndex &globalFaces, const labelListList &globalEdgeFaces, const scalarField &expansionRatio, const indirectPrimitivePatch &pp, const labelList &sidePatchID, const labelList &sideZoneID, const boolList &sideFlip, const labelList &inflateFaceID, const labelList &exposedPatchID, const labelList &nFaceLayers, const labelList &nPointLayers, const vectorField &firstLayerDisp, polyTopoChange &meshMod)
Play commands into polyTopoChange to create layers on top.
dimensionedScalar pos(const dimensionedScalar &ds)