OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
constant.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
29#ifndef PFC_INITIAL_CONDITIONS_CONSTANT_HPP
30#define PFC_INITIAL_CONDITIONS_CONSTANT_HPP
31
32#include "../field_modifier.hpp"
34
35namespace pfc {
36
44class Constant : public FieldModifier {
45private:
46 double m_n0;
47
48public:
52 Constant() = default;
53
59 Constant(double n0) : m_n0(n0) {}
60
65 double get_density() const { return m_n0; }
66
71 void set_density(double n0) { m_n0 = n0; }
72
81 void apply(Model &m, double t_unused) override {
82 (void)t_unused; // Silence unused parameter warning
83 // Apply constant in coordinate space over the local inbox
84 // Preserves distributed behavior and keeps API consistent with new ops
85 pfc::field::apply(m, get_field_name(),
86 [n0 = m_n0](const pfc::Real3 &) { return n0; });
87 }
88};
89
90} // namespace pfc
91
92#endif // PFC_INITIAL_CONDITIONS_CONSTANT_HPP
A class that represents a constant field modifier for use as an initial condition in a partial differ...
Definition constant.hpp:44
double get_density() const
Get the current density value.
Definition constant.hpp:65
void apply(Model &m, double t_unused) override
Apply the constant field modifier to the given model.
Definition constant.hpp:81
Constant()=default
Default constructor for the Constant class.
void set_density(double n0)
Set the density value.
Definition constant.hpp:71
Constant(double n0)
Constructor for the Constant class that sets the initial density value.
Definition constant.hpp:59
Definition field_modifier.hpp:240
The Model class represents the physics model for simulations in OpenPFC.
Definition model.hpp:95
Functional, coordinate-space field operations (header-only)
Represents the global simulation domain (the "world").
Definition world.hpp:91