@@ -28,9 +28,16 @@ InputParameters
28
28
BaselineCorrection ::validParams ()
29
29
{
30
30
InputParameters params = Function ::validParams ();
31
- params .addClassDescription ("Applies a baseline correction to an accceleration time history "
32
- "using least squares polynomial fits and outputs the adjusted "
33
- "acceleration with linear interpolation." );
31
+ params .addClassDescription ("Applies a baseline correction to an accceleration time history using "
32
+ "least squares polynomial fits and outputs adjusted values for the "
33
+ "specified kinematic variable." );
34
+
35
+ MooseEnum series_type ("acceleration velocity displacement" , "acceleration" );
36
+ params .addParam < MooseEnum > (
37
+ "series_type" ,
38
+ series_type ,
39
+ "The kineamtic variable whose corrected time history is to be evaluated. The default is "
40
+ "'acceleration'." );
34
41
35
42
params .addParam < FileName > (
36
43
"data_file" , "The name of a CSV file containing raw acceleration time history data." );
@@ -78,6 +85,7 @@ BaselineCorrection::validParams()
78
85
79
86
BaselineCorrection ::BaselineCorrection (const InputParameters & parameters )
80
87
: Function (parameters ),
88
+ _series (getParam < MooseEnum > ("series_type" )),
81
89
_gamma (getParam < Real > ("gamma" )),
82
90
_beta (getParam < Real > ("beta" )),
83
91
_scale_factor (getParam < Real > ("scale_factor" ))
@@ -119,7 +127,7 @@ BaselineCorrection::BaselineCorrection(const InputParameters & parameters)
119
127
// try building a linear interpolation object
120
128
try
121
129
{
122
- _linear_interp = libmesh_make_unique < LinearInterpolation > (_time , _adj_accel );
130
+ _linear_interp = libmesh_make_unique < LinearInterpolation > (_time , _adj_series );
123
131
}
124
132
catch (std ::domain_error & e )
125
133
{
@@ -154,22 +162,22 @@ BaselineCorrection::applyCorrection()
154
162
_accel [i ], _accel [i + 1 ], vel [i ], disp [i ], _beta , dt ));
155
163
}
156
164
157
- // initialize polyfits and adjusted time history arrays as the nominal ones
165
+ // initialize polyfits and adjusted time history arrays with nominal ones
166
+ unsigned int order ;
158
167
DenseVector < Real > coeffs ;
159
- _adj_accel = _accel ;
160
- std ::vector < Real > p_fit , adj_vel = vel , adj_disp = disp ;
168
+ std ::vector < Real > p_fit , adj_accel = _accel , adj_vel = vel , adj_disp = disp ;
161
169
162
170
// adjust time histories with acceleration fit if desired
163
171
if (isParamValid ("accel_fit_order" ))
164
172
{
165
- _order = getParam < unsigned int > ("accel_fit_order" );
173
+ order = getParam < unsigned int > ("accel_fit_order" );
166
174
coeffs = BaselineCorrectionUtils ::getAccelerationFitCoeffs (
167
- _order , _adj_accel , _time , index_end , _gamma );
175
+ order , adj_accel , _time , index_end , _gamma );
168
176
169
177
for (unsigned int i = 0 ; i <= index_end ; ++ i )
170
178
{
171
- p_fit = BaselineCorrectionUtils ::computePolynomials (_order , coeffs , _time [i ]);
172
- _adj_accel [i ] -= p_fit [0 ];
179
+ p_fit = BaselineCorrectionUtils ::computePolynomials (order , coeffs , _time [i ]);
180
+ adj_accel [i ] -= p_fit [0 ];
173
181
adj_vel [i ] -= p_fit [1 ];
174
182
adj_disp [i ] -= p_fit [2 ];
175
183
}
@@ -178,30 +186,42 @@ BaselineCorrection::applyCorrection()
178
186
// adjust with velocity fit
179
187
if (isParamValid ("vel_fit_order" ))
180
188
{
181
- _order = getParam < unsigned int > ("vel_fit_order" );
189
+ order = getParam < unsigned int > ("vel_fit_order" );
182
190
coeffs = BaselineCorrectionUtils ::getVelocityFitCoeffs (
183
- _order , _adj_accel , adj_vel , _time , index_end , _beta );
191
+ order , adj_accel , adj_vel , _time , index_end , _beta );
184
192
185
193
for (unsigned int i = 0 ; i <= index_end ; ++ i )
186
194
{
187
- p_fit = BaselineCorrectionUtils ::computePolynomials (_order , coeffs , _time [i ]);
188
- _adj_accel [i ] -= p_fit [0 ];
195
+ p_fit = BaselineCorrectionUtils ::computePolynomials (order , coeffs , _time [i ]);
196
+ adj_accel [i ] -= p_fit [0 ];
197
+ adj_vel [i ] -= p_fit [1 ];
189
198
adj_disp [i ] -= p_fit [2 ];
190
199
}
191
200
}
192
201
193
202
// adjust with displacement fit
194
203
if (isParamValid ("disp_fit_order" ))
195
204
{
196
- _order = getParam < unsigned int > ("disp_fit_order" );
197
- coeffs = BaselineCorrectionUtils ::getDisplacementFitCoeffs (_order , adj_disp , _time , index_end );
205
+ order = getParam < unsigned int > ("disp_fit_order" );
206
+ coeffs = BaselineCorrectionUtils ::getDisplacementFitCoeffs (order , adj_disp , _time , index_end );
198
207
199
208
for (unsigned int i = 0 ; i <= index_end ; ++ i )
200
209
{
201
- p_fit = BaselineCorrectionUtils ::computePolynomials (_order , coeffs , _time [i ]);
202
- _adj_accel [i ] -= p_fit [0 ];
210
+ p_fit = BaselineCorrectionUtils ::computePolynomials (order , coeffs , _time [i ]);
211
+ adj_accel [i ] -= p_fit [0 ];
212
+ adj_vel [i ] -= p_fit [1 ];
213
+ adj_disp [i ] -= p_fit [2 ];
203
214
}
204
215
}
216
+
217
+ // copy adjusted values for specified time series to a global variable (would it be faster to set
218
+ // _adj_series with a std::map that pairs '_series' with 'adj_accel', etc.? Probably not...)
219
+ if (_series == "acceleration" )
220
+ _adj_series = adj_accel ;
221
+ else if (_series == "velocity" )
222
+ _adj_series = adj_vel ;
223
+ else
224
+ _adj_series = adj_disp ;
205
225
}
206
226
207
227
void
0 commit comments