Skip to content

Commit 59f2d30

Browse files
committed
doxygen and uncrustify
1 parent 6c8665e commit 59f2d30

File tree

6 files changed

+159
-44
lines changed

6 files changed

+159
-44
lines changed

cmake/Macros.cmake

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,16 @@ macro(hpcReact_add_code_checks)
4343
--suppress=constStatement
4444
--suppress=unusedStructMember )
4545

46-
blt_add_code_checks( PREFIX ${arg_PREFIX}
47-
SOURCES ${_sources}
48-
UNCRUSTIFY_CFG_FILE ${PROJECT_SOURCE_DIR}/src/uncrustify.cfg
49-
CPPCHECK_FLAGS ${CPPCHECK_FLAGS}
50-
)
46+
if( ENABLE_UNCRUSTIFY )
47+
blt_add_code_checks( PREFIX ${arg_PREFIX}
48+
SOURCES ${_sources}
49+
UNCRUSTIFY_CFG_FILE ${PROJECT_SOURCE_DIR}/src/uncrustify.cfg
50+
CPPCHECK_FLAGS ${CPPCHECK_FLAGS}
51+
)
52+
add_test( NAME testUncrustifyCheck
53+
COMMAND sh -c "${CMAKE_MAKE_PROGRAM} uncrustify_check 2> >(tee uncrustify.err) >/dev/null && exit $(cat uncrustify.err | wc -l)"
54+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )
55+
endif()
5156

5257
if( CPPCHECK_FOUND )
5358
add_test( NAME testCppCheck

src/common/symmetricMatrix.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
* @tparam T The type of the elements of the matrix.
1414
* @tparam INDEX_TYPE The type of the indices of the matrix.
1515
* @tparam N The size of the matrix.
16-
* @details
16+
* @details
1717
* The matrix is stored in a 1D array, where the elements are
18-
* stored in a compact way.
19-
*
18+
* stored in a compact way.
19+
*
2020
* The linear index is calculated using
2121
* the formula (i*(i+1))/2 + j, where i and j are the indices of
2222
* the matrix. This corrosponds to filling the lower triangular
2323
* part of the matrix row by row. So each row i has i+1 elements.
24-
*
24+
*
2525
* The size of the matrix is calculated using the
2626
* formula (N*(N+1))/2, where N is the size of the matrix.
2727
*/
@@ -30,13 +30,17 @@ struct symmetricMatrix
3030
{
3131
/**
3232
* @brief the storage size of the matrix
33+
* @return the storage size of the matrix
3334
*/
3435
static constexpr INDEX_TYPE size() { return ( N*(N+1) ) / 2; }
3536

3637
/**
3738
* @brief calculates the linear index of the element at (i,j)
39+
* @param i the row index
40+
* @param j the column index
41+
* @return the linear index of the element at (i,j)
3842
*/
39-
static inline INDEX_TYPE linearIndex( INDEX_TYPE const i, INDEX_TYPE const j ) const
43+
static inline INDEX_TYPE linearIndex( INDEX_TYPE const i, INDEX_TYPE const j )
4044
{
4145
return (( i*(i+1) ) >> 1) + j;
4246
}

src/reactions/bulkGeneric/EquilibriumReactions.hpp

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace bulkGeneric
1414
{
1515

1616
/**
17-
* @brief This class implements components required to calculate equilibrium
17+
* @brief This class implements components required to calculate equilibrium
1818
* reactions for a given set of species. The class also proovides
1919
* device callable methods to enforce equilibrium pointwise and also
2020
* provides methods to launch batch processing of material points.
@@ -33,26 +33,25 @@ class EquilibriumReactions
3333

3434
/// alias for type of the integers used in the class.
3535
using IntType = INT_TYPE;
36-
36+
3737
/// alias for type of the indices used in the class.
3838
using IndexType = INDEX_TYPE;
3939

40-
template< typename PARAMS_DATA,
41-
typename ARRAY_1D,
42-
typename ARRAY_1D_TO_CONST,
43-
typename ARRAY_1D_TO_CONST2,
44-
typename ARRAY_2D >
45-
static HPCREACT_HOST_DEVICE void
46-
computeResidualAndJacobian( RealType const & temperature,
47-
PARAMS_DATA const & params,
48-
ARRAY_1D_TO_CONST const & speciesConcentration0,
49-
ARRAY_1D_TO_CONST2 const & xi,
50-
ARRAY_1D & residual,
51-
ARRAY_2D & jacobian );
40+
5241

5342
/**
54-
* @brief This method enforces equilibrium for a given set of species using
43+
* @brief This method enforces equilibrium for a given set of species using
5544
* reaction extents.
45+
* @param temperature The temperature of the system.
46+
* @param params The parameters for the equilibrium reactions.
47+
* @param speciesConcentration0 The initial species concentrations.
48+
* @param speciesConcentration The species concentrations to be updated.
49+
* @details This method uses the reaction extents to enforce equilibrium
50+
* for a given set of species. It uses the computeResidualAndJacobian
51+
* method to compute the residual and jacobian for the system and
52+
* then uses a direct solver to solve the system. The solution is
53+
* then used to update the species concentrations.
54+
*/
5655
template< typename PARAMS_DATA,
5756
typename ARRAY_1D,
5857
typename ARRAY_1D_TO_CONST >
@@ -63,6 +62,20 @@ class EquilibriumReactions
6362
ARRAY_1D_TO_CONST const & speciesConcentration0,
6463
ARRAY_1D & speciesConcentration );
6564

65+
/**
66+
* @brief This method enforces equilibrium for a given set of species using
67+
* aggregate primary concentrations.
68+
* @param temperature The temperature of the system.
69+
* @param params The parameters for the equilibrium reactions.
70+
* @param speciesConcentration0 The initial species concentrations.
71+
* @param speciesConcentration The species concentrations to be updated.
72+
* @details This method uses the aggregate primary concentrations to enforce
73+
* equilibrium for a given set of species. It uses the
74+
* computeResidualAndJacobianAggregatePrimaryConcentrations method to
75+
* compute the residual and jacobian for the system and then uses a
76+
* direct solver to solve the system. The solution is then used to
77+
* update the species concentrations.
78+
*/
6679
template< typename PARAMS_DATA,
6780
typename ARRAY_1D,
6881
typename ARRAY_1D_TO_CONST >
@@ -73,7 +86,21 @@ class EquilibriumReactions
7386
ARRAY_1D_TO_CONST const & speciesConcentration0,
7487
ARRAY_1D & speciesConcentration );
7588

76-
private:
89+
/**
90+
* @brief This method computes the residual and jacobian when using reaction extents to solve
91+
* for the equilibrium of a given set of species.
92+
* @tparam PARAMS_DATA The type of the parameters data.
93+
* @tparam ARRAY_1D The type of the array of species concentrations.
94+
* @tparam ARRAY_1D_TO_CONST The type of the array of species concentrations.
95+
* @tparam ARRAY_1D_TO_CONST2 The type of the array of reaction extents.
96+
* @tparam ARRAY_2D The type of the array of jacobian.
97+
* @param temperature The temperature of the system.
98+
* @param params The parameters for the equilibrium reactions.
99+
* @param speciesConcentration0 The initial species concentrations.
100+
* @param xi The reaction extents.
101+
* @param residual The residual.
102+
* @param jacobian The jacobian.
103+
*/
77104
template< typename PARAMS_DATA,
78105
typename ARRAY_1D,
79106
typename ARRAY_1D_TO_CONST,
@@ -87,6 +114,21 @@ class EquilibriumReactions
87114
ARRAY_1D & residual,
88115
ARRAY_2D & jacobian );
89116

117+
/**
118+
* @brief This method computes the residual and jacobian when using aggregate primary concentrations
119+
* to solve for the equilibrium of a given set of species.
120+
* @tparam PARAMS_DATA The type of the parameters data.
121+
* @tparam ARRAY_1D The type of the array of species concentrations.
122+
* @tparam ARRAY_1D_TO_CONST The type of the array of target aggregate primary concentrations.
123+
* @tparam ARRAY_1D_TO_CONST The type of the array of log primary species concentrations.
124+
* @tparam ARRAY_2D The type of the array of jacobian.
125+
* @param temperature The temperature of the system.
126+
* @param params The parameters for the equilibrium reactions.
127+
* @param targetAggregatePrimaryConcentrations The target aggregate primary concentrations.
128+
* @param logPrimarySpeciesConcentration The log of the primary species concentrations.
129+
* @param residual The residual.
130+
* @param jacobian The jacobian.
131+
*/
90132
template< typename PARAMS_DATA,
91133
typename ARRAY_1D,
92134
typename ARRAY_1D_TO_CONST,

src/reactions/bulkGeneric/EquilibriumReactionsReactionExtents_impl.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ HPCREACT_HOST_DEVICE inline
2323
void
2424
EquilibriumReactions< REAL_TYPE,
2525
INT_TYPE,
26-
INDEX_TYPE >::computeResidualAndJacobian( REAL_TYPE const & temperature,
27-
PARAMS_DATA const & params,
28-
ARRAY_1D_TO_CONST const & speciesConcentration0,
29-
ARRAY_1D_TO_CONST2 const & xi,
30-
ARRAY_1D & residual,
31-
ARRAY_2D & jacobian )
26+
INDEX_TYPE >::computeResidualAndJacobianReactionExtents( REAL_TYPE const & temperature,
27+
PARAMS_DATA const & params,
28+
ARRAY_1D_TO_CONST const & speciesConcentration0,
29+
ARRAY_1D_TO_CONST2 const & xi,
30+
ARRAY_1D & residual,
31+
ARRAY_2D & jacobian )
3232
{
3333

3434
HPCREACT_UNUSED_VAR( temperature );
@@ -125,12 +125,12 @@ EquilibriumReactions< REAL_TYPE,
125125
REAL_TYPE residualNorm = 0.0;
126126
for( int k=0; k<30; ++k )
127127
{
128-
computeResidualAndJacobian( temperature,
129-
params,
130-
speciesConcentration0,
131-
xi,
132-
residual,
133-
jacobian );
128+
computeResidualAndJacobianReactionExtents( temperature,
129+
params,
130+
speciesConcentration0,
131+
xi,
132+
residual,
133+
jacobian );
134134

135135
residualNorm = 0.0;
136136
for( int j = 0; j < numReactions; ++j )

src/reactions/bulkGeneric/KineticReactions.hpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ namespace hpcReact
1313
namespace bulkGeneric
1414
{
1515

16+
/**
17+
* @brief Class for computing reaction rates and species rates for a given set of reactions.
18+
* @tparam REAL_TYPE The type of the real numbers used in the class.
19+
* @tparam INT_TYPE The type of the integer numbers used in the class.
20+
* @tparam INDEX_TYPE The type of the index used in the class.
21+
* @tparam LOGE_CONCENTRATION Whether to use logarithm of concentration for the calculations.
22+
* @details
23+
* This class provides the ablity to compute kinetic reactions.
24+
*/
1625
template< typename REAL_TYPE,
1726
typename INT_TYPE,
1827
typename INDEX_TYPE,
@@ -21,8 +30,13 @@ class KineticReactions
2130
{
2231
public:
2332

33+
/// Type alias for the real type used in the class.
2434
using RealType = REAL_TYPE;
35+
36+
/// Type alias for the integer type used in the class.
2537
using IntType = INT_TYPE;
38+
39+
/// Type alias for the index type used in the class.
2640
using IndexType = INDEX_TYPE;
2741

2842
/**
@@ -46,6 +60,16 @@ class KineticReactions
4660
reactionRatesDerivatives );
4761
}
4862

63+
/**
64+
* @brief Compute the reaction rates for a given set of species concentrations.
65+
* @tparam PARAMS_DATA The type of the parameters data.
66+
* @tparam ARRAY_1D_TO_CONST The type of the array of species concentrations.
67+
* @tparam ARRAY_1D The type of the array of reaction rates.
68+
* @param temperature The temperature of the system.
69+
* @param params The parameters data.
70+
* @param speciesConcentration The array of species concentrations.
71+
* @param reactionRates The array of reaction rates.
72+
*/
4973
template< typename PARAMS_DATA,
5074
typename ARRAY_1D_TO_CONST,
5175
typename ARRAY_1D >
@@ -64,6 +88,9 @@ class KineticReactions
6488
}
6589

6690

91+
/**
92+
* @copydoc KineticReactions::computeSpeciesRates_impl()
93+
*/
6794
template< typename PARAMS_DATA,
6895
typename ARRAY_1D_TO_CONST,
6996
typename ARRAY_1D,
@@ -82,6 +109,16 @@ class KineticReactions
82109
speciesRatesDerivatives );
83110
}
84111

112+
/**
113+
* @brief Compute the species rates for a given set of species concentrations.
114+
* @tparam PARAMS_DATA The type of the parameters data.
115+
* @tparam ARRAY_1D_TO_CONST The type of the array of species concentrations.
116+
* @tparam ARRAY_1D The type of the array of species rates.
117+
* @param temperature The temperature of the system.
118+
* @param params The parameters data.
119+
* @param speciesConcentration The array of species concentrations.
120+
* @param speciesRates The array of species rates.
121+
*/
85122
template< typename PARAMS_DATA,
86123
typename ARRAY_1D_TO_CONST,
87124
typename ARRAY_1D >
@@ -99,6 +136,20 @@ class KineticReactions
99136
speciesRatesDerivatives );
100137
}
101138

139+
/**
140+
* @brief execute the time step for a given set of kinetic reactions.
141+
* @tparam PARAMS_DATA The type of the parameters data.
142+
* @tparam ARRAY_1D The type of the array of species concentrations.
143+
* @tparam ARRAY_1D_TO_CONST The type of the array of species concentrations.
144+
* @tparam ARRAY_2D The type of the array of species rates derivatives.
145+
* @param dt The time step to be used for the simulation.
146+
* @param temperature The temperature of the reaction.
147+
* @param params The parameters data.
148+
* @param speciesConcentration_n The array of species concentrations at the beginning of the time step.
149+
* @param speciesConcentration The array of species concentrations at the end of the time step.
150+
* @param speciesRates The array of species rates.
151+
* @param speciesRatesDerivatives The array of species rates derivatives.
152+
*/
102153
template< typename PARAMS_DATA,
103154
typename ARRAY_1D,
104155
typename ARRAY_1D_TO_CONST,
@@ -158,6 +209,19 @@ class KineticReactions
158209
ARRAY_1D & reactionRates,
159210
ARRAY_2D & reactionRatesDerivatives );
160211

212+
/**
213+
* @brief Compute the kinetic species rates for a given set of kinetic reactions.
214+
* @tparam PARAMS_DATA The type of the parameters data.
215+
* @tparam CALCULATE_DERIVATIVES Whether to calculate the derivatives of the species rates with respect to the species concentrations.
216+
* @tparam ARRAY_1D_TO_CONST The type of the array of species concentrations.
217+
* @tparam ARRAY_1D The type of the array of species rates.
218+
* @tparam ARRAY_2D The type of the array of species rates derivatives.
219+
* @param temperature The temperature of the system.
220+
* @param params The parameters data.
221+
* @param speciesConcentration The array of species concentrations.
222+
* @param speciesRates The array of species rates.
223+
* @param speciesRatesDerivatives The array of species rates derivatives.
224+
*/
161225
template< typename PARAMS_DATA,
162226
bool CALCULATE_DERIVATIVES,
163227
typename ARRAY_1D_TO_CONST,

src/reactions/bulkGeneric/unitTests/testEquilibriumReactions.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ void computeResidualAndJacobianTest( PARAMS_DATA const & params,
4646
CArrayWrapper< double, numReactions, numReactions > jacobian;
4747

4848

49-
EquilibriumReactionsType::computeResidualAndJacobian( temperature,
50-
params,
51-
speciesConcentration,
52-
xi,
53-
residual,
54-
jacobian );
49+
EquilibriumReactionsType::computeResidualAndJacobianReactionExtents( temperature,
50+
params,
51+
speciesConcentration,
52+
xi,
53+
residual,
54+
jacobian );
5555

5656
// printf( "R = { %8.4g, %8.4g }\n", residual[0], residual[1] );
5757
for( int r=0; r<numReactions; ++r )

0 commit comments

Comments
 (0)