Skip to content

Commit

Permalink
Import from FEniCS and simplify code.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminRodenberg committed Nov 16, 2023
1 parent fe5d6bd commit b1f1639
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
3 changes: 1 addition & 2 deletions partitioned-heat-conduction/fenics/heat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@

from __future__ import print_function, division
from fenics import Function, FunctionSpace, Expression, Constant, DirichletBC, TrialFunction, TestFunction, \
File, solve, lhs, rhs, grad, inner, dot, dx, ds, interpolate, VectorFunctionSpace, MeshFunction, MPI
File, solve, lhs, rhs, grad, inner, dot, dx, ds, interpolate, VectorFunctionSpace, MeshFunction, MPI, MixedElement, split
from fenicsprecice import Adapter
from ufl_legacy import MixedElement, split

from errorcomputation import compute_errors
from my_enums import ProblemType, DomainPart
Expand Down
30 changes: 8 additions & 22 deletions partitioned-heat-conduction/fenics/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,13 @@ def b_splines(precice, degree, dt):
'''
# use equidistant samples
# apparently you need 2k+2 samples for degree k
x_dist = float(dt) / (2 * degree + 2)
nodes = []
nodes = np.linspace(0,dt,2*3+3) # <-- But these are 2k+3 samples
weights = []
b_splines = {}
for i in range(2 * degree + 3):
if i==0:
nodes.append(0)
weights.append(precice.read_data(0))
elif i==2*degree+2:
nodes.append(dt)
weights.append(precice.read_data(dt))
else:
nodes.append(x_dist * i)
weights.append(precice.read_data(x_dist * i))

for node in nodes:
weights.append(precice.read_data(node))

for k in weights[0].keys():
weights_k = []
for i in range(2 * degree + 3):
Expand All @@ -47,17 +40,10 @@ def b_splines_tmp(prec, u_expr, x_, y_, t_, t, degree, dt):
keys = prec.read_data(0).keys()
# use equidistant samples
# apparently you need 2k+2 samples for degree k
x_dist = float(dt) / (2 * degree + 2)
nodes = []
nodes = np.linspace(0,dt,2*3+3) # <-- But these are 2k+3 samples

b_splines = {}
# set times of samples
for i in range(2*degree+3):
if i == 0:
nodes.append(0)
elif i==2*degree+2:
nodes.append(dt)
else:
nodes.append(x_dist * i)

for k in keys:
weights = []
for i in range(2 * degree + 3):
Expand Down

0 comments on commit b1f1639

Please sign in to comment.