KADATH
metric_conf_factor_const.cpp
1 /*
2  Copyright 2019 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 #include "space.hpp"
21 #include "tensor.hpp"
22 #include "metric_nophi.hpp"
23 #include "term_eq.hpp"
24 #include "scalar.hpp"
25 #include "tensor_impl.hpp"
26 #include "system_of_eqs.hpp"
27 #include "metric_tensor.hpp"
28 #include "name_tools.hpp"
29 
30 namespace Kadath {
32  Metric_conf_factor(met, ome) {
33  type_tensor = met.get_type() ;
34 
35  // Compute the flat gradient of conformal factor (trick pass by Term_eq even if not needed)
36  for (int d=0 ; d<espace.get_nbr_domains() ; d++) {
37  Term_eq res (fmet.derive (COV, ' ', Term_eq (d, conformal))) ;
38  for (int i=1 ; i<=3 ; i++)
39  grad_conf.set(i).set_domain(d) = (*res.val_t)(i)(d) ;
40  }
41 }
42 
43 
45  Metric_conf_factor (so) {
46 }
47 
48 Metric_conf_factor_const::~Metric_conf_factor_const() {
49 }
50 
51 
52 
54 
55 
56  int place = place_syst + (dd-syst->dom_min) ;
57  // Right storage : simple copy.
58  if (type_tensor==COV) {
59 
60  if (p_met_cov[dd]==0x0)
61  p_met_cov[dd] = new Term_eq(*syst->cst[place]) ;
62  else
63  *p_met_cov[dd] = Term_eq(*syst->cst[place]) ;
64  }
65  else {
66  Term_eq** res = new Term_eq* [p_met->get_n_comp()] ;
67 
68  Scalar val (espace) ;
69 
70  Val_domain detval (espace.get_domain(dd)) ;
71  detval = (*syst->cst[place]->val_t)(1,1)(dd)*(*syst->cst[place]->val_t)(2,2)(dd)*(*syst->cst[place]->val_t)(3,3)(dd)
72  + (*syst->cst[place]->val_t)(1,2)(dd)*(*syst->cst[place]->val_t)(2,3)(dd)*(*syst->cst[place]->val_t)(1,3)(dd)
73  + (*syst->cst[place]->val_t)(1,3)(dd)*(*syst->cst[place]->val_t)(1,2)(dd)*(*syst->cst[place]->val_t)(2,3)(dd)
74  - (*syst->cst[place]->val_t)(1,3)(dd)*(*syst->cst[place]->val_t)(1,3)(dd)*(*syst->cst[place]->val_t)(2,2)(dd)
75  - (*syst->cst[place]->val_t)(2,3)(dd)*(*syst->cst[place]->val_t)(2,3)(dd)*(*syst->cst[place]->val_t)(1,1)(dd)
76  - (*syst->cst[place]->val_t)(1,2)(dd)*(*syst->cst[place]->val_t)(1,2)(dd)*(*syst->cst[place]->val_t)(3,3)(dd) ;
77 
78  Val_domain cmpval(espace.get_domain(dd)) ;
79 
80  // Compo 1 1
81  cmpval = (*syst->cst[place]->val_t)(2,2)(dd)*(*syst->cst[place]->val_t)(3,3)(dd)
82  -(*syst->cst[place]->val_t)(2,3)(dd)*(*syst->cst[place]->val_t)(2,3)(dd) ;
83  val.set_domain(dd) = cmpval / detval;
84  res[0] = new Term_eq (dd, val) ;
85 
86  // Compo 1 2
87  cmpval = (*syst->cst[place]->val_t)(1,3)(dd)*(*syst->cst[place]->val_t)(2,3)(dd)
88  -(*syst->cst[place]->val_t)(1,2)(dd)*(*syst->cst[place]->val_t)(3,3)(dd) ;
89  val.set_domain(dd) = cmpval / detval ;
90  res[1] = new Term_eq (dd, val) ;
91 
92  // Compo 1 3
93  cmpval = (*syst->cst[place]->val_t)(1,2)(dd)*(*syst->cst[place]->val_t)(2,3)(dd)
94  -(*syst->cst[place]->val_t)(1,3)(dd)*(*syst->cst[place]->val_t)(2,2)(dd) ;
95  val.set_domain(dd) = cmpval / detval ;
96  res[2] = new Term_eq (dd, val) ;
97 
98  // Compo 2 2
99  cmpval = (*syst->cst[place]->val_t)(1,1)(dd)*(*syst->cst[place]->val_t)(3,3)(dd)
100  -(*syst->cst[place]->val_t)(1,3)(dd)*(*syst->cst[place]->val_t)(1,3)(dd) ;
101  val.set_domain(dd) = cmpval / detval ;
102  res[3] = new Term_eq (dd, val) ;
103 
104  // Compo 2 3
105  cmpval = (*syst->cst[place]->val_t)(1,3)(dd)*(*syst->cst[place]->val_t)(1,2)(dd)
106  -(*syst->cst[place]->val_t)(1,1)(dd)*(*syst->cst[place]->val_t)(2,3)(dd) ;
107  val.set_domain(dd) = cmpval / detval ;
108  res[4] = new Term_eq (dd, val) ;
109 
110  // Compo 3 3
111  cmpval = (*syst->cst[place]->val_t)(1,1)(dd)*(*syst->cst[place]->val_t)(2,2)(dd)
112  -(*syst->cst[place]->val_t)(1,2)(dd)*(*syst->cst[place]->val_t)(1,2)(dd) ;
113  val.set_domain(dd) = cmpval / detval ;
114  res[5] = new Term_eq (dd, val) ;
115 
116  // Value field :
117  Metric_tensor resval (espace, COV, basis) ;
118  resval.set(1,1) = res[0]->get_val_t() ;
119  resval.set(1,2) = res[1]->get_val_t() ;
120  resval.set(1,3) = res[2]->get_val_t() ;
121  resval.set(2,2) = res[3]->get_val_t() ;
122  resval.set(2,3) = res[4]->get_val_t() ;
123  resval.set(3,3) = res[5]->get_val_t() ;
124 
125 
126  Metric_tensor zero (espace, COV, basis) ;
127  for (int i=1 ; i<=3 ; i++)
128  for (int j=i ; j<=3 ; j++)
129  zero.set(i,j) = 0 ;
130 
131 
132  if (p_met_cov[dd]==0x0)
133  p_met_cov[dd] = new Term_eq(dd, resval, zero) ;
134  else
135  *p_met_cov[dd] = Term_eq(dd, resval, zero) ;
136 
137  for (int i=0 ; i<p_met->get_n_comp() ; i++)
138  delete res [i] ;
139  delete [] res ;
140  }
141 }
142 
143 
145 
146  int place = place_syst + (dd-syst->dom_min) ;
147  // Right storage : simple copy.
148  if (type_tensor==CON) {
149 
150  if (p_met_con[dd]==0x0)
151  p_met_con[dd] = new Term_eq(*syst->cst[place]) ;
152  else
153  *p_met_con[dd] = Term_eq(*syst->cst[place]) ;
154  }
155  else {
156  //Need to work component by components...
157  Term_eq** res = new Term_eq* [p_met->get_n_comp()] ;
158 
159  Scalar val (espace) ;
160  Val_domain cmpval(espace.get_domain(dd)) ;
161 
162  Val_domain detval (espace.get_domain(dd)) ;
163  detval = (*syst->cst[place]->val_t)(1,1)(dd)*(*syst->cst[place]->val_t)(2,2)(dd)*(*syst->cst[place]->val_t)(3,3)(dd)
164  + (*syst->cst[place]->val_t)(1,2)(dd)*(*syst->cst[place]->val_t)(2,3)(dd)*(*syst->cst[place]->val_t)(1,3)(dd)
165  + (*syst->cst[place]->val_t)(1,3)(dd)*(*syst->cst[place]->val_t)(1,2)(dd)*(*syst->cst[place]->val_t)(2,3)(dd)
166  - (*syst->cst[place]->val_t)(1,3)(dd)*(*syst->cst[place]->val_t)(1,3)(dd)*(*syst->cst[place]->val_t)(2,2)(dd)
167  - (*syst->cst[place]->val_t)(2,3)(dd)*(*syst->cst[place]->val_t)(2,3)(dd)*(*syst->cst[place]->val_t)(1,1)(dd)
168  - (*syst->cst[place]->val_t)(1,2)(dd)*(*syst->cst[place]->val_t)(1,2)(dd)*(*syst->cst[place]->val_t)(3,3)(dd) ;
169 
170 
171  // Compo 1 1
172  cmpval = (*syst->cst[place]->val_t)(2,2)(dd)*(*syst->cst[place]->val_t)(3,3)(dd)
173  -(*syst->cst[place]->val_t)(2,3)(dd)*(*syst->cst[place]->val_t)(2,3)(dd) ;
174  val.set_domain(dd) = cmpval / detval;
175  res[0] = new Term_eq (dd, val) ;
176 
177  // Compo 1 2
178  cmpval = (*syst->cst[place]->val_t)(1,3)(dd)*(*syst->cst[place]->val_t)(2,3)(dd)
179  -(*syst->cst[place]->val_t)(1,2)(dd)*(*syst->cst[place]->val_t)(3,3)(dd) ;
180  val.set_domain(dd) = cmpval / detval;
181  res[1] = new Term_eq (dd, val) ;
182 
183  // Compo 1 3
184  cmpval = (*syst->cst[place]->val_t)(1,2)(dd)*(*syst->cst[place]->val_t)(2,3)(dd)
185  -(*syst->cst[place]->val_t)(1,3)(dd)*(*syst->cst[place]->val_t)(2,2)(dd) ;
186  val.set_domain(dd) = cmpval / detval;
187  res[2] = new Term_eq (dd, val) ;
188 
189  // Compo 2 2
190  cmpval = (*syst->cst[place]->val_t)(1,1)(dd)*(*syst->cst[place]->val_t)(3,3)(dd)
191  -(*syst->cst[place]->val_t)(1,3)(dd)*(*syst->cst[place]->val_t)(1,3)(dd) ;
192  val.set_domain(dd) = cmpval / detval;
193  res[3] = new Term_eq (dd, val) ;
194 
195  // Compo 2 3
196  cmpval = (*syst->cst[place]->val_t)(1,3)(dd)*(*syst->cst[place]->val_t)(1,2)(dd)
197  -(*syst->cst[place]->val_t)(1,1)(dd)*(*syst->cst[place]->val_t)(2,3)(dd) ;
198  val.set_domain(dd) = cmpval / detval ;
199  res[4] = new Term_eq (dd, val) ;
200 
201  // Compo 3 3
202  cmpval = (*syst->cst[place]->val_t)(1,1)(dd)*(*syst->cst[place]->val_t)(2,2)(dd)
203  -(*syst->cst[place]->val_t)(1,2)(dd)*(*syst->cst[place]->val_t)(1,2)(dd) ;
204  val.set_domain(dd) = cmpval / detval;
205  res[5] = new Term_eq (dd, val) ;
206 
207  // Value field :
208  Metric_tensor resval (espace, CON, basis) ;
209  resval.set(1,1) = res[0]->get_val_t() ;
210  resval.set(1,2) = res[1]->get_val_t() ;
211  resval.set(1,3) = res[2]->get_val_t() ;
212  resval.set(2,2) = res[3]->get_val_t() ;
213  resval.set(2,3) = res[4]->get_val_t() ;
214  resval.set(3,3) = res[5]->get_val_t() ;
215 
216  Metric_tensor zero (espace, CON, basis) ;
217  for (int i=1 ; i<=3 ; i++)
218  for (int j=i ; j<=3 ; j++)
219  zero.set(i,j) = 0 ;
220 
221 
222  if (p_met_con[dd]==0x0)
223  p_met_con[dd] = new Term_eq(dd, resval, zero) ;
224  else
225  *p_met_con[dd] = Term_eq(dd, resval, zero) ;
226 
227  for (int i=0 ; i<p_met->get_n_comp() ; i++)
228  delete res [i] ;
229  delete [] res ;
230  }
231 }
232 
233 void Metric_conf_factor_const::set_system (System_of_eqs& ss, const char* name_met) {
234 
235  syst = &ss ;
236 
237  // Position in the system :
238  place_syst = ss.ndom*ss.ncst ;
239 
240  // unknown for the system (no name, the name is in the metric already)
241  ss.add_cst (0x0, *p_met) ;
242 
243  if (ss.met!=0x0) {
244  cerr << "Metric already set for the system" << endl ;
245  abort() ;
246  }
247 
248  ss.met = this ;
249  ss.name_met = new char[LMAX] ;
250  trim_spaces (ss.name_met, name_met) ;
251 }
252 }
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_con(int) const
Computes the contravariant representation, in a given Domain.
Metric_conf_factor_const(Metric_tensor &, const Scalar &conf)
Constructor from a Metric_tensor and a conformal factor.
Class to deal with a metric with a conformal decomposition (mainly used for AADS spacetimes) The true...
Definition: metric.hpp:562
Metric_flat fmet
Associated flat metric.
Definition: metric.hpp:567
Vector grad_conf
flat gradient of the conformal factor
Definition: metric.hpp:569
Metric_tensor * p_met
Pointer on the Metric_tensor describing the coformal metric.
Definition: metric.hpp:565
int place_syst
Gives the location of the metric amongst the various unknowns of the associated System_of_eqs.
Definition: metric.hpp:570
Scalar conformal
The conformal factor (must be a purely radial function)
Definition: metric.hpp:568
const Base_tensor & basis
The tensorial basis used.
Definition: metric.hpp:566
virtual Term_eq derive(int, char, const Term_eq &) const
Computes the covariant derivative of a Term_eq (assumes Cartesian basis of decomposition).
Particular type of Tensor, dedicated to the desription of metrics.
int type_tensor
States if one works in the CON or COV representation.
Definition: metric.hpp:86
const Space & espace
The associated Space.
Definition: metric.hpp:42
MMPtr_array< Term_eq > p_met_cov
Array of pointers on various Term_eq.
Definition: metric.hpp:50
MMPtr_array< Term_eq > p_met_con
Array of pointers on various Term_eq.
Definition: metric.hpp:55
const System_of_eqs * syst
Pointer of the system of equations where the metric is used (only one for now).
Definition: metric.hpp:44
The class Scalar does not really implements scalars in the mathematical sense but rather tensorial co...
Definition: scalar.hpp:67
Val_domain & set_domain(int)
Read/write of a particular Val_domain.
Definition: scalar.hpp:555
const Domain * get_domain(int i) const
returns a pointer on the domain.
Definition: space.hpp:1385
int get_nbr_domains() const
Returns the number of Domains.
Definition: space.hpp:1375
Class used to describe and solve a system of equations.
virtual void add_cst(const char *name, double cst)
Addition of a constant (number case)
int ndom
Number of domains used.
MMPtr_array< Term_eq > cst
Pointers on the Term_eq coming from the constants passed by the user.
char * name_met
Name by which the metric is recognized.
int ncst
Number of constants passed by the user.
int dom_min
Smallest domain number.
Metric * met
Pointer on the associated Metric, if defined.
Scalar & set(const Array< int > &ind)
Returns the value of a component (read/write version).
Definition: tensor_impl.hpp:91
int get_n_comp() const
Returns the number of stored components.
Definition: tensor.hpp:514
This class is intended to describe the manage objects appearing in the equations.
Definition: term_eq.hpp:62
Tensor const & get_val_t() const
Definition: term_eq.hpp:355
Tensor * val_t
Pointer on the value, if the Term_eq is a Tensor.
Definition: term_eq.hpp:68
Class for storing the basis of decompositions of a field and its values on both the configuration and...
Definition: val_domain.hpp:69
Scalar & set(int)
Read/write access to a component.