15 TPZBlackOil2P3D::EState TPZBlackOil2P3D::gState = ELastState;
18 void TPZBlackOil2P3D::Interpolate(std::map<REAL,REAL> &dados,
double x,
double &y,
double &dy){
19 double x0, xL, y0, yL;
20 std::map< REAL, REAL >::iterator w;
21 w = dados.lower_bound(x);
24 std::cout <<
"Error at " << __PRETTY_FUNCTION__ <<
"\n";
42 if (w == dados.begin()){
62 y = (yL-y0)*(x-x0)/(xL-x0)+y0;
67 void TPZBlackOil2P3D::Interpolate(std::map<REAL,REAL> &dados, BFadREAL x, BFadREAL &y){
69 std::map< REAL, REAL >::iterator w;
70 w = dados.lower_bound(x.val());
73 std::cout <<
"Error at " << __PRETTY_FUNCTION__ <<
"\n";
83 if (w == dados.begin()){
95 y = (yL-y0)*(x-x0)/(xL-x0)+y0;
99 void TPZBlackOil2P3D::Kro(
double So,
double &Kro,
double &dKroSo) {
101 double tabela[n][2] = {{0.12,1.},{0.2,0.8},{0.3,0.6},{0.4,0.45},{0.5,0.3},{0.6,0.2},{0.7,0.1},{0.82,0.}};
102 std::map<REAL,REAL> dados;
103 for(
int i = 0; i < n; i++){
104 dados[ 1.-tabela[i][0] ] = tabela[i][1];
106 this->Interpolate(dados,So,Kro,dKroSo);
109 void TPZBlackOil2P3D::Kro(BFadREAL So, BFadREAL &Kro) {
111 double tabela[n][2] = {{0.12,1.},{0.2,0.8},{0.3,0.6},{0.4,0.45},{0.5,0.3},{0.6,0.2},{0.7,0.1},{0.82,0.}};
112 std::map<REAL,REAL> dados;
113 for(
int i = 0; i < n; i++){
114 dados[ 1.-tabela[i][0] ] = tabela[i][1];
116 this->Interpolate(dados,So,Kro);
120 void TPZBlackOil2P3D::Krw(
double So,
double &Krw,
double &dKrwSo) {
122 double tabela[n][2] = {{0.12,0.},{0.2,0.1},{0.3,0.2},{0.4,0.3},{0.5,0.4},{0.6,0.55},{0.7,0.7},{0.82,1.}};
123 std::map<REAL,REAL> dados;
124 for(
int i = 0; i < n; i++){
125 dados[ 1.-tabela[i][0] ] = tabela[i][1];
127 this->Interpolate(dados,So,Krw,dKrwSo);
130 void TPZBlackOil2P3D::testeKrw() {
131 ofstream KrFDP(
"Krw.txt");
134 for(
int i = 0; i < 1000; i++){
136 BFadREAL So(0. + doubleI * 1./100., 0);
138 KrFDP << So.val() <<
"\t" << Krw.val() <<
"\t" << Krw.dx(0) <<
" \n";
142 void TPZBlackOil2P3D::Krw(BFadREAL So, BFadREAL &Krw){
143 static bool testeAG =
true;
149 double tabela[n][2] = {{0.12,0.},{0.2,0.1},{0.3,0.2},{0.4,0.3},{0.5,0.4},{0.6,0.55},{0.7,0.7},{0.82,1.}};
150 std::map<REAL,REAL> dados;
151 for(
int i = 0; i < n; i++){
152 dados[ 1.-tabela[i][0] ] = tabela[i][1];
154 this->Interpolate(dados,So,Krw);
159 void TPZBlackOil2P3D::Bo(
double po,
double &Bo,
double &dBoDpo) {
161 double tabela[n][2] = {{14.7, 1.062}, {264.7, 1.15}, {514.7, 1.207}, {1014.7, 1.295}, {2014.7, 1.435}, {2514., 1.5},
162 {3014.7, 1.565}, {4014.7, 1.695}, {9014.7, 1.695}};
163 const double conv = 6894.757;
164 std::map<REAL,REAL> dados;
165 for(
int i = 0; i < n; i++){
166 dados[ tabela[i][0]*conv ] = tabela[i][1];
168 this->Interpolate(dados,po,Bo,dBoDpo);
172 void TPZBlackOil2P3D::testedoBo() {
173 ofstream BOFDP(
"bo.txt");
176 for(
int i = 0; i < 1000; i++){
178 BFadREAL p(10135.93 + doubleI * (621562370.- 101352.93)/100., 0);
180 BOFDP << p.val() <<
"\t" << Bo.val() <<
"\t" << Bo.dx(0) <<
" \n";
184 void TPZBlackOil2P3D::Bo(BFadREAL po, BFadREAL &Bo) {
186 double tabela[n][2] = {{14.7, 1.062}, {264.7, 1.15}, {514.7, 1.207}, {1014.7, 1.295}, {2014.7, 1.435}, {2514., 1.5},
187 {3014.7, 1.565}, {4014.7, 1.695}, {9014.7, 1.695}};
188 const double conv = 6894.757;
189 std::map<REAL,REAL> dados;
190 for(
int i = 0; i < n; i++){
191 dados[ tabela[i][0]*conv ] = tabela[i][1];
193 this->Interpolate(dados,po,Bo);
197 void TPZBlackOil2P3D::ViscOleo(
double po,
double &ViscOleo,
double &dViscOleoDpo){
199 double tabela[n][2] = {{14.7, 1.062}, {264.7, 1.15}, {514.7, 1.207}, {1014.7, 1.295}, {2014.7, 1.435}, {2514., 1.5},
200 {3014.7, 1.565}, {4014.7, 1.695}, {9014.7, 1.6}};
201 const double conv = 6894.757;
202 const double convVisc = 1e-3;
203 std::map<REAL,REAL> dados;
204 for(
int i = 0; i < n; i++){
205 dados[ tabela[i][0]*conv ] = tabela[i][1]*convVisc;
207 this->Interpolate(dados,po,ViscOleo,dViscOleoDpo);
210 void TPZBlackOil2P3D::ViscOleo(BFadREAL po, BFadREAL &ViscOleo){
213 double tabela[n][2] = {{14.7,1.04},{264.7,0.975},{514.7,0.91},{1014.7,0.83},{2014.7,0.695},
214 {2514.,0.641},{3014.7,0.594},{4014.7,0.51},{5014.7,0.449},{9014.7,0.203}};
215 const double conv = 6894.757;
216 const double convVisc = 1e-3;
217 std::map<REAL,REAL> dados;
218 for(
int i = 0; i < n; i++){
219 dados[ tabela[i][0]*conv ] = tabela[i][1]*convVisc;
221 this->Interpolate(dados,po,ViscOleo);
225 void TPZBlackOil2P3D::PressaoCapilar(
double So,
double &pc,
double &DpcDSo){
230 void TPZBlackOil2P3D::PressaoCapilar(BFadREAL So, BFadREAL &pc){
235 void TPZBlackOil2P3D::Porosidade(
double po,
double &poros,
double &dPorosDpo){
236 const double comp = 3.625943e-10;
237 const double pref = 101352.93;
238 const double porosRef = 0.22;
239 poros = porosRef*
exp(comp*(po-pref));
240 dPorosDpo = comp*porosRef*
exp(comp*(po-pref));
243 void TPZBlackOil2P3D::Porosidade(BFadREAL po, BFadREAL &poros){
244 const double comp = 3.625943e-10;
245 const double pref = 101352.93;
246 const double porosRef = 0.22;
247 poros = porosRef*
exp(comp*((po.val())-pref));
253 double TPZBlackOil2P3D::RhoOleoSC(){
258 double TPZBlackOil2P3D::RhoAguaSC(){
263 double TPZBlackOil2P3D::g(){
268 double TPZBlackOil2P3D::Bw(){
273 double TPZBlackOil2P3D::ViscAgua(){
281 K(0,0) = 2.96077e-13;
282 K(1,1) = 2.96077e-13;
283 K(2,2) = 4.93462e-14;
290 this->fDeltaT = deltaT;
293 TPZBlackOil2P3D::~TPZBlackOil2P3D(){
302 return new TPZBlackOil2P3D(*
this);
308 double stateVal = 0.;
309 if(gState == ELastState) stateVal = -1.;
310 if(gState == ECurrentState) stateVal = +1.;
313 const BFadREAL po(data.
sol[0][0],0);
314 const BFadREAL So(data.
sol[0][1],1);
316 this->PressaoCapilar(So,pc);
317 const BFadREAL pw = po - pc;
318 const BFadREAL Sw = ((BFadREAL)1.)-So;
322 this->Porosidade(po,porosidade);
327 const double Bw = this->Bw();
330 BFadREAL VolOp1 = (porosidade*So/Bo)/this->fDeltaT;
333 BFadREAL VolOp2 = (porosidade*Sw/Bw)/this->fDeltaT;
335 ef(0,0) += -1.*weight*stateVal*VolOp1.val();
336 ef(1,0) += -1.*weight*stateVal*VolOp2.val();
338 if(gState == ECurrentState){
339 ek(0,0) += +1.*weight*stateVal*VolOp1.dx(0);
340 ek(0,1) += +1.*weight*stateVal*VolOp1.dx(1);
342 ek(1,0) += +1.*weight*stateVal*VolOp2.dx(0);
343 ek(1,1) += +1.*weight*stateVal*VolOp2.dx(1);
349 cout <<
"Error: This method shoud not be called. " << __PRETTY_FUNCTION__ <<
"\n";
354 if(gState == ELastState)
return;
358 for(
int i = 0; i < 3; i++){
365 const BFadREAL poL(dataleft.
sol[0][0],0);
366 const BFadREAL SoL(dataleft.
sol[0][1],1);
367 const BFadREAL poR(dataright.
sol[0][0],2);
368 const BFadREAL SoR(dataright.
sol[0][1],3);
371 this->PressaoCapilar(SoL,pcL);
372 this->PressaoCapilar(SoR,pcR);
373 const BFadREAL pwL = poL - pcL;
374 const BFadREAL pwR = poR - pcR;
375 const BFadREAL SwL = ((BFadREAL)1.)-SoL;
376 const BFadREAL SwR = ((BFadREAL)1.)-SoR;
386 const REAL kgradZn = -K(0,2)*data.
normal[0] - K(1,2)*data.
normal[1] - K(2,2)*data.
normal[2];
394 const BFadREAL GammaOleoLeft = this->g() * this->RhoOleoSC()/BoL.val();
395 const BFadREAL GammaOleoRight = this->g() * this->RhoOleoSC()/BoR.val();
398 BFadREAL velocOleo = -1.*((knormal*poR-knormal*poL)/dist - (GammaOleoRight*kgradZn+GammaOleoLeft*kgradZn)/2.);
404 BFadREAL ViscOleoLeft, ViscOleoRight;
405 this->ViscOleo(poL, ViscOleoLeft);
406 this->ViscOleo(poR, ViscOleoRight);
407 BFadREAL LambdaOleoLeft = KroL/(ViscOleoLeft*BoL);
408 BFadREAL LambdaOleoRight = KroR/(ViscOleoRight*BoR);
412 if(velocOleo.val() > 0.){
413 Fn1 = -LambdaOleoLeft*velocOleo;
416 Fn1 = -LambdaOleoRight*velocOleo;
419 ef(0,0) += -1.*weight*( -Fn1.val() );
420 ef(2,0) += -1.*weight*( +Fn1.val() );
424 ek(0,0) += -1.*weight*( +Fn1.dx(0) );
425 ek(0,1) += -1.*weight*( +Fn1.dx(1) );
426 ek(0,2) += -1.*weight*( +Fn1.dx(2) );
427 ek(0,3) += -1.*weight*( +Fn1.dx(3) );
429 ek(2,0) += -1.*weight*( -Fn1.dx(0) );
430 ek(2,1) += -1.*weight*( -Fn1.dx(1) );
431 ek(2,2) += -1.*weight*( -Fn1.dx(2) );
432 ek(2,3) += -1.*weight*( -Fn1.dx(3) );
438 const REAL Bw = this->Bw();
439 const REAL GammaAgua = this->g() * this->RhoAguaSC() / Bw;
442 BFadREAL velocAgua = -1.*( (knormal*pwR-knormal*pwL)/dist - (GammaAgua*kgradZn+GammaAgua*kgradZn)/2. );
448 REAL ViscAgua = this->ViscAgua();
449 BFadREAL LambdaAguaLeft = KrwL.val()/(ViscAgua*Bw);
450 BFadREAL LambdaAguaRight = KrwR.val()/(ViscAgua*Bw);
454 if(velocAgua.val() > 0.){
455 Fn2 = -LambdaAguaLeft*velocAgua;
458 Fn2 = -LambdaAguaRight*velocAgua;
461 ef(1,0) += -1.*weight*( -Fn2.val() );
462 ef(3,0) += -1.*weight*( +Fn2.val() );
466 ek(1,0) += -1.*weight*( +Fn2.dx(0) );
467 ek(1,1) += -1.*weight*( +Fn2.dx(1) );
468 ek(1,2) += -1.*weight*( +Fn2.dx(2) );
469 ek(1,3) += -1.*weight*( +Fn2.dx(3) );
471 ek(3,0) += -1.*weight*( -Fn2.dx(0) );
472 ek(3,1) += -1.*weight*( -Fn2.dx(1) );
473 ek(3,2) += -1.*weight*( -Fn2.dx(2) );
474 ek(3,3) += -1.*weight*( -Fn2.dx(3) );
481 if(gState == ELastState)
return;
484 double vazao = -1. * (-
fabs(bc.
Val2()(0,0)) );
485 ef(1,0) += weight * vazao;
488 if(bc.
Type() == 2)
return;
491 if((bc.
Type() == 0) || (bc.
Type() == 1)){
494 dataright.
sol[0][0] = bc.
Val2()(0,0);
495 dataright.
sol[0][1] = bc.
Val2()(1,0);
500 for(
int i = 0; i < 2; i++){
501 ef(i,0) += auxef(i,0);
502 for(
int j = 0; j < 2; j++){
503 ek(i,j) += auxek(i,j);
512 enum ESolutionVars { ENone = 0, EWaterPressure = 1, EOilPressure, EWaterSaturation, EOilSaturation, EDarcyVelocity };
514 int TPZBlackOil2P3D::VariableIndex(
const std::string &name){
515 if(!strcmp(
"WaterPressure",name.c_str()))
return EWaterPressure;
516 if(!strcmp(
"OilPressure",name.c_str()))
return EOilPressure;
517 if(!strcmp(
"WaterSaturation",name.c_str()))
return EWaterSaturation;
518 if(!strcmp(
"OilSaturation",name.c_str()))
return EOilSaturation;
519 if(!strcmp(
"DarcyVelocity",name.c_str()))
return EDarcyVelocity;
523 int TPZBlackOil2P3D::NSolutionVariables(
int var){
524 if(var == EWaterPressure)
return 1;
525 if(var == EOilPressure)
return 1;
526 if(var == EWaterSaturation)
return 1;
527 if(var == EOilSaturation)
return 1;
528 if(var == EDarcyVelocity)
return 3;
534 const double po = Sol[0];
535 const double So = Sol[1];
537 if(var == EWaterPressure){
539 this->PressaoCapilar(So, pc);
540 Solout[0] = (po-pc.val());
544 if(var == EOilPressure){
549 if(var == EWaterSaturation){
554 if(var == EOilSaturation){
559 if(var == EDarcyVelocity){
560 cout <<
"\nERROR AT " << __PRETTY_FUNCTION__ <<
" \n";
Defines the interface which material objects need to implement for discontinuous Galerkin formulation...
virtual void Solution(TPZMaterialData &data, int var, TPZVec< STATE > &Solout)
Returns the solution associated with the var index based on the finite element approximation.
virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
It computes a contribution to stiffness matrix and load vector at one integration point...
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
TPZManVector< REAL, 3 > normal
normal to the element at the integration point
clarg::argBool bc("-bc", "binary checkpoints", false)
virtual int VariableIndex(const std::string &name)
Returns the variable index associated with the name.
REAL val(STATE &number)
Returns value of the variable.
TPZFMatrix< STATE > & Val2(int loadcase=0)
This abstract class defines the behaviour which each derived class needs to implement.
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
int Zero() override
Makes Zero all the elements.
TPZManVector< REAL, 3 > XCenter
value of the coordinate at the center of the element
This class defines the boundary condition for TPZMaterial objects.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
REAL dist(TPZVec< T1 > &vec1, TPZVec< T1 > &vec2)
virtual int NSolutionVariables(int var)
Returns the number of variables associated with the variable indexed by var.
void Fill(const T ©, const int64_t from=0, const int64_t numelem=-1)
Will fill the elements of the vector with a copy object.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ exp
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
Contains the TPZBlackOil2P3D class which implements a 3D two-phase (oil-water) black-oil flow...
TPZSolVec sol
vector of the solutions at the integration point