22 #include "tensor_impl.hpp"
37 cerr <<
"Ope_inverse only defined with respect for a tensor" << endl ;
41 cerr <<
"Ope_inverse only defined with respect to a second order tensor" << endl ;
45 cerr <<
"Ope_inverse only defined with respect to a tensor which indices are of the same type" << endl ;
51 bool m_doder = (target.
der_t==0x0) ?
false :
true ;
66 gsl_permutation* p(gsl_permutation_calloc(dim));
70 int p1(
static_cast<int>(gsl_permutation_get(p, 0)) + 1);
71 int p2(
static_cast<int>(gsl_permutation_get(p, 1)) + 1);
72 int p3(
static_cast<int>(gsl_permutation_get(p, 2)) + 1);
80 }
while(gsl_permutation_next(p) == GSL_SUCCESS);
81 gsl_permutation_free(p);
84 p = gsl_permutation_calloc(dim - 1);
85 for (
int i(1) ; i <= dim ; ++i)
87 for (
int j(i) ; j <= dim ; ++j)
94 int p1(
static_cast<int>(gsl_permutation_get(p, 0)) + 1);
95 int p2(
static_cast<int>(gsl_permutation_get(p, 1)) + 1);
96 vector<int> index1, index2;
97 index1 = ind_com(i, j, p1, 1);
98 index2 = ind_com(i, j, p2, 2);
99 cmpval += pow(-1.0, i + j)*signature*(*target.
val_t)(index1[0], index1[1])(
dom)*(*target.
val_t)(index2[0],index2[1])(
dom);
101 cmpder += pow(-1.0, i + j)*signature*(*target.
der_t)(index1[0], index1[1])(
dom)*(*target.
val_t)(index2[0], index2[1])(
dom)
102 + pow(-1.0, i + j)*signature*(*target.
val_t)(index1[0], index1[1])(
dom)*(*target.
der_t)(index2[0], index2[1])(
dom);
103 }
while(gsl_permutation_next(p) == GSL_SUCCESS);
104 gsl_permutation_free(p) ;
105 p = gsl_permutation_calloc(dim - 1);
109 der.
set_domain(
dom) = cmpder / detval - cmpval * detder / (detval*detval);
110 res[j - 1 + dim*(i - 1) - i*(i - 1)/2] =
new Term_eq (
dom, val, der);
113 res[j - 1 + dim*(i - 1) - i*(i - 1)/2] =
new Term_eq (
dom, val);
116 gsl_permutation_free(p);
121 for (
int i(1) ; i <= dim ; ++i)
122 for (
int j(i) ; j <= dim ; ++j)
123 resval.
set(i, j) = res[j - 1 + dim*(i - 1) - i*(i - 1)/2]->
get_val_t();
127 for (
int i(1) ; i <= dim ; ++i)
128 for (
int j(i) ; j <= dim ; ++j)
129 resder.
set(i, j) = res[j - 1 + dim*(i - 1) - i*(i - 1)/2]->
get_der_t();
132 for (
int i(0) ; i < dim*(dim + 1)/2 ; ++i)
Particular type of Tensor, dedicated to the desription of metrics.
Abstract class that describes the various operators that can appear in the equations.
MMPtr_array< Ope_eq > parts
Pointers of the various parts of the current operator.
int dom
Index of the Domain where the operator is defined.
Term_eq action() const override
Computes the action of the current Ope_eq using its various parts.
Ope_inverse(const System_of_eqs *syst, Ope_eq *so)
Constructor.
~Ope_inverse() override
Destructor.
The class Scalar does not really implements scalars in the mathematical sense but rather tensorial co...
Val_domain & set_domain(int)
Read/write of a particular Val_domain.
const Domain * get_domain(int i) const
returns a pointer on the domain.
int get_ndim() const
Returns the number of dimensions.
Class used to describe and solve a system of equations.
Scalar & set(const Array< int > &ind)
Returns the value of a component (read/write version).
int get_index_type(int i) const
Gives the type (covariant or contravariant) of a given index.
const Base_tensor & get_basis() const
Returns the vectorial basis (triad) on which the components are defined.
int get_valence() const
Returns the valence.
const Space & get_space() const
Returns the Space.
This class is intended to describe the manage objects appearing in the equations.
Tensor * der_t
Pointer on the variation, if the Term_eq is a Tensor.
const int type_data
Flag describing the type of data :
Tensor const & get_val_t() const
Tensor const & get_der_t() const
Tensor * val_t
Pointer on the value, if the Term_eq is a Tensor.
Class for storing the basis of decompositions of a field and its values on both the configuration and...