-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathOpenSeesPatternCommands.cpp
1141 lines (957 loc) · 32.1 KB
/
OpenSeesPatternCommands.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
/* *****************************************************************************
Copyright (c) 2015-2017, The Regents of the University of California (Regents).
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS
PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*************************************************************************** */
// Written: Minjie
// Description: command to create pattern
#include <elementAPI.h>
#include <Domain.h>
#include <NodalLoad.h>
#include <Beam2dPartialUniformLoad.h>
#include <Beam2dUniformLoad.h>
#include <Beam3dUniformLoad.h>
#include <Beam2dPointLoad.h>
#include <Beam3dPointLoad.h>
#include <BrickSelfWeight.h>
#include <SurfaceLoader.h>
#include <SelfWeight.h>
#include <Beam2dThermalAction.h>
#include <Beam2dTempLoad.h>
#include <SP_Constraint.h>
#include <LoadPattern.h>
#include <MultiSupportPattern.h>
#include <UniformExcitation.h>
#include <ImposedMotionSP.h>
#include <ImposedMotionSP1.h>
#include <TimeSeriesIntegrator.h>
#include <TimeSeries.h>
#include <GroundMotion.h>
#include <vector>
#include <InterpolatedGroundMotion.h>
void* OPS_LoadPattern();
void* OPS_UniformExcitationPattern();
void* OPS_MultiSupportPattern();
void* OPS_TimeSeriesIntegrator();
namespace {
static LoadPattern* theActiveLoadPattern = 0;
static UniformExcitation* theActiveUniformPattern = 0;
static MultiSupportPattern* theActiveMultiSupportPattern = 0;
static int eleLoadTag = 0;
}
int OPS_Pattern()
{
theActiveMultiSupportPattern = 0;
theActiveUniformPattern = 0;
theActiveLoadPattern = 0;
// num args
if(OPS_GetNumRemainingInputArgs() < 1) {
opserr<<"WARNING insufficient args: pattern type ...\n";
return -1;
}
// create pattern
const char* type = OPS_GetString();
LoadPattern* pattern = 0;
if (strcmp(type, "Plain") == 0) {
theActiveLoadPattern = (LoadPattern*)OPS_LoadPattern();
pattern = theActiveLoadPattern;
} else if (strcmp(type, "UniformExcitation") == 0) {
theActiveUniformPattern = (UniformExcitation*)OPS_UniformExcitationPattern();
pattern = theActiveUniformPattern;
} else if (strcmp(type, "MultiSupportPattern") == 0) {
theActiveMultiSupportPattern = (MultiSupportPattern*)OPS_MultiSupportPattern();
pattern = theActiveMultiSupportPattern;
} else {
opserr<<"WARNING unknown pattern type"<<type<<"\n";
return -1;
}
if (pattern == 0) {
opserr<<"WARNING failed to create pattern\n";
return -1;
}
// add to domain
Domain* theDomain = OPS_GetDomain();
if (theDomain == 0) {
opserr<<"WARNING no domain is created\n";
return -1;
}
if (theDomain->addLoadPattern(pattern) == false) {
opserr<<"WARNING failed to add pattern to domain\n";
delete pattern;
pattern = 0;
return -1;
}
return 0;
}
int OPS_NodalLoad()
{
Domain* theDomain = OPS_GetDomain();
if(theDomain == 0) {
opserr<<"WARNING: domain is not defined\n";
return -1;
}
int ndf = OPS_GetNumRemainingInputArgs()-1;
if(ndf < 1) {
opserr<<"insufficient number of args\n";
return -1;
}
// get node tag
int ndtag;
int numData = 1;
if(OPS_GetIntInput(&numData, &ndtag) < 0) {
opserr << "WARNING invalid node tag\n";
return -1;
}
// get load vector
Vector forces(ndf);
if(OPS_GetDoubleInput(&ndf, &forces(0)) < 0) {
opserr << "WARNING invalid load vector\n";
return -1;
}
// get options
bool isLoadConst = false;
bool userPattern = false;
int loadPatternTag = 0;
while(OPS_GetNumRemainingInputArgs() > 0) {
const char* type = OPS_GetString();
if(strcmp(type,"-const") == 0) {
isLoadConst = true;
} else if(strcmp(type,"-pattern") == 0) {
int numData = 1;
if(OPS_GetIntInput(&numData, &loadPatternTag) < 0) {
return -1;
}
userPattern = true;
}
}
// get the current pattern tag
LoadPattern* currPattern = theActiveLoadPattern;
if(userPattern == false) {
if(currPattern==0) {
opserr<<"WARNING: no current load pattern is set\n";
return -1;
}
loadPatternTag = currPattern->getTag();
}
// create the load
static int nodeLoadTag = 0;
NodalLoad* theLoad = new NodalLoad(nodeLoadTag++, ndtag, forces, isLoadConst);
if(theLoad == 0) return -1;
// add load to domain
if(theDomain->addNodalLoad(theLoad,loadPatternTag) == false) {
opserr<<"WARNING: failed to add nodal load to domain\n";
delete theLoad;
return -1;
}
return 0;
}
int OPS_ElementalLoad()
{
if (theActiveLoadPattern == 0) {
opserr << "WARNING no active load pattern - eleLoad\n";
return -1;
}
Domain* theDomain = OPS_GetDomain();
if (theDomain == 0) return -1;
int ndm = OPS_GetNDM();
ElementalLoad* theLoad = 0;
// look for -type, -ele, -range
int locType = -1;
int locEle = -1;
int locRange = -1;
int currentLoc = 1;
while (OPS_GetNumRemainingInputArgs() > 0) {
const char* opt = OPS_GetString();
if (strcmp(opt, "-type") == 0) {
locType = currentLoc;
} else if (strcmp(opt, "-ele") == 0) {
locEle = currentLoc;
} else if (strcmp(opt, "-range") == 0) {
locRange = currentLoc;
}
currentLoc++;
}
if (locType < 0) {
opserr << "WARNING eleLoad - no -type option\n";
return -1;
}
// we first create an ID containing the ele tags of all elements
// for which the load applies.
ID theEleTags(0,16);
if (locEle > 0) {
OPS_ResetCurrentInputArg(locEle+1);
while(OPS_GetNumRemainingInputArgs() > 0) {
int tag;
int numdata = 1;
if (OPS_GetIntInput(&numdata, &tag) < 0) {
break;
}
theEleTags.insert(tag);
}
}
if (locRange > 0) {
OPS_ResetCurrentInputArg(locRange+1);
if (OPS_GetNumRemainingInputArgs() > 1) {
int tags[2];
int numdata = 2;
if (OPS_GetIntInput(&numdata, tags) < 0) {
opserr<<"WARNING failed to read tag range\n";
return -1;
}
for (int tag=tags[0]; tag<=tags[1]; tag++) {
theEleTags.insert(tag);
}
}
}
// we then create the load
OPS_ResetCurrentInputArg(locType+1);
if (OPS_GetNumRemainingInputArgs() < 1) {
opserr<<"WARNING no load type is given\n";
return -1;
}
const char* type = OPS_GetString();
if (strcmp(type,"-beamUniform") == 0 ||
strcmp(type,"beamUniform") == 0) {
if (ndm == 2) {
// wt, wa, aL, bL
double data[4] = {0.0, 0.0, 0.0, 1.0};
int numdata = OPS_GetNumRemainingInputArgs();
if (numdata < 1) {
opserr<<"WARNING eleLoad - beamUniform want Wy <Wx>\n";
return -1;
}
if (numdata > 4) numdata = 4;
if (OPS_GetDoubleInput(&numdata, data) < 0) {
opserr<<"WARNING eleLoad - invalid value for beamUniform\n";
return -1;
}
for (int i=0; i<theEleTags.Size(); i++) {
if (data[2] > 0.0 || data[3] < 1.0)
theLoad = new Beam2dPartialUniformLoad(eleLoadTag, data[0], data[1], data[2], data[3], theEleTags(i));
else
theLoad = new Beam2dUniformLoad(eleLoadTag, data[0], data[1], theEleTags(i));
if (theLoad == 0) {
opserr << "WARNING eleLoad - out of memory creating load of type " << type;
return -1;
}
// get the current pattern tag if no tag given in i/p
int loadPatternTag = theActiveLoadPattern->getTag();
// add the load to the domain
if (theDomain->addElementalLoad(theLoad, loadPatternTag) == false) {
opserr << "WARNING eleLoad - could not add following load to domain:\n ";
opserr << theLoad;
delete theLoad;
return -1;
}
eleLoadTag++;
}
return 0;
}
else if (ndm == 3) {
// wy, wz, wx
double data[3] = {0.0, 0.0, 0.0};
int numdata = OPS_GetNumRemainingInputArgs();
if (numdata < 2) {
opserr<<"WARNING eleLoad - beamUniform want Wy Wz <Wx>\n";
return -1;
}
if (numdata > 3) numdata = 3;
if (OPS_GetDoubleInput(&numdata, data) < 0) {
opserr<<"WARNING eleLoad - invalid value for beamUniform\n";
return -1;
}
for (int i=0; i<theEleTags.Size(); i++) {
theLoad = new Beam3dUniformLoad(eleLoadTag, data[0], data[1], data[2], theEleTags(i));
if (theLoad == 0) {
opserr << "WARNING eleLoad - out of memory creating load of type " << type;
return -1;
}
// get the current pattern tag if no tag given in i/p
int loadPatternTag = theActiveLoadPattern->getTag();
// add the load to the domain
if (theDomain->addElementalLoad(theLoad, loadPatternTag) == false) {
opserr << "WARNING eleLoad - could not add following load to domain:\n ";
opserr << theLoad;
delete theLoad;
return -1;
}
eleLoadTag++;
}
return 0;
}
else {
opserr << "WARNING eleLoad beamUniform currently only valid only for ndm=2 or 3\n";
return -1;
}
} else if (strcmp(type,"-beamPoint") == 0 ||
strcmp(type,"beamPoint") == 0 ) {
if (ndm == 2) {
// P, x, N
double data[3] = {0.0, 0.0, 0.0};
int numdata = OPS_GetNumRemainingInputArgs();
if (numdata < 2) {
opserr<<"WARNING eleLoad - beamPoint want Py xL <Px>\n";
return -1;
}
if (numdata > 3) numdata = 3;
if (OPS_GetDoubleInput(&numdata, data) < 0) {
opserr<<"WARNING eleLoad - invalid value for beamPoint\n";
return -1;
}
if (data[1] < 0.0 || data[1] > 1.0) {
opserr << "WARNING eleLoad - invalid xDivL of " << data[1];
opserr << " for beamPoint (valid range [0.0, 1.0]\n";
return -1;
}
for (int i=0; i<theEleTags.Size(); i++) {
theLoad = new Beam2dPointLoad(eleLoadTag, data[0], data[1],
theEleTags(i), data[2]);
if (theLoad == 0) {
opserr << "WARNING eleLoad - out of memory creating load of type " << type;
return -1;
}
// get the current pattern tag if no tag given in i/p
int loadPatternTag = theActiveLoadPattern->getTag();
// add the load to the domain
if (theDomain->addElementalLoad(theLoad, loadPatternTag) == false) {
opserr << "WARNING eleLoad - could not add following load to domain:\n ";
opserr << theLoad;
delete theLoad;
return -1;
}
eleLoadTag++;
}
return 0;
}
else if (ndm == 3) {
// Py, Pz, x, N
double data[4] = {0.0, 0.0, 0.0, 1.0};
int numdata = OPS_GetNumRemainingInputArgs();
if (numdata < 3) {
opserr<<"WARNING eleLoad - beamPoint want Py Pz xL <Px>\n";
return -1;
}
if (numdata > 4) numdata = 4;
if (OPS_GetDoubleInput(&numdata, data) < 0) {
opserr<<"WARNING eleLoad - invalid value for beamPoint\n";
return -1;
}
if (data[2] < 0.0 || data[2] > 1.0) {
opserr << "WARNING eleLoad - invalid xDivL of " << data[2];
opserr << " for beamPoint (valid range [0.0, 1.0]\n";
return -1;
}
for (int i=0; i<theEleTags.Size(); i++) {
theLoad = new Beam3dPointLoad(eleLoadTag, data[0], data[1], data[2], theEleTags(i), data[3]);
if (theLoad == 0) {
opserr << "WARNING eleLoad - out of memory creating load of type " << type;
return -1;
}
// get the current pattern tag if no tag given in i/p
int loadPatternTag = theActiveLoadPattern->getTag();
// add the load to the domain
if (theDomain->addElementalLoad(theLoad, loadPatternTag) == false) {
opserr << "WARNING eleLoad - could not add following load to domain:\n ";
opserr << theLoad;
delete theLoad;
return -1;
}
eleLoadTag++;
}
return 0;
}
else {
opserr << "WARNING eleLoad beamPoint type currently only valid only for ndm=2 or 3\n";
return -1;
}
}
// Added Joey Yang UC Davis
else if (strcmp(type,"-BrickW") == 0) {
for (int i=0; i<theEleTags.Size(); i++) {
theLoad = new BrickSelfWeight(eleLoadTag, theEleTags(i));
if (theLoad == 0) {
opserr << "WARNING eleLoad - out of memory creating load of type " << type;
return -1;
}
// get the current pattern tag if no tag given in i/p
int loadPatternTag = theActiveLoadPattern->getTag();
// add the load to the domain
if (theDomain->addElementalLoad(theLoad, loadPatternTag) == false) {
opserr << "WARNING eleLoad - could not add following load to domain:\n ";
opserr << theLoad;
delete theLoad;
return -1;
}
eleLoadTag++;
}
return 0;
}
// Added: C.McGann, U.Washington
else if (strcmp(type,"-surfaceLoad") == 0 || strcmp(type,"-SurfaceLoad") == 0) {
for (int i=0; i<theEleTags.Size(); i++) {
theLoad = new SurfaceLoader(eleLoadTag, theEleTags(i));
if (theLoad == 0) {
opserr << "WARNING eleLoad - out of memory creating load of type " << type;
return -1;
}
// get the current pattern tag if no tag given in i/p
int loadPatternTag = theActiveLoadPattern->getTag();
// add the load to the domain
if (theDomain->addElementalLoad(theLoad, loadPatternTag) == false) {
opserr << "WARNING eleLoad - could not add following load to domain:\n ";
opserr << theLoad;
delete theLoad;
return -1;
}
eleLoadTag++;
}
return 0;
}
// Added: C.McGann, U.Washington
else if ((strcmp(type,"-selfWeight") == 0) || (strcmp(type,"-SelfWeight") == 0)) {
// xf, yf, zf
double data[3] = {0.0, 0.0, 0.0};
int numdata = OPS_GetNumRemainingInputArgs();
if (numdata < 2) {
opserr<<"WARNING eleLoad - selfWeight want xf, yf, <zf>\n";
return -1;
}
if (numdata > 3) numdata = 3;
if (OPS_GetDoubleInput(&numdata, data) < 0) {
opserr<<"WARNING eleLoad - invalid value for SelfWeight\n";
return -1;
}
for (int i=0; i<theEleTags.Size(); i++) {
theLoad = new SelfWeight(eleLoadTag, data[0], data[1], data[2], theEleTags(i));
if (theLoad == 0) {
opserr << "WARNING eleLoad - out of memory creating load of type " << type;
return -1;
}
// get the current pattern tag if no tag given in i/p
int loadPatternTag = theActiveLoadPattern->getTag();
// add the load to the domain
if (theDomain->addElementalLoad(theLoad, loadPatternTag) == false) {
opserr << "WARNING eleLoad - could not add following load to domain:\n ";
opserr << theLoad;
delete theLoad;
return -1;
}
eleLoadTag++;
}
return 0;
}
//--Adding identifier for Beam2dThermalAction:[BEGIN] by UoE OpenSees Group--//
else if (strcmp(type,"-beamThermal") == 0) {
// get the current pattern tag if no tag given in i/p
int loadPatternTag = theActiveLoadPattern->getTag();
if (ndm == 2) {
//so far three kinds of temperature distribution
//(1) 9 temperature points, i.e. 8 layers
//(2) 5 temperature points, i.e. 4 layers
//(3) 2 temperature points, i.e. 1 layers: linear or uniform
//double t1, locY1, t2, locY2, t3, locY3, t4, locY4, t5, locY5,
// t6, locY6, t7, locY7, t8, locY8, t9, locY9;
// 9 temperature points are given,i.e. 8 layers are defined; Also the 9 corresponding vertical coordinate is given.
// the temperature at each fiber is obtained by interpolating of temperatures at the nearby temperature points.
int numdata = OPS_GetNumRemainingInputArgs();
double data[18];
double Temp[9]; double Loc[9];
if (numdata == 18) {
if (OPS_GetDoubleInput(&numdata, data) < 0) {
opserr << "WARNING eleLoad - invalid input\n";
return -1;
}
for (int i = 0; i < 9; i++) {
Temp[i] = data[2 * i];
Loc[i] = data[2 * i + 1];
}
}
// 5 temperatures are given, i.e. 4 layers are defined.
else if (numdata == 10){
if (OPS_GetDoubleInput(&numdata, data) < 0) {
opserr << "WARNING eleLoad - invalid input\n";
return -1;
}
Temp[0] = data[0]; Temp[2] = data[2]; Temp[4] = data[4]; Temp[6] = data[6]; Temp[8] = data[8];
Loc[0] = data[1]; Loc[2] = data[3]; Loc[4] = data[5]; Loc[6] = data[7]; Loc[8] = data[9];
for (int i = 1; i < 5; i++) {
Temp[2 * i - 1] = (Temp[2 * i - 2] + Temp[2 * i]) / 2;
Loc[2 * i - 1] = (Loc[2 * i - 2] + Loc[2 * i]) / 2;
}
}
// two temperature is given,
//if the two temperatures are equal,i.e. uniform Temperature change in element
//if the two temperatures are different,i.e. linear Temperature change in element
else if (numdata == 4){
if (OPS_GetDoubleInput(&numdata, data) < 0) {
opserr << "WARNING eleLoad - invalid input\n";
return -1;
}
Temp[0] = data[0]; Temp[8] = data[2];
Loc[0] = data[1]; Loc[8] = data[3];
for (int i = 1; i < 8; i++) {
Temp[i] = Temp[0] - i*(Temp[0] - Temp[8]) / 8;
Loc[i] = Loc[0] - i*(Loc[0] - Loc[8]) / 8;
}
}
//finish the temperature arguments
else {
opserr << "WARNING eleLoad -beamThermalAction invalid number of temperature aguments,/n looking for 0, 2, 5 or 9 arguments.\n";
}
for (int i = 0; i<theEleTags.Size(); i++) {
theLoad = new Beam2dThermalAction(eleLoadTag,
Temp[0], Loc[0], Temp[1], Loc[1],
Temp[2], Loc[2], Temp[3], Loc[3],
Temp[4], Loc[4], Temp[5], Loc[5],
Temp[6], Loc[6], Temp[7], Loc[7],
Temp[8], Loc[8], theEleTags(i));
if (theLoad == 0) {
opserr << "WARNING eleLoad - out of memory creating load of type " << type;
return -1;
}
// add the load to the domain
if (theDomain->addElementalLoad(theLoad, loadPatternTag) == false) {
opserr << "WARNING eleLoad - could not add following load to domain:\n ";
opserr << theLoad;
delete theLoad;
return -1;
}
eleLoadTag++;
}
} // for the if (ndm==2)
else {//if (ndm=3)
opserr << "WARNING eleLoad -beamThermalAction type currently only valid only for ndm=2\n";
return -1;
}
}
//--Adding identifier for Beam2dThermalAction:[END] by UoE OpenSees Group--//
// Added by Scott R. Hamilton - Stanford
else if (strcmp(type,"-beamTemp") == 0) {
if (ndm == 2) {
int numdata = OPS_GetNumRemainingInputArgs();
double data[4];
// double temp1, temp2, temp3, temp4;
// Four temps given, Temp change at top node 1, bottom node 1, top node 2, bottom node 2.
if (numdata == 4){
if (OPS_GetDoubleInput(&numdata, data) < 0) {
opserr << "WARNING eleLoad - invalid input\n";
return -1;
}
for (int i=0; i<theEleTags.Size(); i++) {
theLoad = new Beam2dTempLoad(eleLoadTag, data[0],
data[1], data[2],
data[3], theEleTags(i));
if (theLoad == 0) {
opserr << "WARNING eleLoad - out of memory creating load of type " << type;
return -1;
}
// get the current pattern tag if no tag given in i/p
int loadPatternTag = theActiveLoadPattern->getTag();
// add the load to the domain
if (theDomain->addElementalLoad(theLoad, loadPatternTag) == false) {
opserr << "WARNING eleLoad - could not add following load to domain:\n ";
opserr << theLoad;
delete theLoad;
return -1;
}
eleLoadTag++;
}
return 0;
}
// Two temps given, temp change at top, temp at bottom of element
else if (numdata == 2) {
if (OPS_GetDoubleInput(&numdata, data) < 0) {
opserr << "WARNING eleLoad - invalid input\n";
return -1;
}
for (int i=0; i<theEleTags.Size(); i++) {
theLoad = new Beam2dTempLoad(eleLoadTag, data[0], data[1], theEleTags(i));
if (theLoad == 0) {
opserr << "WARNING eleLoad - out of memory creating load of type " << type;
return -1;
}
// get the current pattern tag if no tag given in i/p
int loadPatternTag = theActiveLoadPattern->getTag();
// add the load to the domain
if (theDomain->addElementalLoad(theLoad, loadPatternTag) == false) {
opserr << "WARNING eleLoad - could not add following load to domain:\n ";
opserr << theLoad;
delete theLoad;
return -1;
}
eleLoadTag++;
}
}
// One twmp change give, uniform temp change in element
else if (numdata == 1) {
if (OPS_GetDoubleInput(&numdata, data) < 0) {
opserr << "WARNING eleLoad - invalid input\n";
return -1;
}
theLoad=0;
for (int i=0; i<theEleTags.Size(); i++) {
theLoad = new Beam2dTempLoad(eleLoadTag, data[0], theEleTags(i));
if (theLoad == 0) {
opserr << "WARNING eleLoad - out of memory creating load of type " << type;
return -1;
}
// get the current pattern tag if no tag given in i/p
int loadPatternTag = theActiveLoadPattern->getTag();
// add the load to the domain
if (theDomain->addElementalLoad(theLoad, loadPatternTag) == false) {
opserr << "WARNING eleLoad - could not add following load to domain:\n ";
opserr << theLoad;
delete theLoad;
return -1;
}
eleLoadTag++;
}
return 0;
}
else {
opserr << "WARNING eleLoad -beamTempLoad invalid number of temperature aguments,/n looking for 0, 1, 2 or 4 arguments.\n";
return -1;
}
} else {
opserr << "WARNING eleLoad -beamTempLoad type currently only valid only for ndm=2\n";
return -1;
}
}
// if get here we have sucessfully created the load and added it to the domain
return 0;
}
int OPS_SP()
{
Domain* theDomain = OPS_GetDomain();
if(theDomain == 0) {
opserr<<"WARNING: domain is not defined\n";
return -1;
}
if(OPS_GetNumRemainingInputArgs() < 3) {
opserr<<"insufficient number of args\n";
return -1;
}
SP_Constraint *theSP = 0;
// get tags
int tags[2];
int numData = 2;
if(OPS_GetIntInput(&numData, &tags[0]) < 0) {
opserr << "WARNING invalid int tags\n";
return -1;
}
// get node
Node* theNode = theDomain->getNode(tags[0]);
if(theNode == 0) {
opserr<<"ERROR node "<<tags[0]<<"does not exsit\n";
return -1;
}
int ndf = theNode->getNumberDOF();
if(tags[1] > ndf || tags[1] < 0) {
opserr<<"WARNING invalid dof\n";
return -1;
}
// get value
double value;
numData = 1;
if(OPS_GetDoubleInput(&numData,&value) < 0) {
opserr << "WARNING invalid double value\n";
return -1;
}
// get sp const
bool isSpConst = false;
bool userPattern = false;
int loadPatternTag = 0;
while(OPS_GetNumRemainingInputArgs() > 0) {
const char* type = OPS_GetString();
if(strcmp(type, "-const") == 0) {
isSpConst = true;
} else if(strcmp(type, "-pattern") == 0) {
if (OPS_GetNumRemainingInputArgs() > 0) {
int numData = 1;
if(OPS_GetIntInput(&numData, &loadPatternTag) < 0) {
opserr << "WARNING invalid pattern tag\n";
return -1;
}
userPattern = true;
}
}
}
// get the current pattern tag
LoadPattern* currPattern = theActiveLoadPattern;
if(userPattern == false) {
if(currPattern == 0) {
opserr<<"WARNING: no current pattern is set\n";
return -1;
}
loadPatternTag = currPattern->getTag();
}
// create pattern
theSP = new SP_Constraint(tags[0], tags[1]-1, value, isSpConst);
if(theSP == 0) return -1;
// add load to domain
if(theDomain->addSP_Constraint(theSP,loadPatternTag) == false) {
opserr<<"WARNING: failed to add SP_Constraint to domain\n";
delete theSP;
return -1;
}
return 0;
}
int OPS_ImposedMotionSP()
{
// check number of arguments
if (OPS_GetNumRemainingInputArgs() < 3) {
opserr << "WARNING bad command - want: imposedMotion nodeId dofID gMotionID\n";
return -1;
}
// get the nodeID, dofId and value of the constraint
int nodeId, dofId, gMotionID;
int numdata = 1;
if (OPS_GetIntInput(&numdata, &nodeId) < 0) {
opserr << "WARNING invalid nodeId: ";
opserr << " - imposedMotion nodeId dofID gMotionID\n";
return -1;
}
if (OPS_GetIntInput(&numdata, &dofId) < 0) {
opserr << "WARNING invalid dofId: imposedMotion ";
opserr << nodeId << " dofID gMotionID\n";
return -1;
}
dofId--; // DECREMENT THE DOF VALUE BY 1 TO GO TO OUR C++ INDEXING
if (OPS_GetIntInput(&numdata, &gMotionID) < 0) {
opserr << "WARNING invalid gMotionID: - imposedMotion ";
opserr << nodeId << " dofID gMotionID\n";
return -1;
}
bool alt = false;
if (OPS_GetNumRemainingInputArgs() > 0) {
const char* flag = OPS_GetString();
if (strcmp(flag,"-other") == 0) {
alt = true;
}
}
//
// check valid node & dof
//
Domain* theDomain = OPS_GetDomain();
if (theDomain == 0) return -1;
Node *theNode = theDomain->getNode(nodeId);
if (theNode == 0) {
opserr << "WARNING invalid node " << nodeId << " node not found\n ";
return -1;
}
int nDof = theNode->getNumberDOF();
if (dofId < 0 || dofId >= nDof) {
opserr << "WARNING invalid dofId: " << dofId << " dof specified cannot be <= 0 or greater than num dof at nod\n ";
return -2;
}
MultiSupportPattern *thePattern = theActiveMultiSupportPattern;
if (thePattern == 0) {
opserr << "WARNING no active multi support pattern - imposedMotion\n";
return -1;
}
int loadPatternTag = thePattern->getTag();
// create a new ImposedMotionSP
SP_Constraint *theSP;
if (alt == true) {
theSP = new ImposedMotionSP1(nodeId, dofId, loadPatternTag, gMotionID);
}
else {
theSP = new ImposedMotionSP(nodeId, dofId, loadPatternTag, gMotionID);
}
if (theSP == 0) {
opserr << "WARNING ran out of memory for ImposedMotionSP ";
opserr << " - imposedMotion ";
opserr << nodeId << " " << dofId++ << " " << gMotionID << endln;
return -1;
}
if (thePattern->addSP_Constraint(theSP) == false) {
opserr << "WARNING could not add SP_Constraint to pattern ";
delete theSP;
return -1;
}
// if get here we have sucessfully created the node and added it to the domain
return 0;
}
int OPS_groundMotion()
{
GroundMotion *theMotion = 0;
int gMotionTag;
MultiSupportPattern *thePattern = theActiveMultiSupportPattern;
if (thePattern == 0) {
opserr << "WARNING no active multi support pattern - groundMotion\n";
return -1;
}
// make sure at least one other argument to contain integrator
if (OPS_GetNumRemainingInputArgs() < 2) {
opserr << "WARNING invalid command - want: groundMotion tag type <args>\n";
opserr << " valid types: AccelRecord and Interpolated \n";
return -1;
}
int numdata = 1;
if (OPS_GetIntInput(&numdata, &gMotionTag) < 0) {
opserr << "WARNING invalid tag: groundMotion tag type <args>\n";
return -1;
}
const char* type = OPS_GetString();
if ((strcmp(type,"Series") == 0) ||
(strcmp(type,"Plain") == 0)) {
TimeSeries *accelSeries = 0;
TimeSeries *velSeries = 0;
TimeSeries *dispSeries = 0;
TimeSeriesIntegrator *seriesIntegrator = 0;
double dtInt = 0.01;
double fact = 1.0;
while (OPS_GetNumRemainingInputArgs() > 1) {
const char* flag = OPS_GetString();
if ((strcmp(flag,"-accel") == 0) ||
(strcmp(flag,"-acceleration") == 0)) {
int tsTag;
if (OPS_GetIntInput(&numdata, &tsTag) < 0) {
opserr << "WARNING failed to get accel time series tag\n";
return -1;
}
accelSeries = OPS_getTimeSeries(tsTag);
if (accelSeries == 0) {
opserr << "WARNING invalid accel series: " << tsTag;
opserr << " groundMotion tag Series -accel {series}\n";
return -1;
}
} else if ((strcmp(flag,"-vel") == 0) ||
(strcmp(flag,"-velocity") == 0)) {
int tsTag;
if (OPS_GetIntInput(&numdata, &tsTag) < 0) {
opserr << "WARNING failed to get accel time series tag\n";
return -1;