Skip to content

Commit

Permalink
Add file writer for output
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasVin committed Jan 2, 2025
1 parent 2f3cfec commit 728db16
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tutorials/partitioned-heat-conduction/fenicsx/heat.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from my_enums import ProblemType, DomainPart
from problem_setup import get_geometry

from dolfinx.io import VTXWriter

def determine_gradient(V_g, u):
"""
Expand Down Expand Up @@ -65,7 +66,7 @@ def determine_gradient(V_g, u):

# create domain and function space
domain, coupling_boundary, remaining_boundary = get_geometry(domain_part)
V = fem.functionspace(domain, ("Lagrange", 1))
V = fem.functionspace(domain, ("Lagrange", 2))
element = basix.ufl.element("Lagrange", domain.topology.cell_name(), 1, shape=(domain.geometry.dim,))
V_g = fem.functionspace(domain, element)
W, map_to_W = V_g.sub(0).collapse()
Expand Down Expand Up @@ -178,6 +179,10 @@ def __call__(self, x):
# boundaries point as always to the end of the timestep
u_exact.t += dt
u_D.interpolate(u_exact)

# create writer for output files
vtxwriter = VTXWriter(MPI.COMM_WORLD, f"output_{problem.name}.bp", [u_n])
vtxwriter.write(t)

while precice.is_coupling_ongoing():

Expand Down Expand Up @@ -229,6 +234,7 @@ def __call__(self, x):
# Update solution at previous time step (u_n)
u_n.x.array[:] = uh.x.array
t += float(dt)
vtxwriter.write(t)

if precice.is_time_window_complete():
u_ref = fem.Function(V)
Expand All @@ -241,5 +247,6 @@ def __call__(self, x):
u_D.interpolate(u_exact)
# TODO: update time dependent f (as soon as it is time dependent)!


precice.finalize()

vtxwriter.close()

0 comments on commit 728db16

Please sign in to comment.