createPatch.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2016-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Application
28  createPatch
29 
30 Group
31  grpMeshManipulationUtilities
32 
33 Description
34  Create patches out of selected boundary faces, which are either
35  from existing patches or from a faceSet.
36 
37  More specifically it:
38  - creates new patches (from selected boundary faces).
39  Synchronise faces on coupled patches.
40  - synchronises points on coupled boundaries
41  - remove patches with 0 faces in them
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #include "cyclicPolyPatch.H"
46 #include "syncTools.H"
47 #include "argList.H"
48 #include "polyMesh.H"
49 #include "Time.H"
50 #include "SortableList.H"
51 #include "OFstream.H"
52 #include "meshTools.H"
53 #include "faceSet.H"
54 #include "IOPtrList.H"
55 #include "polyTopoChange.H"
56 #include "polyModifyFace.H"
57 #include "wordRes.H"
58 #include "processorMeshes.H"
59 #include "IOdictionary.H"
60 
61 using namespace Foam;
62 
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 
65 namespace Foam
66 {
68 }
69 
70 void changePatchID
71 (
72  const polyMesh& mesh,
73  const label faceID,
74  const label patchID,
75  polyTopoChange& meshMod
76 )
77 {
78  const label zoneID = mesh.faceZones().whichZone(faceID);
79 
80  bool zoneFlip = false;
81 
82  if (zoneID >= 0)
83  {
84  const faceZone& fZone = mesh.faceZones()[zoneID];
85 
86  zoneFlip = fZone.flipMap()[fZone.whichFace(faceID)];
87  }
88 
89  meshMod.setAction
90  (
92  (
93  mesh.faces()[faceID], // face
94  faceID, // face ID
95  mesh.faceOwner()[faceID], // owner
96  -1, // neighbour
97  false, // flip flux
98  patchID, // patch ID
99  false, // remove from zone
100  zoneID, // zone ID
101  zoneFlip // zone flip
102  )
103  );
104 }
105 
106 
107 // Filter out the empty patches.
108 void filterPatches(polyMesh& mesh, const wordHashSet& addedPatchNames)
109 {
111 
112  // Patches to keep
113  DynamicList<polyPatch*> allPatches(patches.size());
114 
115  label nOldPatches = returnReduce(patches.size(), sumOp<label>());
116 
117  // Copy old patches.
118  forAll(patches, patchi)
119  {
120  const polyPatch& pp = patches[patchi];
121 
122  // Note: reduce possible since non-proc patches guaranteed in same order
123  if (!isA<processorPolyPatch>(pp))
124  {
125 
126  // Add if
127  // - non zero size
128  // - or added from the createPatchDict
129  // - or cyclic (since referred to by other cyclic half or
130  // proccyclic)
131 
132  if
133  (
134  addedPatchNames.found(pp.name())
135  || returnReduce(pp.size(), sumOp<label>()) > 0
136  || isA<coupledPolyPatch>(pp)
137  )
138  {
139  allPatches.append
140  (
141  pp.clone
142  (
143  patches,
144  allPatches.size(),
145  pp.size(),
146  pp.start()
147  ).ptr()
148  );
149  }
150  else
151  {
152  Info<< "Removing zero-sized patch " << pp.name()
153  << " type " << pp.type()
154  << " at position " << patchi << endl;
155  }
156  }
157  }
158  // Copy non-empty processor patches
159  forAll(patches, patchi)
160  {
161  const polyPatch& pp = patches[patchi];
162 
163  if (isA<processorPolyPatch>(pp))
164  {
165  if (pp.size())
166  {
167  allPatches.append
168  (
169  pp.clone
170  (
171  patches,
172  allPatches.size(),
173  pp.size(),
174  pp.start()
175  ).ptr()
176  );
177  }
178  else
179  {
180  Info<< "Removing empty processor patch " << pp.name()
181  << " at position " << patchi << endl;
182  }
183  }
184  }
185 
186  label nAllPatches = returnReduce(allPatches.size(), sumOp<label>());
187  if (nAllPatches != nOldPatches)
188  {
189  Info<< "Removing patches." << endl;
190  allPatches.shrink();
192  mesh.addPatches(allPatches);
193  }
194  else
195  {
196  Info<< "No patches removed." << endl;
197  forAll(allPatches, i)
198  {
199  delete allPatches[i];
200  }
201  }
202 }
203 
204 
205 // Dump for all patches the current match
206 void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
207 {
209 
210  forAll(patches, patchi)
211  {
212  if
213  (
214  isA<cyclicPolyPatch>(patches[patchi])
215  && refCast<const cyclicPolyPatch>(patches[patchi]).owner()
216  )
217  {
218  const cyclicPolyPatch& cycPatch =
219  refCast<const cyclicPolyPatch>(patches[patchi]);
220 
221  // Dump patches
222  {
223  OFstream str(prefix+cycPatch.name()+".obj");
224  Pout<< "Dumping " << cycPatch.name()
225  << " faces to " << str.name() << endl;
227  (
228  str,
229  cycPatch,
230  cycPatch.points()
231  );
232  }
233 
234  const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
235  {
236  OFstream str(prefix+nbrPatch.name()+".obj");
237  Pout<< "Dumping " << nbrPatch.name()
238  << " faces to " << str.name() << endl;
240  (
241  str,
242  nbrPatch,
243  nbrPatch.points()
244  );
245  }
246 
247 
248  // Lines between corresponding face centres
249  OFstream str(prefix+cycPatch.name()+nbrPatch.name()+"_match.obj");
250  label vertI = 0;
251 
252  Pout<< "Dumping cyclic match as lines between face centres to "
253  << str.name() << endl;
254 
255  forAll(cycPatch, facei)
256  {
257  const point& fc0 = mesh.faceCentres()[cycPatch.start()+facei];
258  meshTools::writeOBJ(str, fc0);
259  vertI++;
260  const point& fc1 = mesh.faceCentres()[nbrPatch.start()+facei];
261  meshTools::writeOBJ(str, fc1);
262  vertI++;
263 
264  str<< "l " << vertI-1 << ' ' << vertI << nl;
265  }
266  }
267  }
268 }
269 
270 
271 void separateList
272 (
273  const vectorField& separation,
275 )
276 {
277  if (separation.size() == 1)
278  {
279  // Single value for all.
280 
281  forAll(field, i)
282  {
283  field[i] += separation[0];
284  }
285  }
286  else if (separation.size() == field.size())
287  {
288  forAll(field, i)
289  {
290  field[i] += separation[i];
291  }
292  }
293  else
294  {
296  << "Sizes of field and transformation not equal. field:"
297  << field.size() << " transformation:" << separation.size()
298  << abort(FatalError);
299  }
300 }
301 
302 
303 // Synchronise points on both sides of coupled boundaries.
304 template<class CombineOp>
305 void syncPoints
306 (
307  const polyMesh& mesh,
309  const CombineOp& cop,
310  const point& nullValue
311 )
312 {
313  if (points.size() != mesh.nPoints())
314  {
316  << "Number of values " << points.size()
317  << " is not equal to the number of points in the mesh "
318  << mesh.nPoints() << abort(FatalError);
319  }
320 
322 
323  // Is there any coupled patch with transformation?
324  bool hasTransformation = false;
325 
326  if (Pstream::parRun())
327  {
328  // Send
329 
330  forAll(patches, patchi)
331  {
332  const polyPatch& pp = patches[patchi];
333 
334  if
335  (
336  isA<processorPolyPatch>(pp)
337  && pp.nPoints() > 0
338  && refCast<const processorPolyPatch>(pp).owner()
339  )
340  {
341  const processorPolyPatch& procPatch =
342  refCast<const processorPolyPatch>(pp);
343 
344  // Get data per patchPoint in neighbouring point numbers.
345  pointField patchInfo(procPatch.nPoints(), nullValue);
346 
347  const labelList& meshPts = procPatch.meshPoints();
348  const labelList& nbrPts = procPatch.neighbPoints();
349 
350  forAll(nbrPts, pointi)
351  {
352  label nbrPointi = nbrPts[pointi];
353  if (nbrPointi >= 0 && nbrPointi < patchInfo.size())
354  {
355  patchInfo[nbrPointi] = points[meshPts[pointi]];
356  }
357  }
358 
359  OPstream toNbr
360  (
362  procPatch.neighbProcNo()
363  );
364  toNbr << patchInfo;
365  }
366  }
367 
368 
369  // Receive and set.
370 
371  forAll(patches, patchi)
372  {
373  const polyPatch& pp = patches[patchi];
374 
375  if
376  (
377  isA<processorPolyPatch>(pp)
378  && pp.nPoints() > 0
379  && !refCast<const processorPolyPatch>(pp).owner()
380  )
381  {
382  const processorPolyPatch& procPatch =
383  refCast<const processorPolyPatch>(pp);
384 
385  pointField nbrPatchInfo(procPatch.nPoints());
386  {
387  // We do not know the number of points on the other side
388  // so cannot use Pstream::read.
389  IPstream fromNbr
390  (
392  procPatch.neighbProcNo()
393  );
394  fromNbr >> nbrPatchInfo;
395  }
396  // Null any value which is not on neighbouring processor
397  nbrPatchInfo.setSize(procPatch.nPoints(), nullValue);
398 
399  if (!procPatch.parallel())
400  {
401  hasTransformation = true;
402  transformList(procPatch.forwardT(), nbrPatchInfo);
403  }
404  else if (procPatch.separated())
405  {
406  hasTransformation = true;
407  separateList(-procPatch.separation(), nbrPatchInfo);
408  }
409 
410  const labelList& meshPts = procPatch.meshPoints();
411 
412  forAll(meshPts, pointi)
413  {
414  label meshPointi = meshPts[pointi];
415  points[meshPointi] = nbrPatchInfo[pointi];
416  }
417  }
418  }
419  }
420 
421  // Do the cyclics.
422  forAll(patches, patchi)
423  {
424  const polyPatch& pp = patches[patchi];
425 
426  if
427  (
428  isA<cyclicPolyPatch>(pp)
429  && refCast<const cyclicPolyPatch>(pp).owner()
430  )
431  {
432  const cyclicPolyPatch& cycPatch =
433  refCast<const cyclicPolyPatch>(pp);
434 
435  const edgeList& coupledPoints = cycPatch.coupledPoints();
436  const labelList& meshPts = cycPatch.meshPoints();
437  const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
438  const labelList& nbrMeshPts = nbrPatch.meshPoints();
439 
440  pointField half0Values(coupledPoints.size());
441 
442  forAll(coupledPoints, i)
443  {
444  const edge& e = coupledPoints[i];
445  label point0 = meshPts[e[0]];
446  half0Values[i] = points[point0];
447  }
448 
449  if (!cycPatch.parallel())
450  {
451  hasTransformation = true;
452  transformList(cycPatch.reverseT(), half0Values);
453  }
454  else if (cycPatch.separated())
455  {
456  hasTransformation = true;
457  separateList(cycPatch.separation(), half0Values);
458  }
459 
460  forAll(coupledPoints, i)
461  {
462  const edge& e = coupledPoints[i];
463  label point1 = nbrMeshPts[e[1]];
464  points[point1] = half0Values[i];
465  }
466  }
467  }
468 
469  //- Note: hasTransformation is only used for warning messages so
470  // reduction not strictly necessary.
471  //reduce(hasTransformation, orOp<bool>());
472 
473  // Synchronize multiple shared points.
474  const globalMeshData& pd = mesh.globalData();
475 
476  if (pd.nGlobalPoints() > 0)
477  {
478  if (hasTransformation)
479  {
481  << "There are decomposed cyclics in this mesh with"
482  << " transformations." << endl
483  << "This is not supported. The result will be incorrect"
484  << endl;
485  }
486 
487 
488  // Values on shared points.
489  pointField sharedPts(pd.nGlobalPoints(), nullValue);
490 
491  forAll(pd.sharedPointLabels(), i)
492  {
493  label meshPointi = pd.sharedPointLabels()[i];
494  // Fill my entries in the shared points
495  sharedPts[pd.sharedPointAddr()[i]] = points[meshPointi];
496  }
497 
498  // Combine on master.
499  Pstream::listCombineGather(sharedPts, cop);
500  Pstream::listCombineScatter(sharedPts);
501 
502  // Now we will all have the same information. Merge it back with
503  // my local information.
504  forAll(pd.sharedPointLabels(), i)
505  {
506  label meshPointi = pd.sharedPointLabels()[i];
507  points[meshPointi] = sharedPts[pd.sharedPointAddr()[i]];
508  }
509  }
510 }
511 
512 
513 
514 int main(int argc, char *argv[])
515 {
517  (
518  "Create patches out of selected boundary faces, which are either"
519  " from existing patches or from a faceSet"
520  );
521 
522  #include "addOverwriteOption.H"
523  #include "addRegionOption.H"
524  argList::addOption("dict", "file", "Alternative createPatchDict");
526  (
527  "writeObj",
528  "Write obj files showing the cyclic matching process"
529  );
530 
531  argList::noFunctionObjects(); // Never use function objects
532 
533  #include "setRootCase.H"
534  #include "createTime.H"
535 
536  const word meshRegionName =
538 
539  const bool overwrite = args.found("overwrite");
540 
541  #include "createNamedPolyMesh.H"
542 
543  const bool writeObj = args.found("writeObj");
544 
545  const word oldInstance = mesh.pointsInstance();
546 
547  const word dictName("createPatchDict");
548  #include "setSystemMeshDictionaryIO.H"
549  Info<< "Reading " << dictIO.instance()/dictIO.name() << nl << endl;
550 
552 
553  // Whether to synchronise points
554  const bool pointSync(dict.get<bool>("pointSync"));
555 
557 
558  // If running parallel check same patches everywhere
560 
561 
562  if (writeObj)
563  {
564  dumpCyclicMatch("initial_", mesh);
565  }
566 
567  // Read patch construct info from dictionary
568  PtrList<dictionary> patchSources(dict.lookup("patches"));
569 
570  wordHashSet addedPatchNames;
571  for (const dictionary& dict : patchSources)
572  {
573  addedPatchNames.insert(dict.get<word>("name"));
574  }
575 
576 
577  // 1. Add all new patches
578  // ~~~~~~~~~~~~~~~~~~~~~~
579 
580  if (patchSources.size())
581  {
582  // Old and new patches.
583  DynamicList<polyPatch*> allPatches(patches.size()+patchSources.size());
584 
585  label startFacei = mesh.nInternalFaces();
586 
587  // Copy old patches.
588  forAll(patches, patchi)
589  {
590  const polyPatch& pp = patches[patchi];
591 
592  if (!isA<processorPolyPatch>(pp))
593  {
594  allPatches.append
595  (
596  pp.clone
597  (
598  patches,
599  patchi,
600  pp.size(),
601  startFacei
602  ).ptr()
603  );
604  startFacei += pp.size();
605  }
606  }
607 
608  for (const dictionary& dict : patchSources)
609  {
610  const word patchName(dict.get<word>("name"));
611 
612  label destPatchi = patches.findPatchID(patchName);
613 
614  if (destPatchi == -1)
615  {
616  dictionary patchDict(dict.subDict("patchInfo"));
617 
618  destPatchi = allPatches.size();
619 
620  Info<< "Adding new patch " << patchName
621  << " as patch " << destPatchi
622  << " from " << patchDict << endl;
623 
624  patchDict.set("nFaces", 0);
625  patchDict.set("startFace", startFacei);
626 
627  // Add an empty patch.
628  allPatches.append
629  (
631  (
632  patchName,
633  patchDict,
634  destPatchi,
635  patches
636  ).ptr()
637  );
638  }
639  else
640  {
641  Info<< "Patch '" << patchName << "' already exists. Only "
642  << "moving patch faces - type will remain the same" << endl;
643  }
644  }
645 
646  // Copy old patches.
647  forAll(patches, patchi)
648  {
649  const polyPatch& pp = patches[patchi];
650 
651  if (isA<processorPolyPatch>(pp))
652  {
653  allPatches.append
654  (
655  pp.clone
656  (
657  patches,
658  patchi,
659  pp.size(),
660  startFacei
661  ).ptr()
662  );
663  startFacei += pp.size();
664  }
665  }
666 
667  allPatches.shrink();
669  mesh.addPatches(allPatches);
670 
671  Info<< endl;
672  }
673 
674 
675 
676  // 2. Repatch faces
677  // ~~~~~~~~~~~~~~~~
678 
679  polyTopoChange meshMod(mesh);
680 
681 
682  for (const dictionary& dict : patchSources)
683  {
684  const word patchName(dict.get<word>("name"));
685  label destPatchi = patches.findPatchID(patchName);
686 
687  if (destPatchi == -1)
688  {
690  << "patch " << patchName << " not added. Problem."
691  << abort(FatalError);
692  }
693 
694  const word sourceType(dict.get<word>("constructFrom"));
695 
696  if (sourceType == "patches")
697  {
698  labelHashSet patchSources
699  (
700  patches.patchSet(dict.get<wordRes>("patches"))
701  );
702 
703  // Repatch faces of the patches.
704  for (const label patchi : patchSources)
705  {
706  const polyPatch& pp = patches[patchi];
707 
708  Info<< "Moving faces from patch " << pp.name()
709  << " to patch " << destPatchi << endl;
710 
711  forAll(pp, i)
712  {
713  changePatchID
714  (
715  mesh,
716  pp.start() + i,
717  destPatchi,
718  meshMod
719  );
720  }
721  }
722  }
723  else if (sourceType == "set")
724  {
725  const word setName(dict.get<word>("set"));
726 
727  faceSet faces(mesh, setName);
728 
729  Info<< "Read " << returnReduce(faces.size(), sumOp<label>())
730  << " faces from faceSet " << faces.name() << endl;
731 
732  // Sort (since faceSet contains faces in arbitrary order)
733  labelList faceLabels(faces.toc());
734 
735  SortableList<label> patchFaces(faceLabels);
736 
737  forAll(patchFaces, i)
738  {
739  label facei = patchFaces[i];
740 
741  if (mesh.isInternalFace(facei))
742  {
744  << "Face " << facei << " specified in set "
745  << faces.name()
746  << " is not an external face of the mesh." << endl
747  << "This application can only repatch existing boundary"
748  << " faces." << exit(FatalError);
749  }
750 
751  changePatchID
752  (
753  mesh,
754  facei,
755  destPatchi,
756  meshMod
757  );
758  }
759  }
760  else
761  {
763  << "Invalid source type " << sourceType << endl
764  << "Valid source types are 'patches' 'set'" << exit(FatalError);
765  }
766  }
767  Info<< endl;
768 
769 
770  // Change mesh, use inflation to reforce calculation of transformation
771  // tensors.
772  Info<< "Doing topology modification to order faces." << nl << endl;
773  autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, true);
774  mesh.movePoints(map().preMotionPoints());
775 
776  if (writeObj)
777  {
778  dumpCyclicMatch("coupled_", mesh);
779  }
780 
781  // Synchronise points.
782  if (!pointSync)
783  {
784  Info<< "Not synchronising points." << nl << endl;
785  }
786  else
787  {
788  Info<< "Synchronising points." << nl << endl;
789 
790  // This is a bit tricky. Both normal and position might be out and
791  // current separation also includes the normal
792  // ( separation_ = (nf&(Cr - Cf))*nf ).
793 
794  // For cyclic patches:
795  // - for separated ones use user specified offset vector
796 
797  forAll(mesh.boundaryMesh(), patchi)
798  {
799  const polyPatch& pp = mesh.boundaryMesh()[patchi];
800 
801  if (pp.size() && isA<coupledPolyPatch>(pp))
802  {
803  const coupledPolyPatch& cpp =
804  refCast<const coupledPolyPatch>(pp);
805 
806  if (cpp.separated())
807  {
808  Info<< "On coupled patch " << pp.name()
809  << " separation[0] was "
810  << cpp.separation()[0] << endl;
811 
812  if (isA<cyclicPolyPatch>(pp) && pp.size())
813  {
814  const cyclicPolyPatch& cycpp =
815  refCast<const cyclicPolyPatch>(pp);
816 
818  {
819  // Force to wanted separation
820  Info<< "On cyclic translation patch " << pp.name()
821  << " forcing uniform separation of "
822  << cycpp.separationVector() << endl;
823  const_cast<vectorField&>(cpp.separation()) =
824  pointField(1, cycpp.separationVector());
825  }
826  else
827  {
828  const cyclicPolyPatch& nbr = cycpp.neighbPatch();
829  const_cast<vectorField&>(cpp.separation()) =
830  pointField
831  (
832  1,
833  nbr[0].centre(mesh.points())
834  - cycpp[0].centre(mesh.points())
835  );
836  }
837  }
838  Info<< "On coupled patch " << pp.name()
839  << " forcing uniform separation of "
840  << cpp.separation() << endl;
841  }
842  else if (!cpp.parallel())
843  {
844  Info<< "On coupled patch " << pp.name()
845  << " forcing uniform rotation of "
846  << cpp.forwardT()[0] << endl;
847 
848  const_cast<tensorField&>
849  (
850  cpp.forwardT()
851  ).setSize(1);
852  const_cast<tensorField&>
853  (
854  cpp.reverseT()
855  ).setSize(1);
856 
857  Info<< "On coupled patch " << pp.name()
858  << " forcing uniform rotation of "
859  << cpp.forwardT() << endl;
860  }
861  }
862  }
863 
864  Info<< "Synchronising points." << endl;
865 
866  pointField newPoints(mesh.points());
867 
868  syncPoints
869  (
870  mesh,
871  newPoints,
873  point(GREAT, GREAT, GREAT)
874  );
875 
876  scalarField diff(mag(newPoints-mesh.points()));
877  Info<< "Points changed by average:" << gAverage(diff)
878  << " max:" << gMax(diff) << nl << endl;
879 
880  mesh.movePoints(newPoints);
881  }
882 
883  // 3. Remove zeros-sized patches
884  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
885 
886  Info<< "Removing patches with no faces in them." << nl<< endl;
887  filterPatches(mesh, addedPatchNames);
888 
889 
890  if (writeObj)
891  {
892  dumpCyclicMatch("final_", mesh);
893  }
894 
895 
896  // Set the precision of the points data to 10
898 
899  if (!overwrite)
900  {
901  ++runTime;
902  }
903  else
904  {
905  mesh.setInstance(oldInstance);
906  }
907 
908  // Write resulting mesh
909  Info<< "Writing repatched mesh to " << runTime.timeName() << nl << endl;
910  mesh.write();
913 
914  Info<< "End\n" << endl;
915 
916  return 0;
917 }
918 
919 
920 // ************************************************************************* //
Foam::polyMesh::addPatches
void addPatches(PtrList< polyPatch > &plist, const bool validBoundary=true)
Add boundary patches.
Definition: polyMesh.C:930
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::UPstream::commsTypes::blocking
wordRes.H
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1038
setSize
points setSize(newPointi)
meshTools.H
Foam::coupledPolyPatch::separation
virtual const vectorField & separation() const
If the planes are separated the separation vector.
Definition: coupledPolyPatch.H:284
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobjectI.H:70
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::fvMesh::write
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
Definition: fvMesh.C:895
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
Foam::IOPtrList
A PtrList of objects of type <T> with automated input and output.
Definition: IOPtrList.H:53
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:62
Foam::polyMesh::defaultRegion
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:312
cyclicPolyPatch.H
Foam::argList::getOrDefault
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
Definition: argListI.H:286
Foam::cyclicPolyPatch
Cyclic plane patch.
Definition: cyclicPolyPatch.H:65
Foam::polyTopoChange::changeMesh
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.
Definition: polyTopoChange.C:2955
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:55
Foam::gAverage
Type gAverage(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:604
Foam::meshTools::writeOBJ
void writeOBJ(Ostream &os, const point &pt)
Write obj representation of a point.
Definition: meshTools.C:203
Foam::OPstream
Output inter-processor communications stream.
Definition: OPstream.H:52
Foam::primitiveMesh::nInternalFaces
label nInternalFaces() const
Number of internal faces.
Definition: primitiveMeshI.H:78
Foam::cyclicPolyPatch::neighbPatch
const cyclicPolyPatch & neighbPatch() const
Definition: cyclicPolyPatch.H:330
addOverwriteOption.H
Foam::coupledPolyPatch::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: coupledPolyPatch.H:296
Foam::IOobject::instance
const fileName & instance() const
Definition: IOobjectI.H:191
polyTopoChange.H
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:415
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:785
Foam::polyTopoChange
Direct mesh changes based on v1.3 polyTopoChange syntax.
Definition: polyTopoChange.H:99
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:63
Foam::coupledPolyPatch::reverseT
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
Definition: coupledPolyPatch.H:302
Foam::argList::addNote
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:413
dictName
const word dictName("blockMeshDict")
Foam::processorPolyPatch::neighbProcNo
int neighbProcNo() const
Return neighbour processor number.
Definition: processorPolyPatch.H:274
Foam::faceSet
A list of face labels.
Definition: faceSet.H:51
Foam::polyModifyFace
Class describing modification of a face.
Definition: polyModifyFace.H:50
Foam::fvMesh::movePoints
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
Definition: fvMesh.C:727
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:435
Foam::defineTemplateTypeNameAndDebug
defineTemplateTypeNameAndDebug(faScalarMatrix, 0)
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::coupledPolyPatch
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
Definition: coupledPolyPatch.H:53
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
Foam::Pout
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
polyMesh.H
Foam::HashSet< word >
processorMeshes.H
syncTools.H
setSystemMeshDictionaryIO.H
createNamedPolyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::sumOp
Definition: ops.H:213
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
OFstream.H
Foam::polyMesh::faceZones
const faceZoneMesh & faceZones() const
Return face zone mesh.
Definition: polyMesh.H:477
Foam::cyclicPolyPatch::coupledPoints
const edgeList & coupledPoints() const
Return connected points (from patch local to neighbour patch local)
Definition: cyclicPolyPatch.C:1008
Foam::coupledPolyPatch::parallel
virtual bool parallel() const
Are the cyclic planes parallel.
Definition: coupledPolyPatch.H:290
Foam::diff
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Definition: triad.C:378
Foam::polyMesh::pointsInstance
const fileName & pointsInstance() const
Return the current instance directory for points.
Definition: polyMesh.C:815
SortableList.H
Foam::coupledPolyPatch::separated
virtual bool separated() const
Are the planes separated.
Definition: coupledPolyPatch.H:278
Foam::polyBoundaryMesh::checkParallelSync
bool checkParallelSync(const bool report=false) const
Check whether all procs have all patches and in same order. Return.
Definition: polyBoundaryMesh.C:950
Foam::transformList
void transformList(const tensor &rotTensor, UList< T > &field)
Inplace transform a list of elements.
Definition: transformList.C:52
Foam::argList::noFunctionObjects
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
Definition: argList.C:454
Foam::globalMeshData::nGlobalPoints
label nGlobalPoints() const
Return number of globally shared points.
Definition: globalMeshData.C:2006
Foam::Field< vector >
Foam::faceZone
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:65
IOPtrList.H
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:67
Foam::OSstream::name
virtual const fileName & name() const
Return the name of the stream.
Definition: OSstream.H:107
argList.H
patchID
label patchID
Definition: boundaryProcessorFaPatchPoints.H:5
Foam::polyMesh::faceOwner
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1076
faceSet.H
Foam::dictionary::subDict
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:528
addRegionOption.H
Foam::processorPolyPatch
Neighbour processor patch.
Definition: processorPolyPatch.H:58
field
rDeltaTY field()
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:62
Foam::polyBoundaryMesh::findPatchID
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
Definition: polyBoundaryMesh.C:766
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::PtrList::append
void append(T *ptr)
Append an element to the end of the list.
Definition: PtrListI.H:115
Foam::dictionary::lookup
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionary.C:424
Foam::ZoneMesh::whichZone
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
Definition: ZoneMesh.C:315
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::PrimitivePatch::nPoints
label nPoints() const
Return number of points supporting patch faces.
Definition: PrimitivePatch.H:316
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::globalMeshData
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
Definition: globalMeshData.H:106
Foam::polyPatch::New
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.
Definition: polyPatchNew.C:35
Foam::PrimitivePatch::points
const Field< point_type > & points() const
Return reference to global points.
Definition: PrimitivePatch.H:305
Foam::SortableList
A list that is sorted upon construction or when explicitly requested with the sort() method.
Definition: List.H:63
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
zoneID
const labelIOList & zoneID
Definition: interpolatedFaces.H:22
dictIO
IOobject dictIO
Definition: setConstantMeshDictionaryIO.H:1
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::faceZone::whichFace
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: faceZone.C:379
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
Foam::coupledPolyPatch::transform
virtual transformType transform() const
Type of transform.
Definition: coupledPolyPatch.H:258
polyModifyFace.H
Foam::polyPatch::clone
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Definition: polyPatch.H:232
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::polyMesh::removeBoundary
void removeBoundary()
Remove boundary patches.
Definition: polyMeshClear.C:39
Foam::OFstream
Output to file stream, using an OSstream.
Definition: OFstream.H:87
Foam::Pstream::listCombineGather
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
Definition: combineGatherScatter.C:290
Foam::argList::addBoolOption
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:325
IOdictionary.H
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
setRootCase.H
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1063
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:372
Foam::processorPolyPatch::neighbPoints
const labelList & neighbPoints() const
Return neighbour point labels. WIP.
Definition: processorPolyPatch.C:529
Foam::polyTopoChange::setAction
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
Definition: polyTopoChange.C:2456
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::IOstream::defaultPrecision
static unsigned int defaultPrecision()
Return the default precision.
Definition: IOstream.H:333
Foam::Vector< scalar >
Foam::List< label >
Foam::primitiveMesh::isInternalFace
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
Definition: primitiveMeshI.H:102
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::primitiveMesh::faceCentres
const vectorField & faceCentres() const
Definition: primitiveMeshFaceCentresAndAreas.C:144
Foam::processorMeshes::removeFiles
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
Definition: processorMeshes.C:274
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::primitiveMesh::nPoints
label nPoints() const
Number of mesh points.
Definition: primitiveMeshI.H:37
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::polyBoundaryMesh::patchSet
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool useGroups=true) const
Return the set of patch IDs corresponding to the given names.
Definition: polyBoundaryMesh.C:857
createTime.H
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
Foam::globalMeshData::sharedPointLabels
const labelList & sharedPointLabels() const
Return indices of local points that are globally shared.
Definition: globalMeshData.C:2016
Foam::globalMeshData::sharedPointAddr
const labelList & sharedPointAddr() const
Return addressing into the complete globally shared points.
Definition: globalMeshData.C:2026
Foam::IPstream
Input inter-processor communications stream.
Definition: IPstream.H:52
Foam::polyMesh::globalData
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1234
Foam::Pstream::listCombineScatter
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
Definition: combineGatherScatter.C:432
Foam::point
vector point
Point is a vector.
Definition: point.H:43
Foam::HashTable::found
bool found(const Key &key) const
Return true if hashed entry is found in table.
Definition: HashTableI.H:100
Foam::PrimitivePatch::meshPoints
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Definition: PrimitivePatch.C:310
Foam::coupledPolyPatch::TRANSLATIONAL
Definition: coupledPolyPatch.H:63
Foam::argList::addOption
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Definition: argList.C:336
args
Foam::argList args(argc, argv)
Foam::minMagSqrEqOp
Definition: ops.H:82
Foam::faceZone::flipMap
const boolList & flipMap() const
Return face flip map.
Definition: faceZone.H:271
Foam::topoSet::removeFiles
static void removeFiles(const polyMesh &)
Helper: remove all sets files from mesh instance.
Definition: topoSet.C:638
Foam::patchIdentifier::name
const word & name() const
The patch name.
Definition: patchIdentifier.H:134
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:298
Foam::cyclicPolyPatch::separationVector
const vector & separationVector() const
Translation vector for translational cyclics.
Definition: cyclicPolyPatch.H:386
Foam::gMax
Type gMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:592
Foam::polyMesh::setInstance
void setInstance(const fileName &instance, const IOobject::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
Definition: polyMeshIO.C:36
Foam::argList::found
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:157