PSCF v1.2
rpc/fts/compressor/LrCompressor.h
1#ifndef RPC_LR_COMPRESSOR_H
2#define RPC_LR_COMPRESSOR_H
3
4/*
5* PSCF - Polymer Self-Consistent Field Theory
6*
7* Copyright 2016 - 2022, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include "Compressor.h"
12#include <prdc/cpu/RField.h>
13#include <prdc/cpu/RFieldDft.h>
14#include <util/containers/DArray.h>
15#include <util/containers/DMatrix.h>
16#include <util/misc/Timer.h>
17#include <rpc/fts/compressor/intra/IntraCorrelation.h>
18
19namespace Pscf {
20namespace Rpc
21{
22
23 template <int D> class System;
24 template <int D> class IntraCorrelation;
25
26 using namespace Util;
27 using namespace Pscf::Prdc::Cpu;
28
39 template <int D>
40 class LrCompressor : public Compressor<D>
41 {
42
43 public:
44
51
56
62 void readParameters(std::istream& in);
63
71 void setup();
72
78 int compress();
79
80 double subspacePercent(){return 0;};
81
82 double correctionPercent(){return 0;};
83
87 void outputTimers(std::ostream& out);
88
89 void clearTimers();
90
91 protected:
92
93 // Inherited protected members
98
99 private:
100
101 // Error tolerance.
102 double epsilon_;
103
104 // Current iteration counter.
105 int itr_;
106
107 // Maximum number of iterations.
108 int maxItr_;
109
110 // Total iteration counter.
111 int totalItr_;
112
113 // Timers for analyzing performance.
114 Timer timerTotal_;
115 Timer timerMDE_;
116
117 // Type of error criterion used to test convergence
118 std::string errorType_;
119
120 // Verbosity level.
121 int verbose_;
122
126 IntVec<D> kMeshDimensions_;
127
131 RField<D> intraCorrelationK_;
132
136 RField<D> resid_;
137
141 RFieldDft<D> residK_;
142
146 DArray< RField<D> > w0_;
147
151 DArray< RField<D> > wFieldTmp_;
152
158 void getResidual();
159
163 void updateWFields();
164
171 double computeError(int verbose);
172
176 double maxAbs(RField<D> const & a);
177
184 double dotProduct(RField<D> const & a, RField<D> const & b);
185
189 double norm(RField<D> const & a);
190
194 void outputToLog();
195
199 IntraCorrelation<D> intra_;
200
201 // Has the IntraCorrelation been calculated?
202 bool isIntraCalculated_;
203
204 // Has required memory been allocated.
205 bool isAllocated_;
206
207 // Private inherited members
208 using Compressor<D>::system;
209
210 };
211
212 #ifndef RPC_LR_COMPRESSOR_TPP
213 // Suppress implicit instantiation
214 extern template class LrCompressor<1>;
215 extern template class LrCompressor<2>;
216 extern template class LrCompressor<3>;
217 #endif
218
219} // namespace Rpc
220} // namespace Pscf
221#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Fourier transform of a real field on an FFT mesh.
Field of real double precision values on an FFT mesh.
Base class for iterators that impose incompressibility.
System< D > const & system() const
Return const reference to parent system.
int mdeCounter_
Count how many times MDE has been solved.
Intramolecular correlation analysis for LR compressors.
LrCompressor(System< D > &system)
Constructor.
int compress()
Iterate pressure field to obtain partial saddle point.
void outputTimers(std::ostream &out)
Return compressor times contributions.
void readParameters(std::istream &in)
Read all parameters and initialize.
void setup()
Initialize just before entry to iterative loop.
Main class for SCFT or PS-FTS simulation of one system.
Definition rpc/System.h:100
Dynamically allocatable contiguous array template.
ScalarParam< Type > & read(std::istream &in, const char *label, Type &value)
Add and read a new required ScalarParam < Type > object.
void setClassName(const char *className)
Set class name string.
ScalarParam< Type > & readOptional(std::istream &in, const char *label, Type &value)
Add and read a new optional ScalarParam < Type > object.
Wall clock timer.
Definition Timer.h:35
Fields and FFTs for periodic boundary conditions (CPU)
Definition CField.cpp:12
PSCF package top-level namespace.
Definition param_pc.dox:1
Utility classes for scientific computation.