PSCF v1.5.0
PropagatorBase.h
1#ifndef RP_PROPAGATOR_BASE_H
2#define RP_PROPAGATOR_BASE_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <pscf/solvers/PropagatorTmpl.h> // base class template
12#include <util/containers/DArray.h> // member
13
14
15// Forward declaration
16namespace Pscf {
17 template <int D> class Mesh;
18}
19namespace Pscf {
20 template <int D, class T> class RField;
21 namespace Rp {
22 template <int D, class T> class Propagator;
23 template <int D, class T> class Block;
24 }
25}
26
27namespace Pscf {
28namespace Rp {
29
30 using namespace Util;
31
80 template <int D, class T>
81 class PropagatorBase : public PropagatorTmpl< Propagator<D,T> >
82 {
83
84 public:
85
92
107 virtual void allocate(int ns, const Mesh<D>& mesh);
108
120 virtual void reallocate(int ns);
121
131 void solve();
132
142 void solve(RField<D,T> const & head);
143
153 void computeQ(double & Q) const;
154
160 RField<D,T> const & q(int i) const;
161
165 RField<D,T> const & head() const;
166
175 RField<D,T> const & tail() const;
176
180 Block<D,T> const & block() const;
181
185 Mesh<D> const & mesh() const;
186
196 int ns() const;
197
201 bool isAllocated() const;
202
205
206 // Inherited non-dependent members (selected, for convenience)
209
210 protected:
211
212 // Protected member functions
213
218
223
233
240 void solveMde();
241
246
247 // Protected member variables
248
251
253 int ns_;
254
257
258 private:
259
261 Block<D,T>* blockPtr_;
262
264 Mesh<D> const * meshPtr_;
265
267 bool hasComputedHead_;
268
269 };
270
271 // Inline member functions
272
273 /*
274 * Return q-field at beginning of block.
275 */
276 template <int D, class T> inline
278 {
280 return qFields_[0];
281 }
282
283 /*
284 * Return q-field at end of block.
285 */
286 template <int D, class T> inline
293
294 /*
295 * Return q-field at specified step.
296 */
297 template <int D, class T> inline
299 {
301 return qFields_[i];
302 }
303
304 /*
305 * Get the associated Block object by const reference.
306 */
307 template <int D, class T> inline
309 {
310 UTIL_ASSERT(blockPtr_);
311 return *blockPtr_;
312 }
313
314 /*
315 * Get the associated Block object by non-const reference.
316 */
317 template <int D, class T> inline
319 {
320 UTIL_ASSERT(blockPtr_);
321 return *blockPtr_;
322 }
323
324 /*
325 * Get the associated Mesh object by const reference.
326 */
327 template <int D, class T> inline
329 {
330 UTIL_ASSERT(meshPtr_);
331 return *meshPtr_;
332 }
333
334 /*
335 * Get the number of contour grid points, including ends.
336 */
337 template <int D, class T> inline
339 { return ns_; }
340
341 /*
342 * Has memory been allocated for this propagator?
343 */
344 template <int D, class T> inline
346 { return isAllocated_; }
347
348 /*
349 * Associate this propagator with a unique block.
350 */
351 template <int D, class T> inline
354
355} // namespace Rp
356} // namespace Pscf
357#endif
Description of a regular grid of points in a periodic domain.
Definition Mesh.h:61
const QT & partner() const
Get partner propagator.
const QT & source(int id) const
Get a source propagator.
virtual void reallocate(int ns)
Reallocate memory used by this propagator.
void solve()
Solve the modified diffusion equation (MDE) for this block.
void solveMde()
Compute solution of modified diffusion equation (MDE).
RField< D, T > const & q(int i) const
Return q-field at a specified step.
DArray< RField< D, CPT > > qFields_
Mesh< D > const & mesh() const
void setBlock(Block< D, T > &block)
Associate this propagator with a block.
PropagatorTmpl< Propagator< D, CPT > > PropagatorTmplT
RField< D, CPT > const & head() const
void solve(RField< D, T > const &head)
Solve the MDE for a specified initial condition.
bool isAllocated() const
Has memory been allocated for this propagator?
virtual void allocate(int ns, const Mesh< D > &mesh)
Allocate memory used by this propagator.
RField< D, T > const & tail() const
Return q-field at the terminal (tail) vertex.
Block< D, T > & block()
Get the associated Block object by non-const reference.
Block< D, CPT > const & block() const
void computeQ(double &Q) const
Compute and return partition function for the polymer molecule.
void computeHead()
Compute initial q-field at the head vertex.
Dynamically allocatable contiguous array template.
Definition DArray.h:32
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
#define UTIL_ASSERT(condition)
Assertion macro suitable for debugging serial or parallel code.
Definition global.h:75
bool isThread()
Is the thread model in use ?
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.