KADATH
bin_fake_add_eq.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 "headcpp.hpp"
21 #include "bin_fake.hpp"
22 #include "utilities.hpp"
23 #include "point.hpp"
24 #include "scalar.hpp"
25 #include "tensor_impl.hpp"
26 #include "system_of_eqs.hpp"
27 #include "name_tools.hpp"
28 
29 namespace Kadath {
30 void Space_bin_fake::add_eq (System_of_eqs& sys, const char* eq, const char* rac, const char* rac_der, int nused, Array<int>** pused) {
31 
32  // Stars
33  sys.add_eq_inside (0, eq, nused, pused) ;
34  sys.add_eq_inside (1, eq, nused, pused) ;
35 
36  // Matching with bispheric
37  sys.add_eq_matching_import (0, OUTER_BC, rac, nused, pused) ;
38  sys.add_eq_matching_import (2, INNER_BC, rac_der, nused, pused) ;
39  sys.add_eq_matching_import (3, INNER_BC, rac_der, nused, pused) ;
40 
41  sys.add_eq_matching_import (1, OUTER_BC, rac, nused, pused) ;
42  sys.add_eq_matching_import (5, INNER_BC, rac_der, nused, pused) ;
43  sys.add_eq_matching_import (6, INNER_BC, rac_der, nused, pused) ;
44 
45  // Chi first
46  sys.add_eq_inside (2, eq, nused, pused) ;
47  sys.add_eq_matching (2, CHI_ONE_BC, rac, nused, pused) ;
48  sys.add_eq_matching (2, CHI_ONE_BC, rac_der, nused, pused) ;
49 
50  // Rect :
51  sys.add_eq_inside (3, eq, nused, pused) ;
52  sys.add_eq_matching (3, ETA_PLUS_BC, rac, nused, pused) ;
53  sys.add_eq_matching (3, ETA_PLUS_BC, rac_der, nused, pused) ;
54 
55  // Eta first
56  sys.add_eq_inside (4, eq, nused, pused) ;
57  sys.add_eq_matching (4, ETA_PLUS_BC, rac, nused, pused) ;
58  sys.add_eq_matching (4, ETA_PLUS_BC, rac_der, nused, pused) ;
59 
60  // Rect
61  sys.add_eq_inside (5, eq, nused, pused) ;
62  sys.add_eq_matching (5, CHI_ONE_BC, rac, nused, pused) ;
63  sys.add_eq_matching (5, CHI_ONE_BC, rac_der, nused, pused) ;
64 
65  // chi first :
66  sys.add_eq_inside (6, eq, nused, pused) ;
67 
68  // Matching outer domain :
69  for (int d=2 ; d<=6 ; d++)
70  sys.add_eq_matching_import (d, OUTER_BC, rac, nused, pused) ;
71  sys.add_eq_matching_import (7, INNER_BC, rac_der, nused, pused) ;
72 
73  // Shell :
74  sys.add_eq_inside (7, eq, nused, pused) ;
75  sys.add_eq_matching (7, OUTER_BC, rac, nused, pused) ;
76  sys.add_eq_matching (7, OUTER_BC, rac_der, nused, pused) ;
77 
78  //Compactified domain
79  sys.add_eq_inside (8, eq, nused, pused) ;
80 }
81 
82 void Space_bin_fake::add_eq_nozec (System_of_eqs& sys, const char* eq, const char* rac, const char* rac_der, int nused, Array<int>** pused) {
83 
84  // Stars
85  sys.add_eq_inside (0, eq, nused, pused) ;
86  sys.add_eq_inside (1, eq, nused, pused) ;
87 
88  // Matching with bispheric
89  sys.add_eq_matching_import (0, OUTER_BC, rac, nused, pused) ;
90  sys.add_eq_matching_import (2, INNER_BC, rac_der, nused, pused) ;
91  sys.add_eq_matching_import (3, INNER_BC, rac_der, nused, pused) ;
92 
93  sys.add_eq_matching_import (1, OUTER_BC, rac, nused, pused) ;
94  sys.add_eq_matching_import (5, INNER_BC, rac_der, nused, pused) ;
95  sys.add_eq_matching_import (6, INNER_BC, rac_der, nused, pused) ;
96 
97  // Chi first
98  sys.add_eq_inside (2, eq, nused, pused) ;
99  sys.add_eq_matching (2, CHI_ONE_BC, rac, nused, pused) ;
100  sys.add_eq_matching (2, CHI_ONE_BC, rac_der, nused, pused) ;
101 
102  // Rect :
103  sys.add_eq_inside (3, eq, nused, pused) ;
104  sys.add_eq_matching (3, ETA_PLUS_BC, rac, nused, pused) ;
105  sys.add_eq_matching (3, ETA_PLUS_BC, rac_der, nused, pused) ;
106 
107  // Eta first
108  sys.add_eq_inside (4, eq, nused, pused) ;
109  sys.add_eq_matching (4, ETA_PLUS_BC, rac, nused, pused) ;
110  sys.add_eq_matching (4, ETA_PLUS_BC, rac_der, nused, pused) ;
111 
112  // Rect
113  sys.add_eq_inside (5, eq, nused, pused) ;
114  sys.add_eq_matching (5, CHI_ONE_BC, rac, nused, pused) ;
115  sys.add_eq_matching (5, CHI_ONE_BC, rac_der, nused, pused) ;
116 
117  // chi first :
118  sys.add_eq_inside (6, eq, nused, pused) ;
119 
120  // Matching outer domain :
121  for (int d=2 ; d<=6 ; d++)
122  sys.add_eq_matching_import (d, OUTER_BC, rac, nused, pused) ;
123  sys.add_eq_matching_import (7, INNER_BC, rac_der, nused, pused) ;
124 
125  // Shell :
126  sys.add_eq_inside (7, eq, nused, pused) ;
127 
128 }
129 
130 void Space_bin_fake::add_eq_int_inf (System_of_eqs& sys, const char* nom) {
131 
132  // Check the last domain is of the right type :
133  const Domain_compact* pcomp = dynamic_cast <const Domain_compact*> (domains[nbr_domains-1]) ;
134  if (pcomp==0x0) {
135  cerr << "add_eq_int_inf requires a compactified domain" << endl ;
136  abort() ;
137  }
138  int dom = nbr_domains-1 ;
139 
140  // Get the lhs and rhs
141  char p1[LMAX] ;
142  char p2[LMAX] ;
143  bool indic = sys.is_ope_bin(nom, p1, p2, '=') ;
144  if (!indic) {
145  cerr << "= needed for equations" << endl ;
146  abort() ;
147  }
148  else {
149  // Verif lhs = 0 ?
150  indic = ((p2[0]=='0') && (p2[1]==' ') && (p2[2]=='\0')) ?
151  true : false ;
152 
153  // Construction of the equation
154  sys.eq_int[sys.neq_int] = new Eq_int(1) ;
155 
156  // Affectation :
157  // no lhs :
158  if (indic)
159  sys.eq_int[sys.neq_int]->set_part(0, sys.give_ope(dom, p1, OUTER_BC)) ;
160 
161  else
162  sys.eq_int[sys.neq_int]->set_part(0, new Ope_sub(&sys, sys.give_ope(dom, p1, OUTER_BC), sys.give_ope(dom, p2, OUTER_BC))) ;
163  sys.neq_int ++ ;
164  }
165  sys.nbr_conditions = -1 ;
166 } }
Class for a spherical compactified domain and a symmetry with respect to the plane .
Definition: spheric.hpp:1007
Class implementing an integral equation.
The operator substraction.
Definition: ope_eq.hpp:165
void add_eq_int_inf(System_of_eqs &syst, const char *eq)
Adds an equation being a surface integral at infinity.
void add_eq(System_of_eqs &syst, const char *eq, const char *rac, const char *rac_der, int nused=-1, Array< int > **pused=0x0)
Adds a bulk equation and two matching conditions.
void add_eq_nozec(System_of_eqs &syst, const char *eq, const char *rac, const char *rac_der, int nused=-1, Array< int > **pused=0x0)
Adds a bulk equation and two matching conditions.
Domain ** domains
Pointers on the various Domains.
Definition: space.hpp:1368
int nbr_domains
Number od Domains.
Definition: space.hpp:1365
Class used to describe and solve a system of equations.
virtual void add_eq_inside(int dom, const char *eq, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Addition of an equation to be solved inside a domain (assumed to be second order).
Definition: add_eq.cpp:26
virtual void add_eq_matching_import(int dom, int bb, const char *eq, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Addition of an equation describing a matching condition between domains using the ("import" setting) ...
Definition: add_eq.cpp:344
virtual void add_eq_matching(int dom, int bb, const char *eq, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Addition of an equation describing a matching condition between two domains (standard setting)
Definition: add_eq.cpp:198
int neq_int
Number of integral equations (i.e. which are doubles)
bool is_ope_bin(const char *input, char *p1, char *p2, char symb) const
Checks if a string represents an operator of the type "a + b".
Definition: give_ope.cpp:276
Ope_eq * give_ope(int dom, const char *name, int bb=0) const
Function that reads a string and returns a pointer on the generated Ope_eq.
Definition: give_ope.cpp:559
int nbr_conditions
Total number of conditions (the number of coefficients of all the equations, once regularities are ta...
MMPtr_array< Eq_int > eq_int
Pointers onto the integral equations.