11#!/usr/bin/env python
22
33## \file run.py
4- # \brief Unsteady inlet boundary conditions.
4+ # \brief Buoyancy force using user defines source term
55# \version 8.1.0 "Harrier"
66#
77# SU2 Project Website: https://su2code.github.io
2626
2727import sys
2828import pysu2
29- import math
30- import itertools
3129# from mpi4py import MPI
3230
3331def main ():
@@ -44,28 +42,17 @@ def main():
4442 print ('A TypeError occured in pysu2.CSinglezoneDriver : ' , exception )
4543 raise
4644
47- # Get the ID of the inlet marker.
48- all_marker_ids = driver .GetMarkerIndices ()
49- marker_name = 'x_minus'
50- marker_id = all_marker_ids [marker_name ] if marker_name in all_marker_ids else - 1
51-
52- # Run the time loop in python to vary the inlet conditions.
53- dt = driver .GetUnsteadyTimeStep ()
54-
5545 print ("\n ------------------------------ Begin Solver -----------------------------" )
5646 sys .stdout .flush ()
5747
5848 # we need to add a source term to the energy equation. For this, we need to get the solver, and the variable first.
5949 # we then loop over all points and for these points, we add the source term
6050 nDim = driver .GetNumberDimensions ()
61- nNodes = driver .GetNumberNodes ()
62- #solverindex = driver.GetSolverIndices()
63- #primindex = driver.GetPrimitiveIndices()
6451
6552 # index to the flow solver
6653 iSOLVER = driver .GetSolverIndices ()['INC.FLOW' ]
6754 print ("index of flow solver = " ,iSOLVER )
68- coords = driver . Coordinates ()
55+
6956 # all the indices and the map to the names of the primitives
7057 primindex = driver .GetPrimitiveIndices ()
7158 print ("indices of primitives=" ,primindex )
@@ -93,7 +80,6 @@ def main():
9380 custom_source_vector = [0.0 for i in range (nVars )]
9481 print ("custom source vector = " , custom_source_vector )
9582
96- inner_iter = driver .GetNumberInnerIter ();
9783 print ("max. number of inner iterations: " ,driver .GetNumberInnerIter ());
9884 print ("max nr of outer iterations: " ,driver .GetNumberOuterIter ());
9985
@@ -105,51 +91,24 @@ def main():
10591 print ("rho freestream = " ,DensityInc_0 )
10692 Force_Ref = driver .GetForce_Ref ()
10793 print ("reference force = " ,Force_Ref )
108- # get the density from the solution
109- #residual[iDim+1] = -(DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref;
110-
111- #for i_node in range(driver.GetNumberNodes() - driver.GetNumberHaloNodes()):
112- #print("(x,y) = ( ",coords.Get(i_node,0)," , ",coords.Get(i_node,1)," )")
113- #custom_source = -9.81
114- # we need to set the custom source to the correct primitive equation, in this case let us add it to the y-momentum equation
115- #i_momy = 2
116- #driver.SetCustomSource(iSOLVER, iVar, i_node,custom_source)
117- #DensityInc_i = driver.GetSolution(iSOLVER,iPoint,2)
118- #driver.SetPointCustomSource(iSOLVER, i_node,custom_source_vector)
119-
12094
121-
122- # we get the numer of iterations:
123-
124- DensityInc_i = 1
125- # we set the actual inner iterations to 1
126- #for time_iter in range(inner_iter):
12795 for inner_iter in range (500 ):
12896
12997 # set the source term, per point
130- print ("loop over nodes and set the source term field" )
13198 for i_node in range (driver .GetNumberNodes () - driver .GetNumberHaloNodes ()):
13299 #print("node = ",i_node)
133- SolutionVector = driver .GetSolutionVector (iSOLVER ,i_node )
100+ # SolutionVector = driver.GetSolutionVector(iSOLVER,i_node)
134101 #print("solutionvector=",SolutionVector)
135102 PrimitiveVector = driver .GetPrimitiveVector (iSOLVER ,i_node )
136103 #print("primitivevector=",PrimitiveVector)
137104 DensityInc_i = PrimitiveVector [iDENSITY ]
138- #residual[iDim+1] = -Volume * (DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref;
105+
139106 for iDim in range (nDim ):
140107 custom_source_vector [iDim + 1 ] = - (DensityInc_i - DensityInc_0 ) * Body_Force_Vector [iDim ] / Force_Ref
108+
141109 #print("density=",DensityInc_i)
142110 driver .SetPointCustomSource (iSOLVER , i_node ,custom_source_vector )
143- print ("end setting custom source term" )
144-
145- # Change the total pressure.
146- #if marker_id >= 0:
147- # for i_vertex in range(driver.GetNumberMarkerNodes(marker_id)):
148- # y = driver.MarkerCoordinates(marker_id)(i_vertex, 1)
149- # t = time_iter * dt
150- # pt = 1e5 + 2e4 * y / 0.01 * (1 - math.cos(2 * math.pi * t / 0.1))
151- # driver.SetMarkerCustomInletFlowVar1(marker_id, i_vertex, pt)
152- #driver.BoundaryConditionsUpdate()
111+
153112 print (" *** inner iteration:" ,inner_iter )
154113 driver .Preprocess (inner_iter )
155114
0 commit comments