v0.9.0
BCData.hpp
Go to the documentation of this file.
1 /** \file BCData.hpp
2  * \brief Data structure with Cubit native blocks/meshet with boundary conditions
3  *
4  */
5 
6 /*
7  * MoFEM is free software: you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15  * License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
19 */
20 
21 #ifndef __BCDATA_HPP__
22 #define __BCDATA_HPP__
23 
24 namespace MoFEM {
25 
26 /*! \struct GenericCubitBcData
27  * \brief Generic bc data structure
28  * \ingroup mofem_bc
29  */
31 
32 
33  /**
34  * \brief get data from structure
35  * @param attributes vector of doubles
36  * @return error code
37  */
38  virtual MoFEMErrorCode fill_data(const std::vector<char>& bc_data) {
40  SETERRQ(PETSC_COMM_SELF,1,"It makes no sense for the generic bc type");
42  }
43 
44  /**
45  * \brief set data on structure
46  * @param tag_ptr pointer to tag on meshset
47  * @param size size of data in bytes
48  * @return error code
49  */
50  virtual MoFEMErrorCode set_data(void *tag_ptr,unsigned int size) const {
52  SETERRQ(PETSC_COMM_SELF,1,"It makes no sense for the generic bc type");
54  }
55 
56  /**
57  * \brief get data structure size
58  * @return size of structure in bytes
59  */
60  virtual std::size_t getSizeOfData() const = 0;
61 
62  /**
63  * \brief get pointer to data structure
64  * @return pointer
65  */
66  virtual const void * getDataPtr() const = 0;
67 
68  const CubitBCType tYpe; ///< Type of boundary condition
69 
70  /**
71  * \brief get data type
72  * @return data type, see CubitBC
73  */
74  virtual const CubitBCType& getType() const { return tYpe; }
75 
77  tYpe(type) {}
78 
79  virtual ~GenericCubitBcData() {}
80 
81 };
82 
83 /*! \struct DisplacementCubitBcData
84  * \brief Definition of the displacement bc data structure
85  * \ingroup mofem_bc
86  */
88 
89  /*! \brief attributes of DisplacementCubitBcData
90  */
91  struct __attribute__ ((packed)) _data_{
92  char name[12]; //< 12 characters for "Displacement"
93  char pre1; //< Always zero
94  char pre2; //< pre-processing flags for modification of displacement bcs. They should not affect analysis, i.e. safe to ignore; 1: smallest combine, 2: average, 3: largest combine, 4: overwrite or no combination defined (default)
95  char flag1; //< Flag for X-Translation (0: N/A, 1: specified)
96  char flag2; //< Flag for Y-Translation (0: N/A, 1: specified)
97  char flag3; //< Flag for Z-Translation (0: N/A, 1: specified)
98  char flag4; //< Flag for X-Rotation (0: N/A, 1: specified)
99  char flag5; //< Flag for Y-Rotation (0: N/A, 1: specified)
100  char flag6; //< Flag for Z-Rotation (0: N/A, 1: specified)
101  double value1; //< Value for X-Translation
102  double value2; //< Value for Y-Translation
103  double value3; //< Value for Z-Translation
104  double value4; //< Value for X-Rotation
105  double value5; //< Value for Y-Rotation
106  double value6; //< Value for Z-Rotation
107  };
108 
109  _data_ data;
110 
111  std::size_t getSizeOfData() const { return sizeof(_data_); }
112  const void * getDataPtr() const { return &data; }
113 
116  bzero(&data,sizeof(data));
117  }
118 
119  MoFEMErrorCode fill_data(const std::vector<char>& bc_data) {
121  //Fill data
122  if(bc_data.size()!=sizeof(data)) SETERRQ(PETSC_COMM_SELF,1,"data inconsistency");
123  memcpy(&data, &bc_data[0], sizeof(data));
125  }
126 
127  MoFEMErrorCode set_data(void *tag_ptr,unsigned int size) const {
129  if(size!=sizeof(data)) {
130  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"data inconsistency");
131  }
132  memcpy(tag_ptr, &data, size);
134  }
135 
136 
137  /*! \brief Print displacement bc data
138  */
139  friend std::ostream& operator<<(std::ostream& os,const DisplacementCubitBcData& e);
140 
141 };
142 
143 /*! \struct ForceCubitBcData
144  * \brief Definition of the force bc data structure
145  * \ingroup mofem_bc
146  */
148  struct __attribute__ ((packed)) _data_{
149  char name[5]; //< 5 characters for "Force"
150  char zero[3]; //< 3 zeros
151  double value1; //< Force magnitude
152  double value2; //< Moment magnitude
153  double value3; //< X-component of force direction vector
154  double value4; //< Y-component of force direction vector
155  double value5; //< Z-component of force direction vector
156  double value6; //< X-component of moment direction vector
157  double value7; //< Y-component of moment direction vector
158  double value8; //< Z-component of moment direction vector
159  char zero2; // 0
160  };
161 
162  _data_ data;
163  std::size_t getSizeOfData() const { return sizeof(_data_); }
164  const void * getDataPtr() const { return &data; }
165 
168  bzero(&data,sizeof(data));
169  }
170 
171  MoFEMErrorCode fill_data(const std::vector<char>& bc_data) {
173  //Fill data
174  if(bc_data.size()!=sizeof(data)) SETERRQ(PETSC_COMM_SELF,1,"data inconsistency");
175  memcpy(&data, &bc_data[0], sizeof(data));
177  }
178 
179  MoFEMErrorCode set_data(void *tag_ptr,unsigned int size) const {
181  if(size!=sizeof(data)) {
182  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"data inconsistency");
183  }
184  memcpy(tag_ptr, &data, size);
186  }
187 
188 
189  /*! \brief Print force bc data
190  */
191  friend std::ostream& operator<<(std::ostream& os,const ForceCubitBcData& e);
192 
193 };
194 
195 /*! \struct VelocityCubitBcData
196  * \brief Definition of the velocity bc data structure
197  * \ingroup mofem_bc
198  */
200  struct __attribute__ ((packed)) _data_{
201  char name[8]; //< 8 characters for "Velocity"
202  char pre1; //< Always zero
203  char pre2; //< pre-processing flags for modification of displacement bcs. They should not affect analysis, i.e. safe to ignore; 1: smallest combine, 2: average, 3: largest combine, 4: overwrite or no combination defined (default)
204  char flag1; //< Flag for X-Translation (0: N/A, 1: specified)
205  char flag2; //< Flag for Y-Translation (0: N/A, 1: specified)
206  char flag3; //< Flag for Z-Translation (0: N/A, 1: specified)
207  char flag4; //< Flag for X-Rotation (0: N/A, 1: specified)
208  char flag5; //< Flag for Y-Rotation (0: N/A, 1: specified)
209  char flag6; //< Flag for Z-Rotation (0: N/A, 1: specified)
210  double value1; //< Value for X-Translation
211  double value2; //< Value for Y-Translation
212  double value3; //< Value for Z-Translation
213  double value4; //< Value for X-Rotation
214  double value5; //< Value for Y-Rotation
215  double value6; //< Value for Z-Rotation
216  };
217 
218  _data_ data;
219  std::size_t getSizeOfData() const { return sizeof(_data_); }
220  const void * getDataPtr() const { return &data; }
221 
224  bzero(&data,sizeof(data));
225  }
226 
227  MoFEMErrorCode fill_data(const std::vector<char>& bc_data) {
229  //Fill data
230  if(bc_data.size()!=sizeof(data)) SETERRQ(PETSC_COMM_SELF,1,"data inconsistency");
231  memcpy(&data, &bc_data[0], sizeof(data));
233  }
234 
235  MoFEMErrorCode set_data(void *tag_ptr,unsigned int size) const {
237  if(size!=sizeof(data)) {
238  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"data inconsistency");
239  }
240  memcpy(tag_ptr, &data, size);
242  }
243 
244  /*! \brief Print velocity bc data
245  */
246  friend std::ostream& operator<<(std::ostream& os,const VelocityCubitBcData& e);
247 
248 };
249 
250 /*! \struct AccelerationCubitBcData
251  * \brief Definition of the acceleration bc data structure
252  * \ingroup mofem_bc
253  */
255  struct __attribute__ ((packed)) _data_{
256  char name[12]; //< 12 characters for "Acceleration"
257  char pre1; //< Always zero
258  char pre2; //< pre-processing flags for modification of displacement bcs. They should not affect analysis, i.e. safe to ignore; 1: smallest combine, 2: average, 3: largest combine, 4: overwrite or no combination defined (default)
259  char flag1; //< Flag for X-Translation (0: N/A, 1: specified)
260  char flag2; //< Flag for Y-Translation (0: N/A, 1: specified)
261  char flag3; //< Flag for Z-Translation (0: N/A, 1: specified)
262  char flag4; //< Flag for X-Rotation (0: N/A, 1: specified)
263  char flag5; //< Flag for Y-Rotation (0: N/A, 1: specified)
264  char flag6; //< Flag for Z-Rotation (0: N/A, 1: specified)
265  double value1; //< Value for X-Translation
266  double value2; //< Value for Y-Translation
267  double value3; //< Value for Z-Translation
268  double value4; //< Value for X-Rotation
269  double value5; //< Value for Y-Rotation
270  double value6; //< Value for Z-Rotation
271  };
272 
273  _data_ data;
274 
275  std::size_t getSizeOfData() const { return sizeof(_data_); }
276  const void * getDataPtr() const { return &data; }
277 
280  bzero(&data,sizeof(data));
281  }
282 
283  MoFEMErrorCode fill_data(const std::vector<char>& bc_data) {
285  //Fill data
286  if(bc_data.size()!=sizeof(data)) SETERRQ(PETSC_COMM_SELF,1,"data inconsistency");
287  memcpy(&data, &bc_data[0], sizeof(data));
289  }
290 
291  MoFEMErrorCode set_data(void *tag_ptr,unsigned int size) const {
293  if(size!=sizeof(data)) {
294  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"data inconsistency");
295  }
296  memcpy(tag_ptr, &data, size);
298  }
299 
300 
301  /*! \brief Print acceleration bc data
302  */
303  friend std::ostream& operator<<(std::ostream& os,const AccelerationCubitBcData& e);
304 
305 };
306 
307 /*! \struct TemperatureCubitBcData
308  * \brief Definition of the temperature bc data structure
309  * \ingroup mofem_bc
310  */
312  struct __attribute__ ((packed)) _data_{
313  char name[11]; //< 11 characters for "Temperature"
314  char pre1; //< This is always zero
315  char pre2; //< 0: temperature is not applied on thin shells (default); 1: temperature is applied on thin shells
316  char flag1; //< 0: N/A, 1: temperature value applied (not on thin shells)
317  char flag2; //< 0: N/A, 1: temperature applied on thin shell middle
318  char flag3; //< 0: N/A, 1: thin shell temperature gradient specified
319  char flag4; //< 0: N/A, 1: top thin shell temperature
320  char flag5; //< 0: N/A, 1: bottom thin shell temperature
321  char flag6; //< This is always zero
322  double value1; //< Temperature (default case - no thin shells)
323  double value2; //< Temperature for middle of thin shells
324  double value3; //< Temperature gradient for thin shells
325  double value4; //< Temperature for top of thin shells
326  double value5; //< Temperature for bottom of thin shells
327  double value6; //< This is always zero, i.e. ignore
328  };
329 
330  _data_ data;
331 
332  std::size_t getSizeOfData() const { return sizeof(_data_); }
333  const void * getDataPtr() const { return &data; }
334 
337  bzero(&data,sizeof(data));
338  }
339 
340  MoFEMErrorCode fill_data(const std::vector<char>& bc_data) {
342  //Fill data
343  if(bc_data.size()!=sizeof(data)) SETERRQ(PETSC_COMM_SELF,1,"data inconsistency");
344  memcpy(&data, &bc_data[0], sizeof(data));
346  }
347 
348  MoFEMErrorCode set_data(void *tag_ptr,unsigned int size) const {
350  if(size!=sizeof(data)) {
351  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"data inconsistency");
352  }
353  memcpy(tag_ptr, &data, size);
355  }
356 
357 
358  /*! \brief Print temperature bc data
359  */
360  friend std::ostream& operator<<(std::ostream& os,const TemperatureCubitBcData& e);
361  };
362 
363 /*! \struct PressureCubitBcData
364  * \brief Definition of the pressure bc data structure
365  * \ingroup mofem_bc
366  */
368  struct __attribute__ ((packed)) _data_{
369  char name[8]; //< 8 characters for "Pressure"
370  char flag1; //< This is always zero
371  char flag2; //< 0: Pressure is interpreted as pure pressure 1: pressure is interpreted as total force
372  double value1; //< Pressure value
373  char zero; //< This is always zero
374  };
375 
376  _data_ data;
377 
378  std::size_t getSizeOfData() const { return sizeof(_data_); }
379  const void * getDataPtr() const { return &data; }
380 
383  bzero(&data,sizeof(data));
384  }
385 
386  MoFEMErrorCode fill_data(const std::vector<char>& bc_data) {
388  //Fill data
389  if(bc_data.size()!=sizeof(data)) {
390  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"data inconsistency");
391  }
392  memcpy(&data, &bc_data[0], sizeof(data));
394  }
395 
396  MoFEMErrorCode set_data(void *tag_ptr,unsigned int size) const {
398  if(size!=sizeof(data)) {
399  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"data inconsistency");
400  }
401  memcpy(tag_ptr, &data, size);
403  }
404 
405  /*! \brief Print pressure bc data
406  */
407  friend std::ostream& operator<<(std::ostream& os,const PressureCubitBcData& e);
408 
409 };
410 
411 /*! \struct HeatFluxCubitBcData
412  * \brief Definition of the heat flux bc data structure
413  * \ingroup mofem_bc
414  */
416 
417  struct __attribute__ ((packed)) _data_ {
418  char name[8]; //< 8 characters for "HeatFlux" (no space)
419  char pre1; //< This is always zero
420  char pre2; //< 0: heat flux is not applied on thin shells (default); 1: heat flux is applied on thin shells
421  char flag1; //< 0: N/A, 1: normal heat flux case (i.e. single value, case without thin shells)
422  char flag2; //< 0: N/A, 1: Thin shell top heat flux specified
423  char flag3; //< 0: N/A, 1: Thin shell bottom heat flux specidied
424  double value1; //< Heat flux value for default case (no thin shells)
425  double value2; //< Heat flux (thin shell top)
426  double value3; //< Heat flux (thin shell bottom)
427  };
428 
429  _data_ data;
430 
431  std::size_t getSizeOfData() const { return sizeof(_data_); }
432  const void * getDataPtr() const { return &data; }
433 
436  bzero(&data,sizeof(data));
437  }
438 
439  MoFEMErrorCode fill_data(const std::vector<char>& bc_data) {
441  //Fill data
442  if(bc_data.size()!=sizeof(data)) SETERRQ(PETSC_COMM_SELF,1,"data inconsistency");
443  memcpy(&data, &bc_data[0], sizeof(data));
445  }
446 
447  MoFEMErrorCode set_data(void *tag_ptr,unsigned int size) const {
449  if(size!=sizeof(data)) {
450  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"data inconsistency");
451  }
452  memcpy(tag_ptr, &data, size);
454  }
455 
456  /*! \brief Print heat flux bc data
457  */
458  friend std::ostream& operator<<(std::ostream& os,const HeatFluxCubitBcData& e);
459 
460 };
461 
462 /*! \struct CfgCubitBcData
463  * \brief Definition of the cfd_bc data structure
464  * \ingroup mofem_bc
465  */
467  struct __attribute__ ((packed)) _data_{
468  char name[6]; //< 6 characters for "cfd_bc"
469  char zero; //< This is always zero
470  char type; //< This is the type of cfd_bc
471  };
472 
473  _data_ data;
474 
475  std::size_t getSizeOfData() const { return sizeof(_data_); }
476  const void * getDataPtr() const { return &data; }
477 
480  bzero(&data,sizeof(data));
481  }
482 
483  MoFEMErrorCode fill_data(const std::vector<char>& bc_data) {
485  //Fill data
486  if(bc_data.size()!=sizeof(data)) SETERRQ(PETSC_COMM_SELF,1,"data inconsistency");
487  memcpy(&data, &bc_data[0], sizeof(data));
489  }
490 
491  MoFEMErrorCode set_data(void *tag_ptr,unsigned int size) const {
493  if(size!=sizeof(data)) {
494  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"data inconsistency");
495  }
496  memcpy(tag_ptr, &data, size);
498  }
499 
500  /*! \brief Print cfd_bc data
501  */
502  friend std::ostream& operator<<(std::ostream& os,const CfgCubitBcData& e);
503 
504 };
505 
506 }
507 
508 #endif // __BCMULTIINDICES_HPP__
Generic bc data structure.
Definition: BCData.hpp:30
const void * getDataPtr() const
get pointer to data structure
Definition: BCData.hpp:276
Definition of the temperature bc data structure.
Definition: BCData.hpp:311
MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
Definition: BCData.hpp:491
friend std::ostream & operator<<(std::ostream &os, const TemperatureCubitBcData &e)
Print temperature bc data.
struct __attribute__((packed)) _data_
Definition: BCData.hpp:200
friend std::ostream & operator<<(std::ostream &os, const HeatFluxCubitBcData &e)
Print heat flux bc data.
MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
Definition: BCData.hpp:235
MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
Definition: BCData.hpp:291
GenericCubitBcData(const CubitBCType type)
Definition: BCData.hpp:76
struct __attribute__((packed)) _data_
Definition: BCData.hpp:467
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
friend std::ostream & operator<<(std::ostream &os, const CfgCubitBcData &e)
Print cfd_bc data.
MoFEMErrorCode fill_data(const std::vector< char > &bc_data)
get data from structure
Definition: BCData.hpp:171
const void * getDataPtr() const
get pointer to data structure
Definition: BCData.hpp:333
const CubitBCType tYpe
Type of boundary condition.
Definition: BCData.hpp:68
std::size_t getSizeOfData() const
get data structure size
Definition: BCData.hpp:378
friend std::ostream & operator<<(std::ostream &os, const ForceCubitBcData &e)
Print force bc data.
std::size_t getSizeOfData() const
get data structure size
Definition: BCData.hpp:475
friend std::ostream & operator<<(std::ostream &os, const DisplacementCubitBcData &e)
Print displacement bc data.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
Definition: BCData.hpp:179
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
Definition of the force bc data structure.
Definition: BCData.hpp:147
struct __attribute__((packed)) _data_
Definition: BCData.hpp:368
Definition of the displacement bc data structure.
Definition: BCData.hpp:87
virtual ~GenericCubitBcData()
Definition: BCData.hpp:79
const void * getDataPtr() const
get pointer to data structure
Definition: BCData.hpp:379
std::size_t getSizeOfData() const
get data structure size
Definition: BCData.hpp:275
const void * getDataPtr() const
get pointer to data structure
Definition: BCData.hpp:476
const void * getDataPtr() const
get pointer to data structure
Definition: BCData.hpp:164
MoFEMErrorCode fill_data(const std::vector< char > &bc_data)
get data from structure
Definition: BCData.hpp:119
MoFEMErrorCode fill_data(const std::vector< char > &bc_data)
get data from structure
Definition: BCData.hpp:340
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
Definition of the acceleration bc data structure.
Definition: BCData.hpp:254
friend std::ostream & operator<<(std::ostream &os, const VelocityCubitBcData &e)
Print velocity bc data.
std::size_t getSizeOfData() const
get data structure size
Definition: BCData.hpp:163
Definition of the cfd_bc data structure.
Definition: BCData.hpp:466
struct __attribute__((packed)) _data_
Definition: BCData.hpp:312
const void * getDataPtr() const
get pointer to data structure
Definition: BCData.hpp:220
virtual MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
Definition: BCData.hpp:50
std::size_t getSizeOfData() const
get data structure size
Definition: BCData.hpp:219
MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
Definition: BCData.hpp:447
virtual const CubitBCType & getType() const
get data type
Definition: BCData.hpp:74
struct __attribute__((packed)) _data_
attributes of DisplacementCubitBcData
Definition: BCData.hpp:91
MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
Definition: BCData.hpp:127
MoFEMErrorCode fill_data(const std::vector< char > &bc_data)
get data from structure
Definition: BCData.hpp:283
struct __attribute__((packed)) _data_
Definition: BCData.hpp:417
std::size_t getSizeOfData() const
get data structure size
Definition: BCData.hpp:111
MoFEMErrorCode fill_data(const std::vector< char > &bc_data)
get data from structure
Definition: BCData.hpp:439
MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
Definition: BCData.hpp:396
MoFEMErrorCode fill_data(const std::vector< char > &bc_data)
get data from structure
Definition: BCData.hpp:386
std::bitset< 32 > CubitBCType
Definition: Types.hpp:63
std::size_t getSizeOfData() const
get data structure size
Definition: BCData.hpp:431
virtual std::size_t getSizeOfData() const =0
get data structure size
friend std::ostream & operator<<(std::ostream &os, const AccelerationCubitBcData &e)
Print acceleration bc data.
const void * getDataPtr() const
get pointer to data structure
Definition: BCData.hpp:112
struct __attribute__((packed)) _data_
Definition: BCData.hpp:148
friend std::ostream & operator<<(std::ostream &os, const PressureCubitBcData &e)
Print pressure bc data.
MoFEMErrorCode fill_data(const std::vector< char > &bc_data)
get data from structure
Definition: BCData.hpp:227
virtual MoFEMErrorCode fill_data(const std::vector< char > &bc_data)
get data from structure
Definition: BCData.hpp:38
virtual const void * getDataPtr() const =0
get pointer to data structure
Definition of the heat flux bc data structure.
Definition: BCData.hpp:415
MoFEMErrorCode fill_data(const std::vector< char > &bc_data)
get data from structure
Definition: BCData.hpp:483
struct __attribute__((packed)) _data_
Definition: BCData.hpp:255
Definition of the pressure bc data structure.
Definition: BCData.hpp:367
const void * getDataPtr() const
get pointer to data structure
Definition: BCData.hpp:432
std::size_t getSizeOfData() const
get data structure size
Definition: BCData.hpp:332
MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
Definition: BCData.hpp:348
Definition of the velocity bc data structure.
Definition: BCData.hpp:199