MIDAS  0.75
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
taux.cpp
Go to the documentation of this file.
1 #include "taux.h"
2 
3 #include "geometry.h"
4 #include "point.h"
5 
6 #include "arrays.h"
7 
8 
9 namespace midaspace {
10 
11 
12 
13 //* ********************************************************************************************
14 //* *** *** *** *** CLASS FiLe *** *** *** ***
15 //* ********************************************************************************************
16 void filename_decomposition (char *&path, char *&base, char *&suff, const char *name)
17 {
18  if (path || base || suff) errol;
19 
20  const char *p;
21 
22  p = strrchr(name, DIRSEPARATOR);
23  if (p) {
24  path = new char[p-name+2];
25  strncpy (path, name, p-name+1);
26  path[p-name+1] = '\0';
27  p++;
28  }
29  else p = name;
30 
31  name = p;
32  p = strchr(name,'.');
33  if (p) {
34  base = new char[p-name+1];
35  strncpy (base, name, p-name);
36  base[p-name] = '\0';
37 
38  suff = new char[strlen(p)+1];
39  strcpy (suff, p);
40  }
41  else {
42  base = new char[strlen(name)+1];
43  strcpy (base, name);
44  }
45 }
46 
47 void addSRCpriorDESTalloc (char *&dest, const char *src)
48 {
49  char *aux = strdupl (src, dest);
50  delete [] dest;
51  dest = aux;
52 }
53 
54 
55 //* ********************************************************************************************
56 //* *** *** *** *** CLASS LCS_pure *** *** *** ***
57 //* ********************************************************************************************
59 void LCS_pure :: initialize_from (const char *&str, femFileFormat ff)
60 {
61  if (ff == FFF_OOFEM) {
62  SP_scan_expected_number_exit (str, 6, "6");
63  if (!v1.scan_xyz(str)) errol;
64  if (!v2.scan_xyz(str)) errol;
65  v3alloc = false;
66  }
67  else errol;
68 }
69 
71 {
72  COMPV3;
73 
74  rotmat->copy_to_row_1(&v1);
75  rotmat->copy_to_row_2(&v2);
76  rotmat->copy_to_row_3(&v3);
77 }
79 {
80  COMPV3;
81 
82  rotmat->copy_to_col_1(&v1);
83  rotmat->copy_to_col_2(&v2);
84  rotmat->copy_to_col_3(&v3);
85 }
86 
87 //* ********************************************************************************************
88 //* *** *** *** *** CLASS LCS_beam *** *** *** ***
89 //* ********************************************************************************************
91 void LCS_beam :: initialize (const Geometry *geom)
92 {
93  if (p) _errorr("mismatch in refNode");
94 
95  const GPA<Point> *points = geom->give_Pjnts();
96 
97  switch (this->type) {
98  case LCSt_NodeID:
99  if ( number > (*points)()) _errorr("refnode id is greather then number of all nodes");
100  if ( number == 0) this->type = LCSt_Void;
101  else p = (*points)[number-1];
102  break;
103  case LCSt_NodeProp:
104  if ( number < 1 ) errol;
105  for (long i=0; i<(*points)(); i++)
106  if ((*points)[i]->has_mproperty(number)) {
107  if (p) _errorr("node with property %d is not unique");
108  else p = (*points)[i];
109  }
110  break;
111  case LCSt_NodeCoords: _errorr("zatim neni implementovano"); break;
112  case LCSt_Vector: break;
113  default: errol;
114  }
115 
116  if (p) {
117  const Node *n = dynamic_cast<const Node *>(p);
118  if (n) {
119  // check if reference node is in all domains
120  // je to zde natvrdo, predpoklada se, ze u paralelnich versi je refnode natolik dulezity aby byl vsude
121  long numdom = n->Msh()->give_NumDomains();
122 
123  if (n->Msh()->give_Parallel())
124  for (long did=0; did<numdom; did++)
125  ((Node*)n)->add_me_to_domain (did);
126 
127  }
128  }
129 }
130 
132 void LCS_beam :: initialize_from (const char *&str, femFileFormat ff)
133 {
134  if (ff == FFF_OOFEM) {
135  SP_scan_number (str, number);
136  direction = LCSd_xy;
137  if (number == -1) {
138  type = LCSt_Vector;
139  SP_scan_expected_word_exit (str, "rnlcs", "rnlcs word is expected", CASE);
140  SP_scan_expected_word_exit (str, "3", "the 3 is expected", CASE);
141  array.scan_xyz (str);
142  }
143  else {
144  type = LCSt_NodeID;
145  if (number < 0) _errorr("error");
146  }
147  }
148  else if (ff == FFF_MIDAS) {
149  char WORD[255];
150  SP_scan_word (str, WORD);
151  if (STRCMP(WORD, "xy") == 0) direction = LCSd_xy;
152  else if (STRCMP(WORD, "xz") == 0) direction = LCSd_xz;
153  else _errorr2("wrong keyword xy xz is supposed, not %s", WORD);
154 
155  while (SP_scan_word (str, WORD))
156  if (STRCMP(WORD, "nodeID" ) == 0) { type = LCSt_NodeID; SP_scan_number (str, number); }
157  else if (STRCMP(WORD, "nodeProp" ) == 0) { type = LCSt_NodeProp; SP_scan_number (str, number); }
158  else if (STRCMP(WORD, "nodeCoords") == 0) { type = LCSt_NodeCoords; SP_scan_expected_number_exit (str, 3, "3"); array.scan_xyz(str); }
159  else if (STRCMP(WORD, "vector" ) == 0) { type = LCSt_Vector; SP_scan_expected_number_exit (str, 3, "3"); array.scan_xyz(str); }
160  else _errorr2("wrong keyword in refnode input %s", WORD);
161  }
162  else errol;
163 }
164 
166 void LCS_beam :: print_row_OOFEM (FILE *stream, int did, Beam *b) const
167 {
168  const Node *n = dynamic_cast<const Node *>(p);
169  if (p && n == NULL) {
170  if (type==LCSt_NodeProp && (dynamic_cast<const Vertex*>(p) != NULL)) {
171  ((LCS_beam*)this)->p = n = ((const Mesh*)b->give_Geom())->give_Node_with_prop (p->give_ID()+1, true); // (number, true);
172  }
173  else errol;
174  }
175 
176  if (direction == LCSd_xz) {
177  if (type != LCSt_Vector) _errorr("");
178  VectoR x, y;
179  x.beP2P( b->give_point(0)->give_coords(), b->give_point(1)->give_coords() );
180  y.beVectProduct(&x, (VectoR*)&array);
181  fprintf (stream, " -1 rnlcs 3 % .6g % .6g % .6g", y.x, y.y, y.z);
182  }
183  else if (direction == LCSd_xy) {
184  if (p) fprintf (stream, " %ld", n->give_lid_id(did) + 1 );
185  else fprintf (stream, " -1 rnlcs 3 % .6g % .6g % .6g", array.x, array.y, array.z);
186  }
187  else errol;
188 }
189 
190 
191 
192 //* ********************************************************************************************
193 //* *** *** *** *** CLASS AdaptivityParameters *** *** *** ***
194 //* ********************************************************************************************
197 {
198  if (fff == FFF_MIDAS || fff == FFF_OOFEM) {
199  char W[255];
200  long auxl;
201 
202  while (SP_scan_word (str, W)) {
203  if (strcmp(W, "type") == 0) { SP_scan_number(str, auxl); eetype = (ADPArameters)auxl; }
204  else if (strcmp(W, "accuracy") == 0) SP_scan_number(str, required_error);
205  //else if (strcmp(W, "enlarg") == 0) SP_scan_number(str, adapt_enlarg);
206  //else if (strcmp(W, "reduct") == 0) SP_scan_number(str, adapt_reduct);
207  else _errorr2 ("Unsupported key word in problem analysis line adaptivity \"%s\"", W);
208  }
209  }
210 }
211 
214 {
215  if (fff == FFF_SIFEL) {
216  fscanf (stream, "%lf %lf %lf", &required_error, &enlarg, &reduct);
217  }
218 }
219 
222 {
223  norm = atol(argv[0]);
224  required_error = atof(argv[1]);
225  SPRboudary = atol(argv[2]);
226  return 3;
227 }
228 
229 //* ********************************************************************************************
230 //* *** *** *** *** CLASS STDOUTDRIVER *** *** *** ***
231 //* ********************************************************************************************
233 void StdoutDriver :: spaces (int n) const
234 {
235  while (n-- >= 0) fprintf (stdout," ");
236 }
237 
238 
240 void StdoutDriver :: print_info_message (SODenum flag, const char *format, ...) const
241 {
242  char buffer[100];
243  va_list args;
244 
245  va_start(args, format);
246  vsprintf(buffer, format, args);
247  va_end(args);
248 
249  this->print_info_message_core (flag, ETC_DEFAULT, buffer);
250 }
251 
253 void StdoutDriver :: print_info_message_colour (SODenum flag, ETCLR colour, const char *format, ...) const
254 {
255  char buffer[100];
256  va_list args;
257 
258  va_start(args, format);
259  vsprintf(buffer, format, args);
260  va_end(args);
261 
262  this->print_info_message_core (flag, colour, buffer);
263 }
264 
267 {
268  if (flag != SODE_end_green_ok) errol;
269 
270  int hod = (int)sec/3600; sec -= hod*3600;
271  int min = (int)sec/60; sec -= min*60;
272 
273  char buffer[15];
274  sprintf (buffer, "%2d:%02d:%05.2f ", hod, min, sec);
275 
276  this->print_info_message_core (flag, ETC_DEFAULT, buffer);
277 }
278 
280 void StdoutDriver :: print_info_message_core (SODenum flag, ETCLR color, const char *buffer) const
281 {
282  int buflen;
283  if (buffer) buflen = strlen(buffer);
284  else { buflen = 0;
285  if (flag != SODE_green_ok) errol;
286  }
287 
288  int actt = act;
289  switch (flag){
291  if (clrout) CHANGE_CONSOLE_COLOUR(stdout, TC_B_CYAN ); fprintf (stdout, " -> ");
292  if (clrout) change_console_colour(stdout, color ); fprintf (stdout, "%s", buffer);
294  actt += 4 + buflen;
295  break;
296  case SODE_row:
297  if (clrout) change_console_colour(stdout, color ); fprintf (stdout, "%s\n", buffer);
299  actt = 0;
300  break;
301  case SODE_end:
302  ; spaces (len - actt - buflen);
303  if (clrout) change_console_colour(stdout, color ); fprintf (stdout, "%s\n", buffer);
305  actt = 0;
306  break;
307  case SODE_end_green_ok:
308  ; spaces (len - actt - buflen - 4);
309  if (clrout) change_console_colour(stdout, color ); fprintf (stdout, "%s", buffer);
310  if (clrout) CHANGE_CONSOLE_COLOUR(stdout, TC_D_GREEN); fprintf (stdout, " ok\n");
312  actt = 0;
313  break;
314  case SODE_green_ok:
315  ; spaces (len - actt - 2);
316  if (clrout) CHANGE_CONSOLE_COLOUR(stdout, TC_D_GREEN); fprintf (stdout, "ok\n");
318  actt = 0;
319  break;
320  default: _errorr ("Unknown type of flag in function print_info_message");
321  }
322 
323  ((StdoutDriver*)this)->set_act(actt);
324 }
325 
326 // this->sodriver()->print_info_message (SODE_start_blue_arrow, "Detection");
327 
328 // this->sodriver()->print_info_message (SODE_row, " ------------------------------------------------------------------------------");
329 
330 // this->sodriver()->print_info_message_core (SODE_green_ok);
331 
332 
333 } // namespace midaspace
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
void change_console_colour(FILE *stream, ETCLR clr)
Definition: gelib.h:129
#define CHANGE_CONSOLE_COLOUR(_1, _2)
Definition: gelib.h:126
femFileFormat
Definition: alias.h:632
LCSdirection direction
Definition: taux.h:238
void initialize_from(const char *&str, femFileFormat ff)
Definition: taux.cpp:59
void addSRCpriorDESTalloc(char *&dest, const char *src)
Definition: taux.cpp:47
#define COMPV3
Definition: taux.h:175
const GPA< Point > * give_Pjnts(void) const
Definition: geometry.h:72
long give_NumDomains(void) const
Definition: geometry.h:319
void copy_to_col_1(const VectoR *v)
Definition: arrays.h:248
void spaces(int n) const
Definition: taux.cpp:233
long SP_scan_word(const char *&src, char *dest)
... word; return value is length of the word
Definition: librw.cpp:528
#define TC_B_CYAN
Definition: gelib.h:80
SODenum
Definition: taux.h:349
#define SP_scan_expected_word_exit(_1, _2, _3, _4)
Definition: librw.h:201
sifel i/o native ff
Definition: alias.h:644
void filename_decomposition(char *&path, char *&base, char *&suff, const char *name)
Definition: taux.cpp:16
Point.
#define SP_scan_expected_number_exit(_1, _2, _3)
Definition: librw.h:229
#define DIRSEPARATOR
Definition: gelib.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
void copy_to_row_1(const VectoR *v)
Definition: arrays.h:244
void print_row_OOFEM(FILE *stream, int did, Beam *b) const
Definition: taux.cpp:166
#define STRCMP
Definition: alias.h:44
const Mesh * Msh(void) const
Definition: point.h:258
void print_info_message_core(SODenum flag, ETCLR color=ETC_DEFAULT, const char *buffer=NULL) const
Definition: taux.cpp:280
long give_ID() const
Definition: subject.h:45
#define errol
Definition: gelib.h:142
void copy_to_row_2(const VectoR *v)
Definition: arrays.h:245
void initialize_from(const char *&str, femFileFormat ff)
Definition: taux.cpp:132
const Geometry * give_Geom(void) const
Definition: subject.h:74
void setup_rotmat_l2g(MatriX *rotmat)
Definition: taux.cpp:78
oofem i/o native ff
Definition: alias.h:643
ETCLR
enum
Definition: gelib.h:89
#define _errorr2(_1, _2)
Definition: gelib.h:145
Elem3D array
Definition: taux.h:241
void initialize(const Geometry *geom)
Definition: taux.cpp:91
const Point * give_point(long i) const
Definition: cell.h:93
Structs Elem3D, PoinT and VectoR; classes Array, Array1d, Xscal, Dscal, Xvctr, Lvctr, Dvctr, Xmtrx, Lmtrx and Dmtrx.
Local coordinate system at beam element.
Definition: taux.h:235
LCStype type
Definition: taux.h:239
#define TC_D_GREEN
Definition: gelib.h:73
void print_info_message_colour(SODenum flag, ETCLR colour, const char *format,...) const
Definition: taux.cpp:253
void copy_to_col_3(const VectoR *v)
Definition: arrays.h:250
Geometry description.
Definition: geometry.h:29
#define clrout
Standard output manager.
Definition: taux.h:344
VectoR * beVectProduct(const VectoR *v1, const VectoR *v2)
vector product v1 x v2 (cross product)
Definition: arrays.h:160
void print_info_time_green_ok(SODenum flag, double sec) const
Definition: taux.cpp:266
bool scan_xyz(FILE *stream)
Definition: arrays.h:71
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
#define _errorr(_1)
Definition: gelib.h:151
#define TC_DEFAULT
Definition: gelib.h:85
Auxiliary functions; classes FiLe, LocalCoordSystem, AdaptivityParameters and StdoutDriver.
#define CASE
Definition: alias.h:43
bool give_Parallel(void) const
Definition: geometry.h:318
VectoR * beP2P(const PoinT *p1, const PoinT *p2)
Receiver is set to vector from p1 to p2, i.e. 'this = p2 - p1'.
Definition: arrays.h:153
bool SP_scan_number(const char *&src, int &dest)
... number of type int/long/double
Definition: librw.cpp:595
Class Geometry, Model and Mesh.
long give_lid_id(long dom) const
vraci lid of node, pro non-Parallel vraci id
Definition: point.h:275
void copy_to_col_2(const VectoR *v)
Definition: arrays.h:249
void copy_to_row_3(const VectoR *v)
Definition: arrays.h:246
const PoinT * give_coords(void) const
Definition: point.h:89
ADPArameters
Adaptivity paramaters.
Definition: taux.h:281
MIDAS input native ff - pro specialni potreby.
Definition: alias.h:646