1#ifndef RPC_AM_COMPRESSOR_TPP
2#define RPC_AM_COMPRESSOR_TPP
11#include "AmCompressor.h"
12#include <rpc/system/System.h>
13#include <rpc/solvers/Mixture.h>
14#include <rpc/field/Domain.h>
50 bool useLambdaRamp =
false;
66 const int nMonomer = system().mixture().nMonomer();
67 const int meshSize = system().domain().mesh().size();
68 IntVec<D> const & dimensions = system().domain().mesh().dimensions();
72 w0_.allocate(nMonomer);
73 wFieldTmp_.allocate(nMonomer);
74 for (
int i = 0; i < nMonomer; ++i) {
75 w0_[i].allocate(dimensions);
76 wFieldTmp_[i].allocate(dimensions);
82 for (
int i = 0; i < nMonomer; ++i) {
83 for (
int j = 0; j< meshSize; ++j){
84 w0_[i][j] = system().w().rgrid(i)[j];
106 out <<
"AmCompressor time contributions:\n";
126 bool AmCompressor<D>::hasInitialGuess()
127 {
return system().w().hasData(); }
133 int AmCompressor<D>::nElements()
134 {
return system().domain().mesh().size(); }
143 const int meshSize = system().domain().mesh().size();
152 for (
int i = 0; i < meshSize; i++){
153 curr[i] = (*currSys)[0][i] - w0_[0][i];
162 void AmCompressor<D>::evaluate()
174 const int n = nElements();
175 const int nMonomer = system().mixture().nMonomer();
176 const int meshSize = system().domain().mesh().size();
179 for (
int i = 0 ; i < n; ++i) {
184 for (
int j = 0; j < nMonomer; ++j) {
185 for (
int k = 0; k < meshSize; ++k) {
186 resid[k] += system().c().rgrid(j)[k];
199 const int nMonomer = system().mixture().nMonomer();
200 const int meshSize = system().domain().mesh().size();
203 for (
int i = 0; i < nMonomer; i++){
204 for (
int k = 0; k < meshSize; k++){
205 wFieldTmp_[i][k] = w0_[i][k] + newGuess[k];
208 system().w().setRGrid(wFieldTmp_);
215 void AmCompressor<D>::outputToLog()
virtual void setup(bool isContinuation)
void readMixingParameters(std::istream &in, bool useLambdaRamp=true)
void outputTimers(std::ostream &out) const
void readErrorType(std::istream &in)
virtual void readParameters(std::istream &in)
int solve(bool isContinuation=false)
An IntVec<D, T> is a D-component vector of elements of integer type T.
int compress() override
Compress to obtain partial saddle point w+.
void outputTimers(std::ostream &out) const override
Return compressor times contributions.
AmCompressor(System< D > &system)
Constructor.
void setup(bool isContinuation) override
Initialize just before entry to iterative loop.
void readParameters(std::istream &in) override
Read all parameters and initialize.
void clearTimers() override
Clear all timers (reset accumulated time to zero).
~AmCompressor()
Destructor.
Base class for iterators that impose incompressibility.
int mdeCounter_
Count how many times MDE has been solved.
Main class, representing a complete physical system.
Dynamically allocatable contiguous array template.
void setClassName(const char *className)
Set class name string.
File containing preprocessor macros for error handling.
Real periodic fields, SCFT and PS-FTS (CPU).
PSCF package top-level namespace.