Input/Output

VTK

ClimateMachine.VTK.writevtkFunction
writevtk(prefix, Q::MPIStateArray, dg::SpaceDiscretization [, fieldnames];
number_sample_points = 0)

Write a vtk file for all the fields in the state array Q using geometry and connectivity information from dg.grid. The filename will start with prefix which may also contain a directory path. The names used for each of the fields in the vtk file can be specified through the collection of strings fieldnames; if not specified the fields names will be "Q1" through "Qk" where k is the number of states in Q, i.e., k = size(Q,2).

If number_sample_points > 0 then the fields are sampled on an equally spaced, tensor-product grid of points with 'numbersamplepoints' in each direction and the output VTK element type is set to by a VTK lagrange type.

When number_sample_points == 0 the raw nodal values are saved, and linear VTK elements are used connecting the degree of freedom boxes.

source
writevtk(prefix, Q::MPIStateArray, dg::SpaceDiscretization, fieldnames,
state_auxiliary::MPIStateArray, auxfieldnames;
number_sample_points = 0)

Write a vtk file for all the fields in the state array Q and auxiliary state state_auxiliary using geometry and connectivity information from dg.grid. The filename will start with prefix which may also contain a directory path. The names used for each of the fields in the vtk file can be specified through the collection of strings fieldnames and auxfieldnames.

If fieldnames === nothing then the fields names will be "Q1" through "Qk" where k is the number of states in Q, i.e., k = size(Q,2).

If auxfieldnames === nothing then the fields names will be "aux1" through "auxk" where k is the number of states in state_auxiliary, i.e., k = size(state_auxiliary,2).

If number_sample_points > 0 then the fields are sampled on an equally spaced, tensor-product grid of points with 'numbersamplepoints' in each direction and the output VTK element type is set to by a VTK lagrange type.

When number_sample_points == 0 the raw nodal values are saved, and linear VTK elements are used connecting the degree of freedom boxes.

source
ClimateMachine.VTK.writepvtuFunction
writepvtu(pvtuprefix, vtkprefixes, fieldnames, FT)

Write a pvtu file with the prefix 'pvtuprefix' for the collection of vtk files given by 'vtkprefixes' using names of fields 'fieldnames'. The data in the vtu files is of type FT.

source
ClimateMachine.VTK.VTKFieldWriterType
VTKFieldWriter(
name::String,
FT::DataType,
fields::Vector{<:Tuple{String, <:Function}};
path_prefix = ".",
number_sample_points = 0,
)

Construct a callable type that computes the specified fields and writes them to a VTK file in path_prefix/. number_sample_points are passed to writevtk.

Intended for use in a callback passed to a running simulation; files are suffixed with a running number beginning with 0.

Example

    function pres_fun(atmos::AtmosModel, prognostic::Vars, auxiliary::Vars)
ts = recover_thermo_state(atmos, prognostic, auxiliary)
air_pressure(ts)
end
fwriter = VTKFieldWriter(solver_config.name, [("pressure", pres_fun)])
cbfw = GenericCallbacks.EveryXSimulationTime(60) do
fwriter(solver_config.dg, solver_config.Q)
end
source

Writers

ClimateMachine.Writers.init_dataFunction
init_data(
writer,
filename,
no_overwrite,
dims,
vars,
)

Creates the specified file, initializing it with the specified dimension information. An unlimited time dimension is implicitly created. The specified variables are also defined. This function must be called before append_data(). Specialized by every Writer subtype.

Arguments:

- writer: instance of a subtype of AbstractWriter.

- filename: into which to write data (without extension).

- no_overwrite: if true, throw an error if filename exists and

would be overwritten.

- dims: Dict of dimension name to 2-tuple of dimension values and Dict

of attributes.

- vars: Dict of variable name to 3-tuple of a k-tuple of dimension

names, variable type, and Dict of attributes.

source
ClimateMachine.Writers.append_dataFunction
append_data(
writer,
filename,
varvals,
simtime,
)

Appends the specified variables to the specified file. The file must have been previously created with init_data(). simtime is appended to the time dimension variable. Specialized by every Writer subtype.

Arguments:

- writer: instance of a subtype of AbstractWriter.

- filename: into which to write data (without extension).

- varvals: Dict of variable name to k-dimensional array of values.

- simtime: Current simulation time.

source