distanceSurface.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "distanceSurface.H"
30 #include "dictionary.H"
31 #include "volFields.H"
32 #include "volPointInterpolation.H"
34 #include "fvMesh.H"
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  defineTypeNameAndDebug(distanceSurface, 0);
41 }
42 
43 
44 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
45 
46 const Foam::Enum
47 <
48  Foam::distanceSurface::topologyFilterType
49 >
50 Foam::distanceSurface::topoFilterNames_
51 ({
52  { topologyFilterType::NONE, "none" },
53  { topologyFilterType::LARGEST_REGION, "largestRegion" },
54  { topologyFilterType::NEAREST_POINTS, "nearestPoints" },
55  { topologyFilterType::PROXIMITY_REGIONS, "proximityRegions" },
56  { topologyFilterType::PROXIMITY_FACES, "proximityFaces" },
57  { topologyFilterType::PROXIMITY_FACES, "proximity" },
58 });
59 
60 
61 // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
62 
63 namespace Foam
64 {
65 
66 // Check that all point hits are valid
67 static inline void checkAllHits(const UList<pointIndexHit>& nearest)
68 {
69  label notHit = 0;
70  for (const pointIndexHit& pHit : nearest)
71  {
72  if (!pHit.hit())
73  {
74  ++notHit;
75  }
76  }
77 
78  if (notHit)
79  {
81  << "Had " << notHit << " faces/cells from "
82  << nearest.size() << " without a point hit." << nl
83  << "May be caused by a severely degenerate input surface" << nl
84  << abort(FatalError);
85  }
86 }
87 
88 
89 // Normal distance from surface hit point to a point in the mesh
90 static inline scalar normalDistance_zero
91 (
92  const point& pt,
93  const pointIndexHit& pHit,
94  const vector& norm
95 )
96 {
97  const vector diff(pt - pHit.point());
98 
99  return (diff & norm);
100 }
101 
102 
103 // Signed distance from surface hit point to a point in the mesh,
104 // the sign is dictated by the normal
105 static inline scalar normalDistance_nonzero
106 (
107  const point& pt,
108  const pointIndexHit& pHit,
109  const vector& norm
110 )
111 {
112  const vector diff(pt - pHit.point());
113  const scalar normDist = (diff & norm);
114 
115  return Foam::sign(normDist) * Foam::mag(diff);
116 }
117 
118 
119 // Normal distance from surface hit point to a point in the mesh
120 static inline void calcNormalDistance_zero
121 (
123  const pointField& points,
124  const List<pointIndexHit>& nearest,
125  const vectorField& normals
126 )
127 {
128  forAll(nearest, i)
129  {
130  distance[i] =
131  normalDistance_zero(points[i], nearest[i], normals[i]);
132  }
133 }
134 
135 
136 // Signed distance from surface hit point -> point in the mesh,
137 // the sign is dictated by the normal
138 static inline void calcNormalDistance_nonzero
139 (
141  const pointField& points,
142  const List<pointIndexHit>& nearest,
143  const vectorField& normals
144 )
145 {
146  forAll(nearest, i)
147  {
148  distance[i] =
149  normalDistance_nonzero(points[i], nearest[i], normals[i]);
150  }
151 }
152 
153 
154 // Close to the surface: normal distance from surface hit point
155 // Far from surface: distance from surface hit point
156 //
157 // Note
158 // This switch may be helpful when working directly with
159 // distance/gradient fields. Has low overhead otherwise.
160 // May be replaced in the future (2020-11)
161 static inline void calcNormalDistance_filtered
162 (
164  const bitSet& ignoreLocation,
165  const pointField& points,
166  const List<pointIndexHit>& nearest,
167  const vectorField& normals
168 )
169 {
170  forAll(nearest, i)
171  {
172  if (ignoreLocation.test(i))
173  {
174  distance[i] =
175  normalDistance_nonzero(points[i], nearest[i], normals[i]);
176  }
177  else
178  {
179  distance[i] =
180  normalDistance_zero(points[i], nearest[i], normals[i]);
181  }
182  }
183 }
184 
185 
186 // Flat surfaces (eg, a plane) have an extreme change in
187 // the normal at the edge, which creates a zero-crossing
188 // extending to infinity.
189 //
190 // Ad hoc treatment: require that the surface hit point is within a
191 // somewhat generous bounding box for the cell (+10%)
192 //
193 // Provisioning for filtering based on the cell points,
194 // but its usefulness remains to be seen (2020-12-09)
195 template<bool WantPointFilter = false>
196 static bitSet simpleGeometricFilter
197 (
198  bitSet& ignoreCells,
199  const List<pointIndexHit>& nearest,
200  const polyMesh& mesh,
201  const scalar boundBoxInflate = 0.1 // 10% to catch corners
202 )
203 {
204  // A deny filter. Initially false (accept everything)
205  ignoreCells.resize(mesh.nCells());
206 
207  bitSet pointFilter;
208  if (WantPointFilter)
209  {
210  // Create as accept filter. Initially false (deny everything)
211  pointFilter.resize(mesh.nPoints());
212  }
213 
214  boundBox cellBb;
215 
216  forAll(nearest, celli)
217  {
218  const point& pt = nearest[celli].point();
219 
220  const labelList& cPoints = mesh.cellPoints(celli);
221 
222  cellBb.clear();
223  cellBb.add(mesh.points(), cPoints);
224  cellBb.inflate(boundBoxInflate);
225 
226  if (!cellBb.contains(pt))
227  {
228  ignoreCells.set(celli);
229  }
230  else if (WantPointFilter)
231  {
232  // Good cell candidate, accept its points
233  pointFilter.set(cPoints);
234  }
235  }
236 
237  // Flip from accept to deny filter
238  pointFilter.flip();
239 
240  return pointFilter;
241 }
242 
243 
244 } // End namespace Foam
245 
246 
247 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
248 
250 (
251  const word& defaultSurfaceName,
252  const polyMesh& mesh,
253  const dictionary& dict
254 )
255 :
256  mesh_(mesh),
257  geometryPtr_
258  (
260  (
261  dict.get<word>("surfaceType"),
262  IOobject
263  (
264  dict.getOrDefault("surfaceName", defaultSurfaceName),
265  mesh.time().constant(), // directory
266  "triSurface", // instance
267  mesh.time(), // registry
268  IOobject::MUST_READ,
269  IOobject::NO_WRITE
270  ),
271  dict
272  )
273  ),
274  distance_(dict.getOrDefault<scalar>("distance", 0)),
275  withZeroDistance_(equal(distance_, 0)),
276  withSignDistance_
277  (
278  withZeroDistance_
279  || (distance_ < 0)
280  || dict.getOrDefault<bool>("signed", true)
281  ),
282 
283  isoParams_
284  (
285  dict,
286  isoSurfaceParams::ALGO_TOPO,
287  isoSurfaceParams::filterType::DIAGCELL
288  ),
289  topoFilter_
290  (
291  topoFilterNames_.getOrDefault
292  (
293  "topology",
294  dict,
295  topologyFilterType::NONE
296  )
297  ),
298  nearestPoints_(),
299  maxDistanceSqr_(Foam::sqr(GREAT)),
300  absProximity_(dict.getOrDefault<scalar>("absProximity", 1e-5)),
301  cellDistancePtr_(nullptr),
302  pointDistance_(),
303  surface_(),
304  meshCells_(),
305  isoSurfacePtr_(nullptr)
306 {
307  if (topologyFilterType::NEAREST_POINTS == topoFilter_)
308  {
309  dict.readEntry("nearestPoints", nearestPoints_);
310  }
311 
312  if (dict.readIfPresent("maxDistance", maxDistanceSqr_))
313  {
314  maxDistanceSqr_ = Foam::sqr(maxDistanceSqr_);
315  }
316 }
317 
318 
320 (
321  const polyMesh& mesh,
322  const word& surfaceType,
323  const word& surfaceName,
324  const isoSurfaceParams& params,
325  const bool interpolate
326 )
327 :
329  (
330  mesh,
331  interpolate,
332  surfaceType,
333  surfaceName,
334  scalar(0),
335  true, // redundant - must be signed
336  params
337  )
338 {}
339 
340 
342 (
343  const polyMesh& mesh,
344  const bool interpolate,
345  const word& surfaceType,
346  const word& surfaceName,
347  const scalar distance,
348  const bool useSignedDistance,
349  const isoSurfaceParams& params
350 )
351 :
353  (
354  mesh,
355  interpolate,
357  (
358  surfaceType,
359  IOobject
360  (
361  surfaceName, // name
362  mesh.time().constant(), // directory
363  "triSurface", // instance
364  mesh.time(), // registry
365  IOobject::MUST_READ,
366  IOobject::NO_WRITE
367  ),
368  dictionary()
369  ),
370  distance,
371  useSignedDistance,
372  params
373  )
374 {}
375 
376 
378 (
379  const polyMesh& mesh,
380  const bool interpolate,
381  autoPtr<searchableSurface>&& surface,
382  const scalar distance,
383  const bool useSignedDistance,
384  const isoSurfaceParams& params
385 )
386 :
387  mesh_(mesh),
388  geometryPtr_(surface),
389  distance_(distance),
390  withZeroDistance_(equal(distance_, 0)),
391  withSignDistance_
392  (
393  withZeroDistance_
394  || (distance_ < 0)
395  || useSignedDistance
396  ),
397 
398  isoParams_(params),
399  topoFilter_(topologyFilterType::NONE),
400  nearestPoints_(),
401  maxDistanceSqr_(Foam::sqr(GREAT)),
402  absProximity_(1e-5),
403  cellDistancePtr_(nullptr),
404  pointDistance_(),
405  surface_(),
406  meshCells_(),
407  isoSurfacePtr_(nullptr)
408 {}
409 
410 
411 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
412 
414 {
415  if (debug)
416  {
417  Pout<< "distanceSurface::createGeometry updating geometry." << endl;
418  }
419 
420  // Clear any previously stored topologies
421  isoSurfacePtr_.reset(nullptr);
422  surface_.clear();
423  meshCells_.clear();
424 
425  // Doing searches on this surface
426  const searchableSurface& geom = geometryPtr_();
427 
428  const fvMesh& fvmesh = static_cast<const fvMesh&>(mesh_);
429 
430  // Distance to cell centres
431  // ~~~~~~~~~~~~~~~~~~~~~~~~
432 
433  cellDistancePtr_.reset
434  (
435  new volScalarField
436  (
437  IOobject
438  (
439  "distanceSurface.cellDistance",
440  fvmesh.time().timeName(),
441  fvmesh.time(),
444  false
445  ),
446  fvmesh,
448  )
449  );
450  auto& cellDistance = *cellDistancePtr_;
451 
452 
453  // For distance = 0 we apply additional geometric filtering
454  // to limit the extent of open edges.
455  //
456  // Does not work with ALGO_POINT
457 
458  bitSet ignoreCells, ignoreCellPoints;
459 
460  const bool filterCells =
461  (
462  withZeroDistance_
463  && isoParams_.algorithm() != isoSurfaceParams::ALGO_POINT
464  );
465 
466 
467  // Internal field
468  {
469  const pointField& cc = fvmesh.C();
470  scalarField& fld = cellDistance.primitiveFieldRef();
471 
472  List<pointIndexHit> nearest;
473  geom.findNearest
474  (
475  cc,
476  // Use initialized field (GREAT) to limit search too
477  fld,
478  nearest
479  );
480  checkAllHits(nearest);
481 
482  // Geometric pre-filtering when distance == 0
483 
484  // NOTE (2021-05-31)
485  // Can skip the prefilter if we use proximity-regions filter anyhow
486  // but it makes the iso algorithm more expensive and doesn't help
487  // unless we start relying on area-based weighting for rejecting regions.
488 
489  if (filterCells)
490  {
491  ignoreCellPoints = simpleGeometricFilter<false>
492  (
493  ignoreCells,
494  nearest,
495  fvmesh,
496 
497  // Inflate bound box.
498  // - To catch corners: approx. 10%
499  // - Extra generous for PROXIMITY_REGIONS
500  // (extra weighting for 'bad' faces)
501  (
502  topologyFilterType::PROXIMITY_REGIONS == topoFilter_
503  ? 1
504  : 0.1
505  )
506  );
507  }
508 
509  if (withSignDistance_)
510  {
511  vectorField norms;
512  geom.getNormal(nearest, norms);
513 
514  if (filterCells)
515  {
516  // With inside/outside switching (see note above)
518  (
519  fld,
520  ignoreCells,
521  cc,
522  nearest,
523  norms
524  );
525  }
526  else if (withZeroDistance_)
527  {
528  calcNormalDistance_zero(fld, cc, nearest, norms);
529  }
530  else
531  {
532  calcNormalDistance_nonzero(fld, cc, nearest, norms);
533  }
534  }
535  else
536  {
537  calcAbsoluteDistance(fld, cc, nearest);
538  }
539  }
540 
541 
542  // Patch fields
543  {
544  forAll(fvmesh.C().boundaryField(), patchi)
545  {
546  const pointField& cc = fvmesh.C().boundaryField()[patchi];
547  scalarField& fld = cellDistance.boundaryFieldRef()[patchi];
548 
549  List<pointIndexHit> nearest;
550  geom.findNearest
551  (
552  cc,
553  scalarField(cc.size(), GREAT),
554  nearest
555  );
556  checkAllHits(nearest);
557 
558  if (withSignDistance_)
559  {
560  vectorField norms;
561  geom.getNormal(nearest, norms);
562 
563  if (withZeroDistance_)
564  {
565  // Slight inconsistency in boundary vs interior when
566  // cells are filtered, but the patch fields are only
567  // used by isoSurfacePoint, and filtering is disabled
568  // for that anyhow.
569 
570  calcNormalDistance_zero(fld, cc, nearest, norms);
571  }
572  else
573  {
574  calcNormalDistance_nonzero(fld, cc, nearest, norms);
575  }
576  }
577  else
578  {
579  calcAbsoluteDistance(fld, cc, nearest);
580  }
581  }
582  }
583 
584 
585  // On processor patches the mesh.C() will already be the cell centre
586  // on the opposite side so no need to swap cellDistance.
587 
588 
589  // Distance to points
590  pointDistance_.resize(fvmesh.nPoints());
591  pointDistance_ = GREAT;
592  {
593  const pointField& pts = fvmesh.points();
594  scalarField& fld = pointDistance_;
595 
596  List<pointIndexHit> nearest;
597  geom.findNearest
598  (
599  pts,
600  // Use initialized field (GREAT) to limit search too
601  pointDistance_,
602  nearest
603  );
604  checkAllHits(nearest);
605 
606  if (withSignDistance_)
607  {
608  vectorField norms;
609  geom.getNormal(nearest, norms);
610 
611  if (filterCells)
612  {
613  // With inside/outside switching (see note above)
615  (
616  fld,
617  ignoreCellPoints,
618  pts,
619  nearest,
620  norms
621  );
622  }
623  else if (withZeroDistance_)
624  {
625  calcNormalDistance_zero(fld, pts, nearest, norms);
626  }
627  else
628  {
629  calcNormalDistance_nonzero(fld, pts, nearest, norms);
630  }
631  }
632  else
633  {
634  calcAbsoluteDistance(fld, pts, nearest);
635  }
636  }
637 
638 
639  // Don't need ignoreCells if there is nothing to ignore.
640  if (ignoreCells.none())
641  {
642  ignoreCells.clearStorage();
643  }
644  else if (filterCells && topologyFilterType::NONE != topoFilter_)
645  {
646  // For refine blocked cells (eg, checking actual cells cut)
647  isoSurfaceBase isoCutter
648  (
649  mesh_,
650  cellDistance,
651  pointDistance_,
652  distance_
653  );
654 
655  if (topologyFilterType::LARGEST_REGION == topoFilter_)
656  {
657  refineBlockedCells(ignoreCells, isoCutter);
658  filterKeepLargestRegion(ignoreCells);
659  }
660  else if (topologyFilterType::NEAREST_POINTS == topoFilter_)
661  {
662  refineBlockedCells(ignoreCells, isoCutter);
663  filterKeepNearestRegions(ignoreCells);
664  }
665 
666  // Note: apply similar filtering for PROXIMITY_REGIONS later instead
667  }
668 
669  // Don't need point filter beyond this point
670  ignoreCellPoints.clearStorage();
671 
672 
673  if (debug)
674  {
675  Pout<< "Writing cell distance:" << cellDistance.objectPath() << endl;
676  cellDistance.write();
677 
678  pointScalarField pDist
679  (
680  IOobject
681  (
682  "distanceSurface.pointDistance",
683  fvmesh.time().timeName(),
684  fvmesh.time(),
687  false
688  ),
689  pointMesh::New(fvmesh),
691  );
692  pDist.primitiveFieldRef() = pointDistance_;
693 
694  Pout<< "Writing point distance:" << pDist.objectPath() << endl;
695  pDist.write();
696  }
697 
698  isoSurfacePtr_.reset
699  (
701  (
702  isoParams_,
703  cellDistance,
704  pointDistance_,
705  distance_,
706  ignoreCells
707  )
708  );
709 
710 
711  // Restrict ignored cells to those actually cut
712  if (filterCells && topologyFilterType::PROXIMITY_REGIONS == topoFilter_)
713  {
714  isoSurfaceBase isoCutter
715  (
716  mesh_,
717  cellDistance,
718  pointDistance_,
719  distance_
720  );
721 
722  refineBlockedCells(ignoreCells, isoCutter);
723  }
724 
725 
726  // ALGO_POINT still needs cell, point fields (for interpolate)
727  // The others can do straight transfer
728 
729  // But also flatten into a straight transfer for proximity filtering
730  if
731  (
733  || topologyFilterType::PROXIMITY_FACES == topoFilter_
734  || topologyFilterType::PROXIMITY_REGIONS == topoFilter_
735  )
736  {
737  surface_.transfer(static_cast<meshedSurface&>(*isoSurfacePtr_));
738  meshCells_.transfer(isoSurfacePtr_->meshCells());
739 
740  isoSurfacePtr_.reset(nullptr);
741  cellDistancePtr_.reset(nullptr);
742  pointDistance_.clear();
743  }
744 
745  if (topologyFilterType::PROXIMITY_FACES == topoFilter_)
746  {
748  }
749  else if (topologyFilterType::PROXIMITY_REGIONS == topoFilter_)
750  {
751  filterRegionProximity(ignoreCells);
752  }
753 
754  if (debug)
755  {
756  print(Pout, debug);
757  Pout<< endl;
758  }
759 }
760 
761 
762 void Foam::distanceSurface::print(Ostream& os, int level) const
763 {
764  os << " surface:" << surfaceName()
765  << " distance:" << distance()
766  << " topology:" << topoFilterNames_[topoFilter_];
767 
768  isoParams_.print(os);
769 
770  if (level)
771  {
772  os << " faces:" << surface().surfFaces().size()
773  << " points:" << surface().points().size();
774  }
775 }
776 
777 
778 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
volFields.H
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1069
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::PackedList::resize
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
Definition: PackedListI.H:409
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::Enum
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: IOstreamOption.H:57
Foam::isoSurfaceBase::New
static autoPtr< isoSurfaceBase > New(const isoSurfaceParams &params, const volScalarField &cellValues, const scalarField &pointValues, const scalar iso, const bitSet &ignoreCells=bitSet())
Create for specified algorithm type.
Definition: isoSurfaceBaseNew.C:37
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::isoSurfaceBase
Low-level components common to various iso-surface algorithms.
Definition: isoSurfaceBase.H:66
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::searchableSurface::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
Foam::primitiveMesh::cellPoints
const labelListList & cellPoints() const
Definition: primitiveMeshCellPoints.C:34
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::distanceSurface::filterRegionProximity
void filterRegionProximity(bitSet &ignoreCells) const
Remove region(s) that have far faces.
Definition: distanceSurfaceFilter.C:311
Foam::boundBox::inflate
void inflate(const scalar s)
Inflate box by factor*mag(span) in all dimensions.
Definition: boundBox.C:175
Foam::isoSurfaceParams::algorithm
algorithmType algorithm() const noexcept
Get current algorithm.
Definition: isoSurfaceParams.H:213
Foam::distanceSurface::print
void print(Ostream &os, int level=0) const
Print information.
Definition: distanceSurface.C:762
Foam::MeshObject< polyMesh, UpdateableMeshObject, pointMesh >::New
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
Definition: MeshObject.C:48
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
Foam::distanceSurface::distanceSurface
distanceSurface(const word &defaultSurfaceName, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: distanceSurface.C:250
Foam::bitSet::set
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition: bitSetI.H:574
Foam::calcNormalDistance_filtered
static void calcNormalDistance_filtered(scalarField &distance, const bitSet &ignoreLocation, const pointField &points, const List< pointIndexHit > &nearest, const vectorField &normals)
Definition: distanceSurface.C:162
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::calcNormalDistance_zero
static void calcNormalDistance_zero(scalarField &distance, const pointField &points, const List< pointIndexHit > &nearest, const vectorField &normals)
Definition: distanceSurface.C:121
Foam::MeshedSurface::clear
virtual void clear()
Clear all storage.
Definition: MeshedSurface.C:598
Foam::distanceSurface::filterKeepNearestRegions
void filterKeepNearestRegions(bitSet &ignoreCells) const
Keep region(s) closest to the nearest points.
Definition: distanceSurfaceFilter.C:187
Foam::Pout
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Foam::sign
dimensionedScalar sign(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:166
Foam::bitSet::test
bool test(const label pos) const
Test value at specified position, never auto-vivify entries.
Definition: bitSetI.H:520
Foam::MatrixTools::equal
bool equal(const Matrix< Form1, Type > &A, const Matrix< Form2, Type > &B, const bool verbose=false, const label maxDiffs=10, const scalar relTol=1e-5, const scalar absTol=1e-8)
Compare matrix elements for absolute or relative equality.
Definition: MatrixTools.C:34
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::primitiveMesh::nPoints
label nPoints() const noexcept
Number of mesh points.
Definition: primitiveMeshI.H:37
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::distanceSurface::refineBlockedCells
bool refineBlockedCells(bitSet &ignoreCells, const isoSurfaceBase &isoContext) const
Re-filter the blocked cells based on the anticipated cuts.
Definition: distanceSurfaceFilter.C:37
Foam::diff
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Definition: triad.C:378
Foam::distanceSurface
A surface defined by a distance from an input searchable surface. Uses an iso-surface algorithm (cell...
Definition: distanceSurface.H:209
Foam::primitiveMesh::nCells
label nCells() const noexcept
Number of mesh cells.
Definition: primitiveMeshI.H:96
Foam::PointIndexHit
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:52
Foam::PointIndexHit::hit
bool hit() const noexcept
Is there a hit?
Definition: PointIndexHit.H:130
Foam::normalDistance_zero
static scalar normalDistance_zero(const point &pt, const pointIndexHit &pHit, const vector &norm)
Definition: distanceSurface.C:91
Foam::MeshedSurface::transfer
void transfer(pointField &pointLst, List< Face > &faceLst)
Transfer the components.
Definition: MeshedSurface.C:1324
Foam::Field< scalar >
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:69
Foam::List::transfer
void transfer(List< T > &list)
Definition: List.C:456
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::distanceSurface::filterFaceProximity
void filterFaceProximity()
Adjust extracted iso-surface to remove far faces.
Definition: distanceSurfaceFilter.C:467
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
Foam::fvMesh::C
const volVectorField & C() const
Return cell centres as volVectorField.
Definition: fvMeshGeometry.C:341
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::bitSet::flip
void flip()
Invert all bits in the addressable region.
Definition: bitSetI.H:618
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::isoSurfaceParams
Preferences for controlling iso-surface algorithms.
Definition: isoSurfaceParams.H:107
os
OBJstream os(runTime.globalPath()/outputName)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::isoSurfaceParams::ALGO_POINT
Definition: isoSurfaceParams.H:119
Foam::Ostream::write
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::searchableSurface::findNearest
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
distanceSurface.H
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::distance
scalar distance(const vector &p1, const vector &p2)
Definition: curveTools.C:12
Foam::boundBox::clear
void clear()
Clear bounding box and make it an inverted box.
Definition: boundBoxI.H:184
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:766
Foam::boundBox::contains
bool contains(const point &pt) const
Contains point? (inside or on edge)
Definition: boundBoxI.H:271
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
volPointInterpolation.H
Foam::bitSet::none
bool none() const
True if no bits in this bitset are set.
Definition: bitSetI.H:487
Foam::checkAllHits
static void checkAllHits(const UList< pointIndexHit > &nearest)
Definition: distanceSurface.C:67
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
dictionary.H
Foam::List::clear
void clear()
Clear the list, i.e. set size to zero.
Definition: ListI.H:116
Foam::PointIndexHit::point
const point_type & point() const noexcept
Return point, no checks.
Definition: PointIndexHit.H:142
Foam::PackedList::clearStorage
void clearStorage()
Clear the list and delete storage.
Definition: PackedListI.H:520
Foam::distanceSurface::filterKeepLargestRegion
void filterKeepLargestRegion(bitSet &ignoreCells) const
Keep region with the most cuts (after region split)
Definition: distanceSurfaceFilter.C:120
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::distanceSurface::createGeometry
void createGeometry()
Create/recreate the distance surface.
Definition: distanceSurface.C:413
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::MeshedSurface< face >
Foam::IOobject::NO_READ
Definition: IOobject.H:188
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::normalDistance_nonzero
static scalar normalDistance_nonzero(const point &pt, const pointIndexHit &pHit, const vector &norm)
Definition: distanceSurface.C:106
Foam::calcNormalDistance_nonzero
static void calcNormalDistance_nonzero(scalarField &distance, const pointField &points, const List< pointIndexHit > &nearest, const vectorField &normals)
Definition: distanceSurface.C:139
Foam::fac::interpolate
static tmp< GeometricField< Type, faePatchField, edgeMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &tvf, const edgeScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62
Foam::boundBox::add
void add(const boundBox &bb)
Extend to include the second box.
Definition: boundBoxI.H:191
Foam::simpleGeometricFilter
static bitSet simpleGeometricFilter(bitSet &ignoreCells, const List< pointIndexHit > &nearest, const polyMesh &mesh, const scalar boundBoxInflate=0.1)
Definition: distanceSurface.C:197