PSCF v1.4.0
rp/solvers/Propagator.h
1#ifndef RP_PROPAGATOR_H
2#define RP_PROPAGATOR_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2025, 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 <util/containers/DArray.h> // member
13
14
15// Forward declaration
16namespace Pscf {
17 template <int D> class Mesh;
18}
19
20namespace Pscf {
21namespace Rp {
22
23 using namespace Util;
24
58 template <int D, class T>
59 class Propagator : public PropagatorTmpl<typename T::Propagator>
60 {
61
62 public:
63
69 void setBlock(typename T::Block& block);
70
85 virtual void allocate(int ns, const Mesh<D>& mesh);
86
98 virtual void reallocate(int ns);
99
109 void solve();
110
120 void solve(typename T::RField const & head);
121
131 void computeQ(double & Q) const;
132
138 const typename T::RField& q(int i) const;
139
143 const typename T::RField& head() const;
144
153 const typename T::RField& tail() const;
154
158 typename T::Block const & block() const;
159
163 Mesh<D> const & mesh() const;
164
174 int ns() const;
175
179 bool isAllocated() const;
180
183
184 // Inherited non-dependent members (selected, for convenience)
187
188 protected:
189
192
194 int ns_;
195
198
203
208
218
225 void solveMde();
226
230 typename T::Block& block();
231
232 private:
233
235 typename T::Block* blockPtr_;
236
238 Mesh<D> const * meshPtr_;
239
240 };
241
242 // Inline member functions
243
244 /*
245 * Return q-field at beginning of block.
246 */
247 template <int D, class T> inline
248 typename T::RField const& Propagator<D,T>::head() const
249 {
251 return qFields_[0];
252 }
253
254 /*
255 * Return q-field at end of block.
256 */
257 template <int D, class T> inline
258 typename T::RField const& Propagator<D,T>::tail() const
259 {
262 return qFields_[ns_-1];
263 }
264
265 /*
266 * Return q-field at specified step.
267 */
268 template <int D, class T> inline
269 typename T::RField const& Propagator<D,T>::q(int i) const
270 {
272 return qFields_[i];
273 }
274
275 /*
276 * Get the associated Block object by const reference.
277 */
278 template <int D, class T> inline
279 typename T::Block const & Propagator<D,T>::block() const
280 {
281 UTIL_ASSERT(blockPtr_);
282 return *blockPtr_;
283 }
284
285 /*
286 * Get the associated Block object by non-const reference.
287 */
288 template <int D, class T> inline
289 typename T::Block& Propagator<D,T>::block()
290 {
291 UTIL_ASSERT(blockPtr_);
292 return *blockPtr_;
293 }
294
295 /*
296 * Get the associated Mesh object by const reference.
297 */
298 template <int D, class T> inline
300 {
301 UTIL_ASSERT(meshPtr_);
302 return *meshPtr_;
303 }
304
305 /*
306 * Get the number of counter grid points.
307 */
308 template <int D, class T> inline
310 { return ns_; }
311
312 /*
313 * Has memory been allocated for this propagator?
314 */
315 template <int D, class T> inline
317 { return isAllocated_; }
318
319 /*
320 * Associate this propagator with a unique block.
321 */
322 template <int D, class T> inline
323 void Propagator<D,T>::setBlock(typename T::Block& block)
324 { blockPtr_ = &block; }
325
326} // namespace Rp
327} // namespace Pscf
328#endif
Description of a regular grid of points in a periodic domain.
Definition Mesh.h:61
const typename T::Propagator & partner() const
const typename T::Propagator & source(int id) const
Mesh< D > const & mesh() const
T::Block & block()
Get the associated Block object by non-const reference.
void solve(typename T::RField const &head)
Solve the MDE for a specified initial condition.
void setBlock(typename T::Block &block)
Associate this propagator with a block.
void computeQ(double &Q) const
Compute and return partition function for the polymer molecule.
bool isAllocated() const
Has memory been allocated for this propagator?
const Types< D >::RField & head() const
Types< D >::Block const & block() const
void computeHead()
Compute initial q-field at the head vertex.
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).
PropagatorTmpl< typename T::Propagator > PropagatorTmplT
Direct (parent) base class.
const T::RField & tail() const
Return q-field at the terminal (tail) vertex.
const T::RField & q(int i) const
Return q-field at a specified step.
DArray< typename Types< D >::RField > qFields_
virtual void allocate(int ns, const Mesh< D > &mesh)
Allocate memory used by this propagator.
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 ?
Class templates for real-valued periodic fields.
PSCF package top-level namespace.