PSCF v1.2
rpc/fts/compressor/LrAmCompressor.h
1#ifndef RPC_LR_POST_AM_COMPRESSOR_H
2#define RPC_LR_POST_AM_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 <pscf/iterator/AmIteratorTmpl.h>
15#include <rpc/fts/compressor/intra/IntraCorrelation.h>
16
17namespace Pscf {
18namespace Rpc
19{
20
21 template <int D> class System;
22 template <int D> class IntraCorrelation;
23
24 using namespace Util;
25 using namespace Pscf::Prdc::Cpu;
26
38 template <int D>
40 : public AmIteratorTmpl<Compressor<D>, DArray<double> >
41 {
42
43 public:
44
51
56
62 void readParameters(std::istream& in);
63
73 void setup(bool isContinuation);
74
75
81 int compress();
82
86 void outputTimers(std::ostream& out);
87
91 void clearTimers();
92
93 // Inherited public member functions
94 using AmIteratorTmpl<Compressor<D>, DArray<double> >::setClassName;
95
96 protected:
97
98 // Inherited protected members
100 using Compressor<D>::mdeCounter_;
101
102 private:
103
107 int itr_;
108
112 DArray< RField<D> > w0_;
113
117 DArray< RField<D> > wFieldTmp_;
118
122 DArray<double> newBasis_;
123
127 RField<D> resid_;
128
132 RFieldDft<D> residK_;
133
137 RField<D> intraCorrelationK_;
138
142 IntVec<D> kMeshDimensions_;
143
150 void setEqual(DArray<double>& a, DArray<double> const & b);
151
155 double dotProduct(DArray<double> const & a, DArray<double> const & b);
156
160 double maxAbs(DArray<double> const & hist);
161
168 void updateBasis(RingBuffer<DArray<double> > & basis,
169 RingBuffer<DArray<double> > const & hists);
170
179 void addHistories(DArray<double>& trial,
180 RingBuffer<DArray<double> > const & basis,
181 DArray<double> coeffs,
182 int nHist);
183
191 void addPredictedError(DArray<double>& fieldTrial,
192 DArray<double> const & resTrial,
193 double lambda);
194
198 bool hasInitialGuess();
199
205 int nElements();
206
212 void getCurrent(DArray<double>& curr);
213
220 void evaluate();
221
227 void getResidual(DArray<double>& resid);
228
234 void update(DArray<double>& newGuess);
235
239 void outputToLog();
240
244 double computeLambda(double r);;
245
249 IntraCorrelation<D> intra_;
250
254 bool isIntraCalculated_;
255
259 bool isAllocated_;
260
261 // Inherited private members
262 using Compressor<D>::system;
263
264 };
265
266 #ifndef RPC_LR_POST_AM_COMPRESSOR_TPP
267 // Suppress implicit instantiation
268 extern template class LrAmCompressor<1>;
269 extern template class LrAmCompressor<2>;
270 extern template class LrAmCompressor<3>;
271 #endif
272
273} // namespace Rpc
274} // namespace Pscf
275#endif
Template for Anderson mixing iterator algorithm.
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.
Intramolecular correlation analysis for LR compressors.
Anderson Mixing compressor with linear-response mixing step.
void readParameters(std::istream &in)
Read all parameters and initialize.
LrAmCompressor(System< D > &system)
Constructor.
void outputTimers(std::ostream &out)
Return compressor times contributions.
void clearTimers()
Clear all timers (reset accumulated time to zero).
void setup(bool isContinuation)
Initialize just before entry to iterative loop.
int compress()
Compress to obtain partial saddle point w+.
Main class for SCFT or PS-FTS simulation of one system.
Definition rpc/System.h:100
Dynamically allocatable contiguous array template.
ScalarParam< Type > & readOptional(std::istream &in, const char *label, Type &value)
Add and read a new optional ScalarParam < Type > object.
Class for storing history of previous values in an array.
Definition RingBuffer.h:27
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.