ODT
Loading...
Searching...
No Matches
dv_mixf.cc
Go to the documentation of this file.
1
6#include "dv_mixf.h"
7#include "domain.h"
8#include <cstdlib>
9#include <cmath>
10
12
19 const string s,
20 const bool Lt,
21 const bool Lo) {
22
23 domn = line;
24 var_name = s;
25 L_transported = Lt;
26 L_output = Lo;
27 d = vector<double>(domn->ngrd, 0.0);
28
29 Dmf = domn->io->streamProps["Dmf"] ? domn->io->streamProps["Dmf"].as<double>() : 0.0;
30 if(L_transported && Dmf == 0.0) {
31 cout << endl << "ERROR: if you are transporting mixture fraction, you need to set Dmf";
32 exit(0);
33 }
34
35}
36
38
42void dv_mixf::setVar(const int ipt){
43
45 return; // don't set mixf from other quantities if its transported
46
47 if(ipt != -1) {
48 cout << endl << "ERROR in setVar: ipt must be -1" << endl;
49 exit(0);
50 }
51
52 d.resize(domn->ngrd);
53
54 int nsp = domn->gas->nSpecies();
55 vector<double> yi(nsp);
56 for(int i=0; i<domn->ngrd; i++) {
57 for(int k=0; k<nsp; k++)
58 yi.at(k) = domn->ysp[k]->d.at(i);
59 d.at(i) = domn->strm->getMixtureFraction(&yi.at(0));
60 }
61}
62
64
69void dv_mixf::getRhsSrc(const int ipt){
70
71 if(!L_transported)
72 return;
73
74 rhsSrc.resize(domn->ngrd, 0.0);
75}
76
78
85void dv_mixf::getRhsMix(const vector<double> &gf,
86 const vector<double> &dxc){
87
88 if(!L_transported) return;
89
90 rhsMix.resize(domn->ngrd, 0.0);
91
92 setFlux(gf, dxc);
93
94 //------------------ Compute the mixing term
95
96 for(int i=0,ip=1; i<domn->ngrd; i++, ip++)
97 rhsMix.at(i) = -domn->pram->cCoord / (domn->rho->d.at(i) * dxc.at(i)) *
98 (flux.at(ip) * pow(abs(domn->posf->d.at(ip)), domn->pram->cCoord-1) -
99 flux.at(i) * pow(abs(domn->posf->d.at(i) ), domn->pram->cCoord-1));
100
101 if(domn->pram->Lspatial)
102 for(int i=0; i<domn->ngrd; i++)
103 rhsMix.at(i) /= domn->uvel->d.at(i);
104
105}
106
108
113void dv_mixf::setFlux(const vector<double> &gf,
114 const vector<double> &dxc){
115
116 flux.resize(domn->ngrdf);
117 vector<double> rhoD(domn->ngrd, Dmf);
118 vector<double> rhoD_f(domn->ngrdf);
119
120 for(int i=0; i<domn->ngrd; i++)
121 rhoD.at(i) *= domn->rho->d.at(i);
122 for(int i=0; i<domn->ngrdf; i++)
123 rhoD_f.at(i) = linearInterpToFace(i, rhoD);
124
125 //==========================
126
127 //---------- Interior faces
128
129 for (int i=1, im=0, sum=0.0; i < domn->ngrd; i++, im++)
130 flux.at(i) = -rhoD_f.at(i)*gf.at(i)*(d.at(i) - d.at(im));
131
132 //---------- Boundary faces
133
134 flux.at(0) = 0.0;
135 flux.at(domn->ngrd) = 0.0;
136}
137
int ngrd
number of grid cells
Definition domain.h:42
IdealGasPhase * gas
pointer to cantera thermochemistry object (reaction rates, Cp, etc.)
Definition domain.h:69
dv * uvel
Definition domain.h:51
dv * posf
access as: posf->d[i], or posf->var_name, etc.
Definition domain.h:48
int ngrdf
number of grid cell faces = ngrd+1
Definition domain.h:43
inputoutput * io
pointer to input/output object
Definition domain.h:72
streams * strm
pointer to gas stream properties
Definition domain.h:71
vector< dv * >::iterator ysp
access as: ysp=v.begin(), (*ysp)->d[i] or (*(ysp+k))->d[i], or ysp[k]->d[i].
Definition domain.h:63
param * pram
pointer to the parameters object
Definition domain.h:73
dv * rho
Definition domain.h:49
virtual void getRhsSrc(const int ipt=-1)
Definition dv_mixf.cc:69
dv_mixf()
Definition dv_mixf.h:50
virtual void getRhsMix(const vector< double > &gf, const vector< double > &dxc)
Definition dv_mixf.cc:85
virtual void setVar(const int ipt=-1)
Definition dv_mixf.cc:42
void setFlux(const vector< double > &gf, const vector< double > &dxc)
Definition dv_mixf.cc:113
double Dmf
default mixture fraction diffusivity (read from input file)
Definition dv_mixf.h:30
vector< double > d
the data
Definition dv.h:30
bool L_transported
flag true if var is transported
Definition dv.h:31
string var_name
name of variable
Definition dv.h:29
bool L_output
flag true if included in output
Definition dv.h:32
vector< double > rhsMix
the data
Definition dv.h:38
virtual double linearInterpToFace(const int &iface, const vector< double > &vec)
Definition dv.cc:136
vector< double > flux
Definition dv.h:40
domain * domn
pointer to domain object (parent)
Definition dv.h:35
vector< double > rhsSrc
the data
Definition dv.h:37
YAML::Node streamProps
yaml sub node
Definition inputoutput.h:41
int cCoord
1 = planar, 2 = cylindrical, 3 = spherical
Definition param.h:68
bool Lspatial
spatial formulation if true
Definition param.h:62
double getMixtureFraction(const double *y, const bool doBeta01=false)
Definition streams.cc:363
Header file for class domain.
Header file for class dv_mixf.