20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALDIRICHLETFLUXCOMPUTEKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALDIRICHLETFLUXCOMPUTEKERNEL_HPP
24 #include "constitutive/fluid/multifluid/MultiFluidBase.hpp"
25 #include "constitutive/fluid/multifluid/MultiFluidFields.hpp"
26 #include "constitutive/thermalConductivity/MultiPhaseThermalConductivityBase.hpp"
27 #include "constitutive/thermalConductivity/ThermalConductivityFields.hpp"
32 namespace thermalCompositionalMultiphaseFVMKernels
44 template<
integer NUM_COMP,
integer NUM_DOF,
typename FLUIDWRAPPER >
57 template<
typename VIEWTYPE >
61 using DofNumberAccessor = AbstractBase::DofNumberAccessor;
71 using AbstractBase::m_gravCoef;
73 using AbstractBase::m_dPhaseCompFrac;
81 using Base::m_dPhaseMob;
82 using Base::m_dPhaseMassDens;
87 using Base::m_faceTemp;
96 fields::multifluid::phaseEnthalpy,
97 fields::multifluid::dPhaseEnthalpy >;
101 fields::thermalconductivity::effectiveConductivity >;
128 FLUIDWRAPPER
const & fluidWrapper,
129 DofNumberAccessor
const & dofNumberAccessor,
140 BitFlags< isothermalCompositionalMultiphaseFVMKernels::KernelFlags > kernelFlags )
149 capPressureAccessors,
150 permeabilityAccessors,
155 m_temp( thermalCompFlowAccessors.get( fields::flow::temperature {} ) ),
156 m_phaseEnthalpy( thermalMultiFluidAccessors.get( fields::multifluid::phaseEnthalpy {} ) ),
157 m_dPhaseEnthalpy( thermalMultiFluidAccessors.get( fields::multifluid::dPhaseEnthalpy {} ) ),
158 m_thermalConductivity( thermalConductivityAccessors.get( fields::thermalconductivity::effectiveConductivity {} ) )
175 using Base::StackVariables::transmissibility;
176 using Base::StackVariables::dofColIndices;
177 using Base::StackVariables::localFlux;
178 using Base::StackVariables::localFluxJacobian;
209 using Deriv = constitutive::multifluid::DerivativeOffset;
225 real64 const facePhaseMob,
229 real64 const dPhaseFlux_dP,
236 real64 const dDensMean_dT = 0.5 * m_dPhaseMassDens[er][esr][ei][0][ip][Deriv::dT];
241 real64 const dF_dT = -stack.transmissibility * dDensMean_dT * ( m_gravCoef[er][esr][ei] -
m_faceGravCoef[kf] );
255 real64 const dPhaseFlux_dT =
m_phaseMob[er][esr][ei][ip] * dF_dT + m_dPhaseMob[er][esr][ei][ip][Deriv::dT] * f;
260 arraySlice1d<
real64 const, constitutive::multifluid::USD_PHASE_COMP - 3 > phaseCompFracSub =
262 arraySlice2d<
real64 const, constitutive::multifluid::USD_PHASE_COMP_DC - 3 > dPhaseCompFracSub =
263 m_dPhaseCompFrac[er][esr][ei][0][ip];
267 real64 const ycp = phaseCompFracSub[ic];
268 stack.
dCompFlux_dT[ic] += dPhaseFlux_dT * ycp + phaseFlux * dPhaseCompFracSub[ic][Deriv::dT];
275 stack.
dEnergyFlux_dP += dPhaseFlux_dP * enthalpy + phaseFlux * m_dPhaseEnthalpy[er][esr][ei][0][ip][Deriv::dP];
276 stack.
dEnergyFlux_dT += dPhaseFlux_dT * enthalpy + phaseFlux * m_dPhaseEnthalpy[er][esr][ei][0][ip][Deriv::dT];
281 m_dPhaseEnthalpy[er][esr][ei][0][ip],
286 stack.
dEnergyFlux_dC[jc] += dPhaseFlux_dC[jc] * enthalpy + phaseFlux * dProp_dC[jc];
294 real64 const dPhaseFlux_dT = facePhaseMob * dF_dT;
300 real64 const ycp = facePhaseCompFrac[ip][ic];
306 real64 const enthalpy = facePhaseEnthalpy[ip];
328 real64 thermalTrans = 0.0;
329 real64 dThermalTrans_dPerm[3]{};
333 dThermalTrans_dPerm );
337 * (
m_temp[
m_seri( iconn, Order::ELEM )][m_sesri( iconn, Order::ELEM )][m_sei( iconn, Order::ELEM )] - m_faceTemp[m_sei( iconn, Order::FACE )] );
383 stack.localFluxJacobian[
numEqn-1],
428 template<
typename POLICY,
typename STENCILWRAPPER >
433 integer const useTotalMassEquation,
434 string const & dofKey,
435 string const & solverName,
438 STENCILWRAPPER
const & stencilWrapper,
439 constitutive::MultiFluidBase & fluidBase,
444 constitutive::constitutiveComponentUpdatePassThru< true >( fluidBase, numComps, [&](
auto & fluid,
auto NC )
446 using FluidType = TYPEOFREF( fluid );
447 typename FluidType::KernelWrapper
const fluidWrapper = fluid.createKernelWrapper();
449 integer constexpr NUM_COMP = NC();
450 integer constexpr NUM_DOF = NC() + 2;
454 dofNumberAccessor.setName( solverName +
"/accessors/" + dofKey );
457 BitFlags< isothermalCompositionalMultiphaseFVMKernels::KernelFlags > kernelFlags;
458 if( useTotalMassEquation )
459 kernelFlags.set( isothermalCompositionalMultiphaseFVMKernels::KernelFlags::TotalMassEquation );
462 typename KernelType::CompFlowAccessors compFlowAccessors( elemManager, solverName );
463 typename KernelType::ThermalCompFlowAccessors thermalCompFlowAccessors( elemManager, solverName );
464 typename KernelType::MultiFluidAccessors multiFluidAccessors( elemManager, solverName );
465 typename KernelType::ThermalMultiFluidAccessors thermalMultiFluidAccessors( elemManager, solverName );
466 typename KernelType::CapPressureAccessors capPressureAccessors( elemManager, solverName );
467 typename KernelType::PermeabilityAccessors permeabilityAccessors( elemManager, solverName );
468 typename KernelType::ThermalConductivityAccessors thermalConductivityAccessors( elemManager, solverName );
470 KernelType kernel( numPhases, rankOffset, faceManager, stencilWrapper, fluidWrapper,
471 dofNumberAccessor, compFlowAccessors, thermalCompFlowAccessors, multiFluidAccessors, thermalMultiFluidAccessors,
472 capPressureAccessors, permeabilityAccessors, thermalConductivityAccessors,
473 dt, localMatrix, localRhs, kernelFlags );
474 KernelType::template launch< POLICY >( stencilWrapper.size(), kernel );
#define GEOS_HOST_DEVICE
Marks a host-device function.
GEOS_HOST_DEVICE void computeWeights(localIndex const iconn, CoefficientAccessor< arrayView3d< real64 const > > const &coefficient, real64 &weight, real64(&dWeight_dCoef)[3]) const
Compute weights and derivatives w.r.t to the coefficient.
The ElementRegionManager class provides an interface to ObjectManagerBase in order to manage ElementR...
ElementViewAccessor< ArrayView< T const, NDIM, getUSD< PERM > > > constructArrayViewAccessor(string const &name, string const &neighborName=string()) const
This is a function to construct a ElementViewAccessor to access array data registered on the mesh.
array1d< array1d< VIEWTYPE > > ElementViewAccessor
The ElementViewAccessor at the ElementRegionManager level is an array of array of VIEWTYPE.
typename ElementViewAccessor< VIEWTYPE >::NestedViewTypeConst ElementViewConst
The ElementViewAccessor at the ElementRegionManager level is the type resulting from ElementViewAcces...
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data.
A struct to automatically construct and store element view accessors.
A struct to automatically construct and store element view accessors.
Define the interface for the assembly kernel in charge of Dirichlet face flux terms.
arrayView1d< real64 const > const m_faceGravCoef
View on the face gravity coefficient.
GEOS_HOST_DEVICE void complete(localIndex const iconn, StackVariables &stack, FUNC &&assemblyKernelOp=NoOpFunc{}) const
Performs the complete phase for the kernel.
GEOS_HOST_DEVICE void computeFlux(localIndex const iconn, StackVariables &stack, FUNC &&compFluxKernelOp=NoOpFunc{}) const
Compute the local Dirichlet face flux contributions to the residual and Jacobian.
Base class for FluxComputeKernel that holds all data not dependent on template parameters (like stenc...
real64 const m_dt
Time step size.
ElementViewConst< arrayView1d< globalIndex const > > const m_dofNumber
Views on dof numbers.
arrayView1d< real64 > const m_localRhs
View on the local RHS.
ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > > const m_phaseCompFrac
Views on phase component fractions.
globalIndex const m_rankOffset
Offset for my MPI rank.
CRSMatrixView< real64, globalIndex const > const m_localMatrix
View on the local CRS matrix.
ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const m_dCompFrac_dCompDens
Views on derivatives of comp fractions.
integer const m_numPhases
Number of fluid phases.
static constexpr integer numEqn
Compute time value for the number of equations (all of them, except the volume balance equation)
static constexpr integer numComp
Compile time value for the number of components.
ElementViewConst< arrayView2d< real64 const, compflow::USD_PHASE > > const m_phaseMob
Views on phase mobilities.
STENCILWRAPPER::IndexContainerViewConstType const m_seri
Connection to element maps.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
BoundaryStencilWrapper const m_stencilWrapper
Reference to the stencil wrapper.
static void createAndLaunch(integer const numComps, integer const numPhases, globalIndex const rankOffset, integer const useTotalMassEquation, string const &dofKey, string const &solverName, FaceManager const &faceManager, ElementRegionManager const &elemManager, STENCILWRAPPER const &stencilWrapper, constitutive::MultiFluidBase &fluidBase, real64 const dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)
Create a new kernel and launch.
Define the interface for the assembly kernel in charge of Dirichlet face flux terms.
ElementViewConst< arrayView3d< real64 const > > const m_thermalConductivity
View on thermal conductivity.
real64 const m_dt
Time step size.
ElementRegionManager::ElementViewConst< VIEWTYPE > ElementViewConst
The type for element-based data. Consists entirely of ArrayView's.
GEOS_HOST_DEVICE void complete(localIndex const iconn, StackVariables &stack) const
Performs the complete phase for the kernel.
ElementViewConst< arrayView4d< real64 const, constitutive::multifluid::USD_PHASE_COMP > > const m_phaseCompFrac
Views on phase component fractions.
GEOS_HOST_DEVICE void computeFlux(localIndex const iconn, StackVariables &stack) const
Compute the local flux contributions to the residual and Jacobian.
ElementViewConst< arrayView3d< real64 const, compflow::USD_COMP_DC > > const m_dCompFrac_dCompDens
Views on derivatives of comp fractions.
DirichletFluxComputeKernel(integer const numPhases, globalIndex const rankOffset, FaceManager const &faceManager, BoundaryStencilWrapper const &stencilWrapper, FLUIDWRAPPER const &fluidWrapper, DofNumberAccessor const &dofNumberAccessor, CompFlowAccessors const &compFlowAccessors, ThermalCompFlowAccessors const &thermalCompFlowAccessors, MultiFluidAccessors const &multiFluidAccessors, ThermalMultiFluidAccessors const &thermalMultiFluidAccessors, CapPressureAccessors const &capPressureAccessors, PermeabilityAccessors const &permeabilityAccessors, ThermalConductivityAccessors const &thermalConductivityAccessors, real64 const dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs, BitFlags< isothermalCompositionalMultiphaseFVMKernels::KernelFlags > kernelFlags)
Constructor for the kernel interface.
ElementViewConst< arrayView1d< real64 const > > const m_temp
Views on temperature.
ElementViewConst< arrayView3d< real64 const, constitutive::multifluid::USD_PHASE > > const m_phaseEnthalpy
Views on phase enthalpies.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D array slice.
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
std::int32_t integer
Signed integer type.
Defines the order of element/face in the stencil.
real64 dEnergyFlux_dP
Derivative of energy fluxes wrt pressure.
real64 dCompFlux_dT[numComp]
Derivatives of component fluxes wrt temperature.
real64 dEnergyFlux_dT
Derivative of energy fluxes wrt temperature.
real64 dEnergyFlux_dC[numComp]
Derivatives of energy fluxes wrt component densities.
real64 energyFlux
Energy fluxes.
GEOS_HOST_DEVICE StackVariables(localIndex const size, localIndex numElems)
Constructor for the stack variables.