PSCF v1.4.0
fts/compressor/LrCompressor.h
1#ifndef RP_LR_COMPRESSOR_H
2#define RP_LR_COMPRESSOR_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 <pscf/math/IntVec.h> // member
12#include <util/containers/DArray.h> // member
13#include <util/misc/Timer.h> // member
14
15namespace Pscf {
16namespace Rp {
17
18 using namespace Util;
19
41 template <int D, class T>
42 class LrCompressor : public T::Compressor
43 {
44
45 public:
46
52 void readParameters(std::istream& in);
53
61 void setup();
62
68 int compress();
69
75 void outputTimers(std::ostream& out) const;
76
80 void clearTimers();
81
82 protected:
83
89 LrCompressor(typename T::System& system);
90
94 ~LrCompressor() = default;
95
96 // Inherited protected members
97 using CompressorT = typename T::Compressor;
98 using CompressorT::mdeCounter_;
99 using CompressorT::system;
100
101 private:
102
103 using RFieldT = typename T::RField;
104 using RFieldDftT = typename T::RFieldDft;
105 using FFTT = typename T::FFT;
106
107 // IntraCorrelation object
108 typename T::IntraCorrelation intra_;
109
110 // Template w Field used in update function
111 DArray< RFieldT > wFieldTmp_;
112
113 // Residual in real space
114 RFieldT resid_;
115
116 // Residual in Fourier space
117 RFieldDftT residK_;
118
119 // Intramolecular correlation in Fourier space
120 RFieldT intraCorrelationK_;
121
122 // Dimensions of wavevector mesh in real-to-complex transform
123 IntVec<D> kMeshDimensions_;
124
125 // Timers for analyzing performance
126 Timer timerTotal_;
127 Timer timerMDE_;
128
129 // Type of error criterion used to test convergence
130 std::string errorType_;
131
132 // Error tolerance
133 double epsilon_;
134
135 // Current iteration counter
136 int itr_;
137
138 // Maximum number of iterations
139 int maxItr_;
140
141 // Total iteration counter
142 int totalItr_;
143
144 // Verbosity level
145 int verbose_;
146
147 // Has required memory been allocated?
148 bool isAllocated_;
149
150 // Has the IntraCorrelation been calculated?
151 bool isIntraCalculated_;
152
153 // Private member functions
154
158 void computeResidual();
159
163 void updateWFields();
164
171 double computeError(int verbose);
172
176 void outputToLog();
177
178 };
179
180} // namespace Rp
181} // namespace Pscf
182#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
int compress()
Iterate pressure field to obtain partial saddle point.
void outputTimers(std::ostream &out) const
Return compressor times contributions.
LrCompressor(typename T::System &system)
Constructor.
~LrCompressor()=default
Destructor.
void setup()
Initialize just before entry to iterative loop.
void readParameters(std::istream &in)
Read all parameters and initialize.
void clearTimers()
Clear all timers.
Wall clock timer.
Definition Timer.h:35
Class templates for real-valued periodic fields.
PSCF package top-level namespace.