Skip to content

Commit

Permalink
first implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
RemDelaporteMathurin committed Oct 13, 2023
1 parent 83bd638 commit 1b9688e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Empty file added festim/exports/__init__.py
Empty file.
40 changes: 40 additions & 0 deletions festim/exports/vtx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from dolfinx.io import VTXWriter
import mpi4py

Check warning on line 2 in festim/exports/vtx.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/vtx.py#L1-L2

Added lines #L1 - L2 were not covered by tests

class VTXExport:

Check warning on line 4 in festim/exports/vtx.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/vtx.py#L4

Added line #L4 was not covered by tests
"""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

Check warning on line 23 in festim/exports/vtx.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/vtx.py#L22-L23

Added lines #L22 - L23 were not covered by tests

def define_writer(self, comm: mpi4py.MPI.Intracomm, functions: list) -> None:

Check warning on line 25 in festim/exports/vtx.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/vtx.py#L25

Added line #L25 was not covered by tests
"""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")

Check warning on line 32 in festim/exports/vtx.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/vtx.py#L32

Added line #L32 was not covered by tests

def write(self, t:float):

Check warning on line 34 in festim/exports/vtx.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/vtx.py#L34

Added line #L34 was not covered by tests
"""Write functions to VTX file
Args:
t (float): the time of export
"""
self.writer.write(t)

Check warning on line 40 in festim/exports/vtx.py

View check run for this annotation

Codecov / codecov/patch

festim/exports/vtx.py#L40

Added line #L40 was not covered by tests

0 comments on commit 1b9688e

Please sign in to comment.