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 
81 template< typename VEC >
84  integer const numRowsInBlock,
85  integer const numBlocks,
86  VEC && v )
87 {
88  for( integer i = 0; i < numBlocks; ++i )
89  {
90  integer const ind = i * numRowsInBlock + numRowsToShift - 1;
91  real64 tmp = v[ind];
92  for( int j = ind - 1; j >= i * numRowsInBlock; --j )
93  {
94  v[j+1] = v[j];
95  tmp += v[j];
96  }
97  v[i*numRowsInBlock] = tmp;
98  }
99 }
100 
109 template< typename VEC >
112  VEC && v )
113 {
115 }
116 
154 template< typename MATRIX, typename VEC >
157  integer const numRowsInBlock,
158  integer const numColsInBlock,
159  integer const numBlocks,
160  MATRIX && mat,
161  VEC && work )
162 {
163 
164  for( integer k = 0; k < numBlocks; ++k )
165  {
166  integer const firstRow = k * numRowsInBlock;
167  integer const ind = firstRow + numRowsToShift - 1;
168  for( integer j = 0; j < numColsInBlock; ++j )
169  {
170  work[j] = mat[ind][j];
171  }
172  integer const numIters = numRowsToShift - 1;
173  for( integer step = 0; step < numIters; ++step )
174  {
175  integer const i = ind - step;
176 
177  for( integer j = 0; j < numColsInBlock; ++j )
178  {
179  mat[i][j] = mat[i-1][j];
180  work[j] += mat[i-1][j];
181  }
182  }
183  for( integer j = 0; j < numColsInBlock; ++j )
184  {
185  mat[firstRow][j] = work[j];
186  }
187  }
188 }
189 
202 template< typename MATRIX, typename VEC >
205  integer const numColsInBlock,
206  MATRIX && mat,
207  VEC && work )
208 {
209  shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( numRowsInBlock, numRowsInBlock, numColsInBlock, 1, mat, work );
210 }
211 
212 } // namespace compositionalMultiphaseUtilities
213 
214 } // namespace geos
215 
216 #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...
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
int integer
Signed integer type.
Definition: DataTypes.hpp:81
ENUM_STRINGS(LinearSolverParameters::SolverType, "direct", "cg", "gmres", "fgmres", "bicgstab", "richardson", "preconditioner")
Declare strings associated with enumeration values.
GravityDensityScheme
Options for density treatment in gravity.