extrudeMesh.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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
7  -------------------------------------------------------------------------------
8  License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24  Application
25  extrudeMesh
26 
27  Description
28  Extrude mesh from existing patch (by default outwards facing normals;
29  optional flips faces) or from patch read from file.
30 
31 Note: Merges close points so be careful.
32 
33 Type of extrusion prescribed by run-time selectable model.
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #include "argList.H"
38 #include "Time.H"
39 #include "polyTopoChange.H"
40 #include "polyTopoChanger.H"
41 #include "edgeCollapser.H"
42 #include "perfectInterface.H"
43 #include "addPatchCellLayer.H"
44 #include "fvMesh.H"
45 #include "MeshedSurfaces.H"
46 #include "globalIndex.H"
47 #include "cellSet.H"
48 #include "extrudedMesh.H"
49 #include "extrudeModel.H"
50 #include "doubleScalar.H"
51 #include "wedge.H"
52 #include "wedgePolyPatch.H"
53 #include "planeExtrusion.H"
54 #include "emptyPolyPatch.H"
55 #include "VectorSpace.H"
56 #include "IOstreams.H"
57 #include <sstream>
58 #include <vector>
59 using namespace Foam;
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 
63 {
67 };
68 
69 namespace Foam
70 {
71  template<>
73  {
74  "mesh",
75  "patch",
76  "surface"
77  };
78 }
79 
81 
82 
84 {
85  // Create dummy system/fv*
86  {
87  IOobject io
88  (
89  "fvSchemes",
90  mesh.time().system(),
91  regionName,
92  mesh,
95  false
96  );
97 
98  Info<< "Testing:" << io.objectPath() << endl;
99 
100  if (!io.headerOk())
101  {
102  Info<< "Writing dummy " << regionName/io.name() << endl;
103  dictionary dummyDict;
104  dictionary divDict;
105  dummyDict.add("divSchemes", divDict);
106  dictionary gradDict;
107  dummyDict.add("gradSchemes", gradDict);
108  dictionary laplDict;
109  dummyDict.add("laplacianSchemes", laplDict);
110 
111  IOdictionary(io, dummyDict).regIOobject::write();
112  }
113  }
114  {
115  IOobject io
116  (
117  "fvSolution",
118  mesh.time().system(),
119  regionName,
120  mesh,
123  false
124  );
125 
126  if (!io.headerOk())
127  {
128  Info<< "Writing dummy " << regionName/io.name() << endl;
129  dictionary dummyDict;
130  IOdictionary(io, dummyDict).regIOobject::write();
131  }
132  }
133 }
134 
135 
137 {
138  const label patchID = patches.findPatchID(name);
139 
140  if (patchID == -1)
141  {
143  << "Cannot find patch " << name
144  << " in the source mesh.\n"
145  << "Valid patch names are " << patches.names()
146  << exit(FatalError);
147  }
148  return patchID;
149 }
150 
151 
153 {
154  label n = 0;
155 
156  forAll(names, i)
157  {
158  const polyPatch& pp = patches[findPatchID(patches, names[i])];
159 
160  n += pp.size();
161  }
162  labelList faceLabels(n);
163  n = 0;
164  forAll(names, i)
165  {
166  const polyPatch& pp = patches[findPatchID(patches, names[i])];
167 
168  forAll(pp, j)
169  {
170  faceLabels[n++] = pp.start()+j;
171  }
172  }
173 
174  return faceLabels;
175 }
176 
177 
178 void updateFaceLabels(const mapPolyMesh& map, labelList& faceLabels)
179 {
180  const labelList& reverseMap = map.reverseFaceMap();
181 
182  labelList newFaceLabels(faceLabels.size());
183  label newI = 0;
184 
185  forAll(faceLabels, i)
186  {
187  label oldFaceI = faceLabels[i];
188 
189  if (reverseMap[oldFaceI] >= 0)
190  {
191  newFaceLabels[newI++] = reverseMap[oldFaceI];
192  }
193  }
194  newFaceLabels.setSize(newI);
195  faceLabels.transfer(newFaceLabels);
196 }
197 
198 
199 void updateCellSet(const mapPolyMesh& map, labelHashSet& cellLabels)
200 {
201  const labelList& reverseMap = map.reverseCellMap();
202 
203  labelHashSet newCellLabels(2*cellLabels.size());
204 
205  forAll(cellLabels, i)
206  {
207  label oldCellI = cellLabels[i];
208 
209  if (reverseMap[oldCellI] >= 0)
210  {
211  newCellLabels.insert(reverseMap[oldCellI]);
212  }
213  }
214  cellLabels.transfer(newCellLabels);
215 }
216 
217 
218 template<class PatchType>
220 (
221  polyMesh& mesh,
222  const word& frontPatchName,
223  const word& backPatchName
224  )
225 {
227 
228  label frontPatchI = findPatchID(patches, frontPatchName);
229  label backPatchI = findPatchID(patches, backPatchName);
230 
231  DynamicList<polyPatch*> newPatches(patches.size());
232 
233  forAll(patches, patchI)
234  {
235  const polyPatch& pp(patches[patchI]);
236 
237  if (patchI == frontPatchI || patchI == backPatchI)
238  {
239  newPatches.append
240  (
241  new PatchType
242  (
243  pp.name(),
244  pp.size(),
245  pp.start(),
246  pp.index(),
247  mesh.boundaryMesh(),
248  PatchType::typeName
249  )
250  );
251  }
252  else
253  {
254  newPatches.append(pp.clone(mesh.boundaryMesh()).ptr());
255  }
256  }
257 
258  // Edit patches
260  mesh.addPatches(newPatches, true);
261 }
262 
263 
265 (
266  const dictionary& dict
267  )
268 {
269  const word modelType("linearDirection");
270 
271  Info<< "Selecting extrudeModel " << modelType << endl;
272 
273  dictionaryConstructorTable::iterator cstrIter =
274  dictionaryConstructorTablePtr_->find(modelType);
275 
276  if (cstrIter == dictionaryConstructorTablePtr_->end())
277  {
279  << "Unknown extrudeModel type "
280  << modelType << nl << nl
281  << "Valid extrudeModel types are :" << nl
282  << dictionaryConstructorTablePtr_->sortedToc() << nl
283  << exit(FatalError);
284  }
285 
286  return autoPtr<extrudeModel>(cstrIter()(dict));
287 }
288 
289 std::string replaceChar(std::string & SourceString, const std::string & strsrc, const std::string & strdst)
290 {
291 
293  std::string::size_type srclen = strsrc.size();
294  std::string::size_type dstlen = strdst.size();
295  std::string stringsource_new = SourceString;
296 
297  while ((pos = stringsource_new.find(strsrc, pos)) != std::string::npos)
298  {
299  stringsource_new.replace(pos, srclen, strdst);
300  pos += dstlen;
301  }
302  return stringsource_new;
303 }
304 
305 
306 
307 
308 std::string trim(std::string s)
309 {
310 
311 
312  if (s.empty())
313  {
314  return s;
315  }
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);
320  return s;
321 
322 }
323 std::vector<std::string> splitstring (std::string SourceString, std::string strSplit = " ", int nSkip = 0 )
324 {
325  std::vector<std::string> vecStr;
327 
328  char aa = '(';
329  char bb = ')';
330  char cc = '"';
331  char dd = '\'';
332  std::string stringsource_new;
333  for (int i = 0; i < (int)SourceString.length(); i++)
334  {
335  if (SourceString[i] == aa || SourceString[i] == bb || SourceString[i] == cc || SourceString[i] == dd)// || SourceString[i] == ee || SourceString[i] == ff)
336  {
337  }//std::cout << "add nothing" << std::endl;
338  else
339  stringsource_new.push_back(SourceString[i]);
340  }
341 
342  std::vector<std::string>::size_type ePos = stringsource_new.find(strSplit, sPos);
343 
344  while (ePos != std::string::npos)
345  {
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);
349  }
350  if (sPos < stringsource_new.size()) vecStr.push_back(trim(stringsource_new.substr(sPos, stringsource_new.size() - sPos)).c_str());
351 
352  return vecStr;
353 }
354 
355 
356 
357 
358 
359 
360 
361 int main(int argc, char *argv[])
362 {
363 #include "addRegionOption.H"
364 #include "addDictOption.H"
365 #include "setRootCase.H"
366 #include "createTimeExtruded.H"
367 #include "createTime.H"
368  //#include "createMesh.H"
369  // Get optional regionName
371  word regionDir;
372  if (args.optionReadIfPresent("region", regionName))
373  {
374  regionDir = regionName;
375  Info<< "Create mesh " << regionName << " for time = "
376  << runTimeExtruded.timeName() << nl << endl;
377  }
378  else
379  {
381  Info<< "Create mesh for time = "
382  << runTimeExtruded.timeName() << nl << endl;
383  }
384 
385  //get the extrudeMesh patches from the fvOptionsDict
386  const dictionary& fvOptionsDict = runTime.db().lookupObject<IOdictionary>("fvOptions");
387  const wordList& patchNames = fvOptionsDict.lookup("sourcePatches");
388  Info << "patchNames= " << patchNames << endl;
389 
390  const wordList& patchNamesA = fvOptionsDict.subDict("svenssonHaggkvistCanopySourceCoeffs").lookup("sourcePatches");
391  Info << "patchNamesA= " << patchNames << endl;
392 
393  const wordList& patchNamesB = fvOptionsDict.subDict("canopy").subDict("svenssonHaggkvistCanopySourceCoeffs").lookup("sourcePatches");
394  Info << "patchNamesB= " << patchNames << endl;
395 
396 
397  fileName dictPath = "";
398  std::string dictPara = "";
399  dictionary dict,subDict,subsubDict;
400  if (args.optionFound("dict"))
401  {
402  dictPara = args["dict"];
403  std::vector<std::string> paraList = splitstring(dictPara," ");
404  if (paraList[0]=="pkpmchenjia1008")
405  {
406 
407  // constructFrom mesh;
408  // sourceCase "D:/Projects/OFTest/tmp"; // para 1
409  // sourcePatches ( ground green_grass parking road water ); //para2
410  // flipNormals false;
411  // extrudeModel linearDirection;
412  // nLayers 6;
413  // expansionRatio 0.831398;
414  // linearDirectionCoeffs
415  // {
416  // axisPt ( 0 0 0 );
417  // direction ( 0 0 -1 );
418  // thickness 2;
419  // }
420  // mergeFaces false;
421  // mergeTol 0;
422  dict.add("constructFrom", word("mesh"));
423  dict.add("sourceCase", replaceChar(paraList[1],"\\","/"));
424  std::vector<std::string> nameList = splitstring(paraList[2]," ");
425  //List<std::string> patchestmp;
426  wordList patchestmp;
427  patchestmp=patchNamesA ;
428 
429 
430 
431 
432  // for (int i=0;i<nameList.size();i++)
433  // {
434  // const fvPatchList& patches = mesh_.boundary();
435  // forAll(patches,patchi) {
436 
437  // const fvPatch& curPatch = patches[patchi];
438  // if (curPatch.name().substr(0,5) == "green")
439  // {
440  // patchestmp.append(nameList[i]);
441  // }
442 
443  // }
444  // }
445  dict.add("sourcePatches", patchestmp);
446  dict.add("flipNormals", (word)"false");
447  dict.add("extrudeModel", (word)"linearDirection");
448  dict.add("nLayers", std::atoi(paraList[3].c_str()));
449  dict.add("expansionRatio", std::atof(paraList[4].c_str()));
450  //doubleScalar a1=0,a2=0,a3=0;
451  // vector axisPt(0,0,0);
452  Vector<doubleScalar> axisPt(0,0,0);
453  //VectorSpace<Vector<scalar>,scalar,1> aadd;
454  subDict.add("axisPt",axisPt);
455  float v1,v2,v3;
456  std::vector<std::string> vectorlist = splitstring(paraList[5]," ");
457  v1=std::atof(vectorlist[0].c_str());
458  v2=std::atof(vectorlist[1].c_str());
459  v3=std::atof(vectorlist[2].c_str());
460  Vector<doubleScalar> directionCom(v1,v2,v3);
461  subDict.add("direction",directionCom);
462  subDict.add("thickness",std::atoi(paraList[6].c_str()));
463  dict.add("linearDirectionCoeffs",subDict);
464  dict.add("mergeFaces",(word) "false");
465  doubleScalar tol=0.0;
466  dict.add("mergeTol", tol);
467  //Info << "my dict is == "<< dict << endl;
468  }
469  else
470  {
471  return 0;
472  }
473 
474  }
475 
476 
477 
478 
479 
480 
481 
482 
483 
484 
485 
486 
487  // Point generator
489  //Info << "dict=== " << dict << endl;
490  // Whether to flip normals
491  const Switch flipNormals(dict.lookup("flipNormals"));
492 
493  // What to extrude
494  const ExtrudeMode mode = ExtrudeModeNames.read
495  (
496  dict.lookup("constructFrom")
497  );
498 
499  // Any merging of small edges
500  const scalar mergeTol(dict.lookupOrDefault<scalar>("mergeTol", 1e-4));
501 
502  // Info<< "Extruding from " << ExtrudeModeNames[mode]
503  // << " using model " << model().type() << endl;
504  if (flipNormals)
505  {
506  Info<< "Flipping normals before extruding" << endl;
507  }
508  if (mergeTol > 0)
509  {
510  Info<< "Collapsing edges < " << mergeTol << " of bounding box" << endl;
511  }
512  else
513  {
514  Info<< "Not collapsing any edges after extrusion" << endl;
515  }
516  Info<< endl;
517 
518 
519  // Generated mesh (one of either)
520  autoPtr<fvMesh> meshFromMesh;
521  autoPtr<polyMesh> meshFromSurface;
522 
523  // Faces on front and back for stitching (in case of mergeFaces)
524  word frontPatchName;
525  labelList frontPatchFaces;
526  word backPatchName;
527  labelList backPatchFaces;
528 
529  // Optional added cells (get written to cellSet)
530  labelHashSet addedCellsSet;
531 
532  if (mode == PATCH || mode == MESH)
533  {
534  if (flipNormals && mode == MESH)
535  {
537  << "Flipping normals not supported for extrusions from mesh."
538  << exit(FatalError);
539  }
540 
541  fileName sourceCasePath(dict.lookup("sourceCase"));
542  sourceCasePath.expand();
543  fileName sourceRootDir = sourceCasePath.path();
544  // Info << sourceRootDir<< endl;
545 
546  fileName sourceCaseDir = sourceCasePath.name();
547  // Info << sourceCaseDir << endl;
548  if (Pstream::parRun())
549  {
550  sourceCaseDir =
551  sourceCaseDir
552  /"processor" + Foam::name(Pstream::myProcNo());
553 
554  }
555  wordList sourcePatches;
556  dict.lookup("sourcePatches") >> sourcePatches;
557 
558  if (sourcePatches.size() == 1)
559  {
560  frontPatchName = sourcePatches[0];
561  }
562 
563  // Info<< "Extruding patches " << sourcePatches
564  // << " on mesh " << sourceCasePath << nl
565  // << endl;
566 
567  Time runTime
568  (
570  sourceRootDir,
571  sourceCaseDir
572  );
573 
574 #include "createMesh.H"
575 
577 
578 
579  // Extrusion engine. Either adding to existing mesh or
580  // creating separate mesh.
581  addPatchCellLayer layerExtrude(mesh, (mode == MESH));
582 
583  const labelList meshFaces(patchFaces(patches, sourcePatches));
584 
585  if (mode == PATCH && flipNormals)
586  {
587  // Cheat. Flip patch faces in mesh. This invalidates the
588  // mesh (open cells) but does produce the correct extrusion.
589  polyTopoChange meshMod(mesh);
590  forAll(meshFaces, i)
591  {
592  label meshFaceI = meshFaces[i];
593 
594  label patchI = patches.whichPatch(meshFaceI);
595  label own = mesh.faceOwner()[meshFaceI];
596  label nei = -1;
597  if (patchI == -1)
598  {
599  nei = mesh.faceNeighbour()[meshFaceI];
600  }
601 
602  label zoneI = mesh.faceZones().whichZone(meshFaceI);
603  bool zoneFlip = false;
604  if (zoneI != -1)
605  {
606  label index = mesh.faceZones()[zoneI].whichFace(meshFaceI);
607  zoneFlip = mesh.faceZones()[zoneI].flipMap()[index];
608  }
609 
610  meshMod.modifyFace
611  (
612  mesh.faces()[meshFaceI].reverseFace(), // modified face
613  meshFaceI, // label of face
614  own, // owner
615  nei, // neighbour
616  true, // face flip
617  patchI, // patch for face
618  zoneI, // zone for face
619  zoneFlip // face flip in zone
620  );
621  }
622 
623  // Change the mesh. No inflation.
624  autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false);
625 
626  // Update fields
627  mesh.updateMesh(map);
628 
629  // Move mesh (since morphing does not do this)
630  if (map().hasMotionPoints())
631  {
632  mesh.movePoints(map().preMotionPoints());
633  }
634  }
635 
636 
637 
638  indirectPrimitivePatch extrudePatch
639  (
641  (
642  mesh.faces(),
643  meshFaces
644  ),
645  mesh.points()
646  );
647 
648  // Determine extrudePatch normal
649  pointField extrudePatchPointNormals
650  (
651  PatchTools::pointNormals(mesh, extrudePatch)
652  );
653 
654 
655  // Precalculate mesh edges for pp.edges.
656  const labelList meshEdges
657  (
658  extrudePatch.meshEdges
659  (
660  mesh.edges(),
661  mesh.pointEdges()
662  )
663  );
664 
665  // Global face indices engine
666  const globalIndex globalFaces(mesh.nFaces());
667 
668  // Determine extrudePatch.edgeFaces in global numbering (so across
669  // coupled patches)
670  labelListList edgeGlobalFaces
671  (
673  (
674  mesh,
675  globalFaces,
676  extrudePatch
677  )
678  );
679 
680 
681  // Determine what patches boundary edges need to get extruded into.
682  // This might actually cause edge-connected processors to become
683  // face-connected so might need to introduce new processor boundaries.
684  // Calculates:
685  // - per pp.edge the patch to extrude into
686  // - any additional processor boundaries (patchToNbrProc = map from
687  // new patchID to neighbour processor)
688  // - number of new patches (nPatches)
689 
690  labelList edgePatchID;
691  labelList edgeZoneID;
692  boolList edgeFlip;
693  labelList inflateFaceID;
694  label nPatches;
695  Map<label> nbrProcToPatch;
696  Map<label> patchToNbrProc;
698  (
699  true, // for internal edges get zone info from any face
700 
701  mesh,
702  globalFaces,
703  edgeGlobalFaces,
704  extrudePatch,
705 
706  edgePatchID,
707  nPatches,
708  nbrProcToPatch,
709  patchToNbrProc,
710 
711  edgeZoneID,
712  edgeFlip,
713  inflateFaceID
714  );
715 
716 
717  // Add any patches.
718 
719  label nAdded = nPatches - mesh.boundaryMesh().size();
720  reduce(nAdded, sumOp<label>());
721 
722  Info<< "Adding overall " << nAdded << " processor patches." << endl;
723 
724  if (nAdded > 0)
725  {
726  DynamicList<polyPatch*> newPatches(nPatches);
727  forAll(mesh.boundaryMesh(), patchI)
728  {
729  newPatches.append
730  (
731  mesh.boundaryMesh()[patchI].clone
732  (
734  ).ptr()
735  );
736  }
737  for
738  (
739  label patchI = mesh.boundaryMesh().size();
740  patchI < nPatches;
741  patchI++
742  )
743  {
744  label nbrProcI = patchToNbrProc[patchI];
745 
746  word name =
747  "procBoundary"
749  + "to"
750  + Foam::name(nbrProcI);
751 
752  Pout<< "Adding patch " << patchI
753  << " name:" << name
754  << " between " << Pstream::myProcNo()
755  << " and " << nbrProcI
756  << endl;
757 
758 
759  newPatches.append
760  (
762  (
763  name,
764  0, // size
765  mesh.nFaces(), // start
766  patchI, // index
767  mesh.boundaryMesh(),// polyBoundaryMesh
768  Pstream::myProcNo(),// myProcNo
769  nbrProcI // neighbProcNo
770  )
771  );
772  }
773 
774  // Add patches. Do no parallel updates.
776  mesh.addFvPatches(newPatches, true);
777  }
778 
779 
780 
781  // Only used for addPatchCellLayer into new mesh
782  labelList exposedPatchID;
783  if (mode == PATCH)
784  {
785  dict.lookup("exposedPatchName") >> backPatchName;
786  exposedPatchID.setSize
787  (
788  extrudePatch.size(),
789  findPatchID(patches, backPatchName)
790  );
791  }
792 
793  // Determine points and extrusion
794  pointField layer0Points(extrudePatch.nPoints());
795  pointField displacement(extrudePatch.nPoints());
796  forAll(displacement, pointI)
797  {
798  const vector& patchNormal = extrudePatchPointNormals[pointI];
799 
800  // layer0 point
801  layer0Points[pointI] = model()
802  (
803  extrudePatch.localPoints()[pointI],
804  patchNormal,
805  0
806  );
807  // layerN point
808  point extrudePt = model()
809  (
810  extrudePatch.localPoints()[pointI],
811  patchNormal,
812  model().nLayers()
813  );
814  displacement[pointI] = extrudePt - layer0Points[pointI];
815  }
816 
817 
818  // Check if wedge (has layer0 different from original patch points)
819  // If so move the mesh to starting position.
820  if (gMax(mag(layer0Points-extrudePatch.localPoints())) > SMALL)
821  {
822  Info<< "Moving mesh to layer0 points since differ from original"
823  << " points - this can happen for wedge extrusions." << nl
824  << endl;
825 
826  pointField newPoints(mesh.points());
827  forAll(extrudePatch.meshPoints(), i)
828  {
829  newPoints[extrudePatch.meshPoints()[i]] = layer0Points[i];
830  }
831  mesh.movePoints(newPoints);
832  }
833 
834 
835  // Layers per face
836  labelList nFaceLayers(extrudePatch.size(), model().nLayers());
837 
838  // Layers per point
839  labelList nPointLayers(extrudePatch.nPoints(), model().nLayers());
840 
841  // Displacement for first layer
842  vectorField firstLayerDisp(displacement*model().sumThickness(1));
843 
844  // Expansion ratio not used.
845  scalarField ratio(extrudePatch.nPoints(), 1.0);
846 
847  // Topo change container. Either copy an existing mesh or start
848  // with empty storage (number of patches only needed for checking)
850  (
851  (
852  mode == MESH
853  ? new polyTopoChange(mesh)
854  : new polyTopoChange(patches.size())
855  )
856  );
857 
858  layerExtrude.setRefinement
859  (
860  globalFaces,
861  edgeGlobalFaces,
862 
863  ratio, // expansion ratio
864  extrudePatch, // patch faces to extrude
865 
866  edgePatchID, // if boundary edge: patch for extruded face
867  edgeZoneID, // optional zone for extruded face
868  edgeFlip,
869  inflateFaceID, // mesh face that zone/patch info is from
870 
871  exposedPatchID, // if new mesh: patches for exposed faces
872  nFaceLayers,
873  nPointLayers,
874  firstLayerDisp,
875  meshMod()
876  );
877 
878  // Reset points according to extrusion model
879  forAll(layerExtrude.addedPoints(), pointI)
880  {
881  const labelList& pPoints = layerExtrude.addedPoints()[pointI];
882  forAll(pPoints, pPointI)
883  {
884  label meshPointI = pPoints[pPointI];
885 
886  point modelPt
887  (
888  model()
889  (
890  extrudePatch.localPoints()[pointI],
891  extrudePatchPointNormals[pointI],
892  pPointI+1 // layer
893  )
894  );
895 
896  const_cast<DynamicList<point>&>
897  (
898  meshMod().points()
899  )[meshPointI] = modelPt;
900  }
901  }
902 
903  // Store faces on front and exposed patch (if mode=patch there are
904  // only added faces so cannot used map to old faces)
905  const labelListList& layerFaces = layerExtrude.layerFaces();
906  backPatchFaces.setSize(layerFaces.size());
907  frontPatchFaces.setSize(layerFaces.size());
908  forAll(backPatchFaces, patchFaceI)
909  {
910  backPatchFaces[patchFaceI] = layerFaces[patchFaceI].first();
911  frontPatchFaces[patchFaceI] = layerFaces[patchFaceI].last();
912  }
913 
914 
915  // Create dummy fvSchemes, fvSolution
916  createDummyFvMeshFiles(mesh, regionDir);
917 
918  // Create actual mesh from polyTopoChange container
919  autoPtr<mapPolyMesh> map = meshMod().makeMesh
920  (
921  meshFromMesh,
922  IOobject
923  (
924  regionName,
925  runTimeExtruded.constant(),
926  runTimeExtruded,
929  false
930  ),
931  mesh
932  );
933 
934  layerExtrude.updateMesh
935  (
936  map(),
937  identity(extrudePatch.size()),
938  identity(extrudePatch.nPoints())
939  );
940 
941  // Calculate face labels for front and back.
942  frontPatchFaces = renumber
943  (
944  map().reverseFaceMap(),
945  frontPatchFaces
946  );
947  backPatchFaces = renumber
948  (
949  map().reverseFaceMap(),
950  backPatchFaces
951  );
952 
953  // Store added cells
954  if (mode == MESH)
955  {
956  const labelListList addedCells
957  (
958  layerExtrude.addedCells
959  (
960  meshFromMesh,
961  layerExtrude.layerFaces()
962  )
963  );
964  forAll(addedCells, faceI)
965  {
966  const labelList& aCells = addedCells[faceI];
967  forAll(aCells, i)
968  {
969  addedCellsSet.insert(aCells[i]);
970  }
971  }
972  }
973  }
974  else
975  {
976  // Read from surface
977  fileName surfName(dict.lookup("surface"));
978  surfName.expand();
979 
980  Info<< "Extruding surfaceMesh read from file " << surfName << nl
981  << endl;
982 
983  MeshedSurface<face> fMesh(surfName);
984 
985  if (flipNormals)
986  {
987  Info<< "Flipping faces." << nl << endl;
988  faceList& faces = const_cast<faceList&>(fMesh.faces());
989  forAll(faces, i)
990  {
991  faces[i] = fMesh[i].reverseFace();
992  }
993  }
994 
995  Info<< "Extruding surface with :" << nl
996  << " points : " << fMesh.points().size() << nl
997  << " faces : " << fMesh.size() << nl
998  << " normals[0] : " << fMesh.faceNormals()[0]
999  << nl
1000  << endl;
1001 
1002  meshFromSurface.reset
1003  (
1004  new extrudedMesh
1005  (
1006  IOobject
1007  (
1009  runTimeExtruded.constant(),
1010  runTimeExtruded
1011  ),
1012  fMesh,
1013  model()
1014  )
1015  );
1016 
1017 
1018  // Get the faces on front and back
1019  frontPatchName = "originalPatch";
1020  frontPatchFaces = patchFaces
1021  (
1022  meshFromSurface().boundaryMesh(),
1023  wordList(1, frontPatchName)
1024  );
1025  backPatchName = "otherSide";
1026  backPatchFaces = patchFaces
1027  (
1028  meshFromSurface().boundaryMesh(),
1029  wordList(1, backPatchName)
1030  );
1031  }
1032 
1033 
1034  polyMesh& mesh =
1035  (
1036  meshFromMesh.valid()
1037  ? meshFromMesh()
1038  : meshFromSurface()
1039  );
1040 
1041 
1042  const boundBox& bb = mesh.bounds();
1043  const vector span = bb.span();
1044  const scalar mergeDim = mergeTol * bb.minDim();
1045 
1046  Info<< "Mesh bounding box : " << bb << nl
1047  << " with span : " << span << nl
1048  << "Merge distance : " << mergeDim << nl
1049  << endl;
1050 
1051 
1052  // Collapse edges
1053  // ~~~~~~~~~~~~~~
1054 
1055  if (mergeDim > 0)
1056  {
1057  Info<< "Collapsing edges < " << mergeDim << " ..." << nl << endl;
1058 
1059  // Edge collapsing engine
1060  edgeCollapser collapser(mesh);
1061 
1062  const edgeList& edges = mesh.edges();
1063  const pointField& points = mesh.points();
1064 
1066  Map<point> collapsePointToLocation(mesh.nPoints());
1067 
1068  forAll(edges, edgeI)
1069  {
1070  const edge& e = edges[edgeI];
1071 
1072  scalar d = e.mag(points);
1073 
1074  if (d < mergeDim)
1075  {
1076  Info<< "Merging edge " << e << " since length " << d
1077  << " << " << mergeDim << nl;
1078 
1079  collapseEdge[edgeI] = true;
1080  collapsePointToLocation.set(e[1], points[e[0]]);
1081  }
1082  }
1083 
1084  List<pointEdgeCollapse> allPointInfo;
1086  labelList pointPriority(mesh.nPoints(), 0);
1087 
1088  collapser.consistentCollapse
1089  (
1090  globalPoints,
1091  pointPriority,
1092  collapsePointToLocation,
1093  collapseEdge,
1094  allPointInfo
1095  );
1096 
1097  // Topo change container
1098  polyTopoChange meshMod(mesh);
1099 
1100  // Put all modifications into meshMod
1101  bool anyChange = collapser.setRefinement(allPointInfo, meshMod);
1102 
1103  if (anyChange)
1104  {
1105  // Construct new mesh from polyTopoChange.
1106  autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false);
1107 
1108  // Update fields
1109  mesh.updateMesh(map);
1110 
1111  // Update stored data
1112  updateFaceLabels(map(), frontPatchFaces);
1113  updateFaceLabels(map(), backPatchFaces);
1114  updateCellSet(map(), addedCellsSet);
1115 
1116  // Move mesh (if inflation used)
1117  if (map().hasMotionPoints())
1118  {
1119  mesh.movePoints(map().preMotionPoints());
1120  }
1121  }
1122  }
1123 
1124 
1125  // Change the front and back patch types as required
1126  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1127 
1128  word frontBackType(word::null);
1129 
1130  if (isType<extrudeModels::wedge>(model()))
1131  {
1132  changeFrontBackPatches<wedgePolyPatch>
1133  (
1134  mesh,
1135  frontPatchName,
1136  backPatchName
1137  );
1138  }
1139  else if (isType<extrudeModels::plane>(model()))
1140  {
1141  changeFrontBackPatches<emptyPolyPatch>
1142  (
1143  mesh,
1144  frontPatchName,
1145  backPatchName
1146  );
1147  }
1148 
1149 
1150  // Merging front and back patch faces
1151  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1152 
1153  Switch mergeFaces(dict.lookup("mergeFaces"));
1154  if (mergeFaces)
1155  {
1156  if (mode == MESH)
1157  {
1159  << "Cannot stitch front and back of extrusion since"
1160  << " in 'mesh' mode (extrusion appended to mesh)."
1161  << exit(FatalError);
1162  }
1163 
1164  Info<< "Assuming full 360 degree axisymmetric case;"
1165  << " stitching faces on patches "
1166  << frontPatchName << " and "
1167  << backPatchName << " together ..." << nl << endl;
1168 
1169  if (frontPatchFaces.size() != backPatchFaces.size())
1170  {
1172  << "Differing number of faces on front ("
1173  << frontPatchFaces.size() << ") and back ("
1174  << backPatchFaces.size() << ")"
1175  << exit(FatalError);
1176  }
1177 
1178 
1179 
1180  polyTopoChanger stitcher(mesh);
1181  stitcher.setSize(1);
1182 
1183  const word cutZoneName("originalCutFaceZone");
1184 
1185  List<faceZone*> fz
1186  (
1187  1,
1188  new faceZone
1189  (
1190  cutZoneName,
1191  frontPatchFaces,
1192  boolList(frontPatchFaces.size(), false),
1193  0,
1194  mesh.faceZones()
1195  )
1196  );
1197 
1199 
1200  // Add the perfect interface mesh modifier
1201  perfectInterface perfectStitcher
1202  (
1203  "couple",
1204  0,
1205  stitcher,
1206  cutZoneName,
1207  word::null, // dummy patch name
1208  word::null // dummy patch name
1209  );
1210 
1211  // Topo change container
1212  polyTopoChange meshMod(mesh);
1213 
1214  perfectStitcher.setRefinement
1215  (
1217  (
1219  (
1220  mesh.faces(),
1221  frontPatchFaces
1222  ),
1223  mesh.points()
1224  ),
1226  (
1228  (
1229  mesh.faces(),
1230  backPatchFaces
1231  ),
1232  mesh.points()
1233  ),
1234  meshMod
1235  );
1236 
1237  // Construct new mesh from polyTopoChange.
1238  autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false);
1239 
1240  // Update fields
1241  mesh.updateMesh(map);
1242 
1243  // Update local data
1244  updateCellSet(map(), addedCellsSet);
1245 
1246  // Move mesh (if inflation used)
1247  if (map().hasMotionPoints())
1248  {
1249  mesh.movePoints(map().preMotionPoints());
1250  }
1251  }
1252 
1253  mesh.setInstance(runTimeExtruded.constant());
1254  Info<< "Writing mesh to " << mesh.objectPath() << nl << endl;
1255 
1256  if (!mesh.write())
1257  {
1259  << exit(FatalError);
1260  }
1261 
1262  // Need writing cellSet
1263  label nAdded = returnReduce(addedCellsSet.size(), sumOp<label>());
1264  if (nAdded > 0)
1265  {
1266  cellSet addedCells(mesh, "addedCells", addedCellsSet);
1267  Info<< "Writing added cells to cellSet " << addedCells.name()
1268  << nl << endl;
1269  if (!addedCells.write())
1270  {
1272  << addedCells.name()
1273  << exit(FatalError);
1274  }
1275  }
1276 
1277  Info<< "End\n" << endl;
1278 
1279  return 0;
1280 }
1281 
1282 
1283 // ************************************************************************* //
planeExtrusion.H
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
addPatchCellLayer.H
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:979
VectorSpace.H
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::doubleScalar
double doubleScalar
Double precision floating point scalar type.
Definition: doubleScalar.H:49
Foam::PackedBoolList
A bit-packed bool list.
Definition: PackedBoolList.H:63
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
main
int main(int argc, char *argv[])
Definition: extrudeMesh.C:260
IOstreams.H
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::globalPoints
Calculates points shared by more than two processor patches or cyclic patches.
Definition: globalPoints.H:100
createDummyFvMeshFiles
void createDummyFvMeshFiles(const polyMesh &mesh, const word &regionName)
Definition: extrudeMesh.C:79
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:86
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
Foam::IOobject::AUTO_WRITE
@ AUTO_WRITE
Definition: IOobject.H:117
nPatches
label nPatches
Definition: readKivaGrid.H:402
Foam::polyMesh::defaultRegion
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:306
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::HashTable::transfer
void transfer(HashTable< T, Key, Hash > &)
Transfer the contents of the argument table into this table.
Definition: HashTable.C:518
splitstring
std::vector< std::string > splitstring(std::string SourceString, std::string strSplit=" ", int nSkip=0)
Definition: extrudeMesh.C:323
Foam::addPatchCellLayer::globalEdgeFaces
static labelListList globalEdgeFaces(const polyMesh &, const globalIndex &globalFaces, const indirectPrimitivePatch &pp)
Per patch edge the pp faces (in global indices) using it. Uses.
Definition: addPatchCellLayer.C:618
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:3039
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:56
Foam::fvMesh::addFvPatches
void addFvPatches(const List< polyPatch * > &, const bool validBoundary=true)
Add boundary patches. Constructor helper.
Definition: fvMesh.C:462
wedgePolyPatch.H
Foam::PrimitivePatch::localPoints
const Field< PointType > & localPoints() const
Return pointField of points in patch.
Definition: PrimitivePatchTemplate.C:432
globalIndex.H
Foam::polyTopoChanger
List of mesh modifiers defining the mesh dynamics.
Definition: polyTopoChanger.H:56
polyTopoChanger.H
Foam::polyTopoChange::modifyFace
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.
Definition: polyTopoChange.C:2869
polyTopoChange.H
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:377
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::PrimitivePatch::meshEdges
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Return labels of patch edges in the global edge list using.
Definition: PrimitivePatchMeshEdges.C:41
Foam::polyTopoChange
Direct mesh changes based on v1.3 polyTopoChange syntax.
Definition: polyTopoChange.H:97
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
Foam::fileName::path
fileName path() const
Return directory path name (part before last /)
Definition: fileName.C:293
Foam::List::transfer
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Foam::dictionary::lookupOrDefault
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Definition: dictionaryTemplates.C:33
Foam::Map< label >
Foam::regIOobject::write
virtual bool write() const
Write using setting from DB.
Definition: regIOobjectWrite.C:126
Foam::fvMesh::removeFvBoundary
void removeFvBoundary()
Remove boundary patches. Warning: fvPatchFields hold ref to.
Definition: fvMesh.C:480
Foam::fvMesh::movePoints
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
Definition: fvMesh.C:726
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:421
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::primitiveMesh::edges
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
Definition: primitiveMeshEdges.C:353
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::primitiveMesh::pointEdges
const labelListList & pointEdges() const
Definition: primitiveMeshPointEdges.C:96
Foam::perfectInterface::setRefinement
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
Definition: perfectInterface.C:435
Foam::addPatchCellLayer::addedPoints
const labelListList & addedPoints() const
Added points per patch point.
Definition: addPatchCellLayer.H:306
Foam::HashSet< label, Hash< label > >
patchFaces
labelList patchFaces(const polyBoundaryMesh &patches, const wordList &names)
Definition: extrudeMesh.C:148
Foam::primitiveMesh::nEdges
label nEdges() const
Definition: primitiveMeshI.H:41
Foam::extrudeModel::New
static autoPtr< extrudeModel > New(const dictionary &)
Select null constructed.
Definition: extrudeModelNew.C:31
wedge.H
Foam::MeshedSurface::faces
const List< Face > & faces() const
Return const access to the faces.
Definition: MeshedSurface.H:301
Foam::mode
mode_t mode(const fileName &)
Return the file mode.
Definition: POSIX.C:573
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
Foam::fileName::name
word name() const
Return file name (part beyond last /)
Definition: fileName.C:212
changeFrontBackPatches
void changeFrontBackPatches(polyMesh &mesh, const word &frontPatchName, const word &backPatchName)
Definition: extrudeMesh.C:216
Foam::polyMesh::faceZones
const faceZoneMesh & faceZones() const
Return face zone mesh.
Definition: polyMesh.H:463
addDictOption.H
createTimeExtruded.H
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:54
Foam::renumber
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
Definition: ListOpsTemplates.C:32
Foam::edgeCollapser
Does polyTopoChanges to remove edges. Can remove faces due to edge collapse but can not remove cells ...
Definition: edgeCollapser.H:66
Foam::IOobject::objectPath
fileName objectPath() const
Return complete path + object name.
Definition: IOobject.H:376
Foam::boundBox::span
vector span() const
The bounding box span (from minimum to maximum)
Definition: boundBoxI.H:84
Foam::fvMesh::write
virtual bool write() const
Write mesh using IO settings from time.
Definition: fvMesh.C:873
PATCH
@ PATCH
Definition: extrudeMesh.C:61
Foam::IOobject::headerOk
bool headerOk()
Read and check header info.
Definition: IOobject.C:439
n
label n
Definition: TABSMDCalcMethod2.H:31
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::primitiveMesh::nPoints
label nPoints() const
Definition: primitiveMeshI.H:35
doubleScalar.H
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:43
updateFaceLabels
void updateFaceLabels(const mapPolyMesh &map, labelList &faceLabels)
Definition: extrudeMesh.C:174
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::TimePaths::system
const word & system() const
Return system name.
Definition: TimePaths.H:120
Foam::extrudedMesh
Definition: extrudedMesh.H:49
Foam::faceZone
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:64
edgeCollapser.H
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
MESH
@ MESH
Definition: extrudeMesh.C:60
extrudeModel.H
argList.H
Foam::polyMesh::faceOwner
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1017
Foam::IndirectList
A List with indirect addressing.
Definition: IndirectList.H:102
addRegionOption.H
Foam::fvMesh::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
Definition: fvMesh.C:802
Foam::boundBox::minDim
scalar minDim() const
Smallest length/height/width dimension.
Definition: boundBoxI.H:102
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobject.H:273
Foam::processorPolyPatch
Neighbour processor patch.
Definition: processorPolyPatch.H:55
size_type
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:73
patchNames
wordList patchNames(nPatches)
findPatchID
label findPatchID(const polyBoundaryMesh &patches, const word &name)
Definition: extrudeMesh.C:132
Foam::edgeCollapser::consistentCollapse
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.
Definition: edgeCollapser.C:1637
Foam::ZoneMesh::whichZone
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
Definition: ZoneMesh.C:226
Foam::identity
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Definition: ListOps.C:104
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::PrimitivePatch::nPoints
label nPoints() const
Return number of points supporting patch faces.
Definition: PrimitivePatchTemplate.H:293
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::HashTable::size
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
Foam::perfectInterface
Hack of attachDetach to couple patches when they perfectly align. Does not decouple....
Definition: perfectInterface.H:55
Foam::addPatchCellLayer
Adds layers of cells to outside of polyPatch. Can optionally create stand-alone extruded mesh (addToM...
Definition: addPatchCellLayer.H:125
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
fvMesh.H
Foam::edgeCollapser::setRefinement
bool setRefinement(const List< pointEdgeCollapse > &allPointInfo, polyTopoChange &meshMod) const
Play commands into polyTopoChange to create mesh.
Definition: edgeCollapser.C:1265
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::cellSet
A collection of cell labels.
Definition: cellSet.H:48
Foam::globalIndex
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:63
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
Foam::boolList
List< bool > boolList
Bool container classes.
Definition: boolList.H:50
s
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))
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
Foam::addPatchCellLayer::updateMesh
void updateMesh(const mapPolyMesh &, const labelList &faceMap, const labelList &pointMap)
Update any locally stored mesh information. Gets additional.
Definition: addPatchCellLayer.C:1972
emptyPolyPatch.H
Foam::DynamicList::append
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Foam::polyPatch::clone
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Definition: polyPatch.H:231
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::polyMesh::removeBoundary
void removeBoundary()
Remove boundary patches.
Definition: polyMeshClear.C:36
Foam::UPstream::myProcNo
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:405
Foam::addPatchCellLayer::layerFaces
const labelListList & layerFaces() const
Layer faces per patch face. See above.
Definition: addPatchCellLayer.H:312
Foam::mapPolyMesh::reverseFaceMap
const labelList & reverseFaceMap() const
Reverse face map.
Definition: mapPolyMesh.H:497
Foam::polyMesh::setInstance
void setInstance(const fileName &)
Set the instance for mesh files.
Definition: polyMeshIO.C:32
Foam::polyMesh::bounds
const boundBox & bounds() const
Return mesh bounding box.
Definition: polyMesh.H:427
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
setRootCase.H
Foam::mapPolyMesh::reverseCellMap
const labelList & reverseCellMap() const
Reverse cell map.
Definition: mapPolyMesh.H:528
SURFACE
@ SURFACE
Definition: extrudeMesh.C:62
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1004
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::primitiveMesh::nFaces
label nFaces() const
Definition: primitiveMeshI.H:58
Foam::sumOp
Definition: ops.H:162
Foam::Pout
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
Foam::PatchTools::pointNormals
static tmp< pointField > pointNormals(const polyMesh &, const PrimitivePatch< Face, FaceList, PointField, PointType > &)
Return parallel consistent point normals for patches using mesh points.
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:57
Foam::polyMesh::addPatches
void addPatches(const List< polyPatch * > &, const bool validBoundary=true)
Add boundary patches.
Definition: polyMesh.C:878
updateCellSet
void updateCellSet(const mapPolyMesh &map, labelHashSet &cellLabels)
Definition: extrudeMesh.C:195
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::addPatchCellLayer::calcExtrudeInfo
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:
Definition: addPatchCellLayer.C:663
Foam::IOobject::clone
Foam::autoPtr< IOobject > clone() const
Clone.
Definition: IOobject.H:252
Foam::string::expand
string & expand(const bool allowEmpty=false)
Expand initial tildes and all occurences of environment variables.
Definition: string.C:98
Foam::autoPtr::valid
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set).
Definition: autoPtrI.H:83
createMesh.H
MeshedSurfaces.H
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::PtrList::size
label size() const
Return the number of elements in the PtrList.
Definition: PtrListI.H:32
Foam::HashSet::insert
bool insert(const Key &key)
Insert a new entry.
Definition: HashSet.H:116
Foam::PtrList::setSize
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
Definition: PtrList.C:142
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
createTime.H
Foam::argList::optionFound
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:108
ExtrudeMode
ExtrudeMode
Definition: extrudeMesh.C:58
Foam::boundBox
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::autoPtr::reset
void reset(T *=0)
If object pointer already set, delete object and set to given.
Definition: autoPtrI.H:114
perfectInterface.H
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
Foam::boundaryMesh
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:59
patches
patches[0]
Definition: createSingleCellMesh.H:36
cellSet.H
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
collapseEdge
label collapseEdge(triSurface &surf, const scalar minLen)
Keep collapsing all edges < minLen.
Foam::PrimitivePatch::meshPoints
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Definition: PrimitivePatchTemplate.C:392
Foam::dictionary::subDict
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:631
Foam::MeshedSurface< face >
args
Foam::argList args(argc, argv)
Foam::Time::controlDictName
static word controlDictName
The default control dictionary name (normally "controlDict")
Definition: Time.H:213
Foam::MeshedSurface::size
label size() const
The surface size is the number of faces.
Definition: MeshedSurface.H:295
dictPath
fileName dictPath
Definition: setConstantMeshDictionaryIO.H:5
Foam::argList::optionReadIfPresent
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
Definition: argListI.H:198
Foam::patchIdentifier::name
const word & name() const
Return name.
Definition: patchIdentifier.H:109
Foam::patchIdentifier::index
label index() const
Return the index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:133
Foam::polyMesh::addZones
void addZones(const List< pointZone * > &pz, const List< faceZone * > &fz, const List< cellZone * > &cz)
Add mesh zones.
Definition: polyMesh.C:922
trim
std::string trim(std::string s)
Definition: extrudeMesh.C:308
Foam::gMax
Type gMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:562
replaceChar
std::string replaceChar(std::string &SourceString, const std::string &strsrc, const std::string &strdst)
Definition: extrudeMesh.C:289
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::polyMesh::faceNeighbour
virtual const labelList & faceNeighbour() const
Return face neighbour.
Definition: polyMesh.C:1023
Foam::dictionary::add
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:729
Foam::addPatchCellLayer::addedCells
static labelListList addedCells(const polyMesh &, const labelListList &layerFaces)
Helper: get added cells per patch face.
Definition: addPatchCellLayer.C:584
Foam::NamedEnum
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:52
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88
ExtrudeModeNames
static const NamedEnum< ExtrudeMode, 3 > ExtrudeModeNames
Definition: extrudeMesh.C:80
Foam::addPatchCellLayer::setRefinement
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.
Definition: addPatchCellLayer.C:1008
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:190