PSCF v1.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 Theory
6*
7* Copyright 2016 - 2022, 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/intra/IntraCorrelation.h>
18
19namespace Pscf {
20namespace Rpg
21{
22
23 template <int D> class System;
24 template <int D> class IntraCorrelation;
25
26 using namespace Util;
27 using namespace Pscf::Prdc;
28 using namespace Pscf::Prdc::Cuda;
29
40 template <int D>
41 class LrCompressor : public Compressor<D>
42 {
43
44 public:
45
52
57
63 void readParameters(std::istream& in);
64
72 void setup();
73
79 int compress();
80
81 double subspacePercent(){return 0;};
82
83 double correctionPercent(){return 0;};
84
88 void outputTimers(std::ostream& out);
89
90 void clearTimers();
91
92 protected:
93
94 // Inherited protected members
99
100 private:
101
102 // Error tolerance.
103 double epsilon_;
104
105 // Current iteration counter.
106 int itr_;
107
108 // Maximum number of iterations.
109 int maxItr_;
110
111 // Total iteration counter.
112 int totalItr_;
113
114 // Timers for analyzing performance.
115 Timer timerTotal_;
116 Timer timerMDE_;
117
118 // Type of error criterion used to test convergence
119 std::string errorType_;
120
121 // Verbosity level.
122 int verbose_;
123
127 IntVec<D> kMeshDimensions_;
128
132 int kSize_;
133
137 RField<D> intraCorrelationK_;
138
142 RField<D> resid_;
143
147 RFieldDft<D> residK_;
148
152 DArray< RField<D> > wFieldTmp_;
153
159 void getResidual();
160
164 void updateWFields();
165
172 double computeError(int verbose);
173
177 double maxAbs(RField<D> const & a);
178
185 double dotProduct(RField<D> const & a, RField<D> const & b);
186
190 double norm(RField<D> const & a);
191
195 void outputToLog();
196
200 IntraCorrelation<D> intra_;
201
205 bool isIntraCalculated_;
206
210 bool isAllocated_;
211
212 // Private inherited members
213 using Compressor<D>::system;
214
215 };
216
217 #ifndef RPG_LR_COMPRESSOR_TPP
218 // Suppress implicit instantiation
219 extern template class LrCompressor<1>;
220 extern template class LrCompressor<2>;
221 extern template class LrCompressor<3>;
222 #endif
223
224} // namespace Rpg
225} // namespace Pscf
226#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.
Base class for iterators that impose incompressibility.
int mdeCounter_
Count how many times MDE has been solved.
System< D > const & system() const
Return const reference to parent system.
Base class for iterators that impose incompressibility.
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.
void outputTimers(std::ostream &out)
Return compressor times contributions.
LrCompressor(System< D > &system)
Constructor.
Main class for calculations that represent one system.
Definition rpg/System.h:107
Dynamically allocatable contiguous array template.
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
PSCF package top-level namespace.
Definition param_pc.dox:1
Utility classes for scientific computation.