PSCF v1.3.1
rpg/fts/compressor/LrCompressor.h
1#ifndef RPG_LR_COMPRESSOR_H
2#define RPG_LR_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
12#include <prdc/cuda/RField.h> // member
13#include <prdc/cuda/RFieldDft.h> // member
14#include <util/containers/DArray.h> // member
15#include <util/misc/Timer.h> // member
16#include <rpg/fts/compressor/IntraCorrelation.h> // member
17
18namespace Pscf {
19namespace Rpg {
20
21 template <int D> class System;
22
23 using namespace Util;
24 using namespace Pscf::Prdc;
25 using namespace Pscf::Prdc::Cuda;
26
37 template <int D>
38 class LrCompressor : public Compressor<D>
39 {
40
41 public:
42
49
54
60 void readParameters(std::istream& in);
61
69 void setup();
70
76 int compress();
77
78 double subspacePercent(){return 0;};
79
80 double correctionPercent(){return 0;};
81
85 void outputTimers(std::ostream& out) const;
86
87 void clearTimers();
88
89 protected:
90
91 // Inherited protected members
96
97 private:
98
99 // Error tolerance.
100 double epsilon_;
101
102 // Current iteration counter.
103 int itr_;
104
105 // Maximum number of iterations.
106 int maxItr_;
107
108 // Total iteration counter.
109 int totalItr_;
110
111 // Timers for analyzing performance.
112 Timer timerTotal_;
113 Timer timerMDE_;
114
115 // Type of error criterion used to test convergence
116 std::string errorType_;
117
118 // Verbosity level.
119 int verbose_;
120
124 IntVec<D> kMeshDimensions_;
125
129 int kSize_;
130
134 RField<D> intraCorrelationK_;
135
139 RField<D> resid_;
140
144 RFieldDft<D> residK_;
145
149 DArray< RField<D> > wFieldTmp_;
150
156 void getResidual();
157
161 void updateWFields();
162
169 double computeError(int verbose);
170
174 double maxAbs(RField<D> const & a);
175
182 double dotProduct(RField<D> const & a, RField<D> const & b);
183
187 double norm(RField<D> const & a);
188
192 void outputToLog();
193
197 IntraCorrelation<D> intra_;
198
202 bool isIntraCalculated_;
203
207 bool isAllocated_;
208
209 // Private inherited members
210 using Compressor<D>::system;
211
212 };
213
214 // Explicit instantiation declarations
215 extern template class LrCompressor<1>;
216 extern template class LrCompressor<2>;
217 extern template class LrCompressor<3>;
218
219} // namespace Rpg
220} // namespace Pscf
221#endif
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
int mdeCounter_
Count how many times MDE has been solved.
Compressor(System< D > &system)
Constructor.
System< D > const & system() const
Return const reference to parent system.
Linear response function for response to pressure.
void setup()
Initialize just before entry to iterative loop.
void readParameters(std::istream &in)
Read all parameters and initialize.
int compress()
Iterate pressure field to obtain partial saddle point.
LrCompressor(System< D > &system)
Constructor.
void outputTimers(std::ostream &out) const
Return compressor times contributions.
Main class, representing a complete physical system.
Dynamically allocatable contiguous array template.
Definition DArray.h:32
ScalarParam< Type > & read(std::istream &in, const char *label, Type &value)
Add and read a new required ScalarParam < Type > object.
void setClassName(const char *className)
Set class name string.
ScalarParam< Type > & readOptional(std::istream &in, const char *label, Type &value)
Add and read a new optional ScalarParam < Type > object.
Wall clock timer.
Definition Timer.h:35
Fields, FFTs, and utilities for periodic boundary conditions (CUDA)
Definition Reduce.cpp:14
Periodic fields and crystallography.
Definition CField.cpp:11
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.
Definition param_pc.dox:1