KADATH
spheric_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 "spheric.hpp"
22 
23 #include "system_of_eqs.hpp"
24 #include "name_tools.hpp"
25 namespace Kadath {
26 void Space_spheric::add_inner_bc (System_of_eqs& sys, const char* name, int nused, Array<int>** pused) {
27  // BC in domain 5 and 6
28  sys.add_eq_bc (sys.get_dom_min(), INNER_BC, name, nused, pused) ;
29 }
30 
31 void Space_spheric::add_outer_bc (System_of_eqs& sys, const char* name, int nused, Array<int>** pused) {
32  sys.add_eq_bc (sys.get_dom_max(), OUTER_BC, name, nused, pused) ;
33 }
34 
35 void Space_spheric::add_eq (System_of_eqs& sys, const char* name, int nused, Array<int>** pused) {
36  for (int dd=sys.get_dom_min() ; dd<=sys.get_dom_max() ; dd++)
37  sys.add_eq_inside (dd, name, nused, pused) ;
38 }
39 
40 void Space_spheric::add_matching (System_of_eqs& sys, const char* name, int nused, Array<int>** pused) {
41  for (int dd=sys.get_dom_min() ; dd<sys.get_dom_max() ; dd++)
42  sys.add_eq_matching (dd, OUTER_BC, name, nused, pused) ;
43 }
44 
45 void Space_spheric::add_eq (System_of_eqs& sys, const char* eq, const char* rac, const char* rac_der, int nused, Array<int>** pused) {
46  for (int dd=sys.get_dom_min() ; dd<sys.get_dom_max(); dd++) {
47  sys.add_eq_inside (dd, eq, nused, pused) ;
48  sys.add_eq_matching (dd, OUTER_BC, rac, nused, pused) ;
49  sys.add_eq_matching (dd, OUTER_BC, rac_der, nused, pused) ;
50  }
51  sys.add_eq_inside (sys.get_dom_max(), eq, nused, pused) ;
52 }
53 
54 void Space_spheric::add_eq_full (System_of_eqs& sys, const char* name, int nused, Array<int>** pused) {
55  for (int dd=sys.get_dom_min() ; dd<=sys.get_dom_max() ; dd++)
56  sys.add_eq_full (dd, name, nused, pused) ;
57 }
58 
59 void Space_spheric::add_eq_one_side (System_of_eqs& sys, const char* name, const char* rac, int nused, Array<int>** pused) {
60  for (int dd=sys.get_dom_min() ; dd<sys.get_dom_max() ; dd++) {
61  sys.add_eq_one_side (dd, name, nused, pused) ;
62  sys.add_eq_matching (dd, OUTER_BC, rac, nused, pused) ;
63  }
64  sys.add_eq_one_side (sys.get_dom_max(), name, nused, pused) ;
65 }
66 
67 void Space_spheric::add_eq_one_side (System_of_eqs& sys, const char* name, int nused, Array<int>** pused) {
68  for (int dd=sys.get_dom_min() ; dd<=sys.get_dom_max() ; dd++)
69  sys.add_eq_one_side (dd, name, nused, pused) ;
70 }
71 
72 
73 void Space_spheric::add_eq_ori (System_of_eqs& sys, const char* name) {
74 
75  Index pos (domains[0]->get_nbr_points()) ;
76  char auxi[LMAX] ;
77  trim_spaces (auxi, name) ;
78  sys.add_eq_val (0, auxi, pos) ;
79 }
80 
81 void Space_spheric::add_eq_int_volume (System_of_eqs& sys, const char* nom) {
82 
83  // Get the lhs and rhs
84  char p1[LMAX] ;
85  char p2[LMAX] ;
86  bool indic = sys.is_ope_bin(nom, p1, p2, '=') ;
87  if (!indic) {
88  cerr << "= needed for equations" << endl ;
89  abort() ;
90  }
91  else {
92  // Construction of the equation
93  sys.eq_int[sys.neq_int] = new Eq_int(nbr_domains+1) ;
94 
95  // Affectation of the intregrale parts
96  for (int d=0 ; d<nbr_domains ; d++)
97  sys.eq_int[sys.neq_int]->set_part(d, sys.give_ope(d, p1)) ;
98  // Affectation of the second member (constant value)
99  sys.eq_int[sys.neq_int]->set_part(nbr_domains, new Ope_minus(&sys, sys.give_ope(0, p2))) ;
100  sys.neq_int ++ ;
101  }
102  sys.nbr_conditions = -1 ;
103 }
104 
105 
106 void Space_spheric::add_eq_mode_mid (System_of_eqs& sys, const char* name, int itarget, int jtarget, int ktarget) {
107 
108  Index pos_cf (domains[0]->get_nbr_coefs()) ;
109  pos_cf.set(0) = itarget ;
110  pos_cf.set(1) = jtarget ;
111  pos_cf.set(2) = ktarget ;
112  double value = 1. ;
113  char auxi[LMAX] ;
114  trim_spaces (auxi, name) ;
115  sys.add_eq_val_mode (1, auxi, pos_cf, value) ;
116 }
117 
118 void Space_spheric::add_eq_point (System_of_eqs& sys, const Point& MM, const char* name) {
119 
120  // Get the domain and num coordinates :
121  int ld = -1;
122  bool* inside = new bool[nbr_domains] ;
123  for (int l=0 ; l<nbr_domains; l++)
124  inside[l] = get_domain(l)->is_in(MM) ;
125  for (int l=0 ; l<nbr_domains ; l++)
126  if ((ld==-1) && (inside[l]))
127  ld = l ;
128  Point num (get_domain(ld)->absol_to_num(MM)) ;
129 
130  char auxi[LMAX] ;
131  trim_spaces (auxi, name) ;
132  sys.add_eq_point (ld, auxi, num) ;
133 }}
virtual bool is_in(const Point &xx, double prec=1e-13) const
Check whether a point lies inside Domain.
Definition: domain.cpp:942
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 minus.
Definition: ope_eq.hpp:128
The class Point is used to store the coordinates of a point.
Definition: point.hpp:30
void add_eq(System_of_eqs &syst, const char *eq, int nused=-1, Array< int > **pused=0x0)
Adds a bulk equation in all the domains of a given system (equation is assumed to be second order)
void add_eq_point(System_of_eqs &syst, const Point &pp, const char *eq)
Adds an equation being the value of some field at a given point.
void add_eq_ori(System_of_eqs &syst, const char *eq)
Adds an equation being the value of some field at the origin.
void add_eq_mode_mid(System_of_eqs &syst, const char *f, int itarget, int jtarget, int ktarget)
Adds an equation saying that one coefficient of a field is zero (in the first shell)
void add_eq_int_volume(System_of_eqs &syst, const char *eq)
Adds an equation being a volume integral in the whole computational space.
void add_eq_full(System_of_eqs &syst, const char *eq, int nused=-1, Array< int > **pused=0x0)
Adds a bulk equation in all the domains of a given system (equation is assumed to be 0th order)
void add_outer_bc(System_of_eqs &syst, const char *eq, int nused=-1, Array< int > **pused=0x0)
Sets a boundary condition at the outer radius of the compactified domain.
void add_matching(System_of_eqs &syst, const char *eq, int nused=-1, Array< int > **pused=0x0)
Adds a matching condition, at all the interface present in a given system.
void add_inner_bc(System_of_eqs &syst, const char *eq, int nused=-1, Array< int > **pused=0x0)
Sets a boundary condition at the inner radius of the innermost shell.
void add_eq_one_side(System_of_eqs &syst, const char *eq, int nused=-1, Array< int > **pused=0x0)
Adds a bulk equation in all the domains of a given system (equation is assumed to be first order)
const Domain * get_domain(int i) const
returns a pointer on the domain.
Definition: space.hpp:1385
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_full(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 zeroth order i....
Definition: add_eq.cpp:374
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
virtual void add_eq_point(int dom, const char *eq, const Point &MM)
Addition of an equation saying that the value of a field must be zero at one point (arbitrary).
Definition: add_eq.cpp:473
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
virtual void add_eq_val(int dom, const char *eq, const Index &pos)
Addition of an equation saying that the value of a field must be zero at one collocation point.
Definition: add_eq.cpp:462
int get_dom_max() const
Returns the highest index of the domains.
int nbr_conditions
Total number of conditions (the number of coefficients of all the equations, once regularities are ta...
virtual void add_eq_one_side(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 first order).
Definition: add_eq.cpp:407
int get_dom_min() const
Returns the smallest index of the domains.
MMPtr_array< Eq_int > eq_int
Pointers onto the integral equations.
virtual void add_eq_val_mode(int dom, 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:450