23 #include "term_eq.hpp"
25 #include "tensor_impl.hpp"
26 #include "system_of_eqs.hpp"
30 espace {sp}, syst{nullptr},
31 p_met_cov{espace.get_nbr_domains()}, p_met_con{espace.get_nbr_domains()},
32 p_christo{espace.get_nbr_domains()}, p_riemann{espace.get_nbr_domains()},
33 p_ricci_tensor{espace.get_nbr_domains()}, p_ricci_scalar{espace.get_nbr_domains()},
34 p_dirac{espace.get_nbr_domains()}, p_det_cov{espace.get_nbr_domains()},
50 espace {so.espace}, syst{so.syst},
51 p_met_cov{espace.get_nbr_domains()}, p_met_con{espace.get_nbr_domains()},
52 p_christo{espace.get_nbr_domains()}, p_riemann{espace.get_nbr_domains()},
53 p_ricci_tensor{espace.get_nbr_domains()}, p_ricci_scalar{espace.get_nbr_domains()},
54 p_dirac{espace.get_nbr_domains()}, p_det_cov{espace.get_nbr_domains()},
55 type_tensor{so.type_tensor}
113 cerr <<
"Unknown type of indice in Metric::give_term" << endl ;
121 return (
p_met_cov[dd]->val_t->get_basis().get_basis(dd)) ;
168 cerr <<
"No background metric defined" << endl ;
191 cerr <<
"Metric::derive partial only defined for tensor data" << endl ;
197 cerr <<
"Metric::derive_partial only defined for tensor on cartesian triad" << endl ;
202 bool doder = ((so.
der_t==
nullptr) || (
p_met_cov[dom]->der_t==
nullptr) || (
p_met_cov[dom]->der_t==
nullptr)) ? false : true ;
204 assert ((type_der==COV) || (type_der==CON)) ;
213 type_ind.
set(0) = COV ;
214 for (
int i=1 ; i<val_res ; i++)
218 bool need_sum = false ;
220 for (
int i=1 ; i<val_res ; i++)
230 for (
int i=1 ; i<val_res ; i++)
235 Index pos_auxi(auxi_val) ;
238 for (
int i=0 ; i<val_res-1 ; i++)
239 pos_so.
set(i) = pos_auxi(i+1) ;
240 auxi_val.
set(pos_auxi).
set_domain(dom) = (*so.
val_t)(pos_so)(dom).der_abs(pos_auxi(0)+1) ;
242 while (pos_auxi.
inc()) ;
263 for (
int i=1 ; i<val_res ; i++)
267 Index pos_auxi_der(auxi_der) ;
269 for (
int i=0 ; i<val_res-1 ; i++)
270 pos_so.
set(i) = pos_auxi_der(i+1) ;
271 auxi_der.
set(pos_auxi_der).
set_domain(dom) = (*so.
der_t)(pos_so)(dom).der_abs(pos_auxi_der(0)+1) ;
273 while (pos_auxi_der.
inc()) ;
276 Term_eq auxi (dom, auxi_val, auxi_der) ;
301 if (ind_der==
char(start))
311 while ((!found) && (start<123)) ;
313 cerr <<
"Trouble with indices in derive (you are not using tensors of order > 24, are you ?)" << endl ;
316 char name_sum = char(start) ;
321 bool doder = ((so.
der_t==
nullptr) || (
p_christo[dd]->der_t==
nullptr)) ?
false :
true ;
329 p_christo[dd]->val_t->set_name_affected() ;
330 p_christo[dd]->val_t->set_name_ind(0, ind_der) ;
331 if (genre_indice==COV) {
333 p_christo[dd]->val_t->set_name_ind(2, name_sum) ;
337 p_christo[dd]->val_t->set_name_ind(1, name_sum) ;
341 p_christo[dd]->der_t->set_name_affected() ;
342 p_christo[dd]->der_t->set_name_ind(0, ind_der) ;
343 if (genre_indice==COV) {
345 p_christo[dd]->der_t->set_name_ind(2, name_sum) ;
349 p_christo[dd]->der_t->set_name_ind(1, name_sum) ;
359 bool need_sum = false ;
360 char const * ind =
p_christo[dd]->val_t->get_name_ind() ;
361 if ((ind[0]==ind[2]) || (ind[1]==ind[2]) || (ind[0]==ind[1]))
372 christ =
new Term_eq (auxi_christ) ;
391 Term_eq part_christo ((*christ)*copie) ;
394 if (genre_indice==CON)
395 res = res + part_christo ;
397 res = res - part_christo ;
403 cerr <<
"derive_flat not implemented for this type of metric (yet)" << endl ;
423 bool doder = ((
p_met_con[dd]->der_t==
nullptr) || (
p_met_cov[dd]->der_t==
nullptr)) ?
false :
true ;
426 type_ind.
set(0) = COV ; type_ind.
set(1) = COV ; type_ind.
set(2) = CON ;
433 Index pos (res_val) ;
440 (*
p_met_con[dd]->val_t)(pos(2)+1,l)(dd)*((*
p_met_cov[dd]->val_t)(pos(1)+1,l)(dd).der_abs(pos(0)+1) +
441 (*
p_met_cov[dd]->val_t)(pos(0)+1,l)(dd).der_abs(pos(1)+1) - (*
p_met_cov[dd]->val_t)(pos(1)+1,pos(0)+1)(dd).der_abs(l))) ;
451 (*
p_met_con[dd]->der_t)(pos(2)+1,l)(dd)*((*
p_met_cov[dd]->val_t)(pos(1)+1,l)(dd).der_abs(pos(0)+1) +
452 (*
p_met_cov[dd]->val_t)(pos(0)+1,l)(dd).der_abs(pos(1)+1) - (*
p_met_cov[dd]->val_t)(pos(1)+1,pos(0)+1)(dd).der_abs(l)))
454 (*
p_met_con[dd]->val_t)(pos(2)+1,l)(dd)*((*
p_met_cov[dd]->der_t)(pos(1)+1,l)(dd).der_abs(pos(0)+1) +
455 (*
p_met_cov[dd]->der_t)(pos(0)+1,l)(dd).der_abs(pos(1)+1) - (*
p_met_cov[dd]->der_t)(pos(1)+1,pos(0)+1)(dd).der_abs(l))) ;
482 bool doder = ((
p_met_con[dd]->der_t==
nullptr) || (
p_met_cov[dd]->der_t==
nullptr)) ?
false :
true ;
484 indices.
set(0) = CON ; indices.
set(1) = COV ; indices.
set(2) = COV ; indices.
set(3) = COV ;
488 Index pos (res_val) ;
492 cmpval = (*
p_christo[dd]->val_t)(pos(1)+1,pos(3)+1,pos(0)+1)(dd).
der_abs(pos(2)+1) -
493 (*
p_christo[dd]->val_t)(pos(1)+1, pos(2)+1, pos(0)+1)(dd).
der_abs(pos(3)+1) ;
496 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)
497 - (*
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) ;
503 cmpder = (*
p_christo[dd]->der_t)(pos(1)+1,pos(3)+1,pos(0)+1)(dd).
der_abs(pos(2)+1) -
504 (*
p_christo[dd]->der_t)(pos(1)+1, pos(2)+1, pos(0)+1)(dd).
der_abs(pos(3)+1) ;
507 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)
508 + (*
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)
509 - (*
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)
510 - (*
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) ;
538 bool doder = ((
p_met_con[dd]->der_t==
nullptr) || (
p_met_cov[dd]->der_t==
nullptr)) ?
false :
true ;
542 Index pos (res_val) ;
550 cmpval += (*
p_christo[dd]->val_t)(k,l,l)(dd)*(*
p_christo[dd]->val_t)(pos(0)+1,pos(1)+1,k)(dd)
551 - (*
p_christo[dd]->val_t)(pos(0)+1,k,l)(dd)*(*
p_christo[dd]->val_t)(pos(1)+1,l,k)(dd) ;
563 cmpder += (*
p_christo[dd]->der_t)(k,l,l)(dd)*(*
p_christo[dd]->val_t)(pos(0)+1,pos(1)+1,k)(dd)
566 - (*
p_christo[dd]->val_t)(pos(0)+1,k,l)(dd)*(*
p_christo[dd]->der_t)(pos(1)+1,l,k)(dd) ;
665 if ((type_start==COV) && (
p_met_con[dd]->der_t!=
nullptr) && (so.
der_t!=
nullptr))
667 if ((type_start==CON) && (
p_met_cov[dd]->der_t!=
nullptr) && (so.
der_t!=
nullptr))
671 for (
int i=0 ; i<valence ; i++)
677 Index pos (val_res) ;
686 cmpval += (*
p_met_con[dd]->val_t)(pos(ind)+1, k+1)(dd) * (*so.
val_t)(copie)(dd);
688 cmpval += (*
p_met_cov[dd]->val_t)(pos(ind)+1, k+1)(dd) * (*so.
val_t)(copie)(dd) ;
700 cmpder += (*
p_met_con[dd]->der_t)(pos(ind)+1, k+1)(dd) * (*so.
val_t)(copie)(dd)
701 +(*
p_met_con[dd]->val_t)(pos(ind)+1, k+1)(dd) * (*so.
der_t)(copie)(dd);
703 cmpder += (*
p_met_cov[dd]->der_t)(pos(ind)+1, k+1)(dd) * (*so.
val_t)(copie)(dd)
704 + (*
p_met_cov[dd]->val_t)(pos(ind)+1, k+1)(dd) * (*so.
der_t)(copie)(dd) ;
715 for (
int i=0 ; i<valence ; i++)
721 for (
int i=0 ; i<valence ; i++)
725 so.
set_val_t()->set_index_type (ind) *= -1 ;
727 so.
set_der_t()->set_index_type (ind) *= -1 ;
732 so.
der_t = (doder) ?
new Tensor (val_der) : nullptr ;
736 cerr <<
"compute_cov not implemented for this type of metric" << endl ;
741 cerr <<
"compute_con not implemented for this type of metric" << endl ;
746 cerr <<
"Compute Dirac not implemented for this type of metric" << endl ;
751 cerr <<
"Compute determinant of covariant not implemented for this type of metric" << endl ;
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.
int & set(int i)
Read/write of the position in a given dimension.
bool inc(int increm, int var=0)
Increments the position of the Index.
Purely abstract class for metric handling.
virtual void compute_det_cov(int) const
Computes the determinant of the covariant representation, in a given Domain.
const Term_eq * give_riemann(int dd) const
Gives the Riemann tensor, in a Domain.
int type_tensor
States if one works in the CON or COV representation.
const Term_eq * give_christo(int dd) const
Gives the Christoffel symbols, in a Domain.
const Term_eq * give_det_cov(int dd) const
Gives the determinant of the covariant metric, in a Domain.
MMPtr_array< Term_eq > p_ricci_tensor
Array of pointers on various Term_eq.
const Term_eq * give_term(int typemet, int dd) const
Gives one representation of the metric, in a Domain.
virtual Term_eq derive_partial(int typeder, char nameder, const Term_eq &so) const
Computes the partial derivative of a Term_eq (assumes Cartesian basis of decomposition).
const Term_eq * give_dirac(int dd) const
Gives the potential of the Dirac gauge, in a Domain.
virtual Term_eq derive(int typeder, char nameder, const Term_eq &so) const
Computes the covariant derivative of a Term_eq (assumes Cartesian basis of decomposition).
virtual void compute_dirac(int) const
Computes the Dirac gauge term, in a given Domain.
const Term_eq * give_ricci_scalar(int dd) const
Gives the Ricci scalar, in a Domain.
const Term_eq * give_ricci_tensor(int dd) const
Gives the Ricci tensor, in a Domain.
virtual void compute_con(int) const
Computes the contravariant representation, in a given Domain.
virtual void compute_ricci_tensor(int) const
Computes the Ricci tensor, in a given Domain.
virtual void update()
Updates the derived quantities (Christoffels etc..) This is done only for the ones that are needed,...
virtual const Metric * get_background() const
Returns a pointer on the background metric, if it exists.
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.
virtual void compute_ricci_scalar(int) const
Computes the Ricci scalar, in a given Domain.
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.
virtual void compute_christo(int) const
Computes the Christoffel symbols, in a given Domain.
MMPtr_array< Term_eq > p_ricci_scalar
Array of pointers on various Term_eq.
MMPtr_array< Term_eq > p_det_cov
Array of pointers on various Term_eq.
virtual ~Metric()
Destructor.
Metric(const Space &)
Constructor from a Space only (internal use only).
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.
virtual Term_eq derive_flat(int typeder, char nameder, const Term_eq &so) const
Computes the covariant flat derivative of a Term_eq.
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.
The Space class is an ensemble of domains describing the whole space of the computation.
const Domain * get_domain(int i) const
returns a pointer on the domain.
int get_ndim() const
Returns the number of dimensions.
int get_nbr_domains() const
Returns the number of Domains.
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.
const Base_tensor & get_basis() const
Returns the vectorial basis (triad) on which the components are defined.
int get_valence() const
Returns the valence.
bool is_name_affected() const
Check whether the names of the indices have been affected.
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.
void set_der_t(Tensor)
Sets the tensorial variation (only the values in the pertinent Domain are copied).
int get_type_data() const
Tensor const & get_val_t() const
Tensor const & get_der_t() const
void set_val_t(Tensor)
Sets the tensorial value (only the values in the pertinent Domain are copied).
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...
Val_domain der_abs(int i) const
Computes the derivative with respect to an absolute coordinate (typically Cartesian).