-
Notifications
You must be signed in to change notification settings - Fork 0
/
TPZPoroPermCoupling.cpp
1296 lines (1006 loc) · 38.3 KB
/
TPZPoroPermCoupling.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// TPZPoroPermCoupling.cpp
// PZ
//
// Created by Omar on 8/28/16.
//
//
#include "TPZPoroPermCoupling.h"
#include <iostream>
#include <string>
#include "pzbndcond.h"
#include "pzaxestools.h"
#include <algorithm>
TPZPoroPermCoupling::TPZPoroPermCoupling():TPZMatWithMem<TPZPoroPermMemory,TPZDiscontinuousGalerkin>(), fnu(0.), falpha(0.), fk(0.), feta(0.), fPlaneStress(0) {
fDim = 2;
fb.resize(2);
fb[0]=0.;
fb[1]=0.;
fPlaneStress = 1.;
frho_s = 2700.0; // @omar:: put a method for the right set up of these values
frho_f = 1000.0;
feta_dp = 0.0;
fxi_dp = 0.0;
}
TPZPoroPermCoupling::TPZPoroPermCoupling(int matid, int dim):TPZMatWithMem<TPZPoroPermMemory,TPZDiscontinuousGalerkin>(matid), fnu(0.), falpha(0.), fk(0.), feta(0.),fPlaneStress(0) {
fDim = dim;
fb.resize(2);
fb[0]=0.;
fb[1]=0.;
fPlaneStress = 1;
frho_s = 2700.0; // @omar:: put a method for the right set up of these values
frho_f = 1000.0;
fk_model = 0;
feta_dp = 0.0;
fxi_dp = 0.0;
}
TPZPoroPermCoupling::~TPZPoroPermCoupling(){
}
int TPZPoroPermCoupling::NStateVariables() {
return 1;
}
REAL TPZPoroPermCoupling::k_permeability(REAL &phi, REAL &k){
k = 0.0;
REAL tom2 = 9.869233e-16;
switch (fk_model) {
case 0:
{
k = fk;
}
break;
case 1:
{
k = fk*pow((phi/fporosity_0),4.0);
}
break;
case 2:
{
k = 0.136*(pow(phi,1.4))*tom2;
}
break;
case 3:
{
k = (100.0*pow(phi,2.25))*(100.0*pow(phi,2.25))*tom2;
}
break;
default:
{
DebugStop();
}
break;
}
return k;
}
/** @brief Poroelastic porosity correction */
REAL TPZPoroPermCoupling::porosoty_corrected(TPZVec<TPZMaterialData> &datavec){
int u_b = 0;
int p_b = 1;
// Getting the space functions
TPZFNMatrix <9,REAL> &axes_u = datavec[u_b].axes;
// Getting the solutions and derivatives
TPZManVector<REAL,2> u = datavec[u_b].sol[0];
TPZManVector<REAL,1> p = datavec[p_b].sol[0];
TPZFNMatrix <6,REAL> du = datavec[u_b].dsol[0];
TPZFNMatrix <6,REAL> dp = datavec[p_b].dsol[0];
TPZFNMatrix<6,REAL> Grad_u(2,2,0.0);
// Computing Gradient of the Solution
Grad_u(0,0) = du(0,0)*axes_u(0,0)+du(1,0)*axes_u(1,0); // dux/dx
Grad_u(1,0) = du(0,0)*axes_u(0,1)+du(1,0)*axes_u(1,1); // dux/dy
Grad_u(0,1) = du(0,1)*axes_u(0,0)+du(1,1)*axes_u(1,0); // duy/dx
Grad_u(1,1) = du(0,1)*axes_u(0,1)+du(1,1)*axes_u(1,1); // duy/dy
REAL div_u = Grad_u(0,0) + Grad_u(1,1);
REAL phi = fporosity_0 + falpha * div_u + fSe * p[0];
return phi;
}
void TPZPoroPermCoupling::Compute_Sigma(TPZFMatrix<REAL> & S_eff,TPZFMatrix<REAL> & Grad_u, REAL p_ex){
TPZFNMatrix<6,REAL> Grad_ut(2,2,0.0), epsilon(2,2,0.0), I(2,2,0.0);
Grad_u.Transpose(&Grad_ut);
epsilon = Grad_u + Grad_ut;
epsilon *= 0.5;
I(0,0) = 1.0;
I(1,1) = 1.0;
REAL trace = (epsilon(0,0) + epsilon(1,1));
S_eff = 2.0 * fmu * epsilon + flambda * trace * I - 0.0*falpha * p_ex * I;
}
void TPZPoroPermCoupling::Compute_Sigma(TPZFMatrix<REAL> & S,TPZFMatrix<REAL> & Grad_v){
TPZFNMatrix<6,REAL> Grad_vt(3,3,0.0), epsilon(3,3,0.0), I(3,3,0.0);
Grad_v.Transpose(&Grad_vt);
epsilon = Grad_v + Grad_vt;
epsilon *= 0.5;
I.Identity();
REAL trace = (epsilon(0,0) + epsilon(1,1));
S = 2.0 * fmu * epsilon + flambda * trace * I;
}
REAL TPZPoroPermCoupling::Inner_Product(TPZFMatrix<REAL> & S,TPZFMatrix<REAL> & T){
REAL inner_product = S(0,0) * T(0,0) + S(0,1) * T(0,1) + S(1,0) * T(1,0) + S(1,1) * T(1,1); // S11 T11 + S12 T12 + S21 T21 + S22 T22
return inner_product;
}
void TPZPoroPermCoupling::Contribute(TPZVec<TPZMaterialData> &datavec, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef){
int u_b = 0;
int p_b = 1;
// Getting the space functions
TPZFMatrix<REAL> &phiu = datavec[u_b].phi;
TPZFMatrix<REAL> &phip = datavec[p_b].phi;
TPZFMatrix<REAL> &dphiu = datavec[u_b].dphix;
TPZFMatrix<REAL> &dphip = datavec[p_b].dphix;
TPZFNMatrix <9,REAL> &axes_u = datavec[u_b].axes;
TPZFNMatrix <9,REAL> &axes_p = datavec[p_b].axes;
// Getting the solutions and derivatives
TPZManVector<REAL,2> u = datavec[u_b].sol[0];
TPZManVector<REAL,1> p = datavec[p_b].sol[0];
TPZFNMatrix <6,REAL> du = datavec[u_b].dsol[0];
TPZFNMatrix <6,REAL> dp = datavec[p_b].dsol[0];
TPZFNMatrix<6,REAL> Grad_p(2,1,0.0),Grad_phi_i(2,1,0.0),Grad_phi_j(2,1,0.0);
Grad_p(0,0) = dp(0,0)*axes_p(0,0)+dp(1,0)*axes_p(1,0);
Grad_p(1,0) = dp(0,0)*axes_p(0,1)+dp(1,0)*axes_p(1,1);
int nphi_u = phiu.Rows();
int nphi_p = phip.Rows();
int first_u = 0;
int first_p = 2*nphi_u;
// Compute porosity poroelastic correction
REAL phi_poro = porosoty_corrected(datavec);
REAL dt = fSimulationData->dt();
if (!fSimulationData->IsCurrentStateQ()) {
// Darcy mono-phascis flow
for (int ip = 0; ip < nphi_p; ip++) {
ef(ip + first_p, 0) += weight * (-1.0/dt) * (phi_poro) * phip(ip,0);
}
return;
}
REAL rho_avg = (1.0-phi_poro)*frho_s+phi_poro*frho_f;
fb[0] = rho_avg*fSimulationData->Gravity()[0];
fb[1] = rho_avg*fSimulationData->Gravity()[1];
// Computing Gradient of the Solution
TPZFNMatrix<6,REAL> Grad_u(3,3,0.0),Grad_u_n,e_e,e_p,S;
Grad_u(0,0) = du(0,0)*axes_u(0,0)+du(1,0)*axes_u(1,0); // dux/dx
Grad_u(0,1) = du(0,0)*axes_u(0,1)+du(1,0)*axes_u(1,1); // dux/dy
Grad_u(1,0) = du(0,1)*axes_u(0,0)+du(1,1)*axes_u(1,0); // duy/dx
Grad_u(1,1) = du(0,1)*axes_u(0,1)+du(1,1)*axes_u(1,1); // duy/dy
// Get the pressure at the integrations points
long global_point_index = datavec[0].intGlobPtIndex;
TPZPoroPermMemory &point_memory = GetMemory()[global_point_index];
e_e = point_memory.epsilon_e_n();
e_p = point_memory.epsilon_p_n();
Grad_u_n = point_memory.grad_u_n();
corrector_DP(Grad_u_n, Grad_u, e_e, e_p, S);
TPZFNMatrix<6,REAL> Grad_vx_i(2,1,0.0),Si_x;
TPZFNMatrix<6,REAL> Grad_vy_i(2,1,0.0),Si_y;
TPZFNMatrix<6,REAL> Grad_v(2,2,0.0),T(2,2,0.0);
TPZFNMatrix<6,REAL> Grad_vx_j(2,1,0.0),Tj_x;
TPZFNMatrix<6,REAL> Grad_vy_j(2,1,0.0),Tj_y;
TPZFMatrix<REAL> & S_0 = fSimulationData->Sigma_0();
// @omar:: uncoupled behaviour
// falpha = 0.0;
S -= S_0; // Applying prestress
for (int iu = 0; iu < nphi_u; iu++) {
// Computing Gradient of the test function for each component
Grad_vx_i(0,0) = dphiu(0,iu)*axes_u(0,0)+dphiu(1,iu)*axes_u(1,0); // dvx/dx
Grad_vx_i(1,0) = dphiu(0,iu)*axes_u(0,1)+dphiu(1,iu)*axes_u(1,1); // dvx/dy
Grad_vy_i(0,0) = dphiu(0,iu)*axes_u(0,0)+dphiu(1,iu)*axes_u(1,0); // dvy/dx
Grad_vy_i(1,0) = dphiu(0,iu)*axes_u(0,1)+dphiu(1,iu)*axes_u(1,1); // dvy/dy
ef(2*iu + first_u, 0) += weight * (S(0,0) * Grad_vx_i(0,0) + S(0,1) * Grad_vx_i(1,0) - (-1.0*falpha * Grad_p(0,0) + fb[0])*phiu(iu, 0));
ef(2*iu+1 + first_u, 0) += weight * (S(1,0) * Grad_vy_i(0,0) + S(1,1) * Grad_vy_i(1,0) - (-1.0*falpha * Grad_p(1,0) + fb[1])*phiu(iu, 0));
for (int ju = 0; ju < nphi_u; ju++) {
// Computing Gradient of the test function
Grad_vx_j(0,0) = dphiu(0,ju)*axes_u(0,0)+dphiu(1,ju)*axes_u(1,0); // dvx/dx
Grad_vx_j(1,0) = dphiu(0,ju)*axes_u(0,1)+dphiu(1,ju)*axes_u(1,1); // dvx/dy
Grad_vy_j(0,0) = dphiu(0,ju)*axes_u(0,0)+dphiu(1,ju)*axes_u(1,0); // dvy/dx
Grad_vy_j(1,0) = dphiu(0,ju)*axes_u(0,1)+dphiu(1,ju)*axes_u(1,1); // dvy/dy
ek(2*iu + first_u, 2*ju + first_u) += weight * ( ( (2.0*fmu + flambda) * Grad_vx_j(0,0) ) * Grad_vx_i(0,0) + fmu * Grad_vx_j(1,0) * Grad_vx_i(1,0) );
ek(2*iu + first_u, 2*ju+1 + first_u) += weight * ( (flambda * Grad_vy_j(1,0) ) * Grad_vx_i(0,0) + fmu * Grad_vy_j(0,0) * Grad_vx_i(1,0) );
ek(2*iu+1 + first_u, 2*ju + first_u) += weight * ( fmu * Grad_vx_j(1,0) * Grad_vy_i(0,0) + flambda * Grad_vx_j(0,0) * Grad_vy_i(1,0));
ek(2*iu+1 + first_u, 2*ju+1 + first_u) += weight * ( (2.0*fmu + flambda) * Grad_vy_j(1,0) * Grad_vy_i(1,0) + fmu * Grad_vy_j(0,0) * Grad_vy_i(0,0) );
}
}
TPZFNMatrix<6,REAL> dv(2,1,0.0);
// Matrix Qc
// Coupling matrix
for(int iu = 0; iu < nphi_u; iu++ )
{
for(int jp = 0; jp < nphi_p; jp++)
{
Grad_phi_j(0,0) = dphip(0,jp)*axes_p(0,0)+dphip(1,jp)*axes_p(1,0);
Grad_phi_j(1,0) = dphip(0,jp)*axes_p(0,1)+dphip(1,jp)*axes_p(1,1);
ek(2*iu,first_p+jp) += (+1.)* weight * 1.0*falpha * Grad_phi_j(0,0) * phiu(iu,0);
ek(2*iu+1,first_p+jp) += (+1.)* weight * 1.0*falpha *Grad_phi_j(1,0) * phiu(iu,0);
}
}
// Matrix QcˆT
// Coupling matrix transpose
for(int ip = 0; ip < nphi_p; ip++ )
{
for(int ju = 0; ju < nphi_u; ju++)
{
dv(0,0) = dphiu(0,ju)*axes_u(0,0)+dphiu(1,ju)*axes_u(1,0);
dv(1,0) = dphiu(0,ju)*axes_u(0,1)+dphiu(1,ju)*axes_u(1,1);
ek(first_p+ip,2*ju) += (1.) * weight * (1.0/dt) * falpha * dv(0,0) * phip(ip,0);
ek(first_p+ip,2*ju+1) += (1.) * weight * (1.0/dt) * falpha * dv(1,0) * phip(ip,0);
}
}
// @omar:: uncoupled behaviour
// falpha = 0.25;
/** @brief Rudnicki diffusion coefficient */
/** J. W. Rudnicki. Fluid mass sources and point forces in linear elastic di usive solids. Journal of Mechanics of Materials, 5:383–393, 1986. */
REAL k = 0.0;
k_permeability(phi_poro,k);
REAL c = (k/feta)*(flambdau-flambda)*(flambda + 2.0*fmu)/(falpha*falpha*(flambdau + 2.0*fmu));
// Darcy mono-phascis flow
for (int ip = 0; ip < nphi_p; ip++) {
Grad_phi_i(0,0) = dphip(0,ip)*axes_p(0,0)+dphip(1,ip)*axes_p(1,0);
Grad_phi_i(1,0) = dphip(0,ip)*axes_p(0,1)+dphip(1,ip)*axes_p(1,1);
REAL dot = 0.0;
for (int i = 0; i < fDim; i++) {
dot += Grad_p(i,0) * Grad_phi_i(i,0);
}
ef(ip + first_p, 0) += weight * (c * dot + (1.0/dt) * (phi_poro) * phip(ip,0));
for (int jp = 0; jp < nphi_p; jp++) {
Grad_phi_j(0,0) = dphip(0,jp)*axes_p(0,0)+dphip(1,jp)*axes_p(1,0);
Grad_phi_j(1,0) = dphip(0,jp)*axes_p(0,1)+dphip(1,jp)*axes_p(1,1);
REAL dot = 0.0;
for (int i = 0; i < fDim; i++) {
dot += Grad_phi_j(i,0) * Grad_phi_i(i,0);
}
ek(ip + first_p, jp + first_p) += weight * ( c * dot + (1.0/dt) * (fSe * phip(jp,0)) * phip(ip,0) );
}
}
}
void TPZPoroPermCoupling::Contribute(TPZVec<TPZMaterialData> &datavec, REAL weight, TPZFMatrix<STATE> &ef){
TPZFMatrix<STATE> ek_fake(ef.Rows(),ef.Rows(),0.0);
this->Contribute(datavec, weight, ek_fake, ef);
}
void TPZPoroPermCoupling::ContributeBC(TPZVec<TPZMaterialData> &datavec,REAL weight, TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc){
if (!fSimulationData->IsCurrentStateQ()) {
return;
}
int u_b = 0;
int p_b = 1;
TPZFMatrix<REAL> &phiu = datavec[u_b].phi;
TPZFMatrix<REAL> &phip = datavec[p_b].phi;
// Getting the solutions and derivatives
TPZManVector<REAL,2> u = datavec[u_b].sol[0];
TPZManVector<REAL,1> p = datavec[p_b].sol[0];
int phru = phiu.Rows();
int phrp = phip.Rows();
short in,jn;
REAL v[3];
v[0] = bc.Val2()(0,0); // Ux displacement
v[1] = bc.Val2()(1,0); // Uy displacement
v[2] = bc.Val2()(2,0); // Pressure
REAL time = this->SimulationData()->t();
REAL Value = bc.Val2()(0,0);
if (bc.HasTimedependentBCForcingFunction()) {
TPZManVector<REAL,3> f(3);
TPZFMatrix<REAL> gradf;
bc.TimedependentBCForcingFunction()->Execute(datavec[p_b].x, time, f, gradf);
v[0] = f[0]; // Ux displacement or Tx
v[1] = f[1]; // Uy displacement or Ty
v[2] = f[2]; // Pressure
}
else{
Value = bc.Val2()(0,0);
}
// Dirichlet in Pressure
switch (bc.Type())
{
case 0 :
{
// Dirichlet condition for each state variable
// Elasticity Equation
for(in = 0 ; in < phru; in++)
{
// Contribution for load Vector
ef(2*in,0) += gBigNumber*(u[0] - v[0])*phiu(in,0)*weight; // X displacement Value
ef(2*in+1,0) += gBigNumber*(u[1] - v[1])*phiu(in,0)*weight; // y displacement Value
for (jn = 0 ; jn < phru; jn++)
{
// Contribution for Stiffness Matrix
ek(2*in,2*jn) += gBigNumber*phiu(in,0)*phiu(jn,0)*weight; // X displacement
ek(2*in+1,2*jn+1) += gBigNumber*phiu(in,0)*phiu(jn,0)*weight; // Y displacement
}
}
// Diffusion Equation
for(in = 0 ; in < phrp; in++)
{
// Contribution for load Vector
ef(in+2*phru,0) += gBigNumber*(p[0]-v[2])*phip(in,0)*weight; // P Pressure Value
for (jn = 0 ; jn < phrp; jn++)
{
// Contribution for Stiffness Matrix
ek(in+2*phru,jn+2*phru) += gBigNumber*phip(in,0)*phip(jn,0)*weight; // P Pressure
}
}
break;
}
case 1 :
{
// Dirichlet condition for each state variable
// Elasticity Equation
for(in = 0 ; in < phru; in++)
{
// Contribution for load Vector
ef(2*in,0) += gBigNumber*(u[0] - v[0])*phiu(in,0)*weight; // X displacement Value
for (jn = 0 ; jn < phru; jn++)
{
// Contribution for Stiffness Matrix
ek(2*in,2*jn) += gBigNumber*phiu(in,0)*phiu(jn,0)*weight; // X displacement
}
}
// Diffusion Equation
for(in = 0 ; in < phrp; in++)
{
// Contribution for load Vector
ef(in+2*phru,0) += gBigNumber*(p[0]-v[2])*phip(in,0)*weight; // P Pressure Value
for (jn = 0 ; jn < phrp; jn++)
{
// Contribution for Stiffness Matrix
ek(in+2*phru,jn+2*phru) += gBigNumber*phip(in,0)*phip(jn,0)*weight; // P Pressure
}
}
break;
}
case 2 :
{
// Dirichlet condition for each state variable
// Elasticity Equation
for(in = 0 ; in < phru; in++)
{
// Contribution for load Vector
ef(2*in+1,0) += gBigNumber*(u[1] - v[1])*phiu(in,0)*weight; // y displacement Value
for (jn = 0 ; jn < phru; jn++)
{
// Contribution for Stiffness Matrix
ek(2*in+1,2*jn+1) += gBigNumber*phiu(in,0)*phiu(jn,0)*weight; // Y displacement
}
}
// Diffusion Equation
for(in = 0 ; in < phrp; in++)
{
// Contribution for load Vector
ef(in+2*phru,0) += gBigNumber*(p[0]-v[2])*phip(in,0)*weight; // P Pressure Value
for (jn = 0 ; jn < phrp; jn++)
{
// Contribution for Stiffness Matrix
ek(in+2*phru,jn+2*phru) += gBigNumber*phip(in,0)*phip(jn,0)*weight; // P Pressure
}
}
break;
}
case 3 :
{
// Neumann condition for each state variable
// Elasticity Equation
for(in = 0 ; in <phru; in++)
{
// Normal Tension Components on neumman boundary
ef(2*in,0) += -1.0*v[0]*phiu(in,0)*weight; // Tnx
ef(2*in+1,0) += -1.0*v[1]*phiu(in,0)*weight; // Tny
}
// Diffusion Equation
for(in = 0 ; in < phrp; in++)
{
// Contribution for load Vector
ef(in+2*phru,0) += gBigNumber*(p[0]-v[2])*phip(in,0)*weight; // P Pressure Value
for (jn = 0 ; jn < phrp; jn++)
{
// Contribution for Stiffness Matrix
ek(in+2*phru,jn+2*phru) += gBigNumber*phip(in,0)*phip(jn,0)*weight; // P Pressure
}
}
break;
}
case 4 :
{
// Neumann condition for each state variable
// Elasticity Equation
for(in = 0 ; in <phru; in++)
{
// Normal Tension Components on neumman boundary
ef(2*in,0) += -1.0*v[0]*phiu(in,0)*weight; // Tnx
}
// Diffusion Equation
for(in = 0 ; in < phrp; in++)
{
// Contribution for load Vector
ef(in+2*phru,0) += gBigNumber*(p[0]-v[2])*phip(in,0)*weight; // P Pressure Value
for (jn = 0 ; jn < phrp; jn++)
{
// Contribution for Stiffness Matrix
ek(in+2*phru,jn+2*phru) += gBigNumber*phip(in,0)*phip(jn,0)*weight; // P Pressure
}
}
break;
}
case 5 :
{
// Neumann condition for each state variable
// Elasticity Equation
for(in = 0 ; in <phru; in++)
{
// Normal Tension Components on neumman boundary
ef(2*in+1,0) += -1.0*v[1]*phiu(in,0)*weight; // Tny
}
// Diffusion Equation
for(in = 0 ; in < phrp; in++)
{
// Contribution for load Vector
ef(in+2*phru,0) += gBigNumber*(p[0]-v[2])*phip(in,0)*weight; // P Pressure Value
for (jn = 0 ; jn < phrp; jn++)
{
// Contribution for Stiffness Matrix
ek(in+2*phru,jn+2*phru) += gBigNumber*phip(in,0)*phip(jn,0)*weight; // P Pressure
}
}
break;
}
case 6 :
{
// Dirichlet condition for each state variable
// Elasticity Equation
for(in = 0 ; in < phru; in++)
{
// Contribution for load Vector
ef(2*in,0) += gBigNumber*(u[0] - v[0])*phiu(in,0)*weight; // X displacement Value
ef(2*in+1,0) += gBigNumber*(u[1] - v[1])*phiu(in,0)*weight; // y displacement Value
for (jn = 0 ; jn < phru; jn++)
{
// Contribution for Stiffness Matrix
ek(2*in,2*jn) += gBigNumber*phiu(in,0)*phiu(jn,0)*weight; // X displacement
ek(2*in+1,2*jn+1) += gBigNumber*phiu(in,0)*phiu(jn,0)*weight; // Y displacement
}
}
// Diffusion Equation
for(in = 0 ; in < phrp; in++)
{
// Normal Flux on neumman boundary
ef(in+2*phru,0) += -1.0*v[2]*phip(in,0)*weight; // Qnormal
}
break;
}
case 7 :
{
// Dirichlet condition for each state variable
// Elasticity Equation
for(in = 0 ; in < phru; in++)
{
// Contribution for load Vector
ef(2*in,0) += gBigNumber*(u[0] - v[0])*phiu(in,0)*weight; // X displacement Value
for (jn = 0 ; jn < phru; jn++)
{
// Contribution for Stiffness Matrix
ek(2*in,2*jn) += gBigNumber*phiu(in,0)*phiu(jn,0)*weight; // X displacement
}
}
// Diffusion Equation
for(in = 0 ; in < phrp; in++)
{
// Normal Flux on neumman boundary
ef(in+2*phru,0) += -1.0*v[2]*phip(in,0)*weight; // Qnormal
}
break;
}
case 8 :
{
// Dirichlet condition for each state variable
// Elasticity Equation
for(in = 0 ; in < phru; in++)
{
// Contribution for load Vector
ef(2*in+1,0) += gBigNumber*(u[1] - v[1])*phiu(in,0)*weight; // y displacement Value
for (jn = 0 ; jn < phru; jn++)
{
// Contribution for Stiffness Matrix
ek(2*in+1,2*jn+1) += gBigNumber*phiu(in,0)*phiu(jn,0)*weight; // Y displacement
}
}
// Diffusion Equation
for(in = 0 ; in < phrp; in++)
{
// Normal Flux on neumman boundary
ef(in+2*phru,0) += -1.0*v[2]*phip(in,0)*weight; // Qnormal
}
break;
}
case 9 :
{
// Neumann condition for each state variable
// Elasticity Equation
for(in = 0 ; in <phru; in++)
{
// Normal Tension Components on neumman boundary
ef(2*in,0) += -1.0*v[0]*phiu(in,0)*weight; // Tnx
ef(2*in+1,0) += -1.0*v[1]*phiu(in,0)*weight; // Tny
}
// Diffusion Equation
for(in = 0 ; in < phrp; in++)
{
// Normal Flux on neumman boundary
ef(in+2*phru,0) += -1.0*v[2]*phip(in,0)*weight; // Qnormal
}
break;
}
case 10 :
{
// Neumann condition for each state variable
// Elasticity Equation
for(in = 0 ; in <phru; in++)
{
// Normal Tension Components on neumman boundary
ef(2*in,0) += -1.0*v[0]*phiu(in,0)*weight; // Tnx
}
// Diffusion Equation
for(in = 0 ; in < phrp; in++)
{
// Normal Flux on neumman boundary
ef(in+2*phru,0) += -1.0*v[2]*phip(in,0)*weight; // Qnormal
}
break;
}
case 11 :
{
// Neumann condition for each state variable
// Elasticity Equation
for(in = 0 ; in <phru; in++)
{
// Normal Tension Components on neumman boundary
ef(2*in+1,0) += -1.0*v[1]*phiu(in,0)*weight; // Tny
}
// Diffusion Equation
for(in = 0 ; in < phrp; in++)
{
// Normal Flux on neumman boundary
ef(in+2*phru,0) += -1.0*v[2]*phip(in,0)*weight; // Qnormal
}
break;
}
default:
{
DebugStop();
}
break;
}
}
void TPZPoroPermCoupling::FillDataRequirements(TPZVec<TPZMaterialData > &datavec)
{
int nref = datavec.size();
for(int i = 0; i<nref; i++)
{
datavec[i].SetAllRequirements(false);
datavec[i].fNeedsSol = true;
datavec[i].fNeedsNeighborSol = true;
datavec[i].fNeedsNeighborCenter = false;
datavec[i].fNeedsNormal = true;
}
}
void TPZPoroPermCoupling::FillBoundaryConditionDataRequirement(int type,TPZVec<TPZMaterialData > &datavec){
int nref = datavec.size();
for(int i = 0; i<nref; i++)
{
datavec[i].fNeedsSol = true;
datavec[i].fNeedsNormal = true;
datavec[i].fNeedsNeighborSol = true;
}
}
void TPZPoroPermCoupling::Print(std::ostream &out)
{
out << "Material Name : " << Name() << "\n";
out << "Plane Problem (fPlaneStress = 0, for Plane Strain conditions) " << fPlaneStress << std::endl;
out << "Properties for TPZPoroPermCoupling: \n";
out << "\t Poisson Ratio = " << fnu << std::endl;
out << "\t Undarined Poisson Ratio = " << fnuu << std::endl;
out << "\t First Lamé Parameter = " << flambda << std::endl;
out << "\t Second Lamé Parameter = " << fmu << std::endl;
out << "\t Undrained First Lamé Parameter = " << flambdau << std::endl;
out << "\t Biot coefficient = " << falpha << std::endl;
out << "\t Body force vector B {X-direction, Y-direction} = " << fb[0] << ' ' << fb[1] << std::endl;
out << "Properties for Diffusion: \n";
out << "\t Permeability = " << fk << std::endl;
out << "\t Fluid Viscosity = " << feta << std::endl;
out << "\t Constrained specific storage at constant strain Se = " << fSe << std::endl;
out << "Class properties :";
TPZMaterial::Print(out);
out << "\n";
}
/** Returns the variable index associated with the name */
int TPZPoroPermCoupling::VariableIndex(const std::string &name)
{
// Elasticity Variables
if(!strcmp("u",name.c_str())) return 1;
if(!strcmp("s_x",name.c_str())) return 2;
if(!strcmp("s_y",name.c_str())) return 3;
if(!strcmp("s_z",name.c_str())) return 4;
if(!strcmp("t_xy",name.c_str())) return 5;
// Diffusion Variables
if(!strcmp("p_ex",name.c_str())) return 6;
if(!strcmp("v",name.c_str())) return 7;
if(!strcmp("k_x",name.c_str())) return 8;
if(!strcmp("k_y",name.c_str())) return 9;
if(!strcmp("phi",name.c_str())) return 10;
if(!strcmp("e_x",name.c_str())) return 11;
if(!strcmp("e_y",name.c_str())) return 12;
if(!strcmp("e_xy",name.c_str())) return 13;
if(!strcmp("ep_x",name.c_str())) return 14;
if(!strcmp("ep_y",name.c_str())) return 15;
if(!strcmp("ep_xy",name.c_str())) return 16;
if(!strcmp("K_0",name.c_str())) return 17;
return TPZMaterial::VariableIndex(name);
}
int TPZPoroPermCoupling::NSolutionVariables(int var){
if(var == 1) return fDim;
if(var == 2) return 1;
if(var == 3) return 1;
if(var == 4) return 1;
if(var == 5) return 1;
if(var == 6) return 1;
if(var == 7) return fDim;
if(var == 8) return 1;
if(var == 9) return 1;
if(var == 10) return 1;
if(var == 11) return 1;
if(var == 12) return 1;
if(var == 13) return 1;
if(var == 14) return 1;
if(var == 15) return 1;
if(var == 16) return 1;
if(var == 17) return 1;
return TPZMaterial::NSolutionVariables(var);
}
// Calculate Secondary variables based on ux, uy, Pore pressure and their derivatives
void TPZPoroPermCoupling::Solution(TPZVec<TPZMaterialData> &datavec, int var, TPZVec<STATE> &Solout){
Solout.Resize( this->NSolutionVariables(var));
int u_b = 0;
int p_b = 1;
// Getting the space functions
TPZFNMatrix <9,REAL> &axes_u = datavec[u_b].axes;
TPZFNMatrix <9,REAL> &axes_p = datavec[p_b].axes;
// Getting the solutions and derivatives
TPZManVector<REAL,2> u = datavec[u_b].sol[0];
TPZManVector<REAL,1> p = datavec[p_b].sol[0];
TPZFNMatrix <6,REAL> du = datavec[u_b].dsol[0];
TPZFNMatrix <6,REAL> dp = datavec[p_b].dsol[0];
REAL to_Mpa = 1.0e-6;
REAL to_Darcy = 1.013249966e+12;
// Computing Gradient of the Solution
TPZFNMatrix<6,REAL> Grad_p(3,1,0.0),Grad_u(3,3,0.0),Grad_u_n(3,3,0.0),e_e(3,3,0.0),e_p(3,3,0.0),S;
Grad_p(0,0) = dp(0,0)*axes_p(0,0)+dp(1,0)*axes_p(1,0); // dp/dx
Grad_p(1,0) = dp(0,0)*axes_p(0,1)+dp(1,0)*axes_p(1,1); // dp/dy
Grad_u(0,0) = du(0,0)*axes_u(0,0)+du(1,0)*axes_u(1,0); // dux/dx
Grad_u(0,1) = du(0,0)*axes_u(0,1)+du(1,0)*axes_u(1,1); // dux/dy
Grad_u(1,0) = du(0,1)*axes_u(0,0)+du(1,1)*axes_u(1,0); // duy/dx
Grad_u(1,1) = du(0,1)*axes_u(0,1)+du(1,1)*axes_u(1,1); // duy/dy
corrector_DP(Grad_u_n, Grad_u, e_e, e_p, S);
// Displacements
if(var == 1){
Solout[0] = u[0];
Solout[1] = u[1];
return;
}
// sigma_x
if(var == 2) {
Solout[0] = S(0,0)*to_Mpa;
return;
}
// sigma_y
if(var == 3) {
Solout[0] = S(1,1)*to_Mpa;
return;
}
// sigma_z
if(var == 4) {
Solout[0] = S(2,2)*to_Mpa;
return;
}
// tau_xy
if(var == 5) {
Solout[0] = S(0,1)*to_Mpa;
return;
}
// Pore pressure excess
if(var == 6) {
Solout[0] = p[0]*to_Mpa;
return;
}
// v
if(var == 7) {
REAL phi = porosoty_corrected(datavec);
REAL k;
k_permeability(phi, k);
Solout[0] = -(k/feta) * Grad_p(0,0);
Solout[1] = -(k/feta) * Grad_p(1,0);
return;
}
// k_x
if(var == 8) {
REAL phi = porosoty_corrected(datavec);
REAL k = 0.0;
k_permeability(phi, k);
Solout[0] = k*to_Darcy;
return;
}
// k_y
if(var == 9) {
REAL phi = porosoty_corrected(datavec);
REAL k = 0.0;
k_permeability(phi, k);
Solout[0] = k*to_Darcy;
return;
}
// Porosity form poroelastic correction
if(var == 10) {
Solout[0] = porosoty_corrected(datavec);
return;
}
// epsilon_x
if(var == 11) {
Solout[0] = e_e(0,0);
return;
}
// epsilon_y
if(var == 12) {
Solout[0] = e_e(1,1);
return;
}
// epsilon_xy
if(var == 13) {
Solout[0] = e_e(0,1);
return;
}
// epsilon_p_x
if(var == 14) {
Solout[0] = e_p(0,0);
return;
}
// epsilon_p_y
if(var == 15) {
Solout[0] = e_p(1,1);
return;
}
// epsilon_p_xy
if(var == 16) {
Solout[0] = e_p(0,1);
return;
}
// K_0
if(var == 17) {
Solout[0] = S(0,0)/S(1,1);
return;
}
// Darcy's velocity
// if (var == 7)
// {
// int id;
// TPZManVector<STATE> dsolp(2,0);
// dsolp[0] = datavec[1].dsol[0](0,0)*datavec[1].axes(0,0)+datavec[1].dsol[0](1,0)*datavec[1].axes(1,0);
// dsolp[1] = datavec[1].dsol[0](0,0)*datavec[1].axes(0,1)+datavec[1].dsol[0](1,0)*datavec[1].axes(1,1);
// for(id=0 ; id<fDim; id++)
// {
// Solout[id] = -1. * this->fK * dsolp[id];
// }
// Solout[2] = 0.0;
// return;
// }
}