From 610338d7239c94eca5dc76b3ad00cbba15bbb5cf Mon Sep 17 00:00:00 2001 From: Saif-Ur-Rehman Date: Fri, 22 Mar 2024 15:10:49 +0100 Subject: [PATCH] solver changes --- src/fenics_constitutive/solver.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/fenics_constitutive/solver.py b/src/fenics_constitutive/solver.py index 4e7b263..28b5b02 100644 --- a/src/fenics_constitutive/solver.py +++ b/src/fenics_constitutive/solver.py @@ -94,6 +94,8 @@ def __init__( form_compiler_options: dict | None = None, jit_options: dict | None = None, ): + print("help, i am in init") + print("help, i am in init") mesh = u.function_space.mesh map_c = mesh.topology.index_map(mesh.topology.dim) num_cells = map_c.size_local + map_c.num_ghosts @@ -229,7 +231,7 @@ def __init__( @property def a(self) -> df.fem.FormMetaClass: """Compiled bilinear form (the Jacobian form)""" - + print("help, i am in a") if not hasattr(self, "_a"): # ensure compilation of UFL forms super().__init__( @@ -255,7 +257,7 @@ def form(self, x: PETSc.Vec) -> None: """ super().form(x) - + print("help, i am in form") assert ( x.array.data == self._u.vector.array.data ), "The solution vector must be the same as the one passed to the MechanicsProblem" @@ -293,14 +295,21 @@ def form(self, x: PETSc.Vec) -> None: with df.common.Timer("stress_evaluation"): self.stress_1.x.array[:] = self.stress_0.x.array - if law.history_dim is not None: + history_input = None + if isinstance(law.history_dim, int): self._history_1[0].x.array[:] = self._history_0[0].x.array + history_input = self._history_1[0].x.array + elif isinstance(law.history_dim, dict): + history_input = {} + for key in law.history_dim: + self._history_1[0][key].x.array[:] = self._history_0[0][key].x.array + history_input[key] = self._history_1[0][key].x.array law.evaluate( self._time, self._del_grad_u[0].x.array, self.stress_1.x.array, self.tangent.x.array, - self._history_1[0].x.array if law.history_dim is not None else None, + history_input, ) self.stress_1.x.scatter_forward()