v0.9.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=true)
 
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 ~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 37 of file TimeForceScale.hpp.

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

Member Function Documentation

◆ getForceScale()

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

Reimplemented from MethodForForceScaling.

Definition at line 98 of file TimeForceScale.hpp.

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

132  {
134  double scale;
135  const double ts_t = fe->ts_t;
136  CHKERR getForceScale(ts_t, scale);
137  Nf *= scale;
139  }
MoFEMErrorCode getForceScale(const double ts_t, double &scale)
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
#define CHKERR
Inline error check.
Definition: definitions.h:602
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:413

◆ timeData()

MoFEMErrorCode TimeForceScale::timeData ( )

Definition at line 48 of file TimeForceScale.hpp.

48  {
50  char time_file_name[255];
51  ierr = PetscOptionsGetString(PETSC_NULL, PETSC_NULL, nAme.c_str(),
52  time_file_name, 255, &fLg);
53  CHKERRG(ierr);
54  if (!fLg && errorIfFileNotGiven) {
55  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
56  "*** ERROR %s (time_data FILE NEEDED)", nAme.c_str());
57  }
58  if (!fLg) {
60  }
61  FILE *time_data = fopen(time_file_name, "r");
62  if (time_data == NULL) {
63  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
64  "*** ERROR data file < %s > open unsuccessful", time_file_name);
65  }
66  double no1 = 0.0, no2 = 0.0;
67  tSeries[no1] = no2;
68  while (!feof(time_data)) {
69  int n = fscanf(time_data, "%lf %lf", &no1, &no2);
70  if ((n <= 0) || ((no1 == 0) && (no2 == 0))) {
71  fgetc(time_data);
72  continue;
73  }
74  if (n != 2) {
75  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
76  "*** ERROR read data file error (check input time data file) "
77  "{ n = %d }",
78  n);
79  }
80  tSeries[no1] = no2;
81  }
82  int r = fclose(time_data);
83  if (debug) {
84  std::map<double, double>::iterator tit = tSeries.begin();
85  for (; tit != tSeries.end(); tit++) {
86  PetscPrintf(PETSC_COMM_WORLD, "** read time series %3.2e time %3.2e\n",
87  tit->first, tit->second);
88  }
89  }
90  if (r != 0) {
91  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
92  "*** ERROR file close unsuccessful");
93  }
94  readFile = 1;
96  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:507
FTensor::Index< 'n', 2 > n
Definition: PlasticOps.hpp:68
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:550
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:514
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 33 of file TimeForceScale.hpp.

◆ errorIfFileNotGiven

bool TimeForceScale::errorIfFileNotGiven

Definition at line 35 of file TimeForceScale.hpp.

◆ fLg

PetscBool TimeForceScale::fLg

Definition at line 46 of file TimeForceScale.hpp.

◆ nAme

string TimeForceScale::nAme

Definition at line 34 of file TimeForceScale.hpp.

◆ readFile

int TimeForceScale::readFile

Definition at line 33 of file TimeForceScale.hpp.

◆ tSeries

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

Definition at line 32 of file TimeForceScale.hpp.


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