22 #include "metric_nophi.hpp"
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) {
33 for (
int d=0 ; d<met.
get_space().get_nbr_domains() ; d++)
35 cerr <<
"Metric_nophi only defined wrt spherical tensorial coordinates" << endl ;
41 Metric (so), p_met(so.p_met), basis(so.basis), fmet(so.fmet), place_syst(so.place_syst) {
44 Metric_nophi::~Metric_nophi() {
67 bool doder = (
syst->
term[place]->der_t==0x0) ?
false :
true ;
75 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)
83 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)
106 cmpval = (*
syst->
term[place]->val_t)(2,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
107 -(*
syst->
term[place]->val_t)(2,3)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd) ;
110 cmpder = (*
syst->
term[place]->der_t)(2,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
113 - (*
syst->
term[place]->val_t)(2,3)(dd)*(*
syst->
term[place]->der_t)(2,3)(dd) ;
114 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
115 res[0] =
new Term_eq (dd, val, der) ;
118 res[0] =
new Term_eq (dd, val) ;
122 cmpval = (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
123 -(*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd) ;
126 cmpder = (*
syst->
term[place]->der_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
129 - (*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->der_t)(3,3)(dd) ;
130 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
131 res[1] =
new Term_eq (dd, val, der) ;
134 res[1] =
new Term_eq (dd, val) ;
138 cmpval = (*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
139 -(*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd) ;
142 cmpder = (*
syst->
term[place]->der_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
145 - (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->der_t)(2,2)(dd) ;
146 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
147 res[2] =
new Term_eq (dd, val, der) ;
150 res[2] =
new Term_eq (dd, val) ;
154 cmpval = (*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
155 -(*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(1,3)(dd) ;
158 cmpder = (*
syst->
term[place]->der_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
161 - (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->der_t)(1,3)(dd) ;
162 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
163 res[3] =
new Term_eq (dd, val, der) ;
166 res[3] =
new Term_eq (dd, val) ;
170 cmpval = (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(1,2)(dd)
171 -(*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd) ;
174 cmpder = (*
syst->
term[place]->der_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(1,2)(dd)
177 - (*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->der_t)(2,3)(dd) ;
178 der.
set_domain(dd) = cmpder/ detval - cmpval * detder / detval/detval ;
179 res[4] =
new Term_eq (dd, val, der) ;
182 res[4] =
new Term_eq (dd, val) ;
186 cmpval = (*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd)
187 -(*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(1,2)(dd) ;
190 cmpder = (*
syst->
term[place]->der_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd)
193 - (*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->der_t)(1,2)(dd) ;
194 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
195 res[5] =
new Term_eq (dd, val, der) ;
198 res[5] =
new Term_eq (dd, val) ;
251 bool doder = (
syst->
term[place]->der_t==0x0) ?
false :
true ;
261 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)
269 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)
290 cmpval = (*
syst->
term[place]->val_t)(2,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
291 -(*
syst->
term[place]->val_t)(2,3)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd) ;
294 cmpder = (*
syst->
term[place]->der_t)(2,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
297 - (*
syst->
term[place]->val_t)(2,3)(dd)*(*
syst->
term[place]->der_t)(2,3)(dd) ;
298 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
299 res[0] =
new Term_eq (dd, val, der) ;
302 res[0] =
new Term_eq (dd, val) ;
306 cmpval = (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
307 -(*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd) ;
310 cmpder = (*
syst->
term[place]->der_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
313 - (*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->der_t)(3,3)(dd) ;
314 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
315 res[1] =
new Term_eq (dd, val, der) ;
318 res[1] =
new Term_eq (dd, val) ;
322 cmpval = (*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
323 -(*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd) ;
326 cmpder = (*
syst->
term[place]->der_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd)
329 - (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->der_t)(2,2)(dd) ;
330 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
331 res[2] =
new Term_eq (dd, val, der) ;
334 res[2] =
new Term_eq (dd, val) ;
338 cmpval = (*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
339 -(*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(1,3)(dd) ;
342 cmpder = (*
syst->
term[place]->der_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(3,3)(dd)
345 - (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->der_t)(1,3)(dd) ;
346 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
347 res[3] =
new Term_eq (dd, val, der) ;
350 res[3] =
new Term_eq (dd, val) ;
354 cmpval = (*
syst->
term[place]->val_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(1,2)(dd)
355 -(*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,3)(dd) ;
358 cmpder = (*
syst->
term[place]->der_t)(1,3)(dd)*(*
syst->
term[place]->val_t)(1,2)(dd)
361 - (*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->der_t)(2,3)(dd) ;
362 der.
set_domain(dd) = cmpder/ detval - cmpval * detder / detval/detval ;
363 res[4] =
new Term_eq (dd, val, der) ;
366 res[4] =
new Term_eq (dd, val) ;
370 cmpval = (*
syst->
term[place]->val_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd)
371 -(*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->val_t)(1,2)(dd) ;
374 cmpder = (*
syst->
term[place]->der_t)(1,1)(dd)*(*
syst->
term[place]->val_t)(2,2)(dd)
377 - (*
syst->
term[place]->val_t)(1,2)(dd)*(*
syst->
term[place]->der_t)(1,2)(dd) ;
378 der.
set_domain(dd) = cmpder / detval - cmpval * detder / detval/detval;
379 res[5] =
new Term_eq (dd, val, der) ;
382 res[5] =
new Term_eq (dd, val) ;
438 type_ind.
set(0) = COV ; type_ind.
set(1) = COV ; type_ind.
set(2) = CON ;
443 bool doder = (flat_der.
der_t==0x0) ?
false :
true ;
445 Index pos (res_val) ;
451 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) +
452 (*flat_der.
val_t)(pos(1)+1, pos(0)+1, l)(dd) - (*flat_der.
val_t)(l, pos(0)+1, pos(1)+1)(dd)) ;
460 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) +
461 (*flat_der.
val_t)(pos(1)+1, pos(0)+1, l)(dd) - (*flat_der.
val_t)(l, pos(0)+1, pos(1)+1)(dd))
462 + 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) +
463 (*flat_der.
der_t)(pos(1)+1, pos(0)+1, l)(dd) - (*flat_der.
der_t)(l, pos(0)+1, pos(1)+1)(dd)) ;
494 indices.
set(0) = CON ; indices.
set(1) = COV ; indices.
set(2) = COV ; indices.
set(3) = COV ;
499 bool doder = (flat_der.
der_t==0x0) ?
false :
true ;
501 Index pos (res_val) ;
504 Val_domain cmpval ((*flat_der.
val_t)(pos(2)+1, pos(1)+1,pos(3)+1,pos(0)+1)(dd)
505 - (*flat_der.
val_t)(pos(3)+1, pos(1)+1, pos(2)+1, pos(0)+1)(dd)) ;
507 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)
508 - (*
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) ;
512 Val_domain cmpder ((*flat_der.
der_t)(pos(2)+1, pos(1)+1,pos(3)+1,pos(0)+1)(dd)
513 - (*flat_der.
der_t)(pos(3)+1, pos(1)+1, pos(2)+1, pos(0)+1)(dd)) ;
515 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)
516 + (*
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)
517 - (*
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)
518 - (*
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);
549 indices.
set(0) = COV ; indices.
set(1) = COV ;
554 bool doder = (flat_der.
der_t==0x0) ?
false :
true ;
556 Index pos (res_val) ;
563 cmpval += (*flat_der.
val_t)(l, pos(1)+1,pos(0)+1,l)(dd)
564 - (*flat_der.
val_t)(pos(1)+1, pos(0)+1,l ,l)(dd) ;
566 cmpval += (*
p_christo[dd]->val_t)(l,m, l)(dd)*(*
p_christo[dd]->val_t)(pos(0)+1,pos(1)+1,m)(dd)
567 - (*
p_christo[dd]->val_t)(pos(0)+1,l, m)(dd)*(*
p_christo[dd]->val_t)(pos(1)+1,m,l)(dd) ;
577 cmpder += (*flat_der.
der_t)(l, pos(1)+1,pos(0)+1,l)(dd)
578 - (*flat_der.
der_t)(pos(1)+1, pos(0)+1,l ,l)(dd) ;
580 cmpder += (*
p_christo[dd]->der_t)(l,m, l)(dd)*(*
p_christo[dd]->val_t)(pos(0)+1,pos(1)+1,m)(dd)
581 + (*
p_christo[dd]->val_t)(l,m, l)(dd)*(*
p_christo[dd]->der_t)(pos(0)+1,pos(1)+1,m)(dd)
582 - (*
p_christo[dd]->der_t)(pos(0)+1,l, m)(dd)*(*
p_christo[dd]->val_t)(pos(1)+1,m,l)(dd)
583 - (*
p_christo[dd]->val_t)(pos(0)+1,l, m)(dd)*(*
p_christo[dd]->der_t)(pos(1)+1,m,l)(dd);
639 if (ind_der==
char(start))
649 while ((!found) && (start<123)) ;
651 cerr <<
"Trouble with indices in derive (you are not using tensors of order > 24, are you ?)" << endl ;
654 char name_sum = char(start) ;
656 bool doder = ((so.
der_t==0x0) || (
p_christo[dd]->der_t==0x0)) ?
false :
true ;
664 p_christo[dd]->val_t->set_name_affected() ;
665 p_christo[dd]->val_t->set_name_ind(0, ind_der) ;
666 if (genre_indice==COV) {
668 p_christo[dd]->val_t->set_name_ind(2, name_sum) ;
672 p_christo[dd]->val_t->set_name_ind(1, name_sum) ;
676 p_christo[dd]->der_t->set_name_affected() ;
677 p_christo[dd]->der_t->set_name_ind(0, ind_der) ;
678 if (genre_indice==COV) {
680 p_christo[dd]->der_t->set_name_ind(2, name_sum) ;
684 p_christo[dd]->der_t->set_name_ind(1, name_sum) ;
694 bool need_sum = false ;
695 char const * ind =
p_christo[dd]->val_t->get_name_ind() ;
696 if ((ind[0]==ind[2]) || (ind[1]==ind[2]) || (ind[0]==ind[1]))
707 christ =
new Term_eq (auxi_christ) ;
726 Term_eq part_christo ((*christ)*copie) ;
729 if (genre_indice==CON)
730 res = res + part_christo ;
732 res = res - part_christo ;
748 cerr <<
"Metric already set for the system" << endl ;
754 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.
virtual Term_eq derive(int, char, const Term_eq &) const
Computes the covariant derivative of a Term_eq (assumes Cartesian basis of decomposition).
Term_eq derive_with_other(int tder, char indder, const Term_eq &so, const Metric *othermet) const
Computes the flat covariant derivative.
Class to deal with a metric independant of .
virtual Term_eq derive_flat(int, char, const Term_eq &) const
Computes the covariant flat derivative of a Term_eq.
Metric_nophi(Metric_tensor &)
Constructor from a Metric_tensor.
virtual void set_system(System_of_eqs &syst, const char *name)
Associate the metric to a given system of equations.
Metric_tensor * p_met
Pointer on the Metric_tensor describing the metric.
virtual void compute_ricci_tensor(int) const
Computes the Ricci tensor, in a given Domain.
virtual void compute_riemann(int) const
Computes the Riemann tensor, 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 compute_cov(int) const
Computes the covariant representation, in a given Domain.
Metric_flat_nophi fmet
Associated flat metric.
const Base_tensor & basis
The tensorial basis used.
virtual void compute_con(int) const
Computes the contravariant representation, in a given Domain.
int place_syst
Gives the location of the metric amongst the various unknowns of the associated System_of_eqs.
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_christo(int) const
Computes the Christoffel symbols, 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 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_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.
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.
Tensor do_summation_one_dom(int dd) const
Does the inner contraction of the Tensor in a given domain.
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.
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...