PSCF v1.4.0
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, typename WT = double>
26 class MixtureTmpl : public MixtureBase<WT>, public ParamComposite
27 {
28 public:
29
30 // Public type aliases
31
35 using SolventT = ST;
36
40 using PolymerT = PT;
41
42 // Public member functions
43
44 /*
45 * Public member functions inherited from MixtureBase:
46 *
47 * int nMonomer() const;
48 * int nPolymer() const;
49 * int nSolvent() const;
50 * int nBlock() const;
51 * double vMonomer() const;
52 * Monomer const & monomer(int id) const;
53 *
54 * void setVmonomer(double);
55 */
56
62 void readParameters(std::istream& in) override;
63
66
72 PolymerT& polymer(int id);
73
79 PolymerT const & polymer(int id) const;
80
88 PolymerSpecies<WT> const & polymerSpecies(int id) const final;
89
95 SolventT& solvent(int id);
96
102 SolventT const & solvent(int id) const;
103
111 SolventSpecies<WT> const & solventSpecies(int id) const final;
112
114
115 protected:
116
121
125 ~MixtureTmpl() override = default;
126
131
132 private:
133
139 DArray<PolymerT> polymers_;
140
146 DArray<SolventT> solvents_;
147
148 // Restrict access to inherited protected data
149 using MixtureBase<WT>::monomers_;
150 using MixtureBase<WT>::nMonomer_;
151 using MixtureBase<WT>::nPolymer_;
152 using MixtureBase<WT>::nSolvent_;
153 using MixtureBase<WT>::nBlock_;
154 using MixtureBase<WT>::vMonomer_;
155
156 };
157
158 // Inline member functions
159
160 template <class PT, class ST, typename WT>
162 {
163 UTIL_CHECK(id < nPolymer_);
164 return polymers_[id];
165 }
166
167 template <class PT, class ST, typename WT>
168 inline PT const & MixtureTmpl<PT,ST,WT>::polymer(int id) const
169 {
170 UTIL_CHECK(id < nPolymer_);
171 return polymers_[id];
172 }
173
174 template <class PT, class ST, typename WT>
176 {
177 UTIL_CHECK(id < nSolvent_);
178 return solvents_[id];
179 }
180
181 template <class PT, class ST, typename WT>
182 inline ST const & MixtureTmpl<PT,ST,WT>::solvent(int id) const
183 {
184 UTIL_CHECK(id < nSolvent_);
185 return solvents_[id];
186 }
187
188}
189#endif
DArray< Monomer > monomers_
SolventSpecies< WT > const & solventSpecies(int id) const final
Set a SolventSpecies descriptor object by const reference.
SolventT const & solvent(int id) const
Get a solvent solver object by constant reference.
MixtureTmpl()
Constructor.
void readParameters(std::istream &in) override
Read parameters from file and initialize.
ST SolventT
Solvent species solver type.
Definition MixtureTmpl.h:35
PT PolymerT
Polymer species solver type.
Definition MixtureTmpl.h:40
PolymerT const & polymer(int id) const
Get a polymer solver by const reference.
PolymerT & polymer(int id)
Get a polymer solver object by non-const reference.
PolymerSpecies< WT > const & polymerSpecies(int id) const final
Get a PolymerSpecies descriptor by const reference.
SolventT & solvent(int id)
Get a solvent solver object.
MixtureBase< WT > MixtureBaseT
Alias for base class.
~MixtureTmpl() override=default
Destructor.
Descriptor for a linear or acyclic branched block polymer.
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.