KADATH
bin_bh_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_bh.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 namespace Kadath {
29 void Space_bin_bh::add_bc_sphere_one (System_of_eqs& sys, const char* name, int nused, Array<int>** pused) {
30  sys.add_eq_bc (2, INNER_BC, name, nused, pused) ;
31 }
32 
33 void Space_bin_bh::add_bc_sphere_two (System_of_eqs& sys, const char* name, int nused, Array<int>** pused) {
34  sys.add_eq_bc (5, INNER_BC, name, nused, pused) ;
35 }
36 
37 void Space_bin_bh::add_bc_outer (System_of_eqs& sys, const char* name, int nused, Array<int>** pused) {
38  sys.add_eq_bc (11, OUTER_BC, name, nused, pused) ;
39 }
40 
41 void Space_bin_bh::add_eq (System_of_eqs& sys, const char* eq, const char* rac, const char* rac_der, int nused, Array<int>** pused) {
42 
43  // First bh
44  sys.add_eq_inside (2, eq, nused, pused) ;
45 
46  // Matching with bispheric :
47  sys.add_eq_matching_import (2, OUTER_BC, rac, nused, pused) ;
48  sys.add_eq_matching_import (6, INNER_BC, rac_der, nused, pused) ;
49  sys.add_eq_matching_import (7, INNER_BC, rac_der, nused, pused) ;
50 
51  // Second BH :
52  sys.add_eq_inside (5, eq, nused, pused) ;
53 
54  // Matching with bispheric :
55  sys.add_eq_matching_import (5, OUTER_BC, rac, nused, pused) ;
56  sys.add_eq_matching_import (9, INNER_BC, rac_der, nused, pused) ;
57  sys.add_eq_matching_import (10, INNER_BC, rac_der, nused, pused) ;
58 
59  // Chi first
60  sys.add_eq_inside (6, eq, nused, pused) ;
61  sys.add_eq_matching (6, CHI_ONE_BC, rac, nused, pused) ;
62  sys.add_eq_matching (6, CHI_ONE_BC, rac_der, nused, pused) ;
63 
64  // Rect :
65  sys.add_eq_inside (7, eq, nused, pused) ;
66  sys.add_eq_matching (7, ETA_PLUS_BC, rac, nused, pused) ;
67  sys.add_eq_matching (7, ETA_PLUS_BC, rac_der, nused, pused) ;
68 
69  // Eta first
70  sys.add_eq_inside (8, eq, nused, pused) ;
71  sys.add_eq_matching (8, ETA_PLUS_BC, rac, nused, pused) ;
72  sys.add_eq_matching (8, ETA_PLUS_BC, rac_der, nused, pused) ;
73 
74  // Rect
75  sys.add_eq_inside (9, eq, nused, pused) ;
76  sys.add_eq_matching (9, CHI_ONE_BC, rac, nused, pused) ;
77  sys.add_eq_matching (9, CHI_ONE_BC, rac_der, nused, pused) ;
78 
79 
80  // chi first :
81  sys.add_eq_inside (10, eq, nused, pused) ;
82 
83  // Matching outer domain :
84  for (int d=6 ; d<=10 ; d++)
85  sys.add_eq_matching_import (d, OUTER_BC, rac, nused, pused) ;
86  sys.add_eq_matching_import (11, INNER_BC, rac_der, nused, pused) ;
87 
88  //Compactified domain
89  sys.add_eq_inside (11, eq, nused, pused) ;
90 
91 }
92 
93 
94 void Space_bin_bh::add_eq_int_inf (System_of_eqs& sys, const char* nom) {
95 
96  // Check the last domain is of the right type :
97  const Domain_compact* pcomp = dynamic_cast <const Domain_compact*> (domains[nbr_domains-1]) ;
98 #ifndef REMOVE_ALL_CHECKS
99  if (pcomp==nullptr) {
100  cerr << "add_eq_int_inf requires a compactified domain" << endl ;
101  abort() ;
102  }
103 #endif
104  int dom = nbr_domains-1 ;
105 
106  // Get the lhs and rhs
107  char p1[LMAX] ;
108  char p2[LMAX] ;
109  bool indic = sys.is_ope_bin(nom, p1, p2, '=') ;
110  if (!indic) {
111  cerr << "= needed for equations" << endl ;
112  abort() ;
113  }
114  else {
115  // Verif lhs = 0 ?
116  indic = ((p2[0]=='0') && (p2[1]==' ') && (p2[2]=='\0')) ?
117  true : false ;
118 
119  // Construction of the equation
120  sys.eq_int[sys.neq_int] = new Eq_int(1) ;
121 
122  // Affectation :
123  // no lhs :
124  if (indic)
125  sys.eq_int[sys.neq_int]->set_part(0, sys.give_ope(dom, p1, OUTER_BC)) ;
126 
127  else
128  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))) ;
129  sys.neq_int ++ ;
130  }
131  sys.nbr_conditions = -1 ;
132 }
133 
134 
136 
137  // Get the lhs and rhs
138  char p1[LMAX] ;
139  char p2[LMAX] ;
140  bool indic = sys.is_ope_bin(nom, p1, p2, '=') ;
141  if (!indic) {
142  cerr << "= needed for equations" << endl ;
143  abort() ;
144  }
145  else {
146 
147  // Verif lhs = 0 ?
148  indic = ((p2[0]=='0') && (p2[1]==' ') && (p2[2]=='\0')) ?
149  true : false ;
150 
151  // Construction of the equation
152  sys.eq_int[sys.neq_int] = new Eq_int(1) ;
153 
154  // Affectation :
155  // no lhs :
156  if (indic) {
157  sys.eq_int[sys.neq_int]->set_part(0, sys.give_ope(2, p1, INNER_BC)) ;
158  }
159  else {
160  sys.eq_int[sys.neq_int]->set_part(0,
161  new Ope_sub(&sys, sys.give_ope(2, p1, INNER_BC), sys.give_ope(2, p2, INNER_BC))) ;
162  }
163  }
164  sys.neq_int ++ ;
165  sys.nbr_conditions = -1 ;
166 }
167 
169 
170  // Get the lhs and rhs
171  char p1[LMAX] ;
172  char p2[LMAX] ;
173  bool indic = sys.is_ope_bin(nom, p1, p2, '=') ;
174  if (!indic) {
175  cerr << "= needed for equations" << endl ;
176  abort() ;
177  }
178  else {
179 
180  // Verif lhs = 0 ?
181  indic = ((p2[0]=='0') && (p2[1]==' ') && (p2[2]=='\0')) ?
182  true : false ;
183 
184  // Construction of the equation
185  sys.eq_int[sys.neq_int] = new Eq_int(1) ;
186 
187  // Affectation :
188  // no lhs :
189  if (indic) {
190  sys.eq_int[sys.neq_int]->set_part(0, sys.give_ope(5, p1, INNER_BC)) ;
191  }
192  else {
193  sys.eq_int[sys.neq_int]->set_part(0,
194  new Ope_sub(&sys, sys.give_ope(5, p1, INNER_BC), sys.give_ope(5, p2, INNER_BC))) ;
195  }
196  }
197  sys.neq_int ++ ;
198  sys.nbr_conditions = -1 ;
199 }
200 
201 void Space_bin_bh::add_eq_zero_mode_inf (System_of_eqs& sys, const char* name, int j, int k) {
202 
203  Index pos_cf (domains[nbr_domains-1]->get_nbr_coefs()) ;
204  pos_cf.set(1) = j ;
205  pos_cf.set(2) = k ;
206  double value = 0. ;
207  char auxi[LMAX] ;
208  trim_spaces (auxi, name) ;
209  sys.add_eq_mode (nbr_domains-1, OUTER_BC, auxi, pos_cf, value) ;
210 }
211 
212 }
Class for a spherical compactified domain and a symmetry with respect to the plane .
Definition: spheric.hpp:1007
Class implementing an integral equation.
Class that gives the position inside a multi-dimensional Array.
Definition: index.hpp:38
int & set(int i)
Read/write of the position in a given dimension.
Definition: index.hpp:72
The operator substraction.
Definition: ope_eq.hpp:165
void add_eq_zero_mode_inf(System_of_eqs &syst, const char *f, int jtarget, int ktarget)
Adds an equation saying that one coefficient of a field is zero (at infinity)
void add_eq_int_inf(System_of_eqs &syst, const char *eq)
Adds an equation being a surface integral at infinity.
void add_bc_sphere_two(System_of_eqs &syst, const char *eq, int nused=-1, Array< int > **pused=0x0)
Sets a boundary condition at the inner radius of the second outer shell.
void add_bc_sphere_one(System_of_eqs &syst, const char *eq, int nused=-1, Array< int > **pused=0x0)
Sets a boundary condition at the inner radius of the first outer shell.
void add_bc_outer(System_of_eqs &syst, const char *eq, int nused=-1, Array< int > **pused=0x0)
Sets a boundary condition at the outer boundary.
void add_eq_int_sphere_two(System_of_eqs &syst, const char *eq)
Adds an equation being a surface integral on the first sphere.
void add_eq_int_sphere_one(System_of_eqs &syst, const char *eq)
Adds an equation being a surface integral on the first sphere.
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.
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_mode(int dom, int bb, const char *eq, const Index &pos_cf, double val)
Addition of an equation prescribing the value of one coefficient of a scalar field,...
Definition: add_eq.cpp:438
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)
virtual void add_eq_bc(int dom, int bb, const char *eq, int n_cmp=-1, Array< int > **p_cmp=nullptr)
Addition of an equation describing a boundary condition.
Definition: add_eq.cpp:168
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.