Skip to content

Commit 1d31438

Browse files
committed
Formatting
1 parent fe4ec92 commit 1d31438

File tree

6 files changed

+442
-386
lines changed

6 files changed

+442
-386
lines changed

bindings/python/mgis/fenics/gradient_flux.py

+19-25
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
class QuadratureFunction:
2424
"""An abstract class for functions defined at quadrature points"""
25-
2625
def __init__(self, name, shape, hypothesis):
2726
self.shape = shape
2827
self.name = name
@@ -31,8 +30,10 @@ def __init__(self, name, shape, hypothesis):
3130
def initialize_function(self, mesh, quadrature_degree):
3231
self.quadrature_degree = quadrature_degree
3332
self.mesh = mesh
34-
self.dx = Measure("dx", metadata={"quadrature_degree": quadrature_degree})
35-
We = get_quadrature_element(mesh.ufl_cell(), quadrature_degree, self.shape)
33+
self.dx = Measure("dx",
34+
metadata={"quadrature_degree": quadrature_degree})
35+
We = get_quadrature_element(mesh.ufl_cell(), quadrature_degree,
36+
self.shape)
3637
self.function_space = FunctionSpace(mesh, We)
3738
self.function = Function(self.function_space, name=self.name)
3839

@@ -65,13 +66,12 @@ def project_on(self, space, degree, as_tensor=False, **kwargs):
6566
V = VectorFunctionSpace(self.mesh, space, degree, dim=self.shape)
6667
v = Function(V, name=self.name)
6768
v.assign(
68-
project(
69-
fun,
70-
V,
71-
form_compiler_parameters={"quadrature_degree": self.quadrature_degree},
72-
**kwargs
73-
)
74-
)
69+
project(fun,
70+
V,
71+
form_compiler_parameters={
72+
"quadrature_degree": self.quadrature_degree
73+
},
74+
**kwargs))
7575
return v
7676

7777

@@ -89,7 +89,6 @@ class Gradient(QuadratureFunction):
8989
This class is intended for internal use only. Gradient objects must be
9090
declared by the user using the registration concept.
9191
"""
92-
9392
def __init__(self, variable, expression, name, hypothesis, symmetric=None):
9493
self.variable = variable
9594
if symmetric is None:
@@ -101,17 +100,17 @@ def __init__(self, variable, expression, name, hypothesis, symmetric=None):
101100
else:
102101
converter = nonsymmetric_tensor_to_vector
103102
if hypothesis in [
104-
mgis_bv.Hypothesis.PlaneStrain,
105-
mgis_bv.Hypothesis.Axisymmetrical,
103+
mgis_bv.Hypothesis.PlaneStrain,
104+
mgis_bv.Hypothesis.Axisymmetrical,
106105
]:
107106
if ufl.shape(expression) == (2, 2):
108107
T22 = 0
109108
expression_2d = expression
110109
elif ufl.shape(expression) == (3, 3):
111110
T22 = expression[2, 2]
112111
expression_2d = ufl.as_tensor(
113-
[[expression[i, j] for j in range(2)] for i in range(2)]
114-
)
112+
[[expression[i, j] for j in range(2)]
113+
for i in range(2)])
115114
self.expression = converter(expression_2d, T22)
116115
else:
117116
self.expression = converter(expression)
@@ -144,12 +143,10 @@ def __call__(self, v):
144143
def variation(self, v):
145144
""" Directional derivative in direction v """
146145
# return ufl.algorithms.expand_derivatives(ufl.derivative(self.expression, self.variable, v))
147-
deriv = sum(
148-
[
149-
ufl.derivative(self.expression, var, v_)
150-
for (var, v_) in zip(split(self.variable), split(v))
151-
]
152-
)
146+
deriv = sum([
147+
ufl.derivative(self.expression, var, v_)
148+
for (var, v_) in zip(split(self.variable), split(v))
149+
])
153150
return ufl.algorithms.expand_derivatives(deriv)
154151

155152
def initialize_function(self, mesh, quadrature_degree):
@@ -172,7 +169,6 @@ def _evaluate_at_quadrature_points(self, x):
172169

173170
class Var(Gradient):
174171
""" A simple variable """
175-
176172
def __init__(self, variable, expression, name, hypothesis):
177173
Gradient.__init__(self, variable, expression, name, hypothesis)
178174

@@ -182,7 +178,6 @@ def _evaluate_at_quadrature_points(self, x):
182178

183179
class QuadratureFunctionTangentBlocks(QuadratureFunction):
184180
"""An abstract class for Flux and InternalStateVariables"""
185-
186181
def initialize_tangent_blocks(self, variables):
187182
self.variables = variables
188183
values = [
@@ -196,8 +191,7 @@ def initialize_tangent_blocks(self, variables):
196191
),
197192
),
198193
name="d{}_d{}".format(self.name, v.name),
199-
)
200-
for v in self.variables
194+
) for v in self.variables
201195
]
202196
keys = [v.name for v in self.variables]
203197
self.tangent_blocks = dict(zip(keys, values))

0 commit comments

Comments
 (0)