2
/// This file is part of Rheolef.
4
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
6
/// Rheolef is free software; you can redistribute it and/or modify
7
/// it under the terms of the GNU General Public License as published by
8
/// the Free Software Foundation; either version 2 of the License, or
9
/// (at your option) any later version.
11
/// Rheolef is distributed in the hope that it will be useful,
12
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
/// GNU General Public License for more details.
16
/// You should have received a copy of the GNU General Public License
17
/// along with Rheolef; if not, write to the Free Software
18
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
/// =========================================================================
23
#include "rheolef/space_constant.h"
25
namespace rheolef { namespace space_constant {
27
// ---------------------------------------------------------------------------
28
// valued: for multi-component field support
29
// ---------------------------------------------------------------------------
32
valued_id [last_valued] = {
41
valued_name (valued_type valued_tag)
43
if (valued_tag < last_valued) return valued_id [valued_tag];
44
error_macro ("invalid valued tag = " << valued_tag);
45
return valued_id [0]; // not reached
48
valued_tag (const std::string& name)
50
for (size_t valued_tag = 0; valued_tag < last_valued; valued_tag++) {
51
if (valued_id[valued_tag] == name) return valued_type(valued_tag);
53
error_macro ("invalid valued `" << name << "'");
54
return scalar; // not reached
56
// ---------------------------------------------------------------------------
57
// coordinate system helper
58
// ---------------------------------------------------------------------------
61
coord_sys_table [last_coord_sys] = {
67
coordinate_system_name (coordinate_type i)
69
assert_macro (i < last_coord_sys, "invalid coordinate_type " << i);
70
return coord_sys_table [i];
73
coordinate_system (std::string sys_coord)
75
for (size_type i = 0; i < last_coord_sys; i++)
76
if (sys_coord == coord_sys_table[i]) return coordinate_type(i);
77
error_macro ("unexpected coordinate system `" << sys_coord << "'");
78
return last_coord_sys;
81
check_coord_sys_and_dimension (coordinate_type i, size_type d)
83
assert_macro (i < last_coord_sys, "invalid coordinate_type " << i);
84
check_macro (!((i == axisymmetric_rz || i == axisymmetric_zr) && d > 2),
85
"inconsistent `" << coord_sys_table[i]
86
<< "' coordinate system for " << d << "D geometry");
88
// ---------------------------------------------------------------------------------
89
// symmetric & unsymmetric 2-tensors field-valued support
90
// ---------------------------------------------------------------------------------
93
symmetric_tensor_index [3][3] = {
99
std::pair<size_type,size_type>
100
symmetric_tensor_subscript [6] = {
110
symmetric_tensor_subscript_name [6] = {
120
unsymmetric_tensor_index [3][3] = {
126
std::pair<size_type,size_type>
127
unsymmetric_tensor_subscript [9] = {
140
unsymmetric_tensor_subscript_name [9] = {
153
valued_type valued_tag,
155
coordinate_type sys_coord)
157
switch (valued_tag) {
158
case vector: return d;
159
case scalar: return 0;
160
case tensor4: { // A_ijkl with A_ijkl=A_jikl, A_ijkl=A_ijlk and A_ijkl=A_klij
161
if ((sys_coord == axisymmetric_rz)||(sys_coord == axisymmetric_zr)) {
162
return 10; // add all the theta,theta components
171
if ((sys_coord == axisymmetric_rz)||(sys_coord == axisymmetric_zr)) {
172
return 4; // add the \tau_{\theta,\theta}" component
176
case unsymmetric_tensor: {
177
if ((sys_coord == axisymmetric_rz)||(sys_coord == axisymmetric_zr)) {
183
error_macro ("unsupported valued space `" << valued_name(valued_tag) << "'");
184
return 0; // not reached
190
const std::string& valued,
192
coordinate_type sys_coord)
194
return n_component (valued_tag(valued), d, sys_coord);
198
valued_type valued_tag,
199
coordinate_type sys_coord,
203
if (valued_tag == unsymmetric_tensor) {
204
if ((sys_coord == axisymmetric_rz || sys_coord == axisymmetric_zr)
207
return unsymmetric_tensor_index [i][j];
209
if ((sys_coord == axisymmetric_rz || sys_coord == axisymmetric_zr)
212
return symmetric_tensor_index [i][j];
218
std::string sys_coord,
222
return tensor_index (valued_tag(valued), coordinate_system(sys_coord), i, j);
224
std::pair<size_type,size_type>
226
valued_type valued_tag,
227
coordinate_type sys_coord,
230
if (valued_tag == unsymmetric_tensor) {
231
if ((sys_coord == axisymmetric_rz || sys_coord == axisymmetric_zr)
233
return std::pair<size_type,size_type>(2,2);
234
return unsymmetric_tensor_subscript [i_comp];
236
if ((sys_coord == axisymmetric_rz || sys_coord == axisymmetric_zr)
238
return std::pair<size_type,size_type>(2,2);
239
return symmetric_tensor_subscript [i_comp];
243
tensor_subscript_name (
244
valued_type valued_tag,
245
coordinate_type sys_coord,
248
if (valued_tag == unsymmetric_tensor) {
249
if ((sys_coord == axisymmetric_rz || sys_coord == axisymmetric_zr)
252
return unsymmetric_tensor_subscript_name [i_comp];
254
if ((sys_coord == axisymmetric_rz || sys_coord == axisymmetric_zr)
257
return symmetric_tensor_subscript_name [i_comp];
260
std::pair<size_type,size_type>
263
std::string sys_coord,
266
return tensor_subscript (valued_tag(valued),
267
coordinate_system(sys_coord), i_comp);
270
tensor_subscript_name (
272
std::string sys_coord,
275
return tensor_subscript_name (valued_tag(valued),
276
coordinate_system(sys_coord), i_comp);
279
}} // namespace rheolef::space_constant