PSCF v1.3.2
rpg/fts/compressor/AmCompressor.h
1#ifndef RPG_AM_COMPRESSOR_H
2#define RPG_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 argument
12#include <prdc/cuda/types.h> // base class argument
13#include <pscf/cuda/DeviceArray.h> // base class argument
14#include <pscf/iterator/AmIteratorTmpl.h> // base class template
15
16#include <prdc/cuda/RField.h> // member
17#include <util/containers/DArray.h> // member
18
19#include <iostream>
20
21namespace Pscf {
22namespace Rpg {
23
24 // Forward declaration
25 template <int D> class System;
26
27 using namespace Util;
28 using namespace Pscf::Prdc;
29 using namespace Pscf::Prdc::Cuda;
30
36 template <int D>
38 : public AmIteratorTmpl< Compressor<D>, DeviceArray<cudaReal> >
39 {
40
41 public:
42
45
51 AmCompressor(System<D>& system);
52
57
63 void readParameters(std::istream& in);
64
74 void setup(bool isContinuation);
75
81 int compress();
82
83 #if 0
87 double computeLambda(double r);
88 #endif
89
94
98 void outputTimers(std::ostream& out) const;
99
103 void clearTimers();
104
105 private:
106
110 int counter_;
111
115 DArray< RField<D> > w0_;
116
120 bool isAllocated_;
121
125 DArray< RField<D> > wFieldTmp_;
126
127 // Private virtual functions that interact with parent System
128
134 int nElements() override;
135
139 bool hasInitialGuess() override;
140
146 void getCurrent(VectorT& curr) override;
147
154 void evaluate() override;
155
161 void getResidual(VectorT& resid) override;
162
168 void update(VectorT& newGuess) override;
169
173 void outputToLog() override;
174
175 // Private virtual functions for vector math
176
183 void setEqual(VectorT& a,
184 VectorT const & b) override;
185
189 double dotProduct(VectorT const & a,
190 VectorT const & b) override;
191
195 double maxAbs(VectorT const & hist) override;
196
204 void subVV(VectorT& a,
205 VectorT const & b,
206 VectorT const & c) override;
207
215 void addEqVc(VectorT& a,
216 VectorT const & b,
217 double c) override;
218
219 // Inherited protected member
220 using Compressor<D>::system;
221
224
225 };
226
227 // Explicit instantiation declarations
228 extern template class AmCompressor<1>;
229 extern template class AmCompressor<2>;
230 extern template class AmCompressor<3>;
231
232} // namespace Rpg
233} // namespace Pscf
234#endif
Dynamic array on the GPU device with aligned data.
Definition DeviceArray.h:43
DeviceArray< cudaReal > VectorT
Typename for state and residual vectors.
int compress()
Compress to obtain partial saddle point w+.
int mdeCounter()
Return how many times MDE has been solved.
AmCompressor(System< D > &system)
Constructor.
void setup(bool isContinuation)
Initialize just before entry to iterative loop.
void clearTimers()
Clear all timers (reset accumulated time to zero).
void readParameters(std::istream &in)
Read all parameters and initialize.
void outputTimers(std::ostream &out) const
Return compressor times contributions.
Base class for iterators that impose incompressibility.
Main class, representing a complete physical system.
Dynamically allocatable contiguous array template.
Definition DArray.h:32
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.