josie.io.write package

Submodules

josie.io.write.strategy module

class josie.io.write.strategy.IterationStrategy(n, animate=False, serialize=True)

Bases: josie.io.write.strategy.Strategy

A Strategy that serializes every n iterations

n

The number of iterations after which we need to serialize

check_write(t, dt, solver)

Updates the state and modifies the should_write if needed.

Returns

A possibly modified dt

Return type

dt

class josie.io.write.strategy.NoopStrategy

Bases: josie.io.write.strategy.Strategy

A Strategy that never serializes anything

check_write(t, dt, solver)

Updates the state and modifies the should_write if needed.

Returns

A possibly modified dt

Return type

dt

class josie.io.write.strategy.Strategy(animate=False, serialize=True)

Bases: abc.ABC

The write strategy to use when serializing a simulation.

should_write

If True, solver must be serialized.

animate

If True, enables capturing an animation with this strategy

serialize

If True, enables serializing the solver state with this strategy

abstract check_write(t, dt, solver)

Updates the state and modifies the should_write if needed.

Returns

A possibly modified dt

Return type

dt

class josie.io.write.strategy.TimeStrategy(dt_save, animate=False, serialize=True)

Bases: josie.io.write.strategy.Strategy

A Strategy that serializes every dt_save seconds of simulated time

dt_save

The time interval after which the solver state must be serialized

t_save

Last time solver was serialized

check_write(t, dt, solver)

Updates the state and modifies the should_write if needed.

Returns

A possibly modified dt

Return type

dt

josie.io.write.writer module

class josie.io.write.writer.FileWriter(filename, strategy, solver, final_time, CFL)

Bases: josie.io.write.writer.Writer

This abstract class provides an interface to write to a file

filename

A pathlib.Path to the file to which the data needs to be serialized to

strategy

An instance of Strategy that implements a serializing strategy

solver

An instance of the solver to manage the execution of

final_time

The final time in seconds at which the simulation must end

CFL

The value of the CFL number to limit the time stepping of a specific scheme

class josie.io.write.writer.MemoryWriter(strategy, solver, final_time, CFL)

Bases: josie.io.write.writer.Writer

This class provides serialization of simulation data into State with an additional field storing time

data

The simulation data. A list of StateElement

strategy

An instance of Strategy that implements a serializing strategy

solver

An instance of the solver to manage the execution of

final_time

The final time in seconds at which the simulation must end

CFL

The value of the CFL number to limit the time stepping of a specific scheme

write()

This methods serializes the solver state to disk or else

class josie.io.write.writer.NoopWriter(solver, final_time, CFL)

Bases: josie.io.write.writer.Writer

A Writer that does not write anything

write()

This methods serializes the solver state to disk or else

class josie.io.write.writer.Writer(strategy, solver, final_time, CFL)

Bases: abc.ABC

A context manager to apply a writing strategy for a simulation

Child classes implement writing on files or in memory.

strategy

An instance of Strategy that implements a serializing strategy

solver

An instance of the solver to manage the execution of

final_time

The final time in seconds at which the simulation must end

CFL

The value of the CFL number to limit the time stepping of a specific scheme

solve()

This method updates the time instant in the Solver, the internal state of the Writer and saves current solver state to the file if needed

abstract write()

This methods serializes the solver state to disk or else

class josie.io.write.writer.XDMFWriter(filename, strategy, solver, final_time, CFL)

Bases: josie.io.write.writer.FileWriter

A class allowing to serialize simulation data to an XDMF time-series

filename

A pathlib.Path to the file to which the data needs to be serialized to

strategy

An instance of Strategy that implements a serializing strategy

solver

An instance of the solver to manage the execution of

final_time

The final time in seconds at which the simulation must end

CFL

The value of the CFL number to limit the time stepping of a specific scheme

solve()

This method updates the time instant in the Solver, the internal state of the Writer and saves current solver state to the file if needed

write()

This methods serializes the solver state to disk or else

Module contents