KADATH
metric_tensor.hpp
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 #ifndef __METRIC_TENSOR_HPP_
21 #define __METRIC_TENSOR_HPP_
22 
23 #include "tensor.hpp"
24 #include "gsl/gsl_permutation.h"
25 #include <vector>
26 #include <cmath>
27 
28 namespace Kadath {
29  double sign(gsl_permutation* p);
30  vector<int> ind_com(int i, int j, int k, int l);
31  int metric_tensor_position_array (const Array<int>& idx, int ndim);
32  int metric_tensor_position_index (const Index& idx, int ndim);
33  Array<int> metric_tensor_indices (int pos, int valence, int ndim);
34 
40  class Metric_tensor : public Tensor {
41 
42  public:
49  Metric_tensor (const Space& sp, int type_descr, const Base_tensor& ba) ;
54  Metric_tensor (const Metric_tensor&, bool copie = true) ;
55  Metric_tensor (const Space& sp, FILE*) ;
56 
57  // Assignement
59  Metric_tensor & operator= (const Tensor& a) override ;
60  Metric_tensor & operator= (double xx) override ;
61 
62 #ifdef TENSOR_MOVE_SEMANTIC
63  Metric_tensor(Metric_tensor &&s) noexcept : Tensor{std::move(s)} {}
64  Metric_tensor & operator=(Metric_tensor &&s) noexcept {this->Tensor::operator=(std::move(s)); return *this;}
65 #endif
66 
72 
76  void std_base2();
77 
81  int get_type() const {return type_indice(0) ;} ;
82  } ;
83 
84  inline Metric_tensor::Metric_tensor (const Space& sp, int type_descr, const Base_tensor& bb) :
85  Tensor (sp, 2, type_descr, 6, bb, 3) {
86 
87  give_place_array = metric_tensor_position_array ;
88  give_place_index = metric_tensor_position_index ;
89  give_indices = metric_tensor_indices ;
90  }
91 
92  inline Metric_tensor::Metric_tensor (const Metric_tensor& so, bool copie) :
93  Tensor (so, copie) {
94  }
95 
96  inline Metric_tensor::Metric_tensor (const Space& sp, FILE* ff) :
97  Tensor (sp, 3, ff) {
98 
99  assert (valence==2) ;
100  assert (type_indice(0)==type_indice(1)) ;
101  assert (n_comp==6) ;
102 
103  // Overwrite the storage functions :
104  give_place_array = metric_tensor_position_array ;
105  give_place_index = metric_tensor_position_index ;
106  give_indices = metric_tensor_indices ;
107  }
108 
109 }
110 
111 #endif
Describes the tensorial basis used by the various tensors.
Definition: base_tensor.hpp:49
Particular type of Tensor, dedicated to the desription of metrics.
Metric_tensor & operator=(const Metric_tensor &)
Assignment to another Metric_tensor.
void std_base2()
Specialized base setting (for AADS)
Metric_tensor inverse()
Computes the inverse of the current objetc.
The Space class is an ensemble of domains describing the whole space of the computation.
Definition: space.hpp:1362
Tensor handling.
Definition: tensor.hpp:149
virtual Tensor & operator=(const Tensor &)
Assignment to a Tensor.
Definition: tensor_math.cpp:27
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...)
Definition: tensor.hpp:157
int(* give_place_index)(const Index &, int)
Pointer on the function that gives the storage location corresponding to a set of indices values....
Definition: tensor.hpp:185
Array< int > type_indice
1D array of integers of size valence containing the type of each index: COV for a covariant one and C...
Definition: tensor.hpp:170
Array< int >(* give_indices)(int, int, int)
Pointer on the function that gives the indices corresponding to a give storage location.
Definition: tensor.hpp:186
int n_comp
Number of stored components, depending on the symmetry.
Definition: tensor.hpp:178
int(* give_place_array)(const Array< int > &, int)
Pointer on the function that gives the storage location corresponding to a set of indices values....
Definition: tensor.hpp:184