Serac  0.1
Serac is an implicit thermal strucural mechanics simulation code.
output.cpp
1 // Copyright (c) 2019-2024, Lawrence Livermore National Security, LLC and
2 // other Serac Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
8 
12 
13 #include "axom/core.hpp"
14 #include "axom/sidre.hpp"
15 
16 #include "mpi.h"
17 
18 namespace serac::output {
19 
20 namespace detail {
21 std::string file_format_string(const FileFormat file_format)
22 {
23  std::string value = "";
24  if (file_format == FileFormat::JSON) {
25  value = "json";
26  } else if (file_format == FileFormat::YAML) {
27  value = "yaml";
28  }
29  return value;
30 }
31 } // namespace detail
32 
33 void outputSummary(const axom::sidre::DataStore& datastore, const std::string& output_directory,
34  const FileFormat file_format)
35 {
36  auto [_, rank] = getMPIInfo();
37  if (rank != 0) {
38  return;
39  }
40 
41  std::string file_format_string = detail::file_format_string(file_format);
42 
43  const std::string file_name = axom::fmt::format("summary.{0}", file_format_string);
44  const std::string path = axom::utilities::filesystem::joinPath(output_directory, file_name);
45  datastore.getRoot()->getGroup("serac_summary")->save(path, file_format_string);
46 }
47 
48 } // namespace serac::output
A function intended to be used as part of a driver to initialize common libraries.
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:18
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:33
FileFormat
The output file formats supported.
Definition: output.hpp:29
std::pair< int, int > getMPIInfo(MPI_Comm comm)
Returns the number of processes and rank for an MPI communicator.
Definition: initialize.cpp:26
This file contains the all the necessary functions for outputting simulation data.
Helper functions for exiting Serac cleanly.