| 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 ASLFDADVECTIONDIFFUSION_H |
| 25 |
#define ASLFDADVECTIONDIFFUSION_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= D_i \Delta c_i - \nabla (\vec v c_i) |
| 50 |
-\nabla\left(\frac{c_i q}{k} \nabla(\phi+f_2) \right)\f] |
| 51 |
where |
| 52 |
\param cData corresponds to \f$c_i\f$ |
| 53 |
\param diffusionCoefficient corresponds to \f$D_i\f$ |
| 54 |
\param efFactor1 corresponds to \f$k\f$ |
| 55 |
\param efFactor2 corresponds to \f$f_2\f$ |
| 56 |
\param efPhi corresponds to \f$\phi\f$ |
| 57 |
\param efChargeAnd corresponds to \f$q\f$ |
| 58 |
\param velocity corresponds to \f$\vec v\f$ |
| 59 |
*/ |
| 60 |
class FDAdvectionDiffusion: public SingleKernelNM |
| 61 |
{ |
| 62 |
public: |
| 63 |
typedef SPDataWithGhostNodesACLData Data; |
| 64 |
typedef SPAbstractDataWithGhostNodes Field; |
| 65 |
|
| 66 |
private: |
| 67 |
std::vector<Data> cData; |
| 68 |
std::vector<Data> cInternalData; |
| 69 |
|
| 70 |
bool electricField; |
| 71 |
Field efPhi; |
| 72 |
Field efFactor1; |
| 73 |
Field efFactor2; |
| 74 |
std::vector<Field> efChargeAnd; |
| 75 |
|
| 76 |
Field velocity; |
| 77 |
/// advection process described by distribution function instead of velocity field |
| 78 |
Field distributionFunction; |
| 79 |
bool compressibilityCorrectionFlag; |
| 80 |
|
| 81 |
const VectorTemplate* vectorTemplate; |
| 82 |
|
| 83 |
int t; |
| 84 |
std::vector<acl::VectorOfElements> diffusionCoefficient; |
| 85 |
|
| 86 |
virtual void init0(); |
| 87 |
virtual void postProcessing(); |
| 88 |
public: |
| 89 |
FDAdvectionDiffusion(); |
| 90 |
FDAdvectionDiffusion(Data c, |
| 91 |
const acl::VectorOfElements & dC, |
| 92 |
const VectorTemplate* vT); |
| 93 |
void setDiffusionCoefficient(acl::VectorOfElements d, |
| 94 |
unsigned int i = 0); |
| 95 |
inline const acl::VectorOfElements & getDiffusionCoefficient(unsigned int i=0) const; |
| 96 |
void setVectorTemplate(VectorTemplate* vT); |
| 97 |
inline const VectorTemplate* getVectorTemplate() const; |
| 98 |
void setElectricFieldParameters(Field phi, |
| 99 |
Field f1, |
| 100 |
Field f2, |
| 101 |
Field qAnd); |
| 102 |
void setVelocity(Field v, bool compressibilityCorrection=false); |
| 103 |
void setDistributionFunction(Field f); |
| 104 |
|
| 105 |
inline Field getVelocity(); |
| 106 |
inline Field getDistributionFunction(); |
| 107 |
inline std::vector<Data> & getData(); |
| 108 |
void addComponent(Data c, acl::VectorOfElements & dC); |
| 109 |
void addComponent(Data c, acl::VectorOfElements & dC, Field qAnd); |
| 110 |
|
| 111 |
}; |
| 112 |
|
| 113 |
typedef std::shared_ptr<FDAdvectionDiffusion> SPFDAdvectionDiffusion; |
| 114 |
|
| 115 |
/** |
| 116 |
\ingroup TransportProcesses |
| 117 |
\ingroup NumMethods |
| 118 |
|
| 119 |
\f[ \partial_t c_i= D_i \Delta c_i - \nabla (\vec v c_i)\f] |
| 120 |
where |
| 121 |
\param cData corresponds to \f$c_i\f$ |
| 122 |
\param diffusionCoefficient corresponds to \f$D_i\f$ |
| 123 |
\param velocity corresponds to \f$\vec v\f$ |
| 124 |
*/ |
| 125 |
SPFDAdvectionDiffusion generateFDAdvectionDiffusion(SPDataWithGhostNodesACLData c, |
| 126 |
double diffustionCoeff, |
| 127 |
SPAbstractDataWithGhostNodes v, |
| 128 |
const VectorTemplate* vt, |
| 129 |
bool compressibilityCorrection = false); |
| 130 |
|
| 131 |
/** |
| 132 |
\ingroup TransportProcesses |
| 133 |
\ingroup NumMethods |
| 134 |
|
| 135 |
\f[ \partial_t c_i= D_i \Delta c_i \f] |
| 136 |
where |
| 137 |
\param cData corresponds to \f$ c_i \f$ |
| 138 |
\param diffusionCoefficient corresponds to \f$ D_i \f$ |
| 139 |
*/ |
| 140 |
SPFDAdvectionDiffusion generateFDAdvectionDiffusion(SPDataWithGhostNodesACLData c, |
| 141 |
double diffustionCoeff, |
| 142 |
const VectorTemplate* vt); |
| 143 |
|
| 144 |
// ------------------------- Implementation ------------------------ |
| 145 |
|
| 146 |
inline FDAdvectionDiffusion::Field FDAdvectionDiffusion::getVelocity() |
| 147 |
{ |
| 148 |
return velocity; |
| 149 |
} |
| 150 |
|
| 151 |
inline FDAdvectionDiffusion::Field FDAdvectionDiffusion::getDistributionFunction() |
| 152 |
{ |
| 153 |
return distributionFunction; |
| 154 |
} |
| 155 |
|
| 156 |
inline std::vector<FDAdvectionDiffusion::Data> & FDAdvectionDiffusion::getData() |
| 157 |
{ |
| 158 |
return cData; |
| 159 |
} |
| 160 |
|
| 161 |
inline const VectorTemplate* FDAdvectionDiffusion::getVectorTemplate() const |
| 162 |
{ |
| 163 |
return vectorTemplate; |
| 164 |
} |
| 165 |
|
| 166 |
inline const acl::VectorOfElements & |
| 167 |
FDAdvectionDiffusion::getDiffusionCoefficient(unsigned int i) const |
| 168 |
{ |
| 169 |
return diffusionCoefficient[i]; |
| 170 |
} |
| 171 |
|
| 172 |
} // asl |
| 173 |
#endif // ASLFDADVECTIONDIFFUSION_H |