From b1f1639fd610ac07d24fd5fab5d8db750383bd52 Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Thu, 16 Nov 2023 10:44:31 +0100 Subject: [PATCH] Import from FEniCS and simplify code. --- partitioned-heat-conduction/fenics/heat.py | 3 +- .../fenics/utils/utils.py | 30 +++++-------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/partitioned-heat-conduction/fenics/heat.py b/partitioned-heat-conduction/fenics/heat.py index b4ade6897..7ba378a2c 100644 --- a/partitioned-heat-conduction/fenics/heat.py +++ b/partitioned-heat-conduction/fenics/heat.py @@ -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 diff --git a/partitioned-heat-conduction/fenics/utils/utils.py b/partitioned-heat-conduction/fenics/utils/utils.py index 632c2a94e..6a828bc32 100644 --- a/partitioned-heat-conduction/fenics/utils/utils.py +++ b/partitioned-heat-conduction/fenics/utils/utils.py @@ -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): @@ -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):