Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add attenuation for acoustic wave solvers #3398

Draft
wants to merge 24 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
065a9a1
first version of viscoacoustic, isotropic and VTI (no PML)
sframba Oct 14, 2024
dfb12a5
addd a lot of leftovers
sframba Oct 15, 2024
2eaf425
missed a couple things
sframba Oct 15, 2024
3becd25
fixed a few bugs
sframba Oct 15, 2024
4b012ef
Merge branch 'develop' into feature/sframbat/viscoacoustic
sframba Oct 15, 2024
9922a20
Merge branch 'develop' into feature/sframbat/viscoacoustic
sframba Oct 16, 2024
f2d24b0
Merge branch 'develop' into feature/sframbat/viscoacoustic
sframba Oct 18, 2024
bc7d11f
added test and corrected bug
sframba Oct 18, 2024
b49f9f6
Merge branch 'develop' into feature/sframbat/viscoacoustic
sframba Oct 19, 2024
6455693
Merge branch 'develop' into feature/sframbat/viscoacoustic
sframba Oct 29, 2024
acdfa44
Merge branch 'develop' into feature/sframbat/viscoacoustic
sframba Oct 29, 2024
0e81bed
Merge branch 'develop' of https://github.com/GEOS-DEV/GEOS into develop
sframba Nov 4, 2024
0041890
Merge branch 'feature/sframbat/viscoacoustic' of https://github.com/G…
sframba Nov 4, 2024
3216693
Merge branch 'develop' into feature/sframbat/viscoacoustic
sframba Nov 4, 2024
dd43aa3
leftover from merge
sframba Nov 4, 2024
c7b4574
Merge branch 'develop' into feature/sframbat/viscoacoustic
sframba Nov 19, 2024
c9f1642
leftover from merge
sframba Nov 19, 2024
b7e7afd
Merge branch 'develop' into feature/sframbat/viscoacoustic
sframba Nov 21, 2024
c06ac4e
Merge branch 'develop' of https://github.com/GEOS-DEV/GEOS into develop
sframba Dec 6, 2024
bff1d2a
Merge branch 'develop' into feature/sframbat/viscoacoustic
sframba Dec 6, 2024
0d0a713
Merge branch 'develop' into feature/sframbat/viscoacoustic
sframba Dec 11, 2024
d737e8d
Merge branch 'develop' of https://github.com/GEOS-DEV/GEOS into develop
sframba Dec 12, 2024
fbd0d95
Merge branch 'develop' into feature/sframbat/viscoacoustic
sframba Dec 12, 2024
d3a3427
Merge branch 'develop' into feature/sframbat/viscoacoustic
sframba Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ DECLARE_FIELD( StiffnessVector_q,
WRITE_AND_READ,
"Stiffness vector contains R_h*Pressure_n." );

DECLARE_FIELD( StiffnessVectorA_p,
"stiffnessVectorA_p",
array1d< real32 >,
0,
NOPLOT,
WRITE_AND_READ,
"P-type acoustic attenuation stiffness vector." );

DECLARE_FIELD( StiffnessVectorA_q,
"stiffnessVectorA_q",
array1d< real32 >,
0,
NOPLOT,
WRITE_AND_READ,
"Q-type acoustic attenuation stiffness vector." );

DECLARE_FIELD( Pressure_p_nm1,
"pressure_p_nm1",
array1d< real32 >,
Expand Down Expand Up @@ -122,6 +138,22 @@ DECLARE_FIELD( Pressure_q_np1,
WRITE_AND_READ,
"Scalar auxiliary pressure q at time n+1." );

DECLARE_FIELD( DivPsi_p,
"divpsi_p",
array2d< real32 >,
0,
NOPLOT,
WRITE_AND_READ,
"p-type memory variable for acoustic VTI attenuation." );

DECLARE_FIELD( DivPsi_q,
"divpsi_q",
array2d< real32 >,
0,
NOPLOT,
WRITE_AND_READ,
"q-type memory variable for acoustic VTI attenuation." );

DECLARE_FIELD( DampingVector_p,
"dampingVector_p",
array1d< real32 >,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ void AcousticVTIWaveEquationSEM::registerDataOnMesh( Group & meshBodies )
acousticvtifields::LateralSurfaceNodeIndicator,
acousticvtifields::BottomSurfaceNodeIndicator >( getName() );

if( m_attenuationType == WaveSolverUtils::AttenuationType::sls )
{
integer l = m_slsReferenceAngularFrequencies.size( 0 );
nodeManager.registerField< acousticvtifields::DivPsi_p,
acousticvtifields::DivPsi_q,
acousticvtifields::StiffnessVectorA_p,
acousticvtifields::StiffnessVectorA_q >( getName() );
nodeManager.getField< acousticvtifields::DivPsi_p >().resizeDimension< 1 >( l );
nodeManager.getField< acousticvtifields::DivPsi_q >().resizeDimension< 1 >( l );
}

FaceManager & faceManager = mesh.getFaceManager();
faceManager.registerField< acousticfields::AcousticFreeSurfaceFaceIndicator >( getName() );
Expand All @@ -98,6 +108,10 @@ void AcousticVTIWaveEquationSEM::registerDataOnMesh( Group & meshBodies )
subRegion.registerField< acousticvtifields::Epsilon >( getName() );
subRegion.registerField< acousticvtifields::F >( getName() );
subRegion.registerField< acousticfields::AcousticVelocity >( getName() );
if( m_attenuationType == WaveSolverUtils::AttenuationType::sls )
{
subRegion.registerField< acousticfields::AcousticQualityFactor >( getName() );
}
} );
} );
}
Expand Down Expand Up @@ -313,6 +327,12 @@ void AcousticVTIWaveEquationSEM::initializePostInitialConditionsPreSubGroups()
} );
} );

// check anelasticity coefficient and/or compute it if needed
if( m_attenuationType == WaveSolverUtils::AttenuationType::sls )
{
initializeAnelasticityCoefficients< acousticfields::AcousticQualityFactor >( domain );
}

WaveSolverUtils::initTrace( "seismoTraceReceiver", getName(), m_outputSeismoTrace, m_receiverConstants.size( 0 ), m_receiverIsLocal );
}

Expand Down Expand Up @@ -590,22 +610,56 @@ real64 AcousticVTIWaveEquationSEM::explicitStepInternal( real64 const & time_n,
"",
kernelFactory );


if( m_attenuationType == WaveSolverUtils::AttenuationType::sls )
{
auto kernelFactory = acousticVTIWaveEquationSEMKernels::ExplicitAcousticVTIAttenuativeSEMFactory( dt );
finiteElement::
regionBasedKernelApplication< EXEC_POLICY,
constitutive::NullModel,
CellElementSubRegion >( mesh,
regionNames,
getDiscretizationName(),
"",
kernelFactory );
}

addSourceToRightHandSide( time_n, rhs );

/// calculate your time integrators

GEOS_MARK_SCOPE ( updateP );

AcousticTimeSchemeSEM::LeapFrogforVTI( nodeManager.size(), dt, p_np1, p_n, p_nm1, q_np1, q_n, q_nm1, mass, stiffnessVector_p,
stiffnessVector_q, damping_p, damping_pq, damping_q, damping_qp,
rhs, freeSurfaceNodeIndicator, lateralSurfaceNodeIndicator,
bottomSurfaceNodeIndicator );

if( m_attenuationType == WaveSolverUtils::AttenuationType::sls )
{
arrayView1d< real32 > const stiffnessVectorA_p = nodeManager.getField< acousticvtifields::StiffnessVectorA_p >();
arrayView1d< real32 > const stiffnessVectorA_q = nodeManager.getField< acousticvtifields::StiffnessVectorA_q >();
arrayView2d< real32 > const divpsi_p = nodeManager.getField< acousticvtifields::DivPsi_p >();
arrayView2d< real32 > const divpsi_q = nodeManager.getField< acousticvtifields::DivPsi_q >();
arrayView1d< real32 > const referenceFrequencies = m_slsReferenceAngularFrequencies.toView();
arrayView1d< real32 > const anelasticityCoefficients = m_slsAnelasticityCoefficients.toView();
AcousticTimeSchemeSEM::AttenuationLeapFrogforVTI( nodeManager.size(), dt, p_np1, p_n, p_nm1, q_np1, q_n, q_nm1, divpsi_p, divpsi_q, mass, stiffnessVector_p,
stiffnessVector_q, stiffnessVectorA_p, stiffnessVectorA_q, damping_p, damping_pq, damping_q, damping_qp, rhs,
freeSurfaceNodeIndicator, lateralSurfaceNodeIndicator, bottomSurfaceNodeIndicator, referenceFrequencies,
anelasticityCoefficients );
}
else
{
AcousticTimeSchemeSEM::LeapFrogforVTI( nodeManager.size(), dt, p_np1, p_n, p_nm1, q_np1, q_n, q_nm1, mass, stiffnessVector_p,
stiffnessVector_q, damping_p, damping_pq, damping_q, damping_qp,
rhs, freeSurfaceNodeIndicator, lateralSurfaceNodeIndicator,
bottomSurfaceNodeIndicator );
}
/// synchronize pressure fields
FieldIdentifiers fieldsToBeSync;
fieldsToBeSync.addFields( FieldLocation::Node, { acousticvtifields::Pressure_p_np1::key() } );
fieldsToBeSync.addFields( FieldLocation::Node, { acousticvtifields::Pressure_q_np1::key() } );

if( m_slsReferenceAngularFrequencies.size( 0 ) > 0 )
{
fieldsToBeSync.addFields( FieldLocation::Node, { acousticvtifields::DivPsi_p::key(), acousticvtifields::DivPsi_q::key() } );
}

CommunicationTools & syncFields = CommunicationTools::getInstance();
syncFields.synchronizeFields( fieldsToBeSync,
mesh,
Expand All @@ -625,6 +679,15 @@ real64 AcousticVTIWaveEquationSEM::explicitStepInternal( real64 const & time_n,
stiffnessVector_q[a] = 0.0;
rhs[a] = 0.0;
} );
if( m_attenuationType == WaveSolverUtils::AttenuationType::sls )
{
arrayView1d< real32 > const stiffnessVectorA_p = nodeManager.getField< acousticvtifields::StiffnessVectorA_p >();
arrayView1d< real32 > const stiffnessVectorA_q = nodeManager.getField< acousticvtifields::StiffnessVectorA_q >();
forAll< EXEC_POLICY >( nodeManager.size() , [=] GEOS_HOST_DEVICE ( localIndex const a )
{
stiffnessVectorA_p[a] = stiffnessVectorA_q[a] = 0.0;
} );
}

} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,13 @@ struct DampingMatrixKernel

template< typename SUBREGION_TYPE,
typename CONSTITUTIVE_TYPE,
typename FE_TYPE >
class ExplicitAcousticVTISEM : public finiteElement::KernelBase< SUBREGION_TYPE,
CONSTITUTIVE_TYPE,
FE_TYPE,
1,
1 >
typename FE_TYPE,
typename Sp = fields::acousticvtifields::StiffnessVector_p, typename Sq = fields::acousticvtifields::StiffnessVector_q >
class ExplicitAcousticVTISEMBase : public finiteElement::KernelBase< SUBREGION_TYPE,
CONSTITUTIVE_TYPE,
FE_TYPE,
1,
1 >
{
public:

Expand Down Expand Up @@ -415,22 +416,22 @@ class ExplicitAcousticVTISEM : public finiteElement::KernelBase< SUBREGION_TYPE,
* @param dt The time interval for the step.
* elements to be processed during this kernel launch.
*/
ExplicitAcousticVTISEM( NodeManager & nodeManager,
EdgeManager const & edgeManager,
FaceManager const & faceManager,
localIndex const targetRegionIndex,
SUBREGION_TYPE const & elementSubRegion,
FE_TYPE const & finiteElementSpace,
CONSTITUTIVE_TYPE & inputConstitutiveType,
real64 const dt ):
ExplicitAcousticVTISEMBase( NodeManager & nodeManager,
EdgeManager const & edgeManager,
FaceManager const & faceManager,
localIndex const targetRegionIndex,
SUBREGION_TYPE const & elementSubRegion,
FE_TYPE const & finiteElementSpace,
CONSTITUTIVE_TYPE & inputConstitutiveType,
real64 const dt ):
Base( elementSubRegion,
finiteElementSpace,
inputConstitutiveType ),
m_nodeCoords( nodeManager.getField< fields::referencePosition32 >() ),
m_p_n( nodeManager.getField< fields::acousticvtifields::Pressure_p_n >() ),
m_q_n( nodeManager.getField< fields::acousticvtifields::Pressure_q_n >() ),
m_stiffnessVector_p( nodeManager.getField< fields::acousticvtifields::StiffnessVector_p >() ),
m_stiffnessVector_q( nodeManager.getField< fields::acousticvtifields::StiffnessVector_q >() ),
m_stiffnessVector_p( nodeManager.getField< Sp >() ),
m_stiffnessVector_q( nodeManager.getField< Sq >() ),
m_epsilon( elementSubRegion.template getField< fields::acousticvtifields::Epsilon >() ),
m_delta( elementSubRegion.template getField< fields::acousticvtifields::Delta >() ),
m_vti_f( elementSubRegion.template getField< fields::acousticvtifields::F >() ),
Expand All @@ -445,7 +446,7 @@ class ExplicitAcousticVTISEM : public finiteElement::KernelBase< SUBREGION_TYPE,
/**
* @copydoc geos::finiteElement::KernelBase::StackVariables
*
* ### ExplicitAcousticVTISEM Description
* ### ExplicitAcousticVTISEMBase Description
* Adds a stack arrays for the nodal force, primary displacement variable, etc.
*/
struct StackVariables : Base::StackVariables
Expand All @@ -461,6 +462,7 @@ class ExplicitAcousticVTISEM : public finiteElement::KernelBase< SUBREGION_TYPE,
/// C-array stack storage for element local the nodal positions.
/// only the eight corners of the mesh cell are needed to compute the Jacobian
real64 xLocal[ 8 ][ 3 ];
real32 factor;
/// local (to this element) stiffness vectors
real32 stiffnessVectorLocal_p[ numNodesPerElem ]{};
real32 stiffnessVectorLocal_q[ numNodesPerElem ]{};
Expand All @@ -487,6 +489,7 @@ class ExplicitAcousticVTISEM : public finiteElement::KernelBase< SUBREGION_TYPE,
stack.xLocal[ a ][ i ] = m_nodeCoords[ nodeIndex ][ i ];
}
}
stack.factor = 1.0;
}

GEOS_HOST_DEVICE
Expand All @@ -504,7 +507,7 @@ class ExplicitAcousticVTISEM : public finiteElement::KernelBase< SUBREGION_TYPE,
/**
* @copydoc geos::finiteElement::KernelBase::quadraturePointKernel
*
* ### ExplicitAcousticVTISEM Description
* ### ExplicitAcousticVTISEMBase Description
* Calculates stiffness vector
*
*/
Expand All @@ -518,20 +521,21 @@ class ExplicitAcousticVTISEM : public finiteElement::KernelBase< SUBREGION_TYPE,
m_finiteElementSpace.template computeStiffnessxyTerm( q, stack.xLocal, [&] ( int i, int j, real64 val )
{
real32 const localIncrement_p = val*(-1-2*m_epsilon[k])*m_p_n[m_elemsToNodes[k][j]];
stack.stiffnessVectorLocal_p[ i ] += localIncrement_p;
stack.stiffnessVectorLocal_p[ i ] += localIncrement_p * stack.factor;

real32 const localIncrement_q = val*((-2*m_delta[k]-m_vti_f[k])*m_p_n[m_elemsToNodes[k][j]] +(m_vti_f[k]-1)*m_q_n[m_elemsToNodes[k][j]]);
stack.stiffnessVectorLocal_q[ i ] += localIncrement_q;
stack.stiffnessVectorLocal_q[ i ] += localIncrement_q * stack.factor;
} );

// Pseudo-Stiffness z

m_finiteElementSpace.template computeStiffnesszTerm( q, stack.xLocal, [&] ( int i, int j, real64 val )
{
real32 const localIncrement_p = val*((m_vti_f[k]-1)*m_p_n[m_elemsToNodes[k][j]] - m_vti_f[k]*m_q_n[m_elemsToNodes[k][j]]);
stack.stiffnessVectorLocal_p[ i ] += localIncrement_p;
stack.stiffnessVectorLocal_p[ i ] += localIncrement_p * stack.factor;

real32 const localIncrement_q = -val*m_q_n[m_elemsToNodes[k][j]];
stack.stiffnessVectorLocal_q[ i ] += localIncrement_q;
stack.stiffnessVectorLocal_q[ i ] += localIncrement_q * stack.factor;
} );
}

Expand Down Expand Up @@ -567,10 +571,84 @@ class ExplicitAcousticVTISEM : public finiteElement::KernelBase< SUBREGION_TYPE,
};



/// The factory used to construct a ExplicitAcousticWaveEquation kernel.
/// Specialization for standard iso elastic kernel
template< typename SUBREGION_TYPE,
typename CONSTITUTIVE_TYPE,
typename FE_TYPE >
using ExplicitAcousticVTISEM = ExplicitAcousticVTISEMBase< SUBREGION_TYPE, CONSTITUTIVE_TYPE, FE_TYPE >;
using ExplicitAcousticVTISEMFactory = finiteElement::KernelFactory< ExplicitAcousticVTISEM,
real64 >;
/// Specialization for attenuation kernel
template< typename SUBREGION_TYPE,
typename CONSTITUTIVE_TYPE,
typename FE_TYPE >
class ExplicitAcousticVTIAttenuativeSEM : public ExplicitAcousticVTISEMBase< SUBREGION_TYPE,
CONSTITUTIVE_TYPE,
FE_TYPE,
fields::acousticvtifields::StiffnessVectorA_p,
fields::acousticvtifields::StiffnessVectorA_q >
{
public:

/// Alias for the base class;
using Base = ExplicitAcousticVTISEMBase< SUBREGION_TYPE,
CONSTITUTIVE_TYPE,
FE_TYPE,
fields::acousticvtifields::StiffnessVectorA_p,
fields::acousticvtifields::StiffnessVectorA_q >;

//*****************************************************************************
/**
* @brief Constructor
* @copydoc geos::finiteElement::KernelBase::KernelBase
* @param nodeManager Reference to the NodeManager object.
* @param edgeManager Reference to the EdgeManager object.
* @param faceManager Reference to the FaceManager object.
* @param targetRegionIndex Index of the region the subregion belongs to.
* @param dt The time interval for the step.
*/
ExplicitAcousticVTIAttenuativeSEM( NodeManager & nodeManager,
EdgeManager const & edgeManager,
FaceManager const & faceManager,
localIndex const targetRegionIndex,
SUBREGION_TYPE const & elementSubRegion,
FE_TYPE const & finiteElementSpace,
CONSTITUTIVE_TYPE & inputConstitutiveType,
real64 const dt ):
Base( nodeManager,
edgeManager,
faceManager,
targetRegionIndex,
elementSubRegion,
finiteElementSpace,
inputConstitutiveType,
dt ),
m_qualityFactor( elementSubRegion.template getField< fields::acousticfields::AcousticQualityFactor >() )
{}

/**
* @copydoc geos::finiteElement::KernelBase::setup
*
* Copies the primary variable, and position into the local stack array.
*/
GEOS_HOST_DEVICE
inline
void setup( localIndex const k,
typename Base::StackVariables & stack ) const
{
Base::setup( k, stack );
stack.factor = stack.factor / m_qualityFactor[ k ];
}

protected:

/// The array containing the acoustic attenuation quality factor
arrayView1d< real32 const > const m_qualityFactor;

};

using ExplicitAcousticVTIAttenuativeSEMFactory = finiteElement::KernelFactory< ExplicitAcousticVTIAttenuativeSEM,
real64 >;

} // namespace acousticVTIWaveEquationSEMKernels

Expand Down
Loading
Loading