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
40
namespace
pfc {
41
42
class
BinaryReader
{
43
44
private
:
45
MPI_Datatype
m_filetype;
46
47
public
:
48
void
set_domain(
const
Vec3<int>
&
arr_global
,
const
Vec3<int>
&
arr_local
,
49
const
Vec3<int>
&
arr_offset
) {
50
MPI_Type_create_subarray
(3,
arr_global
.data(),
arr_local
.data(),
51
arr_offset
.data(),
MPI_ORDER_FORTRAN
,
MPI_DOUBLE
,
52
&m_filetype);
53
MPI_Type_commit
(&m_filetype);
54
};
55
56
MPI_Status
read(
const
std::string &
filename
, Field &data) {
57
MPI_File
fh
;
58
MPI_Status
status
;
59
if
(
MPI_File_open
(
MPI_COMM_WORLD
,
filename
.c_str(),
MPI_MODE_RDONLY
,
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
);
65
MPI_File_close
(&
fh
);
66
return
status
;
67
}
68
};
69
70
}
// namespace pfc
71
72
#endif
// PFC_BINARY_READER_HPP
pfc::BinaryReader
Definition
binary_reader.hpp:42
pfc::world::World
Represents the global simulation domain (the "world").
Definition
world.hpp:91
types.hpp
Common type aliases used throughout OpenPFC.
openpfc
binary_reader.hpp
Generated by
1.9.8