diff --git a/ProcessLib/Output/Output.cpp b/ProcessLib/Output/Output.cpp index 1d3e3252f3fe8f7cfaa61693b93f6184de8c093d..fbcc070499a17190bca88fc37ef8e76ab2f8418b 100644 --- a/ProcessLib/Output/Output.cpp +++ b/ProcessLib/Output/Output.cpp @@ -103,57 +103,6 @@ MeshLib::IO::PVDFile& findPVDFile( return *pvd_file; } -} // namespace ProcessLib - -namespace -{ -void outputMeshVtk(std::string const& file_name, MeshLib::Mesh const& mesh, - bool const compress_output, int const data_mode) -{ - DBUG("Writing output to '{:s}'.", file_name); - - // Store floating-point exception handling. Output of NaN's triggers - // floating point exceptions. Because we are not debugging VTK (or other - // libraries) at this point, the possibly set exceptions are temporary - // disabled and restored before end of the function. -#ifndef _WIN32 -#ifndef __APPLE__ - fenv_t fe_env; - fegetenv(&fe_env); - fesetenv(FE_DFL_ENV); // Set default environment effectively disabling - // exceptions. -#endif //_WIN32 -#endif //__APPLE__ - - MeshLib::IO::VtuInterface vtu_interface(&mesh, data_mode, compress_output); - vtu_interface.writeToFile(file_name); - - // Restore floating-point exception handling. -#ifndef _WIN32 -#ifndef __APPLE__ - fesetenv(&fe_env); -#endif //_WIN32 -#endif //__APPLE__ -} - -void outputMeshVtk(ProcessLib::OutputFile const& output_file, - MeshLib::IO::PVDFile& pvd_file, MeshLib::Mesh const& mesh, - double const t, int const timestep, int const iteration) -{ - auto const name = - output_file.constructFilename(mesh.getName(), timestep, t, iteration); - if (output_file.type == ProcessLib::OutputType::vtk) - { - pvd_file.addVTUFile(name, t); - } - - auto const path = BaseLib::joinPaths(output_file.directory, name); - outputMeshVtk(path, mesh, output_file.compression, output_file.data_mode); -} -} // namespace - -namespace ProcessLib -{ bool Output::isOutputStep(int timestep, double const t) const { auto const fixed_output_time = std::lower_bound( @@ -242,14 +191,11 @@ void Output::outputMeshes( output_file.constructPVDName(mesh.get().getName()); auto& pvd_file = findPVDFile(process, process_id, filename, _process_to_pvd_file); - ::outputMeshVtk(output_file, pvd_file, mesh, t, timestep, - iteration); + outputMeshVtk(output_file, pvd_file, mesh, t, timestep, iteration); } } else if (output_file.type == ProcessLib::OutputType::xdmf) { - std::string name = meshes[0].get().getName(); - output_file.outputMeshXdmf(_output_data_specification, std::move(meshes), timestep, t, iteration); } diff --git a/ProcessLib/Output/OutputFile.cpp b/ProcessLib/Output/OutputFile.cpp index 2a9027eec2119943af3d6c7eca918070a014931d..bf6e408d560cf9de4c8aee385393bdfc3fabb286 100644 --- a/ProcessLib/Output/OutputFile.cpp +++ b/ProcessLib/Output/OutputFile.cpp @@ -17,6 +17,50 @@ namespace ProcessLib { +void outputMeshVtk(std::string const& file_name, MeshLib::Mesh const& mesh, + bool const compress_output, int const data_mode) +{ + DBUG("Writing output to '{:s}'.", file_name); + + // Store floating-point exception handling. Output of NaN's triggers + // floating point exceptions. Because we are not debugging VTK (or other + // libraries) at this point, the possibly set exceptions are temporary + // disabled and restored before end of the function. +#ifndef _WIN32 +#ifndef __APPLE__ + fenv_t fe_env; + fegetenv(&fe_env); + fesetenv(FE_DFL_ENV); // Set default environment effectively disabling + // exceptions. +#endif //_WIN32 +#endif //__APPLE__ + + MeshLib::IO::VtuInterface vtu_interface(&mesh, data_mode, compress_output); + vtu_interface.writeToFile(file_name); + + // Restore floating-point exception handling. +#ifndef _WIN32 +#ifndef __APPLE__ + fesetenv(&fe_env); +#endif //_WIN32 +#endif //__APPLE__ +} + +void outputMeshVtk(ProcessLib::OutputFile const& output_file, + MeshLib::IO::PVDFile& pvd_file, MeshLib::Mesh const& mesh, + double const t, int const timestep, int const iteration) +{ + auto const name = + output_file.constructFilename(mesh.getName(), timestep, t, iteration); + if (output_file.type == ProcessLib::OutputType::vtk) + { + pvd_file.addVTUFile(name, t); + } + + auto const path = BaseLib::joinPaths(output_file.directory, name); + outputMeshVtk(path, mesh, output_file.compression, output_file.data_mode); +} + std::string OutputFile::constructPVDName(std::string const& mesh_name) const { return BaseLib::joinPaths( diff --git a/ProcessLib/Output/OutputFile.h b/ProcessLib/Output/OutputFile.h index 046f79373e73901e3102f04271d679399f6c2187..1f0e98038b80e92da659f1430b212c7ba06a30e2 100644 --- a/ProcessLib/Output/OutputFile.h +++ b/ProcessLib/Output/OutputFile.h @@ -53,6 +53,7 @@ struct OutputFile std::string constructFilename(std::string mesh_name, int const timestep, double const t, int const iteration) const; + void outputMeshXdmf( OutputDataSpecification const& output_data_specification, std::vector<std::reference_wrapper<const MeshLib::Mesh>> meshes, @@ -60,4 +61,7 @@ struct OutputFile std::string constructPVDName(std::string const& mesh_name) const; }; + +void outputMeshVtk(std::string const& file_name, MeshLib::Mesh const& mesh, + bool const compress_output, int const data_mode); } // namespace ProcessLib