PSCF v1.5.0
LrAmCompressor.h
1#ifndef RP_LR_AM_COMPRESSOR_H
2#define RP_LR_AM_COMPRESSOR_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <rp/fts/compressor/AmCompressorBase.h> // base specialization
12#include <rp/fts/compressor/IntraCorrelation.h> // member
13#include <pscf/field/RField.h> // member
14#include <pscf/field/RFieldDft.h> // member
15#include <pscf/math/IntVec.h> // member
16#include <util/containers/DArray.h> // member
17
18#include <pscf/backend/TmplDeclare.h> // declaration macros
19
20// Forward declaration
21namespace Pscf {
22 namespace Rp {
23 template <int D, class T> class System;
24 }
25}
26
27namespace Pscf {
28namespace Rp {
29
30 using namespace Util;
31
50 template <int D, class T>
52 : public AmIteratorTmpl<Compressor<D,T>, BackendArray<typename T::Real,T> >
53 {
54
55 public:
56
63
67 ~LrAmCompressor() = default;
68
74 void readParameters(std::istream& in) override;
75
81 int compress() override;
82
86 void clearCache() override;
87
93 void outputTimers(std::ostream& out) const override;
94
98 void clearTimers() override;
99
100 protected:
101
102 // Inherited member function.
103 using Compressor<D,T>::system;
104
105 private:
106
107 // Private type aliases
108
110 using VectorT = BackendArray<typename T::Real,T>;
111
113 using AmTmpl = AmIteratorTmpl< Compressor<D,T>, VectorT >;
114
115 // Private member variables
116
121
125 DArray< RField<D,T> > wFieldTmp_;
126
130 RField<D,T> resid_;
131
135 RFieldDft<D,T> residK_;
136
140 RField<D,T> intraCorrelationK_;
141
146
150 IntVec<D> kMeshDimensions_;
151
155 int kSize_;
156
160 bool hasIntraCorrelationK_;
161
165 bool isAllocated_;
166
167 // Private AM algorithm member functions (overridden)
168
174 int nElements() override;
175
179 bool hasInitialGuess() override;
180
190 void setup(bool isContinuation) override;
191
197 void getCurrent(VectorT& curr) override;
198
205 void evaluate() override;
206
212 void getResidual(VectorT& resid) override;
213
220 void addCorrection(VectorT& fieldTrial,
221 VectorT const & resTrial) override;
222
228 void update(VectorT& newGuess) override;
229
233 void outputToLog() override;
234
235 };
236
237 // Explicit instantiation declarations
238 PSCF_TMPL_DECLARE(LrAmCompressor)
239
240} // namespace Rp
241} // namespace Pscf
242#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Base class for iterators that impose incompressibility.
Definition Compressor.h:35
Intramolecular correlation analyzer.
Anderson mixing compressor with linear-response correction step.
void clearTimers() override
Clear all timers and MDE solution counter.
~LrAmCompressor()=default
Destructor.
int compress() override
Compress to obtain partial saddle point field.
LrAmCompressor(System< D, T > &system)
Constructor.
void readParameters(std::istream &in) override
Read body of parameter file block and initialize.
void clearCache() override
Mark stored intramolecular correlation function as outdated.
void outputTimers(std::ostream &out) const override
Return compressor time contributions.
Base class template for classes that represent a complete system.
Dynamically allocatable contiguous array template.
Definition DArray.h:32
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.