PSCF v1.3.3
rpc/solvers/Propagator.h
1#ifndef RPC_PROPAGATOR_H
2#define RPC_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 <prdc/cpu/RField.h> // member template
13#include <util/containers/DArray.h> // member template
14
15// Forward declarations
16namespace Pscf {
17 template <int D> class Mesh;
18 namespace Rpc {
19 template <int D> class Block;
20 }
21}
22
23namespace Pscf {
24namespace Rpc {
25
26 using namespace Util;
27 using namespace Pscf::Prdc;
28 using namespace Pscf::Prdc::Cpu;
29
53 template <int D>
54 class Propagator : public PropagatorTmpl< Propagator<D> >
55 {
56
57 public:
58
59 // Public typename aliases
60
65
70
71 // Member functions
72
76 Propagator();
77
82
88 void setBlock(Block<D>& block);
89
104 void allocate(int ns, const Mesh<D>& mesh);
105
117 void reallocate(int ns);
118
128 void solve();
129
139 void solve(FieldT const & head);
140
150 double computeQ() const;
151
157 const FieldT& q(int i) const;
158
162 const FieldT& head() const;
163
172 const FieldT& tail() const;
173
177 Block<D> const & block() const;
178
188 int ns() const;
189
193 bool isAllocated() const;
194
195 // Inherited public members with non-dependent names
196
197 using Base::nSource;
198 using Base::source;
199 using Base::partner;
200 using Base::setIsSolved;
201 using Base::isSolved;
202 using Base::hasPartner;
203 using Base::isHeadEnd;
204 using Base::isTailEnd;
205
206 private:
207
209 DArray<FieldT> qFields_;
210
212 FieldT work_;
213
215 Block<D>* blockPtr_;
216
218 Mesh<D> const * meshPtr_;
219
221 int ns_;
222
224 bool isAllocated_;
225
233 void computeHead();
234
238 void assign(FieldT& lhs, FieldT const & rhs);
239
240 };
241
242 // Inline member functions
243
244 /*
245 * Return q-field at beginning of block.
246 */
247 template <int D>
248 inline
250 {
252 return qFields_[0]; }
253
254 /*
255 * Return q-field at end of block.
256 */
257 template <int D>
258 inline
260 {
263 return qFields_[ns_-1];
264 }
265
266 /*
267 * Return q-field at specified step.
268 */
269 template <int D>
270 inline
271 typename Propagator<D>::FieldT const& Propagator<D>::q(int i) const
272 {
274 return qFields_[i];
275 }
276
277 /*
278 * Get the associated Block object by const reference.
279 */
280 template <int D>
281 inline
283 {
284 UTIL_ASSERT(blockPtr_);
285 return *blockPtr_;
286 }
287
288 /*
289 * Get the number of counter grid points.
290 */
291 template <int D>
292 inline int Propagator<D>::ns() const
293 { return ns_; }
294
295 template <int D>
296 inline bool Propagator<D>::isAllocated() const
297 { return isAllocated_; }
298
299 /*
300 * Associate this propagator with a unique block.
301 */
302 template <int D>
304 { blockPtr_ = &block; }
305
306 // Explicit instantiation declarations
307 extern template class Propagator<1>;
308 extern template class Propagator<2>;
309 extern template class Propagator<3>;
310
311}
312}
313#endif
Description of a regular grid of points in a periodic domain.
Definition Mesh.h:61
Field of real double precision values on an FFT mesh.
Definition cpu/RField.h:29
const Propagator< D > & partner() const
const Propagator< D > & source(int id) const
Block within a linear or branched block polymer.
MDE solver for one direction of one block.
void solve()
Solve the modified diffusion equation (MDE) for this block.
double computeQ() const
Compute and return partition function for the polymer.
void setBlock(Block< D > &block)
Associate this propagator with a block.
int ns() const
Get the 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.
bool isSolved() const
Has the modified diffusion equation been solved?
bool isTailEnd() const
Is the tail vertex a chain end?
const FieldT & tail() const
Return q-field at the end of the block.
bool isAllocated() const
Has memory been allocated for this propagator?
const FieldT & q(int i) const
Return q-field at specified step.
const FieldT & head() const
Return q-field at beginning of the block (initial condition).
void reallocate(int ns)
Reallocate memory used by this propagator.
Block< D > const & block() const
Get the associated Block object by const reference.
RField< D > FieldT
Field type (function of position, defined on a r-space grid).
PropagatorTmpl< Propagator< D > > Base
Base class (partial template specialization).
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 ?
Fields and FFTs for periodic boundary conditions (CPU)
Definition CField.cpp:12
Periodic fields and crystallography.
Definition CField.cpp:11
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.