Commit bb9f56b4 authored by Baptiste Durand's avatar Baptiste Durand

Modification in C_from_levelset

using StiffnessComponentLevelSet rather than StiffnessComponent (use of StiffnessComponent = erreur d'écriture du code?)
level_set.eval(x) => level_set(x)
parent c247d221
......@@ -88,6 +88,10 @@ class StiffnessComponent(fe.UserExpression):
# ? and http://folk.uio.no/kent-and/hpl-fem-book/doc/pub/book/pdf/fem-book-4print-2up.pdf
def eval_cell(self, values, x, cell):
# if isinstance(self.cell_function, fe.MeshFunction):
# subdomain_id = self.cell_function[cell.index]
# if instance(self.cell_function, fe.Function):
# subdomain_id = self.cell_function[cell.index]
subdomain_id = self.cell_function[cell.index]
values[0] = self.mat_dict[subdomain_id].get_C()[self.i, self.j]
......@@ -191,7 +195,7 @@ class StiffnessComponentLevelSet(fe.UserExpression):
super().__init__(degree=kwargs["degree"])
def eval_cell(self, values, x, cell):
stiffness = 1 if self.level_set.eval(x) >= 0 else 0 #! A CORRIGER ! : >= .self.threshold
stiffness = 1 if self.level_set(x) >= self.threshold else 0
values[0] = self.mat_dict[stiffness].get_C()[self.i, self.j]
def value_shape(self):
......@@ -226,7 +230,7 @@ def C_from_levelset(level_set, mat_dict, topo_dim, threshold: float = 0.0):
for i in range(nb_val):
Cj = []
for j in range(nb_val):
Cj = Cj + [StiffnessComponent(level_set, mat_dict, i, j, degree=0)]
Cj = Cj + [StiffnessComponentLevelSet(level_set, mat_dict, i, j, degree=0)]
C = C + [Cj]
stiffness_matrix = fe.as_matrix(C)
return stiffness_matrix
Markdown is supported
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