Skip to content

Commit 8aee149

Browse files
committed
non hermitian preconditioner added
1 parent 848fdfa commit 8aee149

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

solver/poly_precon.c

+79
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "start.h"
1212
#include "linalg_eo.h"
1313
#include "tm_operators.h"
14+
#include "boundary.h"
15+
#include "D_psi.h"
1416
#include "chebyshev_polynomial.h"
1517

1618

@@ -161,3 +163,80 @@ void poly_precon(spinor * const R, spinor * const S, const double prec, const in
161163
}
162164

163165

166+
void poly_nonherm_precon(spinor * const R, spinor * const S,
167+
const double e, const int n) {
168+
int j;
169+
double a1, a2;
170+
double fact1, fact2, temp1, temp2, temp3, temp4, auxnorm;
171+
static spinor *sv_, *sv, *d_, *d, *dd_, *dd, *aux_, *aux, *aux3_, *aux3;
172+
static int initpnH = 0;
173+
static double * c;
174+
const int N = VOLUME;
175+
spinor * psi, * chi, *tmp;
176+
177+
178+
if(initpnH == 0) {
179+
c = (double*)calloc(1000, sizeof(double));
180+
#if (defined SSE || defined SSE2 || defined SSE3)
181+
sv_ = calloc(VOLUMEPLUSRAND+1, sizeof(spinor));
182+
sv = (spinor *)(((unsigned long int)(sv_)+ALIGN_BASE)&~ALIGN_BASE);
183+
d_ = calloc(VOLUMEPLUSRAND+1, sizeof(spinor));
184+
d = (spinor *)(((unsigned long int)(d_)+ALIGN_BASE)&~ALIGN_BASE);
185+
dd_ = calloc(VOLUMEPLUSRAND+1, sizeof(spinor));
186+
dd = (spinor *)(((unsigned long int)(dd_)+ALIGN_BASE)&~ALIGN_BASE);
187+
aux_ = calloc(VOLUMEPLUSRAND+1, sizeof(spinor));
188+
aux = (spinor *)(((unsigned long int)(aux_)+ALIGN_BASE)&~ALIGN_BASE);
189+
aux3_= calloc(VOLUMEPLUSRAND+1, sizeof(spinor));
190+
aux3 = (spinor *)(((unsigned long int)(aux3_)+ALIGN_BASE)&~ALIGN_BASE);
191+
#else
192+
sv_ = calloc(VOLUMEPLUSRAND+1, sizeof(spinor));
193+
sv = sv_;
194+
d_ = calloc(VOLUMEPLUSRAND+1, sizeof(spinor));
195+
d = d_;
196+
dd_ = calloc(VOLUMEPLUSRAND+1, sizeof(spinor));
197+
dd = dd_;
198+
aux_ = calloc(VOLUMEPLUSRAND+1, sizeof(spinor));
199+
aux = aux_;
200+
aux3_= calloc(VOLUMEPLUSRAND+1, sizeof(spinor));
201+
aux3 = aux3_;
202+
#endif
203+
initpnH = 1;
204+
}
205+
206+
207+
/* P_0 * S */
208+
assign(d, S, N);
209+
/* P_1 * S = a_1(1+kappa*H) * S */
210+
a1 = 1./(1.-e*e/2.);
211+
boundary(-g_kappa);
212+
g_mu = -g_mu;
213+
D_psi(dd, d);
214+
mul_r(dd, a1, dd, N);
215+
psi = d;
216+
chi = dd;
217+
/* assign(chi, d, N); */
218+
for(j = 2; j < n+1; j++) {
219+
/* a_n */
220+
a2 = 1./(1.-a1*e*e/4.);
221+
/* 1-a_n */
222+
a1 = 1.-a2;
223+
/* aux = a_n*S + (1-a_n) psi */
224+
mul_add_mul_r(aux, S, psi, a2, a1, N);
225+
/* sv = kappa H chi = (D_psi(-kappa, -2kappamu) - 1) chi */
226+
D_psi(sv, chi);
227+
diff(sv, sv, chi, N);
228+
/* psi = aux + a_n * sv */
229+
mul_add_mul_r(psi, aux, sv, 1., a2, N);
230+
tmp = psi;
231+
psi = chi;
232+
chi = tmp;
233+
a1 = a2;
234+
}
235+
assign(R, chi, N);
236+
boundary(-g_kappa);
237+
g_mu = -g_mu;
238+
239+
return;
240+
}
241+
242+

solver/poly_precon.h

+2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
#define _POLY_PRECON_H
33

44
void poly_precon(spinor * const, spinor * const, const double prec, const int n);
5+
void poly_nonherm_precon(spinor * const R, spinor * const S,
6+
const double e, const int n);
57

68
#endif

0 commit comments

Comments
 (0)