PSCF v1.3.3
MixtureTmpl.h
1#ifndef PSCF_MIXTURE_TMPL_H
2#define PSCF_MIXTURE_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/MixtureBase.h> // base class
12#include <util/param/ParamComposite.h> // base class
13#include <util/containers/DArray.h> // member template
14
15namespace Pscf
16{
17
18 using namespace Util;
19
25 template <class PT, class ST>
26 class MixtureTmpl : public MixtureBase, public ParamComposite
27 {
28 public:
29
30 // Public typedefs
31
35 using SolventT = ST;
36
40 using PolymerT = PT;
41
42 // Public member functions
43
48
53
59 virtual void readParameters(std::istream& in);
60
63
64 /*
65 * Public member functions inherited from MixtureBase:
66 *
67 * int nMonomer() const;
68 * int nPolymer() const;
69 * int nSolvent() const;
70 * int nBlock() const;
71 * double vMonomer() const;
72 * Monomer const & monomer(int id) const;
73 *
74 * void setVmonomer(double);
75 */
76
82 PolymerT& polymer(int id);
83
89 PolymerT const & polymer(int id) const;
90
98 PolymerSpecies const & polymerSpecies(int id) const final;
99
106
112 SolventT const & solvent(int id) const;
113
121 SolventSpecies const & solventSpecies(int id) const final;
122
124
125 private:
126
132 DArray<PolymerT> polymers_;
133
139 DArray<SolventT> solvents_;
140
141 // Restrict access to inherited protected data
148
149 };
150
151 // Inline member functions
152
153 template <class PT, class ST>
155 {
156 UTIL_CHECK(id < nPolymer_);
157 return polymers_[id];
158 }
159
160 template <class PT, class ST>
161 inline PT const & MixtureTmpl<PT,ST>::polymer(int id) const
162 {
163 UTIL_CHECK(id < nPolymer_);
164 return polymers_[id];
165 }
166
167 template <class PT, class ST>
169 {
170 UTIL_CHECK(id < nSolvent_);
171 return solvents_[id];
172 }
173
174 template <class PT, class ST>
175 inline ST const & MixtureTmpl<PT,ST>::solvent(int id) const
176 {
177 UTIL_CHECK(id < nSolvent_);
178 return solvents_[id];
179 }
180
181}
182#endif
int nMonomer_
Number of monomer types.
int nPolymer_
Number of polymer species.
int nBlock_
Number of blocks total, across all polymers.
int nSolvent_
Number of solvent species.
double vMonomer_
Monomer reference volume (set to 1.0 by default).
MixtureBase()
Constructor.
DArray< Monomer > monomers_
Array of monomer type descriptors.
SolventT & solvent(int id)
Get a solvent solver object.
PolymerSpecies const & polymerSpecies(int id) const final
Get a PolymerSpecies descriptor by const reference.
virtual void readParameters(std::istream &in)
Read parameters from file and initialize.
PT PolymerT
Polymer species solver type.
Definition MixtureTmpl.h:40
~MixtureTmpl()
Destructor.
PolymerT & polymer(int id)
Get a polymer solver object by non-const reference.
MixtureTmpl()
Constructor.
SolventSpecies const & solventSpecies(int id) const final
Set a SolventSpecies descriptor object by const reference.
ST SolventT
Solvent species solver type.
Definition MixtureTmpl.h:35
Descriptor for a linear or acyclic branched block polymer.
PT PolymerT
Polymer species solver type.
Definition MixtureTmpl.h:40
ST SolventT
Solvent species solver type.
Definition MixtureTmpl.h:35
Descriptor for a solvent species.
Dynamically allocatable contiguous array template.
Definition DArray.h:32
ParamComposite()
Constructor.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
PSCF package top-level namespace.