OPAL (Object Oriented Parallel Accelerator Library)
2024.2
OPAL
ippl
src
SubField
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
27
#include "
SubField/SubBareField.h
"
28
#include "
SubField/SubFieldTraits.h
"
29
#include "
SubField/SubFieldAssign.h
"
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
40
template
<
class
T,
unsigned
int
Dim,
class
S>
41
bool
SubBareField<T,Dim,S>::checkAddBrackets
(
unsigned
int
B) {
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
57
template
<
class
T,
unsigned
int
Dim,
class
S>
58
SubBareField<T,Dim,S>
&
59
SubBareField<T,Dim,S>::operator=
(
const
SubBareField<T,Dim,S>
&t) {
60
61
62
assign
(*
this
, t);
63
return
*
this
;
64
}
65
66
68
// assignment of a scalar
69
template
<
class
T,
unsigned
int
Dim,
class
S>
70
SubBareField<T,Dim,S>
&
71
SubBareField<T,Dim,S>::operator=
(T t) {
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.
82
template
<
class
T,
unsigned
int
Dim,
class
S>
83
void
SubBareField<T,Dim,S>::get
(T& r) {
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.
100
template
<
class
T,
unsigned
int
Dim,
class
S>
101
typename
SubBareField<T,Dim,S>::iterator
SubBareField<T,Dim,S>::begin
()
const
{
102
103
104
105
return
iterator
(A, A.begin_if(), MyDomain, Brackets);
106
}
107
108
template
<
class
T,
unsigned
int
Dim,
class
S>
109
typename
SubBareField<T,Dim,S>::iterator
SubBareField<T,Dim,S>::end
()
const
{
110
111
112
113
return
iterator
(A, A.end_if(), MyDomain, Brackets);
114
}
115
116
118
// write this subfield to the given ostream
119
template
<
class
T,
unsigned
int
Dim,
class
S>
120
void
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
***************************************************************************/
Dim
const unsigned Dim
Definition
P3MPoissonSolver.h:26
SubBareField.h
SubFieldAssign.h
SubFieldTraits.h
BareField.h
assign
void assign(const BareField< T, Dim > &a, RHS b, OP op, ExprTag< true >)
LField.h
PAssert.h
PAssert_EQ
#define PAssert_EQ(a, b)
Definition
PAssert.h:104
endl
Inform & endl(Inform &inf)
Definition
Inform.cpp:42
IpplInfo.h
ERRORMSG
#define ERRORMSG(msg)
Definition
IpplInfo.h:350
NDIndex
Definition
NDIndex.h:74
SubBareField
Definition
SubBareField.h:57
SubBareField::begin
iterator begin() const
Definition
SubBareField.hpp:101
SubBareField::operator=
SubBareField< T, Dim, S > & operator=(const SubBareField< T, Dim, S > &)
Definition
SubBareField.hpp:59
SubBareField::get
T get()
Definition
SubBareField.h:92
SubBareField::end
iterator end() const
Definition
SubBareField.hpp:109
SubBareField::checkAddBrackets
bool checkAddBrackets(unsigned int)
Definition
SubBareField.hpp:41
SubBareField::write
void write(std::ostream &)
Definition
SubBareField.hpp:120
SubFieldIter
Definition
SubFieldIter.h:251
Generated on Tue Apr 14 2026 07:18:44 for OPAL (Object Oriented Parallel Accelerator Library) by
1.9.8