PSCF v1.3.1
PolymerTmpl.h
1#ifndef PSCF_POLYMER_TMPL_H
2#define PSCF_POLYMER_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/PolymerSpecies.h> // base class
12#include <util/param/ParamComposite.h> // base class
13
14#include <util/containers/Pair.h> // member template
15#include <util/containers/DArray.h> // member template
16
17#include <pscf/chem/Vertex.h>
18#include <pscf/chem/PolymerType.h>
19#include <pscf/chem/PolymerModel.h>
20
21namespace Pscf
22{
23
24 class Edge;
25 using namespace Util;
26
48 template <class BT>
50 {
51
52 public:
53
54 // Public typename aliases
55
59 using BlockT = BT;
60
64 using PropagatorT = typename BT::PropagatorT;
65
66 // Public member functions
67
72
77
83 virtual void readParameters(std::istream& in);
84
115 virtual void solve(double phiTot = 1.0);
116
119
129 Edge& edge(int id) final;
130
136 Edge const& edge(int id) const final;
137
143 BT& block(int id);
144
150 BT const& block(int id) const ;
151
164 PropagatorT& propagator(int blockId, int directionId);
165
172 PropagatorT const & propagator(int blockId, int directionId) const;
173
182
184
185 // Inherited public members
186
196
197 using Species::phi;
198 using Species::mu;
199 using Species::q;
200 using Species::ensemble;
201
202 protected:
203
207 void allocateBlocks() final;
208
214 void readBlocks(std::istream& in) final;
215
216 private:
217
219 DArray<BlockT> blocks_;
220
226 void isValid();
227
228 };
229
230 // Inline functions
231
232 /*
233 * Get a specified Edge (block descriptor) by non-const reference.
234 */
235 template <class BT>
236 inline
237 Edge& PolymerTmpl<BT>::edge(int id)
238 { return blocks_[id]; }
239
240 /*
241 * Get a specified Edge (block descriptor) by const reference.
242 */
243 template <class BT>
244 inline
245 Edge const & PolymerTmpl<BT>::edge(int id) const
246 { return blocks_[id]; }
247
248 /*
249 * Get a specified Block solver by non-const reference.
250 */
251 template <class BT>
252 inline
254 { return blocks_[id]; }
255
256 /*
257 * Get a specified Block solver by const reference.
258 */
259 template <class BT>
260 inline
261 BT const & PolymerTmpl<BT>::block(int id) const
262 { return blocks_[id]; }
263
264 /*
265 * Get a propagator, indexed by block and direction ids (non-const).
266 */
267 template <class BT>
268 inline
269 typename BT::PropagatorT&
270 PolymerTmpl<BT>::propagator(int blockId, int directionId)
271 { return block(blockId).propagator(directionId); }
272
273 /*
274 * Get a propagator, indexed by block and direction ids (const).
275 */
276 template <class BT>
277 inline
278 typename BT::PropagatorT const &
279 PolymerTmpl<BT>::propagator(int blockId, int directionId) const
280 { return block(blockId).propagator(directionId); }
281
282 /*
283 * Get a propagator, indexed in order of computation.
284 */
285 template <class BT>
286 inline
287 typename BT::PropagatorT& PolymerTmpl<BT>::propagator(int id)
288 {
289 Pair<int> propId = propagatorId(id);
290 return propagator(propId[0], propId[1]);
291 }
292
293}
294#include "PolymerTmpl.tpp"
295#endif
Descriptor for a block within a block polymer.
Definition Edge.h:59
const Vertex & vertex(int id) const
Get a specified Vertex by const reference.
PolymerSpecies()
Constructor.
Pair< int > const & path(int is, int it) const
Get an id for a propagator from one vertex towards a target.
int nVertex() const
Number of vertices (junctions and chain ends).
int nPropagator() const
Number of propagators (2*nBlock).
int nBead() const
Total number of beads in the polymer (bead model).
int nBlock() const
Number of blocks.
double length() const
Sum of the lengths of all blocks in the polymer (thread model).
Pair< int > const & propagatorId(int id) const
Get a propagator identifier, indexed by order of computation.
PolymerType::Enum type() const
Get Polymer type (Branched or Linear)
typename BT::PropagatorT PropagatorT
Modified diffusion equation solver for one block, in one direction.
Definition PolymerTmpl.h:64
void allocateBlocks() final
Allocate array of Block objects.
BT const & block(int id) const
Get a specified Block (solver and descriptor) by const reference.
void readBlocks(std::istream &in) final
~PolymerTmpl()
Destructor.
PropagatorT const & propagator(int blockId, int directionId) const
Get the propagator for a specific block and direction (const).
PropagatorT & propagator(int id)
Get a propagator indexed in order of computation (non-const).
virtual void readParameters(std::istream &in)
Read and initialize.
PropagatorT & propagator(int blockId, int directionId)
Get the propagator for a specific block and direction (non-const).
Edge const & edge(int id) const final
Get a specified Edge (block descriptor) by const reference.
BT BlockT
Block of a block polymer.
Definition PolymerTmpl.h:59
virtual void solve(double phiTot=1.0)
Solve modified diffusion equation for all propagators.
PolymerTmpl()
Constructor.
Pair< int > const & propagatorId(int id) const
Get a propagator identifier, indexed by order of computation.
Edge & edge(int id) final
Get a specified Edge (block descriptor) by non-const reference.
BT & block(int id)
Get a specified Block (solver and descriptor).
double phi() const
Get the overall volume fraction for this species.
Definition Species.h:149
double mu() const
Get the chemical potential for this species (units kT=1).
Definition Species.h:155
Ensemble ensemble() const
Get the statistical ensemble for this species (open or closed).
Definition Species.h:167
double q() const
Get the molecular partition function for this species.
Definition Species.h:161
Dynamically allocatable contiguous array template.
Definition DArray.h:32
An array of exactly 2 objects.
Definition Pair.h:24
PSCF package top-level namespace.
Definition param_pc.dox:1