Skip to content

Commit a167fdc

Browse files
committed
Linear algebra changes
1 parent 412ce5a commit a167fdc

80 files changed

Lines changed: 2484 additions & 942 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ vm:
77

88
env:
99
global:
10-
- GEOSX_TPL_TAG=220-932
10+
- GEOSX_TPL_TAG=196-933
1111
- secure: CGs2uH6efq1Me6xJWRr0BnwtwxoujzlowC4FHXHdWbNOkPsXf7nCgdaW5vthfD3bhnOeEUQSrfxdhTRtyU/NfcKLmKgGBnZOdUG4/JJK4gDSJ2Wp8LZ/mB0QEoODKVxbh+YtoAiHe3y4M9PGCs+wkNDw/3eEU00cK12DZ6gad0RbLjI3xkhEr/ZEZDZkcYg9yHAhl5bmpqoh/6QGnIg8mxIqdAtGDw+6tT0EgUqjeqc5bG5WwsamKzJItHSXD5zx8IJAlgDk4EzEGjZe0m56YnNfb9iwqqUsmL3Cuwgs7ByVDYw78JC5Kv42YqoxA5BxMT2mFsEe37TpYNXlzofU7ma2Duw9DGXWQd4IkTCcBxlyR0I0bfo0TmgO+y7PYG9lIyHPUkENemdozsZcWamqqkqegiEdRhDVYlSRo3mu7iCwTS6ZTALliVyEYjYxYb7oAnR3cNywXjblTCI8oKfgLSY+8WijM9SRl57JruIHLkLMCjmRI+cZBfv5tS2tYQTBPkygGrigrrN77ZiC7/TGyfggSN0+y0oYtOAgqEnBcKcreiibMW7tKcV2Z1RFD9ZvIkSc1EXLUPDP8FX1oyhmqBMqVo8LksrYLDJHQ05+F3YNgl2taSt7uMjQ4e8iZ3/IjFeMnbylDw+cj/RbS520HXsFPbWFm2Pb9pceA9n6GnY=
1212

1313
# The integrated test repository contains large data (using git lfs) and we do not use them here.

src/cmake/GeosxConfig.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function( make_full_config_file
6262
set( GEOSX_LA_INTERFACE_HYPRE ON )
6363
set( GEOSX_LA_INTERFACE_TRILINOS OFF )
6464
set( GEOSX_LA_INTERFACE_PETSC OFF )
65+
set( Python3_VERSION "3.10.8" )
6566

6667
configure_file( ${CMAKE_SOURCE_DIR}/coreComponents/common/GeosxConfig.hpp.in
6768
${CMAKE_SOURCE_DIR}/docs/doxygen/GeosxConfig.hpp )

src/coreComponents/codingUtilities/UnitTestUtilities.hpp

Lines changed: 28 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,11 @@ void checkRelativeError( real64 const v1, real64 const v2, real64 const relTol,
119119
EXPECT_PRED_FORMAT4( checkRelativeErrorFormat, v1, v2, relTol, absTol );
120120
}
121121

122-
template< typename ROW_INDEX, typename COL_INDEX, typename VALUE >
123-
void compareMatrixRow( ROW_INDEX const rowNumber, VALUE const relTol, VALUE const absTol,
122+
template< typename COL_INDEX, typename VALUE >
123+
void compareMatrixRow( VALUE const relTol, VALUE const absTol,
124124
localIndex const length1, COL_INDEX const * const indices1, VALUE const * const values1,
125125
localIndex const length2, COL_INDEX const * const indices2, VALUE const * const values2 )
126126
{
127-
SCOPED_TRACE( "Row " + std::to_string( rowNumber ));
128-
129127
EXPECT_EQ( length1, length2 );
130128

131129
for( localIndex j1 = 0, j2 = 0; j1 < length1 && j2 < length2; ++j1, ++j2 )
@@ -150,17 +148,31 @@ void compareMatrixRow( ROW_INDEX const rowNumber, VALUE const relTol, VALUE cons
150148
}
151149
}
152150

153-
template< typename ROW_INDEX, typename COL_INDEX, typename VALUE >
154-
void compareMatrixRow( ROW_INDEX const rowNumber, VALUE const relTol, VALUE const absTol,
155-
arraySlice1d< COL_INDEX const > indices1, arraySlice1d< VALUE const > values1,
156-
arraySlice1d< COL_INDEX const > indices2, arraySlice1d< VALUE const > values2 )
151+
template< typename T, typename COL_INDEX >
152+
void compareLocalMatrices( CRSMatrixView< T const, COL_INDEX const > const & matrix1,
153+
CRSMatrixView< T const, COL_INDEX const > const & matrix2,
154+
real64 const relTol = DEFAULT_REL_TOL,
155+
real64 const absTol = DEFAULT_ABS_TOL,
156+
globalIndex const rowOffset = 0 )
157157
{
158-
ASSERT_EQ( indices1.size(), values1.size() );
159-
ASSERT_EQ( indices2.size(), values2.size() );
158+
ASSERT_EQ( matrix1.numRows(), matrix2.numRows() );
159+
ASSERT_EQ( matrix1.numColumns(), matrix2.numColumns() );
160+
161+
matrix1.move( LvArray::MemorySpace::host, false );
162+
matrix2.move( LvArray::MemorySpace::host, false );
160163

161-
compareMatrixRow( rowNumber, relTol, absTol,
162-
indices1.size(), indices1.dataIfContiguous(), values1.dataIfContiguous(),
163-
indices2.size(), indices2.dataIfContiguous(), values2.dataIfContiguous() );
164+
// check the accuracy across local rows
165+
for( localIndex i = 0; i < matrix1.numRows(); ++i )
166+
{
167+
SCOPED_TRACE( GEOS_FMT( "Row {}", i + rowOffset ) );
168+
compareMatrixRow( relTol, absTol,
169+
matrix1.numNonZeros( i ),
170+
matrix1.getColumns( i ).dataIfContiguous(),
171+
matrix1.getEntries( i ).dataIfContiguous(),
172+
matrix2.numNonZeros( i ),
173+
matrix2.getColumns( i ).dataIfContiguous(),
174+
matrix2.getEntries( i ).dataIfContiguous() );
175+
}
164176
}
165177

166178
template< typename MATRIX >
@@ -175,45 +187,10 @@ void compareMatrices( MATRIX const & matrix1,
175187
ASSERT_EQ( matrix1.numLocalRows(), matrix2.numLocalRows() );
176188
ASSERT_EQ( matrix1.numLocalCols(), matrix2.numLocalCols() );
177189

178-
array1d< globalIndex > indices1, indices2;
179-
array1d< real64 > values1, values2;
180-
181-
// check the accuracy across local rows
182-
for( globalIndex i = matrix1.ilower(); i < matrix1.iupper(); ++i )
183-
{
184-
indices1.resize( matrix1.rowLength( i ) );
185-
values1.resize( matrix1.rowLength( i ) );
186-
matrix1.getRowCopy( i, indices1, values1 );
187-
188-
indices2.resize( matrix2.rowLength( i ) );
189-
values2.resize( matrix2.rowLength( i ) );
190-
matrix2.getRowCopy( i, indices2, values2 );
190+
CRSMatrix< real64, globalIndex > const mat1 = matrix1.extract();
191+
CRSMatrix< real64, globalIndex > const mat2 = matrix2.extract();
191192

192-
compareMatrixRow( i, relTol, absTol,
193-
indices1.size(), indices1.data(), values1.data(),
194-
indices2.size(), indices2.data(), values2.data() );
195-
}
196-
}
197-
198-
template< typename T, typename COL_INDEX >
199-
void compareLocalMatrices( CRSMatrixView< T const, COL_INDEX const > const & matrix1,
200-
CRSMatrixView< T const, COL_INDEX const > const & matrix2,
201-
real64 const relTol = DEFAULT_REL_TOL,
202-
real64 const absTol = DEFAULT_ABS_TOL )
203-
{
204-
ASSERT_EQ( matrix1.numRows(), matrix2.numRows() );
205-
ASSERT_EQ( matrix1.numColumns(), matrix2.numColumns() );
206-
207-
matrix1.move( LvArray::MemorySpace::host, false );
208-
matrix2.move( LvArray::MemorySpace::host, false );
209-
210-
// check the accuracy across local rows
211-
for( localIndex i = 0; i < matrix1.numRows(); ++i )
212-
{
213-
compareMatrixRow( i, relTol, absTol,
214-
matrix1.getColumns( i ), matrix1.getEntries( i ),
215-
matrix2.getColumns( i ), matrix2.getEntries( i ) );
216-
}
193+
compareLocalMatrices( mat1.toViewConst(), mat2.toViewConst(), relTol, absTol, matrix1.ilower() );
217194
}
218195

219196
} // namespace testing

src/coreComponents/common/DataTypes.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,12 @@ template< typename COL_INDEX, typename INDEX_TYPE=localIndex >
338338
using SparsityPatternView = LvArray::SparsityPatternView< COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer >;
339339

340340
/// Alias for CRS Matrix class.
341-
template< typename T, typename COL_INDEX=globalIndex >
342-
using CRSMatrix = LvArray::CRSMatrix< T, COL_INDEX, localIndex, LvArray::ChaiBuffer >;
341+
template< typename T, typename COL_INDEX=globalIndex, typename INDEX_TYPE=localIndex >
342+
using CRSMatrix = LvArray::CRSMatrix< T, COL_INDEX, INDEX_TYPE, LvArray::ChaiBuffer >;
343343

344344
/// Alias for CRS Matrix View.
345-
template< typename T, typename COL_INDEX=globalIndex >
346-
using CRSMatrixView = LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer >;
345+
template< typename T, typename COL_INDEX=globalIndex, typename INDEX_TYPE=localIndex >
346+
using CRSMatrixView = LvArray::CRSMatrixView< T, COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer >;
347347

348348
///@}
349349

src/coreComponents/common/GeosxConfig.hpp.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@
6565
/// Enables use of PETSc library (CMake option ENABLE_PETSC)
6666
#cmakedefine GEOSX_USE_PETSC
6767

68+
/// Enables use of METIS library (CMake option ENABLE_METIS)
69+
#cmakedefine GEOSX_USE_METIS
70+
71+
/// Enables use of ParMETIS library (CMake option ENABLE_PARMETIS)
72+
#cmakedefine GEOSX_USE_PARMETIS
73+
6874
/// Enables use of Scotch library (CMake option ENABLE_SCOTCH)
6975
#cmakedefine GEOSX_USE_SCOTCH
7076

src/coreComponents/common/MpiWrapper.hpp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "common/Span.hpp"
2323
#include "mesh/ElementType.hpp"
2424

25+
#include <numeric>
26+
2527
#if defined(GEOSX_USE_MPI)
2628
#include <mpi.h>
2729
#define MPI_PARAM( x ) x
@@ -337,6 +339,11 @@ struct MpiWrapper
337339
array1d< T > & recvbuf,
338340
MPI_Comm comm = MPI_COMM_GEOSX );
339341

342+
template< typename T >
343+
static int allGatherv( arrayView1d< T const > const & sendbuf,
344+
array1d< T > & recvbuf,
345+
MPI_Comm comm = MPI_COMM_GEOSX );
346+
340347
/**
341348
* @brief Strongly typed wrapper around MPI_Allreduce.
342349
* @param[in] sendbuf The pointer to the sending buffer.
@@ -459,6 +466,22 @@ struct MpiWrapper
459466
MPI_Comm comm,
460467
MPI_Request * request );
461468

469+
/**
470+
* @brief Strongly typed wrapper around MPI_Send()
471+
* @param[in] buf The pointer to the buffer that contains the data to be sent.
472+
* @param[in] count The number of elements in \p buf.
473+
* @param[in] dest The rank of the destination process within \p comm.
474+
* @param[in] tag The message tag that is be used to distinguish different types of messages.
475+
* @param[in] comm The handle to the MPI_Comm.
476+
* @return
477+
*/
478+
template< typename T >
479+
static int send( T const * const buf,
480+
int count,
481+
int dest,
482+
int tag,
483+
MPI_Comm comm );
484+
462485
/**
463486
* @brief Strongly typed wrapper around MPI_Isend()
464487
* @param[in] buf The pointer to the buffer that contains the data to be sent.
@@ -713,6 +736,38 @@ int MpiWrapper::allGather( arrayView1d< T const > const & sendValues,
713736
#endif
714737
}
715738

739+
template< typename T >
740+
int MpiWrapper::allGatherv( arrayView1d< T const > const & sendValues,
741+
array1d< T > & allValues,
742+
MPI_Comm MPI_PARAM( comm ) )
743+
{
744+
int const sendSize = LvArray::integerConversion< int >( sendValues.size() );
745+
#ifdef GEOSX_USE_MPI
746+
int const mpiSize = commSize( comm );
747+
array1d< int > counts;
748+
allGather( sendSize, counts, comm );
749+
array1d< int > displs( mpiSize + 1 );
750+
std::partial_sum( counts.begin(), counts.end(), displs.begin() + 1 );
751+
allValues.resize( displs.back() );
752+
return MPI_Allgatherv( sendValues.data(),
753+
sendSize,
754+
internal::getMpiType< T >(),
755+
allValues.data(),
756+
counts.data(),
757+
displs.data(),
758+
internal::getMpiType< T >(),
759+
comm );
760+
761+
#else
762+
allValues.resize( sendSize );
763+
for( localIndex a=0; a<sendSize; ++a )
764+
{
765+
allValues[a] = sendValues[a];
766+
}
767+
return 0;
768+
#endif
769+
}
770+
716771
template< typename T >
717772
int MpiWrapper::allReduce( T const * const sendbuf,
718773
T * const recvbuf,
@@ -928,6 +983,20 @@ int MpiWrapper::iSend( arrayView1d< T const > const & buf,
928983
#endif
929984
}
930985

986+
template< typename T >
987+
int MpiWrapper::send( T const * const buf,
988+
int count,
989+
int dest,
990+
int tag,
991+
MPI_Comm comm )
992+
{
993+
#ifdef GEOSX_USE_MPI
994+
return MPI_Send( buf, count, internal::getMpiType< T >(), dest, tag, comm );
995+
#else
996+
GEOS_ERROR( "Not implemented without MPI" );
997+
#endif
998+
}
999+
9311000
template< typename T >
9321001
int MpiWrapper::iSend( T const * const buf,
9331002
int count,

src/coreComponents/common/TimingMacros.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace timingHelpers
3434
{
3535
std::string input(prettyFunction);
3636
std::string::size_type const end = input.find_first_of( '(' );
37-
std::string::size_type const beg = input.find_last_of( ' ', end)+1;
37+
std::string::size_type const beg = input.find_last_of( ' ', end ) + 1;
3838
return input.substr( beg, end-beg );
3939
}
4040
}
@@ -95,10 +95,10 @@ namespace timingHelpers
9595
#include <iostream>
9696

9797
/// Mark a function or scope for timing with a given name
98-
#define GEOS_CALIPER_MARK_SCOPE(name) cali::Function __cali_ann##__LINE__(STRINGIZE_NX(name))
98+
#define GEOS_CALIPER_MARK_SCOPE(name) cali::Function GEOS_CONCAT(_cali_ann, __LINE__)(STRINGIZE_NX(name))
9999

100100
/// Mark a function for timing using a compiler-provided name
101-
#define GEOS_CALIPER_MARK_FUNCTION cali::Function __cali_ann##__func__(timingHelpers::stripPF(__PRETTY_FUNCTION__).c_str())
101+
#define GEOS_CALIPER_MARK_FUNCTION cali::Function _cali_ann_func(timingHelpers::stripPF(__PRETTY_FUNCTION__).c_str())
102102

103103
/// Mark the beginning of timed statement group
104104
#define GEOS_CALIPER_MARK_BEGIN(name) CALI_MARK_BEGIN(STRINGIZE(name))

src/coreComponents/linearAlgebra/CMakeLists.txt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ set( linearAlgebra_headers
2121
solvers/PreconditionerBlockJacobi.hpp
2222
solvers/PreconditionerIdentity.hpp
2323
solvers/PreconditionerJacobi.hpp
24+
solvers/PreconditionerNull.hpp
25+
solvers/RichardsonSolver.hpp
2426
solvers/SeparateComponentPreconditioner.hpp
2527
utilities/Arnoldi.hpp
2628
utilities/BlockOperator.hpp
@@ -48,6 +50,7 @@ set( linearAlgebra_sources
4850
solvers/CgSolver.cpp
4951
solvers/GmresSolver.cpp
5052
solvers/KrylovSolver.cpp
53+
solvers/RichardsonSolver.cpp
5154
solvers/SeparateComponentPreconditioner.cpp
5255
)
5356

@@ -105,19 +108,19 @@ if( ENABLE_HYPRE )
105108
interfaces/hypre/mgrStrategies/CompositionalMultiphaseReservoirHybridFVM.hpp
106109
interfaces/hypre/mgrStrategies/HybridSinglePhasePoromechanics.hpp
107110
interfaces/hypre/mgrStrategies/Hydrofracture.hpp
108-
interfaces/hypre/mgrStrategies/LagrangianContactMechanics.hpp
111+
interfaces/hypre/mgrStrategies/LagrangianContactMechanics.hpp
109112
interfaces/hypre/mgrStrategies/MultiphasePoromechanics.hpp
110113
interfaces/hypre/mgrStrategies/MultiphasePoromechanicsReservoirFVM.hpp
111-
interfaces/hypre/mgrStrategies/ReactiveCompositionalMultiphaseOBL.hpp
114+
interfaces/hypre/mgrStrategies/ReactiveCompositionalMultiphaseOBL.hpp
112115
interfaces/hypre/mgrStrategies/SinglePhaseHybridFVM.hpp
113116
interfaces/hypre/mgrStrategies/SinglePhasePoromechanics.hpp
114117
interfaces/hypre/mgrStrategies/SinglePhasePoromechanicsEmbeddedFractures.hpp
115-
interfaces/hypre/mgrStrategies/SinglePhasePoromechanicsReservoirFVM.hpp
118+
interfaces/hypre/mgrStrategies/SinglePhasePoromechanicsReservoirFVM.hpp
116119
interfaces/hypre/mgrStrategies/SinglePhaseReservoirFVM.hpp
117120
interfaces/hypre/mgrStrategies/SinglePhaseReservoirHybridFVM.hpp
118-
interfaces/hypre/mgrStrategies/ThermalCompositionalMultiphaseFVM.hpp
119-
interfaces/hypre/mgrStrategies/ThermalMultiphasePoromechanics.hpp
120-
interfaces/hypre/mgrStrategies/ThermalSinglePhasePoromechanics.hpp
121+
interfaces/hypre/mgrStrategies/ThermalCompositionalMultiphaseFVM.hpp
122+
interfaces/hypre/mgrStrategies/ThermalMultiphasePoromechanics.hpp
123+
interfaces/hypre/mgrStrategies/ThermalSinglePhasePoromechanics.hpp
121124
)
122125

123126
list( APPEND linearAlgebra_sources

0 commit comments

Comments
 (0)