Debian Codegraph @

src/num/aslFDStefanMaxwell.h

raw
1 /*
2 * Advanced Simulation Library <http://asl.org.il>
3 *
4 * Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5 *
6 *
7 * This file is part of Advanced Simulation Library (ASL).
8 *
9 * ASL is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, version 3 of the License.
12 *
13 * ASL is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with ASL. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23
24 #ifndef ASLFDSTEFANMAXWELL_H
25 #define ASLFDSTEFANMAXWELL_H
26
27 #include "aslSingleKernelNM.h"
28
29 namespace acl
30 {
31 class VectorOfElementsData;
32 class VectorOfElements;
33 }
34
35 namespace asl
36 {
37 class VectorTemplate;
38 template <typename V> class DataWithGhostNodes;
39 typedef DataWithGhostNodes<acl::VectorOfElementsData> DataWithGhostNodesACLData;
40 typedef std::shared_ptr<DataWithGhostNodesACLData> SPDataWithGhostNodesACLData;
41 class AbstractDataWithGhostNodes;
42 typedef std::shared_ptr<AbstractDataWithGhostNodes> SPAbstractDataWithGhostNodes;
43
44 /// Numerical method which computes multicomponent transport processes
45 /**
46 \ingroup TransportProcesses
47 \ingroup NumMethods
48
49 \f[ \partial_t c_i= - \vec \nabla \cdot \vec J - \vec \nabla \cdot (\vec v c_i) \f]
50 \f[ -\nabla c_i = \sum_{j, i\neq j} \frac{c_j\vec J_i-c_i\vec J_j}{c_tD_{ij}} + \frac{\vec J_i}{D_{i,D}}\f]
51 where \f$c_i\f$ is a molar concentration, \f$ v \f$ is the flow velocity,
52 \f$J_i\f$ is the molar flux, \f$D_{i,D}\f$ is the component-dust diffusion coefficient,
53 \f$D_{ij}\f$ is the pair diffusion coefficient.
54
55 The second equation can be rewritten in the matrix form:
56 \f[ -\vec \nabla c_i = \sum_k A_{ik} \vec J_k,\;\;\;
57 A_{ik} \equiv \delta_{ik} \left(\frac{1}{D_{i,D}} +
58 \Lambda_i +
59 \frac{c_i}{c_tD_{ik}} \right) -
60 \frac{c_i}{c_tD_{ik}},\;\;\;
61 \Lambda_i \equiv \sum_{j, j\neq i} \frac{c_j}{c_tD_{ij}}\f]
62
63 class parameters are related to the quation ones as follows
64 \param cData corresponds to \f$c_i\f$
65 \param diffusionCoefficients corresponds to \f$D_{ij}\f$
66 \param velocity corresponds to \f$\vec v\f$
67 */
68 class FDStefanMaxwell: public SingleKernelNM
69 {
70 public:
71 typedef SPDataWithGhostNodesACLData Data;
72 typedef SPAbstractDataWithGhostNodes Field;
73 typedef acl::VectorOfElements Param;
74
75 private:
76 std::vector<Data> cData;
77 std::vector<Data> cInternalData;
78
79 Field efPhi;
80 std::vector<Param> efCharge;
81
82 Field velocity;
83
84 const VectorTemplate* vectorTemplate;
85
86 std::vector<std::vector<Param>> diffusionCoefficients;
87 std::vector<Param> dustDiffusionCoefficients;
88
89 virtual void init0();
90 virtual void postProcessing();
91 public:
92 FDStefanMaxwell();
93 FDStefanMaxwell(Data c1,
94 Data c2,
95 const acl::VectorOfElements & dC,
96 const VectorTemplate* vT);
97 void setDiffusionCoefficient(acl::VectorOfElements d,
98 unsigned int i = 0,unsigned int j = 1);
99 inline const Param & getDiffusionCoefficient(unsigned int i=0, unsigned int j=1) const;
100 inline const Param & getDustDiffusionCoefficient(unsigned int i=0) const;
101 void setDustDiffusionCoefficient(unsigned int i, const Param & dd);
102 void setVectorTemplate(VectorTemplate* vT);
103 inline const VectorTemplate* getVectorTemplate() const;
104 void setElectricField(Field phi);
105 Field getElectricField() const;
106 inline const Param & getCharge(unsigned int i) const;
107 void setCharge(unsigned int i, const Param & q);
108 void setVelocity(Field v);
109 inline Field getVelocity();
110 inline std::vector<Data> & getData();
111 void addComponent(Data c, const Param & dC);
112 void addComponent(Data c, const Param & dC, const Param & q);
113 };
114
115 typedef std::shared_ptr<FDStefanMaxwell> SPFDStefanMaxwell;
116
117 /**
118 \ingroup TransportProcesses
119 \ingroup NumMethods
120 \f[ \partial_t c_i= - \vec \nabla \cdot \vec J - \vec \nabla \cdot (\vec v c_i) \f]
121 \f[ -\nabla c_i = \sum_{j, i\neq j} \frac{c_j\vec J_i-c_i\vec J_j}{c_tD_{ij}} + \frac{\vec J_i}{D_{i,D}}\f]
122 where \f$c_i\f$ is a molar concentration, \f$ v \f$ is the flow velocity,
123 \f$J_i\f$ is the molar flux, \f$D_{i,D}\f$ is the component-dust diffusion coefficient,
124 \f$D_{ij}\f$ is the pair diffusion coefficient.
125
126 parameters are related to the quation ones as follows
127 \param c1 \f$c_1\f$
128 \param c2 \f$c_2\f$
129 \param diffusionCoeff corresponds to \f$D_{12}\f$
130 \param v velocity field
131 \param vt used VectorTemplate
132
133 */
134 SPFDStefanMaxwell generateFDStefanMaxwell(SPDataWithGhostNodesACLData c1,
135 SPDataWithGhostNodesACLData c2,
136 double diffustionCoeff,
137 SPAbstractDataWithGhostNodes v,
138 const VectorTemplate* vt);
139
140 /**
141 \ingroup TransportProcesses
142 \ingroup NumMethods
143
144 \f[ \partial_t c_i= - \vec \nabla \cdot \vec J\f]
145 \f[ -\nabla c_i = \sum_{j, i\neq j} \frac{c_j\vec J_i-c_i\vec J_j}{c_tD_{ij}} + \frac{\vec J_i}{D_{i,D}}\f]
146 where \f$c_i\f$ is a molar concentration, \f$ v \f$ is the flow velocity,
147 \f$J_i\f$ is the molar flux, \f$D_{i,D}\f$ is the component-dust diffusion coefficient,
148 \f$D_{ij}\f$ is the pair diffusion coefficient.
149
150 \param c1 \f$c_1\f$
151 \param c2 \f$c_2\f$
152 \param diffusionCoeff corresponds to \f$D_{12}\f$
153 \param vt used VectorTemplate
154
155 */
156 SPFDStefanMaxwell generateFDStefanMaxwell(SPDataWithGhostNodesACLData c1,
157 SPDataWithGhostNodesACLData c2,
158 double diffustionCoeff,
159 const VectorTemplate* vt);
160
161 class FDStefanMaxwellElectricField: public SingleKernelNM
162 {
163 public:
164 typedef SPDataWithGhostNodesACLData Data;
165 typedef SPAbstractDataWithGhostNodes Field;
166
167 private:
168 SPFDStefanMaxwell smSolver;
169 Data phi;
170 Data phiInternalData;
171 Field phiS;
172 const double stepFactor=1e-3;
173
174 virtual void init0();
175 virtual void postProcessing();
176 public:
177 FDStefanMaxwellElectricField(SPFDStefanMaxwell sm, Data phi);
178 void setPhiS(Field pS);
179 };
180
181 typedef std::shared_ptr<FDStefanMaxwellElectricField> SPFDStefanMaxwellElectricField;
182
183 // ------------------------- Implementation ------------------------
184
185 inline FDStefanMaxwell::Field FDStefanMaxwell::getVelocity()
186 {
187 return velocity;
188 }
189
190 inline std::vector<FDStefanMaxwell::Data> & FDStefanMaxwell::getData()
191 {
192 return cData;
193 }
194
195 inline const VectorTemplate* FDStefanMaxwell::getVectorTemplate() const
196 {
197 return vectorTemplate;
198 }
199
200 inline const acl::VectorOfElements &
201 FDStefanMaxwell::getDiffusionCoefficient(unsigned int i, unsigned int j) const
202 {
203 return diffusionCoefficients[i][j];
204 }
205
206 inline const acl::VectorOfElements &
207 FDStefanMaxwell::getDustDiffusionCoefficient(unsigned int i) const
208 {
209 return dustDiffusionCoefficients[i];
210 }
211
212 inline const acl::VectorOfElements &
213 FDStefanMaxwell::getCharge(unsigned int i) const
214 {
215 return efCharge[i];
216 }
217
218
219 } // asl
220 #endif // ASLFDADVECTIONDIFFUSION_H