OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
AssignDefs.h
Go to the documentation of this file.
1// -*- C++ -*-
2/***************************************************************************
3 *
4 * The IPPL Framework
5 *
6 *
7 * Visit http://people.web.psi.ch/adelmann/ for more details
8 *
9 ***************************************************************************/
10
11#ifndef ASSIGN_DEFS_H
12#define ASSIGN_DEFS_H
13
14// include files
15#include "Field/AssignTags.h"
16
17// forward declarations
18template<class T, unsigned int D> class BareField;
19template<class T, unsigned int D> class BareFieldIterator;
20template<class T, unsigned int D> class IndexedBareFieldIterator;
21
23//
24// Do any of the terms in an expression have an ID equal to a given one?
25//
27
28template<class T, class C, unsigned int D>
29inline bool
31{
32 return p.GetBareField().get_Id() == (unsigned int) s.fID;
33}
34
35template<class T, class C, unsigned int D>
36inline bool
38{
39 return p.GetBareField().get_Id() == (unsigned int) s.fID;
40}
41
42//
43// If there is an index in the expr, it can't have the same ID.
44//
45template<class C>
46inline bool
48{
49 return false;
50}
51
52//
53// If there is a scalar in the expr, it can't have the same ID.
54//
55template<class T, class C>
56inline bool
58{
59 return false;
60}
61
63//
64// Plugbase.
65//
67
68template<unsigned D>
70{
72 PlugBase( const NDIndex<D>& domain ) : Domain(domain) {}
73 typedef bool PETE_Return_t;
74};
75
76//
77// Plug into an IndexedBareField.
78//
79template<class T, unsigned int D1, unsigned D2, class C>
80inline bool
82{
83 return p.plugBase(f.Domain);
84}
85
86//
87// plugbase
88//
89template<class C, unsigned D>
90inline bool
92{
93 //cout << "Plugging " << f.Domain << endl;
94 //cout << " p.id() = " << p.id() << endl;
95 for (unsigned d=0; d<D; ++d)
96 {
97 //cout << " d=" << d << ", id=" << f.Domain[d].id() << endl;
98 if ( p.id() == f.Domain[d].id() )
99 {
100 //cout << " matched." << endl;
101 return p.plugBase( f.Domain[d], d );
102 }
103 }
104 return false;
105}
106
107//
108// just return true for scalar
109//
110template<class T, class C, unsigned D>
111inline bool
113{
114 return true;
115}
116
118//
119// Ask each term if it is compressed.
120//
122
123template<class T, class C, unsigned int D>
124inline bool
126{
127 return p.IsCompressed();
128}
129
130template<class T, class C, unsigned int D>
131inline bool
133{
134 return p.IsCompressed();
135}
136
137//
138// Indexes are never compressed.
139//
140template<class C>
141inline bool
143{
144 return false;
145}
146
147//
148// Scalars are always compressed.
149//
150template<class T, class C>
151inline bool
153{
154 return true;
155}
156
158//
159// Evaluation functors.
160// First, no arguments.
161//
163
164template<class T, unsigned int D>
165inline T&
167{
168 return *p;
169}
170
171//
172// Evaluate an Index.
173//
174inline int
176{
177 return *p;
178}
179
181//
182// Evaluation functors.
183// One argument.
184//
186
187template<class T, unsigned int D>
188inline T&
190{
191 return p.offset(e.I);
192}
193
194template<class T, unsigned int D>
195inline T&
197{
198 return p.unit_offset(e.I);
199}
200
201//
202// Evaluate an Index.
203//
204inline int
206{
207 return p.offset(e.I);
208}
209
210//
211// Evaluate a scalar.
212//
213template<class T>
214inline T
216{
217 return T(p);
218}
219
221//
222// Evaluation functors.
223// Two arguments.
224//
226
227template<class T, unsigned int D>
228inline T&
230{
231 return p.offset(e.I, e.J);
232}
233
234template<class T, unsigned int D>
235inline T&
237{
238 return p.unit_offset(e.I, e.J);
239}
240
241//
242// Evaluate an Index.
243//
244inline int
246{
247 return p.offset(e.I, e.J);
248}
249
250//
251// Evaluate a scalar.
252//
253template<class T>
254inline T
256{
257 return T(p);
258}
259
261//
262// Evaluation functors.
263// Three arguments.
264//
266
267template<class T, unsigned int D>
268inline T&
270{
271 return p.offset(e.I, e.J, e.K);
272}
273
274template<class T, unsigned int D>
275inline T&
277{
278 return p.offset(e.I, e.J, e.K);
279}
280
281//
282// Evaluate an Index.
283//
284inline int
286{
287 return p.offset(e.I, e.J, e.K);
288}
289
290//
291// Evaluate a scalar.
292//
293template<class T>
294inline T
296{
297 return T(p);
298}
299
301//
302// Get started in a given LField
303//
305
306template<class T, class C, unsigned int D>
307inline int
309{
310 p.beginLField();
311 return 0;
312}
313
314//
315// ignore this signal
316//
317template<class T, class C>
318inline int
320{
321 return 0;
322}
323
325//
326// Go on to the next LField.
327//
329
330template<class T, class C, unsigned int D>
331inline int
333{
334 p.nextLField();
335 return 0;
336}
337
338//
339// If there is a scalar in the expr, it ignores this signal.
340//
341template<class T, class C>
342inline int
344{
345 return 0;
346}
347
349//
350// Step in some dimension.
351//
353
354template<class T, class C, unsigned int D>
355inline int
357{
358 p.step(s.D);
359 return 0;
360}
361
362template<class T, class C, unsigned int D>
363inline int
365{
366 p.step(s.D);
367 return 0;
368}
369
370template<class T, class C, unsigned int D>
371inline int
373{
374 p.step(s.D);
375 return 0;
376}
377
378//
379// Step along an Index.
380//
381template<class C>
382inline int
384{
385 p.step(s.D);
386 return 0;
387}
388
389//
390// scalar ignores step functor
391//
392template<class T, class C>
393inline int
395{
396 return 0;
397}
398
400//
401// Rewind in some dimension.
402//
404
405template<class T, class C, unsigned int D>
406inline int
408{
409 p.rewind(s.D);
410 return 0;
411}
412
413
414template<class T, class C, unsigned int D>
415inline int
417{
418 p.rewind(s.D);
419 return 0;
420}
421
422
423template<class T, class C, unsigned int D>
424inline int
426{
427 p.rewind(s.D);
428 return 0;
429}
430
431//
432// Rewind an Index.
433//
434template<class C>
435inline int
437{
438 p.rewind(s.D);
439 return 0;
440}
441
442//
443// scalar ignores rewind functor
444//
445template<class T, class C>
446inline int
448{
449 return 0;
450}
451
453//
454// Count the number of elements in an expression.
455//
457
458template<class T, class C, unsigned int D>
459inline int
461{
462 int size = p.size(0);
463 for (unsigned int i=1; i<D; ++i)
464 size *= p.size(i);
465 return size;
466}
467
468template<class T, class C, unsigned int D>
469inline int
471{
473 int n = 0;
474 for (typename BareField<T,D>::iterator_if lf=f.begin_if(); lf!=f.end_if(); ++lf)
475 n += (*lf).second->getOwned().size();
476 return n;
477}
478
479template<class T, class C, unsigned int D>
480inline int
482{
484 int n = 0;
485 for (typename BareField<T,D>::iterator_if lf=f.begin_if(); lf!=f.end_if(); ++lf) {
486 const NDIndex<D>& domain = (*lf).second->getOwned();
487 if ( p.getDomain().touches(domain) )
488 n += p.getDomain().intersect(domain).size();
489 }
490 return n;
491}
492
494//
495// Increment the pointers in an expression.
496//
498
499template<class T, class C, unsigned int D>
500inline int
502{
503 ++p;
504 return 0;
505}
506
507
508template<class T, class C, unsigned int D>
509inline int
511{
512 ++p;
513 return 0;
514}
515
516
517template<class T, class C, unsigned int D>
518inline int
520{
521 ++p;
522 return 0;
523}
524
526//
527// Find out if all the BrickIterators in an expression
528// have unit stride in the first dimension.
529//
531
532template<class T, class C, unsigned int D>
533inline bool
535{
536 return iter.Stride(0) == 1;
537}
538
539template<class T, class C, unsigned int D>
540inline bool
542{
543 return iter.Stride(0) == 1;
544}
545
546template<class T, class C, unsigned int D>
547inline bool
549{
550 return iter.Stride(0) == 1;
551}
552
553template<class C>
554inline bool
556{
557 return true;
558}
559
560template<class T, class C>
561inline bool
563{
564 return true;
565}
566
568//
569// Ask each term to fill guard cells and compress itself
570//
572
573template<class T, class C, unsigned int D, unsigned int D1, class T1>
574inline int
576 const FillGCIfNecessaryTag<D1,T1> &f, C)
577{
578 p.FillGCIfNecessary(*(f.bf_m));
579 return 0;
580}
581
582template<class T, class C, unsigned int D, unsigned int D1, class T1>
583inline int
586{
587 return 0;
588}
589
590template<class T, class C, unsigned int D, class T1>
591inline int
593{
594 return 0;
595}
596
597template<class C, unsigned int D, class T1>
598inline int
600{
601 return 0;
602}
603
604#endif // ASSIGN_DEFS_H
605
606/***************************************************************************
607 * $RCSfile: AssignDefs.h,v $ $Author: adelmann $
608 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:26 $
609 * IPPL_VERSION_ID: $Id: AssignDefs.h,v 1.1.1.1 2003/01/23 07:40:26 adelmann Exp $
610 ***************************************************************************/
bool for_each(const BareFieldIterator< T, D > &p, SameFieldID s, C)
Definition: AssignDefs.h:30
constexpr double e
The value of.
Definition: Physics.h:39
iterator_if begin_if()
Definition: BareField.h:100
ac_id_larray::iterator iterator_if
Definition: BareField.h:92
iterator_if end_if()
Definition: BareField.h:101
BareField< T, Dim > & GetBareField()
bool IsCompressed() const
const NDIndex< Dim > & getDomain() const
void FillGCIfNecessary(const BareField< T1, D1 > &lhs) const
bool plugBase(const NDIndex< D2 > &i)
NDIndex< D > Domain
Definition: AssignDefs.h:71
PlugBase(const NDIndex< D > &domain)
Definition: AssignDefs.h:72
bool PETE_Return_t
Definition: AssignDefs.h:73
unsigned D
Definition: AssignTags.h:89
unsigned D
Definition: AssignTags.h:96
const BareField< T1, D > * bf_m
Definition: AssignTags.h:121
int size(unsigned d) const
Definition: BrickIterator.h:43
T & offset(int i) const
T & unit_offset(int i) const
int Stride(int i) const
void rewind(unsigned d)
void step(unsigned d)
Definition: BrickIterator.h:95
int id() const
Definition: Index.h:368
bool plugBase(const Index &i, unsigned d=0)
Definition: Index.h:360
void step(unsigned d)
Definition: Index.h:350
void rewind(unsigned d)
Definition: Index.h:355
int offset() const
Definition: Index.h:331