KADATH
eq_matching_exception.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 "system_of_eqs.hpp"
21 #include "ope_eq.hpp"
22 #include "scalar.hpp"
23 #include "tensor_impl.hpp"
24 namespace Kadath {
25 Eq_matching_exception::Eq_matching_exception(const Domain* zedom, int dd, int bb, int other_dd, int other_bb,
26  Ope_eq* lhs, Ope_eq* rhs, const Param& par, Ope_eq* exception, int nused, Array<int>** pused) :
27  Equation(zedom, dd, 3, nused, pused), bound(bb), other_dom(other_dd), other_bound(other_bb), parameters(par) {
28  parts[0] = lhs ;
29  parts[1] = rhs ;
30  parts[2] = exception ;
31 }
32 
34 }
35 
36 void Eq_matching_exception::export_val(int& conte, Term_eq** residus, Array<double>& sec, int& pos_res) const {
37 
38  assert (residus[conte]->get_type_data()==TERM_T) ;
39  assert (residus[conte+1]->get_type_data()==TERM_T) ;
40  assert (residus[conte+2]->get_type_data()==TERM_T) ;
41 
42  int start = pos_res ;
43  dom->export_tau_boundary_exception (residus[conte]->get_val_t(), ndom, bound, sec, pos_res, *n_cond,
44  parameters, 1, residus[conte+2]->get_val_t(), n_cmp_used, p_cmp_used) ;
45  Array<double> auxi (pos_res - start) ;
46  auxi = 0. ;
47  int zero = 0 ;
49  (residus[conte+1]->get_val_t(), other_dom, other_bound, auxi, zero, *n_cond, parameters, 2, residus[conte+2]->get_val_t(), n_cmp_used, p_cmp_used) ;
50  for (int i =start ; i<pos_res ; i++)
51  sec.set(i) -= auxi(i-start) ;
52  conte +=3 ;
53 }
54 
55 void Eq_matching_exception::export_der(int& conte, Term_eq** residus, Array<double>& sec, int& pos_res) const {
56 
57  assert (residus[conte]->get_type_data()==TERM_T) ;
58  assert (residus[conte+1]->get_type_data()==TERM_T) ;
59  assert (residus[conte+2]->get_type_data()==TERM_T) ;
60 
61  int start = pos_res ;
62  dom->export_tau_boundary_exception (residus[conte]->get_der_t(), ndom, bound, sec, pos_res, *n_cond, parameters, 3, residus[conte+2]->get_der_t(),
64  Array<double> auxi (pos_res - start) ;
65  auxi = 0. ;
66  int zero = 0 ;
68  (residus[conte+1]->get_der_t(), other_dom, other_bound, auxi, zero, *n_cond, parameters, 4, residus[conte+2]->get_der_t(),
70  for (int i =start ; i<pos_res ; i++)
71  sec.set(i) -= auxi(i-start) ;
72  conte +=3 ;
73 }
74 
77 }
78 
79 
81  if ((target==ndom) || (target==other_dom))
82  return true ;
83  else
84  return false ;
85 }
86 
87 }
reference set(const Index &pos)
Read/write of an element.
Definition: array.hpp:186
Abstract class that implements the fonctionnalities common to all the type of domains.
Definition: space.hpp:60
virtual Array< int > nbr_conditions_boundary(const Tensor &eq, int dom, int bound, int n_cmp=-1, Array< int > **p_cmp=0x0) const
Computes number of discretized equations associated with a given tensorial equation on a boundary.
Definition: domain.cpp:1516
virtual void export_tau_boundary_exception(const Tensor &eq, int dom, int bound, Array< double > &res, int &pos_res, const Array< int > &ncond, const Param &param, int type_exception, const Tensor &exception, int n_cmp=-1, Array< int > **p_cmp=0x0) const
Exports all the residual equations corresponding to one tensorial one on a given boundary,...
Definition: domain.cpp:1550
virtual ~Eq_matching_exception()
Destructor.
Eq_matching_exception(const Domain *dom, int nd, int bb, int oz_nd, int oz_bb, Ope_eq *ope, Ope_eq *oz_ope, const Param &par, Ope_eq *ope_exc, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Constructor.
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
const Param & parameters
Parameters needed for describing the exception.
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
bool take_into_account(int) const override
Check whether the variation of the residual has to be taken into account when computing a given colum...
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
int other_dom
Number of the Domain on the other side of the boundary.
int other_bound
Name of the boundary as seen from the other domain.
Class implementing an equation.
const Domain * dom
Pointer on the Domain where the equation is defined.
Array< int > ** p_cmp_used
Array of pointer on the indices of the used components.
int ndom
Number of the domain.
int n_cmp_used
Number of components used (by default the same thing as n_comp).
Array< int > * n_cond
Number of discretized equations, component by component.
MMPtr_array< Ope_eq > parts
Array of pointers on the various terms.
Abstract class that describes the various operators that can appear in the equations.
Definition: ope_eq.hpp:32
Parameter storage.
Definition: param.hpp:30
const Domain * get_domain(int i) const
returns a pointer on the domain.
Definition: space.hpp:1385
Tensor handling.
Definition: tensor.hpp:149
const Space & get_space() const
Returns the Space.
Definition: tensor.hpp:499
This class is intended to describe the manage objects appearing in the equations.
Definition: term_eq.hpp:62
Tensor const & get_val_t() const
Definition: term_eq.hpp:355