-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83bd638
commit 1b9688e
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from dolfinx.io import VTXWriter | ||
import mpi4py | ||
|
||
class VTXExport: | ||
"""Export functions to VTX file | ||
Args: | ||
filename (str): the name of the output file | ||
Attributes: | ||
filename (str): the name of the output file | ||
writer (dolfinx.io.VTXWriter): the VTX writer | ||
Usage: | ||
>>> u = dolfinx.fem.Function(V) | ||
>>> my_export = festim.VTXExport("my_export.bp") | ||
>>> my_export.define_writer(mesh.comm, [u]) | ||
>>> for t in range(10): | ||
... u.interpolate(lambda x: t * (x[0] ** 2 + x[1] ** 2 + x[2] ** 2)) | ||
... my_export.write(t) | ||
""" | ||
def __init__(self, filename: str) -> None: | ||
self.filename = filename | ||
|
||
def define_writer(self, comm: mpi4py.MPI.Intracomm, functions: list) -> None: | ||
"""Define the writer | ||
Args: | ||
comm (mpi4py.MPI.Intracomm): the MPI communicator | ||
functions (list): the list of functions to export | ||
""" | ||
self.writer = VTXWriter(comm, self.filename, functions, "BP4") | ||
|
||
def write(self, t:float): | ||
"""Write functions to VTX file | ||
Args: | ||
t (float): the time of export | ||
""" | ||
self.writer.write(t) | ||