Skip to content

Commit

Permalink
export one first write
Browse files Browse the repository at this point in the history
  • Loading branch information
jhdark committed Nov 6, 2023
1 parent b1106db commit ee155e9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
8 changes: 0 additions & 8 deletions festim/exports/surface_flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,3 @@ def compute(self, n, ds):
)
)
self.data.append(self.value)

def initialise_export(self):
title = "Flux surface {}: {}".format(self.surface.id, self.field.name)

if self.filename is not None:
with open(self.filename, mode="w", newline="") as file:
writer = csv.writer(file)
writer.writerow(["t(s)", f"{title}"])
9 changes: 9 additions & 0 deletions festim/exports/surface_quantity.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import festim as F
import csv
import os


class SurfaceQuantity:
Expand Down Expand Up @@ -63,6 +64,14 @@ def field(self, value):
self._field = value

def write(self, t):
if not os.path.isfile(self.filename):
title = "Flux surface {}: {}".format(self.surface.id, self.field.name)

if self.filename is not None:
with open(self.filename, mode="w", newline="") as file:
writer = csv.writer(file)
writer.writerow(["t(s)", f"{title}"])

with open(self.filename, mode="a", newline="") as file:
writer = csv.writer(file)
writer.writerow([t, self.value])
2 changes: 0 additions & 2 deletions festim/hydrogen_transport_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ def initialise_exports(self):
export.define_writer(MPI.COMM_WORLD)
if isinstance(export, F.XDMFExport):
export.writer.write_mesh(self.mesh.mesh)
elif isinstance(export, F.SurfaceQuantity):
export.initialise_export()

# compute diffusivity function for surface fluxes

Expand Down

0 comments on commit ee155e9

Please sign in to comment.