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: Add component selector for fluid models #3213

Merged
merged 18 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
5 changes: 5 additions & 0 deletions BASELINE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ This file is designed to track changes to the integrated test baselines.
Any developer who updates the baseline ID in the .integrated_tests.yaml file is expected to create an entry in this file with the pull request number, date, and their justification for rebaselining.
These notes should be in reverse-chronological order, and use the following time format: (YYYY-MM-DD).

PR #3213 (2024-07-12)
======================
Added baselines for new tests on Dirichlet boundary conditions for multiphase flow.


PR #3194 (2024-07-10)
======================
Use aperture table in poromechanics with conforming fractures. Rebaseline the corresponding cases.
Expand Down
227 changes: 227 additions & 0 deletions inputFiles/compositionalMultiphaseFlow/co2_flux_dirichlet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
<?xml version="1.0" ?>

<Problem>
<Solvers>
<CompositionalMultiphaseFVM
name="compflow"
logLevel="1"
discretization="fluidTPFA"
temperature="368.15"
useMass="1"
targetRegions="{ region }">
<NonlinearSolverParameters
newtonTol="1.0e-4"
newtonMaxIter="100"
maxTimeStepCuts="5"
lineSearchAction="None"/>
<LinearSolverParameters
solverType="fgmres"
preconditionerType="mgr"
krylovTol="1.0e-5"/>
</CompositionalMultiphaseFVM>
</Solvers>

<Mesh>
<InternalMesh
name="mesh"
elementTypes="{ C3D8 }"
xCoords="{ 0, 50.0 }"
yCoords="{ -0.5, 0.5 }"
zCoords="{ 0, 15.0 }"
nx="{ 50 }"
ny="{ 1 }"
nz="{ 15 }"
cellBlockNames="{ cellBlock }"/>
</Mesh>

<Geometry>
<Box
name="source"
xMin="{ -0.01, -0.51, 6.99 }"
xMax="{ 1.01, 0.51, 8.01 }"/>

<Box
name="rightEnd"
xMin="{ 49.99, -0.51, -0.01 }"
xMax="{ 50.01, 0.51, 15.01 }"/>
</Geometry>

<Events
maxTime="1e6">
<PeriodicEvent
name="solverApplications"
maxEventDt="5e4"
target="/Solvers/compflow" />

<PeriodicEvent
name="statistics"
timeFrequency="1e5"
targetExactTimestep="1"
target="/Tasks/compflowStatistics" />

<PeriodicEvent
name="outputs"
timeFrequency="1e5"
targetExactTimestep="1"
target="/Outputs/vtkOutput" />

<PeriodicEvent
name="restarts"
timeFrequency="5e5"
targetExactTimestep="0"
target="/Outputs/sidreRestart"/>
</Events>

<NumericalMethods>
<FiniteVolume>
<TwoPointFluxApproximation
name="fluidTPFA"/>
</FiniteVolume>
</NumericalMethods>

<ElementRegions>
<CellElementRegion
name="region"
cellBlocks="{ cellBlock }"
materialList="{ fluid, rock, relperm }"/>
</ElementRegions>

<Constitutive>
<CO2BrinePhillipsFluid
name="fluid"
logLevel="1"
phaseNames="{ gas, water }"
componentNames="{ co2, water }"
componentMolarWeight="{ 44e-3, 18e-3 }"
phasePVTParaFiles="{ pvtgas.txt, pvtliquid.txt }"
flashModelParaFile="co2flash.txt"/>

<CompressibleSolidConstantPermeability
name="rock"
solidModelName="nullSolid"
porosityModelName="rockPorosity"
permeabilityModelName="rockPerm"/>
<NullModel
name="nullSolid"/>
<PressurePorosity
name="rockPorosity"
defaultReferencePorosity="0.2"
referencePressure="1.1e7"
compressibility="1.0e-9" />
<ConstantPermeability
name="rockPerm"
permeabilityComponents="{ 1.0e-13, 1.0e-13, 1.0e-14 }"/>

<TableRelativePermeability
name="relperm"
phaseNames="{ gas, water }"
wettingNonWettingRelPermTableNames="{ waterRelativePermeabilityTable,
gasRelativePermeabilityTable }"/>
</Constitutive>

<FieldSpecifications>
<!-- Initial conditions -->
<FieldSpecification
name="initial_pressure"
setNames="{ all }"
objectPath="ElementRegions/region"
fieldName="pressure"
initialCondition="1"
logLevel="2"
scale="1.1e6" />
<FieldSpecification
name="initial_temperature"
setNames="{ all }"
objectPath="ElementRegions/region"
fieldName="temperature"
initialCondition="1"
scale="368.15" />
<FieldSpecification
name="initial_co2"
setNames="{ all }"
objectPath="ElementRegions/region"
fieldName="globalCompFraction"
initialCondition="1"
component="0"
scale="0.0" />
<FieldSpecification
name="initial_h2o"
setNames="{ all }"
objectPath="ElementRegions/region"
fieldName="globalCompFraction"
initialCondition="1"
component="1"
scale="1.0" />

<!-- Injection rate: 0.002 kg/s -->
<SourceFlux
name="sourceTerm"
objectPath="ElementRegions/region/cellBlock"
component="0"
scale="-0.002"
setNames="{ source }"/>

<!-- Boundary conditions at right end -->
<FieldSpecification
name="sinkTerm_pressure"
setNames="{ rightEnd }"
objectPath="faceManager"
fieldName="pressure"
scale="1.1e6" />
<FieldSpecification
name="sinkTerm_temperature"
setNames="{ rightEnd }"
objectPath="faceManager"
fieldName="temperature"
scale="368.15" />
<FieldSpecification
name="sinkTerm_co2"
setNames="{ rightEnd }"
objectPath="faceManager"
fieldName="globalCompFraction"
component="0"
scale="0.0" />
<FieldSpecification
name="sinkTerm_h2o"
setNames="{ rightEnd }"
objectPath="faceManager"
fieldName="globalCompFraction"
component="1"
scale="1.0" />

</FieldSpecifications>

<Tasks>

<CompositionalMultiphaseStatistics
name="compflowStatistics"
flowSolverName="compflow"
logLevel="1"
writeCSV="1"
computeCFLNumbers="1"
computeRegionStatistics="1"/>

</Tasks>

<Functions>
<TableFunction
name="waterRelativePermeabilityTable"
coordinateFiles="{ phaseVolFraction_water.txt }"
voxelFile="relPerm_water.txt"/>

<TableFunction
name="gasRelativePermeabilityTable"
coordinateFiles="{ phaseVolFraction_gas.txt }"
voxelFile="relPerm_gas.txt"/>
</Functions>

<Outputs>
<VTK
name="vtkOutput"
plotFileRoot="co2_flux_dirichlet"/>

<Restart
name="sidreRestart"/>
</Outputs>

</Problem>
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ decks = [
restart_step=10,
check_step=20,
restartcheck_params=RestartcheckParameters(**restartcheck_params)),
TestDeck(
name="co2_flux_dirichlet",
description=
"Compositional co2-brine flow test (2D co2 injection, 2-phase co2-brine, Table 2-phase relperm curves, Dirichlet boundary)",
partitions=((1, 1, 1), (2, 1, 3)),
restart_step=23,
check_step=46,
restartcheck_params=RestartcheckParameters(**restartcheck_params)),
TestDeck(
name="deadoil_3ph_staircase_obl_3d",
description=
Expand Down
10 changes: 8 additions & 2 deletions src/coreComponents/common/TypeDispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ using Increment = typename IncrementImpl< T, N >::type;

} // namespace internal

/**
* @brief Generate a sequence of integers from @p Begin up to (and including) @p End.
*/
template< integer Begin, integer End >
using IntegerSequence = internal::Increment< camp::make_idx_seq_t< End - Begin + 1 >, Begin >;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice! We did have something like this already.


/**
* @brief Construct a list of types.
*/
Expand Down Expand Up @@ -189,10 +195,10 @@ using IntegralTypes = TypeList< integer, localIndex, globalIndex >;
using RealTypes = TypeList< real32, real64 >;

/**
* @brief Generate a list of types representing array dimensionalities from M up to (and including) @p N.
* @brief Generate a list of types representing array dimensionalities from @p M up to (and including) @p N.
*/
template< int M, int N >
using DimsRange = camp::as_list< internal::Increment< camp::make_idx_seq_t< N - M + 1 >, M > >;
using DimsRange = camp::as_list< IntegerSequence< M, N > >;

/**
* @brief Generate a list of types representing array dimensionality exactly @p N.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,6 @@ CO2BrineFluid( string const & name, Group * const parent ):
}
}

template< typename PHASE1, typename PHASE2, typename FLASH >
bool CO2BrineFluid< PHASE1, PHASE2, FLASH >::isThermal() const
{
return ( PHASE1::Enthalpy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() &&
PHASE2::Enthalpy::catalogName() != PVTProps::NoOpPVTFunction::catalogName() );
}


template< typename PHASE1, typename PHASE2, typename FLASH >
std::unique_ptr< ConstitutiveBase >
CO2BrineFluid< PHASE1, PHASE2, FLASH >::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,19 @@ class CO2BrineFluid : public MultiFluidBase

virtual string getCatalogName() const override { return catalogName(); }

virtual bool isThermal() const override;
static constexpr bool thermal()
{
return !( std::is_same_v< typename PHASE1::Enthalpy, PVTProps::NoOpPVTFunction > ||
std::is_same_v< typename PHASE2::Enthalpy, PVTProps::NoOpPVTFunction > );
}

static constexpr integer min_n_components = 2;
static constexpr integer max_n_components = 2;

virtual bool isThermal() const override
{
return thermal();
}

/**
* @brief Kernel wrapper class for CO2BrineFluid.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ class MultiFluidBase : public ConstitutiveBase
*/
static constexpr integer MAX_NUM_PHASES = MultiFluidConstants::MAX_NUM_PHASES;

/**
* @brief Minimum supported number of fluid components (species) for dispatch
* @note This is the mininum number of components that can be used for dispatch in a kernel launch specific for
* this fluid type.
*/
static constexpr integer min_n_components = 2;

/**
* @brief Maximum supported number of fluid components (species) for dispatch
* @note This is the maxinum number of components that can be used for dispatch in a kernel launch specific for
* this fluid type.
*/
static constexpr integer max_n_components = 5;

/**
* @return number of fluid components (species) in the model
*/
Expand Down
Loading
Loading