Skip to content
Snippets Groups Projects
Commit 278cee2e authored by David Seus's avatar David Seus
Browse files

there were some unstaged changes: rename Sw to Sw_exact etc. and do something with postprocessing

parent e6305c51
Branches
No related tags found
No related merge requests found
...@@ -938,12 +938,12 @@ class LDDsimulation(object): ...@@ -938,12 +938,12 @@ class LDDsimulation(object):
file.write(exact_capillary_pressure, timestep) file.write(exact_capillary_pressure, timestep)
saturation_w = df.project(S(exact_capillary_pressure), subdomain.function_space["pressure"]["wetting"]) saturation_w = df.project(S(exact_capillary_pressure), subdomain.function_space["pressure"]["wetting"])
# saturation_w.assign(Sat_w) # saturation_w.assign(Sat_w)
saturation_w.rename("Sw", "Sw") saturation_w.rename("Sw_exact", "Sw_exact")
file.write(saturation_w, timestep) file.write(saturation_w, timestep)
# S_nw = 1-S(exact_capillary_pressure).vector().get_local() # S_nw = 1-S(exact_capillary_pressure).vector().get_local()
saturation_nw = df.project(1-S(exact_capillary_pressure), subdomain.function_space["pressure"]["wetting"]) saturation_nw = df.project(1-S(exact_capillary_pressure), subdomain.function_space["pressure"]["wetting"])
# saturation_nw.assign(S_nw) # saturation_nw.assign(S_nw)
saturation_nw.rename("Snw", "Snw") saturation_nw.rename("Snw_exact", "Snw_exact")
file.write(saturation_nw, timestep) file.write(saturation_nw, timestep)
...@@ -1459,63 +1459,63 @@ class LDDsimulation(object): ...@@ -1459,63 +1459,63 @@ class LDDsimulation(object):
) )
# def post_processing(self): def post_processing(self):
# """post processing of the simulation. """post processing of the simulation.
# calculate calculate
# - pc_exact and pc_num - pc_exact and pc_num
# - absolute differences to exact solution if present. - absolute differences to exact solution if present.
# - relative errors to exact solution if present - relative errors to exact solution if present
# """ """
# for subdom_ind, subdomain in self.subdomain.items(): for subdom_ind, subdomain in self.subdomain.items():
# self._mesh = df.Mesh() self._mesh = df.Mesh()
# solution_file = self.solution_file[subdom_ind] solution_file = self.solution_file[subdom_ind]
# post_solution_file = self.postprocessed_solution_file[subdom_ind] post_solution_file = self.postprocessed_solution_file[subdom_ind]
# pressure = dict() pressure = dict()
# # the internal time series counter in df.XDMFFile starts at 0 and # the internal time series counter in df.XDMFFile starts at 0 and
# # refers to the first saved value. This corresponds to the initial # refers to the first saved value. This corresponds to the initial
# # values. We then calculated self.number_of_timesteps many timesteps. # values. We then calculated self.number_of_timesteps many timesteps.
# t = self.starttime t = self.starttime
# for internal_timestep in range(self.number_of_timesteps+1): for internal_timestep in range(self.number_of_timesteps+1):
for phase in subdomain.has_phases:
pressure.update(
{phase: df.Function(subdomain.function_space["pressure"][phase])}
)
phase_pressure_string = "pressure_"+"{}".format(phase)
solution_file.read_checkpoint(
u=pressure[phase],
name=phase_pressure_string,
counter=internal_timestep
)
pressure[phase].rename("pressure_"+"{}".format(phase), "pressure_"+"{}".format(phase))
post_solution_file.write(pressure[phase], t)
t += self.timestep_size
print(f"read pressure of {phase}phase:")
print(pressure[phase].vector()[:])
solution_file.close()
# # if we have an exact solution, write out the |u -uh|_L2 to see the
# # absolute error.
# if subdomain.pressure_exact is not None:
# relative_L2_errornorm = dict()
# for phase in subdomain.has_phases: # for phase in subdomain.has_phases:
# pressure.update( # pa_exact = subdomain.pressure_exact[phase]
# {phase: df.Function(subdomain.function_space["pressure"][phase])} # pa_exact.t = self.t
# norm_pa_exact = df.norm(pa_exact, norm_type='L2', mesh=subdomain.mesh)
# error_calculated = df.errornorm(pa_exact, subdomain.pressure[phase], 'L2', degree_rise=6)
# if norm_pa_exact > self.tol:
# relative_L2_errornorm.update(
# {phase: error_calculated/norm_pa_exact}
# )
# else:
# relative_L2_errornorm.update(
# {phase: error_calculated}
# ) # )
# phase_pressure_string = "pressure_"+"{}".format(phase) # errornorm_filename = self.output_dir+self.output_filename_parameter_part[subdom_ind]+\
# solution_file.read_checkpoint( # "_L2_errornorms_over_time" +".csv"
# u=pressure[phase], # self.write_errornorms_to_csv(
# name=phase_pressure_string, # filename = errornorm_filename, #
# counter=internal_timestep # subdomain_index = subdom_ind,
# errors = relative_L2_errornorm,
# ) # )
# pressure[phase].rename("pressure_"+"{}".format(phase), "pressure_"+"{}".format(phase))
# post_solution_file.write(pressure[phase], t)
# t += self.timestep_size
# print(f"read pressure of {phase}phase:")
# print(pressure[phase].vector()[:])
# solution_file.close()
# # # if we have an exact solution, write out the |u -uh|_L2 to see the
# # # absolute error.
# # if subdomain.pressure_exact is not None:
# # relative_L2_errornorm = dict()
# # for phase in subdomain.has_phases:
# # pa_exact = subdomain.pressure_exact[phase]
# # pa_exact.t = self.t
# # norm_pa_exact = df.norm(pa_exact, norm_type='L2', mesh=subdomain.mesh)
# # error_calculated = df.errornorm(pa_exact, subdomain.pressure[phase], 'L2', degree_rise=6)
# # if norm_pa_exact > self.tol:
# # relative_L2_errornorm.update(
# # {phase: error_calculated/norm_pa_exact}
# # )
# # else:
# # relative_L2_errornorm.update(
# # {phase: error_calculated}
# # )
# # errornorm_filename = self.output_dir+self.output_filename_parameter_part[subdom_ind]+\
# # "_L2_errornorms_over_time" +".csv"
# # self.write_errornorms_to_csv(
# # filename = errornorm_filename, #
# # subdomain_index = subdom_ind,
# # errors = relative_L2_errornorm,
# # )
def _init_exact_solution_expression(self): def _init_exact_solution_expression(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment