Debian Codegraph @

School05/Thursday/Sol_two_grids/monopole.C

raw
1 #include "map.h"
2 #include "scalar.h"
3 #include "monopole.h"
4 #include "utilitaires.h"
5
6 // Standard constructor :
7 Monopole::Monopole (const Map_af& mpi_W, const Map_af& mpi_H,
8 double bet) : mp_W(mpi_W), mp_H(mpi_H),
9 radius_on_W(mp_W), radius_on_H(mp_H), beta(bet),
10 big_W (mp_W), small_w (mp_W), big_H (mp_H), small_h(mp_H),
11 big_W_on_H (mp_H), small_w_on_H (mp_H),
12 big_H_on_W (mp_W), small_h_on_W(mp_W) {
13
14 radius_on_W.set_etat_qcq() ;
15 radius_on_W = mp_W.r ;
16 nz_W = mp_W.get_mg()->get_nzone() ;
17
18 radius_on_H.set_etat_qcq() ;
19 radius_on_H = mp_H.r ;
20 nz_H = mp_H.get_mg()->get_nzone() ;
21 }
22
23
24 // Constructor by copy
25 Monopole::Monopole (const Monopole& so) : mp_W(so.mp_W), mp_H(so.mp_H),
26 radius_on_W(so.radius_on_W), radius_on_H(so.radius_on_H),
27 nz_W(so.nz_W), nz_H(so.nz_H),
28 beta (so.beta), big_W (so.big_W),small_w (so.small_w),
29 big_H(so.big_H), small_h(so.small_h), big_W_on_H (so.big_W_on_H),
30 small_w_on_H (so.small_w_on_H), big_H_on_W(so.big_H_on_W),
31 small_h_on_W (so.small_h_on_W) {} ;
32
33 // Constructor from a file :
34 Monopole::Monopole (const Map_af& mpi_W, const Map_af& mpi_H, FILE* fiche) :
35 mp_W(mpi_W), mp_H(mpi_H), radius_on_W(mp_W), radius_on_H(mp_H),
36 big_W (mp_W), small_w(mp_W), big_H (mp_H), small_h(mp_H),
37 big_W_on_H (mp_H), small_w_on_H(mp_H), big_H_on_W(mp_W), small_h_on_W (mp_W) {
38
39 fread_be (&beta, sizeof(double), 1, fiche) ;
40
41 radius_on_W.set_etat_qcq() ;
42 radius_on_W = mp_W.r ;
43 radius_on_H.set_etat_qcq() ;
44 radius_on_H = mp_H.r ;
45
46 nz_W = mp_W.get_mg()->get_nzone() ;
47 nz_H = mp_H.get_mg()->get_nzone() ;
48
49 Scalar big_W_file (mp_W, *mp_W.get_mg(), fiche) ;
50 big_W = big_W_file ;
51
52 Scalar small_w_file (mp_W, *mp_W.get_mg(), fiche) ;
53 small_w = small_w_file ;
54
55 Scalar big_H_file (mp_H, *mp_H.get_mg(), fiche) ;
56 big_H = big_H_file ;
57
58 Scalar small_h_file (mp_H, *mp_H.get_mg(), fiche) ;
59 small_h = small_h_file ;
60
61 Scalar big_W_on_H_file (mp_H, *mp_H.get_mg(), fiche) ;
62 big_W_on_H = big_W_on_H_file ;
63
64 Scalar small_w_on_H_file (mp_H, *mp_H.get_mg(), fiche) ;
65 small_w_on_H = small_w_on_H_file ;
66
67 Scalar big_H_on_W_file (mp_W, *mp_W.get_mg(), fiche) ;
68 big_H_on_W = big_H_on_W_file ;
69
70 Scalar small_h_on_W_file (mp_W, *mp_W.get_mg(), fiche) ;
71 small_h_on_W = small_h_on_W_file ;
72 }
73
74 // Destructor
75 Monopole::~Monopole() {} ;
76
77 // Assignement :
78 void Monopole::operator= (const Monopole& so) {
79 assert (mp_W == so.mp_W) ;
80 assert (mp_H == so.mp_H) ;
81
82 beta = so.beta ;
83
84 radius_on_W = so.radius_on_W ;
85 radius_on_H = so.radius_on_H ;
86
87 nz_W = so.nz_W ;
88 nz_H = so.nz_H ;
89
90 big_W = so.big_W ;
91 small_w = so.small_w ;
92 big_H = so.big_H ;
93 small_h = so.small_h ;
94
95 big_W_on_H = so.big_W_on_H ;
96 small_w_on_H = so.small_w_on_H ;
97 big_H_on_W = so.big_H_on_W ;
98 small_h_on_W = so.small_h_on_W ;
99 }
100
101 // Write to a file :
102 void Monopole::sauve (FILE* fiche) const {
103
104 fwrite_be (&beta, sizeof(double), 1, fiche) ;
105
106 big_W.sauve(fiche) ;
107 small_w.sauve (fiche) ;
108 big_H.sauve(fiche) ;
109 small_h.sauve (fiche) ;
110
111 big_W_on_H.sauve(fiche) ;
112 small_w_on_H.sauve (fiche) ;
113 big_H_on_W.sauve(fiche) ;
114 small_h_on_W.sauve (fiche) ;
115 }
116
117