PSCF v1.4.0
cpc/solvers/Propagator.h
1#ifndef CPC_PROPAGATOR_H
2#define CPC_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/CField.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 Cpc {
19 template <int D> class Block;
20 }
21}
22
23namespace Pscf {
24namespace Cpc {
25
26 using namespace Util;
27 using namespace Pscf::Prdc;
28 using namespace Pscf::Prdc::Cpu;
29
52 template <int D>
53 class Propagator : public PropagatorTmpl< Propagator<D> >
54 {
55
56 public:
57
58 // Public typename aliases
59
64
69
70 // Member functions
71
75 Propagator();
76
81
87 void setBlock(Block<D>& block);
88
103 void allocate(int ns, const Mesh<D>& mesh);
104
116 void reallocate(int ns);
117
127 void solve();
128
138 void solve(FieldT const & head);
139
149 void computeQ(std::complex<double>& Q) const;
150
156 const FieldT& q(int i) const;
157
161 const FieldT& head() const;
162
171 const FieldT& tail() const;
172
176 Block<D> const & block() const;
177
187 int ns() const;
188
192 bool isAllocated() const;
193
194 // Inherited public members with non-dependent names
195
196 using Base::nSource;
197 using Base::source;
198 using Base::partner;
199 using Base::setIsSolved;
200 using Base::isSolved;
201 using Base::hasPartner;
202 using Base::isHeadEnd;
203 using Base::isTailEnd;
204
205 private:
206
208 DArray<FieldT> qFields_;
209
211 FieldT work_;
212
214 Block<D> * blockPtr_;
215
217 Mesh<D> const * meshPtr_;
218
220 int ns_;
221
223 bool isAllocated_;
224
225 // Private member functions
226
234 void computeHead();
235
242 void assignField(FieldT & lhs, FieldT const & rhs);
243
244 };
245
246 // Inline member functions
247
248 /*
249 * Return q-field at the head (beginning) of the block.
250 */
251 template <int D> inline
253 {
255 return qFields_[0]; }
256
257 /*
258 * Return q-field at the tail (end) of the block.
259 */
260 template <int D> inline
262 {
265 return qFields_[ns_-1];
266 }
267
268 /*
269 * Return q-field at a specified step.
270 */
271 template <int D> inline
272 typename Propagator<D>::FieldT const& Propagator<D>::q(int i) const
273 {
275 return qFields_[i];
276 }
277
278 /*
279 * Get the associated Block object by const reference.
280 */
281 template <int D> 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> inline
293 { return ns_; }
294
295 template <int D> inline
297 { return isAllocated_; }
298
299 // Explicit instantiation declarations
300 extern template class Propagator<1>;
301 extern template class Propagator<2>;
302 extern template class Propagator<3>;
303
304} // namespace Cpc
305} // namespace Pscf
306#endif
Block within a linear or branched block polymer.
MDE solver for one direction of one block.
Block< D > const & block() const
Get the associated Block<D> object by const reference.
void computeQ(std::complex< double > &Q) const
Compute and return partition function for the polymer.
const FieldT & tail() const
Return q-field at the end of the block.
PropagatorTmpl< Propagator< D > > Base
Base class (partial template specialization).
void solve()
Solve the modified diffusion equation (MDE) for this block.
bool isSolved() const
Has the modified diffusion equation been solved?
bool isTailEnd() const
Is the tail vertex a chain end?
const FieldT & head() const
Return q-field at beginning of the block (initial condition).
void reallocate(int ns)
Reallocate memory used by this propagator.
int ns() const
Get the number of values of s (or slices), including head and tail.
bool isAllocated() const
Has memory been allocated for this propagator?
CField< D > FieldT
Field type (function of position, defined on a r-space grid).
void allocate(int ns, const Mesh< D > &mesh)
Allocate memory used by this propagator.
const FieldT & q(int i) const
Return slice of q-field at a specified step.
void setBlock(Block< D > &block)
Associate this propagator with a block.
Description of a regular grid of points in a periodic domain.
Definition Mesh.h:61
Field of complex double precision values on an FFT mesh.
Definition cpu/CField.h:29
const Propagator< D > & partner() const
const Propagator< D > & source(int id) const
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
Complex periodic fields, CL-FTS (CPU).
Definition cpc.mod:6
bool isThread()
Is the thread model in use ?
Fields and FFTs for periodic boundary conditions (CPU)
Definition complex.cpp:12
Periodic fields and crystallography.
Definition complex.cpp:11
PSCF package top-level namespace.