MIDAS  0.75
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
taux.h
Go to the documentation of this file.
1 #ifndef MIDAS_AUXILIARY_H
2 #define MIDAS_AUXILIARY_H
3 
4 #include "alias.h"
5 
6 #include "gelib.h"
7 #include "arrays.h"
8 #include "librw.h"
9 #include "gpa.h"
10 #include "tixy2.h"
11 
12 
19 namespace midaspace {
20 
21 
23 template <class T> void TF_GPA_reid (GPA<T> &list) { for (long i=0; i<list(); i++) { list[i]->set_ID(i); } }
25 template <class T> void TF_GPA_reidoid (GPA<T> &list) { for (long i=0; i<list(); i++) { list[i]->set_ID(i); list[i]->set_origID(i); } }
27 template <class T> void TF_GPA_shake_down_reid (GPA<T> &list) { list.shake_down(); TF_GPA_reid (list); }
29 template <class T> void TF_GPA_shake_down_reidoid (GPA<T> &list) { list.shake_down(); TF_GPA_reidoid (list); }
30 
31 
32 //* ********************************************************************************************
33 //* *** *** *** *** CLASS FiLe *** *** *** ***
34 //* ********************************************************************************************
35 void filename_decomposition (char *&path, char *&base, char *&suff, const char *name);
36 void addSRCpriorDESTalloc (char *&dest, const char *src);
37 
38 
39 //* ********************************************************************************************
40 //* *** *** *** *** CLASS FiLe *** *** *** ***
41 //* ********************************************************************************************
42 class FiLe
43 {
44  protected:
48 
50  bool decomposed;
51 
53  char *path;
54  char *base;
55  char *suff;
56  char *name;
57 
58 
59  public:
61  FiLe (femFileFormat form, const char *mp, const char *fn) {
62  format = form;
63  if (mp) mmp = MMprocessingStoE (mp);
64  else mmp = MMP_Void;
65 
66  decomposed = false;
67 
68  if (fn[0] == '-' && fn[1] == '\0') name = NULL;
69  else name = strdupl (fn);
70  path = base = suff = NULL;
71  }
73  FiLe (femFileFormat form, const char *p, const char *b, const char *s) {
74  format = form;
75  decomposed = true;
76 
77  path = strdupl (p);
78  base = strdupl (b);
79  suff = strdupl (s);
80  name = NULL;
81  }
83  virtual ~FiLe() {
84  delete [] name;
85  delete [] path;
86  delete [] base;
87  delete [] suff;
88  }
89 
90  void addGlobPath (const char * globpath)
91  {
92  if (!globpath) errol;
93 
94  if (decomposed) {
95  delete [] name;
96  if (path) addSRCpriorDESTalloc(path, globpath);
97  else path = strdupl (globpath);
98  }
99  else {
100  if (name) addSRCpriorDESTalloc(name, globpath);
101  else errol;
102  }
103  }
104 
107  {
108  if (name == NULL) name = strdupl (src->give_base());
109  }
110 
112  void decompose (void)
113  {
114  decomposed = true;
115 
117 
118  delete [] name;
119  name = NULL;
120  }
121 
123  void compose (void)
124  {
125  if (name) errol;
126  if (!base) errol;
127 
128  if ( path && base && suff) name = strdupl (path, base, suff);
129  else if (!path && base && suff) name = strdupl ( base, suff);
130  else if (!path && base && !suff) name = strdupl ( base );
131  else errol;
132  }
133 
135  //void set_IN_resultFF (femFileFormat val) { IN_resultFF = val; }
136  //void set_suff (const char* val) {
137  // if (suff) errol; suff = strdupl (val);
138  // if (!base) base = strdupl (name);
139  //}
140 
141  const char* give_path (void) const { if (!decomposed) ((FiLe*)this)->decompose(); return path; }
142  const char* give_base (void) const { if (!decomposed) ((FiLe*)this)->decompose(); return base; }
143  const char* give_suff (void) const { if (!decomposed) ((FiLe*)this)->decompose(); return suff; }
144 
145  const char* give_name_or_null (void) const { return ((this->is_empty()) ? NULL : this->give_name()); }
146  const char* give_name (void) const { if (!name) ((FiLe*)this)-> compose(); return name; }
147  femFileFormat give_ff (void) const { return format; }
148  MMprocessing give_mmp (void) const { return mmp; }
149 
150  bool is_empty (void) const { return ((name || base) ? false : true); }
151 };
152 
153 
154 
155 //* ********************************************************************************************
156 //* *** *** *** *** CLASS LocalCoordSystem *** *** *** ***
157 //* ********************************************************************************************
162 {
163  public:
165  LocalCoordSystem (void) { }
167  virtual ~LocalCoordSystem() { }
168 
169 };
170 
171 
172 //* ********************************************************************************************
173 //* *** *** *** *** CLASS LCS_pure *** *** *** ***
174 //* ********************************************************************************************
175 #define COMPV3 ((LCS_pure*)this)->compute_v3();
176 
180 {
181  private:
182  bool v3alloc;
184 
185  public:
187  LCS_pure (void) : LocalCoordSystem () { v3alloc = false; }
189  virtual ~LCS_pure() { }
190 
191  const VectoR* n1(void) const { return &v1; }
192  const VectoR* n2(void) const { return &v2; }
193  const VectoR* n3(void) const { COMPV3; return &v3; }
194 
195  void set_n1 (const VectoR *src) { v1.x = src->x; v1.y = src->y; v1.z = src->z; }
196  void set_n2 (const VectoR *src) { v2.x = src->x; v2.y = src->y; v2.z = src->z; }
197  void set_n3 (const VectoR *src) { v3.x = src->x; v3.y = src->y; v3.z = src->z; v3alloc = true; }
198 
199  void compute_v3 (void) {
200  if (v3alloc) return;
201  v3alloc = true;
202  v3.beVectProduct( &v1, &v2 );
203  }
205  void initialize_from (const char *&str, femFileFormat ff);
207  //void initialize (const Geometry *geom);
208 
210  void setup_rotmat_g2l (MatriX *rotmat);
211  void setup_rotmat_l2g (MatriX *rotmat);
212 };
213 
214 //* ********************************************************************************************
215 //* *** *** *** *** CLASS LCS_beam *** *** *** ***
216 //* ********************************************************************************************
236 {
237  protected:
240  long number;
242  const Point *p;
243 
244  public:
246  LCS_beam (void) : LocalCoordSystem () { direction = LCSd_Void; type = LCSt_Void; number = -1; p = NULL; }
247  LCS_beam (LCSdirection dir, LCStype typ) : LocalCoordSystem () { direction = dir; type = typ; number = -1; p = NULL; }
248  LCS_beam (LCSdirection dir, LCStype typ, long num) : LocalCoordSystem () { direction = dir; type = typ; number = num; p = NULL; }
249  LCS_beam (LCSdirection dir, LCStype typ, const double *a) : LocalCoordSystem () { direction = dir; type = typ; number = -1; p = NULL;
250  switch (this->type) {
251  case LCSt_Vector: array.scan_xyz(a); break;
252  default: errol;
253  }
254  }
256  virtual ~LCS_beam() { p = NULL; }
257 
259  void initialize_from (const char *&str, femFileFormat ff);
261  void initialize (const Geometry *geom);
262 
264  const Elem3D* give_vector (void) const {
265  if (type == LCSt_Vector) return &array;
266  return NULL;
267  }
268 
269 
271  void print_row_OOFEM (FILE *stream, int did, Beam *b) const;
272 
273 };
274 
275 
276 //* ********************************************************************************************
277 //* *** *** *** *** CLASS AdaptivityParameters *** *** *** ***
278 //* ********************************************************************************************
282 
284 {
285  protected:
286  // toto je i v problem.h pro midas adaptivitu; casem to mozna sluc
287  ADPArameters eetype; // error estimation type
288  int norm; // 1 = energy norm; 2 = L2 norm
289  int SPRboudary; // 1, 2, 3
290  double required_error; // required_error
291  double enlarg; // adaptivity -
292  double reduct; // adaptivity -
293 
294  double error; // spoctena chyba
295 
296  // OOFEM minelemsize 0.05 recoverytype 1
297 
298  public:
301  enlarg = 2.0;
302  reduct = 0.5;
303  error = 0.0;
304  }
307  enlarg = 2.0;
308  reduct = 0.5;
309  error = 0.0;
310  }
312  virtual ~AdaptivityParameters() { }
313 
315  void initialize_from (const char *&str, femFileFormat fff);
316  void initialize_from (FILE *stream, femFileFormat fff);
317  int initialize_from (char **argv);
318 
320  //void initialize (const Geometry *geom);
321 
322 
324  void print_row_OOFEM (FILE *stream, int did, Beam *b) const;
325 
326  ADPArameters give_eetype (void) const { return eetype; }
327  int give_norm (void) const { return norm; }
328  int give_SPRboudary (void) const { return SPRboudary; }
329  double give_required_error(void) const { return required_error; }
330  double give_enlarg (void) const { return enlarg; }
331  double give_reduct (void) const { return reduct; }
332  double give_error (void) const { return error; }
333 
334  void set_error (double val) { error = val; }
335 };
336 
337 
338 //* ********************************************************************************************
339 //* *** *** *** *** CLASS STDOUTDRIVER *** *** *** ***
340 //* ********************************************************************************************
342 
343 #ifdef COLOREDOUT
344 #define clrout true
345 #else
346 #define clrout false
347 #endif
348 
350 
352 {
353  protected:
354  int act; // actual length of printed row
355  int len; // max length of the row
356 
357  public:
359  StdoutDriver (void) { act = 0; len = 78; }
361  virtual ~StdoutDriver() { }
362 
364  void set_act (int val) { act = val; }
365 
367  void spaces (int n) const;
369  void print_info_message (SODenum flag, const char *format, ...) const;
371  void print_info_message_colour (SODenum flag, ETCLR colour, const char *format, ...) const;
373  void print_info_time_green_ok (SODenum flag, double sec) const;
375  void print_info_message_core (SODenum flag, ETCLR color = ETC_DEFAULT, const char *buffer = NULL) const;
376 
377 };
378 
379 } // namespace midaspace
380 
381 #endif // MIDAS_AUXILIARY_H
void setup_rotmat_g2l(MatriX *rotmat)
Definition: taux.cpp:70
char * strdupl(const char *src)
standard strdup - Memory for the new string is obtained with malloc(3), and can be freed with free(3)...
Definition: librw.cpp:53
const Elem3D * give_vector(void) const
Definition: taux.h:264
femFileFormat
Definition: alias.h:632
LCSdirection direction
Definition: taux.h:238
virtual ~LCS_beam()
DESTRUCTOR.
Definition: taux.h:256
void set_empty_name_from_base(FiLe *src)
Definition: taux.h:106
void initialize_from(const char *&str, femFileFormat ff)
Definition: taux.cpp:59
double give_error(void) const
Definition: taux.h:332
void addSRCpriorDESTalloc(char *&dest, const char *src)
Definition: taux.cpp:47
#define COMPV3
Definition: taux.h:175
char * base
Definition: taux.h:54
General functions.
void spaces(int n) const
Definition: taux.cpp:233
Class GPA.
const VectoR * n2(void) const
Definition: taux.h:192
SODenum
Definition: taux.h:349
void compute_v3(void)
Definition: taux.h:199
virtual ~FiLe()
DESTRUCTOR.
Definition: taux.h:83
Input / output function.
void filename_decomposition(char *&path, char *&base, char *&suff, const char *name)
Definition: taux.cpp:16
void shake_down(void)
Definition: gpa.h:312
void TF_GPA_shake_down_reid(GPA< T > &list)
clear out NULL components
Definition: taux.h:27
Local coordinate system.
Definition: taux.h:161
virtual ~LocalCoordSystem()
DESTRUCTOR.
Definition: taux.h:167
void TF_GPA_reidoid(GPA< T > &list)
reset ids ascending
Definition: taux.h:25
void initialize_from(const char *&str, femFileFormat fff)
Definition: taux.cpp:196
void print_info_message(SODenum flag, const char *format,...) const
Definition: taux.cpp:240
LCS_pure(void)
CONSTRUCTOR.
Definition: taux.h:187
void print_row_OOFEM(FILE *stream, int did, Beam *b) const
Definition: taux.cpp:166
void compose(void)
Definition: taux.h:123
LCSdirection
Definition: taux.h:217
void print_info_message_core(SODenum flag, ETCLR color=ETC_DEFAULT, const char *buffer=NULL) const
Definition: taux.cpp:280
LCS_beam(LCSdirection dir, LCStype typ)
Definition: taux.h:247
const char * give_path(void) const
Definition: taux.h:141
Alias.
#define errol
Definition: gelib.h:142
void initialize_from(const char *&str, femFileFormat ff)
Definition: taux.cpp:132
void setup_rotmat_l2g(MatriX *rotmat)
Definition: taux.cpp:78
ETCLR
enum
Definition: gelib.h:89
const VectoR * n1(void) const
Definition: taux.h:191
LCS_beam(void)
CONSTRUCTOR.
Definition: taux.h:246
Elem3D array
Definition: taux.h:241
MMprocessing mmp
Definition: taux.h:47
const char * give_base(void) const
Definition: taux.h:142
FiLe(femFileFormat form, const char *mp, const char *fn)
CONSTRUCTOR.
Definition: taux.h:61
void initialize(const Geometry *geom)
Definition: taux.cpp:91
FiLe(femFileFormat form, const char *p, const char *b, const char *s)
CONSTRUCTOR.
Definition: taux.h:73
Structs Elem3D, PoinT and VectoR; classes Array, Array1d, Xscal, Dscal, Xvctr, Lvctr, Dvctr, Xmtrx, Lmtrx and Dmtrx.
int give_norm(void) const
Definition: taux.h:327
Local coordinate system at beam element.
Definition: taux.h:235
virtual ~LCS_pure()
DESTRUCTOR.
Definition: taux.h:189
LCStype type
Definition: taux.h:239
LCS_beam(LCSdirection dir, LCStype typ, long num)
Definition: taux.h:248
char * name
Definition: taux.h:56
femFileFormat format
variables associated with the file
Definition: taux.h:46
MMprocessing give_mmp(void) const
Definition: taux.h:148
const char * give_name(void) const
Definition: taux.h:146
int give_SPRboudary(void) const
Definition: taux.h:328
void set_n2(const VectoR *src)
Definition: taux.h:196
void print_info_message_colour(SODenum flag, ETCLR colour, const char *format,...) const
Definition: taux.cpp:253
const VectoR * n3(void) const
Definition: taux.h:193
virtual ~StdoutDriver()
DESTRUCTOR.
Definition: taux.h:361
TinyXML functions.
char * path
file name
Definition: taux.h:53
MMprocessing MMprocessingStoE(const char *val)
Definition: alias.h:622
const char * give_suff(void) const
Definition: taux.h:143
Geometry description.
Definition: geometry.h:29
VectoR * beVectProduct(const VectoR *v1, const VectoR *v2)
vector product v1 x v2 (cross product)
Definition: arrays.h:160
void decompose(void)
Definition: taux.h:112
void addGlobPath(const char *globpath)
Definition: taux.h:90
void print_info_time_green_ok(SODenum flag, double sec) const
Definition: taux.cpp:266
LCS_beam(LCSdirection dir, LCStype typ, const double *a)
Definition: taux.h:249
ADPArameters give_eetype(void) const
Definition: taux.h:326
bool scan_xyz(FILE *stream)
Definition: arrays.h:71
double give_enlarg(void) const
Definition: taux.h:330
bool is_empty(void) const
Definition: taux.h:150
const Point * p
Definition: taux.h:242
GPA - Generic Pointer Array, template class manages 1d array of pointers to objects of type T...
Definition: gpa.h:23
femFileFormat give_ff(void) const
Definition: taux.h:147
const char * give_name_or_null(void) const
Definition: taux.h:145
MMprocessing
Definition: alias.h:616
void TF_GPA_reid(GPA< T > &list)
reset ids ascending
Definition: taux.h:23
AdaptivityParameters(long ee)
CONSTRUCTOR.
Definition: taux.h:306
virtual ~AdaptivityParameters()
DESTRUCTOR.
Definition: taux.h:312
void set_n1(const VectoR *src)
Definition: taux.h:195
AdaptivityParameters(void)
CONSTRUCTOR.
Definition: taux.h:300
void set_error(double val)
Definition: taux.h:334
bool decomposed
state of file name
Definition: taux.h:50
LCStype
Definition: taux.h:218
Local coordinate system defined by 2 vectors.
Definition: taux.h:179
double give_reduct(void) const
Definition: taux.h:331
char * suff
Definition: taux.h:55
StdoutDriver(void)
CONSTRUCTOR.
Definition: taux.h:359
void print_row_OOFEM(FILE *stream, int did, Beam *b) const
double give_required_error(void) const
Definition: taux.h:329
LocalCoordSystem(void)
CONSTRUCTOR.
Definition: taux.h:165
void TF_GPA_shake_down_reidoid(GPA< T > &list)
clear out NULL components
Definition: taux.h:29
void set_act(int val)
Definition: taux.h:364
ADPArameters
Adaptivity paramaters.
Definition: taux.h:281
void set_n3(const VectoR *src)
Definition: taux.h:197