Skip to content

Commit 471602c

Browse files
authored
Merge branch 'develop' into feature_SST_CD_discretisation
2 parents 177985c + fa22c88 commit 471602c

Some content is hidden

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

55 files changed

+11287
-3137
lines changed

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
3535
- name: Configure (cpp)
3636
if: ${{ matrix.language == 'cpp' }}
37-
run: ./meson.py build --optimization=1
37+
run: ./meson.py setup build --optimization=1
3838

3939
- name: Initialize CodeQL
4040
uses: github/codeql-action/init@v3

.github/workflows/regression.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ jobs:
211211
uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536
212212
with:
213213
# -t <Tutorials-branch> -c <Testcases-branch>
214-
args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}}
214+
args: -b ${{github.ref}} -t develop -c feature_custom_source -s ${{matrix.testscript}}
215215
- name: Cleanup
216216
uses: docker://ghcr.io/su2code/su2/test-su2:240320-1536
217217
with:

Common/include/CConfig.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ class CConfig {
710710
Wrt_Restart_Overwrite, /*!< \brief Overwrite restart files or append iteration number.*/
711711
Wrt_Surface_Overwrite, /*!< \brief Overwrite surface output files or append iteration number.*/
712712
Wrt_Volume_Overwrite, /*!< \brief Overwrite volume output files or append iteration number.*/
713+
PyCustomSource, /*!< \brief Use a user-defined custom source term .*/
713714
Restart_Flow; /*!< \brief Restart flow solution for adjoint and linearized problems. */
714715
unsigned short nMarker_Monitoring, /*!< \brief Number of markers to monitor. */
715716
nMarker_Designing, /*!< \brief Number of markers for the objective function. */
@@ -3090,6 +3091,12 @@ class CConfig {
30903091
*/
30913092
unsigned short GetnMarker_PyCustom(void) const { return nMarker_PyCustom; }
30923093

3094+
/*!
3095+
* \brief Get the Python custom source term activation.
3096+
* \return Custom source term is active or not.
3097+
*/
3098+
bool GetPyCustomSource(void) const { return PyCustomSource; }
3099+
30933100
/*!
30943101
* \brief Get the total number of moving markers.
30953102
* \return Total number of moving markers.

Common/include/containers/CPyWrapperMatrixView.hpp

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
/*! \brief Gets the value for a (row, column) pair. */ \
5656
passivedouble operator()(unsigned long row, unsigned long col) const { return Get(row, col); } \
5757
\
58+
/*! \brief Gets the values for a row of the matrix. */ \
59+
std::vector<passivedouble> operator()(unsigned long row) const { return Get(row); } \
60+
\
5861
/*! \brief Gets the value for a (row, column) pair. */ \
5962
passivedouble Get(unsigned long row, unsigned long col) const { return SU2_TYPE::GetValue(Access(row, col)); } \
6063
\
@@ -163,3 +166,77 @@ class CPyWrapperMarkerMatrixView {
163166
/*--- Use the macro to generate the interface. ---*/
164167
PY_WRAPPER_MATRIX_INTERFACE
165168
};
169+
170+
/*!
171+
* \class CPyWrapper3DMatrixView
172+
* \ingroup PySU2
173+
* \brief This class wraps C3DDoubleMatrix for the python wrapper matrix interface.
174+
* It is generaly used to wrap access to solver gradients defined for the entire volume.
175+
*/
176+
class CPyWrapper3DMatrixView {
177+
protected:
178+
static_assert(su2activematrix::IsRowMajor, "");
179+
su2double* data_ = nullptr;
180+
unsigned long rows_ = 0, cols_ = 0, dims_ = 0;
181+
std::string name_;
182+
bool read_only_ = false;
183+
184+
/*--- Define the functions required by the interface macro. ---*/
185+
inline const su2double& Access(unsigned long row, unsigned long col, unsigned long dim) const {
186+
if (row > rows_ || col > cols_ || dim > dims_) SU2_MPI::Error(name_ + " out of bounds", "CPyWrapper3DMatrixView");
187+
return data_[row * (cols_ * dims_) + col * dims_ + dim];
188+
}
189+
inline su2double& Access(unsigned long row, unsigned long col, unsigned long dim) {
190+
if (read_only_) SU2_MPI::Error(name_ + " is read-only", "CPyWrapper3DMatrixView");
191+
const auto& const_me = *this;
192+
return const_cast<su2double&>(const_me.Access(row, col, dim));
193+
}
194+
195+
public:
196+
CPyWrapper3DMatrixView() = default;
197+
198+
/*!
199+
* \brief Construct the view of the matrix.
200+
* \note "name" should be set to the variable name being returned to give better information to users.
201+
* \note "read_only" can be set to true to prevent the data from being modified.
202+
*/
203+
CPyWrapper3DMatrixView(C3DDoubleMatrix& mat, const std::string& name, bool read_only)
204+
: data_(mat.data()),
205+
rows_(mat.length()),
206+
cols_(mat.rows()),
207+
dims_(mat.cols()),
208+
name_(name),
209+
read_only_(read_only) {}
210+
211+
/*! \brief Returns the shape of the matrix. */
212+
std::vector<unsigned long> Shape() const { return {rows_, cols_, dims_}; }
213+
214+
/*! \brief Returns whether the data is read-only [true] or if it can be modified [false]. */
215+
bool IsReadOnly() const { return read_only_; }
216+
217+
/*! \brief Gets the value for a (row, column, dimension) triplet. */
218+
passivedouble operator()(unsigned long row, unsigned long col, unsigned long dim) const { return Get(row, col, dim); }
219+
220+
/*! \brief Gets the values for a row and column of the matrix. */
221+
std::vector<passivedouble> operator()(unsigned long row, unsigned long col) const { return Get(row, col); }
222+
223+
/*! \brief Gets the value for a (row, column, dimension) triplet. */
224+
passivedouble Get(unsigned long row, unsigned long col, unsigned long dim) const {
225+
return SU2_TYPE::GetValue(Access(row, col, dim));
226+
}
227+
228+
/*! \brief Gets the values for a row and column of the matrix. */
229+
std::vector<passivedouble> Get(unsigned long row, unsigned long col) const {
230+
std::vector<passivedouble> vals(dims_);
231+
for (unsigned long j = 0; j < dims_; ++j) vals[j] = Get(row, col, j);
232+
return vals;
233+
}
234+
/*! \brief Sets the value for a (row, column, dimension) triplet. This clears derivative information. */
235+
void Set(unsigned long row, unsigned long col, unsigned long dim, passivedouble val) { Access(row, col, dim) = val; }
236+
237+
/*! \brief Sets the values for a row and column of the matrix. */
238+
void Set(unsigned long row, unsigned long col, std::vector<passivedouble> vals) {
239+
unsigned long j = 0;
240+
for (const auto& val : vals) Set(row, col, j++, val);
241+
}
242+
};

Common/include/containers/container_decorators.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ class C3DContainerDecorator {
165165
FORCEINLINE StaticContainer get(Int i, Index j = 0) const noexcept {
166166
return m_storage.template get<StaticContainer>(i, j * m_innerSz);
167167
}
168+
169+
/*!
170+
* \brief Raw data access, for Python wrapper.
171+
*/
172+
FORCEINLINE Scalar* data() { return m_storage.data(); }
168173
};
169174

170175
/*!

Common/include/geometry/dual_grid/CPoint.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ class CPoint {
8282
su2activematrix Coord; /*!< \brief vector with the coordinates of the node. */
8383
su2activematrix
8484
Coord_Old; /*!< \brief Old coordinates vector for primal solution reloading for Disc.Adj. with dynamic grid. */
85-
su2activematrix Coord_Sum; /*!< \brief Sum of coordinates vector for geometry smoothing. */
86-
su2activematrix Coord_n; /*!< \brief Coordinates at time n for use with dynamic meshes. */
87-
su2activematrix Coord_n1; /*!< \brief Coordinates at time n-1 for use with dynamic meshes. */
88-
su2activematrix Coord_p1; /*!< \brief Coordinates at time n+1 for use with dynamic meshes. */
85+
su2activematrix Coord_n; /*!< \brief Coordinates at time n for use with dynamic meshes. */
86+
su2activematrix Coord_n1; /*!< \brief Coordinates at time n-1 for use with dynamic meshes. */
87+
su2activematrix Coord_p1; /*!< \brief Coordinates at time n+1 for use with dynamic meshes. */
8988

9089
su2activematrix GridVel; /*!< \brief Velocity of the grid for dynamic mesh cases. */
9190
CVectorOfMatrix GridVel_Grad; /*!< \brief Gradient of the grid velocity for dynamic meshes. */

Common/include/option_structure.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ enum ENUM_FLUIDMODEL {
550550
FLUID_MIXTURE = 9, /*!< \brief Species mixture model. */
551551
COOLPROP = 10, /*!< \brief Thermodynamics library. */
552552
FLUID_FLAMELET = 11, /*!< \brief lookup table (LUT) method for premixed flamelets. */
553-
DATADRIVEN_FLUID = 12, /*!< \brief multi-layer perceptron driven fluid model. */
553+
DATADRIVEN_FLUID = 12, /*!< \brief multi-layer perceptron driven fluid model. */
554554
};
555555
static const MapType<std::string, ENUM_FLUIDMODEL> FluidModel_Map = {
556556
MakePair("STANDARD_AIR", STANDARD_AIR)

Common/src/CConfig.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,9 @@ void CConfig::SetConfig_Options() {
15481548
/*!\brief MARKER_PYTHON_CUSTOM\n DESCRIPTION: Python customizable marker(s) \ingroup Config*/
15491549
addStringListOption("MARKER_PYTHON_CUSTOM", nMarker_PyCustom, Marker_PyCustom);
15501550

1551+
/*!\brief PYTHON_CUSTOM_SOURCE\n DESCRIPTION: Python custom source \ingroup Config*/
1552+
addBoolOption("PYTHON_CUSTOM_SOURCE", PyCustomSource, false);
1553+
15511554
/*!\brief MARKER_WALL_FUNCTIONS\n DESCRIPTION: Viscous wall markers for which wall functions must be applied.
15521555
Format: (Wall function marker, wall function type, ...) \ingroup Config*/
15531556
addWallFunctionOption("MARKER_WALL_FUNCTIONS", nMarker_WallFunctions, Marker_WallFunctions,
@@ -5606,7 +5609,7 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
56065609
"to be equal to the number of entries of SPECIES_INIT +1",
56075610
CURRENT_FUNCTION);
56085611

5609-
// Helper function that checks scalar variable bounds,
5612+
/*--- Helper function that checks scalar variable bounds. ---*/
56105613
auto checkScalarBounds = [&](su2double scalar, const string& name, su2double lowerBound, su2double upperBound) {
56115614
if (scalar < lowerBound || scalar > upperBound)
56125615
SU2_MPI::Error(string("Variable: ") + name + string(", is out of bounds."), CURRENT_FUNCTION);

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Short summary of the minimal requirements:
5454
If you have these tools installed, you can create a configuration using the `meson.py` found in the root source code folder:
5555

5656
```
57-
./meson.py build
57+
./meson.py setup build
5858
```
5959

6060
Use `ninja` to compile and install the code

SU2_CFD/include/drivers/CDriver.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,19 @@ class CDriver : public CDriverBase {
555555
*/
556556
void SetMarkerTranslationRate(unsigned short iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z);
557557

558+
/*!
559+
* \brief Get the Freestream Density for nondimensionalization
560+
* \return Freestream Density
561+
*/
562+
passivedouble GetDensityFreeStreamND() const;
563+
564+
/*!
565+
* \brief Get the reference Body force for nondimensionalization
566+
* \return reference Body Force
567+
*/
568+
passivedouble GetForceRef() const;
569+
570+
558571
/// \}
559572
};
560573

0 commit comments

Comments
 (0)