Skip to content

Commit ceb3b39

Browse files
committed
changes from code review
1 parent 1fa0053 commit ceb3b39

File tree

3 files changed

+20
-29
lines changed

3 files changed

+20
-29
lines changed

SU2_CFD/include/drivers/CDriverBase.hpp

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,15 @@ class CDriverBase {
445445
}
446446

447447
/*!
448-
* \brief Get a read/write view of the usrr defined source on all mesh nodes of a solver.
448+
* \brief Get read/write view of the gradients of a solver variable in a point.
449+
*/
450+
inline CPyWrapper3DMatrixView Gradient(unsigned short iSolver) {
451+
auto* solver = GetSolverAndCheckMarker(iSolver);
452+
return CPyWrapper3DMatrixView(solver->GetNodes()->GetGradient(), "Gradient of " + solver->GetSolverName(), false);
453+
}
454+
455+
/*!
456+
* \brief Get a read/write view of the user defined source on all mesh nodes of a solver.
449457
*/
450458
inline CPyWrapperMatrixView UserDefinedSource(unsigned short iSolver) {
451459
auto* solver = GetSolverAndCheckMarker(iSolver);
@@ -676,23 +684,6 @@ class CDriverBase {
676684
return sens;
677685
}
678686

679-
/*!
680-
* \brief Get the gradients of a solver variable in a point.
681-
* \returns Vector of gradients grad(iVar).
682-
*/
683-
inline vector<passivedouble> GetGradient(unsigned short iSolver, unsigned long iPoint, unsigned short iVar) {
684-
const auto nDim = GetNumberDimensions();
685-
auto* solver = GetSolverAndCheckMarker(iSolver);
686-
auto* nodes = solver->GetNodes();
687-
688-
vector<passivedouble> grad(nDim, 0.0);
689-
for (auto iDim = 0u; iDim < nDim; ++iDim) {
690-
grad[iDim] = SU2_TYPE::GetValue(nodes->GetGradient(iPoint, iVar, iDim));
691-
}
692-
return grad;
693-
}
694-
695-
696687
/*!
697688
* \brief Set the adjoint of the structural displacements.
698689
* \note This can be the input of the FEA solver in an adjoint FSI setting.

SU2_CFD/src/output/CFlowOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ void CFlowOutput::LoadVolumeDataScalar(const CConfig* config, const CSolver* con
15941594
SetVolumeOutputValue("DIFFUSIVITY_"+ std::to_string(iVar), iPoint, Node_Species->GetDiffusivity(iPoint,iVar));
15951595
if (config->GetKind_SlopeLimit_Species() != LIMITER::NONE)
15961596
SetVolumeOutputValue("LIMITER_SPECIES_" + std::to_string(iVar), iPoint, Node_Species->GetLimiter(iPoint, iVar));
1597-
if (config->GetPyCustom_Source()){
1597+
if (config->GetPyCustomSource()){
15981598
SetVolumeOutputValue("SPECIES_UDS_" + std::to_string(iVar), iPoint, Node_Species->GetUserDefinedSource()(iPoint, iVar));
15991599
}
16001600
}

TestCases/py_wrapper/turbulent_premixed_psi/run.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,22 @@
3939
# flame temperature of the methane-air mixture (phi=0.5, P=5)
4040
Tf = 1777
4141

42-
# unburnt temperature of the propane-air mixture (phi=0.5, P=5)
42+
# unburnt temperature of the methane-air mixture (phi=0.5, P=5)
4343
Tu = 673.0
4444
Pu = 5.0
4545
phi = 0.5
4646
# unburnt density at P=5
4747
rho_u = 2.52
48-
# unburnt thermal conductivity of methane-air at phi=0.5 (phi=0.5, P=5)
48+
# unburnt thermal conductivity of methane-air (phi=0.5, P=5)
4949
k_u = 0.0523
50-
# unburnt heat capacity of methane-air at phi=0.5 (P=5)
50+
# unburnt heat capacity of methane-air (phi=0.5, P=5)
5151
cp_u = 1311.0
5252

5353
# P = rho*R*T
5454
# 5 = 2.55 * R * 673
5555
# R = 0.0029
5656

57+
5758
# ################################################################## #
5859
# create a function for the initial progress variable c #
5960
# ################################################################## #
@@ -80,7 +81,6 @@ def SetInitialSpecies(SU2Driver):
8081
coord = allCoords.Get(iPoint)
8182
C = initC(coord)
8283
# now update the initial condition for the species
83-
#SU2Driver.SetSolutionVector(iSPECIESSOLVER, iPoint, [C])
8484
SU2Driver.Solution(iSPECIESSOLVER).Set(iPoint,0,C)
8585

8686
# ################################################################## #
@@ -105,11 +105,11 @@ def update_temperature(SU2Driver, iPoint):
105105
def zimont(SU2Driver, iPoint):
106106

107107
iSSTSOLVER = SU2Driver.GetSolverIndices()['SST']
108-
#tke, dissipation = SU2Driver.GetSolutionVector(iSSTSOLVER,iPoint)
109108
tke, dissipation = SU2Driver.Solution(iSSTSOLVER)(iPoint)
110109

111110
iSPECIESSOLVER = SU2Driver.GetSolverIndices()['SPECIES']
112-
gradc = SU2Driver.GetGradient(iSPECIESSOLVER,iPoint,0)
111+
# get the gradient of species_0
112+
gradc = SU2Driver.Gradient(iSPECIESSOLVER)(iPoint,0)
113113
primindex = SU2Driver.GetPrimitiveIndices()
114114
iDENSITY = primindex.get("DENSITY")
115115
iMU = primindex.get("LAMINAR_VISCOSITY")
@@ -137,7 +137,7 @@ def zimont(SU2Driver, iPoint):
137137
def getsolvar(SU2Driver):
138138
primindex = SU2Driver.GetPrimitiveIndices()
139139
iFLOWSOLVER = SU2Driver.GetSolverIndices()['INC.FLOW']
140-
nVars = SU2Driver.GetNumberSolverVars(iFLOWSOLVER)
140+
nVars = SU2Driver.Solution(iFLOWSOLVER).Shape()[1]
141141
varindex = primindex.copy()
142142
for prim in varindex.copy():
143143
if varindex[prim] >=nVars:
@@ -177,9 +177,9 @@ def main():
177177
# all the indices and the map to the names of the primitives
178178
primindex = driver.GetPrimitiveIndices()
179179
nElem = driver.GetNumberElements()
180-
nVars = driver.GetNumberSolverVars(iFLOWSOLVER)
181-
nVarsSpecies = driver.GetNumberSolverVars(iSPECIESSOLVER)
182-
nVarsTurb = driver.GetNumberSolverVars(iSSTSOLVER)
180+
nVars = driver.Solution(iFLOWSOLVER).Shape()[1]
181+
nVarsSpecies = driver.Solution(iSPECIESSOLVER).Shape()[1]
182+
nVarsTurb = driver.Solution(iSSTSOLVER).Shape()[1]
183183

184184
if rank == 0:
185185
print("Dimensions of the problem = ",nDim)

0 commit comments

Comments
 (0)