30 std::string
const& property_name)
32 if (bulk_mesh == sub_mesh)
38 std::string_view(property_name)))
42 auto const& bulk_mesh_property =
44 std::string_view(property_name));
47 std::string_view mesh_item_type_string =
48 [mesh_item_type, &property_name]() -> std::string_view
50 switch (mesh_item_type)
60 "Property '{}' is assigned to edges. But mappings from the "
61 "bulk edges to submesh edges isn't implemented. Mesh item "
62 "type 'Edge' is not supported, only 'Node' and 'Cell' are "
63 "implemented at the moment.",
69 "Property '{}' is assigned to faces. But mappings from the "
70 "bulk faces to submesh faces isn't implemented. Mesh item "
71 "type 'Face' is not supported, only 'Node' and 'Cell' are "
72 "implemented at the moment.",
78 "Property '{}' is assigned to integration points. But "
79 "mappings from the bulk integration points to submesh "
80 "integration points isn't implemented. Mesh item type "
81 "'IntegrationPoint' is not supported, only 'Node' and "
82 "'Cell' are implemented at the moment.",
88 static_cast<int>(mesh_item_type));
93 if (mesh_item_type_string.empty())
98 mesh_item_type_string, mesh_item_type, 1))
101 "The property {} is required for output on the mesh {}, but it "
103 mesh_item_type_string, sub_mesh.
getName());
107 auto const& bulk_ids =
109 mesh_item_type_string);
111 auto const number_of_components =
113 auto& sub_mesh_property = *MeshLib::getOrCreateMeshProperty<double>(
114 sub_mesh, property_name, mesh_item_type, number_of_components);
116 for (std::size_t sub_mesh_node_id = 0;
117 sub_mesh_node_id < bulk_ids.getNumberOfTuples();
120 auto const& bulk_id = bulk_ids[sub_mesh_node_id];
121 for (std::remove_cv_t<
decltype(number_of_components)> c = 0;
122 c < number_of_components;
125 sub_mesh_property.getComponent(sub_mesh_node_id, c) =
126 bulk_mesh_property.getComponent(bulk_id, c);
133 auto const is_last_process =
144 bool const output_nonlinear_iteration_results,
146 std::vector<std::string>&& mesh_names_for_output,
147 std::vector<std::unique_ptr<MeshLib::Mesh>>
const& meshes)
148 : _output_format(std::move(output_format)),
149 _output_nonlinear_iteration_results(output_nonlinear_iteration_results),
150 _output_data_specification(std::move(output_data_specification)),
151 _mesh_names_for_output(std::move(mesh_names_for_output)),
166 std::string
const& property_name,
174 const int timestep,
const double t,
const int iteration,
175 std::vector<std::reference_wrapper<const MeshLib::Mesh>>
const& meshes)
181 for (
auto const& mesh : meshes)
183 for (
auto [name, property] : mesh.get().getProperties())
185 property->is_for_output =
true;
191 for (
auto const& mesh : meshes)
193 for (
auto [name, property] : mesh.get().getProperties())
195 property->is_for_output =
205 std::string
const& submesh_output_name,
Process const& process,
206 const int process_id,
double const t,
207 std::vector<GlobalVector*>
const& xs)
const
211 [&submesh_output_name](
auto const& m)
212 { return m->getName() == submesh_output_name; },
213 "Need mesh '" + submesh_output_name +
"' for the output.");
215 DBUG(
"Found {:d} nodes for output at mesh '{:s}'.",
216 submesh.getNumberOfNodes(), submesh.getName());
218 bool const output_secondary_variables =
false;
223 auto const process_output_data =
227 output_secondary_variables,
230 auto const& bulk_mesh = process.
getMesh();
231 auto const& property_names =
239 auto is_residuum_field = [](std::string
const& name) ->
bool
241 using namespace std::literals::string_view_literals;
242 static constexpr std::string_view endings[] = {
243 "FlowRate"sv,
"heat_flux"sv,
"MaterialForces"sv,
"NodalForces"sv,
244 "NodalForcesJump"sv};
245 auto ends_with = [&](std::string_view
const& ending)
246 {
return name.ends_with(ending); };
247 return std::find_if(std::begin(endings), std::end(endings),
248 ends_with) != std::end(endings);
251 for (
auto const& name : property_names)
254 {name, MeshLib::MeshItemType::Node}))
261 if (bulk_mesh.getDimension() == submesh.getDimension())
266 if (is_residuum_field(name))
283 const int process_id,
287 std::vector<GlobalVector*>
const& xs)
const
292 bool const output_secondary_variables =
true;
293 auto const process_output_data =
298 output_secondary_variables,
306 std::vector<std::reference_wrapper<const MeshLib::Mesh>> output_meshes;
312 output_meshes.emplace_back(process.
getMesh());
317 auto const& submesh =
319 output_meshes.emplace_back(submesh);
323 outputMeshes(timestep, t, iteration, std::move(output_meshes));
325 INFO(
"[time] Output of timestep {:d} took {:g} s.", timestep,
330 const int process_id,
334 std::vector<GlobalVector*>
const& xs)
const
349 const int process_id,
353 std::vector<GlobalVector*>
const& xs)
const
366 Process const& process,
const int process_id,
int const timestep,
367 const double t,
int const iteration,
368 std::vector<GlobalVector*>
const& xs)
const
378 bool const output_secondary_variable =
true;
379 auto const process_output_data =
390 std::string
const output_file_name =
_output_format->constructFilename(
393 std::string
const output_file_path =
396 DBUG(
"output iteration results to {:s}", output_file_path);
406 DBUG(
"non-linear iterations can only written in Vtk/VTU format.");
408 INFO(
"[time] Output took {:g} s.", time_output.
elapsed());
413 std::vector<std::string> output_names;
416 output_names.push_back(
424 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 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 doOutputLastTimestep(Process const &process, const int process_id, int const timestep, const double t, int const iteration, std::vector< GlobalVector * > const &xs) const
std::vector< std::string > _mesh_names_for_output
MeshLib::Mesh const & prepareSubmesh(std::string const &submesh_output_name, Process const &process, const int process_id, double const t, std::vector< GlobalVector * > const &xs) const
void doOutput(Process const &process, const int process_id, int const timestep, const double t, int const iteration, std::vector< GlobalVector * > const &xs) const
void doNotProjectFromBulkMeshToSubmeshes(std::string const &property_name, MeshLib::MeshItemType const mesh_item_type)
OutputDataSpecification _output_data_specification
void doOutputNonlinearIteration(Process const &process, const int process_id, int const timestep, const double t, const int iteration, std::vector< GlobalVector * > const &xs) const
std::vector< std::reference_wrapper< Process const > > _output_processes
bool isOutputProcess(int const process_id, Process const &process) const
std::unique_ptr< OutputFormat > _output_format
void outputMeshes(int const timestep, const double t, int const iteration, std::vector< std::reference_wrapper< const MeshLib::Mesh > > const &meshes) const
void addProcess(ProcessLib::Process const &process)
TODO doc. Opens a PVD file for each process.
Output(std::unique_ptr< OutputFormat > &&output_file, 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 _output_nonlinear_iteration_results
std::vector< std::string > getFileNamesForOutput() const
void doOutputAlways(Process const &process, const int process_id, int const timestep, const double t, int const iteration, std::vector< GlobalVector * > const &xs) const
MeshLib::Mesh & getMesh() const
bool isMonolithicSchemeUsed() const
std::iterator_traits< InputIt >::reference findElementOrError(InputIt begin, InputIt end, Predicate predicate, std::string const &error="")
std::string joinPaths(std::string const &pathA, std::string const &pathB)
void CoProcess(MeshLib::Mesh const &mesh, double const time, unsigned int const timeStep, bool const lastTimeStep, std::string output_directory)
constexpr std::string_view getBulkIDString(MeshItemType mesh_item_type)
void addProcessDataToMesh(const double 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)
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.
std::set< std::string > output_variables
All variables that shall be output.
bool isOutputStep(int timestep, double const time) const