GEOS
ThermalSolutionCheckKernel.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 Total, S.A
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALSOLUTIONCHECKKERNEL_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALSOLUTIONCHECKKERNEL_HPP
22 
24 
25 namespace geos
26 {
27 
28 namespace thermalCompositionalMultiphaseBaseKernels
29 {
30 
31 /******************************** SolutionCheckKernel ********************************/
32 
38 {
39 public:
40 
42  using Base::m_numComp;
45 
46  static real64 constexpr minTemperature = constants::zeroDegreesCelsiusInKelvin;
47 
61  SolutionCheckKernel( integer const allowCompDensChopping,
62  integer const allowNegativePressure,
64  real64 const scalingFactor,
65  arrayView1d< real64 const > const pressure,
66  arrayView1d< real64 const > const temperature,
68  arrayView1d< real64 > pressureScalingFactor,
69  arrayView1d< real64 > compDensScalingFactor,
70  arrayView1d< real64 > temperatureScalingFactor,
71  globalIndex const rankOffset,
72  integer const numComp,
73  string const dofKey,
74  ElementSubRegionBase const & subRegion,
75  arrayView1d< real64 const > const localSolution,
76  integer const temperatureOffset )
77  : Base( allowCompDensChopping,
78  allowNegativePressure,
79  scalingType,
80  scalingFactor,
81  pressure,
82  compDens,
83  pressureScalingFactor,
84  compDensScalingFactor,
85  rankOffset,
86  numComp,
87  dofKey,
88  subRegion,
89  localSolution ),
90  m_temperature( temperature ),
91  m_temperatureScalingFactor( temperatureScalingFactor ),
92  m_temperatureOffset( temperatureOffset )
93  {}
94 
102  StackVariables & stack ) const
103  {
104  Base::computeSolutionCheck( ei, stack, [&] ()
105  {
107  // compute the change in temperature
108  real64 const newTemp = m_temperature[ei] + (localScaling ? m_temperatureScalingFactor[ei] : m_scalingFactor * m_localSolution[stack.localRow + m_temperatureOffset]);
109  if( newTemp < minTemperature )
110  {
111  stack.localMinVal = 0;
112  }
113  } );
114  }
115 
116 protected:
117 
120 
123 
126 
127 };
128 
133 {
134 public:
135 
148  template< typename POLICY >
150  createAndLaunch( integer const allowCompDensChopping,
151  integer const allowNegativePressure,
152  CompositionalMultiphaseFVM::ScalingType const scalingType,
153  real64 const scalingFactor,
154  arrayView1d< real64 const > const pressure,
155  arrayView1d< real64 const > const temperature,
157  arrayView1d< real64 > pressureScalingFactor,
158  arrayView1d< real64 > temperatureScalingFactor,
159  arrayView1d< real64 > compDensScalingFactor,
160  globalIndex const rankOffset,
161  integer const numComp,
162  string const dofKey,
163  ElementSubRegionBase & subRegion,
164  arrayView1d< real64 const > const localSolution,
165  integer temperatureOffset )
166  {
167  SolutionCheckKernel kernel( allowCompDensChopping, allowNegativePressure, scalingType, scalingFactor,
168  pressure, temperature, compDens, pressureScalingFactor, compDensScalingFactor, temperatureScalingFactor,
169  rankOffset, numComp, dofKey, subRegion, localSolution,
170  temperatureOffset );
171  return SolutionCheckKernel::launch< POLICY >( subRegion.size(), kernel );
172  }
173 
174 };
175 
176 } // namespace thermalCompositionalMultiphaseBaseKernels
177 
178 } // namespace geos
179 
180 
181 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALSOLUTIONCHECKKERNEL_HPP
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
@ Local
Scale the Newton update locally (modifies the Newton direction)
localIndex size() const
Get the "size" of the group, which determines the number of elements in resizable wrappers.
Definition: Group.hpp:1315
GEOS_HOST_DEVICE void computeSolutionCheck(localIndex const ei, StackVariables &stack, FUNC &&kernelOp=NoOpFunc{}) const
Compute the local value of the check.
CompositionalMultiphaseFVM::ScalingType const m_scalingType
scaling type (global or local)
static SolutionCheckKernel::StackVariables createAndLaunch(integer const allowCompDensChopping, integer const allowNegativePressure, CompositionalMultiphaseFVM::ScalingType const scalingType, real64 const scalingFactor, arrayView1d< real64 const > const pressure, arrayView1d< real64 const > const temperature, arrayView2d< real64 const, compflow::USD_COMP > const compDens, arrayView1d< real64 > pressureScalingFactor, arrayView1d< real64 > temperatureScalingFactor, arrayView1d< real64 > compDensScalingFactor, globalIndex const rankOffset, integer const numComp, string const dofKey, ElementSubRegionBase &subRegion, arrayView1d< real64 const > const localSolution, integer temperatureOffset)
Create a new kernel and launch.
arrayView1d< real64 const > const m_temperatureScalingFactor
View on the scaling factor.
arrayView1d< real64 const > const m_temperature
View on the primary variables.
SolutionCheckKernel(integer const allowCompDensChopping, integer const allowNegativePressure, CompositionalMultiphaseFVM::ScalingType const scalingType, real64 const scalingFactor, arrayView1d< real64 const > const pressure, arrayView1d< real64 const > const temperature, arrayView2d< real64 const, compflow::USD_COMP > const compDens, arrayView1d< real64 > pressureScalingFactor, arrayView1d< real64 > compDensScalingFactor, arrayView1d< real64 > temperatureScalingFactor, globalIndex const rankOffset, integer const numComp, string const dofKey, ElementSubRegionBase const &subRegion, arrayView1d< real64 const > const localSolution, integer const temperatureOffset)
Create a new kernel instance.
GEOS_HOST_DEVICE void computeSolutionCheck(localIndex const ei, StackVariables &stack) const
Compute the local value of the solution check.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:180
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:88
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:196