Skip to content

Commit cc3dfab

Browse files
committed
initial working version for buoyant flow
1 parent 5875625 commit cc3dfab

File tree

16 files changed

+577
-98
lines changed

16 files changed

+577
-98
lines changed

Common/include/CConfig.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ class CConfig {
286286
su2double **Giles_FlowDir; /*!< \brief Specified flow direction vector (unit vector) for Giles BC. */
287287
su2double *Inlet_Ptotal; /*!< \brief Specified total pressures for inlet boundaries. */
288288
su2double **Inlet_FlowDir; /*!< \brief Specified flow direction vector (unit vector) for inlet boundaries. */
289+
//su2double *PointSource; /*!< \brief Specified flow direction vector (unit vector) for inlet boundaries. */
289290
su2double *Inlet_Temperature; /*!< \brief Specified temperatures for a supersonic inlet boundaries. */
290291
su2double *Inlet_Pressure; /*!< \brief Specified static pressures for supersonic inlet boundaries. */
291292
su2double **Inlet_Velocity; /*!< \brief Specified flow velocity vectors for supersonic inlet boundaries. */
@@ -9454,6 +9455,18 @@ class CConfig {
94549455
*/
94559456
unsigned long GetnOuter_Iter(void) const { return nOuterIter; }
94569457

9458+
/*!
9459+
* \brief Get the number of inner iterations
9460+
* \return Number of inner iterations on each multizone block
9461+
*/
9462+
void SetnInner_Iter(unsigned long val_iter) { nInnerIter = val_iter; }
9463+
9464+
/*!
9465+
* \brief Get the number of outer iterations
9466+
* \return Number of outer iterations for the multizone problem
9467+
*/
9468+
void SetnOuter_Iter(unsigned long val_iter) { cout << "inner iter=" << val_iter << endl; nOuterIter = val_iter; }
9469+
94579470
/*!
94589471
* \brief Get the number of time iterations
94599472
* \return Number of time steps run

Common/src/CConfig.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,7 @@ void CConfig::SetPointersNull() {
890890
Inlet_FlowDir = nullptr; Inlet_Temperature = nullptr; Inlet_Pressure = nullptr;
891891
Inlet_Velocity = nullptr;
892892
Outlet_Pressure = nullptr; Inlet_SpeciesVal = nullptr; Inlet_TurbVal = nullptr;
893+
//PointSource = nullptr;
893894

894895
/*--- Engine Boundary Condition settings ---*/
895896

@@ -913,7 +914,7 @@ void CConfig::SetPointersNull() {
913914
Inlet_FlowDir = nullptr; Inlet_Temperature = nullptr; Inlet_Pressure = nullptr;
914915
Inlet_Velocity = nullptr; Inflow_Mach = nullptr; Inflow_Pressure = nullptr;
915916
Outlet_Pressure = nullptr; Isothermal_Temperature = nullptr;
916-
917+
//PointSource = nullptr;
917918
ElasticityMod = nullptr; PoissonRatio = nullptr; MaterialDensity = nullptr;
918919

919920
Load_Dir = nullptr; Load_Dir_Value = nullptr; Load_Dir_Multiplier = nullptr;

SU2_CFD/include/drivers/CDriver.hpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,37 @@ class CDriver : public CDriverBase {
475475
*/
476476
unsigned long GetNumberTimeIter() const;
477477

478+
/*!
479+
* \brief Get the number of inner iterations.
480+
* \return Number of inner iterations.
481+
*/
482+
unsigned long GetNumberInnerIter() const;
483+
484+
/*!
485+
* \brief Get the number of outer iterations.
486+
* \return Number of outer iterations.
487+
*/
488+
unsigned long GetNumberOuterIter() const;
489+
490+
491+
/*!
492+
* \brief Set the number of inner iterations.
493+
* \return Number of inner iterations.
494+
*/
495+
void SetNumberInnerIter(unsigned long);
496+
497+
/*!
498+
* \brief Set the number of outer iterations.
499+
* \return Number of outer iterations.
500+
*/
501+
void SetNumberOuterIter(unsigned long);
502+
503+
/*!
504+
* \brief Get the current solution
505+
* \return Current solution
506+
*/
507+
unsigned long GetSolution(unsigned short iSolver, unsigned long iPoint, unsigned short iVar);
508+
478509
/*!
479510
* \brief Get the current time iteration.
480511
* \return Current time iteration.
@@ -555,6 +586,19 @@ class CDriver : public CDriverBase {
555586
*/
556587
void SetMarkerTranslationRate(unsigned short iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z);
557588

589+
/*!
590+
* \brief Get the Freestream Density for nondimensionalization
591+
* \return Freestream Density
592+
*/
593+
unsigned long GetDensity_FreeStreamND() const;
594+
595+
/*!
596+
* \brief Get the reference Body force for nondimensionalization
597+
* \return reference Body Force
598+
*/
599+
unsigned long GetForce_Ref() const;
600+
601+
558602
/// \}
559603
};
560604

SU2_CFD/include/drivers/CDriverBase.hpp

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,15 @@ class CDriverBase {
179179
*/
180180
unsigned long GetNumberElements() const;
181181

182+
/*!
183+
* \brief Get the number of solution variables
184+
* \return Number of solution variables.
185+
*/
186+
//unsigned long GetNumberSolverVars() const;
187+
188+
unsigned short GetNumberSolverVars(const unsigned short iSol) const;
189+
unsigned short GetNumberPrimitiveVars(const unsigned short iSol) const;
190+
182191
/*!
183192
* \brief Get the global index of a mesh element.
184193
* \param[in] iElem - Mesh element index.
@@ -444,8 +453,6 @@ class CDriverBase {
444453
return CPyWrapperMatrixView(solver->GetNodes()->GetSolution(), "Solution of " + solver->GetSolverName(), false);
445454
}
446455

447-
448-
449456
/*!
450457
* \brief Get a read/write view of the current solution on the mesh nodes of a marker.
451458
*/
@@ -680,7 +687,7 @@ class CDriverBase {
680687

681688
vector<passivedouble> grad(nDim, 0.0);
682689
for (auto iDim = 0u; iDim < nDim; ++iDim) {
683-
grad[iDim] = nodes->GetGradient(iPoint, iVar, iDim);
690+
grad[iDim] = SU2_TYPE::GetValue(nodes->GetGradient(iPoint, iVar, iDim));
684691
}
685692
return grad;
686693
}
@@ -753,6 +760,49 @@ class CDriverBase {
753760
}
754761
}
755762

763+
/*!
764+
* \brief Set the array of variables for the source in the point
765+
* \param[in] iMarker - Marker index.
766+
* \param[in] iVertex - Marker vertex index.
767+
* \param[in] value - Value of the variable.
768+
*/
769+
void SetPointCustomSource(unsigned short iSOLVER, unsigned long iPoint, std::vector<passivedouble> values) {
770+
//for (auto iVar = 0ul; iVar < nVar; ++iDim) {
771+
//GetSolverAndCheckField(FLOW_SOL, iPoint)->SetCustomPointSource (iPoint, value);
772+
auto* solver = solver_container[selected_zone][INST_0][MESH_0][iSOLVER];
773+
solver->SetCustomPointSource(iPoint, values);
774+
}
775+
776+
// return solution vector
777+
inline vector<passivedouble> GetSolutionVector(unsigned short iSOLVER, unsigned long iPoint) {
778+
auto* solver = solver_container[iSOLVER][INST_0][MESH_0][iSOLVER];
779+
auto* nodes = solver->GetNodes();
780+
auto nVar = GetNumberSolverVars(iSOLVER);
781+
//cout << "getting solution: "<<iSOLVER << " " << iPoint << " " << nVar << endl;
782+
//auto val = nodes->GetSolution(iPoint,2);
783+
//cout << "value : " << val << endl;
784+
vector<passivedouble> solutionvector(nVar, 0.0);
785+
for (auto iVar = 0u; iVar < nVar; ++iVar) {
786+
solutionvector[iVar] = SU2_TYPE::GetValue(nodes->GetSolution(iPoint,iVar));
787+
//cout << "vector = " << solutionvector[iVar] << endl;
788+
}
789+
return solutionvector;
790+
}
791+
792+
inline vector<passivedouble> GetPrimitiveVector(unsigned short iSOLVER, unsigned long iPoint) {
793+
auto* solver = solver_container[iSOLVER][INST_0][MESH_0][iSOLVER];
794+
auto* nodes = solver->GetNodes();
795+
auto nPrimvar = GetNumberPrimitiveVars(iSOLVER);
796+
//cout << "getting solution: "<<iSOLVER << " " << iPoint << " " << nVar << endl;
797+
//auto val = nodes->GetSolution(iPoint,2);
798+
//cout << "value : " << val << endl;
799+
vector<passivedouble> solutionvector(nPrimvar, 0.0);
800+
for (auto iVar = 0u; iVar < nPrimvar; ++iVar) {
801+
solutionvector[iVar] = SU2_TYPE::GetValue(nodes->GetPrimitive(iPoint,iVar));
802+
//cout << "vector = " << solutionvector[iVar] << endl;
803+
}
804+
return solutionvector;
805+
}
756806
/// \}
757807

758808
protected:
@@ -769,6 +819,21 @@ class CDriverBase {
769819
return solver;
770820
}
771821

822+
/*!
823+
* \brief Automates some boilerplate of accessing solution fields for the python wrapper.
824+
*/
825+
inline CSolver* GetSolverAndCheckField(unsigned short iSolver,
826+
unsigned long iPoint = std::numeric_limits<unsigned long>::max()) const {
827+
// 1. check for the solver the number of variables
828+
// 2. check for the mesh the number of points
829+
//if (iPoint < std::numeric_limits<unsigned long>::max() && iPoint > GetNumberMarkers()) {
830+
// SU2_MPI::Error("Marker index exceeds size.", CURRENT_FUNCTION);
831+
//}
832+
auto* solver = solver_container[selected_zone][INST_0][MESH_0][iSolver];
833+
if (solver == nullptr) SU2_MPI::Error("The selected solver does not exist.", CURRENT_FUNCTION);
834+
return solver;
835+
}
836+
772837
/*!
773838
* \brief Initialize containers.
774839
*/

SU2_CFD/include/numerics/CNumerics.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class CNumerics {
155155
su2double
156156
LocalGridLength_i; /*!< \brief Local grid length at point i. */
157157
const su2double *RadVar_Source; /*!< \brief Source term from the radiative heat transfer equation. */
158+
const su2double *UserDefinedSource; /*!< \brief User Defined Source term. */
158159
const su2double
159160
*Coord_i, /*!< \brief Cartesians coordinates of point i. */
160161
*Coord_j; /*!< \brief Cartesians coordinates of point j. */

SU2_CFD/include/numerics/flow/flow_sources.hpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,3 +467,27 @@ class CSourceRadiation : public CSourceBase_Flow {
467467
ResidualType<> ComputeResidual(const CConfig* config) override;
468468

469469
};
470+
471+
472+
/*!
473+
* \class CSourceUserDefined
474+
* \brief Class for a user defined source term using the python wrapper
475+
* \ingroup SourceDiscr
476+
* \author Nijso Beishuizen
477+
*/
478+
class CSourceUserDefined : public CSourceBase_Flow {
479+
private:
480+
bool implicit;
481+
482+
public:
483+
484+
CSourceUserDefined(unsigned short val_nDim, unsigned short val_nVar, const CConfig *config);
485+
486+
/*!
487+
* \brief Source term integration for a user defined source.
488+
* \param[in] config - Definition of the particular problem.
489+
* \return Lightweight const-view of residual and Jacobian.
490+
*/
491+
ResidualType<> ComputeResidual(const CConfig* config) override;
492+
493+
};

SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ class CFVMFlowSolverBase : public CSolver {
170170
vector<vector<su2double> > Inlet_Ptotal; /*!< \brief Value of the Total P. */
171171
vector<vector<su2double> > Inlet_Ttotal; /*!< \brief Value of the Total T. */
172172
vector<su2activematrix> Inlet_FlowDir; /*!< \brief Value of the Flow Direction. */
173+
su2activematrix PointSource; /*!< \brief Value of the Flow Direction. */
173174
vector<vector<su2double> > HeatFlux; /*!< \brief Heat transfer coefficient for each boundary and vertex. */
174175
vector<vector<su2double> > HeatFluxTarget; /*!< \brief Heat transfer coefficient for each boundary and vertex. */
175176
vector<su2activematrix> CharacPrimVar; /*!< \brief Value of the characteristic variables at each boundary. */
@@ -2148,6 +2149,18 @@ class CFVMFlowSolverBase : public CSolver {
21482149
return Inlet_FlowDir[val_marker][val_vertex][val_dim];
21492150
}
21502151

2152+
/*!
2153+
* \brief A component of the unit vector representing the flow direction at an inlet boundary.
2154+
* \param[in] val_marker - Surface marker where the flow direction is evaluated
2155+
* \param[in] val_vertex - Vertex of the marker <i>val_marker</i> where the flow direction is evaluated
2156+
* \param[in] val_dim - The component of the flow direction unit vector to be evaluated
2157+
* \return Component of a unit vector representing the flow direction.
2158+
*/
2159+
inline su2double GetCustomPointSource(unsigned long val_point,
2160+
unsigned short val_var) const final {
2161+
return PointSource[val_point][val_var];
2162+
}
2163+
21512164
/*!
21522165
* \brief Set the value of the total temperature at an inlet boundary.
21532166
* \param[in] val_marker - Surface marker where the total temperature is set.
@@ -2201,6 +2214,29 @@ class CFVMFlowSolverBase : public CSolver {
22012214
Inlet_FlowDir[val_marker][val_vertex][val_dim] = val_flowdir;
22022215
}
22032216

2217+
/*!
2218+
* \brief Set a component of the unit vector representing the flow direction at an inlet boundary.
2219+
* \param[in] val_marker - Surface marker where the flow direction is set.
2220+
* \param[in] val_vertex - Vertex of the marker <i>val_marker</i> where the flow direction is set.
2221+
* \param[in] val_dim - The component of the flow direction unit vector to be set
2222+
* \param[in] val_flowdir - Component of a unit vector representing the flow direction.
2223+
*/
2224+
inline void SetCustomPointSource(unsigned long val_point,
2225+
vector<passivedouble> val_source) final {
2226+
/*--- Since this call can be accessed indirectly using python, do some error
2227+
* checking to prevent segmentation faults ---*/
2228+
//if (val_marker >= nMarker)
2229+
// SU2_MPI::Error("Out-of-bounds marker index used on inlet.", CURRENT_FUNCTION);
2230+
//else if (val_vertex >= nVertex[val_marker])
2231+
// SU2_MPI::Error("Out-of-bounds vertex index used on inlet.", CURRENT_FUNCTION);
2232+
//else
2233+
//cout << "value list size=" << val_source.size() << endl;
2234+
//cout << "pointsource.size = " << nVar << endl;
2235+
//cout << "point,npoint=" << val_point << " " << nPointDomain << endl;
2236+
for (unsigned short iVar=0; iVar < val_source.size(); iVar++)
2237+
PointSource[val_point][iVar] = val_source[iVar];
2238+
}
2239+
22042240
/*!
22052241
* \brief Update the multi-grid structure for the customized boundary conditions.
22062242
* \param geometry_container - Geometrical definition.

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ void CFVMFlowSolverBase<V, R>::Allocate(const CConfig& config) {
123123
/*--- Store the value of the Flow direction at the inlet BC ---*/
124124

125125
AllocVectorOfMatrices(nVertex, nDim, Inlet_FlowDir);
126+
127+
//AllocVectorOfVectors(nPointDomain, PointSource);
128+
PointSource.resize(nPointDomain,nVar);
126129

127130
/*--- Force definition and coefficient arrays for all of the markers ---*/
128131

SU2_CFD/include/solvers/CSolver.hpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2854,7 +2854,15 @@ class CSolver {
28542854
inline virtual su2double GetInletFlowDir(unsigned short val_marker,
28552855
unsigned long val_vertex,
28562856
unsigned short val_dim) const { return 0; }
2857-
2857+
/*!
2858+
* \brief A virtual member
2859+
* \param[in] val_marker - Surface marker where the flow direction is evaluated
2860+
* \param[in] val_vertex - Vertex of the marker <i>val_marker</i> where the flow direction is evaluated
2861+
* \param[in] val_dim - The component of the flow direction unit vector to be evaluated
2862+
* \return Component of a unit vector representing the flow direction.
2863+
*/
2864+
inline virtual su2double GetCustomPointSource(unsigned long val_point,
2865+
unsigned short val_var) const { return 0; }
28582866
/*!
28592867
* \brief A virtual member
28602868
* \param[in] val_marker - Surface marker where the total temperature is set.
@@ -2886,7 +2894,15 @@ class CSolver {
28862894
unsigned long val_vertex,
28872895
unsigned short val_dim,
28882896
su2double val_flowdir) { }
2889-
2897+
/*!
2898+
* \brief A virtual member
2899+
* \param[in] val_marker - Surface marker where the flow direction is set.
2900+
* \param[in] val_vertex - Vertex of the marker <i>val_marker</i> where the flow direction is set.
2901+
* \param[in] val_dim - The component of the flow direction unit vector to be set
2902+
* \param[in] val_flowdir - Component of a unit vector representing the flow direction.
2903+
*/
2904+
inline virtual void SetCustomPointSource(unsigned long val_Point,
2905+
vector<passivedouble> val_source) { }
28902906
/*!
28912907
* \brief Updates the components of the farfield velocity vector.
28922908
*/

SU2_CFD/src/drivers/CDriverBase.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ unsigned long CDriverBase::GetNumberDimensions() const { return main_geometry->G
165165

166166
unsigned long CDriverBase::GetNumberElements() const { return main_geometry->GetnElem(); }
167167

168+
//unsigned long CDriverBase::GetNumberSolverVars() const { return main_geometry->GetnElem(); }
169+
unsigned short CDriverBase::GetNumberSolverVars(const unsigned short iSol) const { return solver_container[selected_zone][INST_0][MESH_0][iSol]->GetnVar(); }
170+
unsigned short CDriverBase::GetNumberPrimitiveVars(const unsigned short iSol) const { return solver_container[selected_zone][INST_0][MESH_0][iSol]->GetnPrimVar(); }
171+
168172
unsigned long CDriverBase::GetElementGlobalIndex(unsigned long iElem) const {
169173
if (iElem >= GetNumberElements()) {
170174
SU2_MPI::Error("Element index exceeds size.", CURRENT_FUNCTION);

0 commit comments

Comments
 (0)