ODT
Loading...
Searching...
No Matches
dv_enth.cc
Go to the documentation of this file.
1
7#include "dv_enth.h"
8#include "domain.h"
9#include "radiation/rad_opthin.h"
10#include "radiation/rad_twoflux.h"
11#include "radiation/rad_fvdom.h"
12#include <cstdlib>
13#include <cmath>
14
16
23 const string s,
24 const bool Lt,
25 const bool Lo) {
26
27
28 domn = line;
29 var_name = s;
30 L_transported = Lt;
31 L_output = Lo;
32 d = vector<double>(domn->ngrd, 0.0);
33 nspc = domn->gas->nSpecies();
34
35 LdoSpeciesFlux = domn->io->dvParams["LdoSpeciesFlux"] ? domn->io->dvParams["LdoSpeciesFlux"].as<bool>() : true;
36
37 rad = 0;
38
39 if(domn->pram->Lrad) {
40 if (domn->pram->radSolveType == "OPTHIN")
41 rad = new rad_opthin(domn);
42 else if (domn->pram->radSolveType == "TWOFLUX")
43 rad = new rad_twoflux(domn);
44 else if (domn->pram->radSolveType == "FVDOM")
45 rad = new rad_fvdom(domn);
46 else {
47 *domn->io->ostrm << endl << "ERROR: radSolveType not recognized or not consitent with cCoord" << endl;
48 exit(0);
49 }
50 }
51
52}
53
55
60void dv_enth::getRhsSrc(const int ipt){
61
62 if(!L_transported)
63 return;
64
65 if(LagSrc)
66 return;
67
68 rhsSrc.resize(domn->ngrd, 0.0);
69
70 int iS, iE;
71 if(ipt==-1) {
72 iS = 0;
73 iE = domn->ngrd-1;
74 }
75 else {
76 iS = ipt;
77 iE = ipt;
78 }
79
80 //----------- Compute the radiative source
81
82 if(domn->pram->Lrad) {
83
84 vector<vector<double> > xMoleSp(domn->ngrd, vector<double>(nspc));
85
86 for(int i=0; i<domn->ngrd; i++){
88 domn->gas->getMoleFractions(&xMoleSp.at(i).at(0));
89 }
90
91 rad->getRadHeatSource(xMoleSp, domn->temp->d, domn->pram->pres, rhsSrc);
92 }
93
94 if(domn->pram->Lspatial)
95 for(int i=iS; i<=iE; i++)
96 rhsSrc.at(i) /= domn->uvel->d.at(i);
97
98 LagSrc = true; // this is reset to false in setCaseSpecificVars
99
100
101}
102
104
111void dv_enth::getRhsMix(const vector<double> &gf,
112 const vector<double> &dxc){
113
114 if(!L_transported) return;
115
116 rhsMix.resize(domn->ngrd, 0.0);
117
118 setFlux(gf, dxc);
119
120 //------------------ Compute the mixing term
121
122 for(int i=0,ip=1; i<domn->ngrd; i++, ip++)
123 rhsMix.at(i) = -domn->pram->cCoord / (domn->rho->d.at(i) * dxc.at(i)) *
124 (flux.at(ip) * pow(abs(domn->posf->d.at(ip)), domn->pram->cCoord-1) -
125 flux.at(i) * pow(abs(domn->posf->d.at(i) ), domn->pram->cCoord-1));
126
127 if(domn->pram->Lspatial)
128 for(int i=0; i<domn->ngrd; i++)
129 rhsMix.at(i) /= domn->uvel->d.at(i);
130
131}
132
134
139void dv_enth::setFlux(const vector<double> &gf,
140 const vector<double> &dxc){
141
142
143 flux.resize(domn->ngrdf, 0.0);
144
145 vector<double> tcond(domn->ngrd, 0.0);
146 vector<double> tcond_f(domn->ngrdf, 0.0);
147 vector<vector<double> > hsp(nspc, vector<double>(domn->ngrd));
148 vector<double> hh(nspc);
149
150 for(int i=0; i<domn->ngrd; i++) {
152 tcond.at(i) = domn->tran->thermalConductivity(); // W/m*K
153 if(LdoSpeciesFlux) {
154 domn->gas->getEnthalpy_RT(&hh.at(0)); // non-dimensional enthalpy
155 for (int k=0; k<nspc; k++)
156 hsp.at(k).at(i) = hh.at(k) * domn->temp->d.at(i) * GasConstant / domn->gas->molecularWeight(k); // J/kg
157 }
158 }
159
160 interpVarToFacesHarmonic(tcond, tcond_f);
161
162 //========== Do the thermal conduction portion of the flux
163
164 //---------- Interior faces
165
166 for (int i=1, im=0; i < domn->ngrd; i++, im++)
167 flux.at(i) = -gf.at(i) * tcond_f.at(i)*(domn->temp->d.at(i) - domn->temp->d.at(im));
168
169 //---------- Boundary faces
170
171 if(domn->pram->bcType=="OUTFLOW") {
172 flux.at(0) = 0.0;
173 flux.at(domn->ngrd) = 0.0;
174 }
175 else if(domn->pram->bcType=="WALL") {
176 if(domn->pram->hWallBCtype=="ADIABATIC") {
177 flux.at(0) = 0.0;
178 flux.at(domn->ngrd) = 0.0;
179 }
180 else if(domn->pram->hWallBCtype=="ISOTHERMAL") {
181 flux.at(0) = -gf.at(0) * tcond_f.at(0) * (domn->temp->d.at(0) - domn->pram->TBClo);
182 flux.at(domn->ngrd) = -gf.at(domn->ngrd) * tcond_f.at(domn->ngrd) * (domn->pram->TBChi - domn->temp->d.at(domn->ngrd-1));
183 }
184 else {
185 cout << endl << "ERROR: hWallBCtype unknown" << endl;
186 exit(0);
187 }
188 }
189 else if(domn->pram->bcType=="WALL_OUT") {
190 if(domn->pram->hWallBCtype=="ADIABATIC") {
191 flux.at(0) = 0.0;
192 flux.at(domn->ngrd) = 0.0;
193 }
194 else if(domn->pram->hWallBCtype=="ISOTHERMAL") {
195 flux.at(0) = -gf.at(0) * tcond_f.at(0) * (domn->temp->d.at(0) - domn->pram->TBClo);
196 flux.at(domn->ngrd) = 0.0;
197 }
198 else {
199 cout << endl << "ERROR: hWallBCtype unknown" << endl;
200 exit(0);
201 }
202 }
203 else if(domn->pram->bcType=="PERIODIC") {
204 int im = domn->ngrd - 1;
205 flux.at(0) = -gf.at(0) * tcond_f.at(0) * (domn->temp->d.at(0) - domn->temp->d.at(im));
206 flux.at(domn->ngrd) = flux.at(0);
207 }
208 else {
209 *domn->io->ostrm << endl << "ERROR: bcType not recognized in dv_enth::setFlux" << endl;
210 exit(0);
211 }
212
213 //========== Add in the species flux portion.
214
215 if(LdoSpeciesFlux) {
216
217 double h_f;
218 double hjsum;
219 for(int i=0; i<domn->ngrdf; i++){
220 hjsum = 0.0;
221 for(int k=0; k<nspc; k++) {
222 h_f = linearInterpToFace(i, hsp.at(k));
223 hjsum += h_f * domn->ysp[k]->flux.at(i);
224 }
225 flux.at(i) += hjsum;
226 }
227 }
228
229}
230
int ngrd
number of grid cells
Definition domain.h:42
domaincase * domc
domaincase class: set specific vars...
Definition domain.h:84
IdealGasPhase * gas
pointer to cantera thermochemistry object (reaction rates, Cp, etc.)
Definition domain.h:69
dv * uvel
Definition domain.h:51
Transport * tran
pointer to cantera transport object (viscosity, diffusivity, etc.)
Definition domain.h:70
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
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
dv * temp
Definition domain.h:58
virtual void setGasStateAtPt(const int &ipt)
Definition domaincase.h:34
radiation * rad
Definition dv_enth.h:32
int nspc
Definition dv_enth.h:30
void setFlux(const vector< double > &gf, const vector< double > &dxc)
Definition dv_enth.cc:139
bool LdoSpeciesFlux
Definition dv_enth.h:33
dv_enth()
Definition dv_enth.h:52
virtual void getRhsMix(const vector< double > &gf, const vector< double > &dxc)
Definition dv_enth.cc:111
virtual void getRhsSrc(const int ipt=-1)
Definition dv_enth.cc:60
vector< double > d
the data
Definition dv.h:30
virtual void interpVarToFacesHarmonic(const vector< double > &cvar, vector< double > &fvar)
Definition dv.cc:75
bool L_transported
flag true if var is transported
Definition dv.h:31
bool LagSrc
flag to lag source term in implicit solve (initially put in for enthalpy radiation)
Definition dv.h:33
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 dvParams
yaml sub node
Definition inputoutput.h:44
ostream * ostrm
Runtime: points to cout or to a file.
Definition inputoutput.h:33
int cCoord
1 = planar, 2 = cylindrical, 3 = spherical
Definition param.h:68
double TBChi
Required if hWallBCtype = ISOTHERMAL.
Definition param.h:104
bool Lspatial
spatial formulation if true
Definition param.h:62
double TBClo
Required if hWallBCtype = ISOTHERMAL.
Definition param.h:103
string hWallBCtype
ADIABATIC or ISOTHERMAL.
Definition param.h:102
string radSolveType
OPTHIN, TWOFLUX, FVDOM.
Definition param.h:114
double pres
initial pressure (Pa)
Definition param.h:40
string bcType
OUTFLOW, PERIODIC, WALL, WALL_OUT.
Definition param.h:67
bool Lrad
radiation flag
Definition param.h:55
Header file for class domain.
Header file for class dv_enth.