PSCF v1.1
pspc/solvers/Propagator.h
1#ifndef PSPC_PROPAGATOR_H
2#define PSPC_PROPAGATOR_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 <pscf/solvers/PropagatorTmpl.h> // base class template
12#include <pspc/field/RField.h> // member template
13#include <util/containers/DArray.h> // member template
14#include <util/containers/FArray.h> // member template
15
16namespace Pscf { template <int D> class Mesh; }
17
18namespace Pscf {
19namespace Pspc
20{
21
22 template <int D> class Block;
23 using namespace Util;
24
46 template <int D>
47 class Propagator : public PropagatorTmpl< Propagator<D> >
48 {
49
50 public:
51
52 // Public typedefs
53
58
63
68
73
74 // Member functions
75
79 Propagator();
80
85
91 void setBlock(Block<D>& block);
92
107 void allocate(int ns, const Mesh<D>& mesh);
108
125 void reallocate(int ns);
126
138 void solve();
139
150 void solve(QField const & head);
151
162 double computeQ();
163
169 const QField& q(int i) const;
170
174 const QField& head() const;
175
179 const QField& tail() const;
180
184 Block<D>& block();
185
194 int ns() const;
195
199 bool isAllocated() const;
200
201 // Inherited public members with non-dependent names
202
209
210 protected:
211
215 void computeHead();
216
217 private:
218
220 DArray<QField> qFields_;
221
223 QField work_;
224
226 Block<D>* blockPtr_;
227
229 Mesh<D> const * meshPtr_;
230
232 int ns_;
233
235 bool isAllocated_;
236
237 };
238
239 // Inline member functions
240
241 /*
242 * Return q-field at beginning of block.
243 */
244 template <int D>
245 inline
247 { return qFields_[0]; }
248
249 /*
250 * Return q-field at end of block, after solution.
251 */
252 template <int D>
253 inline
255 { return qFields_[ns_-1]; }
256
257 /*
258 * Return q-field at specified step.
259 */
260 template <int D>
261 inline
262 typename Propagator<D>::QField const& Propagator<D>::q(int i) const
263 { return qFields_[i]; }
264
265 /*
266 * Get the associated Block object.
267 */
268 template <int D>
269 inline
271 {
272 assert(blockPtr_);
273 return *blockPtr_;
274 }
275
276 /*
277 * Get the number of counter grid points.
278 */
279 template <int D>
280 inline int Propagator<D>::ns() const
281 { return ns_; }
282
283 template <int D>
284 inline bool Propagator<D>::isAllocated() const
285 { return isAllocated_; }
286
287 /*
288 * Associate this propagator with a unique block.
289 */
290 template <int D>
292 { blockPtr_ = &block; }
293
294 #ifndef PSPC_PROPAGATOR_TPP
295 extern template class Propagator<1>;
296 extern template class Propagator<2>;
297 extern template class Propagator<3>;
298 #endif
299
300}
301}
302#endif
Description of a regular grid of points in a periodic domain.
Definition: Mesh.h:61
Template for propagator classes.
void setIsSolved(bool isSolved)
Set the isSolved flag to true or false.
const Propagator< D > & partner() const
Get partner propagator.
const Propagator< D > & source(int id) const
Get a source propagator.
bool isSolved() const
Has the modified diffusion equation been solved?
bool hasPartner() const
Does this have a partner propagator?
int nSource() const
Number of source / prerequisite propagators.
Block within a branched polymer.
MDE solver for one direction of one block.
RField< D > CField
Monomer concentration field type (r-grid format)
void computeHead()
Compute initial QField at head from tail QFields of sources.
RField< D > WField
Chemical potential field type (r-grid format)
RField< D > QField
Propagator q-field type, i.e., q(r,s) at fixed s.
int ns() const
Number of values of s (or slices), including head and tail.
bool isAllocated() const
Has memory been allocated for this propagator?
void setBlock(Block< D > &block)
Associate this propagator with a unique block.
Block< D > & block()
Get the associated Block object by reference.
void solve()
Solve the modified diffusion equation (MDE) for this block.
void reallocate(int ns)
Reallocate memory used by this propagator.
RField< D > Field
Generic field (function of position, defined on regular grid).
double computeQ()
Compute and return partition function for the polymer.
const QField & q(int i) const
Return q-field at specified step.
const QField & tail() const
Return q-field at the end of the block.
void allocate(int ns, const Mesh< D > &mesh)
Allocate memory used by this propagator.
const QField & head() const
Return q-field at beginning of the block (initial condition).
Field of real double precision values on an FFT mesh.
Definition: RField.h:29
Dynamically allocatable contiguous array template.
Definition: DArray.h:32
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
Definition: accumulators.mod:1