PSCF v1.3.2
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#include <iostream>
18
19namespace Pscf {
20namespace Rpg {
21
22 template <int D> class System;
23
24 using namespace Util;
25 using namespace Pscf::Prdc;
26 using namespace Pscf::Prdc::Cuda;
27
38 template <int D>
39 class LrCompressor : public Compressor<D>
40 {
41
42 public:
43
50
55
61 void readParameters(std::istream& in);
62
70 void setup();
71
77 int compress();
78
79 double subspacePercent(){return 0;};
80
81 double correctionPercent(){return 0;};
82
86 void outputTimers(std::ostream& out) const;
87
88 void clearTimers();
89
90 protected:
91
92 // Inherited protected members
97
98 private:
99
100 // Error tolerance.
101 double epsilon_;
102
103 // Current iteration counter.
104 int itr_;
105
106 // Maximum number of iterations.
107 int maxItr_;
108
109 // Total iteration counter.
110 int totalItr_;
111
112 // Verbosity level.
113 int verbose_;
114
115 // Type of error criterion used to test convergence
116 std::string errorType_;
117
118 // Timers for analyzing performance.
119 Timer timerTotal_;
120 Timer timerMDE_;
121
125 int kSize_;
126
130 IntraCorrelation<D> intra_;
131
135 IntVec<D> kMeshDimensions_;
136
140 RField<D> intraCorrelationK_;
141
145 RField<D> resid_;
146
150 RFieldDft<D> residK_;
151
155 DArray< RField<D> > wFieldTmp_;
156
160 bool isIntraCalculated_;
161
165 bool isAllocated_;
166
167 // Private functions
168
174 void getResidual();
175
179 void updateWFields();
180
187 double computeError(int verbose);
188
192 double maxAbs(RField<D> const & a);
193
200 double dotProduct(RField<D> const & a, RField<D> const & b);
201
205 double norm(RField<D> const & a);
206
210 void outputToLog();
211
212 // Private inherited members
213 using Compressor<D>::system;
214
215 };
216
217 // Explicit instantiation declarations
218 extern template class LrCompressor<1>;
219 extern template class LrCompressor<2>;
220 extern template class LrCompressor<3>;
221
222} // namespace Rpg
223} // namespace Pscf
224#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()
Default 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 CField.cu:12
Periodic fields and crystallography.
Definition CField.cpp:11
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.