Skip to content

Commit

Permalink
refactor code spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
wprzadka committed Sep 4, 2023
1 parent 44ee900 commit 556c4d0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
7 changes: 5 additions & 2 deletions conmech/dynamics/dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def reinitialize_matrices(self, elements_density: Optional[np.ndarray] = None):
U,
V,
self._w_matrix,
self._local_stifness_matrices
self._local_stifness_matrices,
) = get_basic_matrices(elements=self.mesh.elements, nodes=self.moved_nodes)

if elements_density is not None:
Expand All @@ -125,7 +125,10 @@ def reinitialize_matrices(self, elements_density: Optional[np.ndarray] = None):
for j, global_j in enumerate(element):
for x in (0, 1):
for y in (0, 1):
self._w_matrix[x][y][global_i, global_j] += elements_density[element_index] * self._local_stifness_matrices[2*x + y, element_index, i, j]
self._w_matrix[x][y][global_i, global_j] += (
elements_density[element_index]
* self._local_stifness_matrices[2 * x + y, element_index, i, j]
)

(
self.acceleration_operator,
Expand Down
6 changes: 4 additions & 2 deletions conmech/dynamics/factory/_dynamics_factory_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ def get_edges_features_matrix_numba(elements, nodes):

w = [[i_d_phi * j_d_phi for j_d_phi in j_d_phi_vec] for i_d_phi in i_d_phi_vec]

local_stifness_matrices[:, element_index, i, j] = element_volume * np.asarray(w).flatten()

local_stifness_matrices[:, element_index, i, j] = (
element_volume * np.asarray(w).flatten()
)

edges_features_matrix[:, element[i], element[j]] += element_volume * np.array(
[
volume_at_nodes,
Expand Down
8 changes: 5 additions & 3 deletions conmech/dynamics/factory/dynamics_factory_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ def get_basic_matrices(elements: np.ndarray, nodes: np.ndarray):
dimension = len(elements[0]) - 1
factory = get_factory(dimension)

edges_features_matrix, element_initial_volume, local_stifness_matrices = factory.get_edges_features_matrix(
elements, nodes
)
(
edges_features_matrix,
element_initial_volume,
local_stifness_matrices,
) = factory.get_edges_features_matrix(elements, nodes)

volume_at_nodes = edges_features_matrix[0]
U = edges_features_matrix[1]
Expand Down
1 change: 0 additions & 1 deletion conmech/simulations/problem_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ def solve(self, *, initial_displacement: Callable, verbose: bool = False, **kwar


class NonHomogenousSolver(StaticSolver):

def update_density(self, density: np.ndarray):
self.body.reinitialize_matrices(density)
self.refresh_solvers()
Expand Down
3 changes: 1 addition & 2 deletions examples/example_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def friction_bound(u_nu: float) -> float:
return 0

boundaries: ... = BoundariesDescription(
contact=lambda x: x[1] == 0 and x[0] < 0.2,
dirichlet=lambda x: x[0] == 0
contact=lambda x: x[1] == 0 and x[0] < 0.2, dirichlet=lambda x: x[0] == 0
)


Expand Down

0 comments on commit 556c4d0

Please sign in to comment.