GEOS
SolutionScalingAndCheckingKernelBase.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_SOLUTIONSCALINGANDCHECKINGKERNELBASE_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_SOLUTIONSCALINGANDCHECKINGKERNELBASE_HPP
22 
23 #include "common/DataLayouts.hpp"
24 #include "common/DataTypes.hpp"
25 #include "common/GEOS_RAJA_Interface.hpp"
27 
28 namespace geos
29 {
30 
31 namespace isothermalCompositionalMultiphaseBaseKernels
32 {
33 
39 template< typename TYPE >
41 {
42 public:
43 
57  integer const numComp,
58  string const dofKey,
59  ElementSubRegionBase const & subRegion,
60  arrayView1d< real64 const > const localSolution,
61  arrayView1d< real64 const > const pressure,
63  arrayView1d< real64 > pressureScalingFactor,
64  arrayView1d< real64 > compDensScalingFactor )
65  : m_rankOffset( rankOffset ),
66  m_numComp( numComp ),
67  m_dofNumber( subRegion.getReference< array1d< globalIndex > >( dofKey ) ),
68  m_ghostRank( subRegion.ghostRank() ),
69  m_localSolution( localSolution ),
70  m_pressure( pressure ), // not passed with fields::flow to be able to reuse this for wells
71  m_compDens( compDens ), // same here
72  m_pressureScalingFactor( pressureScalingFactor ),
73  m_compDensScalingFactor( compDensScalingFactor )
74  { }
75 
82  {
85  { }
86 
87  StackVariables( real64 _localMinVal )
88  :
89  localRow( -1 ),
90  localMinVal( _localMinVal )
91  { }
92 
95 
98  };
99 
106  void setup( localIndex const ei,
107  StackVariables & stack ) const
108  {
109  stack.localMinVal = 1;
110 
111  // set row index and degrees of freedom indices for this element
112  stack.localRow = m_dofNumber[ei] - m_rankOffset;
113  }
114 
121  integer ghostRank( localIndex const i ) const
122  { return m_ghostRank( i ); }
123 
131  template< typename POLICY, typename KERNEL_TYPE >
132  static TYPE
133  launch( localIndex const numElems,
134  KERNEL_TYPE const & kernelComponent )
135  {
136  RAJA::ReduceMin< ReducePolicy< POLICY >, TYPE > minVal( 1 );
137  forAll< POLICY >( numElems, [=] GEOS_HOST_DEVICE ( localIndex const ei )
138  {
139  if( kernelComponent.ghostRank( ei ) >= 0 )
140  {
141  return;
142  }
143 
144  StackVariables stack;
145  kernelComponent.setup( ei, stack );
146  kernelComponent.compute( ei, stack );
147  minVal.min( stack.localMinVal );
148  } );
149 
150  return minVal.get();
151  }
152 
153 protected:
154 
157 
160 
163 
166 
169 
173 
176  arrayView1d< real64 > const m_compDensScalingFactor;
177 
178 };
179 
180 } // namespace isothermalCompositionalMultiphaseBaseKernels
181 
182 } // namespace geos
183 
184 
185 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONAL_SOLUTIONSCALINGANDCHECKINGKERNELBASE_HPP
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
GEOS_HOST_DEVICE integer ghostRank(localIndex const i) const
Getter for the ghost rank.
GEOS_HOST_DEVICE void setup(localIndex const ei, StackVariables &stack) const
Performs the setup phase for the kernel.
static TYPE launch(localIndex const numElems, KERNEL_TYPE const &kernelComponent)
Performs the kernel launch.
SolutionScalingAndCheckingKernelBase(globalIndex const rankOffset, integer const numComp, string const dofKey, ElementSubRegionBase const &subRegion, arrayView1d< real64 const > const localSolution, arrayView1d< real64 const > const pressure, arrayView2d< real64 const, compflow::USD_COMP > const compDens, arrayView1d< real64 > pressureScalingFactor, arrayView1d< real64 > compDensScalingFactor)
Create a new kernel instance.
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
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:175