OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
file_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_INITIAL_CONDITIONS_FILE_READER_HPP
33#define PFC_INITIAL_CONDITIONS_FILE_READER_HPP
34
35#include <iostream>
36
37#include "../binary_reader.hpp"
38#include "../field_modifier.hpp"
39
40namespace pfc {
41
42class FileReader : public FieldModifier {
43private:
44 std::string m_filename;
45
46public:
47 FileReader() = default;
48
49 void set_filename(std::string filename) { m_filename = filename; }
50 const std::string &get_filename() const { return m_filename; }
51
52 explicit FileReader(const std::string &filename) : m_filename(filename) {}
53
54 void apply(Model &m, double) override {
55 const FFT &fft = m.get_fft();
56 const auto &world = m.get_world();
57 const auto world_size = get_size(world);
58 const auto inbox_size = get_inbox(fft).size;
59 const auto inbox_offset = get_inbox(fft).low;
60
61 Field &f = m.get_real_field(get_field_name());
62 std::cout << "Reading initial condition from file" << get_filename()
63 << std::endl;
66 reader.read(get_filename(), f);
67 }
68};
69
70} // namespace pfc
71
72#endif // PFC_INITIAL_CONDITIONS_FILE_READER_HPP
Definition binary_reader.hpp:42
Definition field_modifier.hpp:240
Definition file_reader.hpp:42
void apply(Model &m, double) override
Apply the field modification to the model (pure virtual)
Definition file_reader.hpp:54
The Model class represents the physics model for simulations in OpenPFC.
Definition model.hpp:95
FFT class for distributed-memory parallel Fourier transforms.
Definition fft.hpp:248
Represents the global simulation domain (the "world").
Definition world.hpp:91