KADATH
base_tensor.cpp
1 /*
2  Copyright 2017 Philippe Grandclement
3 
4  This file is part of Kadath.
5 
6  Kadath 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 3 of the License, or
9  (at your option) any later version.
10 
11  Kadath 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 Kadath. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "headcpp.hpp"
21 #include "base_tensor.hpp"
22 
23 namespace Kadath {
24 // Constructors
25 
26 ostream& operator<< (ostream& flux , const Base_tensor& so) {
27  flux << "Tensorial basis" << endl ;
28  for (int d=0 ; d<so.space.get_nbr_domains() ; d++) {
29  flux << "Domain " << d << " : " ;
30  switch (so.get_basis(d)) {
31  case -1 :
32  flux << "Undefined" << endl ;
33  break ;
34  case CARTESIAN_BASIS :
35  flux << "Cartesian" << endl ;
36  break ;
37  case SPHERICAL_BASIS :
38  flux << "Spherical" << endl ;
39  break ;
40  case MTZ_BASIS :
41  flux << "MTZ" << endl ;
42  break ;
43  default:
44  cerr << "Unknown tensorial basis" << endl ;
45  abort() ;
46  }
47  }
48  return flux ;
49 }
50 
51 bool operator== (const Base_tensor& b1, const Base_tensor& b2) {
52  assert(&b1.space==&b2.space) ;
53  int res = true ;
54  for (int i=0 ; i<b1.space.get_nbr_domains() ; i++)
55  if (b1.get_basis(i) != b2.get_basis(i))
56  res = false ;
57  return res ;
58 }
59 
60 }
61 
Describes the tensorial basis used by the various tensors.
Definition: base_tensor.hpp:49
int get_basis(int nd) const
Read only the basis in a given domain.
Definition: base_tensor.hpp:93
const Space & space
The associated Space.
Definition: base_tensor.hpp:54
int get_nbr_domains() const
Returns the number of Domains.
Definition: space.hpp:1375