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 {
24
Vector
Scalar::grad
()
const
{
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
33
Scalar
Scalar::div_r
()
const
{
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
41
Scalar
Scalar::mult_r
()
const
{
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
49
Scalar
Scalar::div_rsint
()
const
{
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
58
Scalar
Scalar::div_1mx2
()
const
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
68
Scalar
Scalar::mult_cos_theta
()
const
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
76
Scalar
Scalar::mult_sin_theta
()
const
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
84
Scalar
Scalar::mult_cos_phi
()
const
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
92
Scalar
Scalar::mult_sin_phi
()
const
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
}}
Kadath::Base_tensor
Describes the tensorial basis used by the various tensors.
Definition:
base_tensor.hpp:49
Kadath::Scalar
The class Scalar does not really implements scalars in the mathematical sense but rather tensorial co...
Definition:
scalar.hpp:67
Kadath::Scalar::mult_sin_phi
Scalar mult_sin_phi() const
Returns the multiplication by .
Definition:
scalar_calculus.cpp:92
Kadath::Scalar::set_domain
Val_domain & set_domain(int)
Read/write of a particular Val_domain.
Definition:
scalar.hpp:555
Kadath::Scalar::div_rsint
Scalar div_rsint() const
Returns the division by .
Definition:
scalar_calculus.cpp:49
Kadath::Scalar::mult_cos_theta
Scalar mult_cos_theta() const
Returns the multiplication by .
Definition:
scalar_calculus.cpp:68
Kadath::Scalar::mult_sin_theta
Scalar mult_sin_theta() const
Returns the multiplication by .
Definition:
scalar_calculus.cpp:76
Kadath::Scalar::grad
Vector grad() const
Computes the gradient (in Cartesian coordinates).
Definition:
scalar_calculus.cpp:24
Kadath::Scalar::val_zones
Memory_mapped_array< Val_domain * > val_zones
Pointers on the various Val_domain describing the field in each Domain.
Definition:
scalar.hpp:70
Kadath::Scalar::mult_r
Scalar mult_r() const
Returns the multiplication by r.
Definition:
scalar_calculus.cpp:41
Kadath::Scalar::div_r
Scalar div_r() const
Returns the division by .
Definition:
scalar_calculus.cpp:33
Kadath::Scalar::der_abs
Scalar der_abs(int) const
Returns the derivative with respect to one particular absolute Cartesian coordinate.
Definition:
scalar.cpp:149
Kadath::Scalar::div_1mx2
Scalar div_1mx2() const
Returns the division by .
Definition:
scalar_calculus.cpp:58
Kadath::Scalar::mult_cos_phi
Scalar mult_cos_phi() const
Returns the multiplication by .
Definition:
scalar_calculus.cpp:84
Kadath::Tensor::ndim
int ndim
The dimension/.
Definition:
tensor.hpp:156
Kadath::Tensor::operator()
const Scalar & operator()() const
Read only for a Scalar.
Definition:
tensor_impl.hpp:110
Kadath::Tensor::ndom
int ndom
The number of Domain.
Definition:
tensor.hpp:155
Kadath::Tensor::espace
const Space & espace
The Space.
Definition:
tensor.hpp:154
Kadath::Val_domain
Class for storing the basis of decompositions of a field and its values on both the configuration and...
Definition:
val_domain.hpp:69
Kadath::Val_domain::div_sin_theta
Val_domain div_sin_theta() const
Division by .
Definition:
val_domain_ope.cpp:50
Kadath::Vector
A class derived from Tensor to deal specificaly with objects of valence 1 (and so also 1-forms).
Definition:
vector.hpp:41
Kadath::Vector::set
Scalar & set(int)
Read/write access to a component.
Definition:
tensor_impl.hpp:239
src
Scalar
scalar_calculus.cpp
Generated by
1.9.1