LORENE
base_vect_from_file.C
1/*
2 * Methods for Base_vect and file manipulation
3 *
4 * (see file base_vect.h for documentation)
5 */
6
7/*
8 * Copyright (c) 2000-2001 Eric Gourgoulhon
9 *
10 * This file is part of LORENE.
11 *
12 * LORENE is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * LORENE is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with LORENE; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */
27
28char base_vect_from_file_C[] = "$Header: /cvsroot/Lorene/C++/Source/Base_vect/base_vect_from_file.C,v 1.5 2014/10/13 08:52:39 j_novak Exp $" ;
29
30/*
31 * $Id: base_vect_from_file.C,v 1.5 2014/10/13 08:52:39 j_novak Exp $
32 * $Log: base_vect_from_file.C,v $
33 * Revision 1.5 2014/10/13 08:52:39 j_novak
34 * Lorene classes and functions now belong to the namespace Lorene.
35 *
36 * Revision 1.4 2014/10/06 15:12:57 j_novak
37 * Modified #include directives to use c++ syntax.
38 *
39 * Revision 1.3 2002/10/16 14:36:31 j_novak
40 * Reorganization of #include instructions of standard C++, in order to
41 * use experimental version 3 of gcc.
42 *
43 * Revision 1.2 2001/12/04 21:27:52 e_gourgoulhon
44 *
45 * All writing/reading to a binary file are now performed according to
46 * the big endian convention, whatever the system is big endian or
47 * small endian, thanks to the functions fwrite_be and fread_be
48 *
49 * Revision 1.1.1.1 2001/11/20 15:19:28 e_gourgoulhon
50 * LORENE
51 *
52 * Revision 2.0 2000/02/09 13:25:23 eric
53 * *** empty log message ***
54 *
55 *
56 * $Header: /cvsroot/Lorene/C++/Source/Base_vect/base_vect_from_file.C,v 1.5 2014/10/13 08:52:39 j_novak Exp $
57 *
58 */
59
60// Headers C
61#include <cstdlib>
62
63// Header Lorene
64#include "headcpp.h"
65#include "base_vect.h"
66#include "utilitaires.h"
67
68 //--------------------------------------//
69 // Identification virtual functions //
70 //--------------------------------------//
71
72
73namespace Lorene {
74int Base_vect_cart::identify() const { return 1; }
75
76int Base_vect_spher::identify() const { return 2; }
77
78
79
80 //--------------------------------------//
81 // Base_vect construction from a file //
82 //--------------------------------------//
83
85
86 Base_vect* p_bvect ;
87
88 // Type (class) of vectorial basis identificator ;
89 int identificator ;
90 fread_be(&identificator, sizeof(int), 1, fich) ;
91
92 switch(identificator) {
93
94 case 1 : {
95 p_bvect = new Base_vect_cart(fich) ;
96 break ;
97 }
98
99 case 2 : {
100 p_bvect = new Base_vect_spher(fich) ;
101 break ;
102 }
103
104 default : {
105 cout << "Base_vect::bvect_from_file : unknown type of Base_vect!"
106 << endl ;
107 cout << " identificator = " << identificator << endl ;
108 abort() ;
109 break ;
110 }
111
112 }
113
114 return p_bvect ;
115
116}
117
118}
Cartesian vectorial bases (triads).
Definition base_vect.h:201
virtual int identify() const
Returns a number to identify the sub-classe of Base_vect the object belongs to.
Spherical orthonormal vectorial bases (triads).
Definition base_vect.h:308
virtual int identify() const
Returns a number to identify the sub-classe of Base_vect the object belongs to.
Vectorial bases (triads) with respect to which the tensorial components are defined.
Definition base_vect.h:105
static Base_vect * bvect_from_file(FILE *)
Construction of a vectorial basis from a file (see sauve(FILE* ) ).
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
Definition fread_be.C:69
Lorene prototypes.
Definition app_hor.h:64