Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/byer3/single_phase_prop_…
Browse files Browse the repository at this point in the history
…refactor' into pt/mass-energy-1ph
  • Loading branch information
Pavel Tomin authored and Pavel Tomin committed Jan 23, 2025
2 parents dd2519a + 133deac commit ba262ba
Show file tree
Hide file tree
Showing 64 changed files with 932 additions and 904 deletions.
11 changes: 0 additions & 11 deletions src/coreComponents/constitutive/fluid/multifluid/Layouts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@ namespace geos
namespace constitutive
{

namespace singlefluid
{
struct DerivativeOffset
{
/// index of derivative wrt pressure
static integer constexpr dP = 0;
/// index of derivative wrt temperature
static integer constexpr dT = 1;

};
}
namespace multifluid
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ void CompressibleSinglePhaseFluid::allocateConstitutiveData( dataRepository::Gro
getField< fields::singlefluid::density >().setApplyDefaultValue( m_defaultDensity );
getField< fields::singlefluid::viscosity >().setApplyDefaultValue( m_defaultViscosity );

m_density.setValues< serialPolicy >( m_referenceDensity );
m_viscosity.setValues< serialPolicy >( m_referenceViscosity );
m_density.value.setValues< serialPolicy >( m_referenceDensity );
m_viscosity.value.setValues< serialPolicy >( m_referenceViscosity );
}

void CompressibleSinglePhaseFluid::postInputInitialization()
Expand Down Expand Up @@ -131,19 +131,22 @@ void CompressibleSinglePhaseFluid::postInputInitialization()
real64 dRho_dP;
real64 dVisc_dP;
createKernelWrapper().compute( m_referencePressure, m_referenceDensity, dRho_dP, m_referenceViscosity, dVisc_dP );
getField< fields::singlefluid::dDensity_dPressure >().setDefaultValue( dRho_dP );
getField< fields::singlefluid::dViscosity_dPressure >().setDefaultValue( dVisc_dP );

for( integer i=0; i<m_density.value.size(); i++ )
{
m_density.derivs[0][i][DerivOffset::dP] = dRho_dP;
}
}

CompressibleSinglePhaseFluid::KernelWrapper
CompressibleSinglePhaseFluid::createKernelWrapper()
{
return KernelWrapper( KernelWrapper::DensRelationType( m_referencePressure, m_referenceDensity, m_compressibility ),
KernelWrapper::ViscRelationType( m_referencePressure, m_referenceViscosity, m_viscosibility ),
m_density,
m_dDensity_dPressure,
m_viscosity,
m_dViscosity_dPressure );
m_density.value,
m_density.derivs,
m_viscosity.value,
m_viscosity.derivs );
}

REGISTER_CATALOG_ENTRY( ConstitutiveBase, CompressibleSinglePhaseFluid, string const &, Group * const )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ template< ExponentApproximationType DENS_EAT, ExponentApproximationType VISC_EAT
class CompressibleSinglePhaseUpdate : public SingleFluidBaseUpdate
{
public:

using SingleFluidProp = SingleFluidVar< real64, 2, singlefluid::LAYOUT_FLUID, singlefluid::LAYOUT_FLUID_DER >;
using DensRelationType = ExponentialRelation< real64, DENS_EAT >;
using ViscRelationType = ExponentialRelation< real64, VISC_EAT >;

using DerivOffset = singlefluid::DerivativeOffset;
CompressibleSinglePhaseUpdate( DensRelationType const & densRelation,
ViscRelationType const & viscRelation,
arrayView2d< real64 > const & density,
arrayView2d< real64 > const & dDens_dPres,
arrayView2d< real64 > const & viscosity,
arrayView2d< real64 > const & dVisc_dPres )
arrayView2d< real64, constitutive::singlefluid::USD_FLUID > const & density,
arrayView3d< real64, constitutive::singlefluid::USD_FLUID_DER > const & dDensity,
arrayView2d< real64, constitutive::singlefluid::USD_FLUID > const & viscosity,
arrayView3d< real64, constitutive::singlefluid::USD_FLUID_DER > const & dViscosity )
: SingleFluidBaseUpdate( density,
dDens_dPres,
dDensity,
viscosity,
dVisc_dPres ),
dViscosity ),
m_densRelation( densRelation ),
m_viscRelation( viscRelation )
{}
Expand Down Expand Up @@ -111,9 +111,9 @@ class CompressibleSinglePhaseUpdate : public SingleFluidBaseUpdate
{
compute( pressure,
m_density[k][q],
m_dDens_dPres[k][q],
m_dDensity[k][q][DerivOffset::dP],
m_viscosity[k][q],
m_dVisc_dPres[k][q] );
m_dViscosity[k][q][DerivOffset::dP] );
}

GEOS_HOST_DEVICE
Expand All @@ -125,9 +125,9 @@ class CompressibleSinglePhaseUpdate : public SingleFluidBaseUpdate
{
compute( pressure,
m_density[k][q],
m_dDens_dPres[k][q],
m_dDensity[k][q][DerivOffset::dP],
m_viscosity[k][q],
m_dVisc_dPres[k][q] );
m_dViscosity[k][q][DerivOffset::dP] );
}

private:
Expand All @@ -143,7 +143,7 @@ class CompressibleSinglePhaseUpdate : public SingleFluidBaseUpdate
class CompressibleSinglePhaseFluid : public SingleFluidBase
{
public:

using DerivOffset = singlefluid::DerivativeOffset;
CompressibleSinglePhaseFluid( string const & name, Group * const parent );

virtual ~CompressibleSinglePhaseFluid() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ void ProppantSlurryFluid::allocateConstitutiveData( dataRepository::Group & pare
{
SlurryFluidBase::allocateConstitutiveData( parent, numConstitutivePointsPerParentIndex );

m_density.setValues< serialPolicy >( m_referenceDensity );
m_viscosity.setValues< serialPolicy >( m_referenceViscosity );
m_density.value.setValues< serialPolicy >( m_referenceDensity );
m_viscosity.value.setValues< serialPolicy >( m_referenceViscosity );
}


Expand Down Expand Up @@ -109,21 +109,21 @@ ProppantSlurryFluid::createKernelWrapper()
m_nIndices,
m_Ks,
m_isNewtonianFluid,
m_density,
m_dDensity_dPressure,
m_density.value,
m_density.derivs,
m_dDensity_dProppantConc,
m_dDensity_dCompConc,
m_componentDensity,
m_dCompDens_dPres,
m_dCompDens_dCompConc,
m_fluidDensity,
m_fluidDensity.value,
m_dFluidDens_dPres,
m_dFluidDens_dCompConc,
m_fluidViscosity,
m_dFluidVisc_dPres,
m_dFluidVisc_dCompConc,
m_viscosity,
m_dViscosity_dPressure,
m_viscosity.value,
m_viscosity.derivs,
m_dViscosity_dProppantConc,
m_dViscosity_dCompConc );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ namespace constitutive
class ProppantSlurryFluidUpdate final : public SlurryFluidBaseUpdate
{
public:
using SingleFluidProp = SingleFluidVar< real64, 2, constitutive::singlefluid::LAYOUT_FLUID, constitutive::singlefluid::LAYOUT_FLUID_DER >;
using DerivOffset = constitutive::singlefluid::DerivativeOffsetC< 0 >;

/**
* @brief
Expand All @@ -50,7 +52,7 @@ class ProppantSlurryFluidUpdate final : public SlurryFluidBaseUpdate
* @param Ks
* @param isNewtonianFluid
* @param density
* @param dDens_dPres
* @param dDensity
* @param dDens_dProppantConc
* @param dDens_dCompConc
* @param componentDensity
Expand All @@ -63,7 +65,7 @@ class ProppantSlurryFluidUpdate final : public SlurryFluidBaseUpdate
* @param dFluidVisc_dPres
* @param dFluidVisc_dCompConc
* @param viscosity
* @param dVisc_dPres
* @param dViscosity
* @param dVisc_dProppantConc
* @param dVisc_dCompConc
*/
Expand All @@ -79,21 +81,21 @@ class ProppantSlurryFluidUpdate final : public SlurryFluidBaseUpdate
arrayView1d< real64 const > const & nIndices,
arrayView1d< real64 const > const & Ks,
bool const isNewtonianFluid,
arrayView2d< real64 > const & density,
arrayView2d< real64 > const & dDens_dPres,
arrayView2d< real64, constitutive::singlefluid::USD_FLUID > const & density,
arrayView3d< real64, constitutive::singlefluid::USD_FLUID_DER > const & dDensity,
arrayView2d< real64 > const & dDens_dProppantConc,
arrayView3d< real64 > const & dDens_dCompConc,
arrayView3d< real64 > const & componentDensity,
arrayView3d< real64 > const & dCompDens_dPres,
arrayView4d< real64 > const & dCompDens_dCompConc,
arrayView2d< real64 > const & fluidDensity,
arrayView2d< real64, constitutive::singlefluid::USD_FLUID > const & fluidDensity,
arrayView2d< real64 > const & dFluidDens_dPres,
arrayView3d< real64 > const & dFluidDens_dCompConc,
arrayView2d< real64 > const & fluidViscosity,
arrayView2d< real64 > const & dFluidVisc_dPres,
arrayView3d< real64 > const & dFluidVisc_dCompConc,
arrayView2d< real64 > const & viscosity,
arrayView2d< real64 > const & dVisc_dPres,
arrayView2d< real64, constitutive::singlefluid::USD_FLUID > const & viscosity,
arrayView3d< real64, constitutive::singlefluid::USD_FLUID_DER > const & dViscosity,
arrayView2d< real64 > const & dVisc_dProppantConc,
arrayView3d< real64 > const & dVisc_dCompConc )
: SlurryFluidBaseUpdate( defaultComponentDensity,
Expand All @@ -103,7 +105,7 @@ class ProppantSlurryFluidUpdate final : public SlurryFluidBaseUpdate
Ks,
isNewtonianFluid,
density,
dDens_dPres,
dDensity,
dDens_dProppantConc,
dDens_dCompConc,
componentDensity,
Expand All @@ -116,7 +118,7 @@ class ProppantSlurryFluidUpdate final : public SlurryFluidBaseUpdate
dFluidVisc_dPres,
dFluidVisc_dCompConc,
viscosity,
dVisc_dPres,
dViscosity,
dVisc_dProppantConc,
dVisc_dCompConc ),
m_compressibility( compressibility ),
Expand Down Expand Up @@ -164,11 +166,11 @@ class ProppantSlurryFluidUpdate final : public SlurryFluidBaseUpdate
m_dFluidVisc_dCompConc[k][q],
isProppantBoundary,
m_density[k][q],
m_dDensity_dPressure[k][q],
m_dDensity[k][q][DerivOffset::dP],
m_dDensity_dProppantConc[k][q],
m_dDensity_dCompConc[k][q],
m_viscosity[k][q],
m_dViscosity_dPressure[k][q],
m_dViscosity[k][q][DerivOffset::dP],
m_dViscosity_dProppantConc[k][q],
m_dViscosity_dCompConc[k][q] );
}
Expand Down Expand Up @@ -260,11 +262,11 @@ class ProppantSlurryFluidUpdate final : public SlurryFluidBaseUpdate
arraySlice1d< real64 const > const & dFluidViscosity_dComponentConcentration,
integer const & isProppantBoundary,
real64 & density,
real64 & dDensity_dPressure,
real64 & dDensity_dp,
real64 & dDensity_dProppantConcentration,
arraySlice1d< real64 > const & dDensity_dComponentConcentration,
real64 & viscosity,
real64 & dViscosity_dPressure,
real64 & dViscosity_dp,
real64 & dViscosity_dProppantConcentration,
arraySlice1d< real64 > const & dViscosity_dComponentConcentration ) const;

Expand Down Expand Up @@ -477,11 +479,11 @@ ProppantSlurryFluidUpdate::
arraySlice1d< real64 const > const & GEOS_UNUSED_PARAM( dFluidViscosity_dComponentConcentration ),
integer const & isProppantBoundary,
real64 & density,
real64 & dDensity_dPressure,
real64 & dDensity_dp,
real64 & dDensity_dProppantConcentration,
arraySlice1d< real64 > const & dDensity_dComponentConcentration,
real64 & viscosity,
real64 & dViscosity_dPressure,
real64 & dViscosity_dp,
real64 & dViscosity_dProppantConcentration,
arraySlice1d< real64 > const & dViscosity_dComponentConcentration ) const
{
Expand All @@ -494,7 +496,7 @@ ProppantSlurryFluidUpdate::
}

density = (1.0 - effectiveConcentration) * fluidDensity + effectiveConcentration * m_referenceProppantDensity;
dDensity_dPressure = (1.0 - effectiveConcentration) * dFluidDensity_dPressure;
dDensity_dp = (1.0 - effectiveConcentration) * dFluidDensity_dPressure;

dDensity_dProppantConcentration = 0.0;
for( localIndex c = 0; c < NC; ++c )
Expand All @@ -504,8 +506,7 @@ ProppantSlurryFluidUpdate::

real64 const coef = pow( 1.0 + 1.25 * effectiveConcentration / (1.0 - effectiveConcentration / m_maxProppantConcentration), 2.0 );
viscosity = fluidViscosity * coef;
dViscosity_dPressure = dFluidViscosity_dPressure * coef;

dViscosity_dp = dFluidViscosity_dPressure * coef;
dViscosity_dProppantConcentration = 0.0;
for( localIndex c = 0; c < NC; ++c )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,22 @@ namespace constitutive
{

SingleFluidBase::SingleFluidBase( string const & name, Group * const parent )
: ConstitutiveBase( name, parent )
: ConstitutiveBase( name, parent ),
m_numDOF( 1 )
{
registerField( fields::singlefluid::density{}, &m_density );
registerField( fields::singlefluid::dDensity_dPressure{}, &m_dDensity_dPressure );
registerField( fields::singlefluid::dDensity_dTemperature{}, &m_dDensity_dTemperature );
registerField( fields::singlefluid::density{}, &m_density.value );
registerField( fields::singlefluid::dDensity{}, &m_density.derivs );
registerField( fields::singlefluid::density_n{}, &m_density_n );

registerField( fields::singlefluid::viscosity{}, &m_viscosity );
registerField( fields::singlefluid::dViscosity_dPressure{}, &m_dViscosity_dPressure );
registerField( fields::singlefluid::dViscosity_dTemperature{}, &m_dViscosity_dTemperature );
registerField( fields::singlefluid::viscosity{}, &m_viscosity.value );
registerField( fields::singlefluid::dViscosity{}, &m_viscosity.derivs );

registerField( fields::singlefluid::internalEnergy{}, &m_internalEnergy );
registerField( fields::singlefluid::internalEnergy{}, &m_internalEnergy.value );
registerField( fields::singlefluid::dInternalEnergy{}, &m_internalEnergy.derivs );
registerField( fields::singlefluid::internalEnergy_n{}, &m_internalEnergy_n );
registerField( fields::singlefluid::dInternalEnergy_dPressure{}, &m_dInternalEnergy_dPressure );
registerField( fields::singlefluid::dInternalEnergy_dTemperature{}, &m_dInternalEnergy_dTemperature );

registerField( fields::singlefluid::enthalpy{}, &m_enthalpy );
registerField( fields::singlefluid::dEnthalpy_dPressure{}, &m_dEnthalpy_dPressure );
registerField( fields::singlefluid::dEnthalpy_dTemperature{}, &m_dEnthalpy_dTemperature );

registerField( fields::singlefluid::enthalpy{}, &m_enthalpy.value );
registerField( fields::singlefluid::dEnthalpy{}, &m_enthalpy.derivs );
}

void SingleFluidBase::postInputInitialization()
Expand All @@ -68,8 +64,23 @@ void SingleFluidBase::initializeState() const

void SingleFluidBase::saveConvergedState() const
{
m_density_n.setValues< parallelDevicePolicy<> >( m_density.toViewConst() );
m_internalEnergy_n.setValues< parallelDevicePolicy<> >( m_internalEnergy.toViewConst() );
localIndex const numElem = m_density.value.size( 0 );
localIndex const numGauss = m_density.value.size( 1 );

SingleFluidProp::ViewTypeConst const density = m_density.toViewConst();
SingleFluidProp::ViewTypeConst const internalEnergy = m_internalEnergy.toViewConst();

arrayView2d< real64, singlefluid::USD_FLUID > const density_n = m_density_n.toView();
arrayView2d< real64, singlefluid::USD_FLUID > const internalEnergy_n = m_internalEnergy_n.toView();

forAll< parallelDevicePolicy<> >( numElem, [=] GEOS_HOST_DEVICE ( localIndex const k )
{
for( localIndex q = 0; q < numGauss; ++q )
{
density_n[k][q] = density.value[k][q];
internalEnergy_n[k][q] = internalEnergy.value[k][q];
}
} );
}

//START_SPHINX_INCLUDE_00
Expand All @@ -80,23 +91,23 @@ void SingleFluidBase::allocateConstitutiveData( Group & parent,

resize( parent.size() );

m_density.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_dDensity_dPressure.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_dDensity_dTemperature.resize( parent.size(), numConstitutivePointsPerParentIndex );
// density
m_density.value.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_density.derivs.resize( parent.size(), numConstitutivePointsPerParentIndex, m_numDOF );
m_density_n.resize( parent.size(), numConstitutivePointsPerParentIndex );

m_viscosity.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_dViscosity_dPressure.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_dViscosity_dTemperature.resize( parent.size(), numConstitutivePointsPerParentIndex );
// viscosity
m_viscosity.value.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_viscosity.derivs.resize( parent.size(), numConstitutivePointsPerParentIndex, m_numDOF );

m_internalEnergy.resize( parent.size(), numConstitutivePointsPerParentIndex );
// internal energy
m_internalEnergy.value.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_internalEnergy.derivs.resize( parent.size(), numConstitutivePointsPerParentIndex, m_numDOF );
m_internalEnergy_n.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_dInternalEnergy_dPressure.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_dInternalEnergy_dTemperature.resize( parent.size(), numConstitutivePointsPerParentIndex );

m_enthalpy.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_dEnthalpy_dPressure.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_dEnthalpy_dTemperature.resize( parent.size(), numConstitutivePointsPerParentIndex );
// enthalpy
m_enthalpy.value.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_enthalpy.derivs.resize( parent.size(), numConstitutivePointsPerParentIndex, m_numDOF );
}
//END_SPHINX_INCLUDE_00

Expand Down
Loading

0 comments on commit ba262ba

Please sign in to comment.