LORENE
solp_helmholtz_plus.C
1/*
2 * Copyright (c) 1999-2001 Philippe Grandclement
3 *
4 * This file is part of LORENE.
5 *
6 * LORENE 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 2 of the License, or
9 * (at your option) any later version.
10 *
11 * LORENE 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 LORENE; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22
23
24
25/*
26 * $Id: solp_helmholtz_plus.C,v 1.6 2016/12/05 16:18:10 j_novak Exp $
27 * $Log: solp_helmholtz_plus.C,v $
28 * Revision 1.6 2016/12/05 16:18:10 j_novak
29 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
30 *
31 * Revision 1.5 2014/10/13 08:53:31 j_novak
32 * Lorene classes and functions now belong to the namespace Lorene.
33 *
34 * Revision 1.4 2014/10/06 15:16:10 j_novak
35 * Modified #include directives to use c++ syntax.
36 *
37 * Revision 1.3 2008/02/18 13:53:45 j_novak
38 * Removal of special indentation instructions.
39 *
40 * Revision 1.2 2004/01/15 09:15:37 p_grandclement
41 * Modification and addition of the Helmholtz operators
42 *
43 * Revision 1.1 2003/12/11 14:48:49 p_grandclement
44 * Addition of ALL (and that is a lot !) the files needed for the general elliptic solver ... UNDER DEVELOPEMENT...
45 *
46 *
47 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/solp_helmholtz_plus.C,v 1.6 2016/12/05 16:18:10 j_novak Exp $
48 *
49 */
50
51//fichiers includes
52#include <cstdio>
53#include <cstdlib>
54#include <cmath>
55
56#include "matrice.h"
57#include "type_parite.h"
58#include "proto.h"
59
60 //------------------------------------
61 // Routine pour les cas non prevus --
62 //------------------------------------
63namespace Lorene {
64Tbl _solp_helmholtz_plus_pas_prevu (const Matrice &, const Matrice &,
65 const Tbl &, double, double) {
66 cout << " Solution homogene pas prevue ..... : "<< endl ;
67 abort() ;
68 exit(-1) ;
69 Tbl res(1) ;
70 return res;
71}
72
73
74
75 //-------------------
76 //-- R_CHEB -----
77 //-------------------
78Tbl _solp_helmholtz_plus_r_cheb (const Matrice &lap, const Matrice &nondege,
79 const Tbl &source, double alpha, double beta) {
80
81 int n = lap.get_dim(0) ;
82 int dege = n-nondege.get_dim(0) ;
83 assert (dege ==2) ;
84
85 Tbl source_aux(source*alpha*alpha) ;
86 Tbl xso(source_aux) ;
87 Tbl xxso(source_aux) ;
88 multx_1d(n, &xso.t, R_CHEB) ;
89 multx_1d(n, &xxso.t, R_CHEB) ;
90 multx_1d(n, &xxso.t, R_CHEB) ;
91 source_aux = beta*beta/alpha/alpha*source_aux+2*beta/alpha*xso+xxso ;
92
93 source_aux = cl_helmholtz_plus (source_aux, R_CHEB) ;
94
95 Tbl so(n-dege) ;
96 so.set_etat_qcq() ;
97 for (int i=0 ; i<n-dege ; i++)
98 so.set(i) = source_aux(i) ;
99
100 Tbl auxi(nondege.inverse(so)) ;
101
102 Tbl res(n) ;
103 res.set_etat_qcq() ;
104 for (int i=dege ; i<n ; i++)
105 res.set(i) = auxi(i-dege) ;
106
107 for (int i=0 ; i<dege ; i++)
108 res.set(i) = 0 ;
109 return res ;
110}
111
112 //-------------------
113 //-- R_CHEBP ----
114 //-------------------
115Tbl _solp_helmholtz_plus_r_chebp (const Matrice &lap, const Matrice &nondege,
116 const Tbl &source, double alpha, double) {
117
118 int n = lap.get_dim(0) ;
119 int dege = n-nondege.get_dim(0) ;
120 assert (dege ==1) ;
121
122 Tbl source_aux(source*alpha*alpha) ;
123 source_aux = cl_helmholtz_plus (source_aux, R_CHEBP) ;
124
125 Tbl so(n-dege) ;
126 so.set_etat_qcq() ;
127 for (int i=0 ; i<n-dege ; i++)
128 so.set(i) = source_aux(i) ;
129
130 Tbl auxi(nondege.inverse(so)) ;
131
132 Tbl res(n) ;
133 res.set_etat_qcq() ;
134 for (int i=dege ; i<n ; i++)
135 res.set(i) = auxi(i-dege) ;
136
137 for (int i=0 ; i<dege ; i++)
138 res.set(i) = 0 ;
139 return res ;
140}
141 //-------------------
142 //-- Fonction ----
143 //-------------------
144
145
146Tbl solp_helmholtz_plus (const Matrice &lap, const Matrice &nondege,
147 const Tbl &source, double alpha, double beta,
148 int base_r) {
149
150 // Routines de derivation
151 static Tbl (*solp_helmholtz_plus[MAX_BASE]) (const Matrice&, const Matrice&,
152 const Tbl&, double, double) ;
153 static int nap = 0 ;
154
155 // Premier appel
156 if (nap==0) {
157 nap = 1 ;
158 for (int i=0 ; i<MAX_BASE ; i++) {
159 solp_helmholtz_plus[i] = _solp_helmholtz_plus_pas_prevu ;
160 }
161 // Les routines existantes
162 solp_helmholtz_plus[R_CHEB >> TRA_R] = _solp_helmholtz_plus_r_cheb ;
163 solp_helmholtz_plus[R_CHEBP >> TRA_R] = _solp_helmholtz_plus_r_chebp ;
164 }
165
166 Tbl res(solp_helmholtz_plus[base_r] (lap, nondege, source, alpha, beta)) ;
167 return res ;
168}
169}
Matrix handling.
Definition matrice.h:152
Basic array class.
Definition tbl.h:161
int get_dim(int i) const
Gives the i-th dimension (ie dim.dim[i]).
Definition tbl.h:403
#define MAX_BASE
Nombre max. de bases differentes.
#define TRA_R
Translation en R, used for a bitwise shift (in hex).
#define R_CHEB
base de Chebychev ordinaire (fin)
#define R_CHEBP
base de Cheb. paire (rare) seulement
Lorene prototypes.
Definition app_hor.h:67