Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/content/source/tensor_outputs/XDMFTensorOutput.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ and can be selected using the [!param](/TensorOutputs/XDMFTensorOutput/output_mo
results in a value per simulation grid cell (e.g. `N[0] * N[1] * N[2]` entries), while for node centered output
the cell edge nodes are periodically replicated, resulting in `(N[0]+1) * (N[1]+1) * (N[2]+1)` exported entries.

The [!param](/TensorOutputs/XDMFTensorOutput/interval) parameter limits the frequency of
time-step based executions in the same manner as the [!param](/Outputs/interval) option in the
standard [Moose Outputs block](syntax/Outputs/index.md). When set to `n`, the output object writes
results on every `n`-th time step while still honoring any `execute_on` settings.

## Overview

!! Replace these lines with information regarding the XDMFTensorOutput object.
Expand Down
4 changes: 4 additions & 0 deletions include/tensor_outputs/XDMFTensorOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class XDMFTensorOutput : public TensorOutput
~XDMFTensorOutput();

virtual void init() override;
virtual bool shouldRun(const ExecFlagType & execute_flag) const override;

protected:
virtual void output() override;
Expand All @@ -53,6 +54,9 @@ class XDMFTensorOutput : public TensorOutput
/// outputted frame
std::size_t _frame;

/// output interval in time steps
const unsigned int _interval;

/// transpose tensors before outputting to counter a Paraview XDMF reader ideosyncracy
const bool _transpose;

Expand Down
24 changes: 24 additions & 0 deletions src/tensor_outputs/XDMFTensorOutput.C
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ XDMFTensorOutput::validParams()
#ifdef LIBMESH_HAVE_HDF5
params.addParam<bool>("enable_hdf5", false, "Use HDF5 for binary data storage.");
#endif
params.addParam<unsigned int>(
"interval",
1,
"The number of time steps between successive outputs when executing at TIMESTEP_END.");
MultiMooseEnum outputMode("CELL NODE OVERSIZED_NODAL");
outputMode.addDocumentation("CELL", "Output as discontinuous elemental fields.");
outputMode.addDocumentation(
Expand All @@ -58,13 +62,17 @@ XDMFTensorOutput::XDMFTensorOutput(const InputParameters & parameters)
: TensorOutput(parameters),
_dim(_domain.getDim()),
_frame(0),
_interval(getParam<unsigned int>("interval")),
_transpose(getParam<bool>("transpose"))
#ifdef LIBMESH_HAVE_HDF5
,
_enable_hdf5(getParam<bool>("enable_hdf5")),
_hdf5_name(_file_base + ".h5")
#endif
{
if (_interval == 0)
paramError("interval", "The output interval must be greater than zero.");

const auto output_mode = getParam<MultiMooseEnum>("output_mode").getSetValueIDs<OutputMode>();
const auto nbuffers = _out_buffers.size();

Expand Down Expand Up @@ -106,6 +114,22 @@ XDMFTensorOutput::~XDMFTensorOutput()
#endif
}

bool
XDMFTensorOutput::shouldRun(const ExecFlagType & execute_flag) const
{
if (!TensorOutput::shouldRun(execute_flag))
return false;

if (execute_flag != EXEC_TIMESTEP_END || _interval == 1)
return true;

const auto step = _tensor_problem.timeStep();
if (step == 0)
return true;

return ((step - 1) % _interval) == 0;
}

void
XDMFTensorOutput::init()
{
Expand Down
78 changes: 78 additions & 0 deletions test/tests/cahnhilliard/gold/xdmf_interval.xmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0"?>
<Xdmf xmlns:xi="http://www.w3.org/2003/XInclude" Version="2.2">
<Domain>
<Topology TopologyType="2DCoRectMesh" Dimensions="21 21" />
<Geometry Type="ORIGIN_DXDY">
<DataItem Format="XML" Dimensions="2">0 0</DataItem>
<DataItem Format="XML" Dimensions="2">0.15 0.15</DataItem>
</Geometry>
<Grid Name="TimeSeries" GridType="Collection" CollectionType="Temporal">
<Grid Name="T0" GridType="Uniform">
<Time Value="0" />
<xi:include xpointer="xpointer(//Xdmf/Domain/Topology)" />
<xi:include xpointer="xpointer(//Xdmf/Domain/Geometry)" />
<Attribute Name="c" Center="Node">
<DataItem DataType="Float" Dimensions="21 21" Format="HDF">xdmf_interval.h5:/c.0</DataItem>
</Attribute>
<Attribute Name="mu" Center="Cell">
<DataItem DataType="Float" Dimensions="20 20" Format="HDF">xdmf_interval.h5:/mu.0</DataItem>
</Attribute>
</Grid>
<Grid Name="T1" GridType="Uniform">
<Time Value="0.001" />
<xi:include xpointer="xpointer(//Xdmf/Domain/Topology)" />
<xi:include xpointer="xpointer(//Xdmf/Domain/Geometry)" />
<Attribute Name="c" Center="Node">
<DataItem DataType="Float" Dimensions="21 21" Format="HDF">xdmf_interval.h5:/c.1</DataItem>
</Attribute>
<Attribute Name="mu" Center="Cell">
<DataItem DataType="Float" Dimensions="20 20" Format="HDF">xdmf_interval.h5:/mu.1</DataItem>
</Attribute>
</Grid>
<Grid Name="T2" GridType="Uniform">
<Time Value="0.0030000000000000001" />
<xi:include xpointer="xpointer(//Xdmf/Domain/Topology)" />
<xi:include xpointer="xpointer(//Xdmf/Domain/Geometry)" />
<Attribute Name="c" Center="Node">
<DataItem DataType="Float" Dimensions="21 21" Format="HDF">xdmf_interval.h5:/c.2</DataItem>
</Attribute>
<Attribute Name="mu" Center="Cell">
<DataItem DataType="Float" Dimensions="20 20" Format="HDF">xdmf_interval.h5:/mu.2</DataItem>
</Attribute>
</Grid>
<Grid Name="T3" GridType="Uniform">
<Time Value="0.0050000000000000001" />
<xi:include xpointer="xpointer(//Xdmf/Domain/Topology)" />
<xi:include xpointer="xpointer(//Xdmf/Domain/Geometry)" />
<Attribute Name="c" Center="Node">
<DataItem DataType="Float" Dimensions="21 21" Format="HDF">xdmf_interval.h5:/c.3</DataItem>
</Attribute>
<Attribute Name="mu" Center="Cell">
<DataItem DataType="Float" Dimensions="20 20" Format="HDF">xdmf_interval.h5:/mu.3</DataItem>
</Attribute>
</Grid>
<Grid Name="T4" GridType="Uniform">
<Time Value="0.0070000000000000001" />
<xi:include xpointer="xpointer(//Xdmf/Domain/Topology)" />
<xi:include xpointer="xpointer(//Xdmf/Domain/Geometry)" />
<Attribute Name="c" Center="Node">
<DataItem DataType="Float" Dimensions="21 21" Format="HDF">xdmf_interval.h5:/c.4</DataItem>
</Attribute>
<Attribute Name="mu" Center="Cell">
<DataItem DataType="Float" Dimensions="20 20" Format="HDF">xdmf_interval.h5:/mu.4</DataItem>
</Attribute>
</Grid>
<Grid Name="T5" GridType="Uniform">
<Time Value="0.0090000000000000011" />
<xi:include xpointer="xpointer(//Xdmf/Domain/Topology)" />
<xi:include xpointer="xpointer(//Xdmf/Domain/Geometry)" />
<Attribute Name="c" Center="Node">
<DataItem DataType="Float" Dimensions="21 21" Format="HDF">xdmf_interval.h5:/c.5</DataItem>
</Attribute>
<Attribute Name="mu" Center="Cell">
<DataItem DataType="Float" Dimensions="20 20" Format="HDF">xdmf_interval.h5:/mu.5</DataItem>
</Attribute>
</Grid>
</Grid>
</Domain>
</Xdmf>
11 changes: 11 additions & 0 deletions test/tests/cahnhilliard/tests
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@
devices = 'cpu cuda mps'
[]

[xdmf_output_interval]
type = XMLDiff
input = cahnhilliard.i
cli_args = 'TensorOutputs/active="xdmf" TensorOutputs/xdmf/interval=2 TensorOutputs/xdmf/file_base=xdmf_interval'
xmldiff = xdmf_interval.xmf
issues = '#6'
requirement = 'The system shall be able to control the frequency of XDMF outputs using an interval setting'
design = 'XDMFTensorOutput.md'
devices = 'cpu cuda mps'
[]

[xdmf_output_hdf5_threading_error]
type = RunException
input = cahnhilliard.i
Expand Down