ODT
Loading...
Searching...
No Matches
dv_posf.cc
Go to the documentation of this file.
1
6#include "dv_posf.h"
7#include "domain.h"
8#include <iostream>
9#include <cstdlib>
10#include <numeric> //accumulate
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->ngrdf, 0.0);
29
30 double dx = domn->pram->domainLength / domn->ngrd;
31 d.at(0) = domn->pram->xDomainCenter - 0.5*domn->pram->domainLength;
32 for(int i=1; i<domn->ngrdf; i++)
33 d.at(i) = d.at(i-1) + dx;
34
35}
36
38
47void dv_posf::splitCell(const int isplt,
48 const int nsplt,
49 const vector<double> &cellFaces) {
50
51 d.insert( d.begin() + isplt+1, nsplt, 0.0 );
52 for(int i=isplt+1, j=1; i<=isplt+nsplt; i++, j++)
53 d.at(i) = cellFaces.at(j);
54
55}
57
72void dv_posf::merge2cells(const int imrg,
73 const double m1,
74 const double m2,
75 const bool LconstVolume) {
76
77 d.erase(d.begin() + imrg+1);
78
79 if(LconstVolume || domn->pram->bcType=="WALL") { //todo: generalize this (works for constant density flows only, and not spatial (due to velocity)).
80 domn->pos->merge2cells(imrg, m1, m2, LconstVolume);
81 return;
82 }
83
84 double invC = 1.0/domn->pram->cCoord;
85 double C = domn->pram->cCoord;
86
87 vector<double> dxc;
89 dxc.at(imrg) = (m1+m2)/domn->rho->d.at(imrg);
90 if(domn->pram->Lspatial)
91 dxc.at(imrg) /= domn->uvel->d.at(imrg);
92
93
94 domn->mesher->setGridFromDxc(dxc); // does pos also --> pos is done for each merge and also at the end in meshManager::merge2cells
95
97
98 //if(domn->pram->bcType=="OUTFLOW") {
99 //
100 // double V2tot = accumulate(dxc.begin(), dxc.end(), 0.0);
101 // double dmb;
102 // d[0] = -pow(0.5*V2tot, invC);
103 // for(int ie=1, iw=0, i=0; ie<d.size(); ie++, iw++, i++) {
104 // if(d[iw] <= 0.0) {
105 // dmb = pow(abs(d[iw]),C) - dxc[i];
106 // if(dmb >=0) d[ie] = -pow( dmb, invC);
107 // else d[ie] = pow(-dmb, invC);
108 // }
109 // else {
110 // d[ie] = pow(pow(d[iw],C) + dxc[i], invC);
111 // }
112 // }
113 //}
114
116
117 //else if(domn->pram->bcType == "Wall_OUT") {
118 // d[0] = 0.0;
119 // for(int ie=1, iw=0, i=0; ie<domn->ngrdf; ie++, iw++, i++)
120 // d[ie] = pow(pow(d[iw],C) + dxc[i], invC);
121 //}
122
124
125 //else {
126 // cout << endl << "ERROR: dv_posf::merge2cells: not setup for given bcType" << endl;
127 // exit(0);
128 //}
129
130}
131
133
253
259void dv_posf::setDvFromRegion(const int i1, const int i2){
260
261 // note, we are owned by the eddyline, so domn is eddl, so to get domn data, use domn->domn
262 const vector<double> &domn_data = domn->domn->varMap.find(var_name)->second->d;
263
264 if(i2 >= i1)
265 d.assign(domn_data.begin()+i1, domn_data.begin()+i2+2 );
266 else { // wrap around (periodic assignment)
267 d.assign(domn_data.begin()+i1, domn_data.end()-1);
268 double idmb = d.size();
269 d.insert(d.end(), domn_data.begin(), domn_data.begin()+i2+2 );
270 for(int i=idmb; i<d.size(); i++)
271 d.at(i)+=domn->domn->Ldomain();
272 }
273
274}
275
277
281 d.resize(domn->ngrdf);
282}
283
284
285
286
287
288
289
290
291
292
293
294
295
int ngrd
number of grid cells
Definition domain.h:42
dv * uvel
Definition domain.h:51
double Ldomain()
Definition domain.cc:156
map< string, dv * > varMap
Definition domain.h:67
dv * pos
pointers to gas properties
Definition domain.h:47
int ngrdf
number of grid cell faces = ngrd+1
Definition domain.h:43
meshManager * mesher
pointer to mesh manager object
Definition domain.h:78
domain * domn
(for one domain to point to another (eddl))
Definition domain.h:40
param * pram
pointer to the parameters object
Definition domain.h:73
dv * rho
Definition domain.h:49
dv_posf()
Definition dv_posf.h:51
virtual void setDvFromRegion(const int i1, const int i2)
Definition dv_posf.cc:259
virtual void resize()
Definition dv_posf.cc:280
virtual void merge2cells(const int imrg, const double m2, const double m1, const bool LconstVolume=false)
Definition dv_posf.cc:72
virtual void splitCell(const int isplt, const int nsplt, const vector< double > &cellFaces)
Definition dv_posf.cc:47
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
virtual void merge2cells(const int imrg, const double m2, const double m1, const bool LconstVolume=false)
Definition dv.cc:60
domain * domn
pointer to domain object (parent)
Definition dv.h:35
void setGridFromDxc(const vector< double > &dxc2)
void setGridDxc(const domain *line, vector< double > &dxc, double C)
int cCoord
1 = planar, 2 = cylindrical, 3 = spherical
Definition param.h:68
double domainLength
length of domain (m)
Definition param.h:34
bool Lspatial
spatial formulation if true
Definition param.h:62
double xDomainCenter
position of the center of the domain
Definition param.h:69
string bcType
OUTFLOW, PERIODIC, WALL, WALL_OUT.
Definition param.h:67
Header file for class domain.
Header file for class dv_posf.