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
/// =========================================================================
21
// mesh metric i/o in mmg3d format
22
/// =========================================================================
24
#include "rheolef/field.h"
28
// ./metric_interpolate cube-0-metric cube-1-iso.geo
31
// TODO: check the order of tensor component
33
field::put_mmg3d_metric (ostream& out) const
35
typedef field::size_type size_type;
36
// pour mmg3d-3.1c (7 janv 2007)
37
// sortie de type "medit" avec matrices symetriques avec 6 composantes
38
// ou avec matrices completes avec 9 composantes
39
bool use_sym_mat = true;
40
check_macro (dimension() == 3, "mmg3d: 3D expected, "<<dimension()<<" found");
41
check_macro (get_approx() == "P1",
42
"mmg3d metric output: P1 approximation expected, `" << get_approx() << "' found");
43
check_macro (n_component() == 1 || n_component() == 6, "mmg3d: scalar or tensor expected, "<<n_component() <<" component found");
44
size_t ndof = get_space().size_component(0);
45
size_t n_comp = n_component();
46
size_t type = (n_comp == 1) ? 1 : (use_sym_mat ? 3 : 4);
47
out << "MeshVersionFormatted 1" << endl
48
<< "Dimension 3" << endl
49
<< "SolAtVertices" << endl
51
<< "1 " << type << endl;
53
for (size_type idof = 0; idof < ndof; idof++) {
54
out << at(idof) << endl;
59
check_macro(n_comp == 6, "Tensorial metric field expected");
60
for (size_type idof = 0; idof < ndof; idof++) {
61
tensor m = tensor_at (idof);
63
out << m(0,0) << " " << m(0,1) << " " << m(1,1) << " "
64
<< m(0,2) << " " << m(1,2) << " " << m(2,2) << endl;
66
out << m(0,0) << " " << m(0,1) << " " << m(0,2) << " "
67
<< m(0,1) << " " << m(1,1) << " " << m(1,2) << " "
68
<< m(0,2) << " " << m(1,2) << " " << m(2,2) << endl;
75
field::put_yams_metric (ostream& out) const
77
return put_mmg3d_metric (out);
80
field::get_mmg3d_metric (istream& in)
82
fatal_macro ("input mmg3d metric: not yet");