Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog-entries/687.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added FEniCSx solver for the partitioned heat conduction tutorial following the [FEniCS solver](https://github.com/precice/tutorials/tree/develop/partitioned-heat-conduction/solver-fenics)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"participant_name": "Dirichlet",
"precice_config_file_path": "../precice-config.xml",
"interfaces": [
{
"mesh_name": "Dirichlet-Mesh",
"write_data": [
{
"name": "Heat-Flux"
}
],
"read_data": [
{
"name": "Temperature"
}
]
}
]
}
8 changes: 8 additions & 0 deletions partitioned-heat-conduction/dirichlet-fenicsx/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -e -u

python3 -m venv --system-site-packages .venv
. .venv/bin/activate
pip install -r ../solver-fenicsx/requirements.txt

python3 ../solver-fenicsx/heat.py Dirichlet
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"participant_name": "Neumann",
"precice_config_file_path": "../precice-config.xml",
"interfaces": [
{
"mesh_name": "Neumann-Mesh",
"write_data": [
{
"name": "Temperature"
}
],
"read_data": [
{
"name": "Heat-Flux"
}
]
}
]
}
7 changes: 7 additions & 0 deletions partitioned-heat-conduction/neumann-fenicsx/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
set -e -u

python3 -m venv --system-site-packages .venv
. .venv/bin/activate
pip install -r ../solver-fenicsx/requirements.txt
python3 ../solver-fenicsx/heat.py Neumann
6 changes: 6 additions & 0 deletions partitioned-heat-conduction/solver-fenicsx/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
set -e -u

. ../../tools/cleaning-tools.sh

clean_fenics .
21 changes: 21 additions & 0 deletions partitioned-heat-conduction/solver-fenicsx/errorcomputation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from dolfinx import fem
import numpy as np
from mpi4py import MPI
import ufl


def compute_errors(u_approx, u_ref, total_error_tol=10 ** -9):
mesh = u_ref.function_space.mesh
# Compute L2 error and error at nodes
error_L2 = np.sqrt(mesh.comm.allreduce(fem.assemble_scalar(fem.form((u_approx - u_ref)**2 * ufl.dx)), op=MPI.SUM))
if mesh.comm.rank == 0:
print(f"L2-error: {error_L2:.2e}")

# Compute values at mesh vertices
error_max = mesh.comm.allreduce(np.max(np.abs(u_approx.x.array - u_ref.x.array)), op=MPI.MAX)
if mesh.comm.rank == 0:
print(f"Error_max: {error_max:.2e}")

assert (error_L2 < total_error_tol)

return (error_L2, error_max)
Loading