1#ifndef RPG_AM_COMPRESSOR_TPP
2#define RPG_AM_COMPRESSOR_TPP
11#include "AmCompressor.h"
12#include <rpg/system/System.h>
13#include <prdc/cuda/RField.h>
14#include <prdc/cuda/resources.h>
15#include <pscf/math/IntVec.h>
28 { setClassName(
"AmCompressor"); }
51 const int nMonomer = system().mixture().nMonomer();
52 const int meshSize = system().domain().mesh().size();
53 const IntVec<D> dimensions = system().domain().mesh().dimensions();
61 w0_.allocate(nMonomer);
62 wFieldTmp_.allocate(nMonomer);
63 for (
int i = 0; i < nMonomer; ++i) {
64 w0_[i].allocate(dimensions);
65 wFieldTmp_[i].allocate(dimensions);
71 for (
int i = 0; i < nMonomer; ++i) {
100 return Reduce::innerProduct(a, b);
105 double AmCompressor<D>::maxAbs(DeviceArray<cudaReal>
const & a)
107 return Reduce::maxAbs(a);
120 if (basis[0].isAllocated()) {
121 UTIL_CHECK(basis[0].capacity() == hists[0].capacity());
123 basis[0].allocate(hists[0].capacity());
136 for (
int i = 0; i < nHist; i++) {
151 bool AmCompressor<D>::hasInitialGuess()
152 {
return system().w().hasData(); }
156 int AmCompressor<D>::nElements()
157 {
return system().domain().mesh().size(); }
174 void AmCompressor<D>::evaluate()
184 const int nMonomer = system().mixture().nMonomer();
190 for (
int i = 1; i < nMonomer; i++) {
200 const int nMonomer = system().mixture().nMonomer();
203 for (
int i = 0; i < nMonomer; i++) {
208 system().w().setRGrid(wFieldTmp_);
218 void AmCompressor<D>::outputToLog()
226 out <<
"Compressor times contributions:\n";
void readErrorType(std::istream &in)
int solve(bool isContinuation=false)
Dynamic array on the GPU device with aligned data.
int capacity() const
Return allocated capacity.
An IntVec<D, T> is a D-component vector of elements of integer type T.
int compress()
Compress to obtain partial saddle point w+.
AmCompressor(System< D > &system)
Constructor.
~AmCompressor()
Destructor.
void setup(bool isContinuation)
Initialize just before entry to iterative loop.
double computeLambda(double r)
Compute mixing parameter lambda.
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 one complete system.
Dynamically allocatable contiguous array template.
Class for storing history of previous values in an array.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
void addEqV(DeviceArray< cudaReal > &a, DeviceArray< cudaReal > const &b, const int beginIdA, const int beginIdB, const int n)
Vector addition in-place, a[i] += b[i], kernel wrapper (cudaReal).
void eqV(DeviceArray< cudaReal > &a, DeviceArray< cudaReal > const &b, const int beginIdA, const int beginIdB, const int n)
Vector assignment, a[i] = b[i], kernel wrapper (cudaReal).
void addVV(DeviceArray< cudaReal > &a, DeviceArray< cudaReal > const &b, DeviceArray< cudaReal > const &c, const int beginIdA, const int beginIdB, const int beginIdC, const int n)
Vector addition, a[i] = b[i] + c[i], kernel wrapper (cudaReal).
void subVV(DeviceArray< cudaReal > &a, DeviceArray< cudaReal > const &b, DeviceArray< cudaReal > const &c, const int beginIdA, const int beginIdB, const int beginIdC, const int n)
Vector subtraction, a[i] = b[i] - c[i], kernel wrapper (cudaReal).
void subVS(DeviceArray< cudaReal > &a, DeviceArray< cudaReal > const &b, const cudaReal c, const int beginIdA, const int beginIdB, const int n)
Vector subtraction, a[i] = b[i] - c, kernel wrapper (cudaReal).
void addEqVc(DeviceArray< cudaReal > &a, DeviceArray< cudaReal > const &b, cudaReal const c)
Vector addition in-place w/ coefficient, a[i] += b[i] * c, kernel wrapper.
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.