Loading [MathJax]/extensions/TeX/AMSsymbols.js
PSCF v1.2
rpc/solvers/Propagator.h
1#ifndef RPC_PROPAGATOR_H
2#define RPC_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 <prdc/cpu/RField.h> // member template
12#include <pscf/solvers/PropagatorTmpl.h> // base class 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 Rpc {
20
21 template <int D> class Block;
22
23 using namespace Util;
24 using namespace Pscf::Prdc;
25 using namespace Pscf::Prdc::Cpu;
26
48 template <int D>
49 class Propagator : public PropagatorTmpl< Propagator<D> >
50 {
51
52 public:
53
54 // Public typedefs
55
60
65
70
75
76 // Member functions
77
81 Propagator();
82
87
93 void setBlock(Block<D>& block);
94
109 void allocate(int ns, const Mesh<D>& mesh);
110
127 void reallocate(int ns);
128
140 void solve();
141
152 void solve(QField const & head);
153
164 double computeQ();
165
171 const QField& q(int i) const;
172
176 const QField& head() const;
177
181 const QField& tail() const;
182
186 Block<D>& block();
187
196 int ns() const;
197
201 bool isAllocated() const;
202
203 // Inherited public members with non-dependent names
204
211
212 protected:
213
217 void computeHead();
218
219 private:
220
222 DArray<QField> qFields_;
223
225 QField work_;
226
228 Block<D>* blockPtr_;
229
231 Mesh<D> const * meshPtr_;
232
234 int ns_;
235
237 bool isAllocated_;
238
239 };
240
241 // Inline member functions
242
243 /*
244 * Return q-field at beginning of block.
245 */
246 template <int D>
247 inline
249 { return qFields_[0]; }
250
251 /*
252 * Return q-field at end of block, after solution.
253 */
254 template <int D>
255 inline
257 { return qFields_[ns_-1]; }
258
259 /*
260 * Return q-field at specified step.
261 */
262 template <int D>
263 inline
264 typename Propagator<D>::QField const& Propagator<D>::q(int i) const
265 { return qFields_[i]; }
266
267 /*
268 * Get the associated Block object.
269 */
270 template <int D>
271 inline
273 {
274 assert(blockPtr_);
275 return *blockPtr_;
276 }
277
278 /*
279 * Get the number of counter grid points.
280 */
281 template <int D>
282 inline int Propagator<D>::ns() const
283 { return ns_; }
284
285 template <int D>
286 inline bool Propagator<D>::isAllocated() const
287 { return isAllocated_; }
288
289 /*
290 * Associate this propagator with a unique block.
291 */
292 template <int D>
294 { blockPtr_ = &block; }
295
296 #ifndef RPC_PROPAGATOR_TPP
297 extern template class Propagator<1>;
298 extern template class Propagator<2>;
299 extern template class Propagator<3>;
300 #endif
301
302}
303}
304#endif
Description of a regular grid of points in a periodic domain.
Field of real double precision values on an FFT mesh.
Template for propagator classes.
const Propagator< D > & partner() const
const Propagator< D > & source(int id) const
Block within a branched polymer.
MDE solver for one direction of one block.
RField< D > WField
Chemical potential field type (r-grid format)
void solve()
Solve the modified diffusion equation (MDE) for this block.
RField< D > Field
Generic field (function of position, defined on regular grid).
const QField & q(int i) const
Return q-field at specified step.
void setBlock(Block< D > &block)
Associate this propagator with a unique block.
RField< D > CField
Monomer concentration field type (r-grid format)
Block< D > & block()
Get the associated Block object by reference.
int ns() const
Number of values of s (or slices), including head and tail.
void allocate(int ns, const Mesh< D > &mesh)
Allocate memory used by this propagator.
RField< D > QField
Propagator q-field type, i.e., q(r,s) at fixed s.
bool isAllocated() const
Has memory been allocated for this propagator?
const QField & tail() const
Return q-field at the end of the block.
const QField & head() const
Return q-field at beginning of the block (initial condition).
void reallocate(int ns)
Reallocate memory used by this propagator.
void computeHead()
Compute initial QField at head from tail QFields of sources.
double computeQ()
Compute and return partition function for the polymer.
Dynamically allocatable contiguous array template.
Fields and FFTs for periodic boundary conditions (CPU)
Definition CField.cpp:12
Periodic fields and crystallography.
Definition CField.cpp:11
PSCF package top-level namespace.
Definition param_pc.dox:1
Utility classes for scientific computation.