Skip to content

Commit

Permalink
fix: robust point location for degenerate configurations (#3202)
Browse files Browse the repository at this point in the history
* implemented method based on winding number

* using element global index for element choice in degenerate cases

* added global id criterion for points coincident with vertices, as well

* using base discretization for precomputing src/rcv

* enabled for high orders. Also removed extra high-order nodes where not needed
---------

Co-authored-by: Aurelien <[email protected]>
Co-authored-by: acitrain <[email protected]>
  • Loading branch information
3 people authored and rrsettgast committed Sep 17, 2024
1 parent 75f21d0 commit e3a68fc
Show file tree
Hide file tree
Showing 17 changed files with 692 additions and 220 deletions.
2 changes: 1 addition & 1 deletion .integrated_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
baselines:
bucket: geosx
baseline: integratedTests/baseline_integratedTests-pr3215-6396-9b43cc8
baseline: integratedTests/baseline_integratedTests-pr3202-6636-2821c93

allow_fail:
all: ''
Expand Down
4 changes: 4 additions & 0 deletions BASELINE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This file is designed to track changes to the integrated test baselines.
Any developer who updates the baseline ID in the .integrated_tests.yaml file is expected to create an entry in this file with the pull request number, date, and their justification for rebaselining.
These notes should be in reverse-chronological order, and use the following time format: (YYYY-MM-DD).

PR #3202 (2024-08-03)
======================
Acoustic VTI tests needed rebaselining after update in source and receiver location algorithm.

PR #3215 (2024-07-23)
======================
Changed the default value for massCreation and name of the wrapper.
Expand Down
397 changes: 396 additions & 1 deletion src/coreComponents/mesh/utilities/ComputationalGeometry.hpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,14 @@ void AcousticFirstOrderWaveEquationSEM::postInputInitialization()
m_receiverRegion.resize( numReceiversGlobal );
}

void AcousticFirstOrderWaveEquationSEM::precomputeSourceAndReceiverTerm( MeshLevel & mesh, arrayView1d< string const > const & regionNames )
void AcousticFirstOrderWaveEquationSEM::precomputeSourceAndReceiverTerm( MeshLevel & baseMesh, MeshLevel & mesh, arrayView1d< string const > const & regionNames )
{
NodeManager const & nodeManager = mesh.getNodeManager();
FaceManager const & faceManager = mesh.getFaceManager();
GEOS_MARK_FUNCTION;

arrayView2d< wsCoordType const, nodes::REFERENCE_POSITION_USD > const
X = nodeManager.getField< fields::referencePosition32 >().toViewConst();
arrayView2d< real64 const > const faceNormal = faceManager.faceNormal();
arrayView2d< real64 const > const faceCenter = faceManager.faceCenter();
arrayView1d< globalIndex const > const nodeLocalToGlobal = baseMesh.getNodeManager().localToGlobalMap().toViewConst();
ArrayOfArraysView< localIndex const > const nodesToElements = baseMesh.getNodeManager().elementList().toViewConst();
ArrayOfArraysView< localIndex const > const facesToNodes = baseMesh.getFaceManager().nodeList().toViewConst();
arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const nodeCoords = baseMesh.getNodeManager().referencePosition();

arrayView2d< real64 const > const sourceCoordinates = m_sourceCoordinates.toViewConst();
arrayView2d< localIndex > const sourceNodeIds = m_sourceNodeIds.toView();
Expand Down Expand Up @@ -195,39 +194,44 @@ void AcousticFirstOrderWaveEquationSEM::precomputeSourceAndReceiverTerm( MeshLev
}
}

mesh.getElemManager().forElementSubRegions< CellElementSubRegion >( regionNames, [&]( localIndex const regionIndex,
CellElementSubRegion & elementSubRegion )
mesh.getElemManager().forElementSubRegionsComplete< CellElementSubRegion >( regionNames, [&]( localIndex const,
localIndex const regionIndex,
localIndex const esr,
ElementRegionBase &,
CellElementSubRegion & elementSubRegion )
{
GEOS_THROW_IF( elementSubRegion.getElementType() != ElementType::Hexahedron,
getDataContext() << ": Invalid type of element, the acoustic solver is designed for hexahedral meshes only (C3D8) ",
InputError );

arrayView2d< localIndex const > const elemsToFaces = elementSubRegion.faceList();
arrayView2d< localIndex const, cells::NODE_MAP_USD > const & elemsToNodes = elementSubRegion.nodeList();
arrayView2d< localIndex const, cells::NODE_MAP_USD > const & baseElemsToNodes = baseMesh.getElemManager().getRegion( regionIndex ).getSubRegion< CellElementSubRegion >( esr ).nodeList();
arrayView2d< real64 const > const elemCenter = elementSubRegion.getElementCenter();
arrayView1d< integer const > const elemGhostRank = elementSubRegion.ghostRank();
arrayView1d< globalIndex const > const elemLocalToGlobal = elementSubRegion.localToGlobalMap().toViewConst();

finiteElement::FiniteElementBase const &
fe = elementSubRegion.getReference< finiteElement::FiniteElementBase >( getDiscretizationName() );
finiteElement::FiniteElementDispatchHandler< SEM_FE_TYPES >::dispatch3D( fe, [&] ( auto const finiteElement )
{
using FE_TYPE = TYPEOFREF( finiteElement );

localIndex const numFacesPerElem = elementSubRegion.numFacesPerElement();

PreComputeSourcesAndReceivers::
Compute1DSourceAndReceiverConstantsWithElementsAndRegionStorage
< EXEC_POLICY, FE_TYPE >
( elementSubRegion.size(),
regionIndex,
numFacesPerElem,
X,
facesToNodes,
nodeCoords,
nodeLocalToGlobal,
elemLocalToGlobal,
nodesToElements,
baseElemsToNodes,
elemGhostRank,
elemsToNodes,
elemsToFaces,
elemCenter,
faceNormal,
faceCenter,
sourceCoordinates,
sourceIsAccessible,
sourceElem,
Expand Down Expand Up @@ -258,11 +262,12 @@ void AcousticFirstOrderWaveEquationSEM::initializePostInitialConditionsPreSubGro

applyFreeSurfaceBC( 0.0, domain );

forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const &,
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const & meshBodyName,
MeshLevel & mesh,
arrayView1d< string const > const & regionNames )
{
precomputeSourceAndReceiverTerm( mesh, regionNames );
MeshLevel & baseMesh = domain.getMeshBodies().getGroup< MeshBody >( meshBodyName ).getBaseDiscretization();
precomputeSourceAndReceiverTerm( baseMesh, mesh, regionNames );

NodeManager & nodeManager = mesh.getNodeManager();
FaceManager & faceManager = mesh.getFaceManager();
Expand Down Expand Up @@ -435,7 +440,7 @@ real64 AcousticFirstOrderWaveEquationSEM::explicitStepInternal( real64 const & t
{
NodeManager & nodeManager = mesh.getNodeManager();

arrayView2d< wsCoordType const, nodes::REFERENCE_POSITION_USD > const X = nodeManager.getField< fields::referencePosition32 >().toViewConst();
arrayView2d< wsCoordType const, nodes::REFERENCE_POSITION_USD > const nodeCoords = nodeManager.getField< fields::referencePosition32 >().toViewConst();

arrayView1d< real32 const > const mass = nodeManager.getField< acousticfields::AcousticMassVector >();
arrayView1d< real32 const > const damping = nodeManager.getField< acousticfields::DampingVector >();
Expand Down Expand Up @@ -468,7 +473,7 @@ real64 AcousticFirstOrderWaveEquationSEM::explicitStepInternal( real64 const & t
VelocityComputation< FE_TYPE > kernel( finiteElement );
kernel.template launch< EXEC_POLICY, ATOMIC_POLICY >
( elementSubRegion.size(),
X,
nodeCoords,
elemsToNodes,
p_np1,
density,
Expand All @@ -482,7 +487,7 @@ real64 AcousticFirstOrderWaveEquationSEM::explicitStepInternal( real64 const & t
( elementSubRegion.size(),
regionIndex,
nodeManager.size(),
X,
nodeCoords,
elemsToNodes,
velocity_x,
velocity_y,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ class AcousticFirstOrderWaveEquationSEM : public WaveSolverBase
/**
* @brief Locate sources and receivers position in the mesh elements, evaluate the basis functions at each point and save them to the
* corresponding elements nodes.
* @param baseMesh the level-0 mesh
* @param mesh mesh of the computational domain
*/
virtual void precomputeSourceAndReceiverTerm( MeshLevel & mesh, arrayView1d< string const > const & regionNames ) override;
virtual void precomputeSourceAndReceiverTerm( MeshLevel & baseMesh, MeshLevel & mesh, arrayView1d< string const > const & regionNames ) override;

/**
* @brief Apply free surface condition to the face define in the geometry box from the xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,15 @@ void AcousticVTIWaveEquationSEM::postInputInitialization()
m_pressureNp1AtReceivers.resize( m_nsamplesSeismoTrace, numReceiversGlobal + 1 );
}

void AcousticVTIWaveEquationSEM::precomputeSourceAndReceiverTerm( MeshLevel & mesh,
void AcousticVTIWaveEquationSEM::precomputeSourceAndReceiverTerm( MeshLevel & baseMesh, MeshLevel & mesh,
arrayView1d< string const > const & regionNames )
{
NodeManager const & nodeManager = mesh.getNodeManager();
FaceManager const & faceManager = mesh.getFaceManager();

arrayView2d< wsCoordType const, nodes::REFERENCE_POSITION_USD > const nodeCoords32 =
nodeManager.getField< fields::referencePosition32 >().toViewConst();

arrayView2d< real64 const > const faceNormal = faceManager.faceNormal();
arrayView2d< real64 const > const faceCenter = faceManager.faceCenter();
GEOS_MARK_FUNCTION;

arrayView1d< globalIndex const > const nodeLocalToGlobal = baseMesh.getNodeManager().localToGlobalMap().toViewConst();
ArrayOfArraysView< localIndex const > const nodesToElements = baseMesh.getNodeManager().elementList().toViewConst();
ArrayOfArraysView< localIndex const > const facesToNodes = baseMesh.getFaceManager().nodeList().toViewConst();
arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const nodeCoords = baseMesh.getNodeManager().referencePosition().toViewConst();

arrayView2d< real64 const > const sourceCoordinates = m_sourceCoordinates.toViewConst();
arrayView2d< localIndex > const sourceNodeIds = m_sourceNodeIds.toView();
Expand Down Expand Up @@ -153,38 +150,43 @@ void AcousticVTIWaveEquationSEM::precomputeSourceAndReceiverTerm( MeshLevel & me
}
}

mesh.getElemManager().forElementSubRegions< CellElementSubRegion >( regionNames, [&]( localIndex const,
CellElementSubRegion & elementSubRegion )
mesh.getElemManager().forElementSubRegionsComplete< CellElementSubRegion >( regionNames, [&]( localIndex const,
localIndex const er,
localIndex const esr,
ElementRegionBase &,
CellElementSubRegion & elementSubRegion )
{
GEOS_THROW_IF( elementSubRegion.getElementType() != ElementType::Hexahedron,
"Invalid type of element, the acoustic solver is designed for hexahedral meshes only (C3D8), using the SEM formulation",
InputError );

arrayView2d< localIndex const > const elemsToFaces = elementSubRegion.faceList();
arrayView2d< localIndex const, cells::NODE_MAP_USD > const & elemsToNodes = elementSubRegion.nodeList();
arrayView2d< localIndex const, cells::NODE_MAP_USD > const & baseElemsToNodes = baseMesh.getElemManager().getRegion( er ).getSubRegion< CellElementSubRegion >( esr ).nodeList();
arrayView2d< real64 const > const elemCenter = elementSubRegion.getElementCenter();
arrayView1d< integer const > const elemGhostRank = elementSubRegion.ghostRank();
arrayView1d< globalIndex const > const elemLocalToGlobal = elementSubRegion.localToGlobalMap().toViewConst();

finiteElement::FiniteElementBase const &
fe = elementSubRegion.getReference< finiteElement::FiniteElementBase >( getDiscretizationName() );
finiteElement::FiniteElementDispatchHandler< SEM_FE_TYPES >::dispatch3D( fe, [&] ( auto const finiteElement )
{
using FE_TYPE = TYPEOFREF( finiteElement );

localIndex const numFacesPerElem = elementSubRegion.numFacesPerElement();

acousticVTIWaveEquationSEMKernels::
PrecomputeSourceAndReceiverKernel::
launch< EXEC_POLICY, FE_TYPE >
( elementSubRegion.size(),
numFacesPerElem,
nodeCoords32,
facesToNodes,
nodeCoords,
nodeLocalToGlobal,
elemLocalToGlobal,
nodesToElements,
baseElemsToNodes,
elemGhostRank,
elemsToNodes,
elemsToFaces,
elemCenter,
faceNormal,
faceCenter,
sourceCoordinates,
sourceIsAccessible,
sourceNodeIds,
Expand Down Expand Up @@ -233,19 +235,19 @@ void AcousticVTIWaveEquationSEM::initializePostInitialConditionsPreSubGroups()
applyFreeSurfaceBC( 0.0, domain );
precomputeSurfaceFieldIndicator( domain );

forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const &,
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const & meshBodyName,
MeshLevel & mesh,
arrayView1d< string const > const & regionNames )
{
precomputeSourceAndReceiverTerm( mesh, regionNames );
MeshLevel & baseMesh = domain.getMeshBodies().getGroup< MeshBody >( meshBodyName ).getBaseDiscretization();
precomputeSourceAndReceiverTerm( baseMesh, mesh, regionNames );

NodeManager & nodeManager = mesh.getNodeManager();
FaceManager & faceManager = mesh.getFaceManager();

/// get the array of indicators: 1 if the face is on the boundary; 0 otherwise
arrayView1d< integer > const & facesDomainBoundaryIndicator = faceManager.getDomainBoundaryIndicator();
arrayView2d< wsCoordType const, nodes::REFERENCE_POSITION_USD > const nodeCoords =
nodeManager.getField< fields::referencePosition32 >().toViewConst();
arrayView2d< wsCoordType const, nodes::REFERENCE_POSITION_USD > const nodeCoords = nodeManager.getField< fields::referencePosition32 >().toViewConst();

/// get face to node map
ArrayOfArraysView< localIndex const > const facesToNodes = faceManager.nodeList().toViewConst();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ class AcousticVTIWaveEquationSEM : public WaveSolverBase
/**
* @brief Locate sources and receivers position in the mesh elements, evaluate the basis functions at each point and save them to the
* corresponding elements nodes.
* @param baseMesh the level-0 mesh
* @param mesh mesh of the computational domain
*/
virtual void precomputeSourceAndReceiverTerm( MeshLevel & mesh, arrayView1d< string const > const & regionNames ) override;
virtual void precomputeSourceAndReceiverTerm( MeshLevel & baseMesh, MeshLevel & mesh, arrayView1d< string const > const & regionNames ) override;

/**
* @brief Compute the lateral and bottom surface Field indicators of the boxed domain
Expand Down
Loading

0 comments on commit e3a68fc

Please sign in to comment.