Skip to content

Commit d04fa37

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feature_periodic_streamwise
2 parents 546725d + a4894ed commit d04fa37

52 files changed

Lines changed: 1580 additions & 607 deletions

Some content is hidden

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

Common/include/CConfig.hpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#pragma once
3030

31-
#include "./parallelization/mpi_structure.hpp"
31+
#include "parallelization/mpi_structure.hpp"
3232

3333
#include <iostream>
3434
#include <cstdlib>
@@ -416,6 +416,9 @@ class CConfig {
416416

417417
unsigned short nQuasiNewtonSamples; /*!< \brief Number of samples used in quasi-Newton solution methods. */
418418
bool UseVectorization; /*!< \brief Whether to use vectorized numerics schemes. */
419+
bool NewtonKrylov; /*!< \brief Use a coupled Newton method to solve the flow equations. */
420+
array<unsigned short,3> NK_IntParam{{20, 3, 2}}; /*!< \brief Integer parameters for NK method. */
421+
array<su2double,4> NK_DblParam{{-2.0, 0.1, -3.0, 1e-4}}; /*!< \brief Floating-point parameters for NK method. */
419422

420423
unsigned short nMGLevels; /*!< \brief Number of multigrid levels (coarse levels). */
421424
unsigned short nCFL; /*!< \brief Number of CFL, one for each multigrid level. */
@@ -1193,6 +1196,8 @@ class CConfig {
11931196

11941197
void addDoubleArrayOption(const string name, const int size, su2double* option_field);
11951198

1199+
void addUShortArrayOption(const string name, const int size, unsigned short* option_field);
1200+
11961201
void addDoubleListOption(const string name, unsigned short & size, su2double * & option_field);
11971202

11981203
void addShortListOption(const string name, unsigned short & size, short * & option_field);
@@ -3978,6 +3983,21 @@ class CConfig {
39783983
*/
39793984
bool GetUseVectorization(void) const { return UseVectorization; }
39803985

3986+
/*!
3987+
* \brief Get whether to use a Newton-Krylov method.
3988+
*/
3989+
bool GetNewtonKrylov(void) const { return NewtonKrylov; }
3990+
3991+
/*!
3992+
* \brief Get Newton-Krylov integer parameters.
3993+
*/
3994+
array<unsigned short,3> GetNewtonKrylovIntParam(void) const { return NK_IntParam; }
3995+
3996+
/*!
3997+
* \brief Get Newton-Krylov floating-point parameters.
3998+
*/
3999+
array<su2double,4> GetNewtonKrylovDblParam(void) const { return NK_DblParam; }
4000+
39814001
/*!
39824002
* \brief Get the relaxation coefficient of the linear solver for the implicit formulation.
39834003
* \return relaxation coefficient of the linear solver for the implicit formulation.

Common/include/linear_algebra/CSysMatrix.hpp

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828

2929
#pragma once
3030

31-
#include "../../include/parallelization/mpi_structure.hpp"
32-
#include "../../include/parallelization/omp_structure.hpp"
33-
#include "../../include/parallelization/vectorization.hpp"
31+
#include "../../include/CConfig.hpp"
3432
#include "CSysVector.hpp"
3533
#include "CPastixWrapper.hpp"
3634

@@ -75,16 +73,43 @@ struct mkl_jit_wrapper<float> {
7573
#endif
7674
#endif
7775

78-
class CConfig;
7976
class CGeometry;
8077

78+
struct CSysMatrixComms {
79+
/*!
80+
* \brief Routine to load a vector quantity into the data structures for MPI point-to-point
81+
* communication and to launch non-blocking sends and recvs.
82+
* \param[in] x - CSysVector holding the array of data.
83+
* \param[in] geometry - Geometrical definition of the problem.
84+
* \param[in] config - Definition of the particular problem.
85+
* \param[in] commType - Enumerated type for the quantity to be communicated.
86+
*/
87+
template<class T>
88+
static void Initiate(const CSysVector<T>& x, CGeometry *geometry, const CConfig *config,
89+
unsigned short commType = SOLUTION_MATRIX);
90+
91+
/*!
92+
* \brief Routine to complete the set of non-blocking communications launched by
93+
* Initiate() and unpacking of the data in the vector.
94+
* \param[in] x - CSysVector holding the array of data.
95+
* \param[in] geometry - Geometrical definition of the problem.
96+
* \param[in] config - Definition of the particular problem.
97+
* \param[in] commType - Enumerated type for the quantity to be unpacked.
98+
*/
99+
template<class T>
100+
static void Complete(CSysVector<T>& x, CGeometry *geometry, const CConfig *config,
101+
unsigned short commType = SOLUTION_MATRIX);
102+
};
103+
81104
/*!
82105
* \class CSysMatrix
83106
* \brief Main class for defining block-compressed-row-storage sparse matrices.
84107
*/
85108
template<class ScalarType>
86109
class CSysMatrix {
87110
private:
111+
friend class CSysMatrixComms;
112+
88113
const int rank; /*!< \brief MPI Rank. */
89114
const int size; /*!< \brief MPI Size. */
90115

@@ -163,9 +188,11 @@ class CSysMatrix {
163188

164189
/*!
165190
* \brief Handle type conversion for when we Set, Add, etc. blocks, preserving derivative information (if supported by types).
166-
* \note See specialization for discrete adjoint right outside this class's declaration.
167191
*/
168-
template<class DstType, class SrcType>
192+
template<class DstType, class SrcType, su2enable_if<std::is_arithmetic<DstType>::value> = 0>
193+
FORCEINLINE static DstType ActiveAssign(const SrcType& val) { return SU2_TYPE::GetValue(val); }
194+
195+
template<class DstType, class SrcType, su2enable_if<!std::is_arithmetic<DstType>::value> = 0>
169196
FORCEINLINE static DstType ActiveAssign(const SrcType& val) { return val; }
170197

171198
/*!
@@ -378,34 +405,6 @@ class CSysMatrix {
378405
*/
379406
void SetValDiagonalZero(void);
380407

381-
/*!
382-
* \brief Routine to load a vector quantity into the data structures for MPI point-to-point
383-
* communication and to launch non-blocking sends and recvs.
384-
* \param[in] x - CSysVector holding the array of data.
385-
* \param[in] geometry - Geometrical definition of the problem.
386-
* \param[in] config - Definition of the particular problem.
387-
* \param[in] commType - Enumerated type for the quantity to be communicated.
388-
*/
389-
template<class OtherType>
390-
void InitiateComms(const CSysVector<OtherType> & x,
391-
CGeometry *geometry,
392-
const CConfig *config,
393-
unsigned short commType) const;
394-
395-
/*!
396-
* \brief Routine to complete the set of non-blocking communications launched by
397-
* InitiateComms() and unpacking of the data in the vector.
398-
* \param[in] x - CSysVector holding the array of data.
399-
* \param[in] geometry - Geometrical definition of the problem.
400-
* \param[in] config - Definition of the particular problem.
401-
* \param[in] commType - Enumerated type for the quantity to be unpacked.
402-
*/
403-
template<class OtherType>
404-
void CompleteComms(CSysVector<OtherType> & x,
405-
CGeometry *geometry,
406-
const CConfig *config,
407-
unsigned short commType) const;
408-
409408
/*!
410409
* \brief Get a pointer to the start of block "ij"
411410
* \param[in] block_i - Row index.
@@ -918,8 +917,3 @@ class CSysMatrix {
918917
CGeometry *geometry, const CConfig *config) const;
919918

920919
};
921-
922-
#ifdef CODI_REVERSE_TYPE
923-
template<> template<>
924-
FORCEINLINE su2mixedfloat CSysMatrix<su2mixedfloat>::ActiveAssign(const su2double& val) { return SU2_TYPE::GetValue(val); }
925-
#endif

Common/include/linear_algebra/CSysSolve.hpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ class CSysSolve {
8181

8282
mutable bool cg_ready; /*!< \brief Indicate if memory used by CG is allocated. */
8383
mutable bool bcg_ready; /*!< \brief Indicate if memory used by BCGSTAB is allocated. */
84-
mutable bool gmres_ready; /*!< \brief Indicate if memory used by FGMRES is allocated. */
8584
mutable bool smooth_ready; /*!< \brief Indicate if memory used by SMOOTHER is allocated. */
8685

8786
mutable VectorType r; /*!< \brief Residual in CG and BCGSTAB. */
@@ -101,6 +100,9 @@ class CSysSolve {
101100
const VectorType* LinSysRes_ptr; /*!< \brief Pointer to appropriate LinSysRes (set to original or temporary in call to Solve). */
102101

103102
LinearToleranceType tol_type = LinearToleranceType::RELATIVE; /*!< \brief How the linear solvers interpret the tolerance. */
103+
bool xIsZero = false; /*!< \brief If true assume the initial solution is always 0. */
104+
bool recomputeRes = false; /*!< \brief Recompute the residual after inner iterations, if monitoring. */
105+
unsigned long monitorFreq = 10; /*!< \brief Monitoring frequency. */
104106

105107
/*!
106108
* \brief sign transfer function
@@ -388,4 +390,19 @@ class CSysSolve {
388390
*/
389391
inline void SetToleranceType(LinearToleranceType type) {tol_type = type;}
390392

393+
/*!
394+
* \brief Assume the initial solution is 0 to save one product, or don't.
395+
*/
396+
inline void SetxIsZero(bool isZero) {xIsZero = isZero;}
397+
398+
/*!
399+
* \brief Set whether to recompute residuals at the end (while monitoring only).
400+
*/
401+
inline void SetRecomputeResidual(bool recompRes) {recomputeRes = recompRes;}
402+
403+
/*!
404+
* \brief Set the screen output frequency during monitoring.
405+
*/
406+
inline void SetMonitoringFrequency(bool frequency) {monitorFreq = frequency;}
407+
391408
};

Common/include/linear_algebra/CSysVector.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class CSysVector : public VecExpr::CVecExpr<CSysVector<ScalarType>, ScalarType>
6666
ScalarType* vec_val = nullptr; /*!< \brief Storage, 64 byte aligned (do not use normal new/delete). */
6767
unsigned long nElm = 0; /*!< \brief Total number of elements (or number elements on this processor). */
6868
unsigned long nElmDomain = 0; /*!< \brief Total number of elements without Ghost cells. */
69-
unsigned long nVar = 0; /*!< \brief Number of elements in a block. */
69+
unsigned long nVar = 1; /*!< \brief Number of elements in a block. */
7070

7171
/*!
7272
* \brief Generic initialization from a scalar or array.
@@ -111,7 +111,7 @@ class CSysVector : public VecExpr::CVecExpr<CSysVector<ScalarType>, ScalarType>
111111
* \param[in] size - Number of elements locally.
112112
* \param[in] val - Default value for elements.
113113
*/
114-
CSysVector(unsigned long size, ScalarType val = 0.0) { Initialize(size, size, 1, &val, false); }
114+
explicit CSysVector(unsigned long size, ScalarType val = 0.0) { Initialize(size, size, 1, &val, false); }
115115

116116
/*!
117117
* \brief Construct from size and value (block version).
@@ -129,7 +129,7 @@ class CSysVector : public VecExpr::CVecExpr<CSysVector<ScalarType>, ScalarType>
129129
* \param[in] size - Number of elements locally.
130130
* \param[in] u_array - Vector stored as array being copied.
131131
*/
132-
explicit CSysVector(unsigned long size, const ScalarType* u_array) { Initialize(size, size, 1, u_array, true); }
132+
CSysVector(unsigned long size, const ScalarType* u_array) { Initialize(size, size, 1, u_array, true); }
133133

134134
/*!
135135
* \brief Constructor from array (block version).
@@ -138,8 +138,7 @@ class CSysVector : public VecExpr::CVecExpr<CSysVector<ScalarType>, ScalarType>
138138
* \param[in] numVar - number of variables in each block
139139
* \param[in] u_array - vector stored as array being copied
140140
*/
141-
explicit CSysVector(unsigned long numBlk, unsigned long numBlkDomain, unsigned long numVar,
142-
const ScalarType* u_array) {
141+
CSysVector(unsigned long numBlk, unsigned long numBlkDomain, unsigned long numVar, const ScalarType* u_array) {
143142
Initialize(numBlk, numBlkDomain, numVar, u_array, true);
144143
}
145144

Common/include/option_structure.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const unsigned int MAX_PARAMETERS = 10; /*!< \brief Maximum number of para
7777
const unsigned int MAX_NUMBER_PERIODIC = 10; /*!< \brief Maximum number of periodic boundary conditions. */
7878
const unsigned int MAX_STRING_SIZE = 200; /*!< \brief Maximum number of domains. */
7979
const unsigned int MAX_NUMBER_FFD = 15; /*!< \brief Maximum number of FFDBoxes for the FFD. */
80-
const unsigned int MAX_SOLS = 12; /*!< \brief Maximum number of solutions at the same time (dimension of solution container array). */
80+
enum: unsigned int{MAX_SOLS = 12}; /*!< \brief Maximum number of solutions at the same time (dimension of solution container array). */
8181
const unsigned int MAX_TERMS = 6; /*!< \brief Maximum number of terms in the numerical equations (dimension of solver container array). */
8282
const unsigned int MAX_ZONES = 3; /*!< \brief Maximum number of zones. */
8383
const unsigned int MAX_FE_KINDS = 4; /*!< \brief Maximum number of Finite Elements. */
@@ -235,7 +235,7 @@ static const MapType<string, ENUM_MAIN_SOLVER> Solver_Map = {
235235
};
236236

237237
/*!
238-
* \brief different solver types for the multizone environment component
238+
* \brief Different solver types for multizone problems
239239
*/
240240
enum ENUM_MULTIZONE {
241241
MZ_BLOCK_GAUSS_SEIDEL = 0, /*!< \brief Definition of a Block-Gauss-Seidel multizone solver. */
@@ -439,7 +439,6 @@ static const MapType<string, ENUM_MEASUREMENTS> Measurements_Map = {
439439
enum RUNTIME_TYPE {
440440
RUNTIME_FLOW_SYS = 2, /*!< \brief One-physics case, the code is solving the flow equations(Euler and Navier-Stokes). */
441441
RUNTIME_TURB_SYS = 3, /*!< \brief One-physics case, the code is solving the turbulence model. */
442-
RUNTIME_ADJPOT_SYS = 5, /*!< \brief One-physics case, the code is solving the adjoint potential flow equation. */
443442
RUNTIME_ADJFLOW_SYS = 6, /*!< \brief One-physics case, the code is solving the adjoint equations is being solved (Euler and Navier-Stokes). */
444443
RUNTIME_ADJTURB_SYS = 7, /*!< \brief One-physics case, the code is solving the adjoint turbulence model. */
445444
RUNTIME_MULTIGRID_SYS = 14, /*!< \brief Full Approximation Storage Multigrid system of equations. */

Common/include/option_structure.inl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,19 +334,20 @@ public:
334334
}
335335
};
336336

337-
class COptionDoubleArray : public COptionBase {
337+
template<class Type>
338+
class COptionArray : public COptionBase {
338339
string name; // Identifier for the option
339340
const int size; // Number of elements
340-
su2double* field; // Reference to the fieldname
341+
Type* field; // Reference to the field
341342

342343
public:
343-
COptionDoubleArray(string option_field_name, const int list_size, su2double* option_field) :
344+
COptionArray(string option_field_name, const int list_size, Type* option_field) :
344345
name(option_field_name),
345346
size(list_size),
346347
field(option_field) {
347348
}
348349

349-
~COptionDoubleArray() override {};
350+
~COptionArray() override {};
350351

351352
string SetValue(vector<string> option_value) override {
352353
COptionBase::SetValue(option_value);
@@ -368,7 +369,7 @@ public:
368369
for (int i = 0; i < this->size; i++) {
369370
istringstream is(option_value[i]);
370371
if (!(is >> field[i])) {
371-
return badValue(option_value, "su2double array", this->name);
372+
return badValue(option_value, " array", this->name);
372373
}
373374
}
374375
return "";

Common/include/parallelization/mpi_structure.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,49 @@ void CBaseMPIWrapper::Error(std::string ErrorMsg, std::string FunctionName){
122122
}
123123
Abort(currentComm, 0);
124124
}
125+
126+
void CBaseMPIWrapper::CopyData(const void* sendbuf, void* recvbuf, int size, Datatype datatype) {
127+
switch (datatype) {
128+
case MPI_DOUBLE:
129+
for (int i = 0; i < size; i++) {
130+
static_cast<su2double*>(recvbuf)[i] = static_cast<const su2double*>(sendbuf)[i];
131+
}
132+
break;
133+
case MPI_UNSIGNED_LONG:
134+
for (int i = 0; i < size; i++) {
135+
static_cast<unsigned long*>(recvbuf)[i] = static_cast<const unsigned long*>(sendbuf)[i];
136+
}
137+
break;
138+
case MPI_LONG:
139+
for (int i = 0; i < size; i++) {
140+
static_cast<long*>(recvbuf)[i] = static_cast<const long*>(sendbuf)[i];
141+
}
142+
break;
143+
case MPI_UNSIGNED_SHORT:
144+
for (int i = 0; i < size; i++) {
145+
static_cast<unsigned short*>(recvbuf)[i] = static_cast<const unsigned short*>(sendbuf)[i];
146+
}
147+
break;
148+
case MPI_CHAR:
149+
for (int i = 0; i < size; i++) {
150+
static_cast<char*>(recvbuf)[i] = static_cast<const char*>(sendbuf)[i];
151+
}
152+
break;
153+
case MPI_SHORT:
154+
for (int i = 0; i < size; i++) {
155+
static_cast<short*>(recvbuf)[i] = static_cast<const short*>(sendbuf)[i];
156+
}
157+
break;
158+
case MPI_INT:
159+
for (int i = 0; i < size; i++) {
160+
static_cast<int*>(recvbuf)[i] = static_cast<const int*>(sendbuf)[i];
161+
}
162+
break;
163+
default:
164+
Error("Unknown type", CURRENT_FUNCTION);
165+
break;
166+
};
167+
}
125168
#endif
126169

127170
#ifdef HAVE_MPI

Common/include/parallelization/mpi_structure.hpp

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -503,48 +503,7 @@ class CBaseMPIWrapper {
503503
static int Rank, Size;
504504
static Comm currentComm;
505505

506-
static inline void CopyData(const void* sendbuf, void* recvbuf, int size, Datatype datatype) {
507-
switch (datatype) {
508-
case MPI_DOUBLE:
509-
for (int i = 0; i < size; i++) {
510-
static_cast<su2double*>(recvbuf)[i] = static_cast<const su2double*>(sendbuf)[i];
511-
}
512-
break;
513-
case MPI_UNSIGNED_LONG:
514-
for (int i = 0; i < size; i++) {
515-
static_cast<unsigned long*>(recvbuf)[i] = static_cast<const unsigned long*>(sendbuf)[i];
516-
}
517-
break;
518-
case MPI_LONG:
519-
for (int i = 0; i < size; i++) {
520-
static_cast<long*>(recvbuf)[i] = static_cast<const long*>(sendbuf)[i];
521-
}
522-
break;
523-
case MPI_UNSIGNED_SHORT:
524-
for (int i = 0; i < size; i++) {
525-
static_cast<unsigned short*>(recvbuf)[i] = static_cast<const unsigned short*>(sendbuf)[i];
526-
}
527-
break;
528-
case MPI_CHAR:
529-
for (int i = 0; i < size; i++) {
530-
static_cast<char*>(recvbuf)[i] = static_cast<const char*>(sendbuf)[i];
531-
}
532-
break;
533-
case MPI_SHORT:
534-
for (int i = 0; i < size; i++) {
535-
static_cast<short*>(recvbuf)[i] = static_cast<const short*>(sendbuf)[i];
536-
}
537-
break;
538-
case MPI_INT:
539-
for (int i = 0; i < size; i++) {
540-
static_cast<int*>(recvbuf)[i] = static_cast<const int*>(sendbuf)[i];
541-
}
542-
break;
543-
default:
544-
Error("Unknown type", CURRENT_FUNCTION);
545-
break;
546-
};
547-
}
506+
static void CopyData(const void* sendbuf, void* recvbuf, int size, Datatype datatype);
548507

549508
public:
550509
static void Error(std::string ErrorMsg, std::string FunctionName);

0 commit comments

Comments
 (0)