20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_THERMALFLUXCOMPUTEKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_THERMALFLUXCOMPUTEKERNEL_HPP
25 #include "constitutive/thermalConductivity/SinglePhaseThermalConductivityBase.hpp"
26 #include "constitutive/thermalConductivity/ThermalConductivityFields.hpp"
31 namespace thermalSinglePhaseFVMKernels
41 template<
integer NUM_EQN,
integer NUM_DOF,
typename STENCILWRAPPER >
52 template<
typename VIEWTYPE >
56 using DofNumberAccessor = AbstractBase::DofNumberAccessor;
64 using AbstractBase::m_gravCoef;
81 fields::flow::dMobility_dTemperature >;
85 fields::singlefluid::dDensity_dTemperature,
86 fields::singlefluid::enthalpy,
87 fields::singlefluid::dEnthalpy_dPressure,
88 fields::singlefluid::dEnthalpy_dTemperature >;
92 fields::thermalconductivity::effectiveConductivity,
93 fields::thermalconductivity::dEffectiveConductivity_dT >;
112 STENCILWRAPPER
const & stencilWrapper,
113 DofNumberAccessor
const & dofNumberAccessor,
126 singlePhaseFlowAccessors,
127 singlePhaseFluidAccessors,
128 permeabilityAccessors,
132 m_temp( thermalSinglePhaseFlowAccessors.get( fields::flow::temperature {} ) ),
133 m_dMob_dTemp( thermalSinglePhaseFlowAccessors.get( fields::flow::dMobility_dTemperature {} ) ),
134 m_dDens_dTemp( thermalSinglePhaseFluidAccessors.get( fields::singlefluid::dDensity_dTemperature {} ) ),
135 m_enthalpy( thermalSinglePhaseFluidAccessors.get( fields::singlefluid::enthalpy {} ) ),
136 m_dEnthalpy_dPres( thermalSinglePhaseFluidAccessors.get( fields::singlefluid::dEnthalpy_dPressure {} ) ),
137 m_dEnthalpy_dTemp( thermalSinglePhaseFluidAccessors.get( fields::singlefluid::dEnthalpy_dTemperature {} ) ),
138 m_thermalConductivity( thermalConductivityAccessors.get( fields::thermalconductivity::effectiveConductivity {} ) ),
139 m_dThermalCond_dT( thermalConductivityAccessors.get( fields::thermalconductivity::dEffectiveConductivity_dT {} ) )
205 real64 const (&dFlux_dP)[2] )
209 real64 dDensMean_dT[2]{0.0, 0.0};
213 for(
integer ke = 0; ke < 2; ++ke )
216 dDensMean_dT[ke] = 0.5 * dDens_dT;
222 real64 dGravHead_dT[2]{0.0, 0.0};
225 for(
integer ke = 0; ke < 2; ++ke )
232 real64 const gravD = trans[ke] * m_gravCoef[er][esr][ei];
234 for(
integer i = 0; i < 2; ++i )
236 dGravHead_dT[i] += dDensMean_dT[i] * gravD;
243 real64 dFlux_dT[2]{0.0, 0.0};
246 for(
integer ke = 0; ke < 2; ++ke )
248 dFlux_dT[ke] -= dGravHead_dT[ke];
251 for(
integer ke = 0; ke < 2; ++ke )
253 dFlux_dT[ke] *= mobility;
258 if( alpha <= 0.0 || alpha >= 1.0 )
262 dMob_dT[k_up] =
m_dMob_dTemp[seri[k_up]][sesri[k_up]][sei[k_up]];
266 real64 const mobWeights[2] = { alpha, 1.0 - alpha };
267 for(
integer ke = 0; ke < 2; ++ke )
269 dMob_dT[ke] = mobWeights[ke] *
m_dMob_dTemp[seri[ke]][sesri[ke]][sei[ke]];
274 for(
integer ke = 0; ke < 2; ++ke )
276 dFlux_dT[ke] += dMob_dT[ke] * potGrad;
280 for(
integer ke = 0; ke < 2; ++ke )
289 real64 dEnthalpy_dP[2]{0.0, 0.0};
290 real64 dEnthalpy_dT[2]{0.0, 0.0};
292 if( alpha <= 0.0 || alpha >= 1.0 )
296 enthalpy =
m_enthalpy[seri[k_up]][sesri[k_up]][sei[k_up]][0];
297 dEnthalpy_dP[k_up] = m_dEnthalpy_dPres[seri[k_up]][sesri[k_up]][sei[k_up]][0];
298 dEnthalpy_dT[k_up] = m_dEnthalpy_dTemp[seri[k_up]][sesri[k_up]][sei[k_up]][0];
302 real64 const mobWeights[2] = { alpha, 1.0 - alpha };
303 for(
integer ke = 0; ke < 2; ++ke )
305 enthalpy += mobWeights[ke] *
m_enthalpy[seri[ke]][sesri[ke]][sei[ke]][0];
306 dEnthalpy_dP[ke] = mobWeights[ke] * m_dEnthalpy_dPres[seri[ke]][sesri[ke]][sei[ke]][0];
307 dEnthalpy_dT[ke] = mobWeights[ke] * m_dEnthalpy_dTemp[seri[ke]][sesri[ke]][sei[ke]][0];
313 for(
integer ke = 0; ke < 2; ++ke )
319 for(
integer ke = 0; ke < 2; ++ke )
337 stack.thermalTransmissibility,
345 for( k[1] = k[0] + 1; k[1] < stack.
numFluxElems; ++k[1] )
347 real64 const thermalTrans[2] = { stack.thermalTransmissibility[connectionIndex][0], stack.thermalTransmissibility[connectionIndex][1] };
351 localIndex const sesri[2] = {m_sesri( iconn, k[0] ), m_sesri( iconn, k[1] )};
352 localIndex const sei[2] = {m_sei( iconn, k[0] ), m_sei( iconn, k[1] )};
355 for(
integer ke = 0; ke < 2; ++ke )
369 for(
integer ke = 0; ke < 2; ++ke )
374 integer const localDofIndexTemp = localDofIndexPres +
numDof - 1;
454 template<
typename POLICY,
typename STENCILWRAPPER >
457 string const & dofKey,
458 string const & solverName,
460 STENCILWRAPPER
const & stencilWrapper,
470 dofNumberAccessor.setName( solverName +
"/accessors/" + dofKey );
473 typename KernelType::SinglePhaseFlowAccessors flowAccessors( elemManager, solverName );
474 typename KernelType::ThermalSinglePhaseFlowAccessors thermalFlowAccessors( elemManager, solverName );
475 typename KernelType::SinglePhaseFluidAccessors fluidAccessors( elemManager, solverName );
476 typename KernelType::ThermalSinglePhaseFluidAccessors thermalFluidAccessors( elemManager, solverName );
477 typename KernelType::PermeabilityAccessors permAccessors( elemManager, solverName );
478 typename KernelType::ThermalConductivityAccessors thermalConductivityAccessors( elemManager, solverName );
480 KernelType kernel( rankOffset, stencilWrapper, dofNumberAccessor,
481 flowAccessors, thermalFlowAccessors, fluidAccessors, thermalFluidAccessors,
482 permAccessors, thermalConductivityAccessors,
483 dt, localMatrix, localRhs );
484 KernelType::template launch< POLICY >( stencilWrapper.size(), kernel );
#define GEOS_HOST_DEVICE
Marks a host-device function.
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...
A struct to automatically construct and store element view accessors.
A struct to automatically construct and store element view accessors.
Base class for FluxComputeKernel that holds all data not dependent on template parameters (like stenc...
ElementViewConst< arrayView1d< real64 const > > const m_mob
Views on fluid mobility.
ElementViewConst< arrayView1d< globalIndex const > > const m_dofNumber
Views on dof numbers.
real64 const m_dt
Time step size.
arrayView1d< real64 > const m_localRhs
View on the local RHS.
ElementViewConst< arrayView2d< real64 const > > const m_dens
Views on fluid density.
globalIndex const m_rankOffset
Offset for my MPI rank.
CRSMatrixView< real64, globalIndex const > const m_localMatrix
View on the local CRS matrix.
Define the interface for the assembly kernel in charge of flux terms.
static constexpr integer numEqn
Compute time value for the number of equations.
static constexpr localIndex maxNumConns
Maximum number of connections at the face.
GEOS_HOST_DEVICE void complete(localIndex const iconn, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Performs the complete phase for the kernel.
static constexpr localIndex maxStencilSize
Maximum number of points in the stencil.
STENCILWRAPPER::IndexContainerViewConstType const m_seri
Connection to element maps.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
STENCILWRAPPER const m_stencilWrapper
Reference to the stencil wrapper.
GEOS_HOST_DEVICE void computeFlux(localIndex const iconn, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Compute the local flux contributions to the residual and Jacobian.
static constexpr localIndex maxNumElems
Maximum number of elements at the face.
static void createAndLaunch(globalIndex const rankOffset, string const &dofKey, string const &solverName, ElementRegionManager const &elemManager, STENCILWRAPPER const &stencilWrapper, 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 flux terms.
ElementViewConst< arrayView2d< real64 const > > const m_dDens_dTemp
Views on derivatives of fluid densities.
static constexpr integer numEqn
Compute time value for the number of equations.
ElementViewConst< arrayView1d< real64 const > > const m_temp
Views on temperature.
ElementViewConst< arrayView3d< real64 const > > m_dThermalCond_dT
View on derivatives of thermal conductivity w.r.t. temperature.
ElementViewConst< arrayView2d< real64 const > > const m_enthalpy
Views on enthalpies.
static constexpr localIndex maxNumConns
Maximum number of connections at the face.
STENCILWRAPPER::IndexContainerViewConstType const m_seri
Connection to element maps.
FluxComputeKernel(globalIndex const rankOffset, STENCILWRAPPER const &stencilWrapper, DofNumberAccessor const &dofNumberAccessor, SinglePhaseFlowAccessors const &singlePhaseFlowAccessors, ThermalSinglePhaseFlowAccessors const &thermalSinglePhaseFlowAccessors, SinglePhaseFluidAccessors const &singlePhaseFluidAccessors, ThermalSinglePhaseFluidAccessors const &thermalSinglePhaseFluidAccessors, PermeabilityAccessors const &permeabilityAccessors, ThermalConductivityAccessors const &thermalConductivityAccessors, real64 const &dt, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)
Constructor for the kernel interface.
real64 const m_dt
Time step size.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
ElementViewConst< arrayView1d< real64 const > > const m_dMob_dTemp
Views on derivatives of fluid mobilities.
GEOS_HOST_DEVICE void complete(localIndex const iconn, StackVariables &stack) const
Performs the complete phase for the kernel.
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 > > m_thermalConductivity
View on thermal conductivity.
STENCILWRAPPER const m_stencilWrapper
Reference to the stencil wrapper.
ElementRegionManager::ElementViewConst< VIEWTYPE > ElementViewConst
The type for element-based data. Consists entirely of ArrayView's.
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).
StackArray< T, 1, MAXSIZE > stackArray1d
Alias for 1D stack array.
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
std::int32_t integer
Signed integer type.
Kernel variables (dof numbers, jacobian and residual) located on the stack.
real64 dTrans_dPres[maxNumConns][2]
Derivatives of transmissibility with respect to pressure.
real64 transmissibility[maxNumConns][2]
Transmissibility.
stackArray1d< globalIndex, maxNumElems *numDof > dofColIndices
Indices of the matrix rows/columns corresponding to the dofs in this face.
stackArray1d< real64, maxNumElems *numEqn > localFlux
Storage for the face local residual vector (all equations except volume balance)
localIndex const stencilSize
Stencil size for a given connection.
stackArray2d< real64, maxNumElems *numEqn *maxStencilSize *numDof > localFluxJacobian
Storage for the face local Jacobian matrix.
localIndex const numFluxElems
Number of elements for a given connection.
stackArray1d< real64, maxStencilSize > dEnergyFlux_dP
Derivatives of energy fluxes wrt pressure.
real64 dThermalTrans_dT[maxNumConns][2]
Derivatives of thermal transmissibility with respect to temperature.
real64 energyFlux
Energy fluxes.
stackArray1d< real64, maxStencilSize > dEnergyFlux_dT
Derivatives of energy fluxes wrt temperature.