PSCF v1.3.1
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>
12#include <util/param/ParamComposite.h>
13#include <util/containers/DArray.h>
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
45 using BlockT = typename PT::BlockT;
46
50 using PropagatorT = typename BlockT::PropagatorT;
51
52 // Public member functions
53
58
63
69 virtual void readParameters(std::istream& in);
70
73
74 /*
75 * Public member functions inherited from MixtureBase:
76 *
77 * int nMonomer() const;
78 * int nPolymer() const;
79 * int nSolvent() const;
80 * int nBlock() const;
81 * double vMonomer() const;
82 * Monomer const & monomer(int id) const;
83 *
84 * void setVmonomer(double);
85 */
86
92 PolymerT& polymer(int id);
93
99 PolymerT const & polymer(int id) const;
100
108 PolymerSpecies const & polymerSpecies(int id) const final;
109
116
122 SolventT const & solvent(int id) const;
123
131 SolventSpecies const & solventSpecies(int id) const final;
132
134
135 private:
136
142 DArray<PolymerT> polymers_;
143
149 DArray<SolventT> solvents_;
150
151 // Restrict access to inherited protected data
158
159 };
160
161 // Inline member functions
162
163 template <class PT, class ST>
165 {
166 UTIL_CHECK(id < nPolymer_);
167 return polymers_[id];
168 }
169
170 template <class PT, class ST>
171 inline PT const & MixtureTmpl<PT,ST>::polymer(int id) const
172 {
173 UTIL_CHECK(id < nPolymer_);
174 return polymers_[id];
175 }
176
177 template <class PT, class ST>
179 {
180 UTIL_CHECK(id < nSolvent_);
181 return solvents_[id];
182 }
183
184 template <class PT, class ST>
185 inline ST const & MixtureTmpl<PT,ST>::solvent(int id) const
186 {
187 UTIL_CHECK(id < nSolvent_);
188 return solvents_[id];
189 }
190
191}
192#include "MixtureTmpl.tpp"
193#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.
typename PT::BlockT BlockT
Block polymer block type.
Definition MixtureTmpl.h:45
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.
typename BlockT::PropagatorT PropagatorT
Polymer block propagator type.
Definition MixtureTmpl.h:50
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.
Definition param_pc.dox:1