PSCF v1.3.3
rpc/fts/compressor/LrAmCompressor.h
1#ifndef RPC_LR_AM_COMPRESSOR_H
2#define RPC_LR_AM_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 "Compressor.h" // base class argument
12#include <pscf/iterator/AmIteratorDArray.h> // base class template
13
14#include <rpc/fts/compressor/IntraCorrelation.h> // member
15#include <prdc/cpu/RField.h> // member
16#include <prdc/cpu/RFieldDft.h> // member
17#include <util/containers/DArray.h> // member
18
19
20namespace Pscf {
21namespace Rpc {
22
23 // Forward declaration
24 template <int D> class System;
25
26 using namespace Util;
27 using namespace Pscf::Prdc;
28 using namespace Pscf::Prdc::Cpu;
29
41 template <int D>
43 : public AmIteratorDArray< Compressor<D> >
44 {
45
46 public:
47
48
55
60
66 void readParameters(std::istream& in) override;
67
77 void setup(bool isContinuation) override;
78
79
85 int compress() override;
86
92 void outputTimers(std::ostream& out) const override;
93
97 void clearTimers() override;
98
99 private:
100
104 int itr_;
105
109 DArray< RField<D> > w0_;
110
114 DArray< RField<D> > wFieldTmp_;
115
119 DArray<double> newBasis_;
120
124 RField<D> resid_;
125
129 RFieldDft<D> residK_;
130
134 RField<D> intraCorrelationK_;
135
139 IntVec<D> kMeshDimensions_;
140
144 IntraCorrelation<D> intra_;
145
149 bool isIntraCalculated_;
150
154 bool isAllocated_;
155
162 void addCorrection(DArray<double>& fieldTrial,
163 DArray<double> const & resTrial) override;
164
165 // Private virtual functions that interact with parent System
166
172 int nElements() override;
173
177 bool hasInitialGuess() override;
178
184 void getCurrent(DArray<double>& curr) override;
185
192 void evaluate() override;
193
199 void getResidual(DArray<double>& resid) override;
200
206 void update(DArray<double>& newGuess) override;
207
211 void outputToLog() override;
212
213 // Indirect (grandparent) base class.
215
216 // Inherited private members
217 using Compressor<D>::system;
218
219 };
220
221 // Explicit instantiation declarations
222 extern template class LrAmCompressor<1>;
223 extern template class LrAmCompressor<2>;
224 extern template class LrAmCompressor<3>;
225
226} // namespace Rpc
227} // namespace Pscf
228#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.
Definition cpu/RField.h:29
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) override
Read all parameters and initialize.
LrAmCompressor(System< D > &system)
Constructor.
int compress() override
Compress to obtain partial saddle point w+.
void outputTimers(std::ostream &out) const override
Return compressor times contributions.
void setup(bool isContinuation) override
Initialize just before entry to iterative loop.
void clearTimers() override
Clear all timers (reset accumulated time to zero).
Main class, representing a complete physical system.
Dynamically allocatable contiguous array template.
Definition DArray.h:32
Fields and FFTs for periodic boundary conditions (CPU)
Definition CField.cpp:12
Periodic fields and crystallography.
Definition CField.cpp:11
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.