23 #include "term_eq.hpp"
25 #include "tensor_impl.hpp"
26 #include "system_of_eqs.hpp"
27 #include "metric_tensor.hpp"
28 #include "name_tools.hpp"
31 Metric(met.get_space()), p_met(&met), basis(met.get_basis()), fmet(met.get_space(), basis) {
36 Metric (so), p_met(so.p_met), basis(so.basis), fmet(so.fmet), place_syst(so.place_syst) {
39 Metric_general::~Metric_general() {
53 cerr <<
"Function only implemented for dimension 3" << endl ;
68 bool doder = (
syst->
term[place]->der_t==0x0) ?
false :
true ;
76 detval = (*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
84 detder = (*
syst->
term[place]->der_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
107 cmpval = (*
syst->
term[place]->val_t)(2,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
108 -(*
syst->
term[place]->val_t)(2,3)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd) ;
111 cmpder = (*
syst->
term[place]->der_t)(2,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
114 - (*
syst->
term[place]->val_t)(2,3)(dd)*(*
syst->
term[place]->der_t)(2,3)(dd) ;
115 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
116 res[0] =
new Term_eq (dd, val, der) ;
119 res[0] =
new Term_eq (dd, val) ;
123 cmpval = (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
124 -(*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd) ;
127 cmpder = (*
syst->
term[place]->der_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
130 - (*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->der_t)(3,3)(dd) ;
131 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
132 res[1] =
new Term_eq (dd, val, der) ;
135 res[1] =
new Term_eq (dd, val) ;
139 cmpval = (*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
140 -(*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd) ;
143 cmpder = (*
syst->
term[place]->der_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
146 - (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->der_t)(2,2)(dd) ;
147 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
148 res[2] =
new Term_eq (dd, val, der) ;
151 res[2] =
new Term_eq (dd, val) ;
155 cmpval = (*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
156 -(*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(1,3)(dd) ;
159 cmpder = (*
syst->
term[place]->der_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
162 - (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->der_t)(1,3)(dd) ;
163 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
164 res[3] =
new Term_eq (dd, val, der) ;
167 res[3] =
new Term_eq (dd, val) ;
171 cmpval = (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(1,2)(dd)
172 -(*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd) ;
175 cmpder = (*
syst->
term[place]->der_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(1,2)(dd)
178 - (*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->der_t)(2,3)(dd) ;
179 der.
set_domain(dd) = cmpder/ detval - cmpval * detder / detval/detval ;
180 res[4] =
new Term_eq (dd, val, der) ;
183 res[4] =
new Term_eq (dd, val) ;
187 cmpval = (*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd)
188 -(*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(1,2)(dd) ;
191 cmpder = (*
syst->
term[place]->der_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd)
194 - (*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->der_t)(1,2)(dd) ;
195 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
196 res[5] =
new Term_eq (dd, val, der) ;
199 res[5] =
new Term_eq (dd, val) ;
242 cerr <<
"Function only implemented for dimension 3" << endl ;
257 bool doder = (
syst->
term[place]->der_t==0x0) ?
false :
true ;
267 detval = (*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
275 detder = (*
syst->
term[place]->der_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
296 cmpval = (*
syst->
term[place]->val_t)(2,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
297 -(*
syst->
term[place]->val_t)(2,3)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd) ;
300 cmpder = (*
syst->
term[place]->der_t)(2,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
303 - (*
syst->
term[place]->val_t)(2,3)(dd)*(*
syst->
term[place]->der_t)(2,3)(dd) ;
304 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
305 res[0] =
new Term_eq (dd, val, der) ;
308 res[0] =
new Term_eq (dd, val) ;
312 cmpval = (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
313 -(*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd) ;
316 cmpder = (*
syst->
term[place]->der_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
319 - (*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->der_t)(3,3)(dd) ;
320 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
321 res[1] =
new Term_eq (dd, val, der) ;
324 res[1] =
new Term_eq (dd, val) ;
328 cmpval = (*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
329 -(*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd) ;
332 cmpder = (*
syst->
term[place]->der_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
335 - (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->der_t)(2,2)(dd) ;
336 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
337 res[2] =
new Term_eq (dd, val, der) ;
340 res[2] =
new Term_eq (dd, val) ;
344 cmpval = (*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
345 -(*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(1,3)(dd) ;
348 cmpder = (*
syst->
term[place]->der_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
351 - (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->der_t)(1,3)(dd) ;
352 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
353 res[3] =
new Term_eq (dd, val, der) ;
356 res[3] =
new Term_eq (dd, val) ;
360 cmpval = (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(1,2)(dd)
361 -(*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd) ;
364 cmpder = (*
syst->
term[place]->der_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(1,2)(dd)
367 - (*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->der_t)(2,3)(dd) ;
368 der.
set_domain(dd) = cmpder/ detval - cmpval * detder / detval/detval ;
369 res[4] =
new Term_eq (dd, val, der) ;
372 res[4] =
new Term_eq (dd, val) ;
376 cmpval = (*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd)
377 -(*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(1,2)(dd) ;
380 cmpder = (*
syst->
term[place]->der_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd)
383 - (*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->der_t)(1,2)(dd) ;
384 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
385 res[5] =
new Term_eq (dd, val, der) ;
388 res[5] =
new Term_eq (dd, val) ;
444 type_ind.
set(0) = COV ; type_ind.
set(1) = COV ; type_ind.
set(2) = CON ;
449 bool doder = (flat_der.
der_t==0x0) ?
false :
true ;
451 Index pos (res_val) ;
457 cmpval += 0.5*(*
p_met_con[dd]->val_t)(pos(2)+1,l)(dd)*((*flat_der.
val_t)(pos(0)+1, pos(1)+1, l)(dd) +
458 (*flat_der.
val_t)(pos(1)+1, pos(0)+1, l)(dd) - (*flat_der.
val_t)(l, pos(0)+1, pos(1)+1)(dd)) ;
466 cmpder += 0.5*(*
p_met_con[dd]->der_t)(pos(2)+1,l)(dd)*((*flat_der.
val_t)(pos(0)+1, pos(1)+1, l)(dd) +
467 (*flat_der.
val_t)(pos(1)+1, pos(0)+1, l)(dd) - (*flat_der.
val_t)(l, pos(0)+1, pos(1)+1)(dd))
468 + 0.5*(*
p_met_con[dd]->val_t)(pos(2)+1,l)(dd)*((*flat_der.
der_t)(pos(0)+1, pos(1)+1, l)(dd) +
469 (*flat_der.
der_t)(pos(1)+1, pos(0)+1, l)(dd) - (*flat_der.
der_t)(l, pos(0)+1, pos(1)+1)(dd)) ;
501 indices.
set(0) = CON ; indices.
set(1) = COV ; indices.
set(2) = COV ; indices.
set(3) = COV ;
506 bool doder = (flat_der.
der_t==0x0) ?
false :
true ;
508 Index pos (res_val) ;
511 Val_domain cmpval ((*flat_der.
val_t)(pos(2)+1, pos(1)+1,pos(3)+1,pos(0)+1)(dd)
512 - (*flat_der.
val_t)(pos(3)+1, pos(1)+1, pos(2)+1, pos(0)+1)(dd)) ;
514 cmpval += (*
p_christo[dd]->val_t)(pos(2)+1,m, pos(0)+1)(dd)*(*
p_christo[dd]->val_t)(pos(1)+1,pos(3)+1,m)(dd)
515 - (*
p_christo[dd]->val_t)(pos(3)+1,m,pos(0)+1)(dd)*(*
p_christo[dd]->val_t)(pos(1)+1,pos(2)+1,m)(dd) ;
519 Val_domain cmpder ((*flat_der.
der_t)(pos(2)+1, pos(1)+1,pos(3)+1,pos(0)+1)(dd)
520 - (*flat_der.
der_t)(pos(3)+1, pos(1)+1, pos(2)+1, pos(0)+1)(dd)) ;
522 cmpder += (*
p_christo[dd]->der_t)(pos(2)+1,m, pos(0)+1)(dd)*(*
p_christo[dd]->val_t)(pos(1)+1,pos(3)+1,m)(dd)
523 + (*
p_christo[dd]->val_t)(pos(2)+1,m, pos(0)+1)(dd)*(*
p_christo[dd]->der_t)(pos(1)+1,pos(3)+1,m)(dd)
524 - (*
p_christo[dd]->der_t)(pos(3)+1,m,pos(0)+1)(dd)*(*
p_christo[dd]->val_t)(pos(1)+1,pos(2)+1,m)(dd)
525 - (*
p_christo[dd]->val_t)(pos(3)+1,m,pos(0)+1)(dd)*(*
p_christo[dd]->der_t)(pos(1)+1,pos(2)+1,m)(dd);
556 indices.
set(0) = COV ; indices.
set(1) = COV ;
561 bool doder = (flat_der.
der_t==0x0) ?
false :
true ;
563 Index pos (res_val) ;
570 cmpval += (*flat_der.
val_t)(l, pos(1)+1,pos(0)+1,l)(dd)
571 - (*flat_der.
val_t)(pos(1)+1, pos(0)+1,l ,l)(dd) ;
573 cmpval += (*
p_christo[dd]->val_t)(l,m, l)(dd)*(*
p_christo[dd]->val_t)(pos(0)+1,pos(1)+1,m)(dd)
574 - (*
p_christo[dd]->val_t)(pos(0)+1,l, m)(dd)*(*
p_christo[dd]->val_t)(pos(1)+1,m,l)(dd) ;
584 cmpder += (*flat_der.
der_t)(l, pos(1)+1,pos(0)+1,l)(dd)
585 - (*flat_der.
der_t)(pos(1)+1, pos(0)+1,l ,l)(dd) ;
587 cmpder += (*
p_christo[dd]->der_t)(l,m, l)(dd)*(*
p_christo[dd]->val_t)(pos(0)+1,pos(1)+1,m)(dd)
588 + (*
p_christo[dd]->val_t)(l,m, l)(dd)*(*
p_christo[dd]->der_t)(pos(0)+1,pos(1)+1,m)(dd)
589 - (*
p_christo[dd]->der_t)(pos(0)+1,l, m)(dd)*(*
p_christo[dd]->val_t)(pos(1)+1,m,l)(dd)
590 - (*
p_christo[dd]->val_t)(pos(0)+1,l, m)(dd)*(*
p_christo[dd]->der_t)(pos(1)+1,m,l)(dd);
647 if (ind_der==
char(start))
657 while ((!found) && (start<123)) ;
659 cerr <<
"Trouble with indices in derive (you are not using tensors of order > 24, are you ?)" << endl ;
662 char name_sum = char(start) ;
664 bool doder = ((so.
der_t==0x0) || (
p_christo[dd]->der_t==0x0)) ?
false :
true ;
672 p_christo[dd]->val_t->set_name_affected() ;
673 p_christo[dd]->val_t->set_name_ind(0, ind_der) ;
674 if (genre_indice==COV) {
676 p_christo[dd]->val_t->set_name_ind(2, name_sum) ;
680 p_christo[dd]->val_t->set_name_ind(1, name_sum) ;
684 p_christo[dd]->der_t->set_name_affected() ;
685 p_christo[dd]->der_t->set_name_ind(0, ind_der) ;
686 if (genre_indice==COV) {
688 p_christo[dd]->der_t->set_name_ind(2, name_sum) ;
692 p_christo[dd]->der_t->set_name_ind(1, name_sum) ;
702 bool need_sum = false ;
703 char const * ind =
p_christo[dd]->val_t->get_name_ind() ;
704 if ((ind[0]==ind[2]) || (ind[1]==ind[2]) || (ind[0]==ind[1]))
715 christ =
new Term_eq (auxi_christ) ;
734 Term_eq part_christo ((*christ)*copie) ;
737 if (genre_indice==CON)
738 res = res + part_christo ;
740 res = res - part_christo ;
765 bool doder = (flat_der.
der_t==0x0) ?
false :
true ;
767 Index pos (res_val) ;
773 cmpval += (*flat_der.
val_t)(l, l, pos(0)+1)(dd) ;
781 cmpder += (*flat_der.
der_t)(l, l, pos(0)+1)(dd) ;
813 cerr <<
"Metric already set for the system" << endl ;
819 trim_spaces (ss.
name_met, name_met) ;
reference set(const Index &pos)
Read/write of an element.
int get_basis(int nd) const
Read only the basis in a given domain.
Class that gives the position inside a multi-dimensional Array.
bool inc(int increm, int var=0)
Increments the position of the Index.
Term_eq derive_with_other(int tder, char indder, const Term_eq &so, const Metric *othermet) const
Computes the flat covariant derivative.
virtual Term_eq derive(int, char, const Term_eq &) const
Computes the covariant derivative of a Term_eq (assumes Cartesian basis of decomposition).
Class to deal with arbitrary type of metric.
virtual void compute_dirac(int) const
Computes the Dirac gauge term, in a given Domain.
Metric_tensor * p_met
Pointer on the Metric_tensor describing the metric.
Metric_general(Metric_tensor &)
Constructor from a Metric_tensor.
virtual void compute_ricci_tensor(int) const
Computes the Ricci tensor, in a given Domain.
Metric_flat fmet
Associated flat metric.
virtual void compute_christo(int) const
Computes the Christoffel symbols, in a given Domain.
virtual int give_type(int) const
Returns the type of tensorial basis of the covariant representation, in a given Domain.
virtual void set_system(System_of_eqs &syst, const char *name)
Associate the metric to a given system of equations.
virtual void compute_cov(int) const
Computes the covariant representation, in a given Domain.
virtual void compute_riemann(int) const
Computes the Riemann tensor, in a given Domain.
int place_syst
Gives the location of the metric amongst the various unknowns of the associated System_of_eqs.
const Base_tensor & basis
The tensorial basis used.
virtual Term_eq derive_flat(int, char, const Term_eq &) const
Computes the covariant flat derivative of a Term_eq.
virtual Term_eq derive(int, char, const Term_eq &) const
Computes the covariant derivative of a Term_eq (assumes Cartesian basis of decomposition).
virtual void compute_con(int) const
Computes the contravariant representation, in a given Domain.
Particular type of Tensor, dedicated to the desription of metrics.
Purely abstract class for metric handling.
int type_tensor
States if one works in the CON or COV representation.
MMPtr_array< Term_eq > p_ricci_tensor
Array of pointers on various Term_eq.
const Term_eq * give_ricci_tensor(int dd) const
Gives the Ricci tensor, in a Domain.
const Space & espace
The associated Space.
MMPtr_array< Term_eq > p_met_cov
Array of pointers on various Term_eq.
MMPtr_array< Term_eq > p_met_con
Array of pointers on various Term_eq.
virtual void manipulate_ind(Term_eq &so, int ind) const
Uses the Metric to manipulate one of the index of a Term_eq (i.e.
MMPtr_array< Term_eq > p_dirac
Array of pointers on various Term_eq.
MMPtr_array< Term_eq > p_riemann
Array of pointers on various Term_eq.
MMPtr_array< Term_eq > p_christo
Array of pointers on various Term_eq.
const System_of_eqs * syst
Pointer of the system of equations where the metric is used (only one for now).
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.
virtual void add_var(const char *name, double &var)
Addition of a variable (number case)
int ndom
Number of domains used.
char * name_met
Name by which the metric is recognized.
MMPtr_array< Term_eq > term
Pointers on the Term_eq corresponding to the unknown fields.
int dom_min
Smallest domain number.
Metric * met
Pointer on the associated Metric, if defined.
int nvar
Number of unknown fields.
void set_name_ind(int dd, char name)
Sets the name of one index ; the names must have been affected first.
void set_name_affected()
Affects the name of the indices.
Param_tensor & set_parameters()
Read/write of the parameters.
const Param_tensor & get_parameters() const
Returns a pointer on the possible additional parameter.
Scalar & set(const Array< int > &ind)
Returns the value of a component (read/write version).
char const * get_name_ind() const
int get_index_type(int i) const
Gives the type (covariant or contravariant) of a given index.
int get_n_comp() const
Returns the number of stored components.
int get_valence() const
Returns the valence.
bool is_m_quant_affected() const
Checks whether the additional parameter is affected (used for boson stars for instance).
Tensor do_summation_one_dom(int dd) const
Does the inner contraction of the Tensor in a given domain.
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.
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...