MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
adios2datacollection.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12// Created on: Jan 7, 2020
13// Author: William F Godoy godoywf@ornl.gov
14// adios2: Adaptable Input/Output System https://github.com/ornladios/ADIOS2
15
16#ifndef MFEM_ADIOS2DATACOLLECTION
17#define MFEM_ADIOS2DATACOLLECTION
18
19#include "../config/config.hpp"
20
21#ifdef MFEM_USE_ADIOS2
22
24#include "datacollection.hpp"
25
26#include <memory> // std::unique_ptr
27#include <string>
28
29namespace mfem
30{
31
33{
34public:
35#ifdef MFEM_USE_MPI
36 /**
37 * Parallel constructor. Important: scope of this object must be within
38 * MPI_Init and MPI_Finalize otherwise. The destructor will call the Close
39 * function. Either object must live in a try/catch block (inside try) or use
40 * raw pointers calling delete before MPI_Finalize.
41 * @param comm MPI communicator setting the datacollection domain
42 * @param collection_name unique name for saving data
43 * @param mesh can be set at the constructor level or later by calling
44 * SetMesh()
45 * @param engine_type adios2 engine type
46 */
47 ADIOS2DataCollection(MPI_Comm comm, const std::string& collection_name,
48 Mesh* mesh = nullptr,
49 const std::string engine_type = "BPFile");
50#else
51 /**
52 * Serial constructor
53 * @param collection_name unique name for saving data
54 * @param mesh can be set at the constructor level or later by calling
55 * SetMesh()
56 * @param engine_type adios2 engine type
57 * @throws std::invalid_argument (user input error) or std::runtime_error
58 * (system error)
59 */
60 ADIOS2DataCollection(const std::string& collection_name, Mesh* mesh = nullptr,
61 const std::string engine_type = "BPFile");
62#endif
63
64 virtual ~ADIOS2DataCollection();
65
66 /** Save the collection */
67 virtual void Save();
68
69 /**
70 * Pass a parameter unique to adios2datacollection
71 * For available parameters:
72 * See https://adios2.readthedocs.io/en/latest/engines/engines.html
73 * The most common is: key=SubStreams value=1 to nprocs (MPI processes)
74 * @param key parameter key
75 * @param value parameter value
76 */
77 void SetParameter(const std::string key, const std::string value) noexcept;
78
79 /**
80 * Sets the levels of detail for the global grid refinement
81 * @param levels_of_detail (default = 1)
82 */
83 void SetLevelsOfDetail(const int levels_of_detail) noexcept;
84
85private:
86 std::unique_ptr<adios2stream> stream;
87};
88
89} // namespace mfem
90
91#endif // MFEM_USE_ADIOS2
92
93#endif /* MFEM_ADIOS2DATACOLLECTION */
void SetParameter(const std::string key, const std::string value) noexcept
ADIOS2DataCollection(MPI_Comm comm, const std::string &collection_name, Mesh *mesh=nullptr, const std::string engine_type="BPFile")
void SetLevelsOfDetail(const int levels_of_detail) noexcept
Mesh * mesh
The (common) mesh for the collected fields.
Mesh data type.
Definition mesh.hpp:56