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

« back to all changes in this revision

Viewing changes to nfem/lib/field-mmg3d.cc

  • 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
///
 
2
/// This file is part of Rheolef.
 
3
///
 
4
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
 
5
///
 
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.
 
10
///
 
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.
 
15
///
 
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
 
19
///
 
20
/// =========================================================================
 
21
// mesh metric i/o in mmg3d format
 
22
/// =========================================================================
 
23
 
 
24
#include "rheolef/field.h"
 
25
using namespace std;
 
26
 
 
27
// USAGE:
 
28
//   ./metric_interpolate cube-0-metric cube-1-iso.geo 
 
29
#include "rheolef.h"
 
30
 
 
31
// TODO: check the order of tensor component
 
32
ostream&
 
33
field::put_mmg3d_metric (ostream& out) const
 
34
{
 
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
 
50
        << ndof << endl
 
51
        << "1 " << type << endl;
 
52
    if (n_comp == 1) {
 
53
        for (size_type idof = 0; idof < ndof; idof++) {
 
54
            out << at(idof) << endl;
 
55
        }
 
56
        out << "End" << endl;
 
57
        return out;
 
58
    }
 
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);
 
62
     if (use_sym_mat) {
 
63
       out << m(0,0) << " " << m(0,1) << " " << m(1,1) << " "
 
64
           << m(0,2) << " " << m(1,2) << " " << m(2,2) << endl;
 
65
     } else {
 
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;
 
69
     }
 
70
   }
 
71
   out << "End" << endl;
 
72
   return out;
 
73
}
 
74
ostream&
 
75
field::put_yams_metric (ostream& out) const
 
76
{
 
77
  return put_mmg3d_metric (out);
 
78
}
 
79
istream&
 
80
field::get_mmg3d_metric (istream& in)
 
81
{
 
82
   fatal_macro ("input mmg3d metric: not yet");
 
83
   return in;
 
84
}