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];
39 ierr = PetscOptionsGetString(PETSC_NULL, PETSC_NULL,
nAme.c_str(),
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;
150 ierr = PetscOptionsGetString(PETSC_NULL, PETSC_NULL,
nAme.c_str(),
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;
203 VectorDouble acc0 =
tSeries[0], acc1(3);
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;
#define MOFEM_LOG_C(channel, severity, format,...)
static PetscErrorCode ierr
#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 ...
FTensor::Index< 'n', SPACE_DIM > n
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)