@@ -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 */
0 commit comments