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 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_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 
38 template< typename TYPE >
40 {
41 public:
42 
56  integer const numComp,
57  string const dofKey,
58  ElementSubRegionBase const & subRegion,
59  arrayView1d< real64 const > const localSolution,
60  arrayView1d< real64 const > const pressure,
62  arrayView1d< real64 > pressureScalingFactor,
63  arrayView1d< real64 > compDensScalingFactor )
64  : m_rankOffset( rankOffset ),
65  m_numComp( numComp ),
66  m_dofNumber( subRegion.getReference< array1d< globalIndex > >( dofKey ) ),
67  m_ghostRank( subRegion.ghostRank() ),
68  m_localSolution( localSolution ),
69  m_pressure( pressure ), // not passed with fields::flow to be able to reuse this for wells
70  m_compDens( compDens ), // same here
71  m_pressureScalingFactor( pressureScalingFactor ),
72  m_compDensScalingFactor( compDensScalingFactor )
73  { }
74 
80  {
83  { }
84 
85  StackVariables( real64 _localMinVal )
86  :
87  localMinVal( _localMinVal )
88  { }
89 
92 
95  };
96 
103  void setup( localIndex const ei,
104  StackVariables & stack ) const
105  {
106  stack.localMinVal = 1;
107 
108  // set row index and degrees of freedom indices for this element
109  stack.localRow = m_dofNumber[ei] - m_rankOffset;
110  }
111 
118  integer ghostRank( localIndex const i ) const
119  { return m_ghostRank( i ); }
120 
128  template< typename POLICY, typename KERNEL_TYPE >
129  static TYPE
130  launch( localIndex const numElems,
131  KERNEL_TYPE const & kernelComponent )
132  {
133  RAJA::ReduceMin< ReducePolicy< POLICY >, TYPE > minVal( 1 );
134  forAll< POLICY >( numElems, [=] GEOS_HOST_DEVICE ( localIndex const ei )
135  {
136  if( kernelComponent.ghostRank( ei ) >= 0 )
137  {
138  return;
139  }
140 
141  StackVariables stack;
142  kernelComponent.setup( ei, stack );
143  kernelComponent.compute( ei, stack );
144  minVal.min( stack.localMinVal );
145  } );
146 
147  return minVal.get();
148  }
149 
150 protected:
151 
154 
157 
160 
163 
166 
170 
173  arrayView1d< real64 > const m_compDensScalingFactor;
174 
175 };
176 
177 } // namespace isothermalCompositionalMultiphaseBaseKernels
178 
179 } // namespace geos
180 
181 
182 #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: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
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:176