00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ASSIGN_DEFS_H
00012 #define ASSIGN_DEFS_H
00013
00014
00015 #include "Field/AssignTags.h"
00016
00017
00018 template<class T, unsigned int D> class BareField;
00019 template<class T, unsigned int D> class BareFieldIterator;
00020 template<class T, unsigned int D> class IndexedBareFieldIterator;
00021
00023
00024
00025
00027
00028 template<class T, class C, unsigned int D>
00029 inline bool
00030 for_each(const BareFieldIterator<T,D>& p, SameFieldID s, C)
00031 {
00032 return p.GetBareField().get_Id() == s.ID;
00033 }
00034
00035 template<class T, class C, unsigned int D>
00036 inline bool
00037 for_each(const IndexedBareFieldIterator<T,D>& p, SameFieldID s, C)
00038 {
00039 return p.GetBareField().get_Id() == s.ID;
00040 }
00041
00042
00043
00044
00045 template<class C>
00046 inline bool
00047 for_each(const Index::cursor&, SameFieldID, C)
00048 {
00049 return false;
00050 }
00051
00052
00053
00054
00055 template<class T, class C>
00056 inline bool
00057 for_each(const PETE_Scalar<T>&, SameFieldID, C)
00058 {
00059 return false;
00060 }
00061
00063
00064
00065
00067
00068 template<unsigned D>
00069 struct PlugBase
00070 {
00071 NDIndex<D> Domain;
00072 PlugBase( const NDIndex<D>& domain ) : Domain(domain) {}
00073 typedef bool PETE_Return_t;
00074 };
00075
00076
00077
00078
00079 template<class T, unsigned int D1, unsigned D2, class C>
00080 inline bool
00081 for_each(IndexedBareFieldIterator<T,D1>& p, const PlugBase<D2>& f, C)
00082 {
00083 return p.plugBase(f.Domain);
00084 }
00085
00086
00087
00088
00089 template<class C, unsigned D>
00090 inline bool
00091 for_each(Index::cursor& p, const PlugBase<D>& f, C)
00092 {
00093
00094
00095 for (unsigned d=0; d<D; ++d)
00096 {
00097
00098 if ( p.id() == f.Domain[d].id() )
00099 {
00100
00101 return p.plugBase( f.Domain[d], d );
00102 }
00103 }
00104 return false;
00105 }
00106
00107
00108
00109
00110 template<class T, class C, unsigned D>
00111 inline bool
00112 for_each(const PETE_Scalar<T>&, const PlugBase<D>&, C)
00113 {
00114 return true;
00115 }
00116
00118
00119
00120
00122
00123 template<class T, class C, unsigned int D>
00124 inline bool
00125 for_each(const IndexedBareFieldIterator<T,D>& p, IsCompressed, C)
00126 {
00127 return p.IsCompressed();
00128 }
00129
00130 template<class T, class C, unsigned int D>
00131 inline bool
00132 for_each(const BareFieldIterator<T,D>& p, IsCompressed, C)
00133 {
00134 return p.IsCompressed();
00135 }
00136
00137
00138
00139
00140 template<class C>
00141 inline bool
00142 for_each(const Index::cursor&, IsCompressed, C)
00143 {
00144 return false;
00145 }
00146
00147
00148
00149
00150 template<class T, class C>
00151 inline bool
00152 for_each(const PETE_Scalar<T>&, IsCompressed, C)
00153 {
00154 return true;
00155 }
00156
00158
00159
00160
00161
00163
00164 template<class T, unsigned int D>
00165 inline T&
00166 for_each(const BrickIterator<T,D>& p, EvalFunctor_0)
00167 {
00168 return *p;
00169 }
00170
00171
00172
00173
00174 inline int
00175 for_each(const Index::cursor& p, EvalFunctor_0)
00176 {
00177 return *p;
00178 }
00179
00181
00182
00183
00184
00186
00187 template<class T, unsigned int D>
00188 inline T&
00189 for_each(const BrickIterator<T,D>& p, const EvalFunctor_1& e)
00190 {
00191 return p.offset(e.I);
00192 }
00193
00194 template<class T, unsigned int D>
00195 inline T&
00196 for_each(const BrickIterator<T,D>& p, const UnitEvalFunctor_1& e)
00197 {
00198 return p.unit_offset(e.I);
00199 }
00200
00201
00202
00203
00204 inline int
00205 for_each(const Index::cursor& p, const EvalFunctor_1& e)
00206 {
00207 return p.offset(e.I);
00208 }
00209
00210
00211
00212
00213 template<class T>
00214 inline T
00215 for_each(const PETE_Scalar<T>& p, const EvalFunctor_1&)
00216 {
00217 return T(p);
00218 }
00219
00221
00222
00223
00224
00226
00227 template<class T, unsigned int D>
00228 inline T&
00229 for_each(const BrickIterator<T,D>& p, const EvalFunctor_2& e)
00230 {
00231 return p.offset(e.I, e.J);
00232 }
00233
00234 template<class T, unsigned int D>
00235 inline T&
00236 for_each(const BrickIterator<T,D>& p, const UnitEvalFunctor_2& e)
00237 {
00238 return p.unit_offset(e.I, e.J);
00239 }
00240
00241
00242
00243
00244 inline int
00245 for_each(const Index::cursor& p, const EvalFunctor_2& e)
00246 {
00247 return p.offset(e.I, e.J);
00248 }
00249
00250
00251
00252
00253 template<class T>
00254 inline T
00255 for_each(const PETE_Scalar<T>& p, const EvalFunctor_2&)
00256 {
00257 return T(p);
00258 }
00259
00261
00262
00263
00264
00266
00267 template<class T, unsigned int D>
00268 inline T&
00269 for_each(const BrickIterator<T,D>& p, const EvalFunctor_3& e)
00270 {
00271 return p.offset(e.I, e.J, e.K);
00272 }
00273
00274 template<class T, unsigned int D>
00275 inline T&
00276 for_each(const BrickIterator<T,D>& p, const UnitEvalFunctor_3& e)
00277 {
00278 return p.offset(e.I, e.J, e.K);
00279 }
00280
00281
00282
00283
00284 inline int
00285 for_each(const Index::cursor& p, const EvalFunctor_3& e)
00286 {
00287 return p.offset(e.I, e.J, e.K);
00288 }
00289
00290
00291
00292
00293 template<class T>
00294 inline T
00295 for_each(const PETE_Scalar<T>& p, const EvalFunctor_3&)
00296 {
00297 return T(p);
00298 }
00299
00301
00302
00303
00305
00306 template<class T, class C, unsigned int D>
00307 inline int
00308 for_each(BareFieldIterator<T,D>& p, BeginLField, C)
00309 {
00310 p.beginLField();
00311 return 0;
00312 }
00313
00314
00315
00316
00317 template<class T, class C>
00318 inline int
00319 for_each(PETE_Scalar<T>&, BeginLField, C)
00320 {
00321 return 0;
00322 }
00323
00325
00326
00327
00329
00330 template<class T, class C, unsigned int D>
00331 inline int
00332 for_each(BareFieldIterator<T,D>& p, NextLField, C)
00333 {
00334 p.nextLField();
00335 return 0;
00336 }
00337
00338
00339
00340
00341 template<class T, class C>
00342 inline int
00343 for_each(PETE_Scalar<T>&, NextLField, C)
00344 {
00345 return 0;
00346 }
00347
00349
00350
00351
00353
00354 template<class T, class C, unsigned int D>
00355 inline int
00356 for_each(IndexedBareFieldIterator<T,D>& p, StepFunctor s, C)
00357 {
00358 p.step(s.D);
00359 return 0;
00360 }
00361
00362 template<class T, class C, unsigned int D>
00363 inline int
00364 for_each(BareFieldIterator<T,D>& p, StepFunctor s, C)
00365 {
00366 p.step(s.D);
00367 return 0;
00368 }
00369
00370 template<class T, class C, unsigned int D>
00371 inline int
00372 for_each(BrickIterator<T,D>& p, StepFunctor s, C)
00373 {
00374 p.step(s.D);
00375 return 0;
00376 }
00377
00378
00379
00380
00381 template<class C>
00382 inline int
00383 for_each(Index::cursor& p, StepFunctor s, C)
00384 {
00385 p.step(s.D);
00386 return 0;
00387 }
00388
00389
00390
00391
00392 template<class T, class C>
00393 inline int
00394 for_each(PETE_Scalar<T>&, StepFunctor, C)
00395 {
00396 return 0;
00397 }
00398
00400
00401
00402
00404
00405 template<class T, class C, unsigned int D>
00406 inline int
00407 for_each(IndexedBareFieldIterator<T,D>& p, RewindFunctor s, C)
00408 {
00409 p.rewind(s.D);
00410 return 0;
00411 }
00412
00413
00414 template<class T, class C, unsigned int D>
00415 inline int
00416 for_each(BareFieldIterator<T,D>& p, RewindFunctor s, C)
00417 {
00418 p.rewind(s.D);
00419 return 0;
00420 }
00421
00422
00423 template<class T, class C, unsigned int D>
00424 inline int
00425 for_each(BrickIterator<T,D>& p, RewindFunctor s, C)
00426 {
00427 p.rewind(s.D);
00428 return 0;
00429 }
00430
00431
00432
00433
00434 template<class C>
00435 inline int
00436 for_each(Index::cursor& p, RewindFunctor s, C)
00437 {
00438 p.rewind(s.D);
00439 return 0;
00440 }
00441
00442
00443
00444
00445 template<class T, class C>
00446 inline int
00447 for_each(PETE_Scalar<T>&, RewindFunctor, C)
00448 {
00449 return 0;
00450 }
00451
00453
00454
00455
00457
00458 template<class T, class C, unsigned int D>
00459 inline int
00460 for_each(BrickIterator<T,D>& p, PETE_CountElems, C)
00461 {
00462 int size = p.size(0);
00463 for (unsigned int i=1; i<D; ++i)
00464 size *= p.size(i);
00465 return size;
00466 }
00467
00468 template<class T, class C, unsigned int D>
00469 inline int
00470 for_each(BareFieldIterator<T,D>& p, PETE_CountElems, C)
00471 {
00472 BareField<T,D>& f = p.GetBareField();
00473 int n = 0;
00474 for (typename BareField<T,D>::iterator_if lf=f.begin_if(); lf!=f.end_if(); ++lf)
00475 n += (*lf).second->getOwned().size();
00476 return n;
00477 }
00478
00479 template<class T, class C, unsigned int D>
00480 inline int
00481 for_each(IndexedBareFieldIterator<T,D>& p, PETE_CountElems, C)
00482 {
00483 BareField<T,D>& f = p.GetBareField();
00484 int n = 0;
00485 for (typename BareField<T,D>::iterator_if lf=f.begin_if(); lf!=f.end_if(); ++lf) {
00486 const NDIndex<D>& domain = (*lf).second->getOwned();
00487 if ( p.getDomain().touches(domain) )
00488 n += p.getDomain().intersect(domain).size();
00489 }
00490 return n;
00491 }
00492
00494
00495
00496
00498
00499 template<class T, class C, unsigned int D>
00500 inline int
00501 for_each(IndexedBareFieldIterator<T,D>& p, PETE_Increment s, C)
00502 {
00503 ++p;
00504 return 0;
00505 }
00506
00507
00508 template<class T, class C, unsigned int D>
00509 inline int
00510 for_each(BareFieldIterator<T,D>& p, PETE_Increment s, C)
00511 {
00512 ++p;
00513 return 0;
00514 }
00515
00516
00517 template<class T, class C, unsigned int D>
00518 inline int
00519 for_each(BrickIterator<T,D>& p, PETE_Increment s, C)
00520 {
00521 ++p;
00522 return 0;
00523 }
00524
00526
00527
00528
00529
00531
00532 template<class T, class C, unsigned int D>
00533 inline bool
00534 for_each(const IndexedBareFieldIterator<T,D>& iter, HasUnitStride, C)
00535 {
00536 return iter.Stride(0) == 1;
00537 }
00538
00539 template<class T, class C, unsigned int D>
00540 inline bool
00541 for_each(const BareFieldIterator<T,D>& iter, HasUnitStride, C)
00542 {
00543 return iter.Stride(0) == 1;
00544 }
00545
00546 template<class T, class C, unsigned int D>
00547 inline bool
00548 for_each(const BrickIterator<T,D>& iter, HasUnitStride, C)
00549 {
00550 return iter.Stride(0) == 1;
00551 }
00552
00553 template<class C>
00554 inline bool
00555 for_each(const Index::cursor&, HasUnitStride, C)
00556 {
00557 return true;
00558 }
00559
00560 template<class T, class C>
00561 inline bool
00562 for_each(const PETE_Scalar<T>&, HasUnitStride, C)
00563 {
00564 return true;
00565 }
00566
00568
00569
00570
00572
00573 template<class T, class C, unsigned int D, unsigned int D1, class T1>
00574 inline int
00575 for_each(const IndexedBareFieldIterator<T,D>& p,
00576 const FillGCIfNecessaryTag<D1,T1> &f, C)
00577 {
00578 p.FillGCIfNecessary(*(f.bf_m));
00579 return 0;
00580 }
00581
00582 template<class T, class C, unsigned int D, unsigned int D1, class T1>
00583 inline int
00584 for_each(const BareFieldIterator<T,D>& p,
00585 const FillGCIfNecessaryTag<D1,T1> &, C)
00586 {
00587 return 0;
00588 }
00589
00590 template<class T, class C, unsigned int D, class T1>
00591 inline int
00592 for_each(const PETE_Scalar<T>&, const FillGCIfNecessaryTag<D,T1> &, C)
00593 {
00594 return 0;
00595 }
00596
00597 template<class C, unsigned int D, class T1>
00598 inline int
00599 for_each(const Index::cursor&, const FillGCIfNecessaryTag<D,T1> &, C)
00600 {
00601 return 0;
00602 }
00603
00604 #endif // ASSIGN_DEFS_H
00605
00606
00607
00608
00609
00610