PSCF v1.3.2
rpc/fts/compressor/AmCompressor.h
1#ifndef RPC_AM_COMPRESSOR_H
2#define RPC_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 template argument
12#include <prdc/cpu/RField.h> // member
13#include <pscf/iterator/AmIteratorDArray.h> // base class template
14#include <util/containers/DArray.h> // member
15
16namespace Pscf {
17namespace Rpc {
18
19 // Forward declaration
20 template <int D> class System;
21
22 // Namespaces from which names can be used without qualification
23 using namespace Util;
24 using namespace Pscf::Prdc::Cpu;
25
31 template <int D>
33 : public AmIteratorDArray< Compressor<D> >
34 {
35
36 public:
37
43 AmCompressor(System<D>& system);
44
49
55 void readParameters(std::istream& in) override;
56
66 void setup(bool isContinuation) override;
67
73 int compress() override;
74
78 void outputTimers(std::ostream& out) const override;
79
83 void clearTimers() override;
84
85 private:
86
90 int itr_;
91
96
100 bool isAllocated_;
101
105 DArray< RField<D> > wFieldTmp_;
106
107 // Private virtual functions that interact with parent system
108
114 int nElements() override;
115
119 bool hasInitialGuess() override;
120
126 void getCurrent(DArray<double>& curr) override;
127
134 void evaluate() override;
135
141 void getResidual(DArray<double>& resid) override;
142
148 void update(DArray<double>& newGuess) override;
149
153 void outputToLog() override;
154
155 // Inherited private members
156 using Compressor<D>::system;
157
158 // Indirect (grandparent) base class.
160
161 };
162
163 // Explicit instantiation declarations
164 extern template class AmCompressor<1>;
165 extern template class AmCompressor<2>;
166 extern template class AmCompressor<3>;
167
168} // namespace Rpc
169} // namespace Pscf
170#endif
Template for Anderson mixing iterator algorithm.
int compress() override
Compress to obtain partial saddle point w+.
void outputTimers(std::ostream &out) const override
Return compressor times contributions.
AmCompressor(System< D > &system)
Constructor.
void setup(bool isContinuation) override
Initialize just before entry to iterative loop.
void readParameters(std::istream &in) override
Read all parameters and initialize.
void clearTimers() override
Clear all timers (reset accumulated time to zero).
Base class for iterators that impose incompressibility.
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
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.