PSCF v1.1
pspg/solvers/Propagator.h
1#ifndef PSPG_PROPAGATOR_H
2#define PSPG_PROPAGATOR_H
3
4/*
5* PSCF - Polymer Self-Consistent Field Theory
6*
7* Copyright 2016 - 2022, 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#include <pspg/field/RDField.h> // member template
13#include <util/containers/DArray.h> // member template
14
15namespace Pscf { template <int D> class Mesh; }
16
17namespace Pscf {
18namespace Pspg
19{
20
21 template <int D> class Block;
22 using namespace Util;
23
45 template <int D>
46 class Propagator : public PropagatorTmpl< Propagator<D> >
47 {
48
49 public:
50
51 // Public typedefs
52
57
62
67
72
73 // Member functions
74
78 Propagator();
79
84
90 void setBlock(Block<D>& block);
91
98 void allocate(int ns, const Mesh<D>& mesh);
99
109 void solve();
110
121 void solve(const cudaReal * head);
122
130 double computeQ();
131
137 const cudaReal* q(int i) const;
138
142 cudaReal* head() const;
143
147 const cudaReal* tail() const;
148
152 Block<D>& block();
153
157 Block<D> const & block() const;
158
162 int ns() const;
163
167 bool isAllocated() const;
168
175
176 protected:
177
181 void computeHead();
182
183 private:
184
185 // new array purely in device
186 cudaReal* qFields_d;
187 // Workspace
188 // removing this. Does not seem to be used anywhere
189 //QField work_;
190
192 Block<D>* blockPtr_;
193
195 Mesh<D> const * meshPtr_;
196
198 int ns_;
199
201 bool isAllocated_;
202
204 cudaReal* d_temp_;
205 cudaReal* temp_;
206
207 };
208
209 // Inline member functions
210
211 /*
212 * Return q-field at beginning of block.
213 */
214 template <int D>
215 inline
216 cudaReal* Propagator<D>::head() const
217 { return qFields_d; }
218
219 /*
220 * Return q-field at end of block, after solution.
221 */
222 template <int D>
223 inline
224 const cudaReal* Propagator<D>::tail() const
225 { return qFields_d + ((ns_-1) * meshPtr_->size()); }
226
227 /*
228 * Return q-field at specified step.
229 */
230 template <int D>
231 inline
232 const cudaReal* Propagator<D>::q(int i) const
233 { return qFields_d + (i * meshPtr_->size()); }
234
235 /*
236 * Get the associated Block object (non-const reference)
237 */
238 template <int D>
239 inline
241 {
242 assert(blockPtr_);
243 return *blockPtr_;
244 }
245
246 /*
247 * Get the associated Block object (non-const reference)
248 */
249 template <int D>
250 inline
252 {
253 assert(blockPtr_);
254 return *blockPtr_;
255 }
256
257 /*
258 * Get the number ns of contour grid points.
259 */
260 template <int D>
261 inline
263 { return ns_; }
264
265 template <int D>
266 inline
268 { return isAllocated_; }
269
270 /*
271 * Associate this propagator with a block and direction
272 */
273 template <int D>
274 inline
276 { blockPtr_ = &block; }
277
278
279 #ifndef PSPG_PROPAGATOR_TPP
280 // Suppress implicit instantiation
281 extern template class Propagator<1>;
282 extern template class Propagator<2>;
283 extern template class Propagator<3>;
284 #endif
285
286}
287}
288
289//#include "Propagator.tpp"
290#endif
Description of a regular grid of points in a periodic domain.
Definition: Mesh.h:61
Template for propagator classes.
void setIsSolved(bool isSolved)
Set the isSolved flag to true or false.
const Propagator< D > & partner() const
Get partner propagator.
const Propagator< D > & source(int id) const
Get a source propagator.
bool isSolved() const
Has the modified diffusion equation been solved?
bool hasPartner() const
Does this have a partner propagator?
int nSource() const
Number of source / prerequisite propagators.
Block within a branched polymer.
MDE solver for one-direction of one block.
double computeQ()
Compute and return partition function for the molecule.
void solve()
Solve the modified diffusion equation (MDE) for this block.
int ns() const
Get the number of contour grid points.
cudaReal * head() const
Return q-field at beginning of block (initial condition).
RDField< D > WField
Chemical potential field type.
void computeHead()
Compute initial QField at head from tail QFields of sources.
RDField< D > QField
Propagator q-field type.
const cudaReal * tail() const
Return q-field at end of block.
void setBlock(Block< D > &block)
Associate this propagator with a block.
bool isAllocated() const
Has memory been allocated for this propagator?
Block< D > & block()
Get the associated Block object by reference.
void allocate(int ns, const Mesh< D > &mesh)
Associate this propagator with a block.
const cudaReal * q(int i) const
Return q-field at specified step.
RDField< D > CField
Monomer concentration field type.
RDField< D > Field
Generic field (function of position).
Field of real single precision values on an FFT mesh on a device.
Definition: RDField.h:34
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
Definition: accumulators.mod:1