Skip to content

Commit 510cd43

Browse files
committed
remove NDIMS from CArrayWrapper. Begin reorg of ParamData for variance between chemistry applicaitons
1 parent 916438d commit 510cd43

13 files changed

+225
-101
lines changed

src/common/CArrayWrapper.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
* @tparam NDIMS The number of dimensions of the array.
1717
* @tparam DIMS Parameter pack specifying the size of each dimension.
1818
*/
19-
template< typename T, int NDIMS, int ... DIMS >
19+
template< typename T, int ... DIMS >
2020
struct CArrayWrapper
2121
{
22+
static constexpr int ndims = sizeof...( DIMS );
2223
static_assert( false, "Unsupported number of dimensions" );
2324
};
2425

@@ -31,8 +32,9 @@ struct CArrayWrapper
3132
* @tparam DIM0 The size of the single dimension.
3233
*/
3334
template< typename T, int DIM0 >
34-
struct CArrayWrapper< T, 1, DIM0 >
35+
struct CArrayWrapper< T, DIM0 >
3536
{
37+
3638
/**
3739
* @brief Read/write access to an element by index.
3840
* @param dim The index (must be in range [0, DIM0)).
@@ -76,7 +78,7 @@ struct CArrayWrapper< T, 1, DIM0 >
7678
* @tparam DIM1 The size of the second dimension.
7779
*/
7880
template< typename T, int DIM0, int DIM1 >
79-
struct CArrayWrapper< T, 2, DIM0, DIM1 >
81+
struct CArrayWrapper< T, DIM0, DIM1 >
8082
{
8183
/**
8284
* @brief Read/write access to an element by 2D indices.
@@ -138,7 +140,7 @@ struct CArrayWrapper< T, 2, DIM0, DIM1 >
138140
* @tparam DIM2 The size of the third dimension.
139141
*/
140142
template< typename T, int DIM0, int DIM1, int DIM2 >
141-
struct CArrayWrapper< T, 3, DIM0, DIM1, DIM2 >
143+
struct CArrayWrapper< T, DIM0, DIM1, DIM2 >
142144
{
143145
/**
144146
* @brief Read/write access to an element by 3D indices.

src/common/macros.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
/// unused.
2121
#define HPCREACT_UNUSED_VAR( ... ) (void)( __VA_ARGS__ )
2222

23-
#endif // HPCREACT_MACROS_HPP
23+
#endif // HPCREACT_MACROS_HPP

src/common/macrosCleanup.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
#undef HPCREACT_GLOBAL
44
#undef HPCREACT_UNUSED_VAR
55
#undef UNDEFINE_PREPROCESSOR_VARS
6-
#undef HPCREACT_MACROS_HPP
6+
#undef HPCREACT_MACROS_HPP

src/reactions/ReactionsParameterData.hpp

Lines changed: 121 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,133 @@
44
namespace hpcReact
55
{
66

7-
template< typename REAL_TYPE,
8-
typename INT_TYPE,
9-
int NUM_PRIMARY_SPECIES,
10-
int NUM_SECONDARY_SPECIES >
11-
struct EquilibriumReactionsParameterData
12-
{
13-
using RealType = REAL_TYPE;
14-
using IntType = INT_TYPE;
157

16-
static constexpr INT_TYPE numPrimarySpecies = NUM_PRIMARY_SPECIES;
17-
static constexpr INT_TYPE numSecondarySpecies = NUM_SECONDARY_SPECIES;
8+
template< typename REAL_TYPE,
9+
typename INT_TYPE,
10+
int NUM_PRIMARY_SPECIES,
11+
int NUM_SECONDARY_SPECIES >
12+
struct EquilibriumReactionsParameterData
13+
{
14+
using RealType = REAL_TYPE;
15+
using IntType = INT_TYPE;
16+
17+
static constexpr IntType numPrimarySpecies = NUM_PRIMARY_SPECIES;
18+
static constexpr IntType numSecondarySpecies = NUM_SECONDARY_SPECIES;
19+
20+
RealType m_ionSizePrimary[numPrimarySpecies];
1821

19-
REAL_TYPE m_ionSizePrimary[numPrimarySpecies];
22+
RealType m_ionSizeSec[numSecondarySpecies];
2023

21-
REAL_TYPE m_ionSizeSec[numSecondarySpecies];
24+
IntType m_chargePrimary[numPrimarySpecies];
25+
IntType m_chargeSec[numSecondarySpecies];
2226

23-
INT_TYPE m_chargePrimary[numPrimarySpecies];
24-
INT_TYPE m_chargeSec[numSecondarySpecies];
27+
RealType m_DebyeHuckelA;
28+
RealType m_DebyeHuckelB;
29+
RealType m_WATEQBDot;
2530

26-
REAL_TYPE m_DebyeHuckelA;
27-
REAL_TYPE m_DebyeHuckelB;
28-
REAL_TYPE m_WATEQBDot;
31+
CArrayWrapper< RealType, numSecondarySpecies, numPrimarySpecies> m_StoichMatrix[numSecondarySpecies][numPrimarySpecies];
32+
RealType m_Log10EqConst[numSecondarySpecies];
33+
};
34+
35+
36+
37+
template< typename REAL_TYPE,
38+
typename INT_TYPE,
39+
int NUM_PRIMARY_SPECIES,
40+
int NUM_SECONDARY_SPECIES,
41+
int NUM_KINETIC_REACTIONS >
42+
struct KineticReactionsParameterData
43+
{
44+
using RealType = REAL_TYPE;
45+
using IntType = INT_TYPE;
2946

30-
REAL_TYPE m_stoichMatrix[numSecondarySpecies][numPrimarySpecies];
47+
static constexpr IntType numPrimarySpecies = NUM_PRIMARY_SPECIES;
48+
static constexpr IntType numSecondarySpecies = NUM_SECONDARY_SPECIES;
49+
static constexpr IntType numKineticReactions = NUM_KINETIC_REACTIONS;
3150

32-
};
51+
RealType m_ionSizePrimary[numPrimarySpecies];
3352

34-
template< typename REAL_TYPE,
35-
typename INT_TYPE,
36-
int NUM_PRIMARY_SPECIES,
37-
int NUM_SECONDARY_SPECIES,
38-
int NUM_KINETIC_REACTIONS >
39-
struct KineticReactionsParameterData : EquilibriumReactionsParameterData< REAL_TYPE, INT_TYPE, NUM_PRIMARY_SPECIES, NUM_SECONDARY_SPECIES >
53+
RealType m_ionSizeSec[numSecondarySpecies];
54+
55+
IntType m_chargePrimary[numPrimarySpecies];
56+
IntType m_chargeSec[numSecondarySpecies];
57+
58+
RealType m_DebyeHuckelA;
59+
RealType m_DebyeHuckelB;
60+
RealType m_WATEQBDot;
61+
62+
CArrayWrapper< RealType, numKineticReactions, numPrimarySpecies> m_StoichMatrix[numKineticReactions][numPrimarySpecies];
63+
RealType m_log10EqConst[numKineticReactions];
64+
65+
RealType m_reactionRateConstant[numKineticReactions];
66+
RealType m_specificSurfaceArea;
67+
};
68+
69+
70+
template< typename REAL_TYPE,
71+
typename INT_TYPE,
72+
int NUM_PRIMARY_SPECIES,
73+
int NUM_SECONDARY_SPECIES,
74+
int NUM_KINETIC_REACTIONS >
75+
struct ReactionsParameterData
76+
{
77+
using RealType = REAL_TYPE;
78+
using IntType = INT_TYPE;
79+
80+
static constexpr IntType numPrimarySpecies = NUM_PRIMARY_SPECIES;
81+
static constexpr IntType numSecondarySpecies = NUM_SECONDARY_SPECIES;
82+
static constexpr IntType numKineticReactions = NUM_KINETIC_REACTIONS;
83+
84+
RealType m_ionSizePrimary[numPrimarySpecies];
85+
86+
RealType m_ionSizeSec[numSecondarySpecies];
87+
88+
IntType m_chargePrimary[numPrimarySpecies];
89+
IntType m_chargeSec[numSecondarySpecies];
90+
91+
RealType m_DebyeHuckelA;
92+
RealType m_DebyeHuckelB;
93+
RealType m_WATEQBDot;
94+
95+
CArrayWrapper< RealType, numSecondarySpecies, numPrimarySpecies> m_eqStoichMatrix;
96+
RealType m_eqLog10EqConst[numSecondarySpecies];
97+
98+
99+
CArrayWrapper< RealType, numKineticReactions, numPrimarySpecies > m_kineticStoichMatrix;
100+
RealType m_kineticlog10EqConst[numKineticReactions];
101+
102+
RealType m_kineticReactionRateConstant[numKineticReactions];
103+
RealType m_kineticSpecificSurfaceArea;
104+
105+
template< int ... PRIMARY_SPECIES,
106+
int ... SECONDARY_SPECIES,
107+
int ... SPECIES_PERMUTATIONS >
108+
constexpr EquilibriumReactionsParameterData< REAL_TYPE, INT_TYPE, NUM_PRIMARY_SPECIES, NUM_SECONDARY_SPECIES >
109+
equilibriumReactionsParams_impl( std::integer_sequence< int, PRIMARY_SPECIES... >,
110+
std::integer_sequence< int, SECONDARY_SPECIES... >,
111+
std::integer_sequence< int, SPECIES_PERMUTATIONS... > )
40112
{
41-
using Base = EquilibriumReactionsParameterData<REAL_TYPE, INT_TYPE, NUM_PRIMARY_SPECIES, NUM_SECONDARY_SPECIES >;
42-
using Base::numPrimarySpecies;
43-
using Base::numSecondarySpecies;
44-
45-
static constexpr INT_TYPE numKineticReactions = NUM_KINETIC_REACTIONS;
46-
47-
using Base::m_ionSizePrimary;
48-
using Base::m_ionSizeSec;
49-
using Base::m_chargePrimary;
50-
using Base::m_chargeSec;
51-
using Base::m_DebyeHuckelA;
52-
using Base::m_DebyeHuckelB;
53-
using Base::m_WATEQBDot;
54-
using Base::m_stoichMatrix;
55-
56-
REAL_TYPE m_reactionRateConstant[NUM_KINETIC_REACTIONS];
57-
REAL_TYPE m_specificSurfaceArea;
58-
};
59-
60-
}
113+
return EquilibriumReactionsParameterData< REAL_TYPE, INT_TYPE, NUM_PRIMARY_SPECIES, NUM_SECONDARY_SPECIES >{
114+
{m_ionSizePrimary[ PRIMARY_SPECIES ]...},
115+
{m_ionSizeSec[ SECONDARY_SPECIES ]...},
116+
{m_chargePrimary[ PRIMARY_SPECIES ]...},
117+
{m_chargeSec[ SECONDARY_SPECIES ]...},
118+
m_DebyeHuckelA,
119+
m_DebyeHuckelB,
120+
m_WATEQBDot,
121+
m_eqStoichMatrix,
122+
{m_eqLog10EqConst[ SECONDARY_SPECIES ]...}
123+
};
124+
}
125+
126+
constexpr EquilibriumReactionsParameterData< REAL_TYPE, INT_TYPE, NUM_PRIMARY_SPECIES, NUM_SECONDARY_SPECIES >
127+
equilibriumReactions()
128+
{
129+
return equilibriumReactionsParams_impl( std::make_integer_sequence< int, NUM_PRIMARY_SPECIES >{},
130+
std::make_integer_sequence< int, NUM_SECONDARY_SPECIES >{},
131+
std::make_integer_sequence< int, NUM_PRIMARY_SPECIES*NUM_SECONDARY_SPECIES >{} );
132+
}
133+
};
134+
135+
136+
}

src/reactions/ReactionsParameterDataPredefined.hpp

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,54 @@
55
namespace hpcReact
66
{
77

8-
constexpr
9-
EquilibriumReactionsParameterData< double, int, 7, 11 > chemicalReactionsParams =
10-
{ { 9.00, 4.00, 6.00, 4.00, 3.00, 8.00, 4.00 },
11-
{ 3.50, 3.00, 4.50, 3.00, 4.00, 3.00, 3.00, 4.00, 3.00, 3.00, 4.00 },
12-
{ 1, -1, 2, -2, -1, 2, 1 },
13-
{ -1, 0, -2, 0, 1, 0, 0, 1, 0, 0, -1},
14-
0.5465,
15-
0.3346,
16-
0.0438,
17-
{ { -1, 0, 0, 0, 0, 0, 0 },
18-
{ 1, 1, 0, 0, 0, 0, 0 },
19-
{ -1, 1, 0, 0, 0, 0, 0 },
20-
{ 1, 1, 0, 0, 0, 0, 0 },
21-
{ 0, 1, 1, 0, 0, 0, 0 },
22-
{ -1, 1, 1, 0, 0, 0, 0 },
23-
{ 0, 0, 1, 1, 0, 0, 0 },
24-
{ 0, 0, 1, 1, 0, 0, 0 },
25-
{ 0, 0, 1, 0, 2, 0, 0 },
26-
{ 0, 0, 0, 1, 0, 1, 0 },
27-
{ 0, 0, 0, 1, 0, 0, 1 }
28-
}
29-
};
8+
9+
constexpr
10+
ReactionsParameterData< double, int, 7, 11, 2 > chemicalReactionsParams =
11+
{
12+
// m_ionSizePrimary
13+
{ 9.00, 4.00, 6.00, 4.00, 3.00, 8.00, 4.00 },
14+
// m_ionSizeSec
15+
{ 3.50, 3.00, 4.50, 3.00, 4.00, 3.00, 3.00, 4.00, 3.00, 3.00, 4.00 },
16+
// m_chargePrimary
17+
{ 1, -1, 2, -2, -1, 2, 1 },
18+
// m_chargeSec
19+
{ -1, 0, -2, 0, 1, 0, 0, 1, 0, 0, -1 },
20+
// m_DebyeHuckelA
21+
0.5465,
22+
// m_DebyeHuckelB
23+
0.3346,
24+
// m_WATEQBDot
25+
0.0438,
26+
// m_eqStoichMatrix
27+
// First index: 0 = OH-, 1 = CO2, 2 = CO3-2, 3 = H2CO3, 4 = CaHCO3+, 5 = CaCO3, 6 = CaSO4, 7 = CaCl+, 8 = CaCl2, 9 = MgSO4, 10 = NaSO4-
28+
// Second index: 0 = H+, 1 = HCO3-, 2 = Ca+2, 3 = SO4-2, 4 = Cl-, 5 = Mg+2, 6 = Na+1
29+
{ { { -1, 0, 0, 0, 0, 0, 0 },
30+
{ 1, 1, 0, 0, 0, 0, 0 },
31+
{ -1, 1, 0, 0, 0, 0, 0 },
32+
{ 1, 1, 0, 0, 0, 0, 0 },
33+
{ 0, 1, 1, 0, 0, 0, 0 },
34+
{ -1, 1, 1, 0, 0, 0, 0 },
35+
{ 0, 0, 1, 1, 0, 0, 0 },
36+
{ 0, 0, 1, 1, 0, 0, 0 },
37+
{ 0, 0, 1, 0, 2, 0, 0 },
38+
{ 0, 0, 0, 1, 0, 1, 0 },
39+
{ 0, 0, 0, 1, 0, 0, 1 } }
40+
},
41+
// m_eqLog10EqConst
42+
{ 13.99, -6.36, 10.33, -3.77, -1.09, 7.07, -2.16, 0.67, 0.60, -2.43, -0.82 },
43+
// m_kineticStoichMatrix
44+
// First index: 0 = Ca(OH)2 dissolution, 1 = CaCO3 dissolution
45+
// Second index: 0 = H+, 1 = HCO3-, 2 = Ca+2, 3 = SO4-2, 4 = Cl-, 5 = Mg+2, 6 = Na+1
46+
{ { { -2, 0, 1, 0, 0, 0, 0 },
47+
{ -1, 1, 1, 0, 0, 0, 0 } }
48+
},
49+
// m_kineticLog10EqConst
50+
{ 20.19, 1.32 },
51+
// m_reactionRateConstant
52+
{ 9.95e-1, 9.95e-3 },
53+
// m_specificSurfaceArea
54+
1.0
55+
};
3056

3157

32-
} // namespace hpcReact
58+
} // namespace hpcReact

src/reactions/geochemistry/EquilibriumReactions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ class EquilibriumReactions : public ReactionsBase< REAL_TYPE,
9999

100100
} // namespace hpcReact
101101

102-
#include "common/macrosCleanup.hpp"
102+
#include "common/macrosCleanup.hpp"

src/reactions/geochemistry/EquilibriumReactions_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,4 +327,4 @@ EquilibriumReactions< REAL_TYPE,
327327

328328
} // namespace hpcReact
329329

330-
#include "common/macrosCleanup.hpp"
330+
#include "common/macrosCleanup.hpp"

src/reactions/geochemistry/KineticReactions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ class KineticReactions : public ReactionsBase< REAL_TYPE,
4747

4848
} // namespace hpcReact
4949

50-
#include "common/macrosCleanup.hpp"
50+
#include "common/macrosCleanup.hpp"

src/reactions/geochemistry/KineticReactions_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ KineticReactions< REAL_TYPE,
6262

6363
} // namespace hpcReact
6464

65-
#include "common/macrosCleanup.hpp"
65+
#include "common/macrosCleanup.hpp"

src/reactions/geochemistry/ReactionsBase.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ class ReactionsBase
4646

4747
} // namespace hpcReact
4848

49-
#include "common/macrosCleanup.hpp"
49+
#include "common/macrosCleanup.hpp"

0 commit comments

Comments
 (0)