Debian Codegraph @

src/femlib/MatriceCreuse_tpl.hpp

raw symbols SCIP
1 #cxx . . $ `<file>/src/femlib/MatriceCreuse_tpl.hpp`/ifndef MatriceCreuse_tpl_
2 #define MatriceCreuse_tpl_cxx . . $ `src/femlib/MatriceCreuse_tpl.hpp:2:9`!
3 #ifndef MatriceCreuse_h_cxx . . $ `src/femlib/MatriceCreuse.hpp:2:9`!
4 #include "MatriceCreuse.hpp"
5 #include <limits>
6 #include <set>
7 #include <list>
8 #include <map>
9 #endif
10
11 #ifndef __MWERKS__
12 // test blas
13 // on MacOS9 under MWERKS
14 // cblas_ddot macos-9 is not
15 #ifdef HAVE_CBLAS_H_BUG
16 extern "C" {
17 #define FF_VERSION VERSION
18 #undef VERSION
19 #include <cblas.h>
20 //#undef VERSION
21 //#define VERSION VERSION
22 }
23 #define WITHBLAS 1
24 #elif defined(HAVE_VECLIB_CBLAS_BUG) && HAVE_VECLIB_CBLAS_BUG
25 #include <vecLib/cblas.h>
26 #define WITHBLAS 1
27 #endif
28 #endif
29 #ifdef WITHBLAS
30 template<class R> inline R blas_sdot(const int n,const R *sx,const int incx,const R *sy,const int incy)
31 {
32 R s=R();
33
34 if(incx == 1 && incy == 1)
35 for (int k = 0; k< n; k++)
36 s += *sx++ * * sy++;
37 else
38 for (int k = 0; k< n; k++, sx += incx, sy += incy)
39 s += *sx * *sy;
40 return s;
41 }
42
43 template<class R> inline R blas_sdot( int n, R *sx, int incx, R *sy, int incy)
44 {
45 R s=R();
46
47 if(incx == 1 && incy == 1)
48 for (int k = 0; k< n; k++)
49 s += *sx++ * * sy++;
50 else
51 for (int k = 0; k< n; k++, sx += incx, sy += incy)
52 s += *sx * *sy;
53 return s;
54 }
55 // OpenBlas PB with constant remove const ....
56 template<> inline float blas_sdot(const int n, float *sx, int incx, float *sy, int incy)
57 {
58 return cblas_sdot(n,sx,incx,sy,incy);
59 }
60 template<> inline double blas_sdot( int n, double *sx, int incx, double *sy, int incy)
61 {
62 return cblas_ddot(n,sx,incx,sy,incy);
63 }
64
65 #ifdef OPENBLAS_CONFIG_H
66 typedef openblas_complex_double *BLAS_ptr_complex16;
67 #else
68 typedef void *BLAS_ptr_complex16;
69
70 #endif
71 template<> inline complex<double> blas_sdot( int n, complex<double> *sx, int incx, complex<double> *sy, int incy)
72 {
73 complex<double> s;
74 cblas_zdotu_sub(n,( double *)sx,incx,( double *)sy,incy,(BLAS_ptr_complex16)&s);
75 return s;
76 }
77 //template<> inline complex<float> blas_sdot( int n, complex<float> *sx, int incx, complex<float> *sy, int incy)
78 //{
79 // complex<float> s;
80 // cblas_cdotu_sub(n,( void *)sx,incx,( void *)sy,incy,(BLAS_ptr_complex8)&s);
81 // return s;
82 //}
83
84 #endif
85 // end modif FH
86
87
88
89 using stdcxx . . $ std/::numeric_limitscxx . . $ numeric_limits#;
90
91 // -----------
92 template<class FElement>
93 inline int BuildMEK_KKcxx . . $ BuildMEK_KK(81bac79d85c228e4).(const int l,int *p,int *pk,int *pkk,const FElement * pKE,const FElement*pKKE)
94 {
95 // routine which find common dof on to adjacent element pKE and pKKE and make the link ..
96 // if pKKE== 0 then no adj element
97 // the idea is find common dof, but this work only if all dot a different
98 // in on elemnt, so we can have a bug
99 // in case of periodic boundary condition ..
100 // not correct ... F.Hecht ...
101
102 // -----
103 // routine build les array p, pk,pkk
104 // which return number of df int 2 element pKE an pKKE
105 // max l size of array p, pk, pkk
106 // p[i] is the global number of freedom
107 // pk[i] is is the local number in pKE ( -1 if not in pKE element)
108 // pkk[i] is is the local number in pKKE ( -1 if not in pKKE element)
109 const FElement (*pK[2])={pKE,pKKE};
110
111 int ndf=0; // number of dl
112 int * qk=pk, *qkk=pkk;
113 for (int k=0;k<2;k++)
114 if(pK[k])
115 {
116 if(k) Exchangecxx . . $ Exchange(9e0270548159b170).(qk,qkk);
117 const FElement& FEK=*pK[k];
118 int nbdf =FEK.NbDoF();
119
120 for (int ii=0;ii<nbdf;ii++)
121 {
122 p[ndf] = 2*cxx . . $ `operator*`(ca0d58f853b0940).FEK(ii)+cxx . . $ operator+(1f62e43363bf5779).k; // copy the numbering
123 qk[ndf] = ii;
124 qkk[ndf++] = -1;
125 } // end for ii
126 }
127 ffassertcxx . . $ `src/fflib/throwassert.hpp:49:9`!(ndf <=l);
128 int bug=0;
129 // compression suppression des doublons
130 // attention un df peu aparaitre 2 fois (CL period) dans un element ..
131 Fem2Dcxx . . $ Fem2D/::HeapSortcxx . . $ Fem2D/HeapSort(4da1bf9edce66a07).(p,pk,pkk,ndf);
132 int k=0;
133 for(int ii=1;ii<ndf;++ii)
134 if (p[k]/2==p[ii]/2) // doublons k,kk
135 {
136 if (pkk[ii]>=0) pkk[k]=pkk[ii];
137 if (pk[ii]>=0) pk[k]=pk[ii];
138 assertcxx . . $ `/usr/include/assert.h:77:11`!(pk[k] >=0 && pkk[k]>=0);
139 }
140 else { // copy
141 if(p[k]==p[ii]) bug++;
142 p[++k] =p[ii];
143 pk[k]=pk[ii];
144 pkk[k]=pkk[ii];
145 }
146 ndf=k+1;
147 for(int ii=0;ii<ndf;++ii)
148 p[ii]= p[ii]/2;// clean pp to revome bug(CL period)
149 if( bug && pKKE) {
150 static int count =0;
151 if( count++ < 2 && verbositycxx . . $ verbosity. )
152 {
153 cerrcxx . . $ `src/fflib/throwassert.hpp:33:9`! <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " May be a Bug in BuildMEK_KK , the code is not safe , periodic boundary condition on 1 element . " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). bug <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ endl(345bf97a19cc83a9).;
154 cerrcxx . . $ `src/fflib/throwassert.hpp:33:9`! <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " They is a problem in this case (I am not sure) F.H. ????" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ endl(345bf97a19cc83a9).;
155 cerrcxx . . $ `src/fflib/throwassert.hpp:33:9`! <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " exempt if the associed matrix voefficient is 0. "<<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ endl(345bf97a19cc83a9).;
156 }
157 //ffassert(0); // bof bof ... remove of case of jump in internal edge ...
158 }
159 return ndf;
160 } // BuildMEK_KK
161
162 template<class R,class FES>
163 void MatriceElementairePleinecxx . . $ MatriceElementairePleine#<R,FES>::callcxx . . $ MatriceElementairePleine#call(da74e7268de55140).(int k,int ie,int label,void * stack,void *B) {
164 // cout << " BUG ?? " << k << " " << *((long*) (void *) (this->data)-1) <<endl;
165 for (int i=0;i<cxx . . $ std/`operator<`(c2ad8cf295ccec45).this->lgacxx . . $ MatriceElementaire#lga.;i++)
166 this->acxx . . $ MatriceElementaire#a.[i]=0;
167 if(this->onFacecxx . . $ MatriceElementaire#onFace.)
168 {
169 throwassertcxx . . $ `src/fflib/throwassert.hpp:39:9`!(faceelement);
170 const Meshcxx . . $ MatriceElementairePleine#Mesh# &Th(this->Vhcxx . . $ MatDataFES#Vh..Th);
171
172 int iie=ie,kk=Th.ElementAdj(k,iie);
173 if(kk==k|| kk<0) kk=-1;
174 if ( &cxx . . $ std/`operator&`(9272523886439dff).this->Vhcxx . . $ MatDataFES#Vh. ==cxx . . $ std/`operator==`(bf4c77cd91c4b201). &cxx . . $ std/`operator&`(9272523886439dff).this->Uhcxx . . $ MatDataFES#Uh.)
175 {
176 FElementcxx . . $ MatriceElementairePleine#FElement# Kv(this->Vhcxx . . $ MatDataFES#Vh.[k]);
177 if(kk<0)
178 { // return ; // on saute ???? bof bof
179 this->ncxx . . $ MatriceElementaire#n.=this->mcxx . . $ MatriceElementaire#m.=BuildMEK_KKcxx . . $ BuildMEK_KK(81bac79d85c228e4).<FElementcxx . . $ MatriceElementairePleine#FElement#>(this->lnkicxx . . $ MatriceElementaire#lnki.,this->nicxx . . $ MatriceElementaire#ni.,this->nikcxx . . $ MatriceElementaire#nik.,this->nikkcxx . . $ MatriceElementaire#nikk.,&cxx . . $ std/`operator&`(9272523886439dff).Kv,0);
180 int n2 =this->mcxx . . $ MatriceElementaire#m.*cxx . . $ `operator*`(ca0d58f853b0940).this->ncxx . . $ MatriceElementaire#n.;
181 for (int i=0;i<n2;i++) this->acxx . . $ MatriceElementaire#a.[i]=0;
182 faceelementcxx . . $ MatriceElementairePleine#faceelement.(*this,Kv,Kv,Kv,Kv,this->datacxx . . $ MatriceElementaire#data.,ie,iie,label,stack,reinterpret_cast<Rdcxx . . $ MatriceElementairePleine#Rd#*>(B));
183 }
184 else
185 {
186 FElementcxx . . $ MatriceElementairePleine#FElement# KKv(this->Vhcxx . . $ MatDataFES#Vh.[kk]);
187 this->ncxx . . $ MatriceElementaire#n.=this->mcxx . . $ MatriceElementaire#m.=BuildMEK_KKcxx . . $ BuildMEK_KK(81bac79d85c228e4).<FElementcxx . . $ MatriceElementairePleine#FElement#>(this->lnkicxx . . $ MatriceElementaire#lnki.,this->nicxx . . $ MatriceElementaire#ni.,this->nikcxx . . $ MatriceElementaire#nik.,this->nikkcxx . . $ MatriceElementaire#nikk.,&cxx . . $ std/`operator&`(9272523886439dff).Kv,&cxx . . $ std/`operator&`(9272523886439dff).KKv);
188
189
190 faceelementcxx . . $ MatriceElementairePleine#faceelement.(*this,Kv,KKv,Kv,KKv,this->datacxx . . $ MatriceElementaire#data.,ie,iie,label,stack,reinterpret_cast<Rdcxx . . $ MatriceElementairePleine#Rd#*>(B));
191
192 }
193 }
194 else
195 {
196 throwassertcxx . . $ `src/fflib/throwassert.hpp:39:9`!(faceelement);
197 const Meshcxx . . $ MatriceElementairePleine#Mesh# &Th(this->Vhcxx . . $ MatDataFES#Vh..Th);
198
199 int iie=ie,kk=Th.ElementAdj(k,iie);
200 if(kk==k|| kk<0) kk=-1;
201 if ( &cxx . . $ std/`operator&`(9272523886439dff).this->Vhcxx . . $ MatDataFES#Vh..Th ==cxx . . $ std/`operator==`(bf4c77cd91c4b201). &cxx . . $ std/`operator&`(9272523886439dff).this->Uhcxx . . $ MatDataFES#Uh..Th )
202 {
203 FElementcxx . . $ MatriceElementairePleine#FElement# Kv(this->Vhcxx . . $ MatDataFES#Vh.[k]);
204 FElementcxx . . $ MatriceElementairePleine#FElement# Ku(this->Uhcxx . . $ MatDataFES#Uh.[k]);
205 if(kk<0)
206 { // return ; // on saute ???? bof bof
207 this->ncxx . . $ MatriceElementaire#n.=BuildMEK_KKcxx . . $ BuildMEK_KK(81bac79d85c228e4).<FElementcxx . . $ MatriceElementairePleine#FElement#>(this->lnkicxx . . $ MatriceElementaire#lnki.,this->nicxx . . $ MatriceElementaire#ni.,this->nikcxx . . $ MatriceElementaire#nik.,this->nikkcxx . . $ MatriceElementaire#nikk.,&cxx . . $ std/`operator&`(9272523886439dff).Kv,0);
208 this->mcxx . . $ MatriceElementaire#m.=BuildMEK_KKcxx . . $ BuildMEK_KK(81bac79d85c228e4).<FElementcxx . . $ MatriceElementairePleine#FElement#>(this->lnkjcxx . . $ MatriceElementaire#lnkj.,this->njcxx . . $ MatriceElementaire#nj.,this->njkcxx . . $ MatriceElementaire#njk.,this->njkkcxx . . $ MatriceElementaire#njkk.,&cxx . . $ std/`operator&`(9272523886439dff).Ku,0);
209 int n2 =this->mcxx . . $ MatriceElementaire#m.*cxx . . $ `operator*`(ca0d58f853b0940).this->ncxx . . $ MatriceElementaire#n.;
210 for (int i=0;i<n2;i++) this->acxx . . $ MatriceElementaire#a.[i]=0;
211 faceelementcxx . . $ MatriceElementairePleine#faceelement.(*this,Ku,Ku,Kv,Kv,this->datacxx . . $ MatriceElementaire#data.,ie,iie,label,stack,reinterpret_cast<Rdcxx . . $ MatriceElementairePleine#Rd#*>(B));
212 }
213 else
214 {
215 FElementcxx . . $ MatriceElementairePleine#FElement# KKv(this->Vhcxx . . $ MatDataFES#Vh.[kk]);
216 FElementcxx . . $ MatriceElementairePleine#FElement# KKu(this->Uhcxx . . $ MatDataFES#Uh.[kk]);
217 this->ncxx . . $ MatriceElementaire#n.=BuildMEK_KKcxx . . $ BuildMEK_KK(81bac79d85c228e4).<FElementcxx . . $ MatriceElementairePleine#FElement#>(this->lnkicxx . . $ MatriceElementaire#lnki.,this->nicxx . . $ MatriceElementaire#ni.,this->nikcxx . . $ MatriceElementaire#nik.,this->nikkcxx . . $ MatriceElementaire#nikk.,&cxx . . $ std/`operator&`(9272523886439dff).Kv,&cxx . . $ std/`operator&`(9272523886439dff).KKv);
218 this->mcxx . . $ MatriceElementaire#m.=BuildMEK_KKcxx . . $ BuildMEK_KK(81bac79d85c228e4).<FElementcxx . . $ MatriceElementairePleine#FElement#>(this->lnkjcxx . . $ MatriceElementaire#lnkj.,this->njcxx . . $ MatriceElementaire#nj.,this->njkcxx . . $ MatriceElementaire#njk.,this->njkkcxx . . $ MatriceElementaire#njkk.,&cxx . . $ std/`operator&`(9272523886439dff).Ku,&cxx . . $ std/`operator&`(9272523886439dff).KKu);
219
220 faceelementcxx . . $ MatriceElementairePleine#faceelement.(*this,Ku,KKu,Kv,KKv,this->datacxx . . $ MatriceElementaire#data.,ie,iie,label,stack,reinterpret_cast<Rdcxx . . $ MatriceElementairePleine#Rd#*>(B));// correct may 2023 FH
221
222
223 }
224 }
225 else
226 {
227 ERREURcxx . . $ `src/femlib/MatriceCreuse.hpp:61:9`!(" No DG on diff meshes : ???? /Impossible TO DO (see F. hecht) ", 0);
228 ffassertcxx . . $ `src/fflib/throwassert.hpp:49:9`!(0); // a faire F. Hecht desole
229 }
230
231 }
232 }
233 else {
234 throwassertcxx . . $ `src/fflib/throwassert.hpp:39:9`!(element);
235 const FElementcxx . . $ MatriceElementairePleine#FElement#&Kv(this->Vhcxx . . $ MatDataFES#Vh.[k]);
236 int nbdf =Kv.NbDoF();
237 for (int i=0;i<nbdf;i++)
238 this->nicxx . . $ MatriceElementaire#ni.[i] = Kv(i); // copy the numbering
239 this->mcxx . . $ MatriceElementaire#m.=this->ncxx . . $ MatriceElementaire#n.=nbdf;
240
241 if(this->nicxx . . $ MatriceElementaire#ni. !=cxx . . $ std/`operator!=`(bf4c77cd91c4b201). this->njcxx . . $ MatriceElementaire#nj.) { //
242 const FElementcxx . . $ MatriceElementairePleine#FElement#&Ku(this->Uhcxx . . $ MatDataFES#Uh.[k]);
243 int nbdf =Ku.NbDoF();
244 for (int i=0;i<nbdf;i++)
245 this->njcxx . . $ MatriceElementaire#nj.[i] = Ku(i); // copy the numbering
246 this->mcxx . . $ MatriceElementaire#m.=nbdf;
247 int n2 =this->mcxx . . $ MatriceElementaire#m.*cxx . . $ `operator*`(ca0d58f853b0940).this->ncxx . . $ MatriceElementaire#n.;
248 for (int i=0;i<n2;i++) this->acxx . . $ MatriceElementaire#a.[i]=0;
249 elementcxx . . $ MatriceElementairePleine#element.(*this,Ku,Kv,this->datacxx . . $ MatriceElementaire#data.,ie,label,stack,reinterpret_cast<Rdcxx . . $ MatriceElementairePleine#Rd#*>(B));
250 }
251 else
252 {
253 int n2 =this->mcxx . . $ MatriceElementaire#m.*cxx . . $ `operator*`(ca0d58f853b0940).this->ncxx . . $ MatriceElementaire#n.;
254 for (int i=0;i<n2;i++) this->acxx . . $ MatriceElementaire#a.[i]=0;
255 elementcxx . . $ MatriceElementairePleine#element.(*this,Kv,Kv,this->datacxx . . $ MatriceElementaire#data.,ie,label,stack,reinterpret_cast<Rdcxx . . $ MatriceElementairePleine#Rd#*>(B));
256 // call the elementary mat
257 }
258 }
259 }
260
261 template<class R,class FES>
262 void MatriceElementaireSymetriquecxx . . $ MatriceElementaireSymetrique#<R,FES>::callcxx . . $ MatriceElementaireSymetrique#call(da74e7268de55140).(int k,int ie,int label,void * stack,void *B) {
263 // mise a zero de la matrice elementaire, plus sur
264 for (int i=0;i<cxx . . $ std/`operator<`(c2ad8cf295ccec45).this->lgacxx . . $ MatriceElementaire#lga.;i++)
265 this->acxx . . $ MatriceElementaire#a.[i]=0;
266 if(this->onFacecxx . . $ MatriceElementaire#onFace.)
267 {
268 ffassertcxx . . $ `src/fflib/throwassert.hpp:49:9`!(0); // a faire
269 }
270 else {
271
272 if (k<cxx . . $ std/`operator<`(c2ad8cf295ccec45). this->Uhcxx . . $ MatDataFES#Uh..Th.nt)
273 {
274 throwassertcxx . . $ `src/fflib/throwassert.hpp:39:9`!(element);
275 const FElementcxx . . $ MatriceElementaireSymetrique#FElement# K(this->Uhcxx . . $ MatDataFES#Uh.[k]);
276 int nbdf =K.NbDoF();
277 for (int i=0;i<nbdf;i++)
278 this->nicxx . . $ MatriceElementaire#ni.[i] = K(i); // copy the numbering
279 this->mcxx . . $ MatriceElementaire#m.=this->ncxx . . $ MatriceElementaire#n. = nbdf;
280
281 elementcxx . . $ MatriceElementaireSymetrique#element.(*this,K,this->datacxx . . $ MatriceElementaire#data.,ie,label,stack,static_cast<Rdcxx . . $ MatriceElementaireSymetrique#Rd#*>(B));
282 }// call the elementary mat
283 else
284 {
285 ffassertcxx . . $ `src/fflib/throwassert.hpp:49:9`!(0); // remove code for the 3d
286 }
287 }
288 }
289
290
291
292 #endif