75 label addPointZone(
const polyMesh& mesh,
const word& name)
77 label zoneID = mesh.pointZones().findZoneID(name);
81 Info<<
"Reusing existing pointZone " 82 << mesh.pointZones()[zoneID].name()
83 <<
" at index " << zoneID <<
endl;
88 zoneID = pointZones.
size();
89 Info<<
"Adding pointZone " << name <<
" at index " << zoneID <<
endl;
91 pointZones.setSize(zoneID+1);
108 label addFaceZone(
const polyMesh& mesh,
const word& name)
110 label zoneID = mesh.faceZones().findZoneID(name);
114 Info<<
"Reusing existing faceZone " << mesh.faceZones()[zoneID].name()
115 <<
" at index " << zoneID <<
endl;
120 zoneID = faceZones.
size();
121 Info<<
"Adding faceZone " << name <<
" at index " << zoneID <<
endl;
123 faceZones.setSize(zoneID+1);
141 label addCellZone(
const polyMesh& mesh,
const word& name)
143 label zoneID = mesh.cellZones().findZoneID(name);
147 Info<<
"Reusing existing cellZone " << mesh.cellZones()[zoneID].name()
148 <<
" at index " << zoneID <<
endl;
153 zoneID = cellZones.
size();
154 Info<<
"Adding cellZone " << name <<
" at index " << zoneID <<
endl;
156 cellZones.setSize(zoneID+1);
174 void checkPatch(
const polyBoundaryMesh& bMesh,
const word& name)
176 const label patchi = bMesh.findPatchID(name);
181 <<
"Cannot find patch " << name << endl
182 <<
"It should be present and of non-zero size" << endl
183 <<
"Valid patches are " << bMesh.names()
187 if (bMesh[patchi].empty())
190 <<
"Patch " << name <<
" is present but zero size" 197 int main(
int argc,
char *argv[])
201 "Merge the faces on the specified patches (if geometrically possible)\n" 202 "so the faces become internal.\n" 203 "Integral matching is used when the options -partial and -perfect are " 207 argList::noParallel();
211 argList::validArgs.append(
"masterPatch");
212 argList::validArgs.append(
"slavePatch");
214 argList::addBoolOption
217 "couple partially overlapping patches (optional)" 219 argList::addBoolOption
222 "couple perfectly aligned patches (optional)" 228 "dictionary file with tolerances" 233 runTime.functionObjects().off();
236 const word oldInstance = mesh.pointsInstance();
238 const word masterPatchName =
args[1];
239 const word slavePatchName =
args[2];
245 if (partialCover && perfectCover)
248 <<
"Cannot supply both partial and perfect." << endl
249 <<
"Use perfect match option if the patches perfectly align" 250 <<
" (both vertex positions and face centres)" << endl
255 const word mergePatchName(masterPatchName + slavePatchName);
256 const word cutZoneName(mergePatchName +
"CutFaceZone");
258 slidingInterface::typeOfMatch tom = slidingInterface::INTEGRAL;
262 Info<<
"Coupling partially overlapping patches " 263 << masterPatchName <<
" and " << slavePatchName <<
nl 264 <<
"Resulting internal faces will be in faceZone " << cutZoneName
266 <<
"Any uncovered faces will remain in their patch" 269 tom = slidingInterface::PARTIAL;
271 else if (perfectCover)
273 Info<<
"Coupling perfectly aligned patches " 274 << masterPatchName <<
" and " << slavePatchName <<
nl 275 <<
"Resulting (internal) faces will be in faceZone " << cutZoneName
277 <<
"Note: both patches need to align perfectly." <<
nl 279 <<
" positions and the face centres need to align to within" <<
nl 280 <<
"a tolerance given by the minimum edge length on the patch" 285 Info<<
"Coupling patches " << masterPatchName <<
" and " 286 << slavePatchName <<
nl 287 <<
"Resulting (internal) faces will be in faceZone " << cutZoneName
289 <<
"Note: the overall area covered by both patches should be" 290 <<
" identical (\"integral\" interface)." << endl
291 <<
"If this is not the case use the -partial option" <<
nl <<
endl;
295 dictionary slidingTolerances;
298 IOdictionary toleranceFile
305 IOobject::MUST_READ_IF_MODIFIED,
309 slidingTolerances += toleranceFile;
313 checkPatch(mesh.boundaryMesh(), masterPatchName);
314 checkPatch(mesh.boundaryMesh(), slavePatchName);
319 const polyPatch& masterPatch = mesh.boundaryMesh()[masterPatchName];
326 isf[i] = masterPatch.start() + i;
329 polyTopoChanger stitcher(mesh);
332 mesh.pointZones().clearAddressing();
333 mesh.faceZones().clearAddressing();
334 mesh.cellZones().clearAddressing();
339 label cutZoneID = addFaceZone(mesh, cutZoneName);
341 mesh.faceZones()[cutZoneID].resetAddressing
364 label pointZoneID = addPointZone(mesh, mergePatchName +
"CutPointZone");
367 label masterZoneID = addFaceZone(mesh, mergePatchName +
"MasterZone");
369 mesh.faceZones()[masterZoneID].resetAddressing
376 const polyPatch& slavePatch = mesh.boundaryMesh()[slavePatchName];
382 osf[i] = slavePatch.start() + i;
385 label slaveZoneID = addFaceZone(mesh, mergePatchName +
"SlaveZone");
386 mesh.faceZones()[slaveZoneID].resetAddressing
393 label cutZoneID = addFaceZone(mesh, cutZoneName);
394 mesh.faceZones()[cutZoneID].resetAddressing
410 mergePatchName +
"MasterZone",
411 mergePatchName +
"SlaveZone",
412 mergePatchName +
"CutPointZone",
420 static_cast<slidingInterface&
>(stitcher[0]).setTolerances
429 IOobjectList objects(mesh, runTime.timeName());
432 Info<<
"Reading all current volfields" <<
endl;
433 PtrList<volScalarField> volScalarFields;
436 PtrList<volVectorField> volVectorFields;
439 PtrList<volSphericalTensorField> volSphericalTensorFields;
440 ReadFields(mesh, objects, volSphericalTensorFields);
442 PtrList<volSymmTensorField> volSymmTensorFields;
443 ReadFields(mesh, objects, volSymmTensorFields);
445 PtrList<volTensorField> volTensorFields;
465 autoPtr<mapPolyMesh> morphMap = stitcher.changeMesh(
true);
467 mesh.movePoints(morphMap->preMotionPoints());
472 mesh.setInstance(oldInstance);
473 stitcher.instance() = oldInstance;
475 Info<<
nl <<
"Writing polyMesh to time " << runTime.timeName() <<
endl;
477 IOstream::defaultPrecision(
max(10u, IOstream::defaultPrecision()));
482 !runTime.objectRegistry::writeObject
484 runTime.writeFormat(),
485 IOstream::currentVersion,
486 runTime.writeCompression()
491 <<
"Failed writing polyMesh." 495 mesh.faceZones().write();
496 mesh.pointZones().write();
497 mesh.cellZones().write();
DynamicID< pointZoneMesh > pointZoneID
Foam::pointZoneID.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
wordList ReadFields(const Mesh &mesh, const IOobjectList &objects, PtrList< GeoField > &fields, const bool syncPar=true)
Read all fields of the specified type.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Field reading functions for post-processing utilities.
const Foam::HashTable< string > & options() const
Return options.
Various functions to operate on Lists.
List< bool > boolList
Bool container classes.
bool optionFound(const word &opt) const
Return true if the named option is found.
List< label > labelList
A List of labels.
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with the type pointZone.
Foam::argList args(argc, argv)
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with the type cellZone.
label size() const
Return the number of elements in the UPtrList.