Commit cd85b968 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts Committed by Valentin Vallaeys
Browse files

slim : allow multiple export_values_at_point

parent d6fa5b6a
...@@ -161,6 +161,7 @@ class ShallowWater2dWD: ...@@ -161,6 +161,7 @@ class ShallowWater2dWD:
else: else:
dgpy.Msg.Fatal("Unknown temporal scheme "+temporal_scheme+" for shallow water equation !") dgpy.Msg.Fatal("Unknown temporal scheme "+temporal_scheme+" for shallow water equation !")
self._export_every_sub_time_step = export_every_sub_time_step self._export_every_sub_time_step = export_every_sub_time_step
self._point_exporter = []
self._evaluator = None self._evaluator = None
self._ref = [] self._ref = []
self._compute_mass = False self._compute_mass = False
...@@ -319,24 +320,11 @@ class ShallowWater2dWD: ...@@ -319,24 +320,11 @@ class ShallowWater2dWD:
""" """
if self._evaluator is None: if self._evaluator is None:
self._evaluator = dgpy.dgFunctionEvaluator(self._domain._groups, self._solution.getFunction()) self._evaluator = dgpy.dgFunctionEvaluator(self._domain._groups, self._solution.getFunction())
self._evaluator_points_x = x
self._evaluator_points_y = y
if z is None: if z is None:
z = [0.]*len(x) z = [0.]*len(x)
self._evaluator_points_z = z xyz = slim_private.np.vstack([x,y,z])
self._evaluator_output_name = output_name open(output_name,"w")
f = open(output_name, 'w') self._point_exporter += ((xyz, output_name),)
sx = "x,"
sy = "y,"
sz = "z,"
for i in range(len(x)):
sx += str(x[i])+","
sy += str(y[i])+","
sz += str(z[i])+","
f.write(sx[:-1]+'\n')
f.write(sy[:-1]+'\n')
f.write(sz[:-1]+'\n')
f.close()
def compute_mass(self,output_name): def compute_mass(self,output_name):
"""compute the total mass of the domain """compute the total mass of the domain
...@@ -434,6 +422,7 @@ class ShallowWater2d: ...@@ -434,6 +422,7 @@ class ShallowWater2d:
dgpy.Msg.Fatal("Unknown temporal scheme "+temporal_scheme+" for shallow water equation !") dgpy.Msg.Fatal("Unknown temporal scheme "+temporal_scheme+" for shallow water equation !")
self._export_every_sub_time_step = export_every_sub_time_step self._export_every_sub_time_step = export_every_sub_time_step
self._evaluator = None self._evaluator = None
self._point_exporter = []
self._ref = [] self._ref = []
self._compute_mass = False self._compute_mass = False
self._export_on_structured_grid =False self._export_on_structured_grid =False
...@@ -759,24 +748,11 @@ class ShallowWater2d: ...@@ -759,24 +748,11 @@ class ShallowWater2d:
""" """
if self._evaluator is None: if self._evaluator is None:
self._evaluator = dgpy.dgFunctionEvaluator(self._domain._groups, self._solution.getFunction()) self._evaluator = dgpy.dgFunctionEvaluator(self._domain._groups, self._solution.getFunction())
self._evaluator_points_x = x
self._evaluator_points_y = y
if z is None: if z is None:
z = [0.]*len(x) z = [0.]*len(x)
self._evaluator_points_z = z xyz = slim_private.np.vstack([x,y,z])
self._evaluator_output_name = output_name open(output_name,"w")
f = open(output_name, 'w') self._point_exporter += ((xyz, output_name),)
sx = "x,"
sy = "y,"
sz = "z,"
for i in range(len(x)):
sx += str(x[i])+","
sy += str(y[i])+","
sz += str(z[i])+","
f.write(sx[:-1]+'\n')
f.write(sy[:-1]+'\n')
f.write(sz[:-1]+'\n')
f.close()
def compute_mass(self,output_name): def compute_mass(self,output_name):
"""compute the total mass of the domain """compute the total mass of the domain
...@@ -890,6 +866,7 @@ class ShallowWaterTracer2d: ...@@ -890,6 +866,7 @@ class ShallowWaterTracer2d:
self._equation.setHydroSolution(self._hydro_sol) self._equation.setHydroSolution(self._hydro_sol)
self._export_every_sub_time_step = export_every_sub_time_step self._export_every_sub_time_step = export_every_sub_time_step
self._evaluator = None self._evaluator = None
self._point_exporter = []
self._ref = [] self._ref = []
self._compute_mass = False self._compute_mass = False
self._export_on_structured_grid =False self._export_on_structured_grid =False
...@@ -1372,18 +1349,15 @@ class Loop: ...@@ -1372,18 +1349,15 @@ class Loop:
def evaluatePoints(self): def evaluatePoints(self):
for eq in self._equations: for eq in self._equations:
if eq._evaluator is not None: for xyz, name in eq._point_exporter :
res = dgpy.fullMatrixDouble(1,eq._equation.getNbFields()) res = dgpy.fullMatrixDouble(1,eq._equation.getNbFields())
str_sol = ('%+1.10e' % self._time)+"," str_sol = ('%+1.10e' % self._time)+" "
x = eq._evaluator_points_x for i in range(xyz.shape[1]):
y = eq._evaluator_points_y eq._evaluator.compute(xyz[0,i], xyz[1,i], xyz[2,i], res)
z = eq._evaluator_points_z
for i in range(len(x)):
eq._evaluator.compute(x[i], y[i], z[i], res)
for j in range(eq._equation.getNbFields()): for j in range(eq._equation.getNbFields()):
str_sol += ('%+1.6e' % res.get(0,j))+", " str_sol += ('%+1.6e' % res.get(0,j))+" "
if (dgpy.Msg.GetCommRank() == 0): if (dgpy.Msg.GetCommRank() == 0):
f = open(eq._evaluator_output_name, 'a') f = open(name, 'a')
f.write(str_sol[:-1]+'\n') f.write(str_sol[:-1]+'\n')
f.close() f.close()
if eq._compute_mass: if eq._compute_mass:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment