PSCF v1.4.0
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 template
12#include <util/containers/DArray.h> // member
13
14namespace Pscf {
15
16 // Forward declaration
17 class Edge;
18
19 using namespace Util;
20
61 template <class BT, class PT, typename WT = double>
62 class PolymerTmpl : public PolymerSpecies<WT>
63 {
64
65 public:
66
67 // Public member functions
68
74 void readParameters(std::istream& in) override;
75
111 virtual void solve(double phiTot = 1.0);
112
115
126 Edge& edge(int id) final;
127
133 Edge const& edge(int id) const final;
134
140 BT& block(int id);
141
147 BT const& block(int id) const ;
148
161 PT& propagator(int blockId, int directionId);
162
169 PT const & propagator(int blockId, int directionId) const;
170
178 PT& propagator(int id);
179
181
182 // Public typename aliases
183
187 using BlockT = BT;
188
192 using PropagatorT = PT;
193
194 protected:
195
200
204 ~PolymerTmpl() override = default;
205
209 void allocateBlocks() final;
210
216 void readBlocks(std::istream& in) final;
217
218 // Protected typename aliases (base classes)
219
223 using SpeciesT = Species<WT>;
224
229
230 private:
231
233 DArray<BT> blocks_;
234
240 void isValid();
241
242 };
243
244 // Inline functions
245
246 /*
247 * Get a specified Edge (block descriptor) by non-const reference.
248 */
249 template <class BT, class PT, typename WT> inline
250 Edge& PolymerTmpl<BT,PT,WT>::edge(int id)
251 { return blocks_[id]; }
252
253 /*
254 * Get a specified Edge (block descriptor) by const reference.
255 */
256 template <class BT, class PT, typename WT> inline
257 Edge const & PolymerTmpl<BT,PT,WT>::edge(int id) const
258 { return blocks_[id]; }
259
260 /*
261 * Get a specified Block solver by non-const reference.
262 */
263 template <class BT, class PT, typename WT> inline
265 { return blocks_[id]; }
266
267 /*
268 * Get a specified Block solver by const reference.
269 */
270 template <class BT, class PT, typename WT> inline
271 BT const & PolymerTmpl<BT,PT,WT>::block(int id) const
272 { return blocks_[id]; }
273
274}
275#endif
Descriptor for a block within a block polymer.
Definition Edge.h:59
Edge & edge(int id) final
Get a specified Edge (block descriptor) by non-const reference.
PolymerTmpl()
Constructor.
Species< WT > SpeciesT
Indirect (grandparent) base class.
PT & propagator(int blockId, int directionId)
Get the propagator for a specific block and direction (non-const).
PT & propagator(int id)
Get a propagator indexed in order of computation (non-const).
PT const & propagator(int blockId, int directionId) const
Get the propagator for a specific block and direction (const).
PolymerSpecies< WT > PolymerSpeciesT
Direct (parent) base class.
void readParameters(std::istream &in) override
Read and initialize.
BT & block(int id)
Get a specified Block (solver and descriptor).
PT PropagatorT
Modified diffusion equation solution (propagator).
virtual void solve(double phiTot=1.0)
Solve modified diffusion equation for all propagators.
BT BlockT
Block of a block polymer.
void allocateBlocks() final
Allocate array of Block objects.
BT const & block(int id) const
Get a specified Block (solver and descriptor) by const reference.
~PolymerTmpl() override=default
Destructor.
Edge const & edge(int id) const final
Get a specified Edge (block descriptor) by const reference.
Base class for a molecular species (polymer or solvent).
Definition Species.h:35
Dynamically allocatable contiguous array template.
Definition DArray.h:32
PSCF package top-level namespace.