73 bool zoneFlip =
false;
116 if (!isA<processorPolyPatch>(pp))
142 Info<<
"Removing zero-sized patch " << pp.
name()
143 <<
" type " << pp.type()
144 <<
" at position " << patchi <<
endl;
154 if (isA<processorPolyPatch>(pp))
171 Info<<
"Removing empty processor patch " << pp.
name()
172 <<
" at position " << patchi <<
endl;
178 if (nAllPatches != nOldPatches)
187 Info<<
"No patches removed." <<
endl;
190 delete allPatches[i];
205 isA<cyclicPolyPatch>(patches[patchi])
206 && refCast<const cyclicPolyPatch>(patches[patchi]).owner()
210 refCast<const cyclicPolyPatch>(patches[
patchi]);
215 Pout<<
"Writing " << cycPatch.
name()
216 <<
" faces to " << str.name() <<
endl;
228 Pout<<
"Writing " << nbrPatch.
name()
229 <<
" faces to " << str.
name() <<
endl;
240 OFstream str(prefix+cycPatch.
name()+nbrPatch.name()+
"_match.obj");
243 Pout<<
"Writing cyclic match as lines between face centres to " 255 str<<
"l " << vertI-1 <<
' ' << vertI <<
nl;
263 template<
class CombineOp>
268 const CombineOp& cop,
269 const point& nullValue
275 <<
"Number of values " << points.
size()
276 <<
" is not equal to the number of points in the mesh " 283 bool hasTransformation =
false;
295 isA<processorPolyPatch>(pp)
297 && refCast<const processorPolyPatch>(pp).owner()
301 refCast<const processorPolyPatch>(pp);
311 label nbrPointi = nbrPts[pointi];
312 if (nbrPointi >= 0 && nbrPointi < patchInfo.size())
314 patchInfo[nbrPointi] = points[meshPts[pointi]];
336 isA<processorPolyPatch>(pp)
338 && !refCast<const processorPolyPatch>(pp).owner()
342 refCast<const processorPolyPatch>(pp);
353 fromNbr >> nbrPatchInfo;
356 nbrPatchInfo.setSize(procPatch.
nPoints(), nullValue);
360 hasTransformation =
true;
372 label meshPointi = meshPts[pointi];
373 points[meshPointi] = nbrPatchInfo[pointi];
386 isA<cyclicPolyPatch>(pp)
387 && refCast<const cyclicPolyPatch>(pp).owner()
391 refCast<const cyclicPolyPatch>(pp);
402 const edge&
e = coupledPoints[i];
403 label point0 = meshPts[e[0]];
404 patchPoints[i] = points[point0];
409 hasTransformation =
true;
419 const edge&
e = coupledPoints[i];
420 label point1 = nbrMeshPts[e[1]];
421 points[point1] = patchPoints[i];
435 if (hasTransformation)
438 <<
"There are decomposed cyclics in this mesh with" 439 <<
" transformations." << endl
440 <<
"This is not supported. The result will be incorrect" 471 int main(
int argc,
char *argv[])
478 runTime.functionObjects().off();
495 const Switch writeCyclicMatch
507 if (writeCyclicMatch)
509 writeCyclicMatchObjs(
"initial_", mesh);
516 forAll(patchSources, addedI)
518 const dictionary& dict = patchSources[addedI];
519 addedPatchNames.insert(dict.
lookup(
"name"));
526 if (patchSources.size())
538 if (!isA<processorPolyPatch>(pp))
550 startFacei += pp.size();
554 forAll(patchSources, addedI)
556 const dictionary& dict = patchSources[addedI];
560 label destPatchi = patches.findPatchID(patchName);
562 if (destPatchi == -1)
566 destPatchi = allPatches.size();
568 Info<<
"Adding new patch " << patchName
569 <<
" as patch " << destPatchi
570 <<
" from " << patchDict <<
endl;
572 patchDict.set(
"nFaces", 0);
573 patchDict.set(
"startFace", startFacei);
589 Info<<
"Patch '" << patchName <<
"' already exists. Only " 590 <<
"moving patch faces - type will remain the same" <<
endl;
599 if (isA<processorPolyPatch>(pp))
611 startFacei += pp.size();
630 forAll(patchSources, addedI)
632 const dictionary& dict = patchSources[addedI];
635 label destPatchi = patches.findPatchID(patchName);
637 if (destPatchi == -1)
640 <<
"patch " << patchName <<
" not added. Problem." 644 const word sourceType(dict.
lookup(
"constructFrom"));
646 if (sourceType ==
"patches")
659 const polyPatch& pp = patches[iter.key()];
661 Info<<
"Moving faces from patch " << pp.
name()
662 <<
" to patch " << destPatchi <<
endl;
676 else if (sourceType ==
"set")
683 <<
" faces from faceSet " << faces.name() <<
endl;
692 label facei = patchFaces[i];
697 <<
"Face " << facei <<
" specified in set " 699 <<
" is not an external face of the mesh." << endl
700 <<
"This application can only repatch existing boundary" 716 <<
"Invalid source type " << sourceType << endl
725 Info<<
"Doing topology modification to order faces." <<
nl <<
endl;
729 if (writeCyclicMatch)
731 writeCyclicMatchObjs(
"coupled_", mesh);
737 Info<<
"Not synchronising points." <<
nl <<
endl;
750 point(great, great, great)
763 Info<<
"Removing patches with no faces in them." <<
nl<<
endl;
764 filterPatches(mesh, addedPatchNames);
767 if (writeCyclicMatch)
769 writeCyclicMatchObjs(
"final_", mesh);
786 Info<<
"Writing repatched mesh to " << runTime.timeName() <<
nl <<
endl;
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const labelList & sharedPointLabels() const
Return indices of local points that are globally shared.
virtual const fileName & name() const
Return the name of the stream.
label nPoints() const
Return number of points supporting patch faces.
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
A HashTable with keys but without contents.
void append(T *)
Append an element at the end of the list.
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
#define forAll(list, i)
Loop across all elements in list.
autoPtr< polyTopoChangeMap > 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.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
const word & name() const
Return name.
A class for handling file names.
const labelList & nbrPoints() const
Return neighbour point labels. WIP.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const edgeList & coupledPoints() const
Return connected points (from patch local to neighbour patch local)
Class describing modification of a face.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
label nInternalFaces() const
A list that is sorted upon construction or when explicitly requested with the sort() method...
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
static unsigned int defaultPrecision()
Return the default precision.
void size(const label)
Override size to be inconsistent with allocated storage.
const boolList & flipMap() const
Return face flip map.
static word defaultRegion
Return the default region name.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool optionFound(const word &opt) const
Return true if the named option is found.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
virtual const transformer & transform() const
Return transformation between the coupled patches.
const cyclicPolyPatch & nbrPatch() const
IOdictionary systemDict(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion)
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
Neighbour processor patch.
virtual const pointField & points() const
Return raw points.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Input inter-processor communications stream.
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
label nGlobalPoints() const
Return number of globally shared points.
const fileName & pointsInstance() const
Return the current instance directory for points.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
bool found(const Key &) const
Return true if hashedEntry is found in table.
A class for handling words, derived from string.
word name() const
Return file name (part beyond last /)
virtual const labelList & faceOwner() const
Return face owner.
const Field< PointType > & points() const
Return reference to global points.
const globalMeshData & globalData() const
Return parallel info.
virtual const faceList & faces() const
Return raw faces.
int neighbProcNo() const
Return neighbour processor number.
errorManip< error > abort(error &err)
void addPatches(const List< polyPatch *> &, const bool validBoundary=true)
Add boundary patches.
defineTemplateTypeNameAndDebug(IOPtrList< ensightPart >, 0)
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
void removeBoundary()
Remove boundary patches.
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order. Return.
Type gMax(const FieldField< Field, Type > &f)
Output inter-processor communications stream.
void setInstance(const fileName &)
Set the instance for mesh files.
label size() const
Return the number of elements in the UPtrList.
const vectorField & faceCentres() const
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
A PtrList of objects of type <T> with automated input and output.
virtual const transformer & transform() const
Return null transform between processor patches.
static bool & parRun()
Is this a parallel run?
vector point
Point is a vector.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
#define WarningInFunction
Report a warning using Foam::Warning.
Type gAverage(const FieldField< Field, Type > &f)
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
prefixOSstream Pout(cout, "Pout")
const meshFaceZones & faceZones() const
Return face zones.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label start() const
Return start label of this patch in the polyMesh face list.
dimensioned< scalar > mag(const dimensioned< Type > &)
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Return a pointer to a new patch created on freestore from.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
const doubleScalar e
Elementary charge.
Mesh consisting of general polyhedral cells.
A subset of mesh faces organised as a primitive patch.
virtual bool write(const bool write=true) const
Write using setting from DB.
A patch is a list of labels that address the faces in the global face list.
virtual void setPoints(const pointField &)
Reset the points.
Foam::argList args(argc, argv)
const labelList & sharedPointAddr() const
Return addressing into the complete globally shared points.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.