PSCF v1.3
PropagatorTmpl.h
1#ifndef PSCF_PROPAGATOR_TMPL_H
2#define PSCF_PROPAGATOR_TMPL_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/chem/PolymerModel.h>
12#include <util/containers/GArray.h>
13
14namespace Pscf
15{
16
17 using namespace Util;
18
88 template <class QT>
90 {
91
92 public:
93
98
101
108
117 void setPartner(const QT& partner);
118
128 void addSource(const QT& source);
129
134
142
146
152 const QT& source(int id) const;
153
157 const QT& partner() const;
158
162 int directionId() const;
163
167 int nSource() const;
168
172 bool hasPartner() const;
173
179 bool isHeadEnd() const;
180
186 bool isTailEnd() const;
187
191 bool isSolved() const;
192
196 bool isReady() const;
197
199
200 private:
201
203 int directionId_;
204
206 QT const * partnerPtr_;
207
209 GArray<QT const *> sourcePtrs_;
210
212 bool isHeadEnd_;
213
215 bool isTailEnd_;
216
218 bool isSolved_;
219
220 };
221
222 // Inline member functions
223
224 /*
225 * Get the direction index.
226 */
227 template <class QT>
229 { return directionId_; }
230
231 /*
232 * Get the number of source propagators.
233 */
234 template <class QT>
236 { return sourcePtrs_.size(); }
237
238 /*
239 * Get a source propagator.
240 */
241 template <class QT>
242 inline const QT&
244 { return *(sourcePtrs_[id]); }
245
249 template <class QT>
251 { return partnerPtr_; }
252
253 /*
254 * Does this propagator own the head vertex bead?
255 */
256 template <class QT>
258 { return isHeadEnd_; }
259
260 /*
261 * Does this propagator own the tail vertex bead?
262 */
263 template <class QT>
265 { return isTailEnd_; }
266
267 /*
268 * Is the computation of this propagator completed?
269 */
270 template <class QT>
272 { return isSolved_; }
273
274 // Noninline member functions
275
276 /*
277 * Constructor.
278 */
279 template <class QT>
281 : directionId_(-1),
282 partnerPtr_(0),
283 sourcePtrs_(),
284 isSolved_(false)
285 {}
286
287 /*
288 * Set the directionId.
289 */
290 template <class QT>
293
294 /*
295 * Set the partner propagator.
296 */
297 template <class QT>
299 { partnerPtr_ = &partner; }
300
301 /*
302 * Add a source propagator to the list.
303 */
304 template <class QT>
306 { sourcePtrs_.append(&source); }
307
308 /*
309 * Set flags indicate whether vertices are are chain ends.
310 */
311 template <class QT>
313 {
314 isHeadEnd_ = isHeadEnd;
315 isTailEnd_ = isTailEnd;
316 }
317
318 /*
319 * Check if all source propagators are marked completed.
320 */
321 template <class QT>
323 {
324 for (int i=0; i < sourcePtrs_.size(); ++i) {
325 if (!sourcePtrs_[i]->isSolved()) {
326 return false;
327 }
328 }
329 return true;
330 }
331
332 /*
333 * Mark this propagator as solved (true) or not (false).
334 */
335 template <class QT>
337 { isSolved_ = isSolved; }
338
339 /*
340 * Get partner propagator.
341 */
342 template <class QT>
344 const
345 {
346 UTIL_CHECK(partnerPtr_);
347 return *partnerPtr_;
348 }
349
350}
351#endif
int nSource() const
Number of source / prerequisite propagators.
bool hasPartner() const
Does this have a partner propagator?
void setIsSolved(bool isSolved)
Set the isSolved flag to true or false.
void setDirectionId(int directionId)
Associate this propagator with a direction index.
void setEndFlags(bool isHeadEnd, bool isTailEnd)
Set flags indicating whether vertices are chain ends.
const Propagator< D > & partner() const
void setPartner(const QT &partner)
Set the partner of this propagator.
PropagatorTmpl()
Constructor.
const Propagator< D > & source(int id) const
bool isReady() const
Are all source propagators solved?
void addSource(const QT &source)
Add a propagator to the list of sources for this one.
An automatically growable array, analogous to a std::vector.
Definition GArray.h:34
int size() const
Return logical size of this array (i.e., current number of elements).
Definition GArray.h:455
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
PSCF package top-level namespace.
Definition param_pc.dox:1