~ubuntu-branches/ubuntu/trusty/rheolef/trusty-proposed

« back to all changes in this revision

Viewing changes to nfem/lib/fem_helper.h

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2010-06-12 09:08:59 UTC
  • Revision ID: james.westby@ubuntu.com-20100612090859-8gpm2gc7j3ab43et
Tags: upstream-5.89
ImportĀ upstreamĀ versionĀ 5.89

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _RHEO_FEM_H
 
2
#define _RHEO_FEM_H
 
3
///
 
4
/// This file is part of Rheolef.
 
5
///
 
6
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
 
7
///
 
8
/// Rheolef is free software; you can redistribute it and/or modify
 
9
/// it under the terms of the GNU General Public License as published by
 
10
/// the Free Software Foundation; either version 2 of the License, or
 
11
/// (at your option) any later version.
 
12
///
 
13
/// Rheolef is distributed in the hope that it will be useful,
 
14
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
/// GNU General Public License for more details.
 
17
///
 
18
/// You should have received a copy of the GNU General Public License
 
19
/// along with Rheolef; if not, write to the Free Software
 
20
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
21
/// 
 
22
/// =========================================================================
 
23
 
 
24
//! Helps the management of the finite element method.
 
25
//! Helps the geometry coordinate system.
 
26
//! Helps fields that have tensor value : 
 
27
//! doubles indices (i,j) are mapped to single index depending upon
 
28
//! the case : symmetric tensor, axisymmetric problems with extra 
 
29
//! theta-theta tensor component or tridimensionnal case.
 
30
//! This class is used internally by field and space classes.
 
31
//! It contains no data, only typedefs and member functions.
 
32
 
 
33
#include "rheolef/compiler.h"
 
34
 
 
35
class fem_helper {
 
36
public:
 
37
// -------------------------------------------------------------
 
38
// coordinate system helper
 
39
// -------------------------------------------------------------
 
40
 
 
41
// typedefs and static data:
 
42
 
 
43
  typedef size_t size_type;
 
44
 
 
45
  typedef enum {
 
46
          cartesian       = 0,
 
47
          axisymmetric_rz = 1,
 
48
          axisymmetric_zr = 2,
 
49
          max_coord_sys   = 3
 
50
  } coordinate_type;
 
51
 
 
52
  static const char* coord_sys_table [max_coord_sys];
 
53
 
 
54
// static members:
 
55
 
 
56
  static coordinate_type coordinate_system      (std::string sys_coord);
 
57
  static std::string     coordinate_system_name (coordinate_type);
 
58
  static void check_coord_sys_and_dimension     (coordinate_type, size_type d);
 
59
 
 
60
// -------------------------------------------------------------
 
61
// valued field helper
 
62
// -------------------------------------------------------------
 
63
 
 
64
// typedefs and static data:
 
65
  
 
66
  typedef enum {
 
67
          scalar                 = 0,
 
68
          vectorial              = 1,
 
69
          tensorial              = 2, // symmetric, D_ij
 
70
          unsymmetric_tensorial  = 3,
 
71
          tensorial_4            = 4, // symmetric, A_ijkl
 
72
          hybrid                 = 5,
 
73
          max_valued_field       = 6
 
74
  } valued_field_type;
 
75
 
 
76
  // Note: 3 symmetries for 4-order tensors
 
77
  //     A_ijkl=A_ijlk, A_ijkl=A_jikl & A_ijkl=Aklij
 
78
  // => 6 components in 2d, 21 in 3d and 10 in 2d-axisymmetric(rz)
 
79
 
 
80
  struct pair_size_type {
 
81
          size_type first;
 
82
          size_type second;
 
83
  };
 
84
  struct double_pair_size_type {
 
85
          pair_size_type first;
 
86
          pair_size_type second;
 
87
  };
 
88
  static pair_size_type make_pair_size(size_type a, size_type b);
 
89
  static double_pair_size_type make_double_pair_size(
 
90
          size_type a, size_type b, size_type c, size_type d);
 
91
 
 
92
  static const char*    valued_field_table [max_valued_field];
 
93
 
 
94
  static size_type      unsymmetric_tensor_index [3][3];
 
95
  static pair_size_type unsymmetric_tensor_subscript      [9];
 
96
  static const char*    unsymmetric_tensor_subscript_name [9];
 
97
 
 
98
  static size_type        symmetric_tensor_index [3][3];
 
99
  static pair_size_type   symmetric_tensor_subscript      [6];
 
100
  static const char*      symmetric_tensor_subscript_name [6];
 
101
 
 
102
  static size_type             symmetric_tensor4_index [6][6];
 
103
  static double_pair_size_type symmetric_tensor4_subscript      [21];
 
104
  static const char*           symmetric_tensor4_subscript_name [21];
 
105
  static double_pair_size_type symmetric_tensor4_subscript_rz      [10];
 
106
  static const char*           symmetric_tensor4_subscript_rz_name [10];
 
107
 
 
108
// static members:
 
109
  
 
110
  static valued_field_type valued_field      (std::string valued);
 
111
  static std::string       valued_field_name (valued_field_type);
 
112
 
 
113
  static size_type tensor_index (std::string valued, std::string sys_coord, size_type i, size_type j);
 
114
  static size_type tensor_index (valued_field_type, coordinate_type, size_type i, size_type j);
 
115
 
 
116
  static pair_size_type tensor_subscript      (valued_field_type, coordinate_type, size_type i_comp);
 
117
  static std::string    tensor_subscript_name (valued_field_type, coordinate_type, size_type i_comp);
 
118
  static pair_size_type tensor_subscript      (std::string valued, std::string sys_coord, size_type i_comp);
 
119
  static std::string    tensor_subscript_name (std::string valued, std::string sys_coord, size_type i_comp);
 
120
  
 
121
  static size_type tensor4_index (std::string valued, std::string sys_coord,
 
122
                  size_type i, size_type j, size_type k, size_type l);
 
123
  static size_type tensor4_index (valued_field_type, coordinate_type,
 
124
                  size_type i, size_type j, size_type k, size_type l);
 
125
  
 
126
  static double_pair_size_type tensor4_subscript      (valued_field_type, coordinate_type, size_type i_comp);
 
127
  static std::string           tensor4_subscript_name (valued_field_type, coordinate_type, size_type i_comp);
 
128
  static double_pair_size_type tensor4_subscript      (std::string valued, std::string sys_coord, size_type i_comp);
 
129
  static std::string           tensor4_subscript_name (std::string valued, std::string sys_coord, size_type i_comp);
 
130
 
 
131
// -------------------------------------------------------------
 
132
// approximation name -> basis and numbering names
 
133
// -------------------------------------------------------------
 
134
  static std::string basis_name (std::string approx_name);
 
135
  static std::string numbering_name (std::string approx_name);
 
136
};
 
137
#endif // _RHEO_FEM_H