Transmissibility::computeFaceProperties: simplify by passing FaceInfo structs

This commit is contained in:
Arne Morten Kvarving 2025-01-17 14:28:28 +01:00
parent 81de485575
commit 6c292a9d4a
2 changed files with 29 additions and 48 deletions

View File

@ -198,23 +198,15 @@ protected:
template <class Intersection> template <class Intersection>
void computeFaceProperties(const Intersection& intersection, void computeFaceProperties(const Intersection& intersection,
const int, FaceInfo& inside,
const int, FaceInfo& outside,
const int,
const int,
DimVector& faceCenterInside,
DimVector& faceCenterOutside,
DimVector& faceAreaNormal, DimVector& faceAreaNormal,
/*isCpGrid=*/std::false_type) const; /*isCpGrid=*/std::false_type) const;
template <class Intersection> template <class Intersection>
void computeFaceProperties(const Intersection& intersection, void computeFaceProperties(const Intersection& intersection,
const int insideElemIdx, FaceInfo& inside,
const int insideFaceIdx, FaceInfo& outside,
const int outsideElemIdx,
const int outsideFaceIdx,
DimVector& faceCenterInside,
DimVector& faceCenterOutside,
DimVector& faceAreaNormal, DimVector& faceAreaNormal,
/*isCpGrid=*/std::true_type) const; /*isCpGrid=*/std::true_type) const;

View File

@ -367,16 +367,11 @@ update(bool global, const TransUpdateQuantities update_quantities,
typename std::is_same<Grid, Dune::CpGrid>::type isCpGrid; typename std::is_same<Grid, Dune::CpGrid>::type isCpGrid;
computeFaceProperties(intersection, computeFaceProperties(intersection,
inside.elemIdx, inside,
inside.faceIdx, outside,
outside.elemIdx,
outside.faceIdx,
inside.faceCenter,
outside.faceCenter,
faceAreaNormal, faceAreaNormal,
isCpGrid); isCpGrid);
Scalar halfTrans1 = Scalar halfTrans1 =
computeHalfTrans_(faceAreaNormal, computeHalfTrans_(faceAreaNormal,
inside.faceIdx, inside.faceIdx,
@ -928,19 +923,14 @@ template<class Grid, class GridView, class ElementMapper, class CartesianIndexMa
template<class Intersection> template<class Intersection>
void Transmissibility<Grid,GridView,ElementMapper,CartesianIndexMapper,Scalar>:: void Transmissibility<Grid,GridView,ElementMapper,CartesianIndexMapper,Scalar>::
computeFaceProperties(const Intersection& intersection, computeFaceProperties(const Intersection& intersection,
const int, FaceInfo& inside,
const int, FaceInfo& outside,
const int,
const int,
DimVector& faceCenterInside,
DimVector& faceCenterOutside,
DimVector& faceAreaNormal, DimVector& faceAreaNormal,
/*isCpGrid=*/std::false_type) const /*isCpGrid=*/std::false_type) const
{ {
// default implementation for DUNE grids // default implementation for DUNE grids
const auto& geometry = intersection.geometry(); const auto& geometry = intersection.geometry();
faceCenterInside = geometry.center(); outside.faceCenter = inside.faceCenter = geometry.center();
faceCenterOutside = faceCenterInside;
faceAreaNormal = intersection.centerUnitOuterNormal(); faceAreaNormal = intersection.centerUnitOuterNormal();
faceAreaNormal *= geometry.volume(); faceAreaNormal *= geometry.volume();
@ -950,43 +940,41 @@ template<class Grid, class GridView, class ElementMapper, class CartesianIndexMa
template<class Intersection> template<class Intersection>
void Transmissibility<Grid,GridView,ElementMapper,CartesianIndexMapper,Scalar>:: void Transmissibility<Grid,GridView,ElementMapper,CartesianIndexMapper,Scalar>::
computeFaceProperties(const Intersection& intersection, computeFaceProperties(const Intersection& intersection,
const int insideElemIdx, FaceInfo& inside,
const int insideFaceIdx, FaceInfo& outside,
const int outsideElemIdx,
const int outsideFaceIdx,
DimVector& faceCenterInside,
DimVector& faceCenterOutside,
DimVector& faceAreaNormal, DimVector& faceAreaNormal,
/*isCpGrid=*/std::true_type) const /*isCpGrid=*/std::true_type) const
{ {
int faceIdx = intersection.id(); int faceIdx = intersection.id();
if(grid_.maxLevel() == 0) { if (grid_.maxLevel() == 0) {
faceCenterInside = grid_.faceCenterEcl(insideElemIdx, insideFaceIdx, intersection); inside.faceCenter = grid_.faceCenterEcl(inside.elemIdx, inside.faceIdx, intersection);
faceCenterOutside = grid_.faceCenterEcl(outsideElemIdx, outsideFaceIdx, intersection); outside.faceCenter = grid_.faceCenterEcl(outside.elemIdx, outside.faceIdx, intersection);
faceAreaNormal = grid_.faceAreaNormalEcl(faceIdx); faceAreaNormal = grid_.faceAreaNormalEcl(faceIdx);
} }
else { else {
if ((intersection.inside().level() != intersection.outside().level())) { if ((intersection.inside().level() != intersection.outside().level())) {
// For CpGrid with LGRs, intersection laying on the boundary of an LGR, having two neighboring cells: // For CpGrid with LGRs, intersection laying on the boundary of an LGR, having two neighboring cells:
// one coarse neighboring cell and one refined neighboring cell, we get the corresponding parent // one coarse neighboring cell and one refined neighboring cell, we get the corresponding parent
// intersection (from level 0), and use the center of the parent intersection for the coarse // intersection (from level 0), and use the center of the parent intersection for the coarse
// neighboring cell. // neighboring cell.
// Get parent intersection and its geometry // Get parent intersection and its geometry
const auto& parentIntersection = grid_.getParentIntersectionFromLgrBoundaryFace(intersection); const auto& parentIntersection =
grid_.getParentIntersectionFromLgrBoundaryFace(intersection);
const auto& parentIntersectionGeometry = parentIntersection.geometry(); const auto& parentIntersectionGeometry = parentIntersection.geometry();
// For the coarse neighboring cell, take the center of the parent intersection. // For the coarse neighboring cell, take the center of the parent intersection.
// For the refined neighboring cell, take the 'usual' center. // For the refined neighboring cell, take the 'usual' center.
faceCenterInside = (intersection.inside().level() == 0) ? parentIntersectionGeometry.center() : inside.faceCenter = (intersection.inside().level() == 0)
grid_.faceCenterEcl(insideElemIdx, insideFaceIdx, intersection); ? parentIntersectionGeometry.center()
faceCenterOutside = (intersection.outside().level() == 0) ? parentIntersectionGeometry.center() : : grid_.faceCenterEcl(inside.elemIdx, inside.faceIdx, intersection);
grid_.faceCenterEcl(outsideElemIdx, outsideFaceIdx, intersection); outside.faceCenter = (intersection.outside().level() == 0)
? parentIntersectionGeometry.center()
: grid_.faceCenterEcl(outside.elemIdx, outside.faceIdx, intersection);
// For some computations, it seems to be benefitial to replace the actual area of the refined face, by // For some computations, it seems to be benefitial to replace the actual area of the refined face, by
// the area of its parent face. // the area of its parent face.
// faceAreaNormal = parentIntersection.centerUnitOuterNormal(); // faceAreaNormal = parentIntersection.centerUnitOuterNormal();
// faceAreaNormal *= parentIntersectionGeometry.volume(); // faceAreaNormal *= parentIntersectionGeometry.volume();
@ -996,10 +984,10 @@ computeFaceProperties(const Intersection& intersection,
} }
else { else {
assert(intersection.inside().level() == intersection.outside().level()); assert(intersection.inside().level() == intersection.outside().level());
faceCenterInside = grid_.faceCenterEcl(insideElemIdx, insideFaceIdx, intersection); inside.faceCenter = grid_.faceCenterEcl(inside.elemIdx, inside.faceIdx, intersection);
faceCenterOutside = grid_.faceCenterEcl(outsideElemIdx, outsideFaceIdx, intersection); outside.faceCenter = grid_.faceCenterEcl(outside.elemIdx, outside.faceIdx, intersection);
// When the CpGrid has LGRs, we compute the face area normal differently. // When the CpGrid has LGRs, we compute the face area normal differently.
if (intersection.inside().level() > 0) { // remove intersection.inside().level() > 0 if (intersection.inside().level() > 0) { // remove intersection.inside().level() > 0
faceAreaNormal = intersection.centerUnitOuterNormal(); faceAreaNormal = intersection.centerUnitOuterNormal();
@ -1011,6 +999,7 @@ computeFaceProperties(const Intersection& intersection,
} }
} }
} }
template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar> template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
void void
Transmissibility<Grid,GridView,ElementMapper,CartesianIndexMapper,Scalar>:: Transmissibility<Grid,GridView,ElementMapper,CartesianIndexMapper,Scalar>::