KADATH
ope_point.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 "ope_eq.hpp"
21 #include "scalar.hpp"
22 #include "tensor_impl.hpp"
23 #include "system_of_eqs.hpp"
24 namespace Kadath {
25 Ope_point::Ope_point (const System_of_eqs* zesys, const Point &MM, Ope_eq* target) :
26  Ope_eq(zesys, target->get_dom(), 1), num(MM){
27 
28  parts[0] = target ;
29  num = zesys->get_space().get_domain(dom)->absol_to_num(MM) ;
30 }
31 
33 }
34 
36  Term_eq target (parts[0]->action()) ;
37 
38  // Check it is a tensor
39  if (target.type_data != TERM_T) {
40  cerr << "Ope_point only defined with respect for a tensor" << endl ;
41  abort() ;
42  }
43 
44  if (target.val_t->get_n_comp() != 1) {
45  cerr << "Ope_point only defined with respect to a scalar (yet)" << endl ;
46  abort() ;
47  }
48 
49 
50  // The value
51  Array<int> ind (target.val_t->indices(0)) ;
52  Val_domain val ((*target.val_t)(ind)(dom)) ;
53 
54  double resval ;
55  if (val.check_if_zero())
56  resval= 0. ;
57  else {
58  val.coef() ;
59  resval = val.get_base().summation(num, val.get_coef()) ;
60  }
61  if (target.der_t!=0x0) {
62  Array<int> indder (target.der_t->indices(0)) ;
63  Val_domain valder ((*target.der_t)(ind)(dom)) ;
64 
65  double resder ;
66  if (valder.check_if_zero())
67  resder= 0. ;
68  else {
69  valder.coef() ;
70  resder = valder.get_base().summation(num, valder.get_coef()) ;
71  }
72  Term_eq res (dom, resval, resder) ;
73  return res ;
74  }
75  else {
76  Term_eq res (dom, resval) ;
77  return res ;
78  }
79 }}
double summation(const Point &num, const Array< double > &tab) const
Computes the spectral summation.
virtual const Point absol_to_num(const Point &xxx) const
Computes the numerical coordinates from the physical ones.
Definition: domain.cpp:948
Abstract class that describes the various operators that can appear in the equations.
Definition: ope_eq.hpp:32
MMPtr_array< Ope_eq > parts
Pointers of the various parts of the current operator.
Definition: ope_eq.hpp:38
int dom
Index of the Domain where the operator is defined.
Definition: ope_eq.hpp:36
~Ope_point() override
Destructor.
Definition: ope_point.cpp:32
Term_eq action() const override
Computes the action of the current Ope_eq using its various parts.
Definition: ope_point.cpp:35
Point num
Absolute coordinates of the point.
Definition: ope_eq.hpp:1001
Ope_point(const System_of_eqs *syst, const Point &pp, Ope_eq *so)
Constructor.
Definition: ope_point.cpp:25
The class Point is used to store the coordinates of a point.
Definition: point.hpp:30
const Domain * get_domain(int i) const
returns a pointer on the domain.
Definition: space.hpp:1385
Class used to describe and solve a system of equations.
const Space & get_space() const
Returns the space.
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
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
const int type_data
Flag describing the type of data :
Definition: term_eq.hpp:75
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
bool check_if_zero() const
Check whether the logical state is zero or not.
Definition: val_domain.hpp:142
void coef() const
Computes the coefficients.
Definition: val_domain.cpp:622
Array< double > get_coef() const
Definition: val_domain.hpp:136
const Base_spectral & get_base() const
Returns the basis of decomposition.
Definition: val_domain.hpp:122