PSCF v1.2
rpc/scft/sweep/FieldState.h
1#ifndef RPC_FIELD_STATE_H
2#define RPC_FIELD_STATE_H
3
4/*
5* PSCF - Polymer Self-Consistent Field Theory
6*
7* Copyright 2016 - 2021, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <rpc/field/FieldIo.h> // member
12#include <prdc/crystal/UnitCell.h> // member
13#include <util/containers/DArray.h> // member template
14
15namespace Pscf {
16namespace Rpc
17{
18
19 using namespace Util;
20 using namespace Pscf::Prdc;
21
22 template <int D> class System;
23
40 template <int D, class FT>
42 {
43
44 public:
45
48
52 FieldState();
53
62
67
74
78
84 const DArray<FT>& fields() const;
85
92
98 const FT& field(int monomerId) const;
99
105 FT& field(int monomerId);
106
110 const UnitCell<D>& unitCell() const;
111
116
118
119 protected:
120
124 bool hasSystem();
125
130
131 private:
132
136 DArray<FT> fields_;
137
141 UnitCell<D> unitCell_;
142
146 System<D>* systemPtr_;
147
148 };
149
150 // Public inline member functions
151
152 // Get an array of all fields (const reference)
153 template <int D, class FT>
154 inline
156 { return fields_; }
157
158 // Get an array of all fields (non-const reference)
159 template <int D, class FT>
160 inline
162 { return fields_; }
163
164 // Get field for monomer type id (const reference)
165 template <int D, class FT>
166 inline
167 const FT& FieldState<D,FT>::field(int id) const
168 { return fields_[id]; }
169
170 // Get field for monomer type id (non-const reference)
171 template <int D, class FT>
172 inline FT& FieldState<D,FT>::field(int id)
173 { return fields_[id]; }
174
175 // Get the internal Unitcell (const reference)
176 template <int D, class FT>
177 inline
179 { return unitCell_; }
180
181 // Get the internal Unitcell (non-const reference)
182 template <int D, class FT>
184 { return unitCell_; }
185
186 // Protected inline member functions
187
188 // Has the system been set?
189 template <int D, class FT>
191 { return (systemPtr_ != 0); }
192
193 // Get the associated System<D> object.
194 template <int D, class FT>
196 {
197 assert(systemPtr_ != 0);
198 return *systemPtr_;
199 }
200
201 #ifndef RPC_FIELD_STATE_TPP
202 // Suppress implicit instantiation
203 extern template class FieldState< 1, DArray<double> >;
204 extern template class FieldState< 2, DArray<double> >;
205 extern template class FieldState< 3, DArray<double> >;
206 #endif
207
208} // namespace Rpc
209} // namespace Pscf
210#endif
Base template for UnitCell<D> classes, D=1, 2 or 3.
Definition rpg/System.h:34
Record of a state of a System (fields + unit cell).
void setSystem(System< D > &system)
Set association with System, after default construction.
UnitCell< D > & unitCell()
Get the UnitCell by non-const reference.
System< D > & system()
Get associated System by reference.
const UnitCell< D > & unitCell() const
Get UnitCell (i.e., lattice type and parameters) by const reference.
FT & field(int monomerId)
Get field for a specific monomer type (non-const reference).
DArray< FT > & fields()
Get array of all chemical potential fields (non-const reference).
const DArray< FT > & fields() const
Get array of all fields by const reference.
const FT & field(int monomerId) const
Get a field for a single monomer type by const reference.
bool hasSystem()
Has a system been set?
Main class for SCFT or PS-FTS simulation of one system.
Definition rpc/System.h:100
Dynamically allocatable contiguous array template.
Periodic fields and crystallography.
Definition CField.cpp:11
PSCF package top-level namespace.
Definition param_pc.dox:1
Utility classes for scientific computation.