PSCF v1.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
15namespace Pscf { template <int D> class Mesh; }
16
17namespace Pscf {
18namespace Rpc {
19
20 // Forward declaration
21 template <int D> class Block;
22
23 using namespace Util;
24 using namespace Pscf::Prdc;
25 using namespace Pscf::Prdc::Cpu;
26
50 template <int D>
51 class Propagator : public PropagatorTmpl< Propagator<D> >
52 {
53
54 public:
55
56 // Public typename aliases
57
62
67
68 // Member functions
69
73 Propagator();
74
79
85 void setBlock(Block<D>& block);
86
101 void allocate(int ns, const Mesh<D>& mesh);
102
114 void reallocate(int ns);
115
125 void solve();
126
136 void solve(FieldT const & head);
137
147 double computeQ() const;
148
154 const FieldT& q(int i) const;
155
159 const FieldT& head() const;
160
169 const FieldT& tail() const;
170
174 Block<D> const & block() const;
175
185 int ns() const;
186
190 bool isAllocated() const;
191
192 // Inherited public members with non-dependent names
193
194 using Base::nSource;
195 using Base::source;
196 using Base::partner;
197 using Base::setIsSolved;
198 using Base::isSolved;
199 using Base::hasPartner;
200 using Base::isHeadEnd;
201 using Base::isTailEnd;
202
203 private:
204
206 DArray<FieldT> qFields_;
207
209 FieldT work_;
210
212 Block<D>* blockPtr_;
213
215 Mesh<D> const * meshPtr_;
216
218 int ns_;
219
221 bool isAllocated_;
222
230 void computeHead();
231
235 void assign(FieldT& lhs, FieldT const & rhs);
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 {
249 return qFields_[0]; }
250
251 /*
252 * Return q-field at end of block.
253 */
254 template <int D>
255 inline
257 {
260 return qFields_[ns_-1];
261 }
262
263 /*
264 * Return q-field at specified step.
265 */
266 template <int D>
267 inline
268 typename Propagator<D>::FieldT const& Propagator<D>::q(int i) const
269 {
271 return qFields_[i];
272 }
273
274 /*
275 * Get the associated Block object by const reference.
276 */
277 template <int D>
278 inline
280 {
281 UTIL_ASSERT(blockPtr_);
282 return *blockPtr_;
283 }
284
285 /*
286 * Get the number of counter grid points.
287 */
288 template <int D>
289 inline int Propagator<D>::ns() const
290 { return ns_; }
291
292 template <int D>
293 inline bool Propagator<D>::isAllocated() const
294 { return isAllocated_; }
295
296 /*
297 * Associate this propagator with a unique block.
298 */
299 template <int D>
301 {
302 UTIL_ASSERT(blockPtr_);
303 blockPtr_ = &block;
304 }
305
306 #ifndef RPC_PROPAGATOR_TPP
307 // Suppress implicit instantiation
308 extern template class Propagator<1>;
309 extern template class Propagator<2>;
310 extern template class Propagator<3>;
311 #endif
312
313}
314}
315#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.
Definition param_pc.dox:1