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 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_COMPOSITIONALMULTIPHASEUTILITIES_H_
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_COMPOSITIONALMULTIPHASEUTILITIES_H_
22 
23 #include "common/DataTypes.hpp"
24 
25 namespace geos
26 {
27 
28 namespace compositionalMultiphaseUtilities
29 {
30 
61 template< typename VEC >
64  integer const numRowsInBlock,
65  integer const numBlocks,
66  VEC && v )
67 {
68  for( integer i = 0; i < numBlocks; ++i )
69  {
70  integer const ind = i * numRowsInBlock + numRowsToShift - 1;
71  real64 tmp = v[ind];
72  for( int j = ind - 1; j >= i * numRowsInBlock; --j )
73  {
74  v[j+1] = v[j];
75  tmp += v[j];
76  }
77  v[i*numRowsInBlock] = tmp;
78  }
79 }
80 
89 template< typename VEC >
92  VEC && v )
93 {
95 }
96 
134 template< typename MATRIX, typename VEC >
137  integer const numRowsInBlock,
138  integer const numColsInBlock,
139  integer const numBlocks,
140  MATRIX && mat,
141  VEC && work )
142 {
143  for( integer k = 0; k < numBlocks; ++k )
144  {
145  integer const ind = k * numRowsInBlock + numRowsToShift - 1;
146  for( integer j = 0; j < numColsInBlock; ++j )
147  {
148  work[j] = mat[ind][j];
149  }
150  for( integer i = ind - 1; i >= k * numRowsInBlock; --i )
151  {
152  for( integer j = 0; j < numColsInBlock; ++j )
153  {
154  mat[i+1][j] = mat[i][j];
155  work[j] += mat[i][j];
156  }
157  }
158  for( integer j = 0; j < numColsInBlock; ++j )
159  {
160  mat[k*numRowsInBlock][j] = work[j];
161  }
162  }
163 }
164 
177 template< typename MATRIX, typename VEC >
180  integer const numColsInBlock,
181  MATRIX && mat,
182  VEC && work )
183 {
184  shiftBlockRowsAheadByOneAndReplaceFirstRowWithColumnSum( numRowsInBlock, numRowsInBlock, numColsInBlock, 1, mat, work );
185 }
186 
187 } // namespace compositionalMultiphaseUtilities
188 
189 } // namespace geos
190 
191 #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:99
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82