Skip to content

Commit

Permalink
Will *not* use new interpolate, but will switch to interpolate method
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewlhicks committed Jul 10, 2024
1 parent 32068eb commit c8b5556
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
28 changes: 14 additions & 14 deletions q3d/firedrakeplus/vis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from firedrake import (Function, FunctionSpace, SpatialCoordinate,
TensorFunctionSpace, VectorFunctionSpace, as_vector, assemble)
from firedrake.__future__ import interpolate
TensorFunctionSpace, VectorFunctionSpace, as_vector)

import q3d.saves as saves
from q3d.uflplus.fy import qtensorfy
Expand All @@ -13,20 +12,21 @@ def visualize(q_vis, mesh, *, write_outward=False, time=None, path=None, mode=No
x0, x1, x2 = SpatialCoordinate(mesh)

# get tensor form of q_vis
Q_vis = assemble(interpolate(qtensorfy(q_vis), H1_ten))
Q_vis = Function(H1_ten)
Q_vis.interpolate(qtensorfy(q_vis))

# define five elements from which to rebuild Q
Q_00 = assemble(interpolate(Q_vis[0,0], H1_scl))
Q_10 = assemble(interpolate(Q_vis[1,0], H1_scl))
Q_20 = assemble(interpolate(Q_vis[2,0], H1_scl))
Q_21 = assemble(interpolate(Q_vis[2,1], H1_scl))
Q_22 = assemble(interpolate(Q_vis[2,2], H1_scl))

Q_00.rename('Q_00')
Q_10.rename('Q_10')
Q_20.rename('Q_20')
Q_21.rename('Q_21')
Q_22.rename('Q_22')
Q_00 = Function(H1_scl, name='Q_00')
Q_10 = Function(H1_scl, name='Q_10')
Q_20 = Function(H1_scl, name='Q_20')
Q_21 = Function(H1_scl, name='Q_21')
Q_22 = Function(H1_scl, name='Q_22')

Q_00.interpolate(Q_vis[0,0])
Q_10.interpolate(Q_vis[1,0])
Q_20.interpolate(Q_vis[2,0])
Q_21.interpolate(Q_vis[2,1])
Q_22.interpolate(Q_vis[2,2])

# prepare values to write to vis file
values_to_write = [Q_00, Q_10, Q_20, Q_21, Q_22]
Expand Down
4 changes: 2 additions & 2 deletions q3d/saves.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import yaml
from firedrake import File, Function, CheckpointFile, DumbCheckpoint, FILE_READ, FILE_CREATE
from firedrake import VTKFile, Function, CheckpointFile, DumbCheckpoint, FILE_READ, FILE_CREATE

outfile = None
SaveMode = None
Expand Down Expand Up @@ -137,7 +137,7 @@ def save_pvd(*args, time=None, path=None, mode=None):
# check if outfile already created earlier. If not, create it
global outfile
if outfile is None:
outfile = File(f'{SavePath}/{path}', mode=mode)
outfile = VTKFile(f'{SavePath}/{path}', mode=mode)

# write to outfile
outfile.write(*args, time=time)
Expand Down

0 comments on commit c8b5556

Please sign in to comment.