OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
binary_reader.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 VTT Technical Research Centre of Finland Ltd
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
32#ifndef PFC_BINARY_READER_HPP
33#define PFC_BINARY_READER_HPP
34
35#include "types.hpp"
36#include <mpi.h>
37
38#include <iostream>
39
40namespace pfc {
41
43
44private:
45 MPI_Datatype m_filetype;
46
47public:
48 void set_domain(const Vec3<int> &arr_global, const Vec3<int> &arr_local,
49 const Vec3<int> &arr_offset) {
52 &m_filetype);
53 MPI_Type_commit(&m_filetype);
54 };
55
56 MPI_Status read(const std::string &filename, Field &data) {
60 MPI_INFO_NULL, &fh)) {
61 std::cout << "Unable to open file!" << std::endl;
62 }
63 MPI_File_set_view(fh, 0, MPI_DOUBLE, m_filetype, "native", MPI_INFO_NULL);
64 MPI_File_read_all(fh, data.data(), data.size(), MPI_DOUBLE, &status);
66 return status;
67 }
68};
69
70} // namespace pfc
71
72#endif // PFC_BINARY_READER_HPP
Definition binary_reader.hpp:42
Represents the global simulation domain (the "world").
Definition world.hpp:91
Common type aliases used throughout OpenPFC.