Skip to content

Commit d8d30a4

Browse files
committed
small cleanup
1 parent ce0b61e commit d8d30a4

File tree

2 files changed

+30
-33
lines changed

2 files changed

+30
-33
lines changed

SU2_CFD/include/drivers/CDriverBase.hpp

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -762,47 +762,49 @@ class CDriverBase {
762762

763763
/*!
764764
* \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.
765+
* \param[in] iSolver - Solver index.
766+
* \param[in] iPoint - Point index.
767+
* \param[in] values - Vector values of the source term.
768768
*/
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];
769+
void SetPointCustomSource(unsigned short iSolver, unsigned long iPoint, std::vector<passivedouble> values) {
770+
auto* solver = solver_container[selected_zone][INST_0][MESH_0][iSolver];
773771
solver->SetCustomPointSource(iPoint, values);
774772
}
775773

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];
774+
/*!
775+
* \brief Get the solution vector in a point for a specific solver
776+
* \param[in] iSolver - Solver index.
777+
* \param[in] iPoint - Point index.
778+
* \param[out] solutionvector - Vector values of the solution.
779+
*/
780+
inline vector<passivedouble> GetSolutionVector(unsigned short iSolver, unsigned long iPoint) {
781+
auto* solver = solver_container[selected_zone][INST_0][MESH_0][iSolver];
779782
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;
783+
auto nVar = GetNumberSolverVars(iSolver);
784784
vector<passivedouble> solutionvector(nVar, 0.0);
785785
for (auto iVar = 0u; iVar < nVar; ++iVar) {
786786
solutionvector[iVar] = SU2_TYPE::GetValue(nodes->GetSolution(iPoint,iVar));
787-
//cout << "vector = " << solutionvector[iVar] << endl;
788787
}
789788
return solutionvector;
790789
}
791790

792-
inline vector<passivedouble> GetPrimitiveVector(unsigned short iSOLVER, unsigned long iPoint) {
793-
auto* solver = solver_container[iSOLVER][INST_0][MESH_0][iSOLVER];
791+
/*!
792+
* \brief Get the primitive variables vector in a point for a specific solver
793+
* \param[in] iSolver - Solver index.
794+
* \param[in] iPoint - Point index.
795+
* \param[out] solutionvector - Vector values of the primitive variables.
796+
*/
797+
inline vector<passivedouble> GetPrimitiveVector(unsigned short iSolver, unsigned long iPoint) {
798+
auto* solver = solver_container[selected_zone][INST_0][MESH_0][iSolver];
794799
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;
800+
auto nPrimvar = GetNumberPrimitiveVars(iSolver);
799801
vector<passivedouble> solutionvector(nPrimvar, 0.0);
800802
for (auto iVar = 0u; iVar < nPrimvar; ++iVar) {
801803
solutionvector[iVar] = SU2_TYPE::GetValue(nodes->GetPrimitive(iPoint,iVar));
802-
//cout << "vector = " << solutionvector[iVar] << endl;
803804
}
804805
return solutionvector;
805806
}
807+
806808
/// \}
807809

808810
protected:
@@ -826,9 +828,6 @@ inline vector<passivedouble> GetPrimitiveVector(unsigned short iSOLVER, unsigned
826828
unsigned long iPoint = std::numeric_limits<unsigned long>::max()) const {
827829
// 1. check for the solver the number of variables
828830
// 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-
//}
832831
auto* solver = solver_container[selected_zone][INST_0][MESH_0][iSolver];
833832
if (solver == nullptr) SU2_MPI::Error("The selected solver does not exist.", CURRENT_FUNCTION);
834833
return solver;

SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2225,16 +2225,14 @@ class CFVMFlowSolverBase : public CSolver {
22252225
vector<passivedouble> val_source) final {
22262226
/*--- Since this call can be accessed indirectly using python, do some error
22272227
* 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;
2228+
if (val_point > nPointDomain)
2229+
SU2_MPI::Error("Out-of-bounds point index used on solver.", CURRENT_FUNCTION);
2230+
else if (val_source.size() > nVar)
2231+
SU2_MPI::Error("Out-of-bounds source size used on solver.", CURRENT_FUNCTION);
2232+
else {
22362233
for (unsigned short iVar=0; iVar < val_source.size(); iVar++)
22372234
PointSource[val_point][iVar] = val_source[iVar];
2235+
}
22382236
}
22392237

22402238
/*!

0 commit comments

Comments
 (0)