| 1 |
macro ffddmcoarsemeshsetupinit(pr,Thc) |
| 2 |
IFMACRO(!pr#coarsemeshsetupinit) |
| 3 |
|
| 4 |
pr#bCM = 1; |
| 5 |
|
| 6 |
pr#prfe#prmesh#meshN pr#ThCoarse = pr#prfe#prmesh#minimalMesh; |
| 7 |
fespace pr#VhCoarse(pr#ThCoarse,pr#prfe#fPk); /* fespace on the coarse mesh */ |
| 8 |
|
| 9 |
if (pr#prfe#prmesh#isincomm) { |
| 10 |
if (!pr#prfe#prmesh#binexactCS) { |
| 11 |
pr#ThCoarse = Thc; |
| 12 |
pr#ncoarsespace = pr#VhCoarse.ndof; |
| 13 |
|
| 14 |
if (!bpara) { |
| 15 |
matrix Zc = interpolate(pr#prfe#Vhglob,pr#VhCoarse); /* ZCM=R0^T */ |
| 16 |
Zc.thresholding(1.e-10); |
| 17 |
pr#ZCM = Zc; /* (from real to 'complex' matrix for FreeFem) */ |
| 18 |
} |
| 19 |
else if (!pr#prfe#prmesh#excluded){ |
| 20 |
matrix Zci = interpolate(pr#prfe#Vhi,pr#VhCoarse); |
| 21 |
Zci.thresholding(1.e-10); |
| 22 |
pr#ZCMi = Zci; |
| 23 |
} |
| 24 |
NewMacro localmacroaug pr#prfe#prmesh#buildAug EndMacro |
| 25 |
IFMACRO(localmacroaug,1) |
| 26 |
if (bseq) { |
| 27 |
pr#CSinterp = interpolate(pr#VhCoarse,pr#prfe#Vhglob); |
| 28 |
} |
| 29 |
else if (!pr#prfe#prmesh#excluded) { |
| 30 |
pr#CSinterp = interpolate(pr#VhCoarse,pr#prfe#Vhi); |
| 31 |
} |
| 32 |
ENDIFMACRO |
| 33 |
} |
| 34 |
else if (!pr#prfe#prmesh#excluded){ |
| 35 |
NewMacro localmacroinexact pr#prfe#prmesh#minexactCS EndMacro |
| 36 |
IFMACRO (localmacroinexact,1) |
| 37 |
matrix Zci = interpolate(pr#prfe#Vhi,pr#prfe#CoarseVhi); |
| 38 |
Zci.thresholding(1.e-10); |
| 39 |
pr#ZCMi = Zci; |
| 40 |
pr#ncoarsespace = pr#prfe#CoarseNdofglobal; |
| 41 |
ENDIFMACRO |
| 42 |
; |
| 43 |
} |
| 44 |
|
| 45 |
if (!pr#prfe#prmesh#excluded && pr#verbosity && (mpiRank(pr#prfe#prmesh#commddm) == 0)) |
| 46 |
cout << "["+Stringification(pr)+"] Coarse space dimension: " << pr#ncoarsespace << endl; |
| 47 |
} |
| 48 |
|
| 49 |
NewMacro pr#coarsemeshsetupinit()1 EndMacro |
| 50 |
ENDIFMACRO |
| 51 |
// EOM |
| 52 |
|
| 53 |
macro ffddmcoarsemeshsetup(pr,Thc,VarfEprec,VarfA) |
| 54 |
ffddmcoarsemeshsetupinit(pr,Thc) |
| 55 |
if (pr#prfe#prmesh#isincomm) |
| 56 |
{ |
| 57 |
pr#corr = ffddmcorrection; |
| 58 |
|
| 59 |
pr#prfe#prmesh#tic(pr#tloc) |
| 60 |
|
| 61 |
if(bseq) { |
| 62 |
IFMACRO(VarfA) |
| 63 |
VarfA(vaglobalEprec,pr#prfe#prmesh#Thglob,pr#prfe#Vhglob) |
| 64 |
pr#AglobEprec = vaglobalEprec(pr#prfe#Vhglob,pr#prfe#Vhglob,sym=vsym,tgv=vtgvelim); |
| 65 |
ENDIFMACRO |
| 66 |
; |
| 67 |
} |
| 68 |
else if (!pr#prfe#prmesh#excluded) { |
| 69 |
int i = mpiRank(pr#prfe#prmesh#commddm); |
| 70 |
|
| 71 |
IFMACRO(VarfA) |
| 72 |
pr#prfe#prmesh#Thi = pr#prfe#prmesh#aTh[i]; |
| 73 |
|
| 74 |
NewMacro localmacroaug pr#prfe#prmesh#buildAug EndMacro |
| 75 |
IFMACRO(localmacroaug,1) |
| 76 |
pr#prfe#prmesh#AugThi = pr#prfe#prmesh#AugaTh[i]; |
| 77 |
ENDIFMACRO |
| 78 |
IFMACRO(localmacroaug,0) |
| 79 |
pr#prfe#prmesh#meshN pr#prfe#prmesh#AugThi = pr#prfe#prmesh#Thi + pr#prfe#prmesh#aThborder[i]; /* local mesh augmented of one layer to define local Dirichlet matrices without the global matrix*/ |
| 80 |
fespace pr#prfe#AugVhi(pr#prfe#prmesh#AugThi, pr#prfe#fPk); |
| 81 |
int[int] n2o = (0:pr#prfe#prmesh#Thi.nt-1); |
| 82 |
int[int] renum = restrict(pr#prfe#Vhi, pr#prfe#AugVhi,n2o); |
| 83 |
int[int] Ic = (0:pr#prfe#Vhi.ndof-1); |
| 84 |
real[int] Kc(pr#prfe#Vhi.ndof); |
| 85 |
Kc = 1; |
| 86 |
matrix pr#prfe#Auginterp = [Ic,renum,Kc]; |
| 87 |
pr#prfe#Auginterp.resize(pr#prfe#Vhi.ndof, pr#prfe#AugVhi.ndof); |
| 88 |
ENDIFMACRO |
| 89 |
|
| 90 |
VarfA(vPb, pr#prfe#prmesh#AugThi, pr#prfe#AugVhi) |
| 91 |
pr#aRdEprec = vPb(pr#prfe#AugVhi, pr#prfe#AugVhi, sym=vsym,tgv=vtgvelim); |
| 92 |
|
| 93 |
pr#prfe#K[int] rhsFull(pr#prfe#AugVhi.ndof); |
| 94 |
pr#prfe#K[int] rhs(pr#prfe#Vhi.ndof); |
| 95 |
|
| 96 |
renumbering(pr#aRdEprec, pr#prfe#Auginterp, rhsFull, rhs, eps=-1); |
| 97 |
ENDIFMACRO |
| 98 |
} |
| 99 |
|
| 100 |
if (!pr#prfe#prmesh#binexactCS) { |
| 101 |
{ |
| 102 |
IFMACRO(!pr#bem) |
| 103 |
VarfEprec(cvaglobalEprec,pr#ThCoarse,pr#VhCoarse) |
| 104 |
/*if (mpirank < pr#prfe#prmesh#pCS || !bpara)*/ |
| 105 |
if (mpirank == 0 || !bpara) { |
| 106 |
pr#ECM = cvaglobalEprec(pr#VhCoarse,pr#VhCoarse,sym=vsym,tgv=vtgv,solver=GMRES); /* this is A_{eps,0} of Euan paper */ |
| 107 |
/*pr#ECM.thresholding(1.e-10);*/ |
| 108 |
} |
| 109 |
ENDIFMACRO |
| 110 |
/* |
| 111 |
IFMACRO(pr#bem,1) |
| 112 |
pr#Tmatrix<pr#prfe#K> Hloc = VarfEprec(pr#VhCoarse, pr#VhCoarse); |
| 113 |
pr#prfe#K[int,int] mdense(pr#VhCoarse.ndof, pr#VhCoarse.ndof); |
| 114 |
mdense = Hloc; |
| 115 |
pr#ECM = mdense; |
| 116 |
ENDIFMACRO |
| 117 |
*/ |
| 118 |
} |
| 119 |
|
| 120 |
if (bseq || mpirank < pr#prfe#prmesh#pCS) { |
| 121 |
set(pr#ECM,solver=sparsesolver,sym=vsym,commworld=pr#prfe#prmesh#commCS,master=0,factorize=3); /* -1 */ |
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
IFMACRO(pr#withhpddm) |
| 126 |
AttachCoarseOperator(pr#prfe#prmesh#commddm, pr#hpddmOP, pr#Q); |
| 127 |
ENDIFMACRO |
| 128 |
|
| 129 |
pr#prfe#prmesh#toc(pr#tloc,"building E",pr#tbuildE) |
| 130 |
} // EOM |