20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_RESIDUALNORMKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASE_RESIDUALNORMKERNEL_HPP
28 namespace singlePhaseBaseKernels
51 real64 const minNormalizer )
57 m_mass_n( subRegion.template getField< fields::flow::mass_n >() )
62 LinfStackVariables & stack )
const override
66 if( valMass > stack.localValue[0] )
68 stack.localValue[0] = valMass;
74 L2StackVariables & stack )
const override
78 stack.localNormalizer[0] += massNormalizer;
107 real64 const minNormalizer )
113 m_mass_n( subRegion.template getField< fields::flow::mass_n >() ),
114 m_energy_n( subRegion.template getField< fields::flow::energy_n >() )
118 void computeMassEnergyNormalizers(
localIndex const ei,
120 real64 & energyNormalizer )
const
128 LinfStackVariables & stack )
const override
130 real64 massNormalizer = 0.0, energyNormalizer = 0.0;
131 computeMassEnergyNormalizers( ei, massNormalizer, energyNormalizer );
136 if( valMass > stack.localValue[0] )
138 stack.localValue[0] = valMass;
142 real64 const valEnergy = LvArray::math::abs(
m_localResidual[stack.localRow + 1] ) / energyNormalizer;
143 if( valEnergy > stack.localValue[1] )
145 stack.localValue[1] = valEnergy;
151 L2StackVariables & stack )
const override
153 real64 massNormalizer = 0.0, energyNormalizer = 0.0;
154 computeMassEnergyNormalizers( ei, massNormalizer, energyNormalizer );
159 stack.localNormalizer[0] += massNormalizer;
164 stack.localNormalizer[1] += energyNormalizer;
198 template<
typename POLICY >
205 real64 const minNormalizer,
206 real64 (& residualNorm)[1],
207 real64 (& residualNormalizer)[1] )
213 if( normType == physicsSolverBaseKernels::NormType::Linf )
215 IsothermalResidualNormKernel::launchLinf< POLICY >( subRegion.
size(), kernel, residualNorm );
219 IsothermalResidualNormKernel::launchL2< POLICY >( subRegion.
size(), kernel, residualNorm, residualNormalizer );
237 template<
typename POLICY >
241 string const & dofKey,
244 real64 const minNormalizer,
245 real64 (& residualNorm)[2],
246 real64 (& residualNormalizer)[2] )
252 if( normType == physicsSolverBaseKernels::NormType::Linf )
254 ThermalResidualNormKernel::launchLinf< POLICY >( subRegion.
size(), kernel, residualNorm );
258 ThermalResidualNormKernel::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.
array1d< integer > const & ghostRank()
Get the ghost information of each object.
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.
arrayView1d< globalIndex const > const m_dofNumber
View on the dof numbers.
GEOS_HOST_DEVICE integer ghostRank(localIndex const i) const
Getter for the ghost rank.
globalIndex const m_rankOffset
Offset for my MPI rank.
arrayView1d< real64 const > const m_localResidual
View on the local residual.
virtual GEOS_HOST_DEVICE void computeLinf(localIndex const ei, LinfStackVariables &stack) const override
Compute the local values for the Linf norm.
arrayView1d< real64 const > const m_mass_n
View on mass at the previous converged time step.
virtual GEOS_HOST_DEVICE void computeL2(localIndex const ei, L2StackVariables &stack) const override
Compute the local values and normalizer for the L2 norm.
static void createAndLaunch(physicsSolverBaseKernels::NormType const normType, globalIndex const rankOffset, string const dofKey, arrayView1d< real64 const > const &localResidual, ElementSubRegionBase const &subRegion, real64 const minNormalizer, real64(&residualNorm)[1], real64(&residualNormalizer)[1])
Create a new kernel and launch (isothermal version)
static void createAndLaunch(physicsSolverBaseKernels::NormType const normType, globalIndex const rankOffset, string const &dofKey, arrayView1d< real64 const > const &localResidual, ElementSubRegionBase const &subRegion, real64 const minNormalizer, real64(&residualNorm)[2], real64(&residualNormalizer)[2])
Create a new kernel and launch (thermal version)
virtual GEOS_HOST_DEVICE void computeL2(localIndex const ei, L2StackVariables &stack) const override
Compute the local values and normalizer for the L2 norm.
arrayView1d< real64 const > const m_mass_n
View on mass 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.
arrayView1d< real64 const > const m_energy_n
View on energy at the previous converged time step.
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).
Array< T, 1 > array1d
Alias for 1D array.