Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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"
34#include "wallFvPatch.H"
35#include "coupledFvPatch.H"
36#include "emptyFvPatch.H"
37#include "MeshedSurfaceProxy.H"
38#include "surfaceWriter.H"
41
42// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43
44namespace Foam
46 defineTypeNameAndDebug(topOVariablesBase, 0);
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,
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 }
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,
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);
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;
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,
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);
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] =
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 }
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 (
335 (
336 pts, faces, zoneIds, faceIds, surfaceWriter::defaultMergeDim
337 )
338 );
339 }
340 else
341 {
342 surf.reset
343 (
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;
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] =
400 (
401 "topOPatch",
402 zoneSizes[nSerialPatches],
403 cumulZoneSizes[nSerialPatches],
404 zi
405 );
406 surfZones.setSize(zi + 1);
407
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
430Foam::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_()
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);
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] =
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] =
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
673 const label changedFacesOffset =
674 globalIndex::calcOffset(changedFaces.size());
675
676 for (auto& info : changedFacesInfo)
677 {
678 info.data() += changedFacesOffset;
679 }
680}
681
682
683// ************************************************************************* //
constexpr scalar pi(M_PI)
Macros for easy insertion into run-time selection tables.
label size() const noexcept
The number of elements in list.
Definition DLListBase.H:194
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
void append(const T &val)
Copy append an element to the end of this list.
void push_back(const T &val)
Copy append an element to the end of this list.
bool found(const Key &key) const
Same as contains().
Definition HashTable.H:1370
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
const Time & time() const noexcept
Return Time associated with the objectRegistry.
Definition IOobject.C:456
InfoProxy< IOobject > info() const noexcept
Return info proxy, for printing information to a stream.
Definition IOobject.H:1041
fileName globalPath() const
The complete global path for the object (with instance, local,...).
Definition IOobject.C:512
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
void append(const T &val)
Append an element at the end of the list.
Definition List.H:497
void push_back(const T &val)
Append an element at the end of the list.
Definition ListI.H:221
void setSize(label n)
Alias for resize().
Definition List.H:536
A HashTable to objects of type <T> with a label key.
Definition Map.H:54
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
static void write(const fileName &name, const MeshedSurfaceProxy &surf, IOstreamOption streamOpt=IOstreamOption(), const dictionary &options=dictionary::null)
Write to file, select based on its extension.
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
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
Definition UPstream.H:1669
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
Definition UPstream.H:1714
Vector< Cmpt > & normalise(const scalar tol=ROOTVSMALL)
Inplace normalise the vector by its magnitude.
Definition VectorI.H:114
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< T > NewFrom(Args &&... args)
Construct autoPtr from derived type with forwarding arguments.
Definition autoPtr.H:193
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Definition autoPtrI.H:37
const word & name() const
Name function is needed to disambiguate those inherited from regIOobject and dictionary.
Base class for selecting the betaMax value, i.e. the value multiplying the Brinkman penalisation term...
Definition betaMax.H:50
Class for cutting a cell, celli, of an fvMesh, mesh_, at its intersection with an isosurface defined ...
Definition cutCellIso.H:75
Service routines for cutting a cell, celli, of an fvMesh, mesh_, at its intersection with a surface.
Definition cutCell.H:56
Class for cutting a face, faceI, of an fvMesh, mesh_, at its intersection with an isosurface defined ...
Definition cutFaceIso.H:67
Base class for cutting a face, faceI, of an fvMesh, mesh_, at its intersections.
Definition cutFace.H:56
void calcSubFace(const label faceI, const scalarList &pointStatus, label firstFullySubmergedPoint, DynamicList< point > &subFacePoints, DynamicList< point > &surfacePoints, label &faceStatus, vector &subFaceCentre, vector &subFaceArea)
Calculate cut points along edges of face with pointStatus, pointfield and computes geometric informat...
Definition cutFace.C:33
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition dictionary.H:487
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
A class for handling file names.
Definition fileName.H:75
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
const Time & time() const
Return the top-level database.
Definition fvMesh.H:360
const surfaceVectorField & Cf() const
Return face centres as surfaceVectorField.
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Definition fvMesh.H:395
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
static IntType calcOffset(IntType localSize, const label comm=UPstream::worldComm)
Based on the local input size(s), calculate a globally-consistent local start offset.
localIOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.
label nNonProcessor() const
The number of patches before the first processor patch.
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition polyMesh.H:609
virtual const faceList & faces() const
Return raw faces.
Definition polyMesh.C:1088
virtual const pointField & points() const
Return raw points.
Definition polyMesh.C:1063
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
label nPoints() const noexcept
Number of mesh points.
label nFaces() const noexcept
Number of mesh faces.
const cellList & cells() const
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
virtual void rename(const word &newName)
Rename.
A surface zone on a MeshedSurface.
Definition surfZone.H:55
static scalar defaultMergeDim
The default merge dimension (1e-8).
virtual tmp< scalarField > derivative(const scalarField &arg) const =0
Return of function with respect to the argument field.
virtual void interpolate(const scalarField &arg, scalarField &res) const =0
Interpolate argument to result.
Base class for all design variables related to topology optimisation (topO). Provides the lookup func...
void writeFluidSolidInterface(const volScalarField &indicator, const scalar isoValue, labelList &changedFaces, List< wallPointData< label > > &changedFacesInfo)
Write the fluid-solid interface to files.
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.
Map< label > meshFaceToChangedFace_
Map between iso-surface and mesh faces (internal and boundary).
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...
topOZones zones_
Cell zones useful for defining the constant and changing parts of the domain in topO.
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.
fileName isoSurfFolder_
Folder name holding the zero level-set iso-surface.
DynamicList< label > faceFaces(const label facei) const
Construct facesFaces for a given boundary face.
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...
virtual const volScalarField & beta() const =0
Get field used for physical interpolations.
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.
pointField surfPoints_
Per cutting face, the changed faces owned by it.
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.
faceList surfFaces_
Iso-surface faces.
bool isDuplicatePoint(const label pointID, const vector &pointi, const DynamicList< label > &cuttingFaces, const DynamicList< point > &isoSurfPts, const DynamicList< face > &isoSurfFaces, labelList &uniquePointIDs) const
const fvMesh & mesh() const
Const reference to mesh.
Definition topOZones.H:161
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Interpolate from cell centres to points (vertices) using inverse distance weighting.
void close()
End the file contents and close the file after writing.
virtual bool beginCellData(label nFields=0)
Begin CellData output section for specified number of fields.
void writeCellData(const word &fieldName, const UList< Type > &field)
Write primitive field of CellData.
Write faces/points (optionally with fields) as a vtp file or a legacy vtk file.
virtual bool writeGeometry()
Write patch topology.
virtual bool beginFile(std::string title="")
Write file header (non-collective).
Holds information (coordinate and normal) regarding nearest wall point.
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
rDeltaTY field()
dynamicFvMesh & mesh
const pointField & points
const cellShapeList & cells
const labelIOList & zoneIDs
Definition correctPhi.H:59
word timeName
Definition getTimeIndex.H:3
Namespace for handling debugging switches.
Definition debug.C:45
const std::string patch
OpenFOAM patch number as a std::string.
Namespace for OpenFOAM.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
List< label > labelList
A List of labels.
Definition List.H:62
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:616
GeometricField< scalar, fvPatchField, volMesh > volScalarField
List< face > faceList
List of faces.
Definition faceListFwd.H:41
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< cell > cellList
List of cell.
Definition cellListFwd.H:41
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition curveTools.C:75
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
dictionary dict
const pointField & pts
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299