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:
else:
dgpy.Msg.Fatal("Unknown temporal scheme "+temporal_scheme+" for shallow water equation !")
self._export_every_sub_time_step = export_every_sub_time_step
self._point_exporter = []
self._evaluator = None
self._ref = []
self._compute_mass = False
......@@ -319,24 +320,11 @@ class ShallowWater2dWD:
"""
if self._evaluator is None:
self._evaluator = dgpy.dgFunctionEvaluator(self._domain._groups, self._solution.getFunction())
self._evaluator_points_x = x
self._evaluator_points_y = y
if z is None:
z = [0.]*len(x)
self._evaluator_points_z = z
self._evaluator_output_name = output_name
f = open(output_name, 'w')
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()
xyz = slim_private.np.vstack([x,y,z])
open(output_name,"w")
self._point_exporter += ((xyz, output_name),)
def compute_mass(self,output_name):
"""compute the total mass of the domain
......@@ -434,6 +422,7 @@ class ShallowWater2d:
dgpy.Msg.Fatal("Unknown temporal scheme "+temporal_scheme+" for shallow water equation !")
self._export_every_sub_time_step = export_every_sub_time_step
self._evaluator = None
self._point_exporter = []
self._ref = []
self._compute_mass = False
self._export_on_structured_grid =False
......@@ -759,24 +748,11 @@ class ShallowWater2d:
"""
if self._evaluator is None:
self._evaluator = dgpy.dgFunctionEvaluator(self._domain._groups, self._solution.getFunction())
self._evaluator_points_x = x
self._evaluator_points_y = y
if z is None:
z = [0.]*len(x)
self._evaluator_points_z = z
self._evaluator_output_name = output_name
f = open(output_name, 'w')
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()
xyz = slim_private.np.vstack([x,y,z])
open(output_name,"w")
self._point_exporter += ((xyz, output_name),)
def compute_mass(self,output_name):
"""compute the total mass of the domain
......@@ -890,6 +866,7 @@ class ShallowWaterTracer2d:
self._equation.setHydroSolution(self._hydro_sol)
self._export_every_sub_time_step = export_every_sub_time_step
self._evaluator = None
self._point_exporter = []
self._ref = []
self._compute_mass = False
self._export_on_structured_grid =False
......@@ -1372,18 +1349,15 @@ class Loop:
def evaluatePoints(self):
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())
str_sol = ('%+1.10e' % self._time)+","
x = eq._evaluator_points_x
y = eq._evaluator_points_y
z = eq._evaluator_points_z
for i in range(len(x)):
eq._evaluator.compute(x[i], y[i], z[i], res)
str_sol = ('%+1.10e' % self._time)+" "
for i in range(xyz.shape[1]):
eq._evaluator.compute(xyz[0,i], xyz[1,i], xyz[2,i], res)
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):
f = open(eq._evaluator_output_name, 'a')
f = open(name, 'a')
f.write(str_sol[:-1]+'\n')
f.close()
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