GEOS
CompositionalMultiphaseUtilities.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_COMPOSITIONALMULTIPHASEUTILITIES_H_
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONALMULTIPHASEUTILITIES_H_
22 
23 #include "common/DataTypes.hpp"
24 
25 namespace geos
26 {
27 
32 {
39 };
40 
45  "ArithmeticAverage",
46  "PhasePresence" );
47 
48 namespace compositionalMultiphaseUtilities
49 {
50 
54 enum class ScalingType : integer
55 {
56  Global,
57  Local
58 };
59 
60 ENUM_STRINGS( ScalingType,
61  "Global",
62  "Local" );
63 
94 template< typename VEC >
97  integer const numRowsInBlock,
98  integer const numBlocks,
99  VEC && v )
100 {
101  for( integer i = 0; i < numBlocks; ++i )
102  {
103  integer const ind = i * numRowsInBlock + numRowsToShift - 1;
104  real64 tmp = v[ind];
105  for( int j = ind - 1; j >= i * numRowsInBlock; --j )
106  {
107  v[j+1] = v[j];
108  tmp += v[j];
109  }
110  v[i*numRowsInBlock] = tmp;
111  }
112 }
113 
122 template< typename VEC >
125  VEC && v )
126 {
128 }
129 
167 template< typename MATRIX, typename VEC >
170  integer const numRowsInBlock,
171  integer const numColsInBlock,
172  integer const numBlocks,
173  MATRIX && mat,
174  VEC && work )
175 {
176  for( integer k = 0; k < numBlocks; ++k )
177  {
178  integer const ind = k * numRowsInBlock + numRowsToShift - 1;
179  for( integer j = 0; j < numColsInBlock; ++j )
180  {
181  work[j] = mat[ind][j];
182  }
183  for( integer i = ind - 1; i >= k * numRowsInBlock; --i )
184  {
185  for( integer j = 0; j < numColsInBlock; ++j )
186  {
187  mat[i+1][j] = mat[i][j];
188  work[j] += mat[i][j];
189  }
190  }
191  for( integer j = 0; j < numColsInBlock; ++j )
192  {
193  mat[k*numRowsInBlock][j] = work[j];
194  }
195  }
196 }
197 
210 template< typename MATRIX, typename VEC >
213  integer const numColsInBlock,
214  MATRIX && mat,
215  VEC && work )
216 {
217  shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( numRowsInBlock, numRowsInBlock, numColsInBlock, 1, mat, work );
218 }
219 
220 } // namespace compositionalMultiphaseUtilities
221 
222 } // namespace geos
223 
224 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONALMULTIPHASEUTILITIES_HPP_
GEOS_HOST_DEVICE void shiftRowsAheadByOneAndReplaceFirstRowWithColumnSum(integer const numRowsInBlock, integer const numColsInBlock, MATRIX &&mat, VEC &&work)
Shifts all rows one position ahead and replaces the first row with the sum of all rows in the input b...
GEOS_HOST_DEVICE void shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum(integer const numRowsToShift, integer const numRowsInBlock, integer const numColsInBlock, integer const numBlocks, MATRIX &&mat, VEC &&work)
In each block, shift the elements from 0 to numRowsToShift-1, shifts all rows one position ahead and ...
GEOS_HOST_DEVICE void shiftElementsAheadByOneAndReplaceFirstElementWithSum(integer const numRows, VEC &&v)
Shifts all elements one position ahead and replaces the first element with the sum of all elements in...
GEOS_HOST_DEVICE void shiftBlockElementsAheadByOneAndReplaceFirstElementWithSum(integer const numRowsToShift, integer const numRowsInBlock, integer const numBlocks, VEC &&v)
In each block, shift the elements from 0 to numRowsToShift-1 one position ahead and replaces the firs...
ScalingType
Solution scaling type, used in CompositionalMultiphaseFVM.
@ Global
Scale the Newton update with a unique scaling factor.
@ Local
Scale the Newton update locally (modifies the Newton direction)
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
ENUM_STRINGS(LinearSolverParameters::SolverType, "direct", "cg", "gmres", "fgmres", "bicgstab", "preconditioner")
Declare strings associated with enumeration values.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:81
GravityDensityScheme
Options for density treatment in gravity.