PSCF v1.3.3
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
17namespace Pscf {
18
19 class Edge;
20 using namespace Util;
21
43 template <class BT, class PT>
45 {
46
47 public:
48
49 // Public typename aliases
50
54 using BlockT = BT;
55
59 using PropagatorT = PT;
60
61 // Public member functions
62
67
72
78 virtual void readParameters(std::istream& in);
79
110 virtual void solve(double phiTot = 1.0);
111
114
124 Edge& edge(int id) final;
125
131 Edge const& edge(int id) const final;
132
138 BT& block(int id);
139
145 BT const& block(int id) const ;
146
159 PT& propagator(int blockId, int directionId);
160
167 PT const & propagator(int blockId, int directionId) const;
168
176 PT& propagator(int id);
177
179
180 // Inherited public members
181
191
192 using Species::phi;
193 using Species::mu;
194 using Species::q;
195 using Species::ensemble;
196
197 protected:
198
202 void allocateBlocks() final;
203
209 void readBlocks(std::istream& in) final;
210
211 private:
212
214 DArray<BT> blocks_;
215
221 void isValid();
222
223 };
224
225 // Inline functions
226
227 /*
228 * Get a specified Edge (block descriptor) by non-const reference.
229 */
230 template <class BT, class PT>
231 inline
232 Edge& PolymerTmpl<BT,PT>::edge(int id)
233 { return blocks_[id]; }
234
235 /*
236 * Get a specified Edge (block descriptor) by const reference.
237 */
238 template <class BT, class PT>
239 inline
240 Edge const & PolymerTmpl<BT,PT>::edge(int id) const
241 { return blocks_[id]; }
242
243 /*
244 * Get a specified Block solver by non-const reference.
245 */
246 template <class BT, class PT>
247 inline
249 { return blocks_[id]; }
250
251 /*
252 * Get a specified Block solver by const reference.
253 */
254 template <class BT, class PT>
255 inline
256 BT const & PolymerTmpl<BT,PT>::block(int id) const
257 { return blocks_[id]; }
258
259}
260#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)
BT & block(int id)
Get a specified Block (solver and descriptor).
virtual void solve(double phiTot=1.0)
Solve modified diffusion equation for all propagators.
BT BlockT
Block of a block polymer.
Definition PolymerTmpl.h:54
PT & propagator(int id)
Get a propagator indexed in order of computation (non-const).
~PolymerTmpl()
Destructor.
Edge const & edge(int id) const final
Get a specified Edge (block descriptor) by const reference.
PT & propagator(int blockId, int directionId)
Get the propagator for a specific block and direction (non-const).
virtual void readParameters(std::istream &in)
Read and initialize.
BT const & block(int id) const
Get a specified Block (solver and descriptor) by const reference.
PolymerTmpl()
Constructor.
void allocateBlocks() final
Allocate array of Block objects.
PT PropagatorT
Modified diffusion equation solver for one block, in one direction.
Definition PolymerTmpl.h:59
PT const & propagator(int blockId, int directionId) const
Get the propagator for a specific block and direction (const).
Edge & edge(int id) final
Get a specified Edge (block descriptor) by non-const reference.
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
PSCF package top-level namespace.