Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
output.cpp
1 // Copyright (c) Lawrence Livermore National Security, LLC and
2 // other Smith Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
8 
9 #include "axom/core.hpp"
10 #include "axom/sidre.hpp"
11 #include "mpi.h"
12 
15 
16 namespace smith::output {
17 
18 namespace detail {
19 std::string file_format_string(const FileFormat file_format)
20 {
21  std::string value = "";
22  if (file_format == FileFormat::JSON) {
23  value = "json";
24  } else if (file_format == FileFormat::YAML) {
25  value = "yaml";
26  }
27  return value;
28 }
29 } // namespace detail
30 
31 void outputSummary(const axom::sidre::DataStore& datastore, const std::string& output_directory,
32  const FileFormat file_format)
33 {
34  auto [_, rank] = getMPIInfo();
35  if (rank != 0) {
36  return;
37  }
38 
39  std::string file_format_string = detail::file_format_string(file_format);
40 
41  const std::string file_name = axom::fmt::format("summary.{0}", file_format_string);
42  const std::string path = axom::utilities::filesystem::joinPath(output_directory, file_name);
43  datastore.getRoot()->getGroup("smith_summary")->save(path, file_format_string);
44 }
45 
46 } // namespace smith::output
This file contains the interface used for retrieving information about how the driver is configured.
This file contains the all the necessary functions and macros required for logging as well as a helpe...
The output related helper functions and objects.
Definition: output.cpp:16
FileFormat
The output file formats supported.
Definition: output.hpp:29
void outputSummary(const axom::sidre::DataStore &datastore, const std::string &output_directory, const FileFormat file_format)
Outputs simulation summary data from the datastore to the given file only on rank 0.
Definition: output.cpp:31
std::pair< int, int > getMPIInfo(MPI_Comm comm)
Get MPI Info.
Definition: about.cpp:238
This file contains the all the necessary functions for outputting simulation data.