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;
66 using AbstractBase::m_dMob;
68 using AbstractBase::m_dDens;
86 fields::singlefluid::enthalpy,
87 fields::singlefluid::dEnthalpy >;
91 fields::thermalconductivity::effectiveConductivity,
92 fields::thermalconductivity::dEffectiveConductivity_dT >;
111 STENCILWRAPPER
const & stencilWrapper,
112 DofNumberAccessor
const & dofNumberAccessor,
125 singlePhaseFlowAccessors,
126 singlePhaseFluidAccessors,
127 permeabilityAccessors,
131 m_temp( thermalSinglePhaseFlowAccessors.get( fields::flow::temperature {} ) ),
132 m_enthalpy( thermalSinglePhaseFluidAccessors.get( fields::singlefluid::enthalpy {} ) ),
133 m_dEnthalpy( thermalSinglePhaseFluidAccessors.get( fields::singlefluid::dEnthalpy {} ) ),
134 m_thermalConductivity( thermalConductivityAccessors.get( fields::thermalconductivity::effectiveConductivity {} ) ),
135 m_dThermalCond_dT( thermalConductivityAccessors.get( fields::thermalconductivity::dEffectiveConductivity_dT {} ) )
184 using DerivOffset = constitutive::singlefluid::DerivativeOffsetC< 1 >;
202 real64 const (&dFlux_dP)[2] )
206 real64 dDensMean_dT[2]{0.0, 0.0};
210 for(
integer ke = 0; ke < 2; ++ke )
212 dDensMean_dT[ke] = 0.5 * m_dDens[seri[ke]][sesri[ke]][sei[ke]][0][DerivOffset::dT];
218 real64 dGravHead_dT[2]{0.0, 0.0};
221 for(
integer ke = 0; ke < 2; ++ke )
228 real64 const gravD = trans[ke] * m_gravCoef[er][esr][ei];
230 for(
integer i = 0; i < 2; ++i )
232 dGravHead_dT[i] += dDensMean_dT[i] * gravD;
239 real64 dFlux_dT[2]{0.0, 0.0};
242 for(
integer ke = 0; ke < 2; ++ke )
244 dFlux_dT[ke] -= dGravHead_dT[ke];
247 for(
integer ke = 0; ke < 2; ++ke )
249 dFlux_dT[ke] *= mobility;
254 if( alpha <= 0.0 || alpha >= 1.0 )
257 dMob_dT[k_up] = m_dMob[seri[k_up]][sesri[k_up]][sei[k_up]][DerivOffset::dT];
261 real64 const mobWeights[2] = { alpha, 1.0 - alpha };
262 for(
integer ke = 0; ke < 2; ++ke )
264 dMob_dT[ke] = mobWeights[ke] * m_dMob[seri[ke]][sesri[ke]][sei[ke]][DerivOffset::dT];
269 for(
integer ke = 0; ke < 2; ++ke )
271 dFlux_dT[ke] += dMob_dT[ke] * potGrad;
275 for(
integer ke = 0; ke < 2; ++ke )
284 real64 dEnthalpy_dP[2]{0.0, 0.0};
285 real64 dEnthalpy_dT[2]{0.0, 0.0};
287 if( alpha <= 0.0 || alpha >= 1.0 )
291 enthalpy =
m_enthalpy[seri[k_up]][sesri[k_up]][sei[k_up]][0];
292 dEnthalpy_dP[k_up] = m_dEnthalpy[seri[k_up]][sesri[k_up]][sei[k_up]][0][DerivOffset::dP];
293 dEnthalpy_dT[k_up] = m_dEnthalpy[seri[k_up]][sesri[k_up]][sei[k_up]][0][DerivOffset::dT];
297 real64 const mobWeights[2] = { alpha, 1.0 - alpha };
298 for(
integer ke = 0; ke < 2; ++ke )
300 enthalpy += mobWeights[ke] *
m_enthalpy[seri[ke]][sesri[ke]][sei[ke]][0];
301 dEnthalpy_dP[ke] = mobWeights[ke] * m_dEnthalpy[seri[ke]][sesri[ke]][sei[ke]][0][DerivOffset::dP];
302 dEnthalpy_dT[ke] = mobWeights[ke] * m_dEnthalpy[seri[ke]][sesri[ke]][sei[ke]][0][DerivOffset::dT];
308 for(
integer ke = 0; ke < 2; ++ke )
314 for(
integer ke = 0; ke < 2; ++ke )
332 stack.thermalTransmissibility,
340 for( k[1] = k[0] + 1; k[1] < stack.
numFluxElems; ++k[1] )
342 real64 const thermalTrans[2] = { stack.thermalTransmissibility[connectionIndex][0], stack.thermalTransmissibility[connectionIndex][1] };
346 localIndex const sesri[2] = {m_sesri( iconn, k[0] ), m_sesri( iconn, k[1] )};
347 localIndex const sei[2] = {m_sei( iconn, k[0] ), m_sei( iconn, k[1] )};
350 for(
integer ke = 0; ke < 2; ++ke )
364 for(
integer ke = 0; ke < 2; ++ke )
369 integer const localDofIndexTemp = localDofIndexPres +
numDof - 1;
442 template<
typename POLICY,
typename STENCILWRAPPER >
445 string const & dofKey,
446 string const & solverName,
448 STENCILWRAPPER
const & stencilWrapper,
458 dofNumberAccessor.setName( solverName +
"/accessors/" + dofKey );
461 typename KernelType::SinglePhaseFlowAccessors flowAccessors( elemManager, solverName );
462 typename KernelType::ThermalSinglePhaseFlowAccessors thermalFlowAccessors( elemManager, solverName );
463 typename KernelType::SinglePhaseFluidAccessors fluidAccessors( elemManager, solverName );
464 typename KernelType::ThermalSinglePhaseFluidAccessors thermalFluidAccessors( elemManager, solverName );
465 typename KernelType::PermeabilityAccessors permAccessors( elemManager, solverName );
466 typename KernelType::ThermalConductivityAccessors thermalConductivityAccessors( elemManager, solverName );
468 KernelType kernel( rankOffset, stencilWrapper, dofNumberAccessor,
469 flowAccessors, thermalFlowAccessors, fluidAccessors, thermalFluidAccessors,
470 permAccessors, thermalConductivityAccessors,
471 dt, localMatrix, localRhs );
472 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, constitutive::singlefluid::USD_FLUID > > 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.
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.
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.
ElementViewConst< arrayView2d< real64 const, constitutive::singlefluid::USD_FLUID > > const m_enthalpy
Views on enthalpies.
real64 const m_dt
Time step size.
static constexpr integer numDof
Compute time value for the number of degrees of freedom.
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.