KADATH
domain_polar_periodic_nucleus_term_eq.cpp
1 /*
2  Copyright 2017 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 "headcpp.hpp"
21 #include "utilities.hpp"
22 #include "polar_periodic.hpp"
23 #include "point.hpp"
24 #include "array_math.hpp"
25 #include "scalar.hpp"
26 #include "tensor_impl.hpp"
27 #include "vector.hpp"
28 #include "term_eq.hpp"
29 
30 namespace Kadath {
31 
32 
34 
35 
36  Tensor val_res(*so.val_t, false) ;
37 
38  for (int cmp = 0 ; cmp<so.val_t->get_n_comp() ; cmp++) {
39  Array<int>ind (val_res.indices(cmp)) ;
40  val_res.set(ind).set_domain(num_dom) = (*so.val_t)(ind)(num_dom).der_var(3) / (*ome_term_eq->val_d) ;
41  }
42 
43  int valence = so.val_t->get_valence() ;
44  // Put name indices :
45  if (so.val_t->is_name_affected()) {
46  val_res.set_name_affected() ;
47  for (int ncmp = 0 ; ncmp<valence ; ncmp++)
48  val_res.set_name_ind (ncmp, so.val_t->get_name_ind()[ncmp]) ;
49  }
50 
51 
52  bool doder = ((so.der_t==0x0) || (ome_term_eq->der_d==0x0)) ? false : true ;
53 
54  if (doder) {
55  Tensor der_res (*so.der_t, false) ;
56  for (int cmp = 0 ; cmp<so.val_t->get_n_comp() ; cmp++) {
57  Array<int>ind (val_res.indices(cmp)) ;
58  der_res.set(ind).set_domain(num_dom) = (*so.der_t)(ind)(num_dom).der_var(3) / (*ome_term_eq->val_d) - (*ome_term_eq->der_d)* (*so.val_t)(ind)(num_dom).der_var(3) / (*ome_term_eq->val_d) / (*ome_term_eq->val_d) ;
59  }
60 
61  // Put name indices :
62  if (so.der_t->is_name_affected()) {
63  der_res.set_name_affected() ;
64  for (int ncmp = 0 ; ncmp<valence ; ncmp++)
65  der_res.set_name_ind (ncmp, so.der_t->get_name_ind()[ncmp]) ;
66  }
67 
68  return Term_eq (num_dom, val_res, der_res) ;
69  }
70  else
71  return Term_eq (num_dom, val_res) ;
72 }
73 
74 
76 
77  return dtime_term_eq(dtime_term_eq(so)) ;
78 }
79 
80 }
virtual Term_eq ddtime_term_eq(const Term_eq &so) const
Second time derivative of a Term_eq.
virtual Term_eq dtime_term_eq(const Term_eq &so) const
Updates the quantities that depend on the frequency.
Term_eq * ome_term_eq
Pointer on the Term_eq version of the pulsation.
int num_dom
Number of the current domain (used by the Space)
Definition: space.hpp:63
Val_domain & set_domain(int)
Read/write of a particular Val_domain.
Definition: scalar.hpp:555
Tensor handling.
Definition: tensor.hpp:149
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.
Definition: tensor.hpp:435
Scalar & set(const Array< int > &ind)
Returns the value of a component (read/write version).
Definition: tensor_impl.hpp:91
char const * get_name_ind() const
Definition: tensor.hpp:424
int get_n_comp() const
Returns the number of stored components.
Definition: tensor.hpp:514
virtual Array< int > indices(int pos) const
Gives the values of the indices corresponding to a location in the array used for storage of the comp...
Definition: tensor.hpp:484
int get_valence() const
Returns the valence.
Definition: tensor.hpp:509
bool is_name_affected() const
Check whether the names of the indices have been affected.
Definition: tensor.hpp:429
This class is intended to describe the manage objects appearing in the equations.
Definition: term_eq.hpp:62
Tensor * der_t
Pointer on the variation, if the Term_eq is a Tensor.
Definition: term_eq.hpp:69
double * val_d
Pointer on the value, if the Term_eq is a double.
Definition: term_eq.hpp:66
double * der_d
Pointer on the variation if the Term_eq is a double.
Definition: term_eq.hpp:67
Tensor * val_t
Pointer on the value, if the Term_eq is a Tensor.
Definition: term_eq.hpp:68