PSCF v1.3.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 <pscf/solvers/PropagatorTmpl.h> // base class template
12
13#include <prdc/cuda/RField.h> // member
14#include <pscf/cuda/DeviceArray.h> // member
15#include <util/containers/DArray.h> // member array
16
17
18// Forward declarations
19namespace Pscf {
20 template <int D> class Mesh;
21 namespace Rpg {
22 template <int D> class Block;
23 }
24}
25
26namespace Pscf {
27namespace Rpg {
28
29 using namespace Util;
30 using namespace Pscf::Prdc;
31 using namespace Pscf::Prdc::Cuda;
32
56 template <int D>
57 class Propagator : public PropagatorTmpl< Propagator<D> >
58 {
59
60 public:
61
62 // Public typename aliases
63
68
69
74
75 // Member functions
76
80 Propagator();
81
86
92 void setBlock(Block<D>& block);
93
108 void allocate(int ns, const Mesh<D>& mesh);
109
121 void reallocate(int ns);
122
132 void solve();
133
143 void solve(RField<D> const & head);
144
152 double computeQ();
153
159 RField<D> const & q(int i) const;
160
164 RField<D> const & head();
165
174 RField<D> const & tail() const;
175
179 DeviceArray<cudaReal> const & qAll();
180
184 Block<D>& block();
185
189 Block<D> const & block() const;
190
200 int ns() const;
201
205 bool isAllocated() const;
206
207 // Inherited public members with non-dependent names
208
209 using Base::nSource;
210 using Base::source;
211 using Base::partner;
212 using Base::setIsSolved;
213 using Base::isSolved;
214 using Base::hasPartner;
215 using Base::isHeadEnd;
216 using Base::isTailEnd;
217
218 private:
219
227 DeviceArray<cudaReal> qFieldsAll_;
228
237 DArray< RField<D> > qFields_;
238
240 Block<D>* blockPtr_;
241
243 Mesh<D> const * meshPtr_;
244
246 int ns_;
247
249 bool isAllocated_;
250
258 void computeHead();
259
260 };
261
262 // Inline member functions
263
264 /*
265 * Return q-field at initial (head) vertex of block.
266 */
267 template <int D>
268 inline
270 {
272 return qFields_[0];
273 }
274
275 /*
276 * Return q-field at final (tail) vertex of block.
277 */
278 template <int D>
279 inline
281 {
284 return qFields_[ns_-1];
285 }
286
287 /*
288 * Return const q-field at specified step by reference.
289 */
290 template <int D>
291 inline
292 RField<D> const & Propagator<D>::q(int i) const
293 {
295 return qFields_[i];
296 }
297
298 /*
299 * Return the full array of q-fields.
300 */
301 template <int D>
302 inline
304 {
306 return qFieldsAll_;
307 }
308
309 /*
310 * Get the associated Block object (non-const reference)
311 */
312 template <int D>
313 inline
315 {
316 assert(blockPtr_);
317 return *blockPtr_;
318 }
319
320 /*
321 * Get the associated Block object (const reference)
322 */
323 template <int D>
324 inline
326 {
327 assert(blockPtr_);
328 return *blockPtr_;
329 }
330
331 /*
332 * Get the number ns of chain contour points.
333 */
334 template <int D>
335 inline
337 { return ns_; }
338
339 template <int D>
340 inline
342 { return isAllocated_; }
343
344 /*
345 * Associate this propagator with a block and direction
346 */
347 template <int D>
348 inline
350 { blockPtr_ = &block; }
351
352 // Explicit instantiation declarations
353 extern template class Propagator<1>;
354 extern template class Propagator<2>;
355 extern template class Propagator<3>;
356
357}
358}
359#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 CField.cu:12
Periodic fields and crystallography.
Definition CField.cpp:11
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.