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

Single phase property container refactor #3460

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from
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,6 +131,11 @@ void CompressibleSinglePhaseFluid::postInputInitialization()
real64 dRho_dP;
real64 dVisc_dP;
createKernelWrapper().compute( m_referencePressure, m_referenceDensity, dRho_dP, m_referenceViscosity, dVisc_dP );

for( integer i=0; i<m_density.value.size(); i++ )
{
m_density.derivs[0][i][DerivOffset::dP] = dRho_dP;
}
getField< fields::singlefluid::dDensity_dPressure >().setDefaultValue( dRho_dP );
getField< fields::singlefluid::dViscosity_dPressure >().setDefaultValue( dVisc_dP );
}
Expand All @@ -140,9 +145,11 @@ CompressibleSinglePhaseFluid::createKernelWrapper()
{
return KernelWrapper( KernelWrapper::DensRelationType( m_referencePressure, m_referenceDensity, m_compressibility ),
KernelWrapper::ViscRelationType( m_referencePressure, m_referenceViscosity, m_viscosibility ),
m_density,
m_density.value,
m_density.derivs,
m_dDensity_dPressure,
m_viscosity,
m_viscosity.value,
m_viscosity.derivs,
m_dViscosity_dPressure );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,23 @@ template< ExponentApproximationType DENS_EAT, ExponentApproximationType VISC_EAT
class CompressibleSinglePhaseUpdate : public SingleFluidBaseUpdate
{
public:

using SingleFluidProp = SingleFluidVar< real64, 2, singlefluid::LAYOUT_FLUID, singlefluid::LAYOUT_FLUID_DC >;
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,
arrayView3d< real64 > const & dDensity,
arrayView2d< real64 > const & dDens_dPres,
arrayView2d< real64 > const & viscosity,
arrayView3d< real64 > const & dViscosity,
arrayView2d< real64 > const & dVisc_dPres )
: SingleFluidBaseUpdate( density,
dDensity,
dDens_dPres,
viscosity,
dViscosity,
dVisc_dPres ),
m_densRelation( densRelation ),
m_viscRelation( viscRelation )
Expand Down Expand Up @@ -114,6 +118,14 @@ class CompressibleSinglePhaseUpdate : public SingleFluidBaseUpdate
m_dDens_dPres[k][q],
m_viscosity[k][q],
m_dVisc_dPres[k][q] );
compute( pressure,
m_density[k][q],
m_dDensity[k][q][DerivOffset::dP],
m_viscosity[k][q],
m_dVisc_dPres[k][q] );
// tjb std::cout << m_dDens_dPres[k][q]<< " " << m_density_c.derivs[k][q][DerivOffset::dP] << std::endl;
// std::cout.flush();
// assert(fabs(m_dDens_dPres[k][q]-m_density_c.derivs[k][q][DerivOffset::dP])<FLT_EPSILON);
}

GEOS_HOST_DEVICE
Expand All @@ -128,6 +140,15 @@ class CompressibleSinglePhaseUpdate : public SingleFluidBaseUpdate
m_dDens_dPres[k][q],
m_viscosity[k][q],
m_dVisc_dPres[k][q] );
// tjb same same
compute( pressure,
m_density[k][q],
m_dDensity[k][q][DerivOffset::dP],
m_viscosity[k][q],
m_dViscosity[k][q][DerivOffset::dP] );
// tjb std::cout << m_dDens_dPres[k][q]<< " " << m_density_c.derivs[k][q][DerivOffset::dP] << std::endl;
// std::cout.flush();
// assert(fabs(m_dDens_dPres[k][q]-m_density_c.derivs[k][q][DerivOffset::dP])<FLT_EPSILON);
}

private:
Expand All @@ -143,7 +164,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,20 +109,22 @@ ProppantSlurryFluid::createKernelWrapper()
m_nIndices,
m_Ks,
m_isNewtonianFluid,
m_density,
m_density.value,
m_density.derivs,
m_dDensity_dPressure,
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_viscosity.value,
m_viscosity.derivs,
m_dViscosity_dPressure,
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_DC >;
using DerivOffset = constitutive::singlefluid::DerivativeOffsetC<0>;

/**
* @brief
Expand Down Expand Up @@ -80,6 +82,7 @@ class ProppantSlurryFluidUpdate final : public SlurryFluidBaseUpdate
arrayView1d< real64 const > const & Ks,
bool const isNewtonianFluid,
arrayView2d< real64 > const & density,
arrayView3d< real64 > const & dDensity,
arrayView2d< real64 > const & dDens_dPres,
arrayView2d< real64 > const & dDens_dProppantConc,
arrayView3d< real64 > const & dDens_dCompConc,
Expand All @@ -93,6 +96,7 @@ class ProppantSlurryFluidUpdate final : public SlurryFluidBaseUpdate
arrayView2d< real64 > const & dFluidVisc_dPres,
arrayView3d< real64 > const & dFluidVisc_dCompConc,
arrayView2d< real64 > const & viscosity,
arrayView3d< real64 > const & dViscosity,
arrayView2d< real64 > const & dVisc_dPres,
arrayView2d< real64 > const & dVisc_dProppantConc,
arrayView3d< real64 > const & dVisc_dCompConc )
Expand All @@ -103,6 +107,7 @@ class ProppantSlurryFluidUpdate final : public SlurryFluidBaseUpdate
Ks,
isNewtonianFluid,
density,
dDensity,
dDens_dPres,
dDens_dProppantConc,
dDens_dCompConc,
Expand All @@ -116,6 +121,7 @@ class ProppantSlurryFluidUpdate final : public SlurryFluidBaseUpdate
dFluidVisc_dPres,
dFluidVisc_dCompConc,
viscosity,
dViscosity,
dVisc_dPres,
dVisc_dProppantConc,
dVisc_dCompConc ),
Expand Down Expand Up @@ -164,10 +170,12 @@ class ProppantSlurryFluidUpdate final : public SlurryFluidBaseUpdate
m_dFluidVisc_dCompConc[k][q],
isProppantBoundary,
m_density[k][q],
m_dDensity[k][q][DerivOffset::dP], // tjb add deriv:dp
m_dDensity_dPressure[k][q],
m_dDensity_dProppantConc[k][q],
m_dDensity_dCompConc[k][q],
m_viscosity[k][q],
m_dViscosity[k][q][DerivOffset::dP],// tjb add deriv:dp
m_dViscosity_dPressure[k][q],
m_dViscosity_dProppantConc[k][q],
m_dViscosity_dCompConc[k][q] );
Expand Down Expand Up @@ -260,10 +268,12 @@ class ProppantSlurryFluidUpdate final : public SlurryFluidBaseUpdate
arraySlice1d< real64 const > const & dFluidViscosity_dComponentConcentration,
integer const & isProppantBoundary,
real64 & density,
real64 & dDensity_dp, // tjb
real64 & dDensity_dPressure,
real64 & dDensity_dProppantConcentration,
arraySlice1d< real64 > const & dDensity_dComponentConcentration,
real64 & viscosity,
real64 & dViscosity_dp, // tjb
real64 & dViscosity_dPressure,
real64 & dViscosity_dProppantConcentration,
arraySlice1d< real64 > const & dViscosity_dComponentConcentration ) const;
Expand Down Expand Up @@ -477,10 +487,12 @@ ProppantSlurryFluidUpdate::
arraySlice1d< real64 const > const & GEOS_UNUSED_PARAM( dFluidViscosity_dComponentConcentration ),
integer const & isProppantBoundary,
real64 & density,
real64 & dDensity_dp, //tjb
real64 & dDensity_dPressure,
real64 & dDensity_dProppantConcentration,
arraySlice1d< real64 > const & dDensity_dComponentConcentration,
real64 & viscosity,
real64 & dViscosity_dp, //tjb
real64 & dViscosity_dPressure,
real64 & dViscosity_dProppantConcentration,
arraySlice1d< real64 > const & dViscosity_dComponentConcentration ) const
Expand All @@ -495,6 +507,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 @@ -505,7 +518,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,25 +30,36 @@ 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::density{}, &m_density.value );
registerField( fields::singlefluid::dDensity_dPressure{}, &m_dDensity_dPressure );
registerField( fields::singlefluid::dDensity_dTemperature{}, &m_dDensity_dTemperature );
registerField( fields::singlefluid::density_n{}, &m_density_n );

registerField( fields::singlefluid::viscosity{}, &m_viscosity );
registerField( fields::singlefluid::density{}, &m_density.value );
registerField( fields::singlefluid::dDensity{}, &m_density.derivs );

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

registerField( fields::singlefluid::dViscosity_dPressure{}, &m_dViscosity_dPressure );
registerField( fields::singlefluid::dViscosity_dTemperature{}, &m_dViscosity_dTemperature );

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::enthalpy{}, &m_enthalpy.value );
registerField( fields::singlefluid::dEnthalpy{}, &m_enthalpy.derivs );
#if 1
registerField( fields::singlefluid::dEnthalpy_dPressure{}, &m_dEnthalpy_dPressure );
registerField( fields::singlefluid::dEnthalpy_dTemperature{}, &m_dEnthalpy_dTemperature );
#endif

}

Expand All @@ -68,8 +79,8 @@ void SingleFluidBase::initializeState() const

void SingleFluidBase::saveConvergedState() const
{
m_density_n.setValues< parallelDevicePolicy<> >( m_density.toViewConst() );
m_internalEnergy_n.setValues< parallelDevicePolicy<> >( m_internalEnergy.toViewConst() );
m_density_n.setValues< parallelDevicePolicy<> >( m_density.value.toViewConst() );
m_internalEnergy_n.setValues< parallelDevicePolicy<> >( m_internalEnergy.value.toViewConst() );
}

//START_SPHINX_INCLUDE_00
Expand All @@ -80,21 +91,33 @@ 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 );
m_density_n.resize( parent.size(), numConstitutivePointsPerParentIndex );

m_viscosity.resize( parent.size(), numConstitutivePointsPerParentIndex );
// tjb new density
m_density.value.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_density.derivs.resize( parent.size(), numConstitutivePointsPerParentIndex, m_numDOF );

// tjb new viscosity
m_viscosity.value.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_viscosity.derivs.resize( parent.size(), numConstitutivePointsPerParentIndex, m_numDOF );

m_dViscosity_dPressure.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_dViscosity_dTemperature.resize( parent.size(), numConstitutivePointsPerParentIndex );

m_internalEnergy.resize( parent.size(), numConstitutivePointsPerParentIndex );
// tjb new 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 );
// tjb new enthalpy
m_enthalpy.value.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_enthalpy.derivs.resize( parent.size(), numConstitutivePointsPerParentIndex, m_numDOF );

m_dEnthalpy_dPressure.resize( parent.size(), numConstitutivePointsPerParentIndex );
m_dEnthalpy_dTemperature.resize( parent.size(), numConstitutivePointsPerParentIndex );
}
Expand Down
Loading
Loading