v0.13.2
Loading...
Searching...
No Matches
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 scaleNf (const FEMethod *fe, VectorDouble &Nf)=0
 
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 }
static PetscErrorCode ierr
MoFEMErrorCode timeData()

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 }
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
double dt
Definition: heat_method.cpp:26
UBlasVector< double > VectorDouble
Definition: Types.hpp:68
std::map< double, VectorDouble > tSeries

◆ 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 }
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
FTensor::Index< 'n', SPACE_DIM > n
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
const double r
rate factor

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: