OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
SubBareField.hpp
Go to the documentation of this file.
1// -*- C++ -*-
2/***************************************************************************
3 *
4 * The IPPL Framework
5 *
6 * This program was prepared by PSI.
7 * All rights in the program are reserved by PSI.
8 * Neither PSI nor the author(s)
9 * makes any warranty, express or implied, or assumes any liability or
10 * responsibility for the use of this software
11 *
12 * Visit www.amas.web.psi for more details
13 *
14 ***************************************************************************/
15
16// -*- C++ -*-
17/***************************************************************************
18 *
19 * The IPPL Framework
20 *
21 *
22 * Visit http://people.web.psi.ch/adelmann/ for more details
23 *
24 ***************************************************************************/
25
26// include files
30#include "Field/BareField.h"
31#include "Field/LField.h"
32#include "Utility/IpplInfo.h"
33#include "Utility/PAssert.h"
34
35
36
38// check to see if it is ok to add the given number of brackets to our
39// current number
40template<class T, unsigned int Dim, class S>
42
43
44
45 if ((Brackets + B) > Dim) {
46 ERRORMSG("Too many dimensions indexed in SubBareField: ");
47 ERRORMSG((Brackets + B) << " > " << Dim << endl);
48 return false;
49 }
50 return true;
51}
52
53
54
56// assignment of another SubBareField
57template<class T, unsigned int Dim, class S>
60
61
62 assign(*this, t);
63 return *this;
64}
65
66
68// assignment of a scalar
69template<class T, unsigned int Dim, class S>
72
73
74 assign(*this, t);
75 return *this;
76}
77
78
80// get a single value and return it in the given storage. Whichever
81// node owns the value must broadcast it to the other nodes.
82template<class T, unsigned int Dim, class S>
84
85
86 // make sure we have a properly bracketed object
87 PAssert_EQ(checkBrackets(), true);
88
89 // construct an NDIndex which refers to the single point.
90 NDIndex<Dim> Indexes;
91 iterator::makeNDIndex(MyDomain, Indexes);
92
93 // get the value from the BareField
94 A.get(Indexes, r);
95}
96
97
99// Return the beginning and end iterators for this class.
100template<class T, unsigned int Dim, class S>
102
103
104
105 return iterator(A, A.begin_if(), MyDomain, Brackets);
106}
107
108template<class T, unsigned int Dim, class S>
110
111
112
113 return iterator(A, A.end_if(), MyDomain, Brackets);
114}
115
116
118// write this subfield to the given ostream
119template<class T, unsigned int Dim, class S>
120void SubBareField<T,Dim,S>::write(std::ostream& o) {
121
122
123 // make sure we have the right number of brackets
124 PAssert_EQ(Dim, Brackets);
125
126 // determine the range of values which we need to print
127 NDIndex<Dim> testIndex;
128 iterator::makeNDIndex(MyDomain, testIndex);
129
130 // finally, print out the subfield
131 o << A[testIndex];
132}
133
134
136
137/***************************************************************************
138 * $RCSfile: SubBareField.cpp,v $ $Author: adelmann $
139 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:33 $
140 * IPPL_VERSION_ID: $Id: SubBareField.cpp,v 1.1.1.1 2003/01/23 07:40:33 adelmann Exp $
141 ***************************************************************************/
const unsigned Dim
void assign(const BareField< T, Dim > &a, RHS b, OP op, ExprTag< true >)
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
#define PAssert_EQ(a, b)
Definition: PAssert.h:104
#define ERRORMSG(msg)
Definition: IpplInfo.h:350
std::string::iterator iterator
Definition: MSLang.h:16
iterator begin() const
SubBareField< T, Dim, S > & operator=(const SubBareField< T, Dim, S > &)
iterator end() const
bool checkAddBrackets(unsigned int)
void write(std::ostream &)