v0.9.0
MaterialBlocks.hpp
Go to the documentation of this file.
1 /** \file MaterialBlocks.hpp
2  * \brief Data structures for Meshset/Blocsk with material data
3  *
4  * Notes:
5  * - use BLOCK_ATTRIBUTES tag to store data structures
6  * - data structures are tags of meshsets
7 
8  * MoFEM is free software: you can redistribute it and/or modify it under
9  * the terms of the GNU Lesser General Public License as published by the
10  * Free Software Foundation, either version 3 of the License, or (at your
11  * option) any later version.
12  *
13  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
20 */
21 
22 #ifndef __MATERIALBLOCKS_HPP__
23 #define __MATERIALBLOCKS_HPP__
24 
25 namespace MoFEM {
26 
27 /*! \struct GenericAttributeData
28  * \brief Generic attribute data structure
29  */
31 
32  /**
33  * \brief get data from structure
34  * @param attributes vector of doubles
35  * @return error code
36  */
37  virtual MoFEMErrorCode fill_data(const std::vector<double> &attributes) {
39  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
40  "It makes no sense for the generic attribute 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, MOFEM_DATA_INCONSISTENCY,
53  "It makes no sense for the generic attribute type");
55  }
56 
57  const CubitBCType tYpe; ///< Type of data (f.e. MAT_ELATIC)
58 
59  /**
60  * \brief get data type
61  * @return data type, see CubitBC
62  */
63  virtual const CubitBCType &getType() const { return tYpe; }
64 
65  unsigned int minNumberOfAtributes; ///< minimal number of attributes
66 
67  /**
68  * \brief get minimal number of attributes which blockset has to have
69  * @return number of minimal data attributes
70  */
71  virtual unsigned int getMinMumberOfAtributes() const {
72  return minNumberOfAtributes;
73  }
74 
75  /**
76  * \brief get data structure size
77  * @return size of structure in bytes
78  */
79  virtual std::size_t getSizeOfData() const = 0;
80 
81  /**
82  * \brief get pointer to data structure
83  * @return pointer
84  */
85  virtual const void *getDataPtr() const = 0;
86 
88  const unsigned int min_number_of_atributes)
89  : tYpe(type), minNumberOfAtributes(min_number_of_atributes) {}
90 };
91 
92 /** \brief Arbitrary block attributes data structure
93  */
95 
96  /** \brief generic block attributes
97  *
98  */
99  struct __attribute__((packed)) _data_ {
100  double User1; // User attribute 1
101  double User2; // User attribute 2
102  double User3; // User attribute 3
103  double User4; // User attribute 4
104  double User5; // User attribute 5
105  double User6; // User attribute 6
106  double User7; // User attribute 7
107  double User8; // User attribute 8
108  double User9; // User attribute 9
109  double User10; // User attribute 10
110  };
111 
112  _data_ data;
113 
114  std::size_t getSizeOfData() const { return sizeof(_data_); }
115  const void *getDataPtr() const { return &data; }
116 
118  bzero(&data, sizeof(data));
119  }
120 
121  MoFEMErrorCode fill_data(const std::vector<double> &attributes) {
123  if (8 * attributes.size() > sizeof(data)) {
124  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
125  "data inconsistency, please review the number of material "
126  "properties defined");
127  }
128  bzero(&data, sizeof(data));
129  memcpy(&data, &attributes[0], 8 * attributes.size());
131  }
132  MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const {
134  if (size > sizeof(data)) {
135  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
136  "data inconsistency, please review the number of material "
137  "properties defined");
138  }
139  memcpy(tag_ptr, &data, size);
141  }
142 
143  /*! \brief Print data
144  */
145  friend std::ostream &operator<<(std::ostream &os,
146  const BlockSetAttributes &e);
147 };
148 
149 /*! \struct Mat_Elastic
150  * \brief Elastic material data structure
151  */
153 
154  /** \brief block tag data structute
155  *
156  */
157  struct __attribute__((packed)) _data_ {
158  double Young; ///< Young's modulus
159  double Poisson; ///< Poisson's ratio
160  double ThermalExpansion; ///< Thermal expansion
161  double User1; // User attribute 2 // For some models is reserved for density
162  double User2; // User attribute 3
163  double User3; // User attribute 4
164  double User4; // User attribute 5
165  double User5; // User attribute 6
166  double User6; // User attribute 7
167  double User7; // User attribute 8
168  };
169 
170  _data_ data;
171  std::size_t getSizeOfData() const { return sizeof(data); };
172  const void *getDataPtr() const { return &data; }
173 
175  bzero(&data, sizeof(data));
176  };
177 
178  MoFEMErrorCode fill_data(const std::vector<double> &attributes) {
180  if (attributes.size() < minNumberOfAtributes) {
181  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
182  "Young modulus and/or Poisson ratio is not defined. (top tip: "
183  "check number of ELASTIC block attributes) %d !< %d",
184  attributes.size(), minNumberOfAtributes);
185  }
186  if (8 * attributes.size() > sizeof(data)) {
187  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
188  "data inconsistency, please review the number of material "
189  "properties defined");
190  }
191  bzero(&data, sizeof(data));
192  memcpy(&data, &attributes[0], 8 * attributes.size());
194  }
195  MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const {
197  if (size > sizeof(data)) {
198  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
199  "data inconsistency, please review the number of material "
200  "properties defined");
201  }
202  memcpy(tag_ptr, &data, size);
204  }
205 
206  /*! \brief Print Mat_Elastic data
207  */
208  friend std::ostream &operator<<(std::ostream &os, const Mat_Elastic &e);
209 };
210 
211 /*! \struct Mat_Thermal
212  * \brief Thermal material data structure
213  */
215 
216  /** \brief thermal block attributes
217  *
218  */
219  struct __attribute__((packed)) _data_ {
220  double Conductivity; ///< Thermal conductivity
221  double HeatCapacity; ///< Heat Capacity
222  double User2; // User attribute 2
223  double User3; // User attribute 3
224  double User4; // User attribute 4
225  double User5; // User attribute 5
226  double User6; // User attribute 6
227  double User7; // User attribute 7
228  double User8; // User attribute 8
229  double User9; // User attribute 9
230  };
231 
232  _data_ data;
233  std::size_t getSizeOfData() const { return sizeof(data); }
234  const void *getDataPtr() const { return &data; }
235 
237  bzero(&data, sizeof(data));
238  }
239 
240  MoFEMErrorCode fill_data(const std::vector<double> &attributes) {
242  if (attributes.size() < minNumberOfAtributes) {
243  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
244  "Thermal conductivity is not defined. (top tip: check number of "
245  "THERMAL block atributes)");
246  }
247  if (8 * attributes.size() > sizeof(data)) {
248  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
249  "data inconsistency, please review the number of material "
250  "properties defined");
251  }
252  bzero(&data, sizeof(data));
253  memcpy(&data, &attributes[0], 8 * attributes.size());
255  }
256  MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const {
258  if (size > sizeof(data)) {
259  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
260  "data inconsistency, please review the number of material "
261  "properties defined");
262  }
263  memcpy(tag_ptr, &data, size);
265  }
266 
267  /*! \brief Print Mat_Elastic data
268  */
269  friend std::ostream &operator<<(std::ostream &os, const Mat_Thermal &e);
270 };
271 
272 /*! \struct Mat_Moisture
273  * \brief moisture transport material data structure
274  */
275 
277 
278  /** \brief moisture block attributes
279  *
280  */
281  struct __attribute__((packed)) _data_ {
282  double Diffusivity; ///< moisture diffusivity
283  double Viscosity; ///< Viscosity of water
284  double Permeability; ///< Permeability of material
285  double User3; // User attribute 3
286  double User4; // User attribute 4
287  double User5; // User attribute 5
288  double User6; // User attribute 6
289  double User7; // User attribute 7
290  double User8; // User attribute 8
291  double User9; // User attribute 9
292  };
293 
294  _data_ data;
295  std::size_t getSizeOfData() const { return sizeof(data); }
296  const void *getDataPtr() const { return &data; }
297 
299  bzero(&data, sizeof(data));
300  }
301 
302  MoFEMErrorCode fill_data(const std::vector<double> &attributes) {
304  if (attributes.size() < minNumberOfAtributes) {
305  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
306  "moisture diffusivity is not defined. (top tip: check number of "
307  "MOISTURE block atributes)");
308  }
309  if (8 * attributes.size() > sizeof(data)) {
310  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
311  "data inconsistency, please review the number of material "
312  "properties defined");
313  }
314  bzero(&data, sizeof(data));
315  memcpy(&data, &attributes[0], 8 * attributes.size());
317  }
318 
319  /*! \brief Print Mat_Elastic data
320  */
321  friend std::ostream &operator<<(std::ostream &os, const Mat_Moisture &e);
322 };
323 
324 /** \brief Body force data structure
325  */
327 
328  /** \brief body forces
329  *
330  */
331  struct __attribute__((packed)) _data_ {
332  double density; ///< material density
333  double acceleration_x; ///< acceleration X
334  double acceleration_y; ///< acceleration Y
335  double acceleration_z; ///< acceleration Z
336  double User4; // User attribute 4
337  double User5; // User attribute 5
338  double User6; // User attribute 6
339  double User7; // User attribute 7
340  double User8; // User attribute 8
341  };
342 
343  _data_ data;
344  std::size_t getSizeOfData() const { return sizeof(data); }
345  const void *getDataPtr() const { return &data; }
346 
348 
349  MoFEMErrorCode fill_data(const std::vector<double> &attributes) {
351  if (attributes.size() < minNumberOfAtributes) {
352  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
353  "Material density and/or acceleration is not defined. (top tip: "
354  "check number of THERMAL block atributes)");
355  }
356  if (8 * attributes.size() > sizeof(data)) {
357  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
358  "data inconsistency, please review the number of material "
359  "properties defined");
360  }
361  bzero(&data, sizeof(data));
362  memcpy(&data, &attributes[0], 8 * attributes.size());
364  }
365  MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const {
367  if (size > sizeof(data)) {
368  SETERRQ(PETSC_COMM_SELF, 1,
369  "data inconsistency, please review the number of material "
370  "properties defined");
371  }
372  memcpy(tag_ptr, &data, size);
374  }
375 
376  /*! \brief Print Mat_Elastic data
377  */
378  friend std::ostream &operator<<(std::ostream &os, const Block_BodyForces &e);
379 };
380 
381 /*! \struct Mat_Elastic_TransIso
382  * \brief Transverse Isotropic material data structure
383  */
385 
386  /** \brief transverse isotropic
387  *
388  */
389  struct __attribute__((packed)) _data_ {
390  double Youngp; ///< Young's modulus in xy plane (Ep)
391  double Youngz; ///< Young's modulus in z-direction (Ez)
392  double Poissonp; ///< Poisson's ratio in xy plane (vp)
393  double Poissonpz; ///< Poisson's ratio in z-direction (vpz)
394  double Shearzp; ///< Shear modulus in z-direction (Gzp)
395  };
396 
397  _data_ data;
398  std::size_t getSizeOfData() const { return sizeof(data); }
399  const void *getDataPtr() const { return &data; }
400 
402  bzero(&data, sizeof(data));
403  }
404 
405  MoFEMErrorCode fill_data(const std::vector<double> &attributes) {
407  // Fill data
408  if (attributes.size() < minNumberOfAtributes) {
409  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
410  "All material data not defined");
411  }
412  if (8 * attributes.size() != sizeof(data)) {
413  SETERRQ(PETSC_COMM_SELF, 1,
414  "data inconsistency, please review the number of material "
415  "properties defined");
416  }
417  memcpy(&data, &attributes[0], sizeof(data));
418  bzero(&data, sizeof(data));
419  memcpy(&data, &attributes[0], 8 * attributes.size());
420 
422  }
423  MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const {
425  if (size > sizeof(data)) {
426  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
427  "data inconsistency, please review the number of material "
428  "properties defined");
429  }
430  memcpy(tag_ptr, &data, size);
432  }
433 
434  /*! \brief Print Mat_Elastic_TransIso data
435  */
436  friend std::ostream &operator<<(std::ostream &os,
437  const Mat_Elastic_TransIso &e);
438 };
439 
440 /*! \struct Mat_Interf
441  * \brief Linear interface data structure
442  */
444 
445  /** \brief inteface
446  *
447  */
448  struct __attribute__((packed)) _data_ {
449  double alpha; ///< Elastic modulus multiplier
450  double beta; ///< Damage Coupling multiplier between normal and shear
451  ///< (g=sqrt(gn^2 + beta(gt1^2 + gt2^2)))
452  double ft; ///< Maximum stress of crack
453  double Gf; ///< Fracture Energy
454  };
455 
456  _data_ data;
457  std::size_t getSizeOfData() const { return sizeof(data); }
458  const void *getDataPtr() const { return &data; }
459 
461  bzero(&data, sizeof(data));
462  }
463 
464  virtual MoFEMErrorCode fill_data(const std::vector<double> &attributes) {
466  // Fill data
467  if (8 * attributes.size() != sizeof(data)) {
468  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
469  "data inconsistency, please review the number of material "
470  "properties defined");
471  }
472  memcpy(&data, &attributes[0], sizeof(data));
474  }
475  virtual MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const {
477  if (size > sizeof(data)) {
478  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
479  "data inconsistency, please review the number of material "
480  "properties defined");
481  }
482  memcpy(tag_ptr, &data, size);
484  }
485 
486  /*! \brief Print Mat_Interf data
487  */
488  friend std::ostream &operator<<(std::ostream &os, const Mat_Interf &e);
489 };
490 
491 /** \brief Mat_Elastic with Fibres
492  * \brief Elastic material data structure
493  */
495 
496  /** \brief Hotzapler soft tissue
497  *
498  */
499  struct __attribute__((packed)) _data_ {
500  double Young; ///< Young's modulus
501  double Poisson; ///< Poisson's ratio
502  double k1; // User attribute 1
503  double k2; // User attribute 2
504  double a0x; // User attribute 3
505  double a0y; // User attribute 4
506  double a0z; // User attribute 5
507  double a1x; // User attribute 6
508  double a1y; // User attribute 7
509  double a1z; // User attribute 8
510  };
511 
512  _data_ data;
513  std::size_t getSizeOfData() const { return sizeof(data); }
514  const void *getDataPtr() const { return &data; }
515 
517  bzero(&data, sizeof(data));
518  }
519 
520  MoFEMErrorCode fill_data(const std::vector<double> &attributes) {
522  if (attributes.size() < minNumberOfAtributes) {
523  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
524  "All material data not defined");
525  }
526  if (8 * attributes.size() > sizeof(data)) {
527  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
528  "data inconsistency, please review the number of material "
529  "properties defined");
530  }
531  bzero(&data, sizeof(data));
532  memcpy(&data, &attributes[0], 8 * attributes.size());
534  }
535 
536  /*! \brief Print Mat_Elastic data
537  */
538  friend std::ostream &operator<<(std::ostream &os,
540 };
541 
542 } // namespace MoFEM
543 
544 #endif // __MATERIALBLOCKS_HPP__
const void * getDataPtr() const
get pointer to data structure
friend std::ostream & operator<<(std::ostream &os, const Mat_Elastic_EberleinHolzapfel1 &e)
Print Mat_Elastic data.
const void * getDataPtr() const
get pointer to data structure
const void * getDataPtr() const
get pointer to data structure
std::size_t getSizeOfData() const
get data structure size
std::size_t getSizeOfData() const
get data structure size
block name is "MAT_MOISTURE"
Definition: definitions.h:226
MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
virtual MoFEMErrorCode fill_data(const std::vector< double > &attributes)
get data from structure
MoFEMErrorCode fill_data(const std::vector< double > &attributes)
get data from structure
MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
friend std::ostream & operator<<(std::ostream &os, const Mat_Elastic &e)
Print Mat_Elastic data.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
virtual const CubitBCType & getType() const
get data type
struct __attribute__((packed)) _data_
thermal block attributes
std::size_t getSizeOfData() const
get data structure size
Elastic material data structure.
virtual std::size_t getSizeOfData() const =0
get data structure size
Transverse Isotropic material data structure.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
struct __attribute__((packed)) _data_
transverse isotropic
std::size_t getSizeOfData() const
get data structure size
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
friend std::ostream & operator<<(std::ostream &os, const Block_BodyForces &e)
Print Mat_Elastic data.
virtual unsigned int getMinMumberOfAtributes() const
get minimal number of attributes which blockset has to have
unsigned int minNumberOfAtributes
minimal number of attributes
MoFEMErrorCode fill_data(const std::vector< double > &attributes)
get data from structure
struct __attribute__((packed)) _data_
inteface
std::size_t getSizeOfData() const
get data structure size
MoFEMErrorCode fill_data(const std::vector< double > &attributes)
get data from structure
virtual const void * getDataPtr() const =0
get pointer to data structure
struct __attribute__((packed)) _data_
Hotzapler soft tissue.
friend std::ostream & operator<<(std::ostream &os, const Mat_Elastic_TransIso &e)
Print Mat_Elastic_TransIso data.
const CubitBCType tYpe
Type of data (f.e. MAT_ELATIC)
struct __attribute__((packed)) _data_
block tag data structute
Thermal material data structure.
virtual MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
std::size_t getSizeOfData() const
get data structure size
GenericAttributeData(const CubitBCType type, const unsigned int min_number_of_atributes)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
Linear interface data structure.
block name is "MAT_THERMAL"
Definition: definitions.h:224
friend std::ostream & operator<<(std::ostream &os, const Mat_Thermal &e)
Print Mat_Elastic data.
std::size_t getSizeOfData() const
get data structure size
block name is "BODY_FORCES"
Definition: definitions.h:225
virtual MoFEMErrorCode fill_data(const std::vector< double > &attributes)
get data from structure
MoFEMErrorCode fill_data(const std::vector< double > &attributes)
get data from structure
friend std::ostream & operator<<(std::ostream &os, const Mat_Interf &e)
Print Mat_Interf data.
Body force data structure.
struct __attribute__((packed)) _data_
body forces
const void * getDataPtr() const
get pointer to data structure
const void * getDataPtr() const
get pointer to data structure
virtual MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
Generic attribute data structure.
block name is "MAT_ELASTIC"
Definition: definitions.h:222
std::size_t getSizeOfData() const
get data structure size
struct __attribute__((packed)) _data_
generic block attributes
MoFEMErrorCode fill_data(const std::vector< double > &attributes)
get data from structure
Arbitrary block attributes data structure.
friend std::ostream & operator<<(std::ostream &os, const Mat_Moisture &e)
Print Mat_Elastic data.
std::bitset< 32 > CubitBCType
Definition: Types.hpp:63
const void * getDataPtr() const
get pointer to data structure
MoFEMErrorCode fill_data(const std::vector< double > &attributes)
get data from structure
moisture transport material data structure
const void * getDataPtr() const
get pointer to data structure
const void * getDataPtr() const
get pointer to data structure
MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
MoFEMErrorCode fill_data(const std::vector< double > &attributes)
get data from structure
struct __attribute__((packed)) _data_
moisture block attributes
friend std::ostream & operator<<(std::ostream &os, const BlockSetAttributes &e)
Print data.
MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure
MoFEMErrorCode set_data(void *tag_ptr, unsigned int size) const
set data on structure