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

refactor: fields and constitutives #3517

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ DECLARE_FIELD( dTotalDensity,
NO_WRITE,
"Derivative of total density with respect to pressure, temperature, and global component fractions" );

DECLARE_FIELD( kValues,
"kValues",
array4dLayoutPhaseComp,
0,
NOPLOT,
WRITE_AND_READ,
"Phase equilibrium ratios" );

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@
namespace geos
{

namespace fields
{
namespace multifluid
{
DECLARE_FIELD( kValues,
"kValues",
array4dLayoutPhaseComp,
0,
NOPLOT,
WRITE_AND_READ,
"Phase equilibrium ratios" );
}
}

namespace constitutive
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void PVTDriver::postInputInitialization()

// get number of phases and components

constitutive::MultiFluidBase & baseFluid = getFluid();
MultiFluidBase & baseFluid = getFluid();

m_numPhases = baseFluid.numFluidPhases();
m_numComponents = baseFluid.numFluidComponents();
Expand Down Expand Up @@ -185,7 +185,7 @@ bool PVTDriver::execute( real64 const GEOS_UNUSED_PARAM( time_n ),
// get the fluid out of the constitutive manager.
// for the moment it is of type MultiFluidBase.

constitutive::MultiFluidBase & baseFluid = getFluid();
MultiFluidBase & baseFluid = getFluid();

// depending on logLevel, print some useful info

Expand Down Expand Up @@ -361,7 +361,7 @@ void PVTDriver::compareWithBaseline()
file.close();
}

constitutive::MultiFluidBase &
MultiFluidBase &
PVTDriver::getFluid()
{
ConstitutiveManager & constitutiveManager = this->getGroupByPath< ConstitutiveManager >( "/Problem/domain/Constitutive" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void ReactiveFluidDriver::runTest( FLUID_TYPE & fluid, arrayView2d< real64 > con
}

TableFunction const * waterDensityTable =
constitutive::PVTProps::PureWaterProperties::makeSaturationDensityTable( "helpTable", FunctionManager::getInstance() );
PVTProps::PureWaterProperties::makeSaturationDensityTable( "helpTable", FunctionManager::getInstance() );

TableFunction::KernelWrapper waterDensityTableWrapper = waterDensityTable->createKernelWrapper();

Expand All @@ -242,7 +242,7 @@ void ReactiveFluidDriver::runTest( FLUID_TYPE & fluid, arrayView2d< real64 > con
// convert molarity to molefraction
real64 const input[2] = { table( n, PRES ), table( n, TEMP ) };
real64 const conversionFactor =
constitutive::PVTProps::PureWaterProperties::MOLECULAR_WEIGHT / waterDensityTableWrapper.compute( input ) * 1e3;
PVTProps::PureWaterProperties::MOLECULAR_WEIGHT / waterDensityTableWrapper.compute( input ) * 1e3;
for( int i = 0; i < numPrimarySpecies; ++i )
{
composition[0][i] = primarySpeciesTotalConcentration[0][i] * conversionFactor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ void RelpermDriver::outputResults()

void RelpermDriver::postInputInitialization()
{
constitutive::ConstitutiveManager
& constitutiveManager = this->getGroupByPath< constitutive::ConstitutiveManager >( "/Problem/domain/Constitutive" );
constitutive::RelativePermeabilityBase
& baseRelperm = constitutiveManager.getGroup< constitutive::RelativePermeabilityBase >( m_relpermName );
ConstitutiveManager
& constitutiveManager = this->getGroupByPath< ConstitutiveManager >( "/Problem/domain/Constitutive" );
RelativePermeabilityBase
& baseRelperm = constitutiveManager.getGroup< RelativePermeabilityBase >( m_relpermName );

m_numPhases = baseRelperm.numFluidPhases();

Expand All @@ -112,10 +112,10 @@ bool RelpermDriver::execute( const geos::real64 GEOS_UNUSED_PARAM( time_n ),
GEOS_THROW_IF( MpiWrapper::commRank() > 0, "RelpermDriver should only be run in serial", std::runtime_error );


constitutive::ConstitutiveManager
& constitutiveManager = this->getGroupByPath< constitutive::ConstitutiveManager >( "/Problem/domain/Constitutive" );
constitutive::RelativePermeabilityBase
& baseRelperm = constitutiveManager.getGroup< constitutive::RelativePermeabilityBase >( m_relpermName );
ConstitutiveManager
& constitutiveManager = this->getGroupByPath< ConstitutiveManager >( "/Problem/domain/Constitutive" );
RelativePermeabilityBase
& baseRelperm = constitutiveManager.getGroup< RelativePermeabilityBase >( m_relpermName );

if( getLogLevel() > 0 )
{
Expand Down Expand Up @@ -165,12 +165,12 @@ bool RelpermDriver::execute( const geos::real64 GEOS_UNUSED_PARAM( time_n ),
template< typename RELPERM_TYPE >
void RelpermDriver::resizeTables()
{
constitutive::ConstitutiveManager
& constitutiveManager = this->getGroupByPath< constitutive::ConstitutiveManager >( "/Problem/domain/Constitutive" );
constitutive::RelativePermeabilityBase
& baseRelperm = constitutiveManager.getGroup< constitutive::RelativePermeabilityBase >( m_relpermName );
ConstitutiveManager
& constitutiveManager = this->getGroupByPath< ConstitutiveManager >( "/Problem/domain/Constitutive" );
RelativePermeabilityBase
& baseRelperm = constitutiveManager.getGroup< RelativePermeabilityBase >( m_relpermName );

using PT = constitutive::RelativePermeabilityBase::PhaseType;
using PT = RelativePermeabilityBase::PhaseType;
integer const ipWater = baseRelperm.getPhaseOrder()[PT::WATER];
integer const ipOil = baseRelperm.getPhaseOrder()[PT::OIL];
integer const ipGas = baseRelperm.getPhaseOrder()[PT::GAS];
Expand Down Expand Up @@ -246,7 +246,7 @@ void RelpermDriver::resizeTables()


template< typename RELPERM_TYPE >
std::enable_if_t< std::is_same< constitutive::TableRelativePermeabilityHysteresis, RELPERM_TYPE >::value, void >
std::enable_if_t< std::is_same< TableRelativePermeabilityHysteresis, RELPERM_TYPE >::value, void >
RelpermDriver::resizeTable()
{
if( m_numPhases > 2 )
Expand All @@ -261,7 +261,7 @@ RelpermDriver::resizeTable()
}

template< typename RELPERM_TYPE >
std::enable_if_t< !std::is_same< constitutive::TableRelativePermeabilityHysteresis, RELPERM_TYPE >::value, void >
std::enable_if_t< !std::is_same< TableRelativePermeabilityHysteresis, RELPERM_TYPE >::value, void >
RelpermDriver::resizeTable()
{
if( m_numPhases > 2 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace geos
FieldSpecificationManager * FieldSpecificationManager::m_instance = nullptr;

using namespace dataRepository;
using namespace constitutive;

FieldSpecificationManager::FieldSpecificationManager( string const & name, Group * const parent ):
Group( name, parent )
{
Expand Down Expand Up @@ -97,14 +97,14 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c

// Step 2: apply the boundary condition

fs.apply< dataRepository::Group >( mesh,
[&]( FieldSpecificationBase const &,
string const & setName,
SortedArrayView< localIndex const > const & targetSet,
Group & targetGroup,
string const fieldName )
fs.apply< Group >( mesh,
[&]( FieldSpecificationBase const &,
string const & setName,
SortedArrayView< localIndex const > const & targetSet,
Group & targetGroup,
string const fieldName )
{
dataRepository::InputFlags const flag = fs.getWrapper< string >( FieldSpecificationBase::viewKeyStruct::fieldNameString() ).getInputFlag();
InputFlags const flag = fs.getWrapper< string >( FieldSpecificationBase::viewKeyStruct::fieldNameString() ).getInputFlag();

// 2.a) If we enter this loop, we know that the set has been created
// Fracture/fault sets are created later and the "apply" call silently ignores them
Expand Down Expand Up @@ -219,12 +219,12 @@ void FieldSpecificationManager::applyInitialConditions( MeshLevel & mesh ) const
{
if( fs.initialCondition() )
{
fs.apply< dataRepository::Group >( mesh,
[&]( FieldSpecificationBase const & bc,
string const &,
SortedArrayView< localIndex const > const & targetSet,
Group & targetGroup,
string const fieldName )
fs.apply< Group >( mesh,
[&]( FieldSpecificationBase const & bc,
string const &,
SortedArrayView< localIndex const > const & targetSet,
Group & targetGroup,
string const fieldName )
{
bc.applyFieldValue< FieldSpecificationEqual >( targetSet, 0.0, targetGroup, fieldName );
} );
Expand Down
35 changes: 16 additions & 19 deletions src/coreComponents/fileIO/silo/SiloFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,9 @@ template<> int GetTensorRank< string >()
return DB_VARTYPE_SCALAR;
}



}



using namespace constitutive;
using namespace dataRepository;

Expand All @@ -264,7 +261,7 @@ SiloFile::SiloFile():
m_writeFaceMesh( 0 ),
m_writeCellElementMesh( 1 ),
m_writeFaceElementMesh( 1 ),
m_plotLevel( dataRepository::PlotLevel::LEVEL_1 ),
m_plotLevel( PlotLevel::LEVEL_1 ),
m_requireFieldRegistrationCheck( true ),
m_ghostFlags( true )
{
Expand Down Expand Up @@ -1223,7 +1220,7 @@ void SiloFile::writeElementRegionSilo( ElementRegionBase const & elemRegion,
{
// TODO: This is a hack.
conduit::Node conduitNode;
dataRepository::Group fakeGroup( elemRegion.getName(), conduitNode );
Group fakeGroup( elemRegion.getName(), conduitNode );

localIndex numElems = 0;
std::vector< std::map< string, WrapperBase const * > > viewPointers;
Expand Down Expand Up @@ -1454,12 +1451,12 @@ void SiloFile::writeElementMesh( ElementRegionBase const & elementRegion,
} );

string_array
regionSolidMaterialList = elementRegion.getConstitutiveNames< constitutive::SolidBase >();
regionSolidMaterialList = elementRegion.getConstitutiveNames< SolidBase >();

localIndex const numSolids = regionSolidMaterialList.size();

string_array regionFluidMaterialList = elementRegion.getConstitutiveNames< constitutive::SingleFluidBase >();
string_array regionMultiPhaseFluidList = elementRegion.getConstitutiveNames< constitutive::MultiFluidBase >();
string_array regionFluidMaterialList = elementRegion.getConstitutiveNames< SingleFluidBase >();
string_array regionMultiPhaseFluidList = elementRegion.getConstitutiveNames< MultiFluidBase >();

for( string const & matName : regionMultiPhaseFluidList )
{
Expand All @@ -1468,12 +1465,12 @@ void SiloFile::writeElementMesh( ElementRegionBase const & elementRegion,
localIndex const numFluids = regionFluidMaterialList.size();

string_array
fractureContactMaterialList = elementRegion.getConstitutiveNames< constitutive::FrictionBase >();
fractureContactMaterialList = elementRegion.getConstitutiveNames< FrictionBase >();

localIndex const numContacts = fractureContactMaterialList.size();

string_array
nullModelMaterialList = elementRegion.getConstitutiveNames< constitutive::NullModel >();
nullModelMaterialList = elementRegion.getConstitutiveNames< NullModel >();

localIndex const numNullModels = nullModelMaterialList.size();

Expand Down Expand Up @@ -2010,7 +2007,7 @@ int getTensorRankOfArray( ArrayView< TYPE const, NDIM, USD > const & field )

template< typename OUTPUTTYPE >
void SiloFile::writeWrappersToSilo( string const & meshname,
const dataRepository::Group::wrapperMap & wrappers,
const Group::wrapperMap & wrappers,
int const centering,
int const cycleNum,
real64 const problemTime,
Expand All @@ -2034,13 +2031,13 @@ void SiloFile::writeWrappersToSilo( string const & meshname,
// TODO This is wrong. problem with uniqueness
if( typeID==typeid(array1d< real64 >) )
{
auto const & wrapperT = dynamic_cast< dataRepository::Wrapper< array1d< real64 > > const & >( *wrapper );
auto const & wrapperT = dynamic_cast< Wrapper< array1d< real64 > > const & >( *wrapper );
this->writeDataField< real64 >( meshname.c_str(), fieldName,
wrapperT.reference(), centering, cycleNum, problemTime, multiRoot );
}
if( typeID==typeid(array2d< real64 >) )
{
auto const & wrapperT = dynamic_cast< dataRepository::Wrapper< array2d< real64 > > const & >( *wrapper );
auto const & wrapperT = dynamic_cast< Wrapper< array2d< real64 > > const & >( *wrapper );

arrayView2d< real64 const > const & array = wrapperT.reference();
this->writeDataField< real64 >( meshname.c_str(),
Expand All @@ -2056,7 +2053,7 @@ void SiloFile::writeWrappersToSilo( string const & meshname,
}
if( typeID==typeid(array2d< real64, RAJA::PERM_JI >) )
{
auto const & wrapperT = dynamic_cast< dataRepository::Wrapper< array2d< real64, RAJA::PERM_JI > > const & >( *wrapper );
auto const & wrapperT = dynamic_cast< Wrapper< array2d< real64, RAJA::PERM_JI > > const & >( *wrapper );

arrayView2d< real64 const, LvArray::typeManipulation::getStrideOneDimension( RAJA::PERM_JI {} ) > const &
array = wrapperT.reference();
Expand All @@ -2072,25 +2069,25 @@ void SiloFile::writeWrappersToSilo( string const & meshname,
}
if( typeID==typeid(array3d< real64 >) )
{
auto const & wrapperT = dynamic_cast< dataRepository::Wrapper< array3d< real64 > > const & >( *wrapper );
auto const & wrapperT = dynamic_cast< Wrapper< array3d< real64 > > const & >( *wrapper );
this->writeDataField< real64 >( meshname.c_str(), fieldName,
wrapperT.reference(), centering, cycleNum, problemTime, multiRoot );
}
if( typeID==typeid(integer_array) )
{
auto const & wrapperT = dynamic_cast< dataRepository::Wrapper< integer_array > const & >( *wrapper );
auto const & wrapperT = dynamic_cast< Wrapper< integer_array > const & >( *wrapper );
this->writeDataField< integer >( meshname.c_str(), fieldName,
wrapperT.reference(), centering, cycleNum, problemTime, multiRoot );
}
if( typeID==typeid(localIndex_array) )
{
auto const & wrapperT = dynamic_cast< dataRepository::Wrapper< localIndex_array > const & >( *wrapper );
auto const & wrapperT = dynamic_cast< Wrapper< localIndex_array > const & >( *wrapper );
this->writeDataField< localIndex >( meshname.c_str(), fieldName,
wrapperT.reference(), centering, cycleNum, problemTime, multiRoot );
}
if( typeID==typeid(globalIndex_array) )
{
auto const & wrapperT = dynamic_cast< dataRepository::Wrapper< globalIndex_array > const & >( *wrapper );
auto const & wrapperT = dynamic_cast< Wrapper< globalIndex_array > const & >( *wrapper );
this->writeDataField< globalIndex >( meshname.c_str(), fieldName,
wrapperT.reference(), centering, cycleNum, problemTime, multiRoot );
}
Expand Down Expand Up @@ -3195,7 +3192,7 @@ int SiloFile::getMeshType( string const & meshName ) const
return meshType;
}

bool SiloFile::isFieldPlotEnabled( dataRepository::WrapperBase const & wrapper ) const
bool SiloFile::isFieldPlotEnabled( WrapperBase const & wrapper ) const
{
return outputUtilities::isFieldPlotEnabled( wrapper.getPlotLevel(),
m_plotLevel,
Expand Down
4 changes: 2 additions & 2 deletions src/coreComponents/mainInterface/ProblemManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ using namespace dataRepository;
using namespace constitutive;

ProblemManager::ProblemManager( conduit::Node & root ):
dataRepository::Group( dataRepository::keys::ProblemManager, root ),
Group( keys::ProblemManager, root ),
m_physicsSolverManager( nullptr ),
m_eventManager( nullptr ),
m_functionManager( nullptr ),
Expand Down Expand Up @@ -960,7 +960,7 @@ map< std::tuple< string, string, string, string >, localIndex > ProblemManager::

finiteElement::FiniteElementBase &
fe = subRegion.template registerWrapper< finiteElement::FiniteElementBase >( discretizationName, std::move( newFE ) ).
setRestartFlags( dataRepository::RestartFlags::NO_WRITE ).reference();
setRestartFlags( RestartFlags::NO_WRITE ).reference();
subRegion.excludeWrappersFromPacking( { discretizationName } );

finiteElement::FiniteElementDispatchHandler< ALL_FE_TYPES >::dispatch3D( fe,
Expand Down
1 change: 0 additions & 1 deletion src/coreComponents/mesh/CellElementSubRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
namespace geos
{
using namespace dataRepository;
using namespace constitutive;

CellElementSubRegion::CellElementSubRegion( string const & name, Group * const parent ):
ElementSubRegionBase( name, parent )
Expand Down
1 change: 0 additions & 1 deletion src/coreComponents/mesh/ParticleSubRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
namespace geos
{
using namespace dataRepository;
using namespace constitutive;

ParticleSubRegion::ParticleSubRegion( string const & name, Group * const parent ):
ParticleSubRegionBase( name, parent )
Expand Down
1 change: 0 additions & 1 deletion src/coreComponents/mesh/ParticleSubRegionBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace geos
{

using namespace dataRepository;
using namespace constitutive;

ParticleSubRegionBase::ParticleSubRegionBase( string const & name, Group * const parent ):
ObjectManagerBase( name, parent ),
Expand Down
Loading
Loading