From 844b1c6aa1d481ea0a6db11a026b3a57de08208b Mon Sep 17 00:00:00 2001 From: Davor Dundovic <33790330+ddundo@users.noreply.github.com> Date: Thu, 9 May 2024 19:53:22 +0200 Subject: [PATCH] #55 Update multiple fields in indicate_errors (#191) Closes #55. --- goalie/go_mesh_seq.py | 22 ++++++++++++++-------- pyproject.toml | 1 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/goalie/go_mesh_seq.py b/goalie/go_mesh_seq.py index 36f9173..287c356 100644 --- a/goalie/go_mesh_seq.py +++ b/goalie/go_mesh_seq.py @@ -185,13 +185,19 @@ def indicate_errors( f", not type '{type(forms)}'." ) - # Loop over each strongly coupled field - for f in self.fields: - # Loop over each timestep - solutions = self.solutions.extract(layout="field") - indicators = self.indicators.extract(layout="field") - for j in range(len(solutions[f]["forward"][i])): - # Update fields + # Loop over each timestep + for j in range(self.time_partition.num_exports_per_subinterval[i] - 1): + # In case of having multiple solution fields that are solved for one + # after another, the field that is solved for first uses the values of + # latter fields from the previous timestep. Therefore, we must transfer + # the lagged solution of latter fields as if they were the current + # timestep solutions. This assumes that the order of fields being solved + # for in get_solver is the same as their order in self.fields + for f_next in self.fields[1:]: + transfer(self.solutions[f_next][FWD_OLD][i][j], u[f_next]) + # Loop over each strongly coupled field + for f in self.fields: + # Transfer solutions associated with the current field f transfer(self.solutions[f][FWD][i][j], u[f]) transfer(self.solutions[f][FWD_OLD][i][j], u_[f]) transfer(self.solutions[f][ADJ][i][j], u_star[f]) @@ -214,7 +220,7 @@ def indicate_errors( # Transfer back to the base space indi = self._transfer(indi_e, P0_spaces[i]) indi.interpolate(abs(indi)) - indicators[f][i][j].interpolate(ufl.max_value(indi, 1.0e-16)) + self.indicators[f][i][j].interpolate(ufl.max_value(indi, 1.0e-16)) return self.solutions, self.indicators diff --git a/pyproject.toml b/pyproject.toml index 94d4ab6..b3cefe9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,6 +51,7 @@ select = [ ] ignore = [ "E501", # line too long + "E203", # whitespace before ':' "E226", # missing whitespace around arithmetic operator "E402", # module level import not at top of file "E741", # ambiguous variable name