File: vect_inf.C

package info (click to toggle)
lorene 0.0.0~cvs20161116%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, stretch
  • size: 26,444 kB
  • ctags: 13,953
  • sloc: cpp: 212,946; fortran: 21,645; makefile: 1,750; sh: 4
file content (222 lines) | stat: -rw-r--r-- 6,123 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/*
 * Test for the vectorial Poisson equation for a discontinuous non-compact source
 */

/*
 *   Copyright (c) 2000-2001 Philippe Grandclement
 *
 *   This file is part of LORENE.
 *
 *   LORENE is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   LORENE is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with LORENE; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

char vect_inf_C[] = "$Header: /cvsroot/Lorene/Codes/Test/Poisson_vect/vect_inf.C,v 1.3 2014/10/06 15:12:55 j_novak Exp $" ;

/*
 * $Id: vect_inf.C,v 1.3 2014/10/06 15:12:55 j_novak Exp $
 * $Log: vect_inf.C,v $
 * Revision 1.3  2014/10/06 15:12:55  j_novak
 * Modified #include directives to use c++ syntax.
 *
 * Revision 1.2  2003/01/09 11:07:56  j_novak
 * headcpp.h is now compliant with C++ norm.
 * The include files have been ordered, as well as the local_settings_linux
 *
 * Revision 1.1.1.1  2001/11/20 15:19:31  e_gourgoulhon
 * LORENE
 *
 * Revision 1.1  2000/02/15  14:57:18  phil
 * Initial revision
 *
 *
 * $Header: /cvsroot/Lorene/Codes/Test/Poisson_vect/vect_inf.C,v 1.3 2014/10/06 15:12:55 j_novak Exp $
 *
 */

// LORENE

#include "type_parite.h"
#include "nbr_spx.h"
#include "grilles.h"
#include "map.h"
#include "valeur.h"
#include "utilitaires.h"
#include "coord.h"
#include "cmp.h"
#include "graphique.h"
#include "proto.h"
#include "tenseur.h"
#include "base_vect.h"
#include "param.h"

//standard
#include <ctime>
#include <cstdlib>
#include <cstdio>
#include <cmath>

void main() { 

    int symetrie = NONSYM ;
    double lambda = 1./3. ;
    int n=4 ;
    
    // Construction de la grille ...
    int nz = 3 ;
    double R = (nz-1) ;
    
    //Construction du mapping :
    double* bornes = new double[nz+1] ;
    for (int i=0 ; i<nz ; i++)
	bornes[i] = i ;
    bornes[nz] = __infinity ;
    
    // echantillonnage en phi :
    int* np = new int [nz] ;
    for (int l=0 ; l<nz ; l++)
	np[l] = 8 ;
    int type_p = symetrie ;
    
    // echantillonnage en theta :
    int* nt = new int [nz] ;
    for (int l=0 ; l<nz ; l++)
	nt[l] = 9 ;
    int type_t = SYM ;
    int* nr = new int[nz] ;
    int* type_r = new int[nz] ;
    int nbrer ;
    
    cin >> nbrer ;

	// echantillonage en r :
	
	for (int l=0 ; l<nz ; l++)
	    nr[l] = nbrer ;
	
	type_r[0] = RARE ;
	for (int l=1 ; l<nz-1 ; l++)
	    type_r[l] = FIN ;
	type_r[nz-1] = UNSURR ;
    
	Mg3d grille (nz, nr, type_r, nt, type_t, np, type_p) ;
    
   
	Map_af mapping(grille, bornes) ;

    
	    // Construction de la source .
	    
	Coord& x = mapping.x ;
	Coord& y = mapping.y ;
	Coord& z = mapping.z ;
	Coord& r = mapping.r ;
	
	Mtbl a_cont (&grille) ;
	a_cont = -(4.+n)/2./pow(R, 6.+n) ;
	Mtbl b_cont (&grille) ;
	b_cont = (6.+n)/2./pow(R, 4.+n) ;
	
	// Composante x
	Valeur val_x(&grille) ;
	val_x = x*((54+18*lambda)*a_cont*pow(r, 4.)+
		    (28+12*lambda)*b_cont*pow(r, 2.))
		+ lambda*pow(x, 3.)*(24*a_cont*pow(r, 2.)+8*b_cont) ;
	// ZEC ...
	Valeur val_x_zec(&grille) ;
	val_x_zec = n*(n-3-3*lambda)*x/pow(r, n)+
		    n*(n+2)*lambda*pow(x, 3.)/pow(r, n+2.)  ;
	for (int k=0 ; k<np[nz-1] ; k++)
	    for (int j=0 ; j<nt[nz-1] ; j++)
		val_x_zec.set(nz-1, k, j, nr[nz-1]-1) = 0. ;
	*(val_x.c->t[nz-1]) = *(val_x_zec.c->t[nz-1]) ; 
	
	// Composante y
	Valeur val_y(&grille) ;
	val_y = lambda*y*(6*a_cont*pow(r, 4.)+4*b_cont*pow(r, 2.)) 
		+lambda*pow(x, 2.)*y*(24*a_cont*pow(r, 2.)+8*b_cont);
	// ZEC ...
	Valeur val_y_zec(&grille) ;
	val_y_zec = -lambda*n*y/pow(r, n)+lambda*n*(n+2)*pow(x, 2.)*y/pow(r, n+2.)  ;
	for (int k=0 ; k<np[nz-1] ; k++)
	    for (int j=0 ; j<nt[nz-1] ; j++)
		val_y_zec.set(nz-1, k, j, nr[nz-1]-1) = 0. ;
	*(val_y.c->t[nz-1]) = *(val_y_zec.c->t[nz-1]) ; 
	
	// Composante z
	Valeur val_z(&grille) ;
	val_z = lambda*z*(6*a_cont*pow(r, 4.)+4*b_cont*pow(r, 2.)) 
		+lambda*pow(x, 2.)*z*(24*a_cont*pow(r, 2.)+8*b_cont);
	// ZEC ...
	Valeur val_z_zec(&grille) ;
	val_z_zec = -lambda*n*z/pow(r, n)+lambda*n*(n+2)*pow(x, 2.)*z/pow(r, n+2.)  ;
	for (int k=0 ; k<np[nz-1] ; k++)
	    for (int j=0 ; j<nt[nz-1] ; j++)
		val_z_zec.set(nz-1, k, j, nr[nz-1]-1) = 0. ;
	*(val_z.c->t[nz-1]) = *(val_z_zec.c->t[nz-1]) ; 
	
	// On construit le vecteur ...
	Tenseur source (mapping, 1, CON, mapping.get_bvect_cart()) ;
	source.set_etat_qcq() ;
	source.set(0) = val_x ;
	source.set(1) = val_y ;
	source.set(2) = val_z ;
	for (int i=0 ; i<3 ; i++)
	    source.set(i).set_dzpuis(2) ;
	source.set_std_base() ;
	
	
	// On construit la solution analytique
	// Composante x
	Valeur sol_x(&grille) ;
	sol_x = x*(a_cont*pow(r, 6.)+b_cont*pow(r, 4.)) ;
    
	// ZEC ...
	Valeur sol_x_zec(&grille) ;
	sol_x_zec = x/pow(r, n) ;
	for (int k=0 ; k<np[nz-1] ; k++)
	    for (int j=0 ; j<nt[nz-1] ; j++)
		sol_x_zec.set(nz-1, k, j, nr[nz-1]-1) = 0. ;
	*(sol_x.c->t[nz-1]) = *(sol_x_zec.c->t[nz-1]) ; 

	// On construit le vecteur ...
	Tenseur soluce(mapping, 1, CON, mapping.get_bvect_cart()) ;
	soluce.set_etat_qcq() ;
	soluce.set(0) = sol_x ;
	soluce.set(1) = 0 ;
	soluce.set(2) = 0 ;
	for (int i=0 ; i<3 ; i++)
	    soluce.set(i).set_dzpuis(0) ;
	soluce.set_std_base() ;
	
	Tenseur vect_auxi (mapping, 1, CON, mapping.get_bvect_cart()) ;
	vect_auxi.set_etat_qcq() ;
	Tenseur scal_auxi (mapping) ;
	scal_auxi.set_etat_qcq() ;
	
	Tenseur shibata (source.poisson_vect(lambda, vect_auxi, scal_auxi)) ;
	
	cout << "Shibata" << endl ;
	for (int i=0 ; i<3 ; i++)
	    cout << "Composante " << i << " : " <<
		diffrelmax(shibata(i), soluce(i)) << endl ;
	cout <<"-------------------------------------------" << endl ;
	
    delete [] nr ;
    delete [] nt ;
    delete [] np ;
    delete [] type_r ;
    delete [] bornes ;
}