Commit bf30510c authored by Tobias Meisel's avatar Tobias Meisel Committed by Lars Bilke

[MeL/IO] Process output uses new xdmf functionality

parent 8f8e2d63
......@@ -14,7 +14,8 @@
#include "BaseLib/StringTools.h"
#include "MeshLib/IO/Legacy/MeshIO.h"
#include "MeshLib/IO/VtkIO/VtuInterface.h"
#include "MeshLib/IO/XDMF/writeXdmf.h"
#include "MeshLib/IO/XDMF/Xdmf3Writer.h"
#include "MeshLib/IO/XDMF/transformData.h"
#include "MeshLib/Mesh.h"
namespace MeshLib
......
......@@ -16,9 +16,10 @@
#include <vector>
#include "Applications/InSituLib/Adaptor.h"
#include "BaseLib/Logging.h"
#include "BaseLib/FileTools.h"
#include "BaseLib/Logging.h"
#include "BaseLib/RunTime.h"
#include "MeshLib/IO/XDMF/transformData.h"
#include "ProcessLib/Process.h"
namespace
......@@ -226,9 +227,29 @@ struct Output::OutputFile
}
};
void Output::outputMeshXdmf(OutputFile const& output_file,
MeshLib::Mesh const& mesh,
const int timestep,
double const t)
{
// ToDo Refactor to a dedicated VTKOutput and XdmfOutput
// The XdmfOutput will create on contruction the Xdmf3Writer
if (!_mesh_xdmf_writer)
{
std::filesystem::path path(output_file.path);
_mesh_xdmf_writer =
std::make_unique<MeshLib::IO::Xdmf3Writer>(MeshLib::IO::Xdmf3Writer(
path, MeshLib::IO::transformGeometry(mesh),
MeshLib::IO::transformTopology(mesh),
MeshLib::IO::transformAttributes(mesh), timestep));
}
_mesh_xdmf_writer->WriteStep(timestep, t);
}
void Output::outputMesh(OutputFile const& output_file,
MeshLib::IO::PVDFile* const pvd_file,
MeshLib::Mesh const& mesh,
const int timestep,
double const t) const
{
DBUG("output to {:s}", output_file.path);
......@@ -239,7 +260,7 @@ void Output::outputMesh(OutputFile const& output_file,
}
makeOutput(output_file.path, mesh, output_file.compression,
output_file.data_mode, output_file.type);
output_file.data_mode, output_file.type, timestep, t);
}
void Output::doOutputAlways(Process const& process,
......@@ -279,17 +300,27 @@ void Output::doOutputAlways(Process const& process,
}
auto output_bulk_mesh = [&](MeshLib::Mesh& mesh) {
OutputFile const file(_output_directory, _output_file_type,
_output_file_prefix, _output_file_suffix,
mesh.getName(), timestep, t,
_output_file_data_mode, _output_file_compression);
MeshLib::IO::PVDFile* pvd_file = nullptr;
if (_output_file_type == ProcessLib::OutputType::vtk)
{
OutputFile const file(
_output_directory, _output_file_type, _output_file_prefix,
_output_file_suffix, mesh.getName(), timestep, t,
_output_file_data_mode, _output_file_compression);
pvd_file = findPVDFile(process, process_id, mesh.getName());
outputMesh(file, pvd_file, mesh, timestep, t);
}
else if (_output_file_type == ProcessLib::OutputType::xdmf)
{
OutputFile const file(
_output_directory, _output_file_type, _output_file_prefix, "",
mesh.getName(), timestep, t, _output_file_data_mode,
_output_file_compression);
outputMeshXdmf(file, mesh, timestep, t);
// this->XdmfOutputHandler = outputChangedMeshPartsToXdmf(mesh, t);
}
outputMesh(file, pvd_file, mesh, t);
};
for (auto const& mesh_output_name : _mesh_names_for_output)
......@@ -423,15 +454,15 @@ void Output::doOutputNonlinearIteration(Process const& process,
std::string const output_file_name = OutputFile::constructFilename(
_output_file_type, _output_file_prefix,
"_ts_{:timestep}_nliter_{:time}", process.getMesh().getName(), timestep,
iteration);
"_ts_{:timestep}_nliter_{:time}", process.getMesh().getName(),
timestep, iteration);
std::string const output_file_path =
BaseLib::joinPaths(_output_directory, output_file_name);
DBUG("output iteration results to {:s}", output_file_path);
makeOutput(output_file_path, process.getMesh(), _output_file_compression,
_output_file_data_mode, _output_file_type);
_output_file_data_mode, _output_file_type, timestep, t);
INFO("[time] Output took {:g} s.", time_output.elapsed());
}
} // namespace ProcessLib
......@@ -14,6 +14,7 @@
#include <utility>
#include "MeshLib/IO/VtkIO/PVDFile.h"
#include "MeshLib/IO/XDMF/Xdmf3Writer.h"
#include "ProcessOutput.h"
namespace ProcessLib
......@@ -82,11 +83,18 @@ public:
private:
struct OutputFile;
void outputMesh(OutputFile const& output_file,
MeshLib::IO::PVDFile* const pvd_file,
MeshLib::Mesh const& mesh,
const int timestep,
double const t) const;
void outputMeshXdmf(OutputFile const& output_file,
MeshLib::Mesh const& mesh,
const int timestep,
double const t);
private:
std::unique_ptr<MeshLib::IO::Xdmf3Writer>_mesh_xdmf_writer;
std::string const _output_directory;
OutputType const _output_file_type;
std::string const _output_file_prefix;
......
......@@ -251,7 +251,8 @@ void addProcessDataToMesh(
void makeOutput(std::string const& file_name, MeshLib::Mesh const& mesh,
bool const compress_output, int const data_mode,
OutputType const file_type)
OutputType const file_type, int const time_step,
double const time)
{
// Write output file
DBUG("Writing output to '{:s}'.", file_name);
......@@ -278,13 +279,18 @@ void makeOutput(std::string const& file_name, MeshLib::Mesh const& mesh,
vtu_interface.writeToFile(file_name);
break;
}
case OutputType::xdmf:
{
MeshLib::IO::writeXdmf3(mesh, file_name);
MeshLib::IO::Xdmf3Writer writer(
file_name, MeshLib::IO::transformGeometry(mesh),
MeshLib::IO::transformTopology(mesh),
MeshLib::IO::transformAttributes(mesh), time_step);
writer.WriteStep(time_step, time);
}
}
// Restore floating-point exception handling.
// Restore floating-point exception handling.
#ifndef _WIN32
#ifndef __APPLE__
fesetenv(&fe_env);
......
......@@ -53,5 +53,5 @@ enum class OutputType : uint8_t
};
void makeOutput(std::string const& file_name, MeshLib::Mesh const& mesh,
bool const compress_output, int const data_mode,
OutputType const file_type);
OutputType const file_type, int const timestep, double const t);
} // namespace ProcessLib
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment