PSCF v1.1
AmIteratorBasis.h
1#ifndef PSPG_AM_ITERATOR_BASIS_H
2#define PSPG_AM_ITERATOR_BASIS_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 "Iterator.h"
12#include <pscf/iterator/AmIteratorTmpl.h>
13#include <pscf/iterator/AmbdInteraction.h> // member variable
14
15namespace Pscf {
16namespace Pspg
17{
18
19 template <int D>
20 class System;
21
22 using namespace Util;
23
29 template <int D>
30 class AmIteratorBasis : public AmIteratorTmpl<Iterator<D>, DArray<double> >
31 {
32
33 public:
34
41
46
52 void readParameters(std::istream& in);
53
54 using Iterator<D>::isFlexible;
56
57 protected:
58
60 using Iterator<D>::system;
61 using Iterator<D>::isFlexible_;
62 using AmIteratorTmpl<Iterator<D>, DArray<double> >::setClassName;
64
70 void setup(bool isContinuation);
71
72 private:
73
74 // Local copy of interaction, adapted for use AMBD residual definition
75 AmbdInteraction interaction_;
76
78 double scaleStress_;
79
86 void setEqual(DArray<double>& a, DArray<double> const & b);
87
91 double dotProduct(DArray<double> const & a, DArray<double> const & b);
92
96 double maxAbs(DArray<double> const & hist);
97
104 void updateBasis(RingBuffer< DArray<double> > & basis,
105 RingBuffer< DArray<double> > const & hists);
106
115 void addHistories(DArray<double>& trial,
116 RingBuffer<DArray<double> > const & basis,
117 DArray<double> coeffs, int nHist);
118
126 void addPredictedError(DArray<double>& fieldTrial,
127 DArray<double> const & resTrial,
128 double lambda);
129
131 bool hasInitialGuess();
132
136 int nElements();
137
138 /*
139 * Get the current state of the system.
140 *
141 * \param curr current field vector (output)
142 */
143 void getCurrent(DArray<double>& curr);
144
148 void evaluate();
149
155 void getResidual(DArray<double>& resid);
156
162 void update(DArray<double>& newGuess);
163
167 void outputToLog();
168
169 // --- Private member functions specific to this implementation ---
170
171 cudaReal findAverage(cudaReal * const field, int n);
172
173 };
174
175} // namespace Pspg
176} // namespace Pscf
177#endif
Template for Anderson mixing iterator algorithm.
int verbose() const
Verbosity level, allowed values 0, 1, or 2.
int solve(bool isContinuation=false)
Iterate to a solution.
DArray< double > const & field() const
Return the current field or state vector by const reference.
Modified interaction to compute residual defn.
Pspg implementation of the Anderson Mixing iterator.
void setup(bool isContinuation)
Setup iterator just before entering iteration loop.
void readParameters(std::istream &in)
Read all parameters and initialize.
Base class for iterative solvers for SCF equations.
Main class in SCFT simulation of one system.
Definition: pspg/System.h:71
Dynamically allocatable contiguous array template.
Definition: DArray.h:32
ScalarParam< Type > & readOptional(std::istream &in, const char *label, Type &value)
Add and read a new optional ScalarParam < Type > object.
Class for storing history of previous values in an array.
Definition: RingBuffer.h:27
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
Definition: accumulators.mod:1