KADATH
scalar_calculus.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 "scalar.hpp"
21 #include "tensor_impl.hpp"
22 #include "vector.hpp"
23 namespace Kadath {
25 
26  Base_tensor base (espace, CARTESIAN_BASIS) ;
27  Vector res(espace, COV, base) ;
28  for (int i=0 ; i<ndim ; i++)
29  res.set(i+1) = der_abs(i+1) ;
30  return res ;
31 }
32 
34  Scalar res (*this, false) ;
35  for (int dom=0 ; dom<ndom ; dom++)
36  res.set_domain(dom) = val_zones[dom]->zone->div_r(*val_zones[dom]) ;
37 
38  return res ;
39 }
40 
42  Scalar res (*this, false) ;
43  for (int dom=0 ; dom<ndom ; dom++)
44  res.set_domain(dom) = val_zones[dom]->zone->mult_r(*val_zones[dom]) ;
45 
46  return res ;
47 }
48 
50  Scalar res (*this, false) ;
51  for (int dom=0 ; dom<ndom ; dom++) {
52  Val_domain auxi (val_zones[dom]->zone->div_r(*val_zones[dom])) ;
53  res.set_domain(dom) = auxi.div_sin_theta() ;
54  }
55  return res ;
56 }
57 
59 {
60  Scalar res (*this, false) ;
61  for (int dom(0) ; dom < ndom ; ++dom)
62  {
63  res.set_domain(dom) = operator()(dom).div_1mx2();
64  }
65  return res ;
66 }
67 
69 {
70  Scalar res (*this, false) ;
71  for (int dom(0) ; dom < ndom ; ++dom)
72  res.set_domain(dom) = operator()(dom).mult_cos_theta();
73  return res ;
74 }
75 
77 {
78  Scalar res (*this, false) ;
79  for (int dom(0) ; dom < ndom ; ++dom)
80  res.set_domain(dom) = operator()(dom).mult_sin_theta();
81  return res ;
82 }
83 
85 {
86  Scalar res (*this, false) ;
87  for (int dom(0) ; dom < ndom ; ++dom)
88  res.set_domain(dom) = operator()(dom).mult_cos_phi();
89  return res ;
90 }
91 
93 {
94  Scalar res (*this, false) ;
95  for (int dom(0) ; dom < ndom ; ++dom)
96  res.set_domain(dom) = operator()(dom).mult_sin_phi();
97  return res ;
98 }}
Describes the tensorial basis used by the various tensors.
Definition: base_tensor.hpp:49
The class Scalar does not really implements scalars in the mathematical sense but rather tensorial co...
Definition: scalar.hpp:67
Scalar mult_sin_phi() const
Returns the multiplication by .
Val_domain & set_domain(int)
Read/write of a particular Val_domain.
Definition: scalar.hpp:555
Scalar div_rsint() const
Returns the division by .
Scalar mult_cos_theta() const
Returns the multiplication by .
Scalar mult_sin_theta() const
Returns the multiplication by .
Vector grad() const
Computes the gradient (in Cartesian coordinates).
Memory_mapped_array< Val_domain * > val_zones
Pointers on the various Val_domain describing the field in each Domain.
Definition: scalar.hpp:70
Scalar mult_r() const
Returns the multiplication by r.
Scalar div_r() const
Returns the division by .
Scalar der_abs(int) const
Returns the derivative with respect to one particular absolute Cartesian coordinate.
Definition: scalar.cpp:149
Scalar div_1mx2() const
Returns the division by .
Scalar mult_cos_phi() const
Returns the multiplication by .
int ndim
The dimension/.
Definition: tensor.hpp:156
const Scalar & operator()() const
Read only for a Scalar.
int ndom
The number of Domain.
Definition: tensor.hpp:155
const Space & espace
The Space.
Definition: tensor.hpp:154
Class for storing the basis of decompositions of a field and its values on both the configuration and...
Definition: val_domain.hpp:69
Val_domain div_sin_theta() const
Division by .
A class derived from Tensor to deal specificaly with objects of valence 1 (and so also 1-forms).
Definition: vector.hpp:41
Scalar & set(int)
Read/write access to a component.