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

fix: use mass and energy consistently for single phase solvers #3485

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -55,11 +55,7 @@ class CompressibleSolidUpdates : public CoupledSolidUpdates< NullModel, PORO_TYP
virtual void updateStateFromPressureAndTemperature( localIndex const k,
localIndex const q,
real64 const & pressure,
real64 const & GEOS_UNUSED_PARAM( pressure_k ),
real64 const & GEOS_UNUSED_PARAM( pressure_n ),
real64 const & temperature,
real64 const & GEOS_UNUSED_PARAM( temperature_k ),
real64 const & GEOS_UNUSED_PARAM( temperature_n ) ) const override final
real64 const & temperature ) const override final
{
m_porosityUpdate.updateFromPressureAndTemperature( k, q, pressure, temperature );
real64 const porosity = m_porosityUpdate.getPorosity( k, q );
Expand Down
19 changes: 14 additions & 5 deletions src/coreComponents/constitutive/solid/CoupledSolid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,20 @@ class CoupledSolidUpdates
virtual void updateStateFromPressureAndTemperature( localIndex const k,
localIndex const q,
real64 const & pressure,
real64 const & pressure_k,
real64 const & pressure_n,
real64 const & temperature,
real64 const & temperature_k,
real64 const & temperature_n ) const
real64 const & temperature ) const
{
GEOS_UNUSED_VAR( k, q, pressure, temperature );
}

GEOS_HOST_DEVICE
virtual void updateStateFixedStress( localIndex const k,
localIndex const q,
real64 const & pressure,
real64 const & pressure_k,
real64 const & pressure_n,
real64 const & temperature,
real64 const & temperature_k,
real64 const & temperature_n ) const
{
GEOS_UNUSED_VAR( k, q,
pressure, pressure_k, pressure_n,
Expand Down
16 changes: 8 additions & 8 deletions src/coreComponents/constitutive/solid/PorousSolid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class PorousSolidUpdates : public CoupledSolidUpdates< SOLID_TYPE, BiotPorosity,
{}

GEOS_HOST_DEVICE
virtual void updateStateFromPressureAndTemperature( localIndex const k,
localIndex const q,
real64 const & pressure,
real64 const & pressure_k,
real64 const & pressure_n,
real64 const & temperature,
real64 const & temperature_k,
real64 const & temperature_n ) const override final
virtual void updateStateFixedStress( localIndex const k,
localIndex const q,
real64 const & pressure,
real64 const & pressure_k,
real64 const & pressure_n,
real64 const & temperature,
real64 const & temperature_k,
real64 const & temperature_n ) const override final
{
updateBiotCoefficientAndAssignModuli( k );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ class BiotPorosityUpdates : public PorosityBaseUpdates
dPorosity_dPressure = biotSkeletonModulusInverse;
dPorosity_dTemperature = -porosityThermalExpansion;

savePorosity( k, q, porosity, dPorosity_dPressure, dPorosity_dTemperature );
m_newPorosity[k][q] = porosity;
m_dPorosity_dPressure[k][q] = dPorosity_dPressure;
m_dPorosity_dTemperature[k][q] = dPorosity_dTemperature;
}

GEOS_HOST_DEVICE
Expand Down
24 changes: 0 additions & 24 deletions src/coreComponents/constitutive/solid/porosity/PorosityBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,6 @@ class PorosityBaseUpdates
m_referencePorosity ( referencePorosity )
{}

/**
* @brief Helper to save porosity back to m_newPorosity array
*
* This is mostly defined for improving code readability.
*
* @param[in] k Element index.
* @param[in] q Quadrature point index.
* @param[in] porosity porosity to be saved to m_newPorosity[k][q]
* @param[in] dPorosity_dPressure porosity derivative w.r.t pressure to be saved to m_dPorosity_dPressure[k][q]
* @param[in] dPorosity_dTemperature porosity derivative w.r.t temperature to be saved to m_dPorosity_dTemperature[k][q]
*/
GEOS_HOST_DEVICE
GEOS_FORCE_INLINE
void savePorosity( localIndex const k,
localIndex const q,
real64 const & porosity,
real64 const & dPorosity_dPressure,
real64 const & dPorosity_dTemperature ) const
{
m_newPorosity[k][q] = porosity;
m_dPorosity_dPressure[k][q] = dPorosity_dPressure;
m_dPorosity_dTemperature[k][q] = dPorosity_dTemperature;
}

GEOS_HOST_DEVICE
inline
real64 getPorosity( localIndex const k,
Expand Down
47 changes: 32 additions & 15 deletions src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,43 @@ template< typename POROUSWRAPPER_TYPE >
void updatePorosityAndPermeabilityFromPressureAndTemperature( POROUSWRAPPER_TYPE porousWrapper,
CellElementSubRegion & subRegion,
arrayView1d< real64 const > const & pressure,
arrayView1d< real64 const > const & pressure_k,
arrayView1d< real64 const > const & pressure_n,
arrayView1d< real64 const > const & temperature,
arrayView1d< real64 const > const & temperature_k,
arrayView1d< real64 const > const & temperature_n )
arrayView1d< real64 const > const & temperature )
{
forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOS_DEVICE ( localIndex const k )
{
for( localIndex q = 0; q < porousWrapper.numGauss(); ++q )
{
porousWrapper.updateStateFromPressureAndTemperature( k, q,
pressure[k],
pressure_k[k],
pressure_n[k],
temperature[k],
temperature_k[k],
temperature_n[k] );
temperature[k] );
}
} );
}

template< typename POROUSWRAPPER_TYPE >
void updatePorosityAndPermeabilityFixedStress( POROUSWRAPPER_TYPE porousWrapper,
CellElementSubRegion & subRegion,
arrayView1d< real64 const > const & pressure,
arrayView1d< real64 const > const & pressure_k,
arrayView1d< real64 const > const & pressure_n,
arrayView1d< real64 const > const & temperature,
arrayView1d< real64 const > const & temperature_k,
arrayView1d< real64 const > const & temperature_n )
{
forAll< parallelDevicePolicy<> >( subRegion.size(), [=] GEOS_DEVICE ( localIndex const k )
{
for( localIndex q = 0; q < porousWrapper.numGauss(); ++q )
{
porousWrapper.updateStateFixedStress( k, q,
pressure[k],
pressure_k[k],
pressure_n[k],
temperature[k],
temperature_k[k],
temperature_n[k] );
}
} );
}

template< typename POROUSWRAPPER_TYPE >
void updatePorosityAndPermeabilityFromPressureAndAperture( POROUSWRAPPER_TYPE porousWrapper,
Expand Down Expand Up @@ -168,6 +184,8 @@ void FlowSolverBase::registerDataOnMesh( Group & meshBodies )
if( m_isThermal )
{
subRegion.registerField< fields::flow::energy >( getName() );
subRegion.registerField< fields::flow::dEnergy_dPressure >( getName() );
subRegion.registerField< fields::flow::dEnergy_dTemperature >( getName() );
subRegion.registerField< fields::flow::energy_n >( getName() );
}
} );
Expand Down Expand Up @@ -583,10 +601,7 @@ void FlowSolverBase::updatePorosityAndPermeability( CellElementSubRegion & subRe
GEOS_MARK_FUNCTION;

arrayView1d< real64 const > const & pressure = subRegion.getField< fields::flow::pressure >();
arrayView1d< real64 const > const & pressure_n = subRegion.getField< fields::flow::pressure_n >();

arrayView1d< real64 const > const & temperature = subRegion.getField< fields::flow::temperature >();
arrayView1d< real64 const > const & temperature_n = subRegion.getField< fields::flow::temperature_n >();

string const & solidName = subRegion.getReference< string >( viewKeyStruct::solidNamesString() );
CoupledSolidBase & porousSolid = subRegion.template getConstitutiveModel< CoupledSolidBase >( solidName );
Expand All @@ -596,13 +611,15 @@ void FlowSolverBase::updatePorosityAndPermeability( CellElementSubRegion & subRe
typename TYPEOFREF( castedPorousSolid ) ::KernelWrapper porousWrapper = castedPorousSolid.createKernelUpdates();
if( m_isFixedStressPoromechanicsUpdate )
{
arrayView1d< real64 const > const & pressure_n = subRegion.getField< fields::flow::pressure_n >();
arrayView1d< real64 const > const & pressure_k = subRegion.getField< fields::flow::pressure_k >();
arrayView1d< real64 const > const & temperature_n = subRegion.getField< fields::flow::temperature_n >();
arrayView1d< real64 const > const & temperature_k = subRegion.getField< fields::flow::temperature_k >();
updatePorosityAndPermeabilityFromPressureAndTemperature( porousWrapper, subRegion, pressure, pressure_k, pressure_n, temperature, temperature_k, temperature_n );
updatePorosityAndPermeabilityFixedStress( porousWrapper, subRegion, pressure, pressure_k, pressure_n, temperature, temperature_k, temperature_n );
}
else
{
updatePorosityAndPermeabilityFromPressureAndTemperature( porousWrapper, subRegion, pressure, pressure_n, pressure_n, temperature, temperature_n, temperature_n );
updatePorosityAndPermeabilityFromPressureAndTemperature( porousWrapper, subRegion, pressure, temperature );
}
} );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,46 +241,38 @@ DECLARE_FIELD( temperatureScalingFactor,
NO_WRITE,
"Scaling factors for temperature" );

DECLARE_FIELD( mass,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mass went to single phase file since it is used there, not for compositional

"mass",
DECLARE_FIELD( energy,
"energy",
array1d< real64 >,
0,
LEVEL_0,
WRITE_AND_READ,
"Mass" );
"Energy" );

DECLARE_FIELD( mass_n,
"mass_n",
DECLARE_FIELD( dEnergy_dPressure,
"dEnergy_dPressure",
array1d< real64 >,
0,
NOPLOT,
WRITE_AND_READ,
"Mass at the previous converged time step" );
NO_WRITE,
"Derivative of energy with respect to pressure" );

DECLARE_FIELD( energy,
"energy",
DECLARE_FIELD( dEnergy_dTemperature,
"dEnergy_dTemperature",
array1d< real64 >,
0,
LEVEL_0,
WRITE_AND_READ,
"Energy" );
NOPLOT,
NO_WRITE,
"Derivative of energy with respect to temperature" );

DECLARE_FIELD( energy_n,
"energy_n",
array1d< real64 >,
0,
NOPLOT,
WRITE_AND_READ,
NO_WRITE,
"Energy at the previous converged time step" );

DECLARE_FIELD( massCreated,
"massCreated",
array1d< real64 >,
0,
LEVEL_1,
WRITE_AND_READ,
"The amount of remaining mass that was introduced when the SurfaceElement was created." );

}

}
Expand Down
Loading
Loading