20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALRESIDUALNORMKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALRESIDUALNORMKERNEL_HPP
28 namespace thermalCompositionalMultiphaseBaseKernels
41 using Base::m_minNormalizer;
42 using Base::m_rankOffset;
43 using Base::m_localResidual;
44 using Base::m_dofNumber;
53 constitutive::MultiFluidBase
const & fluid,
54 constitutive::CoupledSolidBase
const & solid,
55 constitutive::SolidInternalEnergy
const & solidInternalEnergy,
56 real64 const minNormalizer )
67 m_totalDens_n( fluid.totalDensity_n() ),
68 m_phaseDens_n( fluid.phaseDensity_n() ),
69 m_phaseInternalEnergy_n( fluid.phaseInternalEnergy_n() ),
74 void computeMassEnergyNormalizers(
localIndex const ei,
76 real64 & energyNormalizer )
const
83 energyNormalizer += m_phaseInternalEnergy_n[ei][0][ip] * m_phaseDens_n[ei][0][ip] *
m_phaseVolFrac_n[ei][ip] * poreVolume;
86 energyNormalizer = LvArray::math::max(
m_minNormalizer, LvArray::math::abs( energyNormalizer ) );
91 LinfStackVariables & stack )
const override
93 real64 massNormalizer = 0.0, energyNormalizer = 0.0;
94 computeMassEnergyNormalizers( ei, massNormalizer, energyNormalizer );
101 real64 const valMass = LvArray::math::abs(
m_localResidual[stack.localRow + idof] ) / massNormalizer;
102 if( valMass > stack.localValue[0] )
104 stack.localValue[0] = valMass;
111 if( valVol > stack.localValue[1] )
113 stack.localValue[1] = valVol;
119 if( valEnergy > stack.localValue[2] )
121 stack.localValue[2] = valEnergy;
127 L2StackVariables & stack )
const override
130 real64 massNormalizer = 0.0, energyNormalizer = 0.0;
131 computeMassEnergyNormalizers( ei, massNormalizer, energyNormalizer );
138 stack.localNormalizer[0] += massNormalizer;
145 stack.localValue[1] += valVol * valVol;
146 stack.localNormalizer[1] += massNormalizer;
151 stack.localNormalizer[2] += energyNormalizer;
202 template<
typename POLICY >
208 string const & dofKey,
211 constitutive::MultiFluidBase
const & fluid,
212 constitutive::CoupledSolidBase
const & solid,
213 constitutive::SolidInternalEnergy
const & solidInternalEnergy,
214 real64 const minNormalizer,
215 real64 (& residualNorm)[3],
216 real64 (& residualNormalizer)[3] )
222 numComps, numPhases, subRegion, fluid, solid, solidInternalEnergy, minNormalizer );
223 if( normType == physicsSolverBaseKernels::NormType::Linf )
225 ResidualNormKernel::launchLinf< POLICY >( subRegion.
size(), kernel, residualNorm );
229 ResidualNormKernel::launchL2< POLICY >( subRegion.
size(), kernel, residualNorm, residualNormalizer );
#define GEOS_HOST_DEVICE
Marks a host-device function.
NormType
Type of norm used to check convergence TODO: find a way to put this inside the class.
arrayView1d< real64 const > getElementVolume() const
Get the volume of each element in this subregion.
array1d< integer > const & ghostRank()
Get the ghost information of each object.
GEOS_DECLTYPE_AUTO_RETURN getField() const
Get a view to the field associated with a trait from this ObjectManagerBase.
GEOS_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
Define the base interface for the residual calculations.
real64 const m_minNormalizer
Value used to make sure that normalizers are never zero.
GEOS_HOST_DEVICE integer ghostRank(localIndex const i) const
Getter for the ghost rank.
arrayView1d< real64 const > const m_localResidual
View on the local residual.
static void createAndLaunch(physicsSolverBaseKernels::NormType const normType, integer const numComps, integer const numPhases, globalIndex const rankOffset, string const &dofKey, arrayView1d< real64 const > const &localResidual, ElementSubRegionBase const &subRegion, constitutive::MultiFluidBase const &fluid, constitutive::CoupledSolidBase const &solid, constitutive::SolidInternalEnergy const &solidInternalEnergy, real64 const minNormalizer, real64(&residualNorm)[3], real64(&residualNormalizer)[3])
Create a new kernel and launch.
arrayView1d< real64 const > const m_volume
View on the volume.
arrayView2d< real64 const > const m_solidInternalEnergy_n
View on solid properties at the previous converged time step.
arrayView2d< real64 const, compflow::USD_PHASE > const m_phaseVolFrac_n
View on phase properties at the previous converged time step.
arrayView2d< real64 const > const m_porosity_n
View on porosity at the previous converged time step.
virtual GEOS_HOST_DEVICE void computeLinf(localIndex const ei, LinfStackVariables &stack) const override
Compute the local values for the Linf norm.
integer const m_numPhases
Number of fluid phases.
integer const m_numComponents
Number of fluid components.
virtual GEOS_HOST_DEVICE void computeL2(localIndex const ei, L2StackVariables &stack) const override
Compute the local values and normalizer for the L2 norm.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
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.
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Array< T, 1 > array1d
Alias for 1D array.
ArrayView< T, 3, USD > arrayView3d
Alias for 3D array view.