PSCF v1.4.0
fts/compressor/AmCompressor.h
1#ifndef RP_AM_COMPRESSOR_H
2#define RP_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 <pscf/iterator/AmIteratorTmpl.h> // base class template
12#include <util/containers/DArray.h> // member
13
14namespace Pscf {
15namespace Rp {
16
17 // Namespaces that can be used implicitly
18 using namespace Util;
19
37 template <int D, class T, class V>
39 : public AmIteratorTmpl< typename T::Compressor, V >
40 {
41
42 public:
43
45 using VectorT = V;
46
52 void readParameters(std::istream& in) override;
53
63 void setup(bool isContinuation) override;
64
70 int compress() override;
71
77 void outputTimers(std::ostream& out) const override;
78
82 void clearTimers() override;
83
84 protected:
85
91 AmCompressor(typename T::System& system);
92
96 ~AmCompressor() = default;
97
99 using CompressorT = typename T::Compressor;
100
101 // Inherited protected member function
102 using CompressorT::system;
103
104 private:
105
110
115
119 bool isAllocated_;
120
121 // Private virtual AM algorithm functions.
122
128 int nElements() override;
129
133 bool hasInitialGuess() override;
134
140 void getCurrent(VectorT& curr) override;
141
148 void evaluate() override;
149
155 void getResidual(VectorT& resid) override;
156
162 void update(VectorT& newGuess) override;
163
167 void outputToLog() override;
168
171
172 };
173
174} // namespace Rp
175} // namespace Pscf
176#endif
V VectorT
Type for state and residual vectors.
void readParameters(std::istream &in) override
Read all parameters and initialize.
void outputTimers(std::ostream &out) const override
Return compressor times contributions.
AmCompressor(typename T::System &system)
Constructor.
int compress() override
Compress to obtain partial saddle point w+.
void clearTimers() override
Clear all timers and mde counter.
void setup(bool isContinuation) override
Initialize just before entry to iterative loop.
typename T::Compressor CompressorT
Compressor type.
~AmCompressor()=default
Destructor.
Class templates for real-valued periodic fields.
PSCF package top-level namespace.