PSCF v1.4.0
rp/scft/iterator/Iterator.h
1#ifndef RP_ITERATOR_H
2#define RP_ITERATOR_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2025, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <util/param/ParamComposite.h> // base class
12#include <util/containers/FSArray.h> // member
13#include <util/global.h>
14
15namespace Pscf {
16namespace Rp {
17
18 using namespace Util;
19
34 template <int D, class ST>
35 class Iterator : public ParamComposite
36 {
37
38 public:
39
46 virtual int solve(bool isContinuation) = 0;
47
51 virtual void outputTimers(std::ostream& out) const = 0;
52
56 virtual void clearTimers() = 0;
57
61 bool isSymmetric() const
62 { return (isSymmetric_); }
63
67 bool isFlexible() const
68 { return (isFlexible_); }
69
78
82 int nFlexibleParams() const;
83
89 void setFlexibleParams(FSArray<bool,6> const & flexParams);
90
99 virtual double stress(int paramId) const;
100
101 protected:
102
107
112
117
118 // Protected member functions
119
123 Iterator();
124
130 Iterator(ST& system);
131
135 ~Iterator();
136
142 void setSystem(ST& system);
143
147 ST const & system() const;
148
152 ST& system();
153
154 private:
155
157 ST* sysPtr_;
158
159 };
160
161 // Inline member functions
162
166 template <int D, class ST> inline
167 ST const & Iterator<D, ST>::system() const
168 {
169 UTIL_CHECK(sysPtr_);
170 return *sysPtr_;
171 }
172
176 template <int D, class ST> inline
178 {
179 UTIL_CHECK(sysPtr_);
180 return *sysPtr_;
181 }
182
183} // namespace Rp
184} // namespace Pscf
185#endif
bool isSymmetric() const
Does this iterator use a symmetry-adapted Fourier basis?
void setFlexibleParams(FSArray< bool, 6 > const &flexParams)
Set the array indicating which lattice parameters are flexible.
Definition Iterator.tpp:67
ST const & system() const
Get parent system by const reference.
Iterator()
Default constructor.
Definition Iterator.tpp:24
void setSystem(ST &system)
Set parent system.
Definition Iterator.tpp:101
bool isSymmetric_
Does this iterator use a symmetry-adapted basis?
virtual int solve(bool isContinuation)=0
Iterate to solution.
int nFlexibleParams() const
Get the number of flexible lattice parameters.
Definition Iterator.tpp:51
FSArray< bool, 6 > flexibleParams() const
Get the array indicating which lattice parameters are flexible.
virtual double stress(int paramId) const
Return the stress used by this Iterator, for one lattice parameter.
Definition Iterator.tpp:82
~Iterator()
Destructor.
Definition Iterator.tpp:44
bool isFlexible_
Are any lattice parameters flexible during iteration?
virtual void outputTimers(std::ostream &out) const =0
Log output timing results.
bool isFlexible() const
Return true iff unit cell has any flexible lattice parameters.
virtual void clearTimers()=0
Clear timers.
FSArray< bool, 6 > flexibleParams_
Array of indices of the lattice parameters that are flexible.
A fixed capacity (static) contiguous array with a variable logical size.
Definition FSArray.h:38
ParamComposite()
Constructor.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Class templates for real-valued periodic fields.
PSCF package top-level namespace.