From 39552c6f18e1a087514ea810aa0c37ada7eb909a Mon Sep 17 00:00:00 2001 From: wprzadka Date: Wed, 13 Sep 2023 18:04:54 -0300 Subject: [PATCH 1/2] make Mesh inherit RawMesh --- conmech/dynamics/dynamics.py | 2 +- conmech/mesh/mesh.py | 21 +++++++------ conmech/plotting/drawer.py | 10 +++---- conmech/scene/body_forces.py | 6 ++-- conmech/simulations/problem_solver.py | 30 +++++++------------ conmech/solvers/direct.py | 2 +- conmech/solvers/optimization/optimization.py | 2 +- conmech/solvers/validator.py | 2 +- conmech/state/state.py | 9 +++--- examples/error_estimates.py | 10 +++---- examples/example_nonhomogenous_density.py | 2 +- examples/example_static.py | 2 +- examples/example_temperature_dynamic_2.py | 10 +++---- .../test_Jureczka_and_Ochal_2019.py | 4 +-- .../regression/test_density_update.py | 6 ++-- tests/test_conmech/regression/test_dynamic.py | 4 +-- .../test_piezoelectric_quasistatic.py | 6 ++-- .../regression/test_quasistatic.py | 4 +-- tests/test_conmech/regression/test_static.py | 4 +-- .../regression/test_temperature_dynamic.py | 6 ++-- tests/test_conmech/unit_test/test_matrices.py | 2 +- 21 files changed, 67 insertions(+), 77 deletions(-) diff --git a/conmech/dynamics/dynamics.py b/conmech/dynamics/dynamics.py index 31e3dbb3..9dcd96b2 100644 --- a/conmech/dynamics/dynamics.py +++ b/conmech/dynamics/dynamics.py @@ -53,7 +53,7 @@ def reinitialize_matrices(self, elements_density: Optional[np.ndarray] = None): self._w_matrix, self._local_stifness_matrices, ) = get_basic_matrices( - elements=self.body.mesh.elements, nodes=self.body.mesh.initial_nodes + elements=self.body.mesh.elements, nodes=self.body.mesh.nodes ) # + self.displacement_old) if elements_density is not None: diff --git a/conmech/mesh/mesh.py b/conmech/mesh/mesh.py index 44f31a6c..289b6c29 100644 --- a/conmech/mesh/mesh.py +++ b/conmech/mesh/mesh.py @@ -7,6 +7,7 @@ from conmech.mesh.boundaries_factory import BoundariesFactory from conmech.mesh.boundaries import Boundaries from conmech.properties.mesh_description import MeshDescription +from conmech.mesh.zoo.raw_mesh import RawMesh @numba.njit @@ -82,40 +83,38 @@ def get_base_seed_indices_numba(nodes): return base_seed_indices, int(np.argmin(errors)) -# TODO make it inherit from RawMesh -class Mesh: +class Mesh(RawMesh): def __init__( self, mesh_descr: MeshDescription, boundaries_description: BoundariesDescription, ): - self.initial_nodes: np.ndarray - self.elements: np.ndarray self.edges: np.ndarray self.boundaries: Boundaries input_nodes, input_elements = mesh_builders.build_mesh(mesh_descr=mesh_descr) + super().__init__(input_nodes, input_elements) unordered_nodes, unordered_elements = remove_unconnected_nodes_numba( input_nodes, input_elements ) ( - self.initial_nodes, + self.nodes, self.elements, self.boundaries, ) = BoundariesFactory.identify_boundaries_and_reorder_nodes( unordered_nodes, unordered_elements, boundaries_description ) - edges_matrix = get_edges_matrix(nodes_count=len(self.initial_nodes), elements=self.elements) + edges_matrix = get_edges_matrix(nodes_count=len(self.nodes), elements=self.elements) self.edges = get_edges_list_numba(edges_matrix) @property def dimension(self): - return self.initial_nodes.shape[1] + return self.nodes.shape[1] @property def scale(self): - return np.max(self.initial_nodes, axis=0) - np.min(self.initial_nodes, axis=0) + return np.max(self.nodes, axis=0) - np.min(self.nodes, axis=0) def normalize_shift(self, vectors): _ = self @@ -123,7 +122,7 @@ def normalize_shift(self, vectors): @property def normalized_initial_nodes(self): - return self.normalize_shift(self.initial_nodes) + return self.normalize_shift(self.nodes) @property def input_initial_nodes(self): @@ -180,7 +179,7 @@ def boundary_indices(self): @property def initial_boundary_nodes(self): - return self.initial_nodes[self.boundary_indices] + return self.nodes[self.boundary_indices] @property def contact_indices(self): @@ -207,7 +206,7 @@ def free_indices(self): @property def nodes_count(self): - return len(self.initial_nodes) + return len(self.nodes) @property def boundary_surfaces_count(self): diff --git a/conmech/plotting/drawer.py b/conmech/plotting/drawer.py index d580f082..06118551 100644 --- a/conmech/plotting/drawer.py +++ b/conmech/plotting/drawer.py @@ -90,22 +90,22 @@ def set_axes_limits(self, axes, foundation): # pylint: disable=nested-min-max if self.x_min is None: self.x_min = min( - min(self.state.body.mesh.initial_nodes[:, 0]), min(self.state.displaced_nodes[:, 0]) + min(self.state.body.mesh.nodes[:, 0]), min(self.state.displaced_nodes[:, 0]) ) if self.x_max is None: self.x_max = max( - max(self.state.body.mesh.initial_nodes[:, 0]), max(self.state.displaced_nodes[:, 0]) + max(self.state.body.mesh.nodes[:, 0]), max(self.state.displaced_nodes[:, 0]) ) dx = self.x_max - self.x_min x_margin = dx * 0.2 xlim = (self.x_min - x_margin, self.x_max + x_margin) if self.y_min is None: self.y_min = min( - min(self.state.body.mesh.initial_nodes[:, 1]), min(self.state.displaced_nodes[:, 1]) + min(self.state.body.mesh.nodes[:, 1]), min(self.state.displaced_nodes[:, 1]) ) if self.y_max is None: self.y_max = max( - max(self.state.body.mesh.initial_nodes[:, 1]), max(self.state.displaced_nodes[:, 1]) + max(self.state.body.mesh.nodes[:, 1]), max(self.state.displaced_nodes[:, 1]) ) dy = self.y_max - self.y_min y_margin = dy * 0.2 @@ -200,7 +200,7 @@ def draw_forces(self, axes): neumann_nodes = list(set(neumann_nodes.flatten())) x = self.state.displaced_nodes[neumann_nodes] v = self.state.body.dynamics.force.outer.node_source( - self.state.body.mesh.initial_nodes, self.state.time + self.state.body.mesh.nodes, self.state.time )[neumann_nodes] scale = self.outer_forces_scale diff --git a/conmech/scene/body_forces.py b/conmech/scene/body_forces.py index 33876d92..40dd7b98 100644 --- a/conmech/scene/body_forces.py +++ b/conmech/scene/body_forces.py @@ -66,7 +66,7 @@ def clear(self): self.outer.cache = None def get_integrated_inner_forces(self, time: float): - inner_forces = self.inner.node_source(self.body.mesh.initial_nodes, time) + inner_forces = self.inner.node_source(self.body.mesh.nodes, time) # TODO: should be only on boundary! return self.body.dynamics.volume_at_nodes @ inner_forces @@ -74,9 +74,9 @@ def get_integrated_outer_forces(self, time: float): neumann_surfaces = get_surface_per_boundary_node_numba( boundary_surfaces=self.body.mesh.neumann_boundary, considered_nodes_count=self.body.mesh.nodes_count, - moved_nodes=self.body.mesh.initial_nodes, + moved_nodes=self.body.mesh.nodes, ) - outer_forces = self.outer.node_source(self.body.mesh.initial_nodes, time) + outer_forces = self.outer.node_source(self.body.mesh.nodes, time) return neumann_surfaces * outer_forces def get_integrated_field_sources_column(self, time: float): diff --git a/conmech/simulations/problem_solver.py b/conmech/simulations/problem_solver.py index dc11ea5c..9161c714 100644 --- a/conmech/simulations/problem_solver.py +++ b/conmech/simulations/problem_solver.py @@ -375,7 +375,7 @@ def solve(self, *, initial_displacement: Callable, verbose: bool = False, **kwar """ state = State(self.body) state.displacement = initial_displacement( - self.body.mesh.initial_nodes[: self.body.mesh.nodes_count] + self.body.mesh.nodes[: self.body.mesh.nodes_count] ) self.step_solver.u_vector[:] = state.displacement.T.ravel().copy() @@ -436,11 +436,9 @@ def solve( output_step = (0, *output_step) if output_step else (0, n_steps) # 0 for diff state = State(self.body) - state.absement[:] = initial_absement( - self.body.mesh.initial_nodes[: self.body.mesh.nodes_count] - ) + state.absement[:] = initial_absement(self.body.mesh.nodes[: self.body.mesh.nodes_count]) state.displacement[:] = initial_displacement( - self.body.mesh.initial_nodes[: self.body.mesh.nodes_count] + self.body.mesh.nodes[: self.body.mesh.nodes_count] ) self.step_solver.b_vector[:] = state.absement.T.ravel().copy() @@ -505,11 +503,9 @@ def solve( state: State = State(self.body) state.displacement[:] = initial_displacement( - self.body.mesh.initial_nodes[: self.body.mesh.nodes_count] - ) - state.velocity[:] = initial_velocity( - self.body.mesh.initial_nodes[: self.body.mesh.nodes_count] + self.body.mesh.nodes[: self.body.mesh.nodes_count] ) + state.velocity[:] = initial_velocity(self.body.mesh.nodes[: self.body.mesh.nodes_count]) self.step_solver.u_vector[:] = state.displacement.T.ravel().copy() self.step_solver.v_vector[:] = state.velocity.T.ravel().copy() @@ -576,13 +572,11 @@ def solve( state = TemperatureState(self.body) state.displacement[:] = initial_displacement( - self.body.mesh.initial_nodes[: self.body.mesh.nodes_count] - ) - state.velocity[:] = initial_velocity( - self.body.mesh.initial_nodes[: self.body.mesh.nodes_count] + self.body.mesh.nodes[: self.body.mesh.nodes_count] ) + state.velocity[:] = initial_velocity(self.body.mesh.nodes[: self.body.mesh.nodes_count]) state.temperature[:] = initial_temperature( - self.body.mesh.initial_nodes[: self.body.mesh.nodes_count] + self.body.mesh.nodes[: self.body.mesh.nodes_count] ) solution = state.velocity.reshape(2, -1) @@ -671,13 +665,11 @@ def solve( state = PiezoelectricState(self.body) state.displacement[:] = initial_displacement( - self.body.mesh.initial_nodes[: self.body.mesh.nodes_count] - ) - state.velocity[:] = initial_velocity( - self.body.mesh.initial_nodes[: self.body.mesh.nodes_count] + self.body.mesh.nodes[: self.body.mesh.nodes_count] ) + state.velocity[:] = initial_velocity(self.body.mesh.nodes[: self.body.mesh.nodes_count]) state.electric_potential[:] = initial_electric_potential( - self.body.mesh.initial_nodes[: self.body.mesh.nodes_count] + self.body.mesh.nodes[: self.body.mesh.nodes_count] ) solution = state.velocity.reshape(2, -1) diff --git a/conmech/solvers/direct.py b/conmech/solvers/direct.py index 71957635..69ee37ab 100644 --- a/conmech/solvers/direct.py +++ b/conmech/solvers/direct.py @@ -57,7 +57,7 @@ def _solve_impl(self, initial_guess: np.ndarray, **kwargs) -> np.ndarray: self.equation, initial_guess, args=( - self.body.mesh.initial_nodes, + self.body.mesh.nodes, self.body.mesh.contact_boundary, self.body.mesh.boundaries.contact_normals, self.node_relations, diff --git a/conmech/solvers/optimization/optimization.py b/conmech/solvers/optimization/optimization.py index d9458623..b6ae519a 100644 --- a/conmech/solvers/optimization/optimization.py +++ b/conmech/solvers/optimization/optimization.py @@ -106,7 +106,7 @@ def _solve_impl( maxiter = kwargs.get("maxiter", int(len(initial_guess) * 1e9)) tol = kwargs.get("tol", 1e-12) args = ( - self.body.mesh.initial_nodes, + self.body.mesh.nodes, self.body.mesh.contact_boundary, self.body.mesh.boundaries.contact_normals, self.lhs, diff --git a/conmech/solvers/validator.py b/conmech/solvers/validator.py index e2a6ed34..daee11e0 100644 --- a/conmech/solvers/validator.py +++ b/conmech/solvers/validator.py @@ -27,7 +27,7 @@ def validate(self, state: State, solution: np.ndarray) -> float: quality_inv = np.linalg.norm( self.rhs( solution, - state.body.mesh.initial_nodes, + state.body.mesh.nodes, state.body.mesh.contact_boundary, state.body.mesh.boundaries.contact_normals, self.elasticity, diff --git a/conmech/state/state.py b/conmech/state/state.py index dc782b81..e0513d1f 100644 --- a/conmech/state/state.py +++ b/conmech/state/state.py @@ -14,7 +14,7 @@ def __init__(self, body): self.displacement: np.ndarray = np.zeros( (self.body.mesh.nodes_count, self.body.mesh.dimension) ) - self.displaced_nodes: np.ndarray = np.copy(self.body.mesh.initial_nodes) + self.displaced_nodes: np.ndarray = np.copy(self.body.mesh.nodes) self.velocity: np.ndarray = np.zeros((self.body.mesh.nodes_count, self.body.mesh.dimension)) self.setup = None self.__stress: np.ndarray = None @@ -26,7 +26,7 @@ def set_displacement( ): self.displacement = displacement_vector.reshape((self.body.mesh.dimension, -1)).T self.displaced_nodes[: self.body.mesh.nodes_count, :] = ( - self.body.mesh.initial_nodes[: self.body.mesh.nodes_count, :] + self.displacement[:, :] + self.body.mesh.nodes[: self.body.mesh.nodes_count, :] + self.displacement[:, :] ) if update_absement: dt = time - self.time @@ -39,8 +39,7 @@ def set_velocity(self, velocity_vector: np.ndarray, time: float, *, update_displ dt = time - self.time self.displacement += dt * self.velocity self.displaced_nodes[: self.body.mesh.nodes_count, :] = ( - self.body.mesh.initial_nodes[: self.body.mesh.nodes_count, :] - + self.displacement[:, :] + self.body.mesh.nodes[: self.body.mesh.nodes_count, :] + self.displacement[:, :] ) self.time = time @@ -54,7 +53,7 @@ def stress(self): absement=self.absement, setup=self.setup, elements=self.body.mesh.elements, - nodes=self.body.mesh.initial_nodes, + nodes=self.body.mesh.nodes, time=self.time, ) return self.__stress diff --git a/examples/error_estimates.py b/examples/error_estimates.py index 5a3f9dbb..774d0466 100644 --- a/examples/error_estimates.py +++ b/examples/error_estimates.py @@ -15,8 +15,8 @@ def compare(ref: TemperatureState, sol: TemperatureState): ut = 0 tt = 0 - x = sol.body.mesh.initial_nodes[:, 0] - y = sol.body.mesh.initial_nodes[:, 1] + x = sol.body.mesh.nodes[:, 0] + y = sol.body.mesh.nodes[:, 1] soltri = tri.Triangulation(x, y, triangles=sol.body.mesh.elements) u1hi = tri.LinearTriInterpolator(soltri, sol.displacement[:, 0]) @@ -24,9 +24,9 @@ def compare(ref: TemperatureState, sol: TemperatureState): thi = tri.LinearTriInterpolator(soltri, sol.temperature) for element in ref.body.mesh.elements: - x0 = ref.body.mesh.initial_nodes[element[0]] - x1 = ref.body.mesh.initial_nodes[element[1]] - x2 = ref.body.mesh.initial_nodes[element[2]] + x0 = ref.body.mesh.nodes[element[0]] + x1 = ref.body.mesh.nodes[element[1]] + x2 = ref.body.mesh.nodes[element[2]] u1_0 = ref.displacement[element[0], 0] u1_1 = ref.displacement[element[1], 0] u1_2 = ref.displacement[element[2], 0] diff --git a/examples/example_nonhomogenous_density.py b/examples/example_nonhomogenous_density.py index 5cc6d99a..305d0fdf 100644 --- a/examples/example_nonhomogenous_density.py +++ b/examples/example_nonhomogenous_density.py @@ -51,7 +51,7 @@ def main(config: Config): elem_centers = np.empty(shape=(len(runner.body.mesh.elements), 2)) for idx, elem in enumerate(runner.body.mesh.elements): - verts = runner.body.mesh.initial_nodes[elem] + verts = runner.body.mesh.nodes[elem] elem_centers[idx] = np.sum(verts, axis=0) / len(elem) density = np.asarray([1 if x[0] < 1 else 0.2 for x in elem_centers]) diff --git a/examples/example_static.py b/examples/example_static.py index 21b5843c..8b0a2120 100644 --- a/examples/example_static.py +++ b/examples/example_static.py @@ -67,7 +67,7 @@ def main(config: Config): fig = plt.figure() axs = fig.add_subplot(111, projection="3d") # Draw nodes - nodes = state.body.mesh.initial_nodes + nodes = state.body.mesh.nodes axs.scatter(nodes[:, 0], nodes[:, 1], nodes[:, 2], c="b", marker="o") # Draw elements diff --git a/examples/example_temperature_dynamic_2.py b/examples/example_temperature_dynamic_2.py index 041c3e75..7686ca5d 100644 --- a/examples/example_temperature_dynamic_2.py +++ b/examples/example_temperature_dynamic_2.py @@ -24,8 +24,8 @@ def compute_error(ref: TemperatureState, sol: TemperatureState): - x = sol.body.mesh.initial_nodes[:, 0] - y = sol.body.mesh.initial_nodes[:, 1] + x = sol.body.mesh.nodes[:, 0] + y = sol.body.mesh.nodes[:, 1] soltri = tri.Triangulation(x, y, triangles=sol.body.mesh.elements) u1hi = tri.LinearTriInterpolator(soltri, sol.velocity[:, 0]) @@ -35,9 +35,9 @@ def compute_error(ref: TemperatureState, sol: TemperatureState): total_abs_error = np.full_like(ref.temperature, fill_value=np.nan) for element in ref.body.mesh.elements: - x0 = ref.body.mesh.initial_nodes[element[0]] - x1 = ref.body.mesh.initial_nodes[element[1]] - x2 = ref.body.mesh.initial_nodes[element[2]] + x0 = ref.body.mesh.nodes[element[0]] + x1 = ref.body.mesh.nodes[element[1]] + x2 = ref.body.mesh.nodes[element[2]] if total_abs_error[element[0]] != np.nan: total_abs_error[element[0]] = ( # abs(ref.velocity[element[0], 0] - u1hi(*x0)) # + abs(ref.velocity[element[0], 1] - u2hi(*x0)) diff --git a/tests/test_conmech/regression/test_Jureczka_and_Ochal_2019.py b/tests/test_conmech/regression/test_Jureczka_and_Ochal_2019.py index 9149e8df..a86cb719 100644 --- a/tests/test_conmech/regression/test_Jureczka_and_Ochal_2019.py +++ b/tests/test_conmech/regression/test_Jureczka_and_Ochal_2019.py @@ -72,8 +72,8 @@ def test(solving_method): fixed_point_abs_tol=0.001, initial_displacement=setup.initial_displacement ) - displacement = result.body.mesh.initial_nodes[:] - result.displaced_nodes[:] - std_ids = standard_boundary_nodes(runner.body.mesh.initial_nodes, runner.body.mesh.elements) + displacement = result.body.mesh.nodes[:] - result.displaced_nodes[:] + std_ids = standard_boundary_nodes(runner.body.mesh.nodes, runner.body.mesh.elements) # print result np.set_printoptions(precision=8, suppress=True) diff --git a/tests/test_conmech/regression/test_density_update.py b/tests/test_conmech/regression/test_density_update.py index 64f7cde6..af904520 100644 --- a/tests/test_conmech/regression/test_density_update.py +++ b/tests/test_conmech/regression/test_density_update.py @@ -22,7 +22,7 @@ def solving_method(request): def get_elem_centers(runner: NonHomogenousSolver): elem_centers = np.empty(shape=(len(runner.body.mesh.elements), 2)) for idx, elem in enumerate(runner.body.mesh.elements): - verts = runner.body.mesh.initial_nodes[elem] + verts = runner.body.mesh.nodes[elem] elem_centers[idx] = np.sum(verts, axis=0) / len(elem) return elem_centers @@ -252,8 +252,8 @@ def test_nonhomogenous_solver(solving_method, setup, density_func, expected_disp result = runner.solve(initial_displacement=setup.initial_displacement) - displacement = result.displaced_nodes[:] - result.body.mesh.initial_nodes[:] - std_ids = standard_boundary_nodes(runner.body.mesh.initial_nodes, runner.body.mesh.elements) + displacement = result.displaced_nodes[:] - result.body.mesh.nodes[:] + std_ids = standard_boundary_nodes(runner.body.mesh.nodes, runner.body.mesh.elements) # print result np.set_printoptions(precision=8, suppress=True) diff --git a/tests/test_conmech/regression/test_dynamic.py b/tests/test_conmech/regression/test_dynamic.py index 7635c467..499ab22c 100644 --- a/tests/test_conmech/regression/test_dynamic.py +++ b/tests/test_conmech/regression/test_dynamic.py @@ -181,8 +181,8 @@ def test_time_dependent_solver(solving_method, setup, expected_displacement_vect initial_velocity=setup.initial_velocity, ) - displacement = results[-1].body.mesh.initial_nodes[:] - results[-1].displaced_nodes[:] - std_ids = standard_boundary_nodes(runner.body.mesh.initial_nodes, runner.body.mesh.elements) + displacement = results[-1].body.mesh.nodes[:] - results[-1].displaced_nodes[:] + std_ids = standard_boundary_nodes(runner.body.mesh.nodes, runner.body.mesh.elements) # print result np.set_printoptions(precision=8, suppress=True) diff --git a/tests/test_conmech/regression/test_piezoelectric_quasistatic.py b/tests/test_conmech/regression/test_piezoelectric_quasistatic.py index 06b84505..88ec5a33 100644 --- a/tests/test_conmech/regression/test_piezoelectric_quasistatic.py +++ b/tests/test_conmech/regression/test_piezoelectric_quasistatic.py @@ -310,9 +310,9 @@ def test_piezoelectric_time_dependent_solver( initial_electric_potential=setup.initial_electric_potential, ) - std_ids = standard_boundary_nodes(runner.body.mesh.initial_nodes, runner.body.mesh.elements) - displacement = results[-1].body.mesh.initial_nodes[:] - results[-1].displaced_nodes[:] - electric_potential = np.zeros(len(results[-1].body.mesh.initial_nodes)) + std_ids = standard_boundary_nodes(runner.body.mesh.nodes, runner.body.mesh.elements) + displacement = results[-1].body.mesh.nodes[:] - results[-1].displaced_nodes[:] + electric_potential = np.zeros(len(results[-1].body.mesh.nodes)) electric_potential[: len(results[-1].electric_potential)] = results[-1].electric_potential # print result diff --git a/tests/test_conmech/regression/test_quasistatic.py b/tests/test_conmech/regression/test_quasistatic.py index dab640ca..d371e641 100644 --- a/tests/test_conmech/regression/test_quasistatic.py +++ b/tests/test_conmech/regression/test_quasistatic.py @@ -182,8 +182,8 @@ def test_time_dependent_solver(solving_method, setup, expected_displacement_vect initial_velocity=setup.initial_velocity, ) - displacement = results[-1].body.mesh.initial_nodes[:] - results[-1].displaced_nodes[:] - std_ids = standard_boundary_nodes(runner.body.mesh.initial_nodes, runner.body.mesh.elements) + displacement = results[-1].body.mesh.nodes[:] - results[-1].displaced_nodes[:] + std_ids = standard_boundary_nodes(runner.body.mesh.nodes, runner.body.mesh.elements) # print result np.set_printoptions(precision=8, suppress=True) diff --git a/tests/test_conmech/regression/test_static.py b/tests/test_conmech/regression/test_static.py index faa9f703..ab41fa8e 100644 --- a/tests/test_conmech/regression/test_static.py +++ b/tests/test_conmech/regression/test_static.py @@ -170,8 +170,8 @@ def test_static_solver(solving_method, setup, expected_displacement_vector): runner = StaticSolver(setup, solving_method) result = runner.solve(initial_displacement=setup.initial_displacement) - displacement = result.body.mesh.initial_nodes[:] - result.displaced_nodes[:] - std_ids = standard_boundary_nodes(runner.body.mesh.initial_nodes, runner.body.mesh.elements) + displacement = result.body.mesh.nodes[:] - result.displaced_nodes[:] + std_ids = standard_boundary_nodes(runner.body.mesh.nodes, runner.body.mesh.elements) # print result np.set_printoptions(precision=8, suppress=True) diff --git a/tests/test_conmech/regression/test_temperature_dynamic.py b/tests/test_conmech/regression/test_temperature_dynamic.py index 2a07a323..192f0727 100644 --- a/tests/test_conmech/regression/test_temperature_dynamic.py +++ b/tests/test_conmech/regression/test_temperature_dynamic.py @@ -312,9 +312,9 @@ def test_temperature_time_dependent_solver( # replace generator with collection results = tuple(result_generator) - std_ids = standard_boundary_nodes(runner.body.mesh.initial_nodes, runner.body.mesh.elements) - displacement = results[-1].body.mesh.initial_nodes[:] - results[-1].displaced_nodes[:] - temperature = np.zeros(len(results[-1].body.mesh.initial_nodes)) + std_ids = standard_boundary_nodes(runner.body.mesh.nodes, runner.body.mesh.elements) + displacement = results[-1].body.mesh.nodes[:] - results[-1].displaced_nodes[:] + temperature = np.zeros(len(results[-1].body.mesh.nodes)) temperature[: len(results[-1].temperature)] = results[-1].temperature # print result diff --git a/tests/test_conmech/unit_test/test_matrices.py b/tests/test_conmech/unit_test/test_matrices.py index 4c8807e2..59644414 100644 --- a/tests/test_conmech/unit_test/test_matrices.py +++ b/tests/test_conmech/unit_test/test_matrices.py @@ -93,7 +93,7 @@ def test_local_stiff_mats_assembly(): ) mesh = object.__new__(Mesh) - mesh.initial_nodes = initial_nodes + mesh.nodes = initial_nodes mesh.elements = elements body = object.__new__(Body) From 459a1a025e8cdb5e59f994ae460be6e27b92baaa Mon Sep 17 00:00:00 2001 From: wprzadka Date: Wed, 13 Sep 2023 21:01:18 -0300 Subject: [PATCH 2/2] fix drawer --- conmech/plotting/drawer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conmech/plotting/drawer.py b/conmech/plotting/drawer.py index 06118551..13176e2c 100644 --- a/conmech/plotting/drawer.py +++ b/conmech/plotting/drawer.py @@ -24,7 +24,7 @@ def __init__(self, state, config: Config): self.state = state self.config = config self.mesh = state.body.mesh - self.node_size = 2 + (300 / len(self.mesh.initial_nodes)) + self.node_size = 2 + (300 / len(self.mesh.nodes)) self.line_width = self.node_size / 2 self.deformed_mesh_color = "k" self.original_mesh_color = "0.7" @@ -123,7 +123,7 @@ def set_axes_limits(self, axes, foundation): def draw_meshes(self, axes): if self.original_mesh_color is not None: self.draw_mesh( - self.mesh.initial_nodes, + self.mesh.nodes, axes, label="Original", node_color=self.original_mesh_color,