MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / integrate

Method integrate

SRC/domain/pattern/TrapezoidalTimeSeriesIntegrator.cpp:59–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59TimeSeries*
60TrapezoidalTimeSeriesIntegrator::integrate(TimeSeries *theSeries, double delta)
61{
62 // Check for zero time step, before dividing to get number of steps
63 if (delta <= 0.0) {
64 opserr << "TrapezoidalTimeSeriesIntegrator::integrate() Attempting to integrate usiing time step" <<
65 delta << "<= 0\n";
66 return 0;
67 }
68
69 // check a TimeSeries object was passed
70 if (theSeries == 0) {
71 opserr << "TrapezoidalTimeSeriesIntegrator::integrate() - - no TimeSeries passed\n";
72 return 0;
73 }
74
75 // Add one to get ceiling out of type cast
76 long long numSteps = (long long)(theSeries->getDuration() / delta + 1.0);
77
78 Vector *theInt = new Vector (numSteps);
79
80 // Check that the Vector was allocated properly
81 if (theInt == 0 || theInt->Size() == 0) {
82 opserr << "TrapezoidalTimeSeriesIntegrator::integrate() Ran out of memory allocating Vector " << endln;
83
84
85 if (theInt != 0)
86 delete theInt;
87
88 return 0;
89 }
90
91 double dummyTime; // Dummy variable for integrating
92 double fi, fj; //function values
93 double F; //intergral value
94
95 dummyTime = theSeries->getStartTime();
96
97 F = 0.0;
98
99 fi = 0.0;
100
101 for (long long i = 0; i < numSteps; i++, dummyTime += delta) {
102 fj = theSeries->getFactor(dummyTime);
103
104 // Apply the trapezoidal rule to update the integral
105 F = F + 0.5 * delta * (fi + fj);
106
107 (*theInt)[i] = F;
108
109 fi = fj;
110 }
111
112 // Set the method return value
113 PathSeries *returnSeries = new PathSeries (0, *theInt, delta, 1.0, true, false, theSeries->getStartTime());
114 delete theInt;
115
116 if (returnSeries == 0) {

Callers

nothing calls this directly

Calls 4

getDurationMethod · 0.45
SizeMethod · 0.45
getStartTimeMethod · 0.45
getFactorMethod · 0.45

Tested by

no test coverage detected