1#ifndef RPG_PROPAGATOR_TPP
2#define RPG_PROPAGATOR_TPP
11#include "Propagator.h"
13#include <prdc/cuda/resources.h>
14#include <pscf/mesh/Mesh.h>
15#include <util/containers/DArray.h>
50 int meshSize = meshPtr_->
size();
51 qFieldsAll_.allocate(
ns * meshSize);
54 qFields_.allocate(
ns);
55 for (
int i = 0; i <
ns; ++i) {
56 qFields_[i].associate(qFieldsAll_, i*meshSize, meshPtr_->dimensions());
74 qFields_.deallocate();
76 qFieldsAll_.deallocate();
79 int meshSize = meshPtr_->size();
80 qFieldsAll_.allocate(
ns * meshSize);
83 qFields_.allocate(
ns);
84 for (
int i = 0; i <
ns; ++i) {
85 qFields_[i].associate(qFieldsAll_, i*meshSize,
86 meshPtr_->dimensions());
96 void Propagator<D>::computeHead()
99 int nx = meshPtr_->size();
108 tails[0] = &qFields_[0];
109 for (
int is = 0; is < nSource(); ++is) {
110 if (!source(is).isSolved()) {
111 UTIL_THROW(
"Source not solved in computeHeadThread");
113 tails[is+1] = &(source(is).tail());
134 for (
int iStep = 0; iStep < ns_ - 1; ++iStep) {
135 block().stepThread(qFields_[iStep], qFields_[iStep + 1]);
145 block().stepHalfBondBead(qFields_[0], qFields_[1]);
147 block().stepFieldBead(qFields_[1]);
151 for (iStep = 1; iStep < ns_ - 2; ++iStep) {
152 block().stepBead(qFields_[iStep], qFields_[iStep + 1]);
159 block().stepHalfBondBead(qFields_[ns_-2], qFields_[ns_-1]);
184 for (
int iStep = 0; iStep < ns_ - 1; ++iStep) {
185 block().stepThread(qFields_[iStep], qFields_[iStep + 1]);
195 block().stepHalfBondBead(qFields_[0], qFields_[1]);
197 block().stepFieldBead(qFields_[1]);
201 for (iStep = 1; iStep < ns_ - 2; ++iStep) {
202 block().stepBead(qFields_[iStep], qFields_[iStep + 1]);
209 block().stepHalfBondBead(qFields_[ns_-2], qFields_[ns_-1]);
235 UTIL_THROW(
"Partner propagator is not solved");
248 Q = Reduce::innerProduct(qh, qt);
250 Q /= double(meshPtr_->size());
Description of a regular grid of points in a periodic domain.
int size() const
Get total number of grid points.
Field of real double precision values on an FFT mesh.
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.
const Propagator< D > & partner() const
Get partner propagator.
void solve()
Solve the modified diffusion equation (MDE) for this block.
bool isHeadEnd() const
Is the head vertex a chain end?
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.
void setIsSolved(bool isSolved)
Set the isSolved flag to true or false.
bool isSolved() const
Has the modified diffusion equation been solved?
bool isTailEnd() const
Is the tail vertex a chain end?
bool isAllocated() const
Has memory been allocated for this propagator?
bool hasPartner() const
Does this have a partner propagator?
void reallocate(int ns)
Reallocate memory used by this propagator.
Dynamically allocatable contiguous array template.
void allocate(int capacity)
Allocate the underlying C array.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
bool isThread()
Is the thread model in use ?
bool isBead()
Is the bead model in use ?
void eqV(DeviceArray< cudaReal > &a, DeviceArray< cudaReal > const &b, const int beginIdA, const int beginIdB, const int n)
Vector assignment, a[i] = b[i], kernel wrapper (cudaReal).
void eqS(DeviceArray< cudaReal > &a, const cudaReal b, const int beginIdA, const int n)
Vector assignment, a[i] = b, kernel wrapper (cudaReal).
void mulVMany(DeviceArray< cudaReal > &a, DArray< DeviceArray< cudaReal > > const &vecs)
Multiply an undefined number of vectors pointwise, kernel wrapper.
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.