Skip to content

Commit 1e1a3e6

Browse files
CusiniMklevzoffrrsettgast
authored
Remove R1Tensor (#1180)
* Removed Cross products. Fixed BoundedPlane, ThickPlane, ComputationalGeometry. Started removal of Dot from solvers and surfGenerators. * Clean up more R1Tensor uses. Get rid or realT. * A few more cleanups. * Remove most R1Tensor uses in flow solvers * surfaceGen r1Tensor operators * R1Tensor initialization in surfGen * removed R1Tensor use from all remaining solvers. * WIP change R1Tensor in EmbSurfSubregion * Templated functions on array_type in CompGeometry. * Add Simple Tensor type for input * Bugfix local var initialization Co-authored-by: Sergey Klevtsov <[email protected]> Co-authored-by: Randolph R. Settgast <[email protected]>
1 parent ecaa0f2 commit 1e1a3e6

File tree

103 files changed

+1853
-3679
lines changed

Some content is hidden

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

103 files changed

+1853
-3679
lines changed

.gitmodules

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
[submodule "src/coreComponents/LvArray"]
22
path = src/coreComponents/LvArray
3-
url = https://github.com/GEOSX/LvArray.git
3+
url = ../LvArray.git
44
[submodule "src/cmake/blt"]
55
path = src/cmake/blt
6-
url = https://github.com/LLNL/blt.git
6+
url = ../../LLNL/blt.git
77
[submodule "src/externalComponents/PVTPackage"]
88
path = src/externalComponents/PVTPackage
9-
url = https://github.com/GEOSX/PVTPackage.git
9+
url = ../PVTPackage.git
1010
[submodule "integratedTests"]
1111
path = integratedTests
12-
url = [email protected]:GEOSX/integratedTests.git
12+
url = ../integratedTests.git
1313
[submodule "src/externalComponents/PAMELA"]
1414
path = src/externalComponents/PAMELA
15-
url = https://github.com/GEOSX/PAMELA.git
15+
url = ../PAMELA.git
1616
shallow = true
1717
[submodule "src/coreComponents/fileIO/coupling/hdf5_interface"]
1818
path = src/coreComponents/fileIO/coupling/hdf5_interface
19-
url = https://github.com/GEOSX/hdf5_interface.git
19+
url = ../hdf5_interface.git
2020
[submodule "src/coreComponents/physicsSolvers/GEOSX_PTP"]
2121
path = src/coreComponents/physicsSolvers/GEOSX_PTP
22-
url = https://github.com/GEOSX/GEOSX_PTP.git
22+
url = ../GEOSX_PTP.git

src/coreComponents/codingUtilities/SFINAE_Macros.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
*/
1414

1515
/**
16-
* @file sfinae.hpp
16+
* @file SFINAE_Macros.hpp
1717
*/
1818

19-
#ifndef SRC_CODINGUTILITIES_SFINAE_HPP_
20-
#define SRC_CODINGUTILITIES_SFINAE_HPP_
19+
#ifndef GEOSX_CODINGUTILITIES_SFINAE_MACROS_HPP_
20+
#define GEOSX_CODINGUTILITIES_SFINAE_MACROS_HPP_
2121

2222
#include "LvArray/src/Macros.hpp"
2323
#include "LvArray/src/typeManipulation.hpp"
@@ -50,11 +50,13 @@
5050
IS_VALID_EXPRESSION( HasMemberFunction_ ## NAME, CLASS, \
5151
std::is_convertible< decltype( std::declval< CLASS >().NAME( __VA_ARGS__ ) ), RTYPE >::value )
5252

53+
5354
/**
5455
* @brief Macro that expands to a static constexpr bool templated on a type that is only true when
5556
* the type has a an alias @p NAME. The name of the boolean variable is HasAlias_ ## @p NAME.
5657
*/
5758
#define HAS_ALIAS( NAME ) \
5859
IS_VALID_EXPRESSION( HasAlias_ ## NAME, CLASS, !std::is_enum< typename CLASS::NAME >::value )
5960

60-
#endif /* SRC_CODINGUTILITIES_SFINAE_HPP_ */
61+
62+
#endif /* GEOSX_CODINGUTILITIES_SFINAE_MACROS_HPP_ */

src/coreComponents/codingUtilities/Utilities.hpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,11 @@
2020
#define GEOSX_CODINGUTILITIES_UTILITIES_H_
2121

2222
#include "common/DataTypes.hpp"
23+
#include "LvArray/src/limits.hpp"
2324

2425
namespace geosx
2526
{
2627

27-
/**
28-
* @brief GPU-friendly analogue of std::numeric_limits
29-
* @tparam T type of numeric value
30-
*/
31-
template< typename T >
32-
struct NumericTraits
33-
{
34-
static constexpr T min = std::numeric_limits< T >::lowest();
35-
static constexpr T max = std::numeric_limits< T >::max();
36-
static constexpr T eps = std::numeric_limits< T >::epsilon();
37-
};
38-
3928
/**
4029
* @brief Compare two real values with a tolerance.
4130
* @tparam type of real value
@@ -48,7 +37,7 @@ template< typename T >
4837
GEOSX_FORCE_INLINE GEOSX_HOST_DEVICE constexpr
4938
bool isEqual( T const val1, T const val2, T const relTol = 0.0 )
5039
{
51-
T const absTol = ( relTol > 10 * NumericTraits< T >::eps ) ? relTol * ( fabs( val1 ) + fabs( val2 ) ) * 0.5 : 0.0;
40+
T const absTol = ( relTol > 10 * LvArray::NumericLimits< T >::epsilon ) ? relTol * ( fabs( val1 ) + fabs( val2 ) ) * 0.5 : 0.0;
5241
return ( val2 - absTol ) <= val1 && val1 <= ( val2 + absTol );
5342
}
5443

@@ -61,7 +50,7 @@ bool isEqual( T const val1, T const val2, T const relTol = 0.0 )
6150
*/
6251
template< typename T >
6352
GEOSX_FORCE_INLINE GEOSX_HOST_DEVICE constexpr
64-
bool isZero( T const val, T const tol = NumericTraits< T >::eps )
53+
bool isZero( T const val, T const tol = LvArray::NumericLimits< T >::epsilon )
6554
{
6655
return -tol <= val && val <= tol;
6756
}

src/coreComponents/codingUtilities/tests/testGeosxTraits.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ TEST( testGeosxTraits, HasOperatorPlusEquals )
2828
{
2929
static_assert( HasOperatorPlusEquals< int >, "Should be true." );
3030
static_assert( HasOperatorPlusEquals< std::string >, "Should be true." );
31-
static_assert( HasOperatorPlusEquals< R1Tensor >, "Should be true." );
3231

3332
static_assert( !HasOperatorPlusEquals< int const >, "Should be false." );
3433
static_assert( !HasOperatorPlusEquals< std::vector< int > >, "Should be false." );
@@ -39,8 +38,6 @@ TEST( testGeosxTraits, HasOperatorPlusEquals2 )
3938
{
4039
static_assert( HasOperatorPlusEquals2< double, int >, "Should be true." );
4140
static_assert( HasOperatorPlusEquals2< double, int const >, "Should be true." );
42-
static_assert( HasOperatorPlusEquals2< R1Tensor, int >, "Should be true." );
43-
static_assert( HasOperatorPlusEquals2< R1Tensor, R1Tensor >, "Should be true." );
4441
static_assert( HasOperatorPlusEquals2< std::string, std::string >, "Should be true." );
4542

4643
static_assert( !HasOperatorPlusEquals2< double const, int >, "Should be false." );

src/coreComponents/codingUtilities/traits.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static constexpr bool HasMemberFunction_toView = LvArray::typeManipulation::HasM
101101
IS_VALID_EXPRESSION_2( CanStreamInto, SRC, DST, std::declval< SRC & >() >> std::declval< DST & >() );
102102

103103
/**
104-
* @brief Defines a static constexpr bool HasAlias_value_type< @p CLASS >
104+
* @brief Defines a static constexpr bool HasMemberType_value_type< @p CLASS >
105105
* that is true iff @p CLASS ::value_type is valid and not an enum.
106106
* @tparam CLASS The type to test.
107107
*/

src/coreComponents/common/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ set(common_headers
1313
TimingMacros.hpp
1414
Logger.hpp
1515
DataLayouts.hpp
16+
Tensor.hpp
1617
)
1718

1819
#

src/coreComponents/common/DataTypes.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
#include "common/GeosxMacros.hpp"
2828
#include "common/BufferAllocator.hpp"
2929
#include "common/DataLayouts.hpp"
30-
#include "Logger.hpp"
30+
#include "common/Tensor.hpp"
31+
#include "common/Logger.hpp"
3132
#include "LvArray/src/Macros.hpp"
3233
#include "LvArray/src/Array.hpp"
3334
#include "LvArray/src/ArrayOfArrays.hpp"
@@ -39,7 +40,6 @@
3940
#include "LvArray/src/StackBuffer.hpp"
4041
#include "LvArray/src/ChaiBuffer.hpp"
4142

42-
#include "math/TensorT/TensorT.h"
4343
#include "Path.hpp"
4444

4545
// TPL includes
@@ -189,6 +189,9 @@ using StackArray = LvArray::StackArray< T, NDIM, PERMUTATION, localIndex, MAXSIZ
189189
*/
190190
///@{
191191

192+
/// Alias for a local (stack-based) rank-1 tensor type
193+
using R1Tensor = Tensor< real64, 3 >;
194+
192195
/// Alias for 1D array.
193196
template< typename T >
194197
using array1d = Array< T, 1 >;

src/coreComponents/common/Logger.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
* @param EXP an expression that will be evaluated as a predicate
6767
* @param msg a message to log (any expression that can be stream inserted)
6868
*/
69+
#if defined(__CUDA_ARCH__)
70+
#define GEOSX_LOG_RANK_IF( EXP, msg )
71+
#else
6972
#define GEOSX_LOG_RANK_IF( EXP, msg ) \
7073
do { \
7174
if( EXP ) \
@@ -75,6 +78,7 @@
7578
*logger::internal::rankStream << oss.str() << std::endl; \
7679
} \
7780
} while( false )
81+
#endif
7882

7983
/**
8084
* @brief Log a message to the rank output stream.
@@ -93,7 +97,11 @@
9397
* @param EXP an expression that will be evaluated as a predicate
9498
* @param msg a message to log (any expression that can be stream inserted)
9599
*/
100+
#if defined(__CUDA_ARCH__)
101+
#define GEOSX_ERROR_IF( EXP, msg ) LVARRAY_ERROR_IF( EXP, msg )
102+
#else
96103
#define GEOSX_ERROR_IF( EXP, msg ) LVARRAY_ERROR_IF( EXP, "***** Rank " << ::geosx::logger::internal::rankString << ": " << msg )
104+
#endif
97105

98106
/**
99107
* @brief Raise a hard error and terminate the program.
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/*
2+
* ------------------------------------------------------------------------------------------------------------
3+
* SPDX-License-Identifier: LGPL-2.1-only
4+
*
5+
* Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6+
* Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7+
* Copyright (c) 2018-2020 Total, S.A
8+
* Copyright (c) 2019- GEOSX Contributors
9+
* All rights reserved
10+
*
11+
* See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12+
* ------------------------------------------------------------------------------------------------------------
13+
*/
14+
15+
#ifndef GEOSX_COMMON_TENSOR_HPP_
16+
#define GEOSX_COMMON_TENSOR_HPP_
17+
18+
#include "common/GeosxMacros.hpp"
19+
20+
namespace geosx
21+
{
22+
23+
/**
24+
* @brief Lightweight wrapper around a c-array
25+
* @tparam T data type
26+
* @tparam SIZE_TPARAM number of values
27+
*/
28+
template< typename T, int SIZE_TPARAM >
29+
class Tensor
30+
{
31+
public:
32+
33+
static_assert( SIZE_TPARAM > 0, "Tensor size must be a positive value" );
34+
35+
/// Alias for type template parameter
36+
using value_type = T;
37+
38+
/// Alias for size template parameter
39+
static constexpr int SIZE = SIZE_TPARAM;
40+
41+
/**
42+
* @brief Const element access.
43+
* @param i element index
44+
* @return const reference to the i-th element
45+
*/
46+
GEOSX_HOST_DEVICE
47+
GEOSX_FORCE_INLINE
48+
T const & operator[]( std::ptrdiff_t const i ) const
49+
{
50+
return data[i];
51+
}
52+
53+
/**
54+
* @brief Non-const element access.
55+
* @param i element index
56+
* @return reference to the i-th element
57+
*/
58+
GEOSX_HOST_DEVICE
59+
GEOSX_FORCE_INLINE
60+
T & operator[]( std::ptrdiff_t const i )
61+
{
62+
return data[i];
63+
}
64+
65+
/**
66+
* @brief Equality comparison operator.
67+
* @tparam U dummy parameter to enable SFINAE, do not provide explicitly
68+
* @param rhs the right-hand side value to compare to
69+
* @return true iff @code data[i] == rhs.data[i] @endcode
70+
* @note Version for floating point types that avoids direct equality comparison.
71+
*/
72+
template< typename U = T >
73+
GEOSX_HOST_DEVICE
74+
GEOSX_FORCE_INLINE
75+
std::enable_if_t< std::is_floating_point< U >::value, bool >
76+
operator==( Tensor< U, SIZE > const & rhs ) const
77+
{
78+
for( int i = 0; i < SIZE; ++i )
79+
{
80+
if( (data[i] > rhs.data[i]) || (data[i] < rhs.data[i]) )
81+
{
82+
return false;
83+
}
84+
}
85+
return true;
86+
}
87+
88+
/**
89+
* @brief Equality comparison operator.
90+
* @tparam U dummy parameter to enable SFINAE, do not provide explicitly
91+
* @param rhs the right-hand side value to compare to
92+
* @return true iff @code data[i] == rhs.data[i] @endcode
93+
* @note Version for all types except floating point.
94+
*/
95+
template< typename U = T >
96+
GEOSX_HOST_DEVICE
97+
GEOSX_FORCE_INLINE
98+
std::enable_if_t< !std::is_floating_point< U >::value, bool >
99+
operator==( Tensor< U, SIZE > const & rhs ) const
100+
{
101+
for( int i = 0; i < SIZE; ++i )
102+
{
103+
if( data[i] != rhs.data[i] )
104+
{
105+
return false;
106+
}
107+
}
108+
return true;
109+
}
110+
111+
/**
112+
* @brief Returns the size of the tensor
113+
* @param junk Unused
114+
* @return The value of the template parameter SIZE.
115+
*/
116+
GEOSX_HOST_DEVICE
117+
GEOSX_FORCE_INLINE
118+
constexpr int size( int junk ) const
119+
{
120+
GEOSX_UNUSED_VAR( junk )
121+
return SIZE;
122+
}
123+
124+
/// Underlying array
125+
T data[SIZE] = {};
126+
127+
private:
128+
129+
/**
130+
* @brief Stream insertion operator for Tensor.
131+
* @param os the output stream
132+
* @param t the tensor value
133+
* @return reference to @p os
134+
*/
135+
friend inline std::ostream & operator<<( std::ostream & os, Tensor< T, SIZE > const & t )
136+
{
137+
os << t.data[0];
138+
for( int i = 1; i < SIZE; ++i )
139+
{
140+
os << ',' << t.data[i];
141+
}
142+
return os;
143+
}
144+
};
145+
146+
}
147+
148+
#endif //GEOSX_COMMON_TENSOR_HPP_

0 commit comments

Comments
 (0)