Commit 0e85dec4 authored by Lambert Theisen's avatar Lambert Theisen
Browse files

Update error handling to work for generic cases (heat stress, cpld)

parent fdbf1fdb
Pipeline #166919 passed with stages
in 8 minutes and 6 seconds
......@@ -59,91 +59,10 @@ def main():
errors = solver.errors
if params["mode"] == "heat":
# FIXME: Resolve this if statement proberly
data.append({
"h": current_mesh.mesh.hmax(),
"theta": {
"L_2": errors["f"]["l2"]["theta"],
"l_inf": errors["v"]["linf"]["theta"],
},
"sx": {
"L_2": errors["f"]["l2"]["s"][0],
"l_inf": errors["v"]["linf"]["s"][0],
},
"sy": {
"L_2": errors["f"]["l2"]["s"][1],
"l_inf": errors["v"]["linf"]["s"][1],
},
})
elif params["mode"] == "stress":
data.append({
"h": current_mesh.mesh.hmax(),
"p": {
"L_2": errors["f"]["l2"]["p"],
"l_inf": errors["v"]["linf"]["p"],
},
"ux": {
"L_2": errors["f"]["l2"]["u"][0],
"l_inf": errors["v"]["linf"]["u"][0],
},
"uy": {
"L_2": errors["f"]["l2"]["u"][1],
"l_inf": errors["v"]["linf"]["u"][1],
},
"sigmaxx": {
"L_2": errors["f"]["l2"]["sigma"][0],
"l_inf": errors["v"]["linf"]["sigma"][0],
},
"sigmaxy": {
"L_2": errors["f"]["l2"]["sigma"][1],
"l_inf": errors["v"]["linf"]["sigma"][1],
},
"sigmayy": {
"L_2": errors["f"]["l2"]["sigma"][2],
"l_inf": errors["v"]["linf"]["sigma"][2],
}
})
elif params["mode"] == "coupled":
data.append({
"h": current_mesh.mesh.hmax(),
"theta": {
"L_2": errors["f"]["l2"]["theta"],
"l_inf": errors["v"]["linf"]["theta"],
},
"sx": {
"L_2": errors["f"]["l2"]["s"][0],
"l_inf": errors["v"]["linf"]["s"][0],
},
"sy": {
"L_2": errors["f"]["l2"]["s"][1],
"l_inf": errors["v"]["linf"]["s"][1],
},
"p": {
"L_2": errors["f"]["l2"]["p"],
"l_inf": errors["v"]["linf"]["p"],
},
"ux": {
"L_2": errors["f"]["l2"]["u"][0],
"l_inf": errors["v"]["linf"]["u"][0],
},
"uy": {
"L_2": errors["f"]["l2"]["u"][1],
"l_inf": errors["v"]["linf"]["u"][1],
},
"sigmaxx": {
"L_2": errors["f"]["l2"]["sigma"][0],
"l_inf": errors["v"]["linf"]["sigma"][0],
},
"sigmaxy": {
"L_2": errors["f"]["l2"]["sigma"][1],
"l_inf": errors["v"]["linf"]["sigma"][1],
},
"sigmayy": {
"L_2": errors["f"]["l2"]["sigma"][2],
"l_inf": errors["v"]["linf"]["sigma"][2],
}
})
data.append({
"h": current_mesh.mesh.hmax(),
**errors
})
if p == len(mesh_names)-1: # after last mesh
postp = Postprocessor(data, params["case_name"])
......
......@@ -113,20 +113,7 @@ class Solver:
"u": None,
"sigma": None,
}
self.errors = {
"f": {
"l2": {
"theta": None,
"s": None,
}
},
"v": {
"linf": {
"theta": None,
"s": None,
}
}
}
self.errors = {}
def setup_function_spaces(self):
"Setup function spaces"
......@@ -462,7 +449,10 @@ class Solver:
self.write_xdmf(name_ + "_e", field_e_i)
return (err_f_L2, err_v_linf)
return {
"L_2": err_f_L2,
"l_inf": err_v_linf,
}
def calc_vectorfield_errors(sol_, sol_e_, v_sol, name_):
"TODO"
......@@ -491,7 +481,10 @@ class Solver:
self.write_xdmf(name_ + "_e", field_e_i)
return (errs_f_L2, errs_v_linf)
return [{
"L_2": errs_f_L2[i],
"l_inf": errs_v_linf[i],
} for i in range(dofs)]
def calc_tensorfield_errors(sol_, sol_e_, v_sol, name_):
"TODO"
......@@ -521,7 +514,10 @@ class Solver:
self.write_xdmf(name_ + "_e", field_e_i)
return (errs_f_L2, errs_v_linf)
return [{
"L_2": errs_f_L2[i],
"l_inf": errs_v_linf[i],
} for i in range(dofs)]
if self.mode == "heat" or self.mode == "coupled":
se = calc_scalarfield_errors(
......@@ -532,10 +528,10 @@ class Solver:
self.sol["s"], self.esol["s"],
self.fspaces["s"], "s"
)
f_l2 = self.errors["f"]["l2"]
v_linf = self.errors["v"]["linf"]
(f_l2["theta"], v_linf["theta"]) = se
(f_l2["s"], v_linf["s"]) = ve
ers = self.errors
ers["theta"] = se
ers["sx"] = ve[0]
ers["sy"] = ve[1]
if self.mode == "stress" or self.mode == "coupled":
se = calc_scalarfield_errors(
self.sol["p"], self.esol["p"],
......@@ -549,11 +545,13 @@ class Solver:
self.sol["sigma"], self.esol["sigma"],
self.fspaces["sigma"], "sigma"
)
f_l2 = self.errors["f"]["l2"]
v_linf = self.errors["v"]["linf"]
(f_l2["p"], v_linf["p"]) = se
(f_l2["u"], v_linf["u"]) = ve
(f_l2["sigma"], v_linf["sigma"]) = te
ers = self.errors
ers["p"] = se
ers["ux"] = ve[0]
ers["uy"] = ve[1]
ers["sigmaxx"] = te[0]
ers["sigmaxy"] = te[1]
ers["sigmayy"] = te[2]
def write_solutions(self):
"Write Solutions"
......
Supports Markdown
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