20 #include "system_of_eqs.hpp"
21 #include "name_tools.hpp"
22 #include "term_eq.hpp"
23 #include "base_tensor.hpp"
28 trim_spaces (auxi, name) ;
41 for (
int i=0 ; i<
nvar ; i++) {
50 res = is_tensor(name,
names_var[i], valence, name_ind, type_ind) ;
53 if (valence !=
var[which]->get_valence()) {
54 cerr <<
"Bad valence for " << name << endl ;
65 for (
int i=0 ; i<
ncst ; i++) {
69 int type_cst =
cst[ind]->get_type_data() ;
81 res = is_tensor(name,
names_cst[i], valence, name_ind, type_ind) ;
84 if (valence !=
cst[ind]->get_val_t().get_valence()) {
85 cerr <<
"Bad valence for " << name << endl ;
97 cerr <<
"Unknown type of data in System_of_eqs::iscst" << endl ;
108 for (
int i=0 ; i<
ndef ; i++) {
109 if (name_ind !=0x0) {
113 if (type_ind !=0x0) {
117 res = is_tensor(name,
names_def[i], valence, name_ind, type_ind) ;
118 if ((res) && (
def[i]->get_dom()==dd)) {
142 val = strtod (name, &error);
143 bool res = ((*error !=
' ') || (strlen(error)>1)) ? false : true ;
152 bool res = is_tensor(name,
name_met, valence, name_ind, type_ind) ;
155 cerr <<
"Bad valence for the metric " <<
name_met <<
" in " << name << endl ;
159 if ((*type_ind)(0)!=(*type_ind)(1)) {
160 cerr <<
"Indices of the metric must be of the same type" << endl ;
164 type_indice = (*type_ind)(0) ;
173 trim_spaces(auxi, name) ;
190 bool res = is_tensor(name,
"Gam ", valence, name_ind, type_ind) ;
193 cerr <<
"Bad valence for Christoffel symbol in " << name << endl ;
197 if (((*type_ind)(0)!=COV) || ((*type_ind)(1)!=COV) || ((*type_ind)(2)!=CON)) {
198 cerr <<
"Indices of the wrong type in " << name << endl ;
210 bool res = is_tensor(name,
"R ", valence, name_ind, type_ind) ;
216 if (((*type_ind)(0)!=CON) || ((*type_ind)(1)!=COV) || ((*type_ind)(2)!=COV) || ((*type_ind)(3)!=COV)) {
238 bool res = is_tensor(name,
"R ", valence, name_ind, type_ind) ;
239 if ((res) && (valence != 2)) {
259 bool res = is_tensor(name,
"R ", valence, name_ind, type_ind) ;
260 if ((res) && (valence != 0)) {
277 assert ((cible==
'+') || (cible==
'-') || (cible==
'*') || (cible==
'/') || (cible==
'=')) ;
280 int nbr_cible = nbr_char(name, cible) ;
283 while ((!res) && (conte<nbr_cible)) {
284 get_parts(name, part1, part2, cible, conte) ;
285 if ((part1[0] !=
'\0') && (part2[0]!=
'\0'))
286 if ((nbr_char(part1,
'(')==nbr_char(part1,
')')) && (nbr_char(part2,
'(')==nbr_char(part2,
')')))
297 trim_spaces(auxi, name) ;
298 int len =
static_cast<int>(strlen(auxi)) ;
305 for (
int i=1 ; i<len-1 ; i++)
306 occi[i-1] = auxi[i] ;
309 trim_spaces(part, occi) ;
318 trim_spaces(auxi, zeope) ;
319 int len =
static_cast<int>(strlen(auxi)) ;
322 for (
int i=0 ; i<len-1 ; i++)
323 if (name[i]!=auxi[i]) {
329 if (name[len-1]!=
'(')
334 int lentot =
static_cast<int>(strlen(name)) ;
335 assert (name[lentot-1]==
' ') ;
336 if (name[lentot-2]!=
')')
339 for (
int i=len ; i<lentot-2 ; i++)
340 part[i-len] = name[i] ;
342 part[lentot-len-2] =
' ' ;
343 part[lentot-len-1] =
'\0' ;
353 trim_spaces(auxi, zeope) ;
354 int len =
static_cast<int>(strlen(auxi)) ;
356 for (
int i=0 ; i<len-2 ; i++)
357 if (name[i]!=auxi[i]) {
362 if (name[len-1]!=
'(')
369 int lentot =
static_cast<int>(strlen(name)) ;
370 assert (name[lentot-1]==
' ') ;
371 if (name[lentot-2]!=
')')
374 for (
int i=len ; i<lentot-2 ; i++)
375 part[i-len] = name[i] ;
377 part[lentot-len-2] =
' ' ;
378 part[lentot-len-1] =
'\0' ;
380 get_parts(part, p1, p2,
',') ;
387 trim_spaces(name, nn) ;
389 int len =
static_cast<int>(strlen(name)) ;
411 for (
int i=3 ; i<len ; i++)
412 auxi[i-3] = name[i] ;
414 trim_spaces(part, auxi) ;
421 trim_spaces(name, nn) ;
423 int len =
static_cast<int>(strlen(name)) ;
447 for (
int i=4 ; i<len ; i++)
448 auxi[i-4] = name[i] ;
450 trim_spaces(part, auxi) ;
457 trim_spaces(name, nn) ;
459 int len =
static_cast<int>(strlen(name)) ;
483 for (
int i=4 ; i<len ; i++)
484 auxi[i-4] = name[i] ;
486 trim_spaces(part, auxi) ;
493 trim_spaces(name, nn) ;
495 int len =
static_cast<int>(strlen(name)) ;
498 if (strncmp(name,
"partial", 7) != 0)
511 for (
int i=9 ; i<len ; i++)
512 auxi[i-9] = name[i] ;
514 trim_spaces(part, auxi) ;
521 trim_spaces(auxi, name) ;
523 bool res = (nbr_char(auxi,
'^')>=1) ?
true :
false ;
528 get_parts(auxi, part, p2,
'^') ;
532 expo =
static_cast<int>(strtol (p2, &error, 0));
533 res = ((*error !=
' ') || (strlen(error)>1)) ? false : true ;
542 trim_spaces(auxi, name) ;
544 bool res = (nbr_char(name,
',')==1) ?
true :
false ;
547 get_parts(auxi, part, p2,
',') ;
900 indic =
is_ope_uni(name, p1,
"inversenodet") ;
907 indic =
is_ope_uni(name, p1, p2,
"fitwaves") ;
939 p_ope =
new Ope_der (
this, type_der, ind_der,
give_ope(dd,p1, bound)) ;
990 char* name_ind = 0x0 ;
992 indic =
isvar (name, which, valence, name_ind, type_ind) ;
994 p_ope =
new Ope_id (
this,
give_term(which, dd), valence, name_ind, type_ind) ;
1002 indic =
ismet (name, name_ind, type_indice) ;
1005 type_ind->
set(0) = type_indice ; type_ind->
set(1) = type_indice ;
1013 indic =
ischristo (name, name_ind, type_ind) ;
1022 indic =
isriemann (name, name_ind, type_ind) ;
1049 indic = is_tensor(name,
"dirac ", valence, name_ind, type_ind) ;
1052 cerr <<
"Dirac operator must be of valence one" << endl ;
1062 indic = is_tensor(name,
"normal ", valence, name_ind, type_ind) ;
1065 cerr <<
"Normal vector operator must be of valence one" << endl ;
1069 cerr <<
"Metric must be passed to call normal" << endl ;
1080 indic =
iscst (name, which, valence, name_ind, type_ind) ;
1085 p_ope =
new Ope_id (
this,
give_cst(which, dd), valence, name_ind, type_ind) ;
1101 indic =
isdef (dd, name, which, valence, name_ind, type_ind) ;
1103 p_ope =
new Ope_id (
this,
give_def(which)->get_res(), valence, name_ind, type_ind) ;
1132 assert (p_ope==0x0) ;
1133 cerr <<
"Unknown operator " << name << endl ;
reference set(const Index &pos)
Read/write of an element.
virtual const Term_eq * give_normal(int bound, int tipe) const
Returns the vector normal to a surface.
virtual int give_place_var(char *name) const
Translates a name of a coordinate into its corresponding numerical name.
const Term_eq * give_riemann(int dd) const
Gives the Riemann tensor, in a Domain.
const Term_eq * give_christo(int dd) const
Gives the Christoffel symbols, in a Domain.
const Term_eq * give_term(int typemet, int dd) const
Gives one representation of the metric, in a Domain.
const Term_eq * give_dirac(int dd) const
Gives the potential of the Dirac gauge, in a 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 int give_type(int) const
Returns the type of tensorial basis of the covariant representation, in a given Domain.
Operator inverse hyperbolic tangent (only defined for a scalar field or a double)
Operator changin the tensorial basis of a field.
Complex conjugate (only changes the m_quant parameter so far).
Operator cosine (only defined for a scalar field or a double)
Operator hyperbolic cosine (only defined for a scalar field or a double)
The operator second derivative wrt .
The operator second radial derivative.
The operator second derivative wrt .
Second time derivative Computes the second time derivative.
The operator covariant derivative with respect to the background metric.
The operator covariant derivative with respect to the flat metric.
The operator covariant derivative.
The operator determinant.
The operator division by (for AADS spacetimes).
The operator division by .
The operator division by .
The operator division by .
The operator division by .
The operator division by .
The operator division by .
The operator normal derivative Computes the derivative in the direction normal to a given boundary.
The operator first radial derivative.
The operator first derivative wrt .
The operator time derivative.
Abstract class that describes the various operators that can appear in the equations.
Operator exponential (only defined for a scalar field or a double)
Operator that fits a field to outgoing waves (highly specialized stuff)
The operator flat gradient Intended for systems where no metric has been defined.
Operator importing the values of a field from a neighborig Domain.
The operator volume integral (in a given Domain)
The operator surface integral.
The operator inverse (of a Metric_tensor ; i.e.
The operator inverse (of a Metric_tensor ; i.e.
The operator Laplacian 2D.
The operator Laplacian 3D.
Operator logarithm (only defined for a scalar field or a double)
The operator multiplication by (for AADS spacetimes).
The operator multiplication by .
The operator multiplication by .
The operator multiplication by .
The operator multiplication by (what it means depend on the Space considered).
The operator Multiplication.
The operator partial derivative wrt one variable (same thing as Ope_partial ??)
The operator partial derivative.
The operator flat scalar product Intended for systems where no metric has been defined.
Operator sine (only defined for a scalar field or a double)
Operator hyperbolic sine (only defined for a scalar field or a double)
Operator square-root (only defined for a scalar field or a double).
Operator square-root (only defined for a scalar field or a double).
Operator square-root (only defined for a scalar field or a double)
The operator multiplication by .
The operator substraction.
Operator defined by the user in the System_of_eqs This version is intended to work with two arguments...
Operator defined by the user in the System_of_eqs This version is intended to work with one argument.
This operator gives the value of a field at the origin.
const Domain * get_domain(int i) const
returns a pointer on the domain.
MMPtr_array< Ope_def > def
Pointers on the definition (i.e. on the Ope_def that is needed to compute the result).
bool isvar(const char *target, int &which, int &valence, char *&name_ind, Array< int > *&type_ind) const
Check if a string is an unknown field.
MMPtr_array< Param > paruser
Parameters used by the user defined operators (single argument).
int nvar_double
Number of unknowns that are numbers (i.e. not fields)
int nopeuser_bin
Number of operators defined by the user (with two arguments).
bool isvar_double(const char *target, int &which) const
Check if a string is an unknown (number).
Term_eq * give_term_double(int which, int dd) const
Returns a pointer on a Term_eq corresponding to an unknown number.
bool is_ope_der_var(int dd, const char *input, char *p1, int &which) const
Checks if a string represents the derivative wrt a numerical coordinate of a given Domain (like "a,...
bool isricci_tensor(const char *input, char *&name_ind, Array< int > *&type_ind) const
Checks if a string represents the Ricci tensor.
MMPtr_array< Ope_def_global > def_glob
Pointers on the global definitions.
MMPtr_array< char > names_def_glob
Names of the global definitions.
bool is_ope_minus(const char *input, char *output) const
Checks if a string contains the operator minus.
MMPtr_array< char > names_var
Names of the unknown fields.
bool is_ope_uni(const char *input, char *p1, const char *nameope) const
Checks if a string represents an operator of the type "ope(a)".
Term_eq * give_cst_hard(double xx, int dd) const
Returns a pointer on a Term_eq corresponding to a constant generated on the fly.
bool is_ope_deriv_background(const char *input, char *p1, int &typeder, char &nameind) const
Checks if a string represents the covariant derivative wrt a background metric.
Term_eq * give_term(int which, int dd) const
Returns a pointer on a Term_eq corresponding to an unknown field.
Ope_def * give_def(int i) const
Returns a pointer on a definition (better to use give_val_def if one wants to access the result of so...
bool isdouble(const char *input, double &output) const
Checks if a string is a double.
bool ischristo(const char *input, char *&name_ind, Array< int > *&type_ind) const
Checks if a string represents the Christoffel symbols.
MMPtr_array< char > names_opeuser_bin
Names of the user defined operators (with two arguments).
int ndom
Number of domains used.
int ndef_glob
Number of global definitions (the one that require the knowledge of the whole space to give the resul...
bool isriemann(const char *input, char *&name_ind, Array< int > *&type_ind) const
Checks if a string represents the Riemann tensor.
Ope_def_global * give_def_glob(int i) const
Returns a pointer on a global definition.
bool is_ope_pow(const char *input, char *p1, int &expo) const
Checks if a string represents the power of something (like "a^2").
bool iscst(const char *target, int &which, int &valence, char *&name_ind, Array< int > *&type_ind) const
Check if a string is a constant (can required indices manipulation and/or inner contraction).
MMPtr_array< char > names_opeuser
Names of the user defined operators (single argument).
bool is_ope_partial(const char *input, char *p1, char &nameind) const
Checks if a string represents the partial derivative (like "partial_i a")
bool is_ope_bin(const char *input, char *p1, char *p2, char symb) const
Checks if a string represents an operator of the type "a + b".
bool ismet(const char *input, char *&name_ind, int &type_ind) const
Checks if a string is a metric.
int nopeuser
Number of operators defined by the user (single argument).
MMPtr_array< Param > paruser_bin
Parameters used by the user defined operators (with two arguments).
MMPtr_array< Tensor > var
Pointer on the unknown fields.
bool isdef_glob(int dd, const char *target, int &which) const
Check if a string is a global definition.
MMPtr_array< Term_eq > cst
Pointers on the Term_eq coming from the constants passed by the user.
Ope_eq * give_ope(int dom, const char *name, int bb=0) const
Function that reads a string and returns a pointer on the generated Ope_eq.
MMPtr_array< char > names_cst
Names of the constants passed by the user.
bool isricci_scalar(const char *input, char *&name_ind, Array< int > *&type_ind) const
Checks if a string represents the Ricci scalar.
int ndef
Number of definitions.
MMPtr_array< char > names_var_double
Names of the unknowns that are numbers (i.e. not fields)
char * name_met
Name by which the metric is recognized.
bool is_ope_deriv(const char *input, char *p1, int &typeder, char &nameind) const
Checks if a string represents the covariant derivative.
bool isdef(int dd, const char *target, int &which, int &valence, char *&name_ind, Array< int > *&type_ind) const
Check if a string is a definition (can required indices manipulation and/or inner contraction).
const Space & espace
Associated Space.
MMPtr_array< char > names_def
Names of the definitions.
int ncst
Number of constants passed by the user.
Term_eq * give_cst(int which, int dd) const
Returns a pointer on a Term_eq corresponding to a constant.
bool is_ope_deriv_flat(const char *input, char *p1, int &typeder, char &nameind) const
Checks if a string represents the flat covariant derivative.
Metric * met
Pointer on the associated Metric, if defined.
int nvar
Number of unknown fields.
Term_eq(* opeuser_bin[VARMAX])(const Term_eq &, const Term_eq &, Param *)
Pointers on the functions used by the user defined operators (with two arguments).
Term_eq(* opeuser[VARMAX])(const Term_eq &, Param *)
Pointers on the functions used by the user defined operators (single argument).