v0.14.0
Public Member Functions | Public Attributes | List of all members
TimeAccelerogram Struct Reference

#include <users_modules/basic_finite_elements/src/TimeForceScale.hpp>

Inheritance diagram for TimeAccelerogram:
[legend]
Collaboration diagram for TimeAccelerogram:
[legend]

Public Member Functions

 TimeAccelerogram (string name="-my_accelerogram")
 
MoFEMErrorCode timeData ()
 
MoFEMErrorCode scaleNf (const FEMethod *fe, VectorDouble &Nf)
 
- Public Member Functions inherited from MethodForForceScaling
virtual MoFEMErrorCode getForceScale (const double ts_t, double &scale)
 
virtual ~MethodForForceScaling ()
 

Public Attributes

std::map< double, VectorDouble > tSeries
 
int readFile
 
int debug
 
string nAme
 

Additional Inherited Members

- Static Public Member Functions inherited from MethodForForceScaling
static MoFEMErrorCode applyScale (const FEMethod *fe, boost::ptr_vector< MethodForForceScaling > &methods_op, VectorDouble &nf)
 
static MoFEMErrorCode applyScale (const FEMethod *fe, boost::shared_ptr< MethodForForceScaling > method_op, VectorDouble &nf)
 

Detailed Description

Examples
nonlinear_dynamics.cpp.

Definition at line 133 of file TimeForceScale.hpp.

Constructor & Destructor Documentation

◆ TimeAccelerogram()

TimeAccelerogram::TimeAccelerogram ( string  name = "-my_accelerogram")
inline

Definition at line 139 of file TimeForceScale.hpp.

140  : readFile(0), debug(0), nAme(name) {
141 
142  ierr = timeData();
143  CHKERRABORT(PETSC_COMM_WORLD, ierr);
144  }

Member Function Documentation

◆ scaleNf()

MoFEMErrorCode TimeAccelerogram::scaleNf ( const FEMethod fe,
VectorDouble &  Nf 
)
inlinevirtual

Implements MethodForForceScaling.

Definition at line 196 of file TimeForceScale.hpp.

196  {
198  if (readFile == 0) {
199  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data file not read");
200  }
201  double ts_t = fe->ts_t;
202  VectorDouble acc(3);
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) {
208  t1 = tit->first;
209  acc1 = tit->second;
210  dt = ts_t - t0;
211  acc = acc0 + ((acc1 - acc0) / (t1 - t0)) * dt;
212  break;
213  }
214  t0 = tit->first;
215  acc0 = tit->second;
216  acc = acc0;
217  }
218  Nf += acc;
220  }

◆ timeData()

MoFEMErrorCode TimeAccelerogram::timeData ( )
inline

Definition at line 146 of file TimeForceScale.hpp.

146  {
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);
152  CHKERRG(ierr);
153  if (flg != PETSC_TRUE) {
154  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
155  "*** ERROR %s (time_data FILE NEEDED)", nAme.c_str());
156  }
157  FILE *time_data = fopen(time_file_name, "r");
158  if (time_data == NULL) {
159  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
160  "*** ERROR data file < %s > open unsuccessful", time_file_name);
161  }
162  double no1 = 0.0;
163  VectorDouble no2(3);
164  tSeries[no1] = no2;
165  while (!feof(time_data)) {
166  int n =
167  fscanf(time_data, "%lf %lf %lf %lf", &no1, &no2[0], &no2[1], &no2[2]);
168  if (n < 0) {
169  fgetc(time_data);
170  continue;
171  }
172  if (n != 4) {
173  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
174  "*** ERROR read data file error (check input time data file) "
175  "{ n = %d }",
176  n);
177  }
178  tSeries[no1] = no2;
179  }
180  int r = fclose(time_data);
181  if (debug) {
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]);
187  }
188  }
189  if (r != 0) {
190  SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR file close unsuccessful");
191  }
192  readFile = 1;
194  }

Member Data Documentation

◆ debug

int TimeAccelerogram::debug

Definition at line 136 of file TimeForceScale.hpp.

◆ nAme

string TimeAccelerogram::nAme

Definition at line 137 of file TimeForceScale.hpp.

◆ readFile

int TimeAccelerogram::readFile

Definition at line 136 of file TimeForceScale.hpp.

◆ tSeries

std::map<double, VectorDouble> TimeAccelerogram::tSeries

Definition at line 135 of file TimeForceScale.hpp.


The documentation for this struct was generated from the following file:
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
TimeAccelerogram::timeData
MoFEMErrorCode timeData()
Definition: TimeForceScale.hpp:146
TimeAccelerogram::readFile
int readFile
Definition: TimeForceScale.hpp:136
sdf.r
int r
Definition: sdf.py:8
TimeAccelerogram::debug
int debug
Definition: TimeForceScale.hpp:136
TimeAccelerogram::tSeries
std::map< double, VectorDouble > tSeries
Definition: TimeForceScale.hpp:135
convert.n
n
Definition: convert.py:82
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::PetscOptionsGetString
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
Definition: DeprecatedPetsc.hpp:172
MoFEM::Types::VectorDouble
UBlasVector< double > VectorDouble
Definition: Types.hpp:68
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
dt
double dt
Definition: heat_method.cpp:26
TimeAccelerogram::nAme
string nAme
Definition: TimeForceScale.hpp:137
CHKERRG
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483