topOVariablesBase.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) 2007-2023 PCOpt/NTUA
9  Copyright (C) 2013-2023 FOSS GP
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 \*---------------------------------------------------------------------------*/
28 
29 #include "topOVariablesBase.H"
30 #include "pointMesh.H"
31 #include "topOZones.H"
32 #include "volFields.H"
33 #include "volPointInterpolation.H"
34 #include "wallFvPatch.H"
35 #include "coupledFvPatch.H"
36 #include "emptyFvPatch.H"
37 #include "MeshedSurfaceProxy.H"
38 #include "surfaceWriter.H"
39 #include "foamVtkSurfaceWriter.H"
41 
42 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
47 }
48 
49 
50 // * * * * * * * * * * * Protected Members Functions * * * * * * * * * * * * //
51 
53 (
54  const label facei
55 ) const
56 {
57  const fvMesh& mesh = zones_.mesh();
58  const labelListList& edgeFaces = mesh.edgeFaces();
59  DynamicList<label> neighs;
60  if (!mesh.isInternalFace(facei))
61  {
62  const labelList& faceEdges = mesh.faceEdges()[facei];
63  for (const label edgei: faceEdges)
64  {
65  const labelList& edgeIFaces = edgeFaces[edgei];
66  for (const label neiFacei : edgeIFaces)
67  {
68  if (neiFacei != facei && !mesh.isInternalFace(neiFacei))
69  {
70  const label patchi =
71  mesh.boundaryMesh().whichPatch(neiFacei);
72  if (!isA<emptyFvPatch>(mesh.boundary()[patchi]))
73  {
74  neighs.push_back(neiFacei);
75  }
76  }
77  }
78  }
79  }
80  return neighs;
81 }
82 
83 
85 (
86  const label facei,
87  const cutFaceIso& cutFace,
88  DynamicList<vector>& isoSurfPts,
89  DynamicList<face>& isoSurfFaces,
90  DynamicList<label>& zoneIDs,
91  List<DynamicList<label>>& cuttingFacesPerMeshFace
92 ) const
93 {
94  const fvMesh& mesh = zones_.mesh();
95  // If this is a boundary face being cut, append it to the iso-surface
96  if (!mesh.isInternalFace(facei))
97  {
98  const label cutPatchi = mesh.boundaryMesh().whichPatch(facei);
99  const fvPatch& cutPatch = mesh.boundary()[cutPatchi];
100  if (!isA<coupledFvPatch>(cutPatch) && !isA<emptyFvPatch>(cutPatch))
101  {
102  if
103  (
104  addCuttingFaceToIsoline
105  (
106  cutFace.subFacePoints(),
107  cutPatchi,
108  faceFaces(facei),
109  cuttingFacesPerMeshFace,
110  isoSurfPts,
111  isoSurfFaces,
112  zoneIDs
113  )
114  )
115  {
116  cuttingFacesPerMeshFace[facei].push_back
117  (
118  isoSurfFaces.size() - 1
119  );
120  return true;
121  }
122 
123  }
124  }
125  return false;
126 }
127 
128 
130 (
131  const DynamicList<point>& facePoints,
132  const label nSerialPatches,
133  const DynamicList<label>& cellCutFaces,
134  const List<DynamicList<label>>& cuttingFacesPerMeshFace,
135  DynamicList<vector>& isoSurfPts,
136  DynamicList<face>& isoSurfFaces,
137  DynamicList<label>& zoneIDs
138 ) const
139 {
140  if (facePoints.size() > 2)
141  {
142  // Check whether any of points of the new iso-surface face are already
143  // present in the surface. To reduce the number of comparisons, only
144  // points on iso-surface faces cutting the current cell are checked
145  labelList uniquePointIDs(facePoints.size(), -1);
146  DynamicList<point> uniqueFacePoints(facePoints.size());
147  DynamicList<label> uniqueFacePointEdges(facePoints.size());
148  label addedPoints = Zero;
149  forAll(facePoints, pi)
150  {
151  bool foundInNei = false;
152  for (const label cutMeshFacei : cellCutFaces)
153  {
154  if
155  (
156  isDuplicatePoint
157  (
158  pi,
159  facePoints[pi],
160  cuttingFacesPerMeshFace[cutMeshFacei],
161  isoSurfPts,
162  isoSurfFaces,
163  uniquePointIDs
164  )
165  )
166  {
167  foundInNei = true;
168  break;
169  }
170  }
171  if (!foundInNei)
172  {
173  uniquePointIDs[pi] = isoSurfPts.size() + addedPoints;
174  ++addedPoints;
175  uniqueFacePoints.push_back(facePoints[pi]);
176  }
177  }
178 
179  face isoFace(uniquePointIDs);
180  isoSurfPts.append(uniqueFacePoints);
181  isoSurfFaces.append(isoFace);
182  zoneIDs.append(nSerialPatches);
183 
184  return true;
185  }
186  return false;
187 }
188 
189 
191 (
192  const label pointID,
193  const vector& pointi,
194  const DynamicList<label>& cuttingFaces,
195  const DynamicList<point>& isoSurfPts,
196  const DynamicList<face>& isoSurfFaces,
197  labelList& uniquePointIDs
198 ) const
199 {
200  for (const label cuttingFacei : cuttingFaces)
201  {
202  const face& cuttingFace = isoSurfFaces[cuttingFacei];
203  for (const label neiPi : cuttingFace)
204  {
205  if (mag(pointi - isoSurfPts[neiPi]) < SMALL)
206  {
207  uniquePointIDs[pointID] = neiPi;
208  return true;
209  }
210  }
211  }
212  return false;
213 }
214 
215 
217 (
218  const pointScalarField& pointY,
219  const Map<label>& addedFaces,
220  const scalar isoValue,
221  DynamicList<vector>& isoSurfPts,
222  DynamicList<face>& isoSurfFaces,
223  DynamicList<label>& zoneIDs,
224  label& nChangedFaces,
225  labelList& changedFaces,
226  List<wallPointData<label>>& changedFacesInfo,
227  labelList& changedFaceToCutFace,
228  List<DynamicList<label>>& cuttingFacesPerMeshFace
229 )
230 {
231  const fvMesh& mesh = zones_.mesh();
232  const pointField& points = mesh.points();
233  const faceList& faces = mesh.faces();
234  forAll(mesh.boundary(), patchi)
235  {
236  const fvPatch& patch = mesh.boundary()[patchi];
237  bool isWall = isA<wallFvPatch>(patch);
238  if (!isA<emptyFvPatch>(patch) && !isA<coupledFvPatch>(patch))
239  {
240  const label start = patch.start();
241  forAll(patch, facei)
242  {
243  const label gFacei = start + facei;
244  // On rare occasions, a face value might be negative but all
245  // point values are positive. In such a case, the face won't be
246  // cut and is seen as a fluid face. Hence, the point values are
247  // used to determine the status of the boundary face.
248  bool isFluid(true);
249  for (const label pti : mesh.faces()[gFacei])
250  {
251  isFluid = isFluid && (pointY[pti] >= isoValue);
252  }
253  if (isFluid && !addedFaces.found(gFacei))
254  {
255  // Insert wall faces if they belong to the outer boundary
256  if (isWall)
257  {
258  // Mesh face to changedFace addressing
259  meshFaceToChangedFace_.insert(gFacei, nChangedFaces);
260  // Set origin face for meshWave
261  changedFacesInfo[nChangedFaces] =
262  wallPointData<label>
263  (
264  patch.Cf()[facei],
265  nChangedFaces,
266  0
267  );
268  changedFaces[nChangedFaces] = gFacei;
269  // Origin face-to-cut face
270  changedFaceToCutFace.push_back(isoSurfFaces.size());
271  ++nChangedFaces;
272  }
273 
274  if
275  (
276  addCuttingFaceToIsoline
277  (
278  faces[gFacei].points(points),
279  patchi,
280  faceFaces(gFacei),
281  cuttingFacesPerMeshFace,
282  isoSurfPts,
283  isoSurfFaces,
284  zoneIDs
285  )
286  )
287  {
288  cuttingFacesPerMeshFace[gFacei].push_back
289  (
290  isoSurfFaces.size() - 1
291  );
292  }
293  }
294  }
295  }
296  }
297 }
298 
299 
301 (
302  const pointField& pts,
303  const faceList& faces,
304  const labelList& zoneIds,
305  const label nSerialPatches
306 ) const
307 {
308  const fvMesh& mesh = zones_.mesh();
309 
310  // Write vtp file
311  const word timeName = mesh.time().timeName();
312  fileName localName("topOIsoSurface" + timeName);
313  fileName fname(isoSurfFolder_/localName);
314  vtk::surfaceWriter vtkFile(pts, faces, fname);
315  vtkFile.beginFile();
316  vtkFile.writeGeometry();
317  vtkFile.beginCellData(1);
318  vtkFile.writeCellData("zoneIds", zoneIds);
319  vtkFile.close();
320 
321  // It appears that there is no interface to write a multi-zone stl file (?)
322  // Follow a process similar to proxySurfaceWriter, but also use the zoneIds.
323 
324  // Dummy faceIds.
325  // faceMap is built after merging the geometry from all processors, to
326  // be based on the global addressing
327  labelList faceIds;
328 
329  autoPtr<meshedSurf> surf(nullptr);
330  if (Pstream::parRun())
331  {
332  surf.reset
333  (
334  autoPtr<meshedSurf>::NewFrom<mergedSurf>
335  (
336  pts, faces, zoneIds, faceIds, surfaceWriter::defaultMergeDim
337  )
338  );
339  }
340  else
341  {
342  surf.reset
343  (
344  autoPtr<meshedSurf>::NewFrom<meshedSurfRef>
345  (
346  pts, faces, zoneIds, faceIds
347  )
348  );
349  }
350 
351  if (Pstream::master())
352  {
353  const faceList& surfFaces = surf().faces();
354  const labelList& surfZoneIds = surf().zoneIds();
355 
356  // Size per zone
357  labelList zoneSizes(nSerialPatches + 1, 0);
358  forAll(surfFaces, fi)
359  {
360  ++zoneSizes[surfZoneIds[fi]];
361  }
362 
363  // Faces passed in previous zones
364  labelList cumulZoneSizes(nSerialPatches + 1, 0);
365  for (label zi = 1; zi < cumulZoneSizes.size(); ++zi)
366  {
367  cumulZoneSizes[zi] = cumulZoneSizes[zi - 1] + zoneSizes[zi - 1];
368  }
369 
370  // Construction of the faceMap
371  // ---------------------------
372  labelList faceMap(surfFaces.size(), -1);
373  // Faces visited so far per zone
374  labelList passedFacesPerZone(surfZoneIds.size(), 0);
375 
376  forAll(surfFaces, fi)
377  {
378  const label zi = surfZoneIds[fi];
379  faceMap[cumulZoneSizes[zi] + passedFacesPerZone[zi]] = fi;
380  ++passedFacesPerZone[zi];
381  }
382 
383  // Construction of the surfZoneList
384  // --------------------------------
385  List<surfZone> surfZones(nSerialPatches + 1);
386  label zi = 0;
387  forAll(mesh.boundary(), pi)
388  {
389  const fvPatch& patch = mesh.boundary()[pi];
390  const word& name = patch.name();
391  if (!isA<coupledFvPatch>(patch) && !isA<emptyFvPatch>(patch))
392  {
393  surfZones[zi] =
394  surfZone(name, zoneSizes[zi], cumulZoneSizes[zi], zi);
395  zi++;
396  }
397  }
398  surfZones[zi] =
399  surfZone
400  (
401  "topOPatch",
402  zoneSizes[nSerialPatches],
403  cumulZoneSizes[nSerialPatches],
404  zi
405  );
406  surfZones.setSize(zi + 1);
407 
408  MeshedSurfaceProxy<face>
409  (
410  surf().points(),
411  surfFaces,
412  surfZones,
413  faceMap
414  ).write
415  (
416  fname + ".stl"
417  // BINARY seems to loose the patch names
418  //IOstreamOption
419  //(
420  // IOstreamOption::streamFormat::ASCII,
421  // IOstreamOption::compressionType::COMPRESSED
422  //)
423  );
424  }
425 }
426 
427 
428 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
429 
430 Foam::topOVariablesBase::topOVariablesBase
431 (
432  fvMesh& mesh,
433  const dictionary& dict
434 )
435 :
436  localIOdictionary
437  (
438  IOobject
439  (
440  "topOVars",
441  mesh.time().timeName(),
442  fileName("uniform"),
443  mesh,
444  IOobject::READ_IF_PRESENT,
445  IOobject::AUTO_WRITE
446  ),
447  word::null
448  ),
449  zones_(mesh, dict),
450  isoSurfFolder_
451  (mesh.time().globalPath()/"optimisation"/"topOIsoSurfaces"),
452  meshFaceToChangedFace_(),
453  //changedFacesPerCuttingFace_(),
454  surfPoints_(),
455  surfFaces_()
456 {
458 }
459 
460 
461 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * //
462 
464 (
466  const topOInterpolationFunction& interpolationFunc,
467  const scalar betaMax,
468  const word& interpolationFieldName
469 ) const
470 {
471  // Interpolate based on beta values
472  const scalarField& beta = this->beta().primitiveField();
473  interpolationFunc.interpolate(beta, field.field());
474  field *= betaMax;
475 }
476 
477 
479 (
480  scalarField& sens,
481  const topOInterpolationFunction& interpolationFunc,
482  const scalar betaMax,
483  const word& designVariablesName,
484  const word& interpolationFieldName
485 ) const
486 {
487  if (designVariablesName == "beta")
488  {
489  // Multiply with derivative of the interpolation function
490  const scalarField& beta = this->beta().primitiveField();
491  sens *= betaMax*interpolationFunc.derivative(beta);
492  }
493 }
494 
495 
497 (
498  const volScalarField& indicator,
499  const scalar isoValue,
500  labelList& changedFaces,
501  List<wallPointData<label>>& changedFacesInfo
502 )
503 {
504  const fvMesh& mesh = zones_.mesh();
505 
506  // Current number of mesh faces being cut
507  label nChangedFaces(0);
508 
509  // Indicator at the mesh points, used to compute the iso-surface
510  pointScalarField pointY(volPointInterpolation(mesh).interpolate(indicator));
511  if (debug && mesh.time().writeTime())
512  {
513  pointY.rename("pointY");
514  pointY.write();
515  }
516 
517  // Storage for the cutting face/cell mechanism
518  cutCellIso cutCell(mesh, pointY);
519  cutFaceIso cutFace(mesh, pointY);
520  DynamicList<face> isoSurfFaces(mesh.nFaces()/100);
521  DynamicList<point> isoSurfPts(mesh.nPoints()/100);
522  DynamicList<label> zoneIDs(mesh.nFaces()/100);
523 
524  // Number of patches before processor ones
525  label nSerialPatches = mesh.boundaryMesh().nNonProcessor();
526 
527  // Map between iso-surface and mesh faces (internal and boundary)
528  meshFaceToChangedFace_.clearStorage();
529 
530  // Map between changedFace and cutFace
531  // Index is the changedFaceID, output is the cutFaceID
532  DynamicList<label> changedFaceToCutFace;
533 
534  // Per mesh face, its cutting faces
535  List<DynamicList<label>> cuttingFacesPerMeshFace(mesh.nFaces());
536 
537  // Loop over cells and check whether they are cut by zero iso-surface
538  const cellList& cells = mesh.cells();
539 
540  forAll(cells, celli)
541  {
542  if (!cutCell.calcSubCell(celli, isoValue))
543  {
544  const vector& cuttingCf = cutCell.faceCentre();
545  vector cuttingNf = cutCell.faceArea();
546  cuttingNf.normalise();
547  DynamicList<label> cellCutFaces(cells[celli].size());
548 
549  // Loop over faces of the cut cell and check whether they are cut
550  // too, setting their distance from the cutting face
551  forAll(cells[celli], fi)
552  {
553  const label facei = cells[celli][fi];
554  if (!cutFace.calcSubFace(facei, isoValue))
555  {
556  const vector& Cf = mesh.Cf()[facei];
557  const scalar distSqr =
558  magSqr((Cf - cuttingCf) & cuttingNf);
559  const vector lsPoint =
560  Cf + ((cuttingCf - Cf) & cuttingNf)*cuttingNf;
561  cellCutFaces.push_back(facei);
562 
563  if (!meshFaceToChangedFace_.found(facei))
564  {
565  // If the face being cut is a boundary one, part of
566  // it belongs to the iso-surface
567  bool addedToIsoSurf = addCutBoundaryFaceToIsoline
568  (
569  facei,
570  cutFace,
571  isoSurfPts,
572  isoSurfFaces,
573  zoneIDs,
574  cuttingFacesPerMeshFace
575  );
576  if (mesh.isInternalFace(facei) || addedToIsoSurf)
577  {
578  // Mesh face to changedFace addressing
579  meshFaceToChangedFace_.insert(facei, nChangedFaces);
580  // Set origin face for meshWave
581  changedFacesInfo[nChangedFaces] =
582  wallPointData<label>
583  (
584  lsPoint,
585  nChangedFaces,
586  distSqr
587  );
588  changedFaces[nChangedFaces] = facei;
589  // Origin face-to-cut face
590  changedFaceToCutFace.push_back(isoSurfFaces.size());
591  ++nChangedFaces;
592  }
593  }
594  else
595  {
596  label visitedFace = meshFaceToChangedFace_.at(facei);
597  if (distSqr < changedFacesInfo[visitedFace].distSqr())
598  {
599  // Set origin face for meshWave
600  changedFacesInfo[visitedFace] =
601  wallPointData<label>
602  (
603  lsPoint,
604  visitedFace,
605  distSqr
606  );
607  // Origin face-to-cut face
608  changedFaceToCutFace[visitedFace] =
609  isoSurfFaces.size();
610  }
611  }
612  }
613  }
614 
615  if
616  (
617  addCuttingFaceToIsoline
618  (
619  cutCell.facePoints(),
620  nSerialPatches,
621  cellCutFaces,
622  cuttingFacesPerMeshFace,
623  isoSurfPts,
624  isoSurfFaces,
625  zoneIDs
626  )
627  )
628  {
629  for (const label facei : cellCutFaces)
630  {
631  cuttingFacesPerMeshFace[facei].push_back
632  (
633  isoSurfFaces.size() - 1
634  );
635  }
636  }
637  }
638  }
639 
640  // Add boundary faces on the initial domain with a positive values on all
641  // points to the zero iso-surface
642  addBoundaryFacesToIsoline
643  (
644  pointY,
645  meshFaceToChangedFace_,
646  isoValue,
647  isoSurfPts,
648  isoSurfFaces,
649  zoneIDs,
650  nChangedFaces,
651  changedFaces,
652  changedFacesInfo,
653  changedFaceToCutFace,
654  cuttingFacesPerMeshFace
655  );
656 
657  changedFaces.setSize(nChangedFaces);
658  changedFacesInfo.setSize(nChangedFaces);
659 
660  // vtp and multi-region stl files holding the current geometry
661  surfPoints_.transfer(isoSurfPts);
662  surfFaces_.transfer(isoSurfFaces);
663 
664  const labelList zoneIds(std::move(zoneIDs));
665  writeSurfaceFiles(surfPoints_, surfFaces_, zoneIds, nSerialPatches);
666 
667  // Invert changedFace-to-cuttingFace map for the sensitivity computations
668  //changedFacesPerCuttingFace_ =
669  // invertOneToMany(surfFaces_.size(), changedFaceToCutFace);
670 
671  // Transform origin cut faces to a global numbering
672  labelList cuttingFacesPerProc(Pstream::nProcs(), Zero);
673  cuttingFacesPerProc[Pstream::myProcNo()] = changedFaces.size();
674  Pstream::listCombineReduce(cuttingFacesPerProc, plusEqOp<label>());
675 
676  labelList passedFaces(Pstream::nProcs(), Zero);
677  for (label i = 1; i < Pstream::nProcs(); ++i)
678  {
679  passedFaces[i] = passedFaces[i - 1] + cuttingFacesPerProc[i - 1];
680  }
681 
682  forAll(changedFacesInfo, facei)
683  {
684  changedFacesInfo[facei].data() += passedFaces[Pstream::myProcNo()];
685  }
686 }
687 
688 
689 // ************************************************************************* //
bool addCuttingFaceToIsoline(const DynamicList< point > &facePoints, const label nSerialPatches, const DynamicList< label > &cellCutFaces, const List< DynamicList< label >> &cuttingFacesPerMeshFace, DynamicList< vector > &isoSurfPts, DynamicList< face > &isoSurfFaces, DynamicList< label > &zoneIDs) const
Add the cutting face to the zero level-set iso-surface.
dictionary dict
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
const labelIOList & zoneIDs
Definition: correctPhi.H:59
rDeltaTY field()
List< cell > cellList
List of cell.
Definition: cellListFwd.H:39
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label nPoints() const noexcept
Number of mesh points.
const surfaceVectorField & Cf() const
Return face centres as surfaceVectorField.
void append(const T &val)
Append an element at the end of the list.
Definition: List.H:517
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
topOZones zones_
Cell zones useful for defining the constant and changing parts of the domain in topO.
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1049
const cellList & cells() const
Vector< Cmpt > & normalise(const scalar tol=ROOTVSMALL)
Inplace normalise the vector by its magnitude.
Definition: VectorI.H:114
bool isDuplicatePoint(const label pointID, const vector &pointi, const DynamicList< label > &cuttingFaces, const DynamicList< point > &isoSurfPts, const DynamicList< face > &isoSurfFaces, labelList &uniquePointIDs) const
bool writeTime() const noexcept
True if this is a write interval.
Definition: TimeStateI.H:73
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
Definition: UPstream.H:1074
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:360
label nFaces() const noexcept
Number of mesh faces.
label calcSubFace(const label faceI, const scalar cutValue)
Calculate cut points along edges of faceI.
Definition: cutFaceIso.C:47
Macros for easy insertion into run-time selection tables.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
DynamicList< label > faceFaces(const label facei) const
Construct facesFaces for a given boundary face.
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1078
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:81
static scalar defaultMergeDim
The default merge dimension (1e-8)
List< face > faceList
List of faces.
Definition: faceListFwd.H:39
word timeName
Definition: getTimeIndex.H:3
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
Definition: UPstream.H:1065
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
dynamicFvMesh & mesh
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
Definition: POSIX.C:614
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
const cellShapeList & cells
const pointField & points
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:51
virtual void sourceTerm(DimensionedField< scalar, volMesh > &field, const topOInterpolationFunction &interpolationFunc, const scalar betaMax, const word &interpolationFieldName="beta") const
Populate source terms for the flow equations.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition: polyMesh.H:608
A class for handling words, derived from Foam::string.
Definition: word.H:63
fileName isoSurfFolder_
Folder name holding the zero level-set iso-surface.
virtual void sourceTermSensitivities(scalarField &sens, const topOInterpolationFunction &interpolationFunc, const scalar betaMax, const word &designVariablesName, const word &interpolationFieldName="beta") const
Post-processing sensitivities due to interpolations based on the indicator fields.
constexpr scalar pi(M_PI)
Vector< scalar > vector
Definition: vector.H:57
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1103
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
virtual tmp< scalarField > derivative(const scalarField &arg) const =0
Return of function with respect to the argument field.
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
Definition: Time.C:714
int debug
Static debugging option.
Base class for selecting the betaMax value, i.e. the value multiplying the Brinkman penalisation term...
Definition: betaMax.H:49
defineTypeNameAndDebug(combustionModel, 0)
void writeFluidSolidInterface(const volScalarField &indicator, const scalar isoValue, labelList &changedFaces, List< wallPointData< label >> &changedFacesInfo)
Write the fluid-solid interface to files.
const fvMesh & mesh() const
Const reference to mesh.
Definition: topOZones.H:161
void push_back(const T &val)
Copy append an element to the end of this list.
Definition: DynamicListI.H:555
void addBoundaryFacesToIsoline(const pointScalarField &pointY, const Map< label > &addedFaces, const scalar isoValue, DynamicList< vector > &isoSurfPts, DynamicList< face > &isoSurfFaces, DynamicList< label > &zoneIDs, label &nChangedFaces, labelList &changedFaces, List< wallPointData< label >> &changedFacesInfo, labelList &changedFaceToCutFace, List< DynamicList< label >> &cuttingFacesPerMeshFace)
Check whether the boundary faces of the initial domain belong to the fluid part and add them to the s...
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
Definition: UPstream.H:1082
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
void push_back(T *ptr)
Append an element to the end of the list.
Definition: PtrListI.H:114
const std::string patch
OpenFOAM patch number as a std::string.
virtual void interpolate(const scalarField &arg, scalarField &res) const =0
Interpolate argument to result.
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Definition: fvMesh.H:395
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
List< label > labelList
A List of labels.
Definition: List.H:62
bool addCutBoundaryFaceToIsoline(const label facei, const cutFaceIso &cutFace, DynamicList< vector > &isoSurfPts, DynamicList< face > &isoSurfFaces, DynamicList< label > &zoneIDs, List< DynamicList< label >> &cuttingFacesPerMeshFace) const
Check whether the cutFace intersects the boundary of the initial domain and add fluid part of the int...
label nNonProcessor() const
The number of patches before the first processor patch.
void writeSurfaceFiles(const pointField &pts, const faceList &faces, const labelList &zoneIds, const label nSerialPatches) const
Write the surface describing the fluid domain to stl and vtp files.
Base class for all design variables related to topology optimisation (topO). Provides the lookup func...
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Namespace for OpenFOAM.
static void listCombineReduce(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
After completion all processors have the same data.
const pointField & pts
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127