PSCF v1.4.0
r1d/solvers/Propagator.h
1#ifndef R1D_PROPAGATOR_H
2#define R1D_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#include <util/containers/DArray.h> // member template
13
14namespace Pscf {
15namespace R1d {
16
17 class Block;
18 using namespace Util;
19
25 class Propagator : public PropagatorTmpl<Propagator>
26 {
27
28 public:
29
30 // Public typedefs
31
36
37 // Member functions
38
42 Propagator();
43
48
54 void setBlock(Block& block);
55
62 void allocate(int ns, int nx);
63
77 void reallocate(int ns);
78
88 void solve();
89
100 void solve(const FieldT& head);
101
112 void computeQ(double & Q);
113
119 FieldT const & q(int i) const;
120
124 FieldT const & head() const;
125
129 FieldT const & tail() const;
130
139 int ns() const;
140
144 bool isAllocated() const;
145
146 private:
147
149 DArray<FieldT> qFields_;
150
152 FieldT work_;
153
155 Block* blockPtr_;
156
158 int ns_;
159
161 int nx_;
162
164 bool isAllocated_;
165
169 Block & block();
170
174 void computeHead();
175
176 };
177
178 // Inline member functions
179
180 /*
181 * Return q-field at beginning of block.
182 */
184 { return qFields_[0]; }
185
186 /*
187 * Return q-field at end of block, after solution.
188 */
190 { return qFields_[ns_-1]; }
191
192 /*
193 * Return q-field at specified step.
194 */
195 inline Propagator::FieldT const& Propagator::q(int i) const
196 { return qFields_[i]; }
197
198 /*
199 * Get the associated Block object.
200 */
201 inline Block& Propagator::block()
202 {
203 assert(blockPtr_);
204 return *blockPtr_;
205 }
206
207 /*
208 * Get the number of counter grid points.
209 */
210 inline int Propagator::ns() const
211 { return ns_; }
212
213 /*
214 * Associate this propagator with a block and direction
215 */
216 inline void Propagator::setBlock(Block& block)
217 { blockPtr_ = &block; }
218
219}
220}
221#endif
Block within a block polymer.
FieldT const & head() const
Return q-field at beginning of block (initial condition).
bool isAllocated() const
Has memory been allocated for this propagator?
FieldT const & tail() const
Return q-field at end of block.
FieldT const & q(int i) const
Return q-field at specified step.
int ns() const
Number of values of s (or slices), including head and tail.
void setBlock(Block &block)
Associate this propagator with a block.
void solve()
Solve the modified diffusion equation (MDE) for this block.
void computeQ(double &Q)
Compute and return partition function for the molecule.
void reallocate(int ns)
Reallocate memory used by this propagator.
void allocate(int ns, int nx)
Set discretization and allocate memory.
DArray< double > FieldT
Generic field (function of position).
Dynamically allocatable contiguous array template.
Definition DArray.h:32
SCFT with real 1D fields.
PSCF package top-level namespace.