16#include <range/v3/algorithm/transform.hpp>
17#include <range/v3/range/conversion.hpp>
34 std::string
const& property_name)
36 if (bulk_mesh == sub_mesh)
42 std::string_view(property_name)))
46 auto const& bulk_mesh_property =
48 std::string_view(property_name));
51 std::string_view mesh_item_type_string =
52 [mesh_item_type, &property_name]() -> std::string_view
54 switch (mesh_item_type)
64 "Property '{}' is assigned to edges. But mappings from the "
65 "bulk edges to submesh edges isn't implemented. Mesh item "
66 "type 'Edge' is not supported, only 'Node' and 'Cell' are "
67 "implemented at the moment.",
73 "Property '{}' is assigned to faces. But mappings from the "
74 "bulk faces to submesh faces isn't implemented. Mesh item "
75 "type 'Face' is not supported, only 'Node' and 'Cell' are "
76 "implemented at the moment.",
82 "Property '{}' is assigned to integration points. But "
83 "mappings from the bulk integration points to submesh "
84 "integration points isn't implemented. Mesh item type "
85 "'IntegrationPoint' is not supported, only 'Node' and "
86 "'Cell' are implemented at the moment.",
92 static_cast<int>(mesh_item_type));
97 if (mesh_item_type_string.empty())
102 mesh_item_type_string, mesh_item_type, 1))
105 "The property {} is required for output on the mesh {}, but it "
107 mesh_item_type_string, sub_mesh.
getName());
111 auto const& bulk_ids =
113 mesh_item_type_string);
115 auto const number_of_components =
118 sub_mesh, property_name, mesh_item_type, number_of_components);
120 for (std::size_t sub_mesh_node_id = 0;
121 sub_mesh_node_id < bulk_ids.getNumberOfTuples();
124 auto const& bulk_id = bulk_ids[sub_mesh_node_id];
125 for (std::remove_cv_t<
decltype(number_of_components)> c = 0;
126 c < number_of_components;
129 sub_mesh_property.getComponent(sub_mesh_node_id, c) =
130 bulk_mesh_property.getComponent(bulk_id, c);
137 auto const is_last_process =
148 bool const output_nonlinear_iteration_results,
150 std::vector<std::string>&& mesh_names_for_output,
151 std::vector<std::unique_ptr<MeshLib::Mesh>>
const& meshes)
152 : _output_format(std::move(output_format)),
153 _output_nonlinear_iteration_results(output_nonlinear_iteration_results),
154 _output_data_specification(std::move(output_data_specification)),
155 _mesh_names_for_output(std::move(mesh_names_for_output)),
170 std::string
const& property_name,
178 const int timestep,
const double t,
const int iteration,
179 bool const converged,
180 std::vector<std::reference_wrapper<const MeshLib::Mesh>>
const& meshes)
186 for (
auto const& mesh : meshes)
188 for (
auto [name, property] : mesh.get().getProperties())
190 property->is_for_output =
true;
196 for (
auto const& mesh : meshes)
198 for (
auto [name, property] : mesh.get().getProperties())
201 if (name ==
"OGS_VERSION")
203 property->is_for_output =
true;
207 property->is_for_output =
212 _output_format->outputMeshes(timestep, t, iteration, converged, meshes,
217 std::string
const& submesh_output_name,
Process const& process,
219 std::vector<GlobalVector*>
const& xs)
const
223 DBUG(
"Found {:d} nodes for output at mesh '{:s}'.",
224 submesh.getNumberOfNodes(), submesh.getName());
226 bool const output_secondary_variables =
false;
231 auto const process_output_data =
235 output_secondary_variables,
238 auto const& bulk_mesh = process.
getMesh();
239 auto const& property_names =
247 auto is_residuum_field = [](std::string
const& name) ->
bool
249 using namespace std::literals::string_view_literals;
250 static constexpr std::string_view endings[] = {
251 "FlowRate"sv,
"heat_flux"sv,
"MaterialForces"sv,
"NodalForces"sv,
252 "NodalForcesJump"sv};
253 auto ends_with = [&](std::string_view
const& ending)
254 {
return name.ends_with(ending); };
255 return std::find_if(std::begin(endings), std::end(endings),
256 ends_with) != std::end(endings);
259 for (
auto const& name : property_names)
262 {name, MeshLib::MeshItemType::Node}))
269 if (bulk_mesh.getDimension() == submesh.getDimension())
274 if (is_residuum_field(name))
291 const int process_id,
295 bool const converged,
296 std::vector<GlobalVector*>
const& xs)
const
301 bool const output_secondary_variables =
true;
302 auto const process_output_data =
307 output_secondary_variables,
315 std::vector<std::reference_wrapper<const MeshLib::Mesh>> output_meshes;
321 output_meshes.emplace_back(process.
getMesh());
326 auto const& submesh =
328 output_meshes.emplace_back(submesh);
332 outputMeshes(timestep, t(), iteration, converged, std::move(output_meshes));
334 INFO(
"[time] Output of timestep {:d} took {:g} s.", timestep,
339 const int process_id,
343 bool const converged,
344 std::vector<GlobalVector*>
const& xs)
const
348 doOutputAlways(process, process_id, timestep, t, iteration, converged,
360 const int process_id,
364 bool const converged,
365 std::vector<GlobalVector*>
const& xs)
const
369 doOutputAlways(process, process_id, timestep, t, iteration, converged,
379 Process const& process,
const int process_id,
int const timestep,
380 const NumLib::Time& t,
int const iteration,
bool const converged,
381 std::vector<GlobalVector*>
const& xs)
const
391 bool const output_secondary_variable =
true;
392 auto const process_output_data =
403 std::string
const output_file_name =
_output_format->constructFilename(
404 process.
getMesh().
getName(), timestep, t(), iteration, converged);
406 std::string
const output_file_path =
409 DBUG(
"output iteration results to {:s}", output_file_path);
419 DBUG(
"non-linear iterations can only written in Vtk/VTU format.");
421 INFO(
"[time] Output took {:g} s.", time_output.
elapsed());
431 auto construct_filename = ranges::views::transform(
432 [&](
auto const& output_name) {
438 ranges::to<std::vector>;
442 std::vector<Output>
const& outputs)
444 std::vector<double> fixed_times;
445 for (
auto const& output : outputs)
447 auto const& output_fixed_times = output.getFixedOutputTimes();
448 fixed_times.insert(fixed_times.end(), output_fixed_times.begin(),
449 output_fixed_times.end());
457 os <<
"Output::_output_data_specification:\t"
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Mesh class.
Definition of the RunTime class.
double elapsed() const
Get the elapsed time in seconds.
void start()
Start the timer.
Properties & getProperties()
const std::string getName() const
Get name of the mesh.
std::vector< std::string > getPropertyVectorNames() const
bool existsPropertyVector(std::string_view name) const
PropertyVector< T > const * getPropertyVector(std::string_view name) const
MeshItemType getMeshItemType() const
int getNumberOfGlobalComponents() const
std::set< std::pair< std::string, MeshLib::MeshItemType > > _do_not_project_from_bulk_mesh_to_submeshes
std::reference_wrapper< std::vector< std::unique_ptr< MeshLib::Mesh > > const > _meshes
void doOutputAlways(Process const &process, const int process_id, int const timestep, const NumLib::Time &t, int const iteration, bool const converged, std::vector< GlobalVector * > const &xs) const
void doOutput(Process const &process, const int process_id, int const timestep, const NumLib::Time &t, int const iteration, bool const converged, std::vector< GlobalVector * > const &xs) const
void doOutputNonlinearIteration(Process const &process, const int process_id, int const timestep, const NumLib::Time &t, const int iteration, bool const converged, std::vector< GlobalVector * > const &xs) const
std::vector< std::string > _mesh_names_for_output
void doOutputLastTimestep(Process const &process, const int process_id, int const timestep, const NumLib::Time &t, int const iteration, bool const converged, std::vector< GlobalVector * > const &xs) const
void outputMeshes(int const timestep, const double t, int const iteration, bool const converged, std::vector< std::reference_wrapper< const MeshLib::Mesh > > const &meshes) const
void doNotProjectFromBulkMeshToSubmeshes(std::string const &property_name, MeshLib::MeshItemType const mesh_item_type)
OutputDataSpecification _output_data_specification
std::vector< std::reference_wrapper< Process const > > _output_processes
MeshLib::Mesh const & prepareSubmesh(std::string const &submesh_output_name, Process const &process, const int process_id, NumLib::Time const &t, std::vector< GlobalVector * > const &xs) const
Output(std::unique_ptr< OutputFormat > &&output_format, bool const output_nonlinear_iteration_results, OutputDataSpecification &&output_data_specification, std::vector< std::string > &&mesh_names_for_output, std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes)
bool isOutputProcess(int const process_id, Process const &process) const
std::unique_ptr< OutputFormat > _output_format
void addProcess(ProcessLib::Process const &process)
TODO doc. Opens a PVD file for each process.
bool _output_nonlinear_iteration_results
std::vector< std::string > getFileNamesForOutput() const
bool isOutputStep(int const timestep, NumLib::Time const &t) const
Tells if output will be written at the specified timestep/time.
MeshLib::Mesh & getMesh() const
virtual bool isMonolithicSchemeUsed() const
std::string joinPaths(std::string const &pathA, std::string const &pathB)
void makeVectorUnique(std::vector< T > &v)
void CoProcess(MeshLib::Mesh const &mesh, double const time, unsigned int const timeStep, bool const lastTimeStep, std::string output_directory)
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)
Mesh & findMeshByName(std::vector< std::unique_ptr< Mesh > > const &meshes, std::string_view const name)
constexpr std::string_view getBulkIDString(MeshItemType mesh_item_type)
void addProcessDataToMesh(NumLib::Time const &t, std::vector< GlobalVector * > const &xs, int const process_id, ProcessOutputData const &process_output_data, bool const output_secondary_variables, OutputDataSpecification const &process_output)
ProcessOutputData createProcessOutputData(Process const &process, std::size_t const n_processes, MeshLib::Mesh &output_mesh)
Extracts data necessary for output from the given process.
std::ostream & operator<<(std::ostream &os, Output const &output)
void outputMeshVtk(std::string const &file_name, MeshLib::Mesh const &mesh, bool const compress_output, int const data_mode)
std::vector< double > calculateUniqueFixedTimesForAllOutputs(std::vector< Output > const &outputs)
void addBulkMeshPropertyToSubMesh(MeshLib::Mesh const &bulk_mesh, MeshLib::Mesh &sub_mesh, std::string const &property_name)
Holds information about which variables to write to output files.
bool isOutputStep(int timestep, NumLib::Time const &time) const
std::set< std::string > output_variables
All variables that shall be output.