PSCF v1.3
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"
12#include <prdc/cuda/RField.h>
13#include <prdc/cuda/RFieldDft.h>
14#include <util/containers/DArray.h>
15#include <util/containers/DMatrix.h>
16#include <util/misc/Timer.h>
17#include <rpg/fts/compressor/IntraCorrelation.h>
18
19namespace Pscf {
20namespace Rpg
21{
22
23 template <int D> class System;
24
25 using namespace Util;
26 using namespace Pscf::Prdc;
27 using namespace Pscf::Prdc::Cuda;
28
39 template <int D>
40 class LrCompressor : public Compressor<D>
41 {
42
43 public:
44
51
56
62 void readParameters(std::istream& in);
63
71 void setup();
72
78 int compress();
79
80 double subspacePercent(){return 0;};
81
82 double correctionPercent(){return 0;};
83
87 void outputTimers(std::ostream& out) const;
88
89 void clearTimers();
90
91 protected:
92
93 // Inherited protected members
98
99 private:
100
101 // Error tolerance.
102 double epsilon_;
103
104 // Current iteration counter.
105 int itr_;
106
107 // Maximum number of iterations.
108 int maxItr_;
109
110 // Total iteration counter.
111 int totalItr_;
112
113 // Timers for analyzing performance.
114 Timer timerTotal_;
115 Timer timerMDE_;
116
117 // Type of error criterion used to test convergence
118 std::string errorType_;
119
120 // Verbosity level.
121 int verbose_;
122
126 IntVec<D> kMeshDimensions_;
127
131 int kSize_;
132
136 RField<D> intraCorrelationK_;
137
141 RField<D> resid_;
142
146 RFieldDft<D> residK_;
147
151 DArray< RField<D> > wFieldTmp_;
152
158 void getResidual();
159
163 void updateWFields();
164
171 double computeError(int verbose);
172
176 double maxAbs(RField<D> const & a);
177
184 double dotProduct(RField<D> const & a, RField<D> const & b);
185
189 double norm(RField<D> const & a);
190
194 void outputToLog();
195
199 IntraCorrelation<D> intra_;
200
204 bool isIntraCalculated_;
205
209 bool isAllocated_;
210
211 // Private inherited members
212 using Compressor<D>::system;
213
214 };
215
216 #ifndef RPG_LR_COMPRESSOR_TPP
217 // Suppress implicit instantiation
218 extern template class LrCompressor<1>;
219 extern template class LrCompressor<2>;
220 extern template class LrCompressor<3>;
221 #endif
222
223} // namespace Rpg
224} // namespace Pscf
225#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 one complete 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