KADATH
ope_mode.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 namespace Kadath {
24 Ope_mode::Ope_mode (const System_of_eqs* zesys, int bb, const Index &pp, double vv, Ope_eq* target) :
25  Ope_eq(zesys, target->get_dom(), 1), bound(bb), pos_cf (pp), value(vv) {
26  parts[0] = target ;
27 }
28 
30 }
31 
33  Term_eq target (parts[0]->action()) ;
34  // Check it is a tensor
35  if (target.type_data != TERM_T) {
36  cerr << "Ope_int only defined with respect for a tensor" << endl ;
37  abort() ;
38  }
39 
40  if (target.val_t->get_n_comp() != 1) {
41  cerr << "Ope_mode only defined with respect to a scalar (yet)" << endl ;
42  abort() ;
43  }
44 
45  // The value
46  Array<int> ind (target.val_t->indices(0)) ;
47  Val_domain val ((*target.val_t)(ind)(dom)) ;
48  double resval ;
49  if (val.check_if_zero())
50  resval= 0. ;
51  else
52  resval = val.get_domain()->val_boundary(bound, val, pos_cf) - value ;
53 
54  if (target.der_t!=0x0) {
55  Val_domain val_der ((*target.der_t)(ind)(dom)) ;
56  double resder ;
57  if (val_der.check_if_zero())
58  resder = 0. ;
59  else
60  resder = val_der.get_domain()->val_boundary(bound, val_der, pos_cf) ;
61  Term_eq res (dom, resval, resder) ;
62  return res ;
63  }
64  else {
65  Term_eq res (dom, resval) ;
66  return res ;
67  }
68 }}
virtual double val_boundary(int bound, const Val_domain &so, const Index &ind) const
Computes the value of a field at a boundary.
Definition: domain.cpp:1581
Class that gives the position inside a multi-dimensional Array.
Definition: index.hpp:38
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
double value
The result is the coefficient minus value.
Definition: ope_eq.hpp:934
Ope_mode(const System_of_eqs *syst, int bb, const Index &ind, double val, Ope_eq *so)
Constructor.
Definition: ope_mode.cpp:24
Term_eq action() const override
Computes the action of the current Ope_eq using its various parts.
Definition: ope_mode.cpp:32
Index pos_cf
The desired coefficient.
Definition: ope_eq.hpp:933
int bound
The boundary where the coefficients are read.
Definition: ope_eq.hpp:928
~Ope_mode() override
Destructor.
Definition: ope_mode.cpp:29
Class used to describe and solve a system of equations.
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
const Domain * get_domain() const
Definition: val_domain.hpp:111