1#ifndef CPC_PROPAGATOR_TPP
2#define CPC_PROPAGATOR_TPP
11#include "Propagator.h"
14#include <pscf/cpu/complex.h>
15#include <pscf/math/arithmetic.h>
16#include <pscf/mesh/Mesh.h>
44 template <
int D>
inline
61 qFields_.allocate(
ns);
62 for (
int i = 0; i <
ns; ++i) {
80 qFields_.deallocate();
91 qFields_.allocate(
ns);
92 for (
int i = 0; i <
ns; ++i) {
93 qFields_[i].allocate(meshPtr_->dimensions());
103 void Propagator<D>::computeHead()
106 int nx = meshPtr_->size();
109 FieldT& qh = qFields_[0];
112 for (
int ix = 0; ix < nx; ++ix) {
120 for (
int is = 0; is < nSource(); ++is) {
121 if (!source(is).isSolved()) {
122 UTIL_THROW(
"Source not solved in computeHead");
124 FieldT
const& qt = source(is).tail();
125 for (
int ix = 0; ix < nx; ++ix) {
126 mulEq(qh[ix], qt[ix]);
138 void Propagator<D>::assignField(FieldT& lhs, FieldT
const & rhs)
140 int nx = lhs.capacity();
142 for (
int ix = 0; ix < nx; ++ix) {
164 for (
int iStep = 0; iStep < ns_ - 1; ++iStep) {
165 block().stepThread(qFields_[iStep], qFields_[iStep + 1]);
173 assignField(qFields_[1], qFields_[0]);
175 block().stepHalfBondBead(qFields_[0], qFields_[1]);
177 block().stepFieldBead(qFields_[1]);
181 for (iStep = 1; iStep < ns_ - 2; ++iStep) {
182 block().stepBead(qFields_[iStep], qFields_[iStep + 1]);
187 assignField(qFields_[ns_-1], qFields_[ns_-2]);
189 block().stepHalfBondBead(qFields_[ns_-2], qFields_[ns_-1]);
209 int nx = meshPtr_->size();
214 for (
int i = 0; i < nx; ++i) {
222 for (
int iStep = 0; iStep < ns_ - 1; ++iStep) {
223 block().stepThread(qFields_[iStep], qFields_[iStep + 1]);
231 assignField(qFields_[1], qFields_[0]);
233 block().stepHalfBondBead(qFields_[0], qFields_[1]);
235 block().stepFieldBead(qFields_[1]);
239 for (iStep = 1; iStep < ns_ - 2; ++iStep) {
240 block().stepBead(qFields_[iStep], qFields_[iStep + 1]);
245 assignField(qFields_[ns_-1], qFields_[ns_-2]);
247 block().stepHalfBondBead(qFields_[ns_-2], qFields_[ns_-1]);
272 UTIL_THROW(
"Partner propagator is not solved");
276 int nx = meshPtr_->size();
283 for (
int ix = 0; ix < nx; ++ix) {
291 for (
int ix = 0; ix < nx; ++ix) {
297 double meshSize = double(nx);
298 divEq(sum, meshSize);
Block within a linear or branched block polymer.
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 Propagator< D > & partner() const
Get partner propagator.
bool isHeadEnd() const
Is the head vertex a chain end?
void solve()
Solve the modified diffusion equation (MDE) for this block.
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?
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.
bool hasPartner() const
Does this have a partner propagator?
void setBlock(Block< D > &block)
Associate this propagator with a block.
Description of a regular grid of points in a periodic domain.
IntVec< D > dimensions() const
Get an IntVec<D> of the grid dimensions.
#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.
void mulEq(fftw_complex &a, fftw_complex const &b)
In-place multiplication of two complex number, a *= b.
void addEq(fftw_complex &a, fftw_complex const &b)
In-place addition of fftw_complex numbers, a += b.
void assign(fftw_complex &z, double const &a, double const &b)
Create an fftw_complex from real and imaginary parts, z = a + ib.
void mul(fftw_complex &z, fftw_complex const &a, fftw_complex const &b)
Multiplication of fftw_complex numbers, z = a * b.
void divEq(fftw_complex &a, fftw_complex const &b)
In-place division of fftw_complex numbers, a /= b.
Complex periodic fields, CL-FTS (CPU).
bool isThread()
Is the thread model in use ?
bool isBead()
Is the bead model in use ?
PSCF package top-level namespace.
float product(float a, float b)
Product for float Data.