/
FourNodeQuadUP.cpp
1431 lines (1187 loc) · 36.7 KB
/
FourNodeQuadUP.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
///////////////////////////////////////////////////////////////////////////////
// Description: This file contains the class definition for FourNodeQuadUP. //
// FourNodeQuadUP is a 4-node plane strain element for solid-fluid fully //
// coupled analysis. This implementation is a simplified u-p formulation //
// of Biot theory (u - solid displacement, p - fluid pressure). Each element //
// node has two DOFs for u and 1 DOF for p. //
// //
// Written by Zhaohui Yang (May 2002) //
// based on FourNodeQuad element by Michael Scott //
///////////////////////////////////////////////////////////////////////////////
// $Revision: 1.8 $
// $Date: 2008-07-08 00:01:54 $
// $Source: /usr/local/cvs/OpenSees/SRC/element/UP-ucsd/FourNodeQuadUP.cpp,v $
#include <FourNodeQuadUP.h>
#include <Node.h>
#include <NDMaterial.h>
#include <Matrix.h>
#include <Vector.h>
#include <ID.h>
#include <Renderer.h>
#include <Domain.h>
#include <string.h>
#include <Information.h>
#include <Parameter.h>
#include <Channel.h>
#include <FEM_ObjectBroker.h>
#include <ElementResponse.h>
#include <ElementalLoad.h>
#include <elementAPI.h>
void* OPS_FourNodeQuadUP()
{
if (OPS_GetNDM() != 2 || OPS_GetNDF() != 3) {
opserr << "WARNING -- model dimensions and/or nodal DOF not compatible with QuadUP element\n";
return 0;
}
if (OPS_GetNumRemainingInputArgs() < 11) {
opserr << "WARNING insufficient arguments\n";
opserr << "Want: element FourNodeQuadUP eleTag? iNode? jNode? kNode? lNode? thk? type? matTag? bulk? rho? perm_x? perm_y? <b1? b2? pressure? dM? dK?>\n";
return 0;
}
// FourNodeQuadUPId, iNode, jNode, kNode, lNode
int tags[5];
int num = 5;
if (OPS_GetIntInput(&num,tags) < 0) {
opserr<<"WARNING: invalid integer input\n";
return 0;
}
double thk;
num = 1;
if (OPS_GetDoubleInput(&num,&thk) < 0) {
opserr<<"WARNING: invalid double input\n";
return 0;
}
int matTag;
if (OPS_GetIntInput(&num,&matTag) < 0) {
opserr<<"WARNING: invalid integer input\n";
return 0;
}
NDMaterial* mat = OPS_getNDMaterial(matTag);
if (mat == 0) {
opserr << "WARNING material not found\n";
opserr << "material tag: " << matTag;
opserr << "\nquad element: " << tags[0] << endln;
}
// bk, r, perm1, perm2
double data[4];
num = 4;
if (OPS_GetDoubleInput(&num,data) < 0) {
opserr<<"WARNING: invalid double input\n";
return 0;
}
// b1, b2, p
double opt[3] = {0,0,0};
num = OPS_GetNumRemainingInputArgs();
if (num > 3) {
num = 3;
}
if (num > 0) {
if (OPS_GetDoubleInput(&num,opt) < 0) {
opserr<<"WARNING: invalid double input\n";
return 0;
}
}
return new FourNodeQuadUP(tags[0],tags[1],tags[2],tags[3],tags[4],
*mat,"PlaneStrain",thk,data[0],data[1],data[2],data[3],
opt[0],opt[1],opt[2]);
}
Matrix FourNodeQuadUP::K(12,12);
Vector FourNodeQuadUP::P(12);
double FourNodeQuadUP::shp[3][4][4];
double FourNodeQuadUP::pts[4][2];
double FourNodeQuadUP::wts[4];
double FourNodeQuadUP::dvol[4];
double FourNodeQuadUP::shpBar[3][4];
Node *FourNodeQuadUP::theNodes[4];
FourNodeQuadUP::FourNodeQuadUP(int tag, int nd1, int nd2, int nd3, int nd4,
NDMaterial &m, const char *type, double t, double bulk,
double r, double p1, double p2, double b1, double b2, double p)
:Element (tag, ELE_TAG_FourNodeQuadUP),
theMaterial(0), connectedExternalNodes(4),
nd1Ptr(0), nd2Ptr(0), nd3Ptr(0), nd4Ptr(0), Ki(0),
Q(12), pressureLoad(12), applyLoad(0), thickness(t), kc(bulk), rho(r), pressure(p),
end1InitDisp(0),end2InitDisp(0),end3InitDisp(0),end4InitDisp(0)
{
pts[0][0] = -0.5773502691896258;
pts[0][1] = -0.5773502691896258;
pts[1][0] = 0.5773502691896258;
pts[1][1] = -0.5773502691896258;
pts[2][0] = 0.5773502691896258;
pts[2][1] = 0.5773502691896258;
pts[3][0] = -0.5773502691896258;
pts[3][1] = 0.5773502691896258;
wts[0] = 1.0;
wts[1] = 1.0;
wts[2] = 1.0;
wts[3] = 1.0;
// Body forces
b[0] = b1;
b[1] = b2;
// Permeabilities
perm[0] = p1;
perm[1] = p2;
// Allocate arrays of pointers to NDMaterials
theMaterial = new NDMaterial *[4];
if (theMaterial == 0) {
opserr << "FourNodeQuadUP::FourNodeQuadUP - failed allocate material model pointer\n";
exit(-1);
}
for (int i = 0; i < 4; i++) {
// Get copies of the material model for each integration point
theMaterial[i] = m.getCopy(type);
// Check allocation
if (theMaterial[i] == 0) {
opserr << "FourNodeQuadUP::FourNodeQuadUP -- failed to get a copy of material model\n";
exit(-1);
}
}
// Set connected external node IDs
connectedExternalNodes(0) = nd1;
connectedExternalNodes(1) = nd2;
connectedExternalNodes(2) = nd3;
connectedExternalNodes(3) = nd4;
}
FourNodeQuadUP::FourNodeQuadUP()
:Element (0,ELE_TAG_FourNodeQuadUP),
theMaterial(0), connectedExternalNodes(4),
nd1Ptr(0), nd2Ptr(0), nd3Ptr(0), nd4Ptr(0), Ki(0),
Q(12), pressureLoad(12), applyLoad(0), thickness(0.0), kc(0.0), rho(0.0), pressure(0.0),
end1InitDisp(0),end2InitDisp(0),end3InitDisp(0),end4InitDisp(0)
{
pts[0][0] = -0.577350269189626;
pts[0][1] = -0.577350269189626;
pts[1][0] = 0.577350269189626;
pts[1][1] = -0.577350269189626;
pts[2][0] = 0.577350269189626;
pts[2][1] = 0.577350269189626;
pts[3][0] = -0.577350269189626;
pts[3][1] = 0.577350269189626;
wts[0] = 1.0;
wts[1] = 1.0;
wts[2] = 1.0;
wts[3] = 1.0;
}
FourNodeQuadUP::~FourNodeQuadUP()
{
for (int i = 0; i < 4; i++) {
if (theMaterial[i])
delete theMaterial[i];
}
// Delete the array of pointers to NDMaterial pointer arrays
if (theMaterial)
delete [] theMaterial;
if (Ki != 0)
delete Ki;
if (end1InitDisp != 0)
delete [] end1InitDisp;
if (end2InitDisp != 0)
delete [] end2InitDisp;
if (end3InitDisp != 0)
delete [] end3InitDisp;
if (end4InitDisp != 0)
delete [] end4InitDisp;
}
int
FourNodeQuadUP::getNumExternalNodes() const
{
return 4;
}
const ID&
FourNodeQuadUP::getExternalNodes()
{
return connectedExternalNodes;
}
Node **
FourNodeQuadUP::getNodePtrs()
{
theNodes[0] = nd1Ptr;
theNodes[1] = nd2Ptr;
theNodes[2] = nd3Ptr;
theNodes[3] = nd4Ptr;
return theNodes;
}
int
FourNodeQuadUP::getNumDOF()
{
return 12;
}
void
FourNodeQuadUP::setDomain(Domain *theDomain)
{
// Check Domain is not null - invoked when object removed from a domain
if (theDomain == 0) {
nd1Ptr = 0;
nd2Ptr = 0;
nd3Ptr = 0;
nd4Ptr = 0;
return;
}
int Nd1 = connectedExternalNodes(0);
int Nd2 = connectedExternalNodes(1);
int Nd3 = connectedExternalNodes(2);
int Nd4 = connectedExternalNodes(3);
nd1Ptr = theDomain->getNode(Nd1);
nd2Ptr = theDomain->getNode(Nd2);
nd3Ptr = theDomain->getNode(Nd3);
nd4Ptr = theDomain->getNode(Nd4);
if (nd1Ptr == 0 || nd2Ptr == 0 || nd3Ptr == 0 || nd4Ptr == 0) {
//opserr << "FATAL ERROR FourNodeQuadUP (tag: %d), node not found in domain",
// this->getTag());
return;
}
int dofNd1 = nd1Ptr->getNumberDOF();
int dofNd2 = nd2Ptr->getNumberDOF();
int dofNd3 = nd3Ptr->getNumberDOF();
int dofNd4 = nd4Ptr->getNumberDOF();
if (dofNd1 != 3 || dofNd2 != 3 || dofNd3 != 3 || dofNd4 != 3) {
//opserr << "FATAL ERROR FourNodeQuadUP (tag: %d), has differing number of DOFs at its nodes",
// this->getTag());
return;
}
this->DomainComponent::setDomain(theDomain);
// Compute consistent nodal loads due to pressure
this->setPressureLoadAtNodes();
const Vector &disp1 = nd1Ptr->getDisp();
if (disp1.Norm() != 0.0) {
end1InitDisp = new double[2];
for (int i=0; i<2; i++) {
end1InitDisp[0] = disp1(i);
}
}
const Vector &disp2 = nd2Ptr->getDisp();
if (disp2.Norm() != 0.0) {
end2InitDisp = new double[2];
for (int i=0; i<2; i++) {
end2InitDisp[0] = disp2(i);
}
}
const Vector &disp3 = nd3Ptr->getDisp();
if (disp3.Norm() != 0.0) {
end3InitDisp = new double[2];
for (int i=0; i<2; i++) {
end3InitDisp[0] = disp3(i);
}
}
const Vector &disp4 = nd4Ptr->getDisp();
if (disp4.Norm() != 0.0) {
end4InitDisp = new double[2];
for (int i=0; i<2; i++) {
end4InitDisp[0] = disp4(i);
}
}
}
int
FourNodeQuadUP::commitState() {
int retVal = 0;
// call element commitState to do any base class stuff
if ((retVal = this->Element::commitState()) != 0) {
opserr << "FourNodeQuad_UP::commitState () - failed in base class";
}
// Loop over the integration points and commit the material states
for (int i = 0; i < 4; i++)
retVal += theMaterial[i]->commitState();
return retVal;
}
int
FourNodeQuadUP::revertToLastCommit()
{
int retVal = 0;
// Loop over the integration points and revert to last committed state
for (int i = 0; i < 4; i++)
retVal += theMaterial[i]->revertToLastCommit();
return retVal;
}
int
FourNodeQuadUP::revertToStart()
{
int retVal = 0;
// Loop over the integration points and revert states to start
for (int i = 0; i < 4; i++)
retVal += theMaterial[i]->revertToStart();
return retVal;
}
int
FourNodeQuadUP::update()
{
const Vector &disp1 = nd1Ptr->getTrialDisp();
const Vector &disp2 = nd2Ptr->getTrialDisp();
const Vector &disp3 = nd3Ptr->getTrialDisp();
const Vector &disp4 = nd4Ptr->getTrialDisp();
static double u[2][4];
if (end1InitDisp == 0) {
u[0][0] = disp1(0);
u[1][0] = disp1(1);
} else {
u[0][0] = disp1(0) - end1InitDisp[0];
u[1][0] = disp1(1) - end1InitDisp[1];
}
if (end2InitDisp == 0) {
u[0][1] = disp2(0);
u[1][1] = disp2(1);
} else {
u[0][1] = disp2(0) - end2InitDisp[0];
u[1][1] = disp2(1) - end2InitDisp[1];
}
if (end3InitDisp == 0) {
u[0][2] = disp3(0);
u[1][2] = disp3(1);
} else {
u[0][2] = disp3(0) - end3InitDisp[0];
u[1][2] = disp3(1) - end3InitDisp[1];
}
if (end3InitDisp == 0) {
u[0][3] = disp4(0);
u[1][3] = disp4(1);
} else {
u[0][3] = disp4(0) - end4InitDisp[0];
u[1][3] = disp4(1) - end4InitDisp[1];;
}
static Vector eps(3);
int ret = 0;
// Determine Jacobian for this integration point
this->shapeFunction();
// Loop over the integration points
for (int i = 0; i < 4; i++) {
// Interpolate strains
//eps = B*u;
//eps.addMatrixVector(0.0, B, u, 1.0);
eps.Zero();
for (int beta = 0; beta < 4; beta++) {
eps(0) += shp[0][beta][i]*u[0][beta];
eps(1) += shp[1][beta][i]*u[1][beta];
eps(2) += shp[0][beta][i]*u[1][beta] + shp[1][beta][i]*u[0][beta];
}
// Set the material strain
ret += theMaterial[i]->setTrialStrain(eps);
}
return ret;
}
const Matrix&
FourNodeQuadUP::getTangentStiff()
{
K.Zero();
double DB[3][2];
// Determine Jacobian for this integration point
this->shapeFunction();
// Loop over the integration points
for (int i = 0; i < 4; i++) {
// Get the material tangent
const Matrix &D = theMaterial[i]->getTangent();
// Perform numerical integration
//K = K + (B^ D * B) * intWt(i)*intWt(j) * detJ;
//K.addMatrixTripleProduct(1.0, B, D, intWt(i)*intWt(j)*detJ);
for (int alpha = 0, ia = 0; alpha < 4; alpha++, ia += 3) {
for (int beta = 0, ib = 0; beta < 4; beta++, ib += 3) {
DB[0][0] = dvol[i] * (D(0,0)*shp[0][beta][i] + D(0,2)*shp[1][beta][i]);
DB[1][0] = dvol[i] * (D(1,0)*shp[0][beta][i] + D(1,2)*shp[1][beta][i]);
DB[2][0] = dvol[i] * (D(2,0)*shp[0][beta][i] + D(2,2)*shp[1][beta][i]);
DB[0][1] = dvol[i] * (D(0,1)*shp[1][beta][i] + D(0,2)*shp[0][beta][i]);
DB[1][1] = dvol[i] * (D(1,1)*shp[1][beta][i] + D(1,2)*shp[0][beta][i]);
DB[2][1] = dvol[i] * (D(2,1)*shp[1][beta][i] + D(2,2)*shp[0][beta][i]);
K(ia,ib) += shp[0][alpha][i]*DB[0][0] + shp[1][alpha][i]*DB[2][0];
K(ia,ib+1) += shp[0][alpha][i]*DB[0][1] + shp[1][alpha][i]*DB[2][1];
K(ia+1,ib) += shp[1][alpha][i]*DB[1][0] + shp[0][alpha][i]*DB[2][0];
K(ia+1,ib+1) += shp[1][alpha][i]*DB[1][1] + shp[0][alpha][i]*DB[2][1];
}
}
}
return K;
}
const Matrix &FourNodeQuadUP::getInitialStiff ()
{
if (Ki != 0) return *Ki;
K.Zero();
double DB[3][2];
// Determine Jacobian for this integration point
this->shapeFunction();
// Loop over the integration points
for (int i = 0; i < 4; i++) {
// Get the material tangent
const Matrix &D = theMaterial[i]->getInitialTangent();
// Perform numerical integration
//K = K + (B^ D * B) * intWt(i)*intWt(j) * detJ;
//K.addMatrixTripleProduct(1.0, B, D, intWt(i)*intWt(j)*detJ);
for (int alpha = 0, ia = 0; alpha < 4; alpha++, ia += 3) {
for (int beta = 0, ib = 0; beta < 4; beta++, ib += 3) {
DB[0][0] = dvol[i] * (D(0,0)*shp[0][beta][i] + D(0,2)*shp[1][beta][i]);
DB[1][0] = dvol[i] * (D(1,0)*shp[0][beta][i] + D(1,2)*shp[1][beta][i]);
DB[2][0] = dvol[i] * (D(2,0)*shp[0][beta][i] + D(2,2)*shp[1][beta][i]);
DB[0][1] = dvol[i] * (D(0,1)*shp[1][beta][i] + D(0,2)*shp[0][beta][i]);
DB[1][1] = dvol[i] * (D(1,1)*shp[1][beta][i] + D(1,2)*shp[0][beta][i]);
DB[2][1] = dvol[i] * (D(2,1)*shp[1][beta][i] + D(2,2)*shp[0][beta][i]);
K(ia,ib) += shp[0][alpha][i]*DB[0][0] + shp[1][alpha][i]*DB[2][0];
K(ia,ib+1) += shp[0][alpha][i]*DB[0][1] + shp[1][alpha][i]*DB[2][1];
K(ia+1,ib) += shp[1][alpha][i]*DB[1][0] + shp[0][alpha][i]*DB[2][0];
K(ia+1,ib+1) += shp[1][alpha][i]*DB[1][1] + shp[0][alpha][i]*DB[2][1];
}
}
}
Ki = new Matrix(K);
if (Ki == 0) {
opserr << "FATAL FourNodeQuadUP::getInitialStiff() -";
opserr << "ran out of memory\n";
exit(-1);
}
return *Ki;
}
const Matrix&
FourNodeQuadUP::getDamp()
{
static Matrix Kdamp(12,12);
Kdamp.Zero();
if (betaK != 0.0)
Kdamp.addMatrix(1.0, this->getTangentStiff(), betaK);
if (betaK0 != 0.0)
Kdamp.addMatrix(1.0, this->getInitialStiff(), betaK0);
if (betaKc != 0.0)
Kdamp.addMatrix(1.0, *Kc, betaKc);
int i, j, m, i1, j1;
if (alphaM != 0.0) {
this->getMass();
for (i = 0; i < 12; i += 3) {
for (j = 0; j < 12; j += 3) {
Kdamp(i,j) += K(i,j)*alphaM;
Kdamp(i+1,j+1) += K(i+1,j+1)*alphaM;
}
}
}
// Determine Jacobian for this integration point
this->shapeFunction();
// Compute coupling matrix
double vol = dvol[0] + dvol[1] + dvol[2] + dvol[3];
for (i = 0; i < 12; i += 3) {
i1 = i / 3;
for (j = 2; j < 12; j += 3) {
j1 = (j-2) / 3;
//K(i,j) += -vol*shpBar[0][i1]*shpBar[2][j1];
//K(i+1,j) += -vol*shpBar[1][i1]*shpBar[2][j1];
for (m = 0; m < 4; m++) {
Kdamp(i,j) += -dvol[m]*shp[0][i1][m]*shp[2][j1][m];
Kdamp(i+1,j) += -dvol[m]*shp[1][i1][m]*shp[2][j1][m];
}
Kdamp(j,i) = Kdamp(i,j);
Kdamp(j,i+1) = Kdamp(i+1,j);
}
}
// Compute permeability matrix
for (i = 2; i < 12; i += 3) {
int i1 = (i-2) / 3;
for (j = 2; j < 12; j += 3) {
int j1 = (j-2) / 3;
//K(i,j) = - (vol*perm[0]*shpBar[0][i1]*shpBar[0][j1] +
// vol*perm[1]*shpBar[1][i1]*shpBar[1][j1]);
for (m = 0; m < 4; m++) {
Kdamp(i,j) += - dvol[m]*(perm[0]*shp[0][i1][m]*shp[0][j1][m] +
perm[1]*shp[1][i1][m]*shp[1][j1][m]);
}
}
}
K = Kdamp;
return K;
}
const Matrix&
FourNodeQuadUP::getMass()
{
K.Zero();
int i, j, m, i1, j1;
double Nrho;
// Determine Jacobian for this integration point
this->shapeFunction();
// Compute an ad hoc lumped mass matrix
/*for (i = 0; i < 4; i++) {
// average material density
tmp = mixtureRho(i);
for (int alpha = 0, ia = 0; alpha < 4; alpha++, ia += 3) {
Nrho = shp[2][alpha][i]*dvol[i]*tmp;
K(ia,ia) += Nrho;
K(ia+1,ia+1) += Nrho;
}
}*/
// Compute consistent mass matrix
for (i = 0, i1 = 0; i < 12; i += 3, i1++) {
for (j = 0, j1 = 0; j < 12; j += 3, j1++) {
for (m = 0; m < 4; m++) {
Nrho = dvol[m]*mixtureRho(m)*shp[2][i1][m]*shp[2][j1][m];
K(i,j) += Nrho;
K(i+1,j+1) += Nrho;
}
}
}
// Compute compressibility matrix
double vol = dvol[0] + dvol[1] + dvol[2] + dvol[3];
double oneOverKc = 1./kc;
for (i = 2; i < 12; i += 3) {
i1 = (i-2) / 3;
for (j = 2; j < 12; j += 3) {
j1 = (j-2) / 3;
//K(i,j) = -vol*oneOverKc*shpBar[2][i1]*shpBar[2][j1];
for (m = 0; m < 4; m++) {
K(i,j) += -dvol[m]*oneOverKc*shp[2][i1][m]*shp[2][j1][m];
}
}
}
/*for (i = 2; i < 12; i += 3) {
i1 = (i-2) / 3;
K(i,i) = -vol*oneOverKc*shpBar[2][i1];
}*/
return K;
}
void
FourNodeQuadUP::zeroLoad(void)
{
Q.Zero();
applyLoad = 0;
appliedB[0] = 0.0;
appliedB[1] = 0.0;
return;
}
int
FourNodeQuadUP::addLoad(ElementalLoad *theLoad, double loadFactor)
{
// Added option for applying body forces in load pattern: C.McGann, U.Washington
int type;
const Vector &data = theLoad->getData(type, loadFactor);
if (type == LOAD_TAG_SelfWeight) {
applyLoad = 1;
appliedB[0] += loadFactor*data(0)*b[0];
appliedB[1] += loadFactor*data(1)*b[1];
return 0;
} else {
opserr << "FourNodeQuadUP::addLoad - load type unknown for ele with tag: " << this->getTag() << endln;
return -1;
}
return -1;
}
int
FourNodeQuadUP::addInertiaLoadToUnbalance(const Vector &accel)
{
// accel = uDotDotG (see EarthquakePattern.cpp)
// Get R * accel from the nodes
const Vector &Raccel1 = nd1Ptr->getRV(accel);
const Vector &Raccel2 = nd2Ptr->getRV(accel);
const Vector &Raccel3 = nd3Ptr->getRV(accel);
const Vector &Raccel4 = nd4Ptr->getRV(accel);
if (3 != Raccel1.Size() || 3 != Raccel2.Size() || 3 != Raccel3.Size() ||
3 != Raccel4.Size()) {
opserr << "FourNodeQuadUP::addInertiaLoadToUnbalance matrix and vector sizes are incompatible\n";
return -1;
}
double ra[12];
ra[0] = Raccel1(0);
ra[1] = Raccel1(1);
ra[2] = 0.;
ra[3] = Raccel2(0);
ra[4] = Raccel2(1);
ra[5] = 0.;
ra[6] = Raccel3(0);
ra[7] = Raccel3(1);
ra[8] = 0.;
ra[9] = Raccel4(0);
ra[10] = Raccel4(1);
ra[11] = 0.;
// Compute mass matrix
this->getMass();
// Want to add ( - fact * M R * accel ) to unbalance
int i, j;
for (i = 0; i < 12; i++) {
for (j = 0; j < 12; j++)
Q(i) += -K(i,j)*ra[j];
}
return 0;
}
const Vector&
FourNodeQuadUP::getResistingForce()
{
P.Zero();
// Determine Jacobian for this integration point
this->shapeFunction();
double vol = dvol[0] + dvol[1] + dvol[2] + dvol[3];
int i;
// Loop over the integration points
for (i = 0; i < 4; i++) {
// Get material stress response
const Vector &sigma = theMaterial[i]->getStress();
// Perform numerical integration on internal force
//P = P + (B^ sigma) * intWt(i)*intWt(j) * detJ;
//P.addMatrixTransposeVector(1.0, B, sigma, intWt(i)*intWt(j)*detJ);
for (int alpha = 0, ia = 0; alpha < 4; alpha++, ia += 3) {
P(ia) += dvol[i]*(shp[0][alpha][i]*sigma(0) + shp[1][alpha][i]*sigma(2));
P(ia+1) += dvol[i]*(shp[1][alpha][i]*sigma(1) + shp[0][alpha][i]*sigma(2));
// Subtract equiv. body forces from the nodes
//P = P - (N^ b) * intWt(i)*intWt(j) * detJ;
//P.addMatrixTransposeVector(1.0, N, b, -intWt(i)*intWt(j)*detJ);
double r = mixtureRho(i);
if (applyLoad == 0) {
P(ia) -= dvol[i]*(shp[2][alpha][i]*r*b[0]);
P(ia+1) -= dvol[i]*(shp[2][alpha][i]*r*b[1]);
} else {
P(ia) -= dvol[i]*(shp[2][alpha][i]*r*appliedB[0]);
P(ia+1) -= dvol[i]*(shp[2][alpha][i]*r*appliedB[1]);
}
}
}
// Subtract fluid body force
for (int alpha = 0, ia = 0; alpha < 4; alpha++, ia += 3) {
//P(ia+2) += vol*rho*(perm[0]*b[0]*shpBar[0][alpha]
// +perm[1]*b[1]*shpBar[1][alpha]);
for (i = 0; i < 4; i++) {
if (applyLoad == 0) {
P(ia+2) += dvol[i]*rho*(perm[0]*b[0]*shp[0][alpha][i] +
perm[1]*b[1]*shp[1][alpha][i]);
} else {
P(ia+2) += dvol[i]*rho*(perm[0]*appliedB[0]*shp[0][alpha][i] +
perm[1]*appliedB[1]*shp[1][alpha][i]);
}
}
}
// Subtract pressure loading from resisting force
if (pressure != 0.0) {
//P = P + pressureLoad;
P.addVector(1.0, pressureLoad, -1.0);
}
// Subtract other external nodal loads ... P_res = P_int - P_ext
//P = P - Q;
P.addVector(1.0, Q, -1.0);
return P;
}
const Vector&
FourNodeQuadUP::getResistingForceIncInertia()
{
int i, j, k;
const Vector &accel1 = nd1Ptr->getTrialAccel();
const Vector &accel2 = nd2Ptr->getTrialAccel();
const Vector &accel3 = nd3Ptr->getTrialAccel();
const Vector &accel4 = nd4Ptr->getTrialAccel();
static double a[12];
a[0] = accel1(0);
a[1] = accel1(1);
a[2] = accel1(2);
a[3] = accel2(0);
a[4] = accel2(1);
a[5] = accel2(2);
a[6] = accel3(0);
a[7] = accel3(1);
a[8] = accel3(2);
a[9] = accel4(0);
a[10] = accel4(1);
a[11] = accel4(2);
// Compute the current resisting force
this->getResistingForce();
//opserr<<"K "<<P<<endln;
// Compute the mass matrix
this->getMass();
for (i = 0; i < 12; i++) {
for (j = 0; j < 12; j++)
P(i) += K(i,j)*a[j];
}
//opserr<<"K+M "<<P<<endln;
// dynamic seepage force
/*for (i = 0, k = 0; i < 4; i++, k += 3) {
// loop over integration points
for (j = 0; j < 4; j++) {
P(i+2) -= rho*dvol[j]*(shp[2][i][j]*a[k]*perm[0]*shp[0][i][j]
+shp[2][i][j]*a[k+1]*perm[1]*shp[1][i][j]);
}
}*/
//opserr<<"K+M+fb "<<P<<endln;
const Vector &vel1 = nd1Ptr->getTrialVel();
const Vector &vel2 = nd2Ptr->getTrialVel();
const Vector &vel3 = nd3Ptr->getTrialVel();
const Vector &vel4 = nd4Ptr->getTrialVel();
a[0] = vel1(0);
a[1] = vel1(1);
a[2] = vel1(2);
a[3] = vel2(0);
a[4] = vel2(1);
a[5] = vel2(2);
a[6] = vel3(0);
a[7] = vel3(1);
a[8] = vel3(2);
a[9] = vel4(0);
a[10] = vel4(1);
a[11] = vel4(2);
this->getDamp();
for (i = 0; i < 12; i++) {
for (j = 0; j < 12; j++) {
P(i) += K(i,j)*a[j];
}
}
//opserr<<"final "<<P<<endln;
return P;
}
int
FourNodeQuadUP::sendSelf(int commitTag, Channel &theChannel)
{
int res = 0;
// note: we don't check for dataTag == 0 for Element
// objects as that is taken care of in a commit by the Domain
// object - don't want to have to do the check if sending data
int dataTag = this->getDbTag();
// Quad packs its data into a Vector and sends this to theChannel
// along with its dbTag and the commitTag passed in the arguments
static Vector data(13);
data(0) = this->getTag();
data(1) = thickness;
data(2) = rho;
data(3) = b[0];
data(4) = b[1];
data(5) = pressure;
data(6) = alphaM;
data(7) = betaK;
data(8) = betaK0;
data(9) = betaKc;
data(10) = kc;
data(11) = perm[0];
data(12) = perm[1];
res += theChannel.sendVector(dataTag, commitTag, data);
if (res < 0) {
opserr << "WARNING FourNodeQuadUP::sendSelf() - " << this->getTag() << " failed to send Vector\n";
return res;
}
// Now quad sends the ids of its materials
int matDbTag;
static ID idData(12);
int i;
for (i = 0; i < 4; i++) {
idData(i) = theMaterial[i]->getClassTag();
matDbTag = theMaterial[i]->getDbTag();
// NOTE: we do have to ensure that the material has a database
// tag if we are sending to a database channel.
if (matDbTag == 0) {
matDbTag = theChannel.getDbTag();
if (matDbTag != 0)
theMaterial[i]->setDbTag(matDbTag);
}
idData(i+4) = matDbTag;
}
idData(8) = connectedExternalNodes(0);
idData(9) = connectedExternalNodes(1);
idData(10) = connectedExternalNodes(2);
idData(11) = connectedExternalNodes(3);
res += theChannel.sendID(dataTag, commitTag, idData);
if (res < 0) {
opserr << "WARNING FourNodeQuadUP::sendSelf() - " << this->getTag() << " failed to send ID\n";
return res;
}
// Finally, quad asks its material objects to send themselves
for (i = 0; i < 4; i++) {
res += theMaterial[i]->sendSelf(commitTag, theChannel);
if (res < 0) {
opserr << "WARNING FourNodeQuadUP::sendSelf() - " << this->getTag() << " failed to send its Material\n";
return res;
}
}
return res;
}
int
FourNodeQuadUP::recvSelf(int commitTag, Channel &theChannel,
FEM_ObjectBroker &theBroker)
{
int res = 0;
int dataTag = this->getDbTag();
// Quad creates a Vector, receives the Vector and then sets the
// internal data with the data in the Vector
static Vector data(13);
res += theChannel.recvVector(dataTag, commitTag, data);
if (res < 0) {
opserr << "WARNING FourNodeQuadUP::recvSelf() - failed to receive Vector\n";
return res;
}
this->setTag((int)data(0));
thickness = data(1);
rho = data(2);
b[0] = data(3);
b[1] = data(4);
pressure = data(5);
alphaM = data(6);
betaK = data(7);
betaK0 = data(8);
betaKc = data(9);
kc = data(10);
perm[0] = data(11);
perm[1] = data(12);
static ID idData(12);
// Quad now receives the tags of its four external nodes
res += theChannel.recvID(dataTag, commitTag, idData);
if (res < 0) {
opserr << "WARNING FourNodeQuadUP::recvSelf() - " << this->getTag() << " failed to receive ID\n";
return res;
}
connectedExternalNodes(0) = idData(8);
connectedExternalNodes(1) = idData(9);
connectedExternalNodes(2) = idData(10);
connectedExternalNodes(3) = idData(11);
if (theMaterial == 0) {
// Allocate new materials
theMaterial = new NDMaterial *[4];
if (theMaterial == 0) {
opserr << "FourNodeQuadUP::recvSelf() - Could not allocate NDMaterial* array\n";
return -1;
}
for (int i = 0; i < 4; i++) {
int matClassTag = idData(i);
int matDbTag = idData(i+4);
// Allocate new material with the sent class tag
theMaterial[i] = theBroker.getNewNDMaterial(matClassTag);
if (theMaterial[i] == 0) {
opserr << "FourNodeQuadUP::recvSelf() - Broker could not create NDMaterial of class type " << matClassTag << endln;