PSCF v1.3.1
rpg/scft/iterator/Iterator.h
1#ifndef RPG_ITERATOR_H
2#define RPG_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
13#include <prdc/cuda/types.h> // typedef
14#include <pscf/cuda/DeviceArray.h> // typedef
15#include <util/containers/FSArray.h> // member
16
17namespace Pscf {
18namespace Rpg {
19
20 template <int D> class System;
21
22 using namespace Util;
23 using namespace Prdc;
24 using namespace Prdc::Cuda;
25
26 typedef DeviceArray<cudaReal> FieldCUDA;
27
33 template <int D>
34 class Iterator : public ParamComposite
35 {
36
37 public:
38
42 Iterator();
43
50
54 ~Iterator();
55
62 virtual int solve(bool isContinuation) = 0;
63
67 virtual void outputTimers(std::ostream& out) const = 0;
68
72 virtual void clearTimers() = 0;
73
77 bool isSymmetric() const;
78
82 bool isFlexible() const;
83
91
95 int nFlexibleParams() const;
96
102 void setFlexibleParams(FSArray<bool, 6> const & flexParams);
103
112 virtual double stress(int paramId) const;
113
114 protected:
115
120
125
130
134 System<D>& system();
135
139 System<D> const & system() const;
140
141 private:
142
144 System<D>* sysPtr_;
145
146 };
147
148 // Protected inline member functions
149
150 // Return reference to parent system.
151 template<int D> inline
153 { return *sysPtr_; }
154
155 // Return const reference to parent system.
156 template<int D> inline
158 { return *sysPtr_; }
159
160 // Explicit instantiation declarations
161 extern template class Iterator<1>;
162 extern template class Iterator<2>;
163 extern template class Iterator<3>;
164
165} // namespace Rpg
166} // namespace Pscf
167#endif
Dynamic array on the GPU device with aligned data.
Definition DeviceArray.h:43
Base class for iterative solvers for SCF equations.
System< D > & system()
Return reference to parent system.
void setFlexibleParams(FSArray< bool, 6 > const &flexParams)
Set the array indicating which lattice parameters are flexible.
virtual int solve(bool isContinuation)=0
Iterate to solution.
virtual void clearTimers()=0
Clear timers.
bool isFlexible() const
Is the unit cell flexible (true) or rigid (false).
int nFlexibleParams() const
Get the number of flexible lattice parameters.
bool isSymmetric() const
Does this iterator use a symmetry-adapted Fourier basis?
bool isFlexible_
Is the unit cell flexible during iteration?
virtual double stress(int paramId) const
Return the stress used by this Iterator, for one lattice parameter.
FSArray< bool, 6 > flexibleParams() const
Get the array indicating which lattice parameters are flexible.
FSArray< bool, 6 > flexibleParams_
Array of indices of the lattice parameters that are flexible.
bool isSymmetric_
Does this iterator use a symmetry-adapted basis?
virtual void outputTimers(std::ostream &out) const =0
Log output timing results.
Main class, representing a complete physical system.
A fixed capacity (static) contiguous array with a variable logical size.
Definition FSArray.h:38
ParamComposite()
Constructor.
Periodic fields and crystallography.
Definition CField.cpp:11
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.
Definition param_pc.dox:1