ODT
Loading...
Searching...
No Matches
dv_uvw.cc
Go to the documentation of this file.
1
7#include "dv_uvw.h"
8#include "domain.h"
9#include <cstdlib>
10#include <cmath>
11
13
20 const string s,
21 const bool Lt,
22 const bool Lo) {
23
24 domn = line;
25 var_name = s;
26 L_transported = Lt;
27 L_output = Lo;
28 d = vector<double>(domn->ngrd, 0.0);
29
30}
31
33
37void dv_uvw::getRhsSrc(const int ipt){
38
39 if(!L_transported)
40 return;
41
42 rhsSrc.resize(domn->ngrd, 0.0);
43
44 //-------------------------
45
46 if(ipt==-1) {
47 if(var_name == "uvel" && domn->pram->cCoord != 3.0) {
48 rhsSrc = vector<double>(domn->ngrd, -domn->pram->dPdx);
49 for(int i=0; i<domn->ngrd; i++) {
50 if(domn->pram->Lbuoyant)
51 rhsSrc.at(i) += (domn->rho->d.at(i) - domn->rho->d.at(domn->ngrd-1))*domn->pram->g;
52 rhsSrc.at(i) /= domn->rho->d.at(i);
53 }
54 }
55
56 if(domn->pram->Lspatial)
57 for(int i=0; i<domn->ngrd; i++)
58 rhsSrc.at(i) /= domn->uvel->d.at(i);
59 }
60 else {
61 if(var_name == "uvel" && domn->pram->cCoord != 3.0) {
62 rhsSrc.at(ipt) = -domn->pram->dPdx;
63 if(domn->pram->Lbuoyant)
64 rhsSrc.at(ipt) += (domn->rho->d.at(ipt) - domn->rho->d.at(domn->ngrd-1))*domn->pram->g;
65 rhsSrc.at(ipt) /= domn->rho->d.at(ipt);
66 }
67
68 if(domn->pram->Lspatial)
69 rhsSrc.at(ipt) /= domn->uvel->d.at(ipt);
70 }
71}
72
74
79void dv_uvw::getRhsMix(const vector<double> &gf,
80 const vector<double> &dxc){
81
82 rhsMix.resize(domn->ngrd, 0.0);
83
84 //------------------ Set fluxes
85
86 flux.resize(domn->ngrdf);
87 vector<double> dvisc_f(domn->ngrdf);
88
90
91 //---------- Interior faces
92
93 for (int i=1, im=0; i < domn->ngrd; i++, im++)
94 flux.at(i) = -gf.at(i) * dvisc_f.at(i)*(d.at(i) - d.at(im));
95
96 //---------- Boundary faces
97
98 if(domn->pram->bcType=="OUTFLOW") {
99 flux.at(0) = 0.0;
100 flux.at(domn->ngrd) = 0.0;
101 }
102 else if(domn->pram->bcType=="WALL") {
103 double bclo = var_name=="uvel" ? domn->pram->uBClo : var_name=="vvel" ? domn->pram->vBClo : domn->pram->wBClo;
104 double bchi = var_name=="uvel" ? domn->pram->uBChi : var_name=="vvel" ? domn->pram->vBChi : domn->pram->wBChi;
105 flux.at(0) = -gf.at(0) * dvisc_f.at(0) * (d.at(0) - bclo);
106 flux.at(domn->ngrd) = -gf.at(domn->ngrd) * dvisc_f.at(domn->ngrd) * (bchi - d.at(domn->ngrd-1));
107 }
108 else if(domn->pram->bcType=="WALL_OUT") {
109 double bclo = var_name=="uvel" ? domn->pram->uBClo : var_name=="vvel" ? domn->pram->vBClo : domn->pram->wBClo;
110 flux.at(0) = -gf.at(0) * dvisc_f.at(0) * (d.at(0) - bclo);
111 flux.at(domn->ngrd) = 0.0;
112 }
113 else if(domn->pram->bcType=="PERIODIC") {
114 int im = domn->ngrd - 1;
115 flux.at(0) = -gf.at(0) * dvisc_f.at(0) * (d.at(0) - d.at(im));
116 flux.at(domn->ngrd) = flux.at(0);
117 }
118 else {
119 *domn->io->ostrm << endl << "ERROR: bcType not recognized in dv_uvw::getRhsMix" << endl;
120 exit(0);
121 }
122
123 //------------------ Compute the mixing term
124
125 for(int i=0,ip=1; i<domn->ngrd; i++, ip++)
126 rhsMix.at(i) = -domn->pram->cCoord / (domn->rho->d.at(i) * dxc.at(i)) *
127 (flux.at(ip) * pow(abs(domn->posf->d.at(ip)), domn->pram->cCoord-1) -
128 flux.at(i) * pow(abs(domn->posf->d.at(i) ), domn->pram->cCoord-1));
129
130 if(domn->pram->Lspatial)
131 for(int i=0; i<domn->ngrd; i++)
132 rhsMix.at(i) /= domn->uvel->d.at(i);
133
134}
135
136
int ngrd
number of grid cells
Definition domain.h:42
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
dv * dvisc
Definition domain.h:50
param * pram
pointer to the parameters object
Definition domain.h:73
dv * rho
Definition domain.h:49
virtual void getRhsMix(const vector< double > &gf, const vector< double > &dxc)
Definition dv_uvw.cc:79
dv_uvw()
Definition dv_uvw.h:42
virtual void getRhsSrc(const int ipt=-1)
Definition dv_uvw.cc:37
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
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
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
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 vBChi
Dirichlet velocity boundary condition.
Definition param.h:97
double g
gravity (default -9.81)
Definition param.h:59
double uBChi
Dirichlet velocity boundary condition.
Definition param.h:95
bool Lspatial
spatial formulation if true
Definition param.h:62
double vBClo
Dirichlet velocity boundary condition.
Definition param.h:96
double dPdx
initial pressure gradient (Pa/m)
Definition param.h:39
double uBClo
Dirichlet velocity boundary condition.
Definition param.h:94
bool Lbuoyant
flag to turn on bouyancy (horizontal domain)
Definition param.h:56
string bcType
OUTFLOW, PERIODIC, WALL, WALL_OUT.
Definition param.h:67
double wBClo
Dirichlet velocity boundary condition.
Definition param.h:98
double wBChi
Dirichlet velocity boundary condition.
Definition param.h:99
Header file for class domain.
Header file for class dv_uvw.