chombo-discharge
Loading...
Searching...
No Matches
CD_PolyhedralEBUtils.cpp File Reference

Implementation of CD_PolyhedralEBUtils.H. More...

#include <cmath>
#include <BoxIterator.H>
#include <CH_Timer.H>
#include <CH_assert.H>
#include <CD_PolyhedralEBUtils.H>
#include <CD_CutCellBody.H>
#include <CD_PolyUtils.H>
#include <CD_NamespaceHeader.H>
#include <CD_NamespaceFooter.H>
Include dependency graph for CD_PolyhedralEBUtils.cpp:

Functions

void PolyhedralEB::fillNodeValues (BaseFab< Real > &a_nodeValues, const BaseIF &a_function, const Box &a_region, const RealVect &a_probLo, const Real &a_dx)
 Evaluate the implicit function at every node of a region.
void PolyhedralEB::defineIntercepts (BaseFab< Real > a_intercept[SpaceDim], const Box &a_region)
 Size the edge-crossing cache for a region and mark every edge as not yet bisected.
Real PolyhedralEB::edgeCrossing (const BaseIF &a_function, BaseFab< Real > a_intercept[SpaceDim], const IntVect &a_cell, const int a_edge, const Real a_lo, const Real a_hi, const RealVect &a_probLo, const Real &a_dx)
 Find where the implicit function changes sign along a cell edge.
bool PolyhedralEB::isDust (const PolyhedralEB::CutCellBody &a_body) noexcept
 Whether a cut body holds nothing at all and is therefore a regular cell.
Real PolyhedralEB::snappedValue (const BaseIF &a_function, const RealVect &a_point, const Real a_dx) noexcept
 Read the implicit function at a point, with a value within s_snapTolerance of a cell width of zero read as exactly zero, and a zero that is a tangency read from beside the point instead.
Real PolyhedralEB::resolveTangency (const BaseIF &a_function, const RealVect &a_point, const Real a_dx) noexcept
 Read the implicit function beside a point where it is zero, when no surface passes through the point.
Real PolyhedralEB::edgeRoot (const BaseIF &a_function, const IntVect &a_edgeIV, const int a_dir, const Real a_loValue, const Real a_hiValue, const RealVect &a_probLo, const Real a_dx) noexcept
 Bisect one cell edge for the crossing on it.
void PolyhedralEB::fillCorners (PolyhedralEB::CutCellSurface &a_surface, const BaseFab< Real > &a_nodeValues, const IntVect &a_cell)
 Read one cell's corner values off the node values.
void PolyhedralEB::buildSurface (BaseFab< Real > a_intercept[SpaceDim], PolyhedralEB::CutCellSurface &a_surface, const BaseIF &a_function, const BaseFab< Real > &a_nodeValues, const IntVect &a_cell, const RealVect &a_probLo, const Real &a_dx)
 Gather the corner values and edge crossings one cell's surface is built from.
void PolyhedralEB::decideFaces (PolyhedralEB::CutCellSurface &a_surface, const BaseIF &a_function, const IntVect &a_cell, const RealVect &a_probLo, const Real a_dx) noexcept
 Decide, for every face of a cell whose corners alternate in sign, whether its fluid corners or its solid ones meet across it.

Detailed Description

Implementation of CD_PolyhedralEBUtils.H.

Author
Robert Marskar

Function Documentation

◆ buildSurface()

void PolyhedralEB::buildSurface ( BaseFab< Real > a_intercept[SpaceDim],
PolyhedralEB::CutCellSurface & a_surface,
const BaseIF & a_function,
const BaseFab< Real > & a_nodeValues,
const IntVect & a_cell,
const RealVect & a_probLo,
const Real & a_dx )

Gather the corner values and edge crossings one cell's surface is built from.

The corners come from the shared node values and every edge whose ends disagree gets its crossing through the shared cache, so every caller that reconstructs a cell – the graph, the surface pass and the grid builder's curvature test – builds the same cell.

Parameters
[in,out]a_interceptEdge-centred crossing cache
[out]a_surfaceThe values the cell's body is reconstructed from
[in]a_functionImplicit function
[in]a_nodeValuesNode-centred implicit function values
[in]a_cellThe cell
[in]a_probLoLower-left corner of computational domain
[in]a_dxGrid resolution

◆ decideFaces()

void PolyhedralEB::decideFaces ( PolyhedralEB::CutCellSurface & a_surface,
const BaseIF & a_function,
const IntVect & a_cell,
const RealVect & a_probLo,
const Real a_dx )
noexcept

Decide, for every face of a cell whose corners alternate in sign, whether its fluid corners or its solid ones meet across it.

Four alternating corners admit both readings, and the bilinear interpolant of the corners picks the one its saddle falls on, which for a feature thinner than the face is the wrong one: the large values at two corners outweigh the small ones of a thin plate at the other two, and the chords pierce the plate. The implicit function at the centre of the face is read instead, with the value snap of a grid twice as fine, so that it is the very node a finer level holds there. Every cell sharing the face reads the same point. A centre that reads exactly zero falls back to the bilinear saddle. In two dimensions the face is the cell itself.

Parameters
[in,out]a_surfaceSurface whose corners are filled; its face decisions are set.
[in]a_functionImplicit function.
[in]a_cellThe cell.
[in]a_probLoLower-left corner of the domain.
[in]a_dxGrid spacing.

◆ defineIntercepts()

void PolyhedralEB::defineIntercepts ( BaseFab< Real > a_intercept[SpaceDim],
const Box & a_region )

Size the edge-crossing cache for a region and mark every edge as not yet bisected.

One fab per direction, over the edges of the region's cells, addressed by the node at the low end of the edge as edgeCrossing addresses them.

Parameters
[out]a_interceptEdge-centred cache, one fab per direction
[in]a_regionCell-centred region whose edges are wanted

◆ edgeCrossing()

Real PolyhedralEB::edgeCrossing ( const BaseIF & a_function,
BaseFab< Real > a_intercept[SpaceDim],
const IntVect & a_cell,
const int a_edge,
const Real a_lo,
const Real a_hi,
const RealVect & a_probLo,
const Real & a_dx )

Find where the implicit function changes sign along a cell edge.

Bisection between the two endpoints, looked up in a cache first. Every cut edge is reached from both of its adjoining faces and from each neighbouring cell, always with the same endpoints, so the root is found once and reused. That is what makes two cells agree on a shared aperture bit for bit.

Parameters
[in]a_functionImplicit function
[in,out]a_interceptEdge-centred cache, one component per direction
[in]a_cellCell the edge is being read from
[in]a_edgeEdge index within the cell
[in]a_loImplicit function at the edge's low corner
[in]a_hiImplicit function at the edge's high corner
[in]a_probLoLower-left corner of computational domain
[in]a_dxGrid resolution
Returns
Position along the edge, parameterised from its low corner.

◆ edgeRoot()

Real PolyhedralEB::edgeRoot ( const BaseIF & a_function,
const IntVect & a_edgeIV,
const int a_dir,
const Real a_loValue,
const Real a_hiValue,
const RealVect & a_probLo,
const Real a_dx )
noexcept

Bisect one cell edge for the crossing on it.

An endpoint at exactly zero is not taken to be the crossing: the function may be zero along a stretch of the edge (a face of the geometry lying in the edge's plane), and the crossing is where it leaves that stretch. The bisection walks through zeros, which the fluid predicate reads as solid, and a root that lands within s_snapTolerance of an endpoint that is exactly zero is put exactly on it.

Parameters
[in]a_functionImplicit function.
[in]a_edgeIVNode at the low end of the edge.
[in]a_dirDirection the edge runs in.
[in]a_loValueImplicit function at the low end.
[in]a_hiValueImplicit function at the high end.
[in]a_probLoLower-left corner of the domain.
[in]a_dxGrid spacing.
Returns
Position along the edge, in [0,1].

◆ fillCorners()

void PolyhedralEB::fillCorners ( PolyhedralEB::CutCellSurface & a_surface,
const BaseFab< Real > & a_nodeValues,
const IntVect & a_cell )

Read one cell's corner values off the node values.

Corner c of the cell is the node offset by ((c >> d) & 1) in each direction d.

Parameters
[out]a_surfaceSurface whose corners are filled. Its crossings are left alone.
[in]a_nodeValuesNode-centred implicit function values
[in]a_cellThe cell

◆ fillNodeValues()

void PolyhedralEB::fillNodeValues ( BaseFab< Real > & a_nodeValues,
const BaseIF & a_function,
const Box & a_region,
const RealVect & a_probLo,
const Real & a_dx )

Evaluate the implicit function at every node of a region.

One evaluation per node rather than per cell corner, since the cells meeting at a node share it and must agree on its value. Values are read through snappedValue.

Parameters
[out]a_nodeValuesNode-centred values over a_region
[in]a_functionImplicit function
[in]a_regionCell-centred region whose nodes are wanted
[in]a_probLoLower-left corner of computational domain
[in]a_dxGrid resolution

◆ isDust()

bool PolyhedralEB::isDust ( const PolyhedralEB::CutCellBody & a_body)
noexcept

Whether a cut body holds nothing at all and is therefore a regular cell.

A node that lands exactly on the interface is solid by rule, so the cells around it classify as cut from their corners while their bodies hold no solid and no interface whatsoever – the reconstruction finds an empty polyhedron. Those cells are regular, and dropping them discards nothing, since there is no surface in them for a neighbour to meet. Emptiness is exact rather than thresholded: a body with any solid in it, however little, keeps its cell, because its interface is what closes the surface against its neighbours, and a rule that discarded it by size would leave a hole the size of what it discarded. A cell whose interface lies in one of its faces has no solid volume either, but it does have boundary area, and it is not dust.

Parameters
[in]a_bodyBody of the cell.
Returns
True if the cell should be treated as regular.

◆ resolveTangency()

Real PolyhedralEB::resolveTangency ( const BaseIF & a_function,
const RealVect & a_point,
const Real a_dx )
noexcept

Read the implicit function beside a point where it is zero, when no surface passes through the point.

A composite function can be zero over a whole region that is not its surface: a difference of two bodies sharing a face evaluates to the maximum of zero and something negative over the whole of that face. Taken at face value such a zero is material by the fluid rule, and it invents an interface where the geometry has none and displaces the interfaces of whatever else the cell holds. It is told apart from a surface by the function's sign a probe spacing off the point, along each axis in turn. A surface through the point changes the sign across it along any axis the surface is not parallel to, and since a surface has a normal there is always such an axis, so one sign change is enough to leave the zero alone. The zero is read through only on the evidence of an axis whose two readings are both away from zero and of the same sign, which is what a function that touches zero without a surface being there looks like; the largest such reading stands in for the zero. One reading of zero is not evidence of anything – it is the point's own zero again, which is what an axis along a face of the geometry returns, and what both axes along the faces meeting at a convex edge return.

Parameters
[in]a_functionImplicit function.
[in]a_pointPoint the function is zero at.
[in]a_dxGrid spacing that sets the probe spacing.
Returns
The reading beside the point, or exactly zero if a surface passes through it.

◆ snappedValue()

Real PolyhedralEB::snappedValue ( const BaseIF & a_function,
const RealVect & a_point,
const Real a_dx )
noexcept

Read the implicit function at a point, with a value within s_snapTolerance of a cell width of zero read as exactly zero, and a zero that is a tangency read from beside the point instead.

A face of the geometry lying in a node plane evaluates to zero there only up to round-off: the same face comes back as plus zero, minus zero and a few parts in 1e19 at neighbouring nodes, and cells on either side of it would then be classified by which of those they were handed. Reading everything within a fixed fraction of the cell width of zero as zero puts every such node on one side by rule, in the corner values and in the bisection alike. A zero that no surface passes through is then read through resolveTangency, so that nothing downstream sees it.

Parameters
[in]a_functionImplicit function.
[in]a_pointPoint to evaluate at.
[in]a_dxGrid spacing that sets the scale.
Returns
The value, or exactly zero.