25 #ifndef __TIMEFORCESCALE_HPP__
26 #define __TIMEFORCESCALE_HPP__
38 bool error_if_file_not_given =
false)
43 CHKERRABORT(PETSC_COMM_WORLD,
ierr);
50 char time_file_name[255];
52 time_file_name, 255, &
fLg);
56 "*** ERROR %s (time_data FILE NEEDED)",
nAme.c_str());
60 "The %s file not provided. Loading scaled with time.",
64 FILE *time_data = fopen(time_file_name,
"r");
65 if (time_data == NULL) {
67 "*** ERROR data file < %s > open unsuccessful", time_file_name);
69 double no1 = 0.0, no2 = 0.0;
71 while (!feof(time_data)) {
72 int n = fscanf(time_data,
"%lf %lf", &no1, &no2);
73 if ((
n <= 0) || ((no1 == 0) && (no2 == 0))) {
79 "*** ERROR read data file error (check input time data file) "
85 int r = fclose(time_data);
87 std::map<double, double>::iterator tit =
tSeries.begin();
88 for (; tit !=
tSeries.end(); tit++) {
89 PetscPrintf(PETSC_COMM_WORLD,
"** read time series %3.2e time %3.2e\n",
90 tit->first, tit->second);
95 "*** ERROR file close unsuccessful");
108 SETERRQ(PETSC_COMM_SELF, 1,
"data file not read");
111 double t0 = 0, t1, s0 =
tSeries[0], s1,
dt;
112 std::map<double, double>::iterator tit =
tSeries.begin();
113 for (; tit !=
tSeries.end(); tit++) {
114 if (tit->first > ts_t) {
118 scale = s0 + ((s1 - s0) / (t1 - t0)) *
dt;
138 const double ts_t = fe->ts_t;
155 CHKERRABORT(PETSC_COMM_WORLD,
ierr);
160 char time_file_name[255];
161 PetscBool flg = PETSC_TRUE;
163 time_file_name, 255, &flg);
165 if (flg != PETSC_TRUE) {
167 "*** ERROR %s (time_data FILE NEEDED)",
nAme.c_str());
169 FILE *time_data = fopen(time_file_name,
"r");
170 if (time_data == NULL) {
172 "*** ERROR data file < %s > open unsuccessful", time_file_name);
177 while (!feof(time_data)) {
179 fscanf(time_data,
"%lf %lf %lf %lf", &no1, &no2[0], &no2[1], &no2[2]);
186 "*** ERROR read data file error (check input time data file) "
192 int r = fclose(time_data);
194 std::map<double, VectorDouble>::iterator tit =
tSeries.begin();
195 for (; tit !=
tSeries.end(); tit++) {
196 PetscPrintf(PETSC_COMM_WORLD,
197 "** read accelerogram %3.2e time %3.2e %3.2e %3.2e\n",
198 tit->first, tit->second[0], tit->second[1], tit->second[2]);
202 SETERRQ(PETSC_COMM_SELF, 1,
"*** ERROR file close unsuccessful");
213 double ts_t = fe->ts_t;
216 double t0 = 0, t1,
dt;
217 std::map<double, VectorDouble>::iterator tit =
tSeries.begin();
218 for (; tit !=
tSeries.end(); tit++) {
219 if (tit->first > ts_t) {
223 acc = acc0 + ((acc1 - acc0) / (t1 - t0)) *
dt;
#define MOFEM_LOG_C(channel, severity, format,...)
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
UBlasVector< double > VectorDouble
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
const double r
rate factor
Class used to scale loads, f.e. in arc-length control.
std::map< double, VectorDouble > tSeries
TimeAccelerogram(string name="-my_accelerogram")
MoFEMErrorCode timeData()
MoFEMErrorCode scaleNf(const FEMethod *fe, VectorDouble &Nf)
Force scale operator for reading two columns.
TimeForceScale(string name="-my_time_data_file", bool error_if_file_not_given=false)
std::map< double, double > tSeries
MoFEMErrorCode scaleNf(const FEMethod *fe, VectorDouble &Nf)
Scale force the right hand vector.
MoFEMErrorCode timeData()
MoFEMErrorCode getForceScale(const double ts_t, double &scale)