v0.13.1
Public Member Functions | Public Attributes | List of all members
TimeForceScale Struct Reference

Force scale operator for reading two columns. More...

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

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

Public Member Functions

 TimeForceScale (string name="-my_time_data_file", bool error_if_file_not_given=false)
 
MoFEMErrorCode timeData ()
 
MoFEMErrorCode getForceScale (const double ts_t, double &scale)
 
MoFEMErrorCode scaleNf (const FEMethod *fe, VectorDouble &Nf)
 Scale force the right hand vector. More...
 
- 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, doubletSeries
 
int readFile
 
int debug
 
string nAme
 
bool errorIfFileNotGiven
 
PetscBool fLg
 

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

Force scale operator for reading two columns.

Examples
Remodeling.cpp, UnsaturatedFlow.hpp, bone_adaptation.cpp, and nonlinear_dynamics.cpp.

Definition at line 18 of file TimeForceScale.hpp.

Constructor & Destructor Documentation

◆ TimeForceScale()

TimeForceScale::TimeForceScale ( string  name = "-my_time_data_file",
bool  error_if_file_not_given = false 
)

Definition at line 25 of file TimeForceScale.hpp.

27 : readFile(0), debug(0), nAme(name),
28 errorIfFileNotGiven(error_if_file_not_given) {
29
30 ierr = timeData();
31 CHKERRABORT(PETSC_COMM_WORLD, ierr);
32 }
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
MoFEMErrorCode timeData()

Member Function Documentation

◆ getForceScale()

MoFEMErrorCode TimeForceScale::getForceScale ( const double  ts_t,
double scale 
)
virtual

Reimplemented from MethodForForceScaling.

Definition at line 89 of file TimeForceScale.hpp.

89 {
91 if (!fLg) {
92 scale = ts_t; // scale with time, by default
94 }
95 if (readFile == 0) {
96 SETERRQ(PETSC_COMM_SELF, 1, "data file not read");
97 }
98 scale = 0;
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) {
103 t1 = tit->first;
104 s1 = tit->second;
105 dt = ts_t - t0;
106 scale = s0 + ((s1 - s0) / (t1 - t0)) * dt;
107 break;
108 }
109 t0 = tit->first;
110 s0 = tit->second;
111 scale = s0;
112 }
114 }
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#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
double scale
Definition: plastic.cpp:94
std::map< double, double > tSeries

◆ scaleNf()

MoFEMErrorCode TimeForceScale::scaleNf ( const FEMethod fe,
VectorDouble &  Nf 
)
virtual

Scale force the right hand vector.

Parameters
fe
Nf
Returns
MoFEMErrorCode

Implements MethodForForceScaling.

Definition at line 123 of file TimeForceScale.hpp.

123 {
125 double scale;
126 const double ts_t = fe->ts_t;
128 Nf *= scale;
130 }
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEMErrorCode getForceScale(const double ts_t, double &scale)

◆ timeData()

MoFEMErrorCode TimeForceScale::timeData ( )

Definition at line 36 of file TimeForceScale.hpp.

36 {
38 char time_file_name[255];
39 ierr = PetscOptionsGetString(PETSC_NULL, PETSC_NULL, nAme.c_str(),
40 time_file_name, 255, &fLg);
42 if (!fLg && errorIfFileNotGiven) {
43 SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
44 "*** ERROR %s (time_data FILE NEEDED)", nAme.c_str());
45 }
46 if (!fLg) {
47 MOFEM_LOG_C("WORLD", Sev::warning,
48 "The %s file not provided. Loading scaled with time.",
49 nAme.c_str());
51 }
52 FILE *time_data = fopen(time_file_name, "r");
53 if (time_data == NULL) {
54 SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
55 "*** ERROR data file < %s > open unsuccessful", time_file_name);
56 }
57 double no1 = 0.0, no2 = 0.0;
58 tSeries[no1] = no2;
59 while (!feof(time_data)) {
60 int n = fscanf(time_data, "%lf %lf", &no1, &no2);
61 if ((n <= 0) || ((no1 == 0) && (no2 == 0))) {
62 fgetc(time_data);
63 continue;
64 }
65 if (n != 2) {
66 SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
67 "*** ERROR read data file error (check input time data file) "
68 "{ n = %d }",
69 n);
70 }
71 tSeries[no1] = no2;
72 }
73 int r = fclose(time_data);
74 if (debug) {
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);
79 }
80 }
81 if (r != 0) {
82 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
83 "*** ERROR file close unsuccessful");
84 }
85 readFile = 1;
87 }
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:304
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
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 TimeForceScale::debug

Definition at line 21 of file TimeForceScale.hpp.

◆ errorIfFileNotGiven

bool TimeForceScale::errorIfFileNotGiven

Definition at line 23 of file TimeForceScale.hpp.

◆ fLg

PetscBool TimeForceScale::fLg

Definition at line 34 of file TimeForceScale.hpp.

◆ nAme

string TimeForceScale::nAme

Definition at line 22 of file TimeForceScale.hpp.

◆ readFile

int TimeForceScale::readFile

Definition at line 21 of file TimeForceScale.hpp.

◆ tSeries

std::map<double, double> TimeForceScale::tSeries

Definition at line 20 of file TimeForceScale.hpp.


The documentation for this struct was generated from the following file: