KADATH
eq_vel_pot.cpp
1 /*
2  Copyright 2019 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 "term_eq.hpp"
23 #include "scalar.hpp"
24 #include "tensor_impl.hpp"
25 namespace Kadath {
26 Eq_vel_pot::Eq_vel_pot(const Domain* zedom, int dd, int ord, Ope_eq* so, Ope_eq* constant) : Equation(zedom, dd, 2), order(ord) {
27  parts[0] = so ;
28  parts[1] = constant ;
29 }
30 
32 }
33 
34 void Eq_vel_pot::export_val (int& conte, Term_eq** residus, Array<double>& sec, int& pos_res) const {
35 
36  assert (residus[conte]->get_type_data()==TERM_T) ;
37  assert (residus[conte]->get_val_t().get_valence()==0) ; //only defined for a scalar field so far
38 
39  assert (residus[conte+1]->get_type_data()==TERM_T) ;
40  assert (residus[conte+1]->get_val_t().get_valence()==0) ;
41 
42  int old_pos = pos_res ;
43 
44  dom->export_tau (residus[conte]->get_val_t(), ndom, order, sec, pos_res, *n_cond) ;
45 
46  // Get the first coef (a bit long probably but anyway...)
47  Array<double> auxi (pos_res - old_pos) ;
48  auxi = 0. ;
49  int zero = 0 ;
50  dom->export_tau(residus[conte+1]->get_val_t(), ndom, order, auxi, zero, *n_cond) ;
51 
52  // Put the coef in the right place
53  sec.set(old_pos) = auxi(0) ;
54 
55  conte += 2 ;
56 }
57 
58 void Eq_vel_pot::export_der (int& conte, Term_eq** residus, Array<double>& sec, int& pos_res) const {
59 
60  assert (residus[conte]->get_type_data()==TERM_T) ;
61  assert (residus[conte]->get_der_t().get_valence()==0) ; //only defined for a scalar field so far
62 
63  assert (residus[conte+1]->get_type_data()==TERM_T) ;
64  assert (residus[conte+1]->get_der_t().get_valence()==0) ;
65 
66  int old_pos = pos_res ;
67 
68  dom->export_tau (residus[conte]->get_der_t(), ndom, order, sec, pos_res, *n_cond) ;
69 
70  // Get the first coef (a bit long probably but anyway...)
71  Array<double> auxi (pos_res - old_pos) ;
72  auxi = 0. ;
73  int zero = 0 ;
74  dom->export_tau(residus[conte+1]->get_der_t(), ndom, order, auxi, zero, *n_cond) ;
75 
76  // Put the coef in the right place
77  sec.set(old_pos) = auxi(0) ;
78 
79 
80  conte +=2 ;
81 }
82 
84  return dom->nbr_conditions (tt, ndom, order) ;
85 }
86 
87 bool Eq_vel_pot::take_into_account (int target) const {
88  if (target == ndom)
89  return true ;
90  else
91  return false ;
92 }
93 
94 }
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 void export_tau(const Tensor &eq, int dom, int order, Array< double > &res, int &pos_res, const Array< int > &ncond, int n_cmp=-1, Array< int > **p_cmp=0x0) const
Exports all the residual equations corresponding to a tensorial one in the bulk.
Definition: domain.cpp:1533
virtual Array< int > nbr_conditions(const Tensor &eq, int dom, int order, int n_cmp=-1, Array< int > **p_cmp=0x0) const
Computes number of discretized equations associated with a given tensorial equation in the bulk.
Definition: domain.cpp:1504
int order
Order of 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...
Definition: eq_vel_pot.cpp:87
virtual ~Eq_vel_pot()
Destructor.
Definition: eq_vel_pot.cpp:31
Eq_vel_pot(const Domain *dom, int nd, int ord, Ope_eq *ope, Ope_eq *ope_constant)
Constructor.
Definition: eq_vel_pot.cpp:26
void export_der(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized variations, from the various Term_eq computed by the equation.
Definition: eq_vel_pot.cpp:58
void export_val(int &, Term_eq **, Array< double > &, int &) const override
Generates the discretized errors, from the various Term_eq computed by the equation.
Definition: eq_vel_pot.cpp:34
Array< int > do_nbr_conditions(const Tensor &tt) const override
Computes the number of conditions associated with the equation.
Definition: eq_vel_pot.cpp:83
Class implementing an equation.
const Domain * dom
Pointer on the Domain where the equation is defined.
int ndom
Number of the domain.
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
Tensor handling.
Definition: tensor.hpp:149
This class is intended to describe the manage objects appearing in the equations.
Definition: term_eq.hpp:62