v0.9.0
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=true)
 
MoFEMErrorCode timeData ()
 
MoFEMErrorCode getForceScale (const double ts_t, double &scale)
 
MoFEMErrorCode scaleNf (const FEMethod *fe, VectorDouble &Nf)
 
- Public Member Functions inherited from MethodForForceScaling
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
bone_adaptation.cpp, Remodeling.cpp, and UnsaturatedFlow.hpp.

Definition at line 30 of file TimeForceScale.hpp.

Constructor & Destructor Documentation

◆ TimeForceScale()

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

Definition at line 38 of file TimeForceScale.hpp.

41  :
42  readFile(0),
43  debug(1),
44  nAme(name),
45  errorIfFileNotGiven(error_if_file_not_given) {
46 
47  ierr = timeData(); CHKERRABORT(PETSC_COMM_WORLD,ierr);
48  }
MoFEMErrorCode timeData()

Member Function Documentation

◆ getForceScale()

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

Reimplemented from MethodForForceScaling.

Definition at line 95 of file TimeForceScale.hpp.

95  {
97  if(!fLg) {
98  scale = 1; // not scale at all, no history file
100  }
101  if(readFile==0) {
102  SETERRQ(PETSC_COMM_SELF,1,"data file not read");
103  }
104  scale = 0;
105  double t0 = 0,t1,s0 = tSeries[0],s1,dt;
106  std::map<double, double>::iterator tit = tSeries.begin();
107  for(;tit!=tSeries.end();tit++) {
108  if(tit->first > ts_t) {
109  t1 = tit->first;
110  s1 = tit->second;
111  dt = ts_t - t0;
112  scale = s0 + ( (s1-s0)/(t1-t0) )*dt;
113  break;
114  }
115  t0 = tit->first;
116  s0 = tit->second;
117  scale = s0;
118  }
120  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
std::map< double, double > tSeries

◆ scaleNf()

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

Implements MethodForForceScaling.

Definition at line 124 of file TimeForceScale.hpp.

124  {
126  double scale;
127  const double ts_t = fe->ts_t;
128  ierr = getForceScale(ts_t,scale); CHKERRG(ierr);
129  Nf *= scale;
131  }
MoFEMErrorCode getForceScale(const double ts_t, double &scale)
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:544
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508

◆ timeData()

MoFEMErrorCode TimeForceScale::timeData ( )

Definition at line 54 of file TimeForceScale.hpp.

54  {
56  char time_file_name[255];
57  ierr = PetscOptionsGetString(PETSC_NULL,PETSC_NULL,nAme.c_str(),time_file_name,255,&fLg); CHKERRG(ierr);
58  if(!fLg && errorIfFileNotGiven) {
59  SETERRQ1(PETSC_COMM_SELF,1,"*** ERROR %s (time_data FILE NEEDED)",nAme.c_str());
60  }
61  if(!fLg) {
63  }
64  FILE *time_data = fopen(time_file_name,"r");
65  if(time_data == NULL) {
66  SETERRQ1(PETSC_COMM_SELF,1,"*** ERROR data file < %s > open unsuccessful",time_file_name);
67  }
68  double no1 = 0.0, no2 = 0.0;
69  tSeries[no1] = no2;
70  while(!feof(time_data)){
71  int n = fscanf(time_data,"%lf %lf",&no1,&no2);
72  if((n <= 0)||((no1==0)&&(no2==0))) {
73  fgetc(time_data);
74  continue;
75  }
76  if(n != 2){
77  SETERRQ1(PETSC_COMM_SELF,1,"*** ERROR read data file error (check input time data file) { n = %d }",n);
78  }
79  tSeries[no1] = no2;
80  }
81  int r = fclose(time_data);
82  if(debug) {
83  std::map<double, double>::iterator tit = tSeries.begin();
84  for(;tit!=tSeries.end();tit++) {
85  PetscPrintf(PETSC_COMM_WORLD,"** read time series %3.2e time %3.2e\n",tit->first,tit->second);
86  }
87  }
88  if(r!=0) {
89  SETERRQ(PETSC_COMM_SELF,1,"*** ERROR file close unsuccessful");
90  }
91  readFile=1;
93  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:544
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
std::map< double, double > tSeries

Member Data Documentation

◆ debug

int TimeForceScale::debug

Definition at line 34 of file TimeForceScale.hpp.

◆ errorIfFileNotGiven

bool TimeForceScale::errorIfFileNotGiven

Definition at line 36 of file TimeForceScale.hpp.

◆ fLg

PetscBool TimeForceScale::fLg

Definition at line 52 of file TimeForceScale.hpp.

◆ nAme

string TimeForceScale::nAme

Definition at line 35 of file TimeForceScale.hpp.

◆ readFile

int TimeForceScale::readFile

Definition at line 34 of file TimeForceScale.hpp.

◆ tSeries

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

Definition at line 33 of file TimeForceScale.hpp.


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