13 #ifndef __TIMEFORCESCALE_HPP__
14 #define __TIMEFORCESCALE_HPP__
26 bool error_if_file_not_given =
false)
31 CHKERRABORT(PETSC_COMM_WORLD,
ierr);
38 char time_file_name[255];
40 time_file_name, 255, &
fLg);
44 "*** ERROR %s (time_data FILE NEEDED)",
nAme.c_str());
48 "The %s file not provided. Loading scaled with time.",
52 FILE *time_data = fopen(time_file_name,
"r");
53 if (time_data == NULL) {
55 "*** ERROR data file < %s > open unsuccessful", time_file_name);
57 double no1 = 0.0, no2 = 0.0;
59 while (!feof(time_data)) {
60 int n = fscanf(time_data,
"%lf %lf", &no1, &no2);
61 if ((
n <= 0) || ((no1 == 0) && (no2 == 0))) {
67 "*** ERROR read data file error (check input time data file) "
73 int r = fclose(time_data);
75 std::map<double, double>::iterator tit =
tSeries.begin();
76 for (; tit !=
tSeries.end(); tit++) {
77 PetscPrintf(PETSC_COMM_WORLD,
"** read time series %3.2e time %3.2e\n",
78 tit->first, tit->second);
83 "*** ERROR file close unsuccessful");
96 SETERRQ(PETSC_COMM_SELF, 1,
"data file not read");
99 double t0 = 0, t1, s0 =
tSeries[0], s1,
dt;
100 std::map<double, double>::iterator tit =
tSeries.begin();
101 for (; tit !=
tSeries.end(); tit++) {
102 if (tit->first > ts_t) {
106 scale = s0 + ((s1 - s0) / (t1 - t0)) *
dt;
126 const double ts_t = fe->ts_t;
143 CHKERRABORT(PETSC_COMM_WORLD,
ierr);
148 char time_file_name[255];
149 PetscBool flg = PETSC_TRUE;
151 time_file_name, 255, &flg);
153 if (flg != PETSC_TRUE) {
155 "*** ERROR %s (time_data FILE NEEDED)",
nAme.c_str());
157 FILE *time_data = fopen(time_file_name,
"r");
158 if (time_data == NULL) {
160 "*** ERROR data file < %s > open unsuccessful", time_file_name);
165 while (!feof(time_data)) {
167 fscanf(time_data,
"%lf %lf %lf %lf", &no1, &no2[0], &no2[1], &no2[2]);
174 "*** ERROR read data file error (check input time data file) "
180 int r = fclose(time_data);
182 std::map<double, VectorDouble>::iterator tit =
tSeries.begin();
183 for (; tit !=
tSeries.end(); tit++) {
184 PetscPrintf(PETSC_COMM_WORLD,
185 "** read accelerogram %3.2e time %3.2e %3.2e %3.2e\n",
186 tit->first, tit->second[0], tit->second[1], tit->second[2]);
190 SETERRQ(PETSC_COMM_SELF, 1,
"*** ERROR file close unsuccessful");
201 double ts_t = fe->ts_t;
204 double t0 = 0, t1,
dt;
205 std::map<double, VectorDouble>::iterator tit =
tSeries.begin();
206 for (; tit !=
tSeries.end(); tit++) {
207 if (tit->first > ts_t) {
211 acc = acc0 + ((acc1 - acc0) / (t1 - t0)) *
dt;
223 #endif // __TIMEFORCESCALE_HPP__