PSCF v1.3
rpg/solvers/Propagator.h
1#ifndef RPG_PROPAGATOR_H
2#define RPG_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 <prdc/cuda/RField.h> // member array
12#include <pscf/cuda/DeviceArray.h> // member array
13#include <pscf/solvers/PropagatorTmpl.h> // base class template
14#include <util/containers/DArray.h> // member array
15
16
17namespace Pscf { template <int D> class Mesh; }
18
19namespace Pscf {
20namespace Rpg {
21
22 // Forward declaration
23 template <int D> class Block;
24
25 using namespace Util;
26 using namespace Pscf::Prdc;
27 using namespace Pscf::Prdc::Cuda;
28
52 template <int D>
53 class Propagator : public PropagatorTmpl< Propagator<D> >
54 {
55
56 public:
57
58 // Public typename aliases
59
64
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(RField<D> const & head);
140
148 double computeQ();
149
155 RField<D> const & q(int i) const;
156
160 RField<D> const & head();
161
170 RField<D> const & tail() const;
171
175 DeviceArray<cudaReal> const & qAll();
176
180 Block<D>& block();
181
185 Block<D> const & block() const;
186
196 int ns() const;
197
201 bool isAllocated() const;
202
203 // Inherited public members with non-dependent names
204
205 using Base::nSource;
206 using Base::source;
207 using Base::partner;
208 using Base::setIsSolved;
209 using Base::isSolved;
210 using Base::hasPartner;
211 using Base::isHeadEnd;
212 using Base::isTailEnd;
213
214 private:
215
223 DeviceArray<cudaReal> qFieldsAll_;
224
233 DArray< RField<D> > qFields_;
234
236 Block<D>* blockPtr_;
237
239 Mesh<D> const * meshPtr_;
240
242 int ns_;
243
245 bool isAllocated_;
246
254 void computeHead();
255
256 };
257
258 // Inline member functions
259
260 /*
261 * Return q-field at initial (head) vertex of block.
262 */
263 template <int D>
264 inline
266 {
268 return qFields_[0];
269 }
270
271 /*
272 * Return q-field at final (tail) vertex of block.
273 */
274 template <int D>
275 inline
277 {
280 return qFields_[ns_-1];
281 }
282
283 /*
284 * Return const q-field at specified step by reference.
285 */
286 template <int D>
287 inline
288 RField<D> const & Propagator<D>::q(int i) const
289 {
291 return qFields_[i];
292 }
293
294 /*
295 * Return the full array of q-fields.
296 */
297 template <int D>
298 inline
300 {
302 return qFieldsAll_;
303 }
304
305 /*
306 * Get the associated Block object (non-const reference)
307 */
308 template <int D>
309 inline
311 {
312 assert(blockPtr_);
313 return *blockPtr_;
314 }
315
316 /*
317 * Get the associated Block object (const reference)
318 */
319 template <int D>
320 inline
322 {
323 assert(blockPtr_);
324 return *blockPtr_;
325 }
326
327 /*
328 * Get the number ns of chain contour points.
329 */
330 template <int D>
331 inline
333 { return ns_; }
334
335 template <int D>
336 inline
338 { return isAllocated_; }
339
340 /*
341 * Associate this propagator with a block and direction
342 */
343 template <int D>
344 inline
346 { blockPtr_ = &block; }
347
348 #ifndef RPG_PROPAGATOR_TPP
349 // Suppress implicit instantiation
350 extern template class Propagator<1>;
351 extern template class Propagator<2>;
352 extern template class Propagator<3>;
353 #endif
354
355}
356}
357#endif
Dynamic array on the GPU device with aligned data.
Definition DeviceArray.h:43
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 branched polymer.
MDE solver for one-direction of one block.
Block< D > & block()
Get the associated Block object by reference.
int ns() const
Get the number of values of s (or slices), including head and tail.
void solve()
Solve the modified diffusion equation (MDE) for this block.
DeviceArray< cudaReal > const & qAll()
Return the full array of q-fields as an unrolled 1D array.
double computeQ()
Compute and return partition function for the molecule.
void allocate(int ns, const Mesh< D > &mesh)
Allocate propagator arrays.
RField< D > const & head()
Return q-field at initial (head) vertex.
bool isSolved() const
Has the modified diffusion equation been solved?
bool isTailEnd() const
Is the tail vertex a chain end?
PropagatorTmpl< Propagator< D > > Base
Base class type (partial template specialization).
RField< D > const & tail() const
Return q-field at terminal (tail) vertex.
RField< D > const & q(int i) const
Return q-field at specified slice.
bool isAllocated() const
Has memory been allocated for this propagator?
void setBlock(Block< D > &block)
Associate this propagator with a block.
RField< D > FieldT
Field type (function of position, defined on real space grid).
void reallocate(int ns)
Reallocate 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
bool isThread()
Is the thread model in use ?
Fields, FFTs, and utilities for periodic boundary conditions (CUDA)
Definition Reduce.cpp:14
Periodic fields and crystallography.
Definition CField.cpp:11
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.
Definition param_pc.dox:1