1#ifndef PSPG_PROPAGATOR_TPP
2#define PSPG_PROPAGATOR_TPP
11#include "Propagator.h"
13#include <thrust/reduce.h>
14#include "device_launch_parameters.h"
17#include <thrust/count.h>
18#include <pspg/math/GpuResources.h>
19#include <pscf/mesh/Mesh.h>
60 gpuErrchk(cudaMalloc((
void**)&qFields_d,
sizeof(cudaReal)* mesh.
size() *
78 int nx = meshPtr_->size();
81 int nBlocks, nThreads;
86 assignUniformReal<<<nBlocks, nThreads>>>(qFields_d, 1.0, nx);
93 for (
int is = 0; is < nSource(); ++is) {
94 if (!source(is).isSolved()) {
95 UTIL_THROW(
"Source not solved in computeHead");
98 qt = source(is).tail();
101 inPlacePointwiseMul<<<nBlocks, nThreads>>>(qFields_d, qt, nx);
119 for (
int iStep = 0; iStep < ns_ - 1; ++iStep) {
120 currentIdx = iStep * meshPtr_->size();
122 block().step(qFields_d + currentIdx, qFields_d + currentIdx + meshPtr_->size());
134 int nx = meshPtr_->size();
137 int nBlocks, nThreads;
141 cudaReal* qh = qFields_d;
143 assignReal<<<nBlocks, nThreads>>>(qh, head, nx);
147 for (
int iStep = 0; iStep < ns_ - 1; ++iStep) {
148 currentIdx = iStep * nx;
149 block().step(qFields_d + currentIdx, qFields_d + currentIdx + nx);
167 if (!partner().isSolved()) {
168 UTIL_THROW(
"Partner propagator is not solved");
170 const cudaReal * qh = head();
171 const cudaReal * qt = partner().tail();
172 int nx = meshPtr_->size();
179 Q = gpuInnerProduct(qh, qt, nx);
Description of a regular grid of points in a periodic domain.
int size() const
Get total number of grid points.
double computeQ()
Compute and return partition function for the molecule.
void solve()
Solve the modified diffusion equation (MDE) for this block.
void computeHead()
Compute initial QField at head from tail QFields of sources.
void allocate(int ns, const Mesh< D > &mesh)
Associate this propagator with a block.
#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.
int nBlocks()
Get the current number of blocks for execution.
void setThreadsLogical(int nThreadsLogical)
Set the total number of threads required for execution.
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.