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 TotalEnergies
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  ElementsReporterCollector const & negPressureIds,
77  ElementsReporterCollector const & negDensityIds,
78  ElementsReporterCollector const & negTotalDensityIds,
79  integer const temperatureOffset )
80  : Base( allowCompDensChopping,
81  allowNegativePressure,
82  scalingType,
83  scalingFactor,
84  pressure,
85  compDens,
86  pressureScalingFactor,
87  compDensScalingFactor,
88  rankOffset,
89  numComp,
90  dofKey,
91  subRegion,
92  localSolution,
93  negPressureIds,
94  negDensityIds,
95  negTotalDensityIds ),
96  m_temperature( temperature ),
97  m_temperatureScalingFactor( temperatureScalingFactor ),
98  m_temperatureOffset( temperatureOffset )
99  {}
100 
108  StackVariables & stack ) const
109  {
110  Base::computeSolutionCheck( ei, stack, [&] ()
111  {
112  bool const localScaling = m_scalingType == compositionalMultiphaseUtilities::ScalingType::Local;
113  // compute the change in temperature
114  real64 const newTemp = m_temperature[ei] + (localScaling ? m_temperatureScalingFactor[ei] : m_scalingFactor * m_localSolution[stack.localRow + m_temperatureOffset]);
115  if( newTemp < minTemperature )
116  {
117  stack.localMinVal = 0;
118  }
119  } );
120  }
121 
122 protected:
123 
126 
129 
132 
133 };
134 
139 {
140 public:
141 
154  template< typename POLICY >
156  createAndLaunch( integer const allowCompDensChopping,
157  integer const allowNegativePressure,
159  real64 const scalingFactor,
160  arrayView1d< real64 const > const pressure,
161  arrayView1d< real64 const > const temperature,
163  arrayView1d< real64 > pressureScalingFactor,
164  arrayView1d< real64 > temperatureScalingFactor,
165  arrayView1d< real64 > compDensScalingFactor,
166  globalIndex const rankOffset,
167  integer const numComp,
168  string const dofKey,
169  ElementSubRegionBase & subRegion,
170  arrayView1d< real64 const > const localSolution,
171  ElementsReporterCollector const & negPressureIds,
172  ElementsReporterCollector const & negDensityIds,
173  ElementsReporterCollector const & negTotalDensityIds,
174  integer temperatureOffset )
175  {
176  SolutionCheckKernel kernel( allowCompDensChopping, allowNegativePressure, scalingType, scalingFactor,
177  pressure, temperature, compDens, pressureScalingFactor, compDensScalingFactor,
178  temperatureScalingFactor, rankOffset, numComp, dofKey, subRegion, localSolution,
179  negPressureIds, negDensityIds, negTotalDensityIds, temperatureOffset );
180  return SolutionCheckKernel::launch< POLICY >( subRegion.size(), kernel );
181  }
182 
183 };
184 
185 } // namespace thermalCompositionalMultiphaseBaseKernels
186 
187 } // namespace geos
188 
189 
190 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_THERMALSOLUTIONCHECKKERNEL_HPP
ScalingType
Solution scaling type, used in CompositionalMultiphaseFVM.
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
Collects and reports elements ids and data using an atomic counter. This class provides functionality...
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.
compositionalMultiphaseUtilities::ScalingType const m_scalingType
scaling type (global or local)
static SolutionCheckKernel::KernelStats createAndLaunch(integer const allowCompDensChopping, integer const allowNegativePressure, compositionalMultiphaseUtilities::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, ElementsReporterCollector const &negPressureIds, ElementsReporterCollector const &negDensityIds, ElementsReporterCollector const &negTotalDensityIds, 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, compositionalMultiphaseUtilities::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, ElementsReporterCollector const &negPressureIds, ElementsReporterCollector const &negDensityIds, ElementsReporterCollector const &negTotalDensityIds, 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:179
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:87
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:195
int integer
Signed integer type.
Definition: DataTypes.hpp:81