ODT
Loading...
Searching...
No Matches
source
domainvariables
dv_sca.cc
Go to the documentation of this file.
1
7
#include "
dv_sca.h
"
8
#include "
domain.h
"
9
#include <cstdlib>
10
#include <cmath>
11
13
19
dv_sca::dv_sca
(
domain
*line,
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
constantSource
=
domn
->
io
->
dvParams
[
"scalarSource"
] ?
domn
->
io
->
dvParams
[
"scalarSource"
].as<
double
>() : 0.0;
31
32
}
33
35
44
//dv_sca::setVar(const int ipt) {}
45
47
51
void
dv_sca::getRhsSrc
(
const
int
ipt){
52
53
if
(!
L_transported
)
54
return
;
55
56
//-------------------------
57
58
// Volume forcing like in Kawamura's heated channel here:
59
60
rhsSrc
.resize(
domn
->
ngrd
,
constantSource
);
61
62
}
63
65
70
void
dv_sca::getRhsMix
(
const
vector<double> &gf,
71
const
vector<double> &dxc){
72
73
rhsMix
.resize(
domn
->
ngrd
, 0.0);
74
75
//------------------ Set fluxes
76
77
flux
.resize(
domn
->
ngrdf
);
78
vector<double> rho_f(
domn
->
ngrdf
);
79
80
interpVarToFacesHarmonic
(
domn
->
rho
->
d
, rho_f);
81
82
//---------- Interior faces
83
84
for
(
int
i=1, im=0; i<
domn
->
ngrd
; i++, im++)
85
flux
.at(i) = -gf.at(i) * rho_f.at(i)*
domn
->
pram
->
sdiff0
* (
d
.at(i) -
d
.at(im));
// rho*sdiff0 is the "dynamic" diffusion coefficient
86
87
//---------- Boundary faces
88
89
if
(
domn
->
pram
->
bcType
==
"OUTFLOW"
) {
90
flux
.at(0) = 0.0;
91
flux
.at(
domn
->
ngrd
) = 0.0;
92
}
93
else
if
(
domn
->
pram
->
bcType
==
"WALL"
) {
94
double
bclo =
domn
->
pram
->
sBClo
;
95
double
bchi =
domn
->
pram
->
sBChi
;
96
flux
.at(0) = -gf.at(0) * rho_f.at(0) *
domn
->
pram
->
sdiff0
* (
d
.at(0) - bclo);
97
flux
.at(
domn
->
ngrd
) = -gf.at(
domn
->
ngrd
) * rho_f.at(
domn
->
ngrd
) *
domn
->
pram
->
sdiff0
* (bchi -
d
.at(
domn
->
ngrd
-1));
98
}
99
else
if
(
domn
->
pram
->
bcType
==
"WALL_OUT"
) {
100
double
bclo =
domn
->
pram
->
sBClo
;
101
flux
.at(0) = -gf.at(0) * rho_f.at(0) *
domn
->
pram
->
sdiff0
* (
d
.at(0) - bclo);
102
flux
.at(
domn
->
ngrd
) = 0.0;
103
}
104
else
if
(
domn
->
pram
->
bcType
==
"PERIODIC"
) {
105
flux
.at(0) = -gf.at(0) * rho_f.at(0) *
domn
->
pram
->
sdiff0
* (
d
.at(0) -
d
.at(
domn
->
ngrd
-1));
106
flux
.at(
domn
->
ngrd
) =
flux
.at(0);
107
}
108
else
{
109
*
domn
->
io
->
ostrm
<< endl <<
"ERROR: bcType not recognized in dv_sca::getRhsMix"
<< endl;
110
exit(0);
111
}
112
113
//------------------ Compute the mixing term
114
115
for
(
int
i=0,ip=1; i<
domn
->
ngrd
; i++, ip++)
116
rhsMix
.at(i) = -
domn
->
pram
->
cCoord
/ (
domn
->
rho
->
d
.at(i) * dxc.at(i)) *
117
(
flux
.at(ip) * pow(abs(
domn
->
posf
->
d
.at(ip)),
domn
->
pram
->
cCoord
-1) -
118
flux
.at(i) * pow(abs(
domn
->
posf
->
d
.at(i) ),
domn
->
pram
->
cCoord
-1));
119
120
if
(
domn
->
pram
->
Lspatial
)
121
for
(
int
i=0; i<
domn
->
ngrd
; i++)
122
rhsMix
.at(i) /=
domn
->
uvel
->
d
.at(i);
123
124
}
125
domain
Definition
domain.h:34
domain::ngrd
int ngrd
number of grid cells
Definition
domain.h:42
domain::uvel
dv * uvel
Definition
domain.h:51
domain::posf
dv * posf
access as: posf->d[i], or posf->var_name, etc.
Definition
domain.h:48
domain::ngrdf
int ngrdf
number of grid cell faces = ngrd+1
Definition
domain.h:43
domain::io
inputoutput * io
pointer to input/output object
Definition
domain.h:72
domain::pram
param * pram
pointer to the parameters object
Definition
domain.h:73
domain::rho
dv * rho
Definition
domain.h:49
dv_sca::getRhsMix
virtual void getRhsMix(const vector< double > &gf, const vector< double > &dxc)
Definition
dv_sca.cc:70
dv_sca::constantSource
double constantSource
Definition
dv_sca.h:31
dv_sca::dv_sca
dv_sca()
Definition
dv_sca.h:48
dv_sca::getRhsSrc
virtual void getRhsSrc(const int ipt=-1)
Definition
dv_sca.cc:51
dv::d
vector< double > d
the data
Definition
dv.h:30
dv::interpVarToFacesHarmonic
virtual void interpVarToFacesHarmonic(const vector< double > &cvar, vector< double > &fvar)
Definition
dv.cc:75
dv::L_transported
bool L_transported
flag true if var is transported
Definition
dv.h:31
dv::var_name
string var_name
name of variable
Definition
dv.h:29
dv::L_output
bool L_output
flag true if included in output
Definition
dv.h:32
dv::rhsMix
vector< double > rhsMix
the data
Definition
dv.h:38
dv::flux
vector< double > flux
Definition
dv.h:40
dv::domn
domain * domn
pointer to domain object (parent)
Definition
dv.h:35
dv::rhsSrc
vector< double > rhsSrc
the data
Definition
dv.h:37
inputoutput::dvParams
YAML::Node dvParams
yaml sub node
Definition
inputoutput.h:44
inputoutput::ostrm
ostream * ostrm
Runtime: points to cout or to a file.
Definition
inputoutput.h:33
param::cCoord
int cCoord
1 = planar, 2 = cylindrical, 3 = spherical
Definition
param.h:68
param::sBChi
double sBChi
Dirichlet scalar boundary condition.
Definition
param.h:101
param::sdiff0
double sdiff0
initial uniform scalar diffusivity (m^2/s)
Definition
param.h:38
param::Lspatial
bool Lspatial
spatial formulation if true
Definition
param.h:62
param::sBClo
double sBClo
Dirichlet scalar boundary condition.
Definition
param.h:100
param::bcType
string bcType
OUTFLOW, PERIODIC, WALL, WALL_OUT.
Definition
param.h:67
domain.h
Header file for class domain.
dv_sca.h
Header file for class dv_sca.
Generated by
1.10.0