OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
SubField.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 SUB_FIELD_H
12#define SUB_FIELD_H
13
14// include files
17
18
19// forward declarations
20template <class T> class PETE_Expr;
21template<class T, unsigned D, class M, class C> class Field;
22
23
24/***************************************************************************
25 SubField - represent a view on a given Field, referring to a
26 subset of the original field data. This is meant as an eventual
27 replacement for IndexedField. It is the same as SubBareField, but also
28 includes the Mesh and Centering template parameters.
29 ***************************************************************************/
30
31template<class T, unsigned int Dim, class M, class C, class S>
32class SubField : public SubBareField<T,Dim,S> {
33
34 friend class Field<T,Dim,M,C>;
35
36public:
37 //
38 // accessor functions
39 //
40
41 // return a reference to the field we are subsetting
42 Field<T,Dim,M,C>& getField() const { return F; }
43
44 //
45 // bracket operators
46 //
47
48 // bracket operator, which select subsets of the BareField.
49 //mwerks template<class S2>
50 //mwerks SubField<T,Dim,M,C,typename SubFieldTraits<T,Dim,S,S2>::Return_t>
51 //mwerks operator[](const S2&);
53 // bracket operators, which select subsets of the Field. This
54 // further subsets from the current SubField based on the type of
55 // input subset object.
56 template<class S2>
58 operator[](const S2& s) {
59 // create a new instance of the resulting subset object
60 typename SubFieldTraits<T,Dim,S,S2>::Return_t newdomain;
61
62
63
64 // make sure we can subset by the number of dimensions requested, then
65 // combine the current subset value with the new one
67 if (this->checkAddBrackets(B)) {
70 s,
71 newdomain,
75 }
76
77 // return a new SubField
78 return SubField<T,Dim,M,C,
79 typename SubFieldTraits<T,Dim,S,S2>::Return_t>(F, newdomain);
80 }
81
82
83 //
84 // assignment operators
85 //
86
87 // assignment of a scalar
88 void operator=(T);
89
90 // assignment of another subfield
92
93 // assignment of an arbitrary expression
94 //mwerks template<class B>
95 //mwerks SubField<T,Dim,M,C,S>& operator=(const PETE_Expr<B> &);
97 // assignment of an arbitrary expression
98 template<class B>
101
102 assign(*this, b);
103 return *this;
104 }
105
106
107
108protected:
109 // the field we are subsetting
111
112public:
113
114 // Make the constructor private so that only this class and it's friends
115 // can construct them.
116 //mwerks template<class S2>
117 //mwerks SubField(Field<T,Dim,M,C>&, const S2&);
119 // Make the constructor private so that only this class and it's friends
120 // can construct them.
121 template<class S2>
122 SubField(Field<T,Dim,M,C>& f, const S2& s)
123 : SubBareField<T,Dim,S>(f, s), F(f) { }
124
125};
126
127#include "SubField/SubField.hpp"
128
129#endif // SUB_FIELD_H
130
131/***************************************************************************
132 * $RCSfile: SubField.h,v $ $Author: adelmann $
133 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:33 $
134 * IPPL_VERSION_ID: $Id: SubField.h,v 1.1.1.1 2003/01/23 07:40:33 adelmann Exp $
135 ***************************************************************************/
const unsigned Dim
void assign(const BareField< T, Dim > &a, RHS b, OP op, ExprTag< true >)
Definition: Field.h:33
Definition: PETE.h:77
bool checkAddBrackets(unsigned int)
Field< T, Dim, M, C > & F
Definition: SubField.h:110
SubField(Field< T, Dim, M, C > &f, const S2 &s)
Definition: SubField.h:122
Field< T, Dim, M, C > & getField() const
Definition: SubField.h:42
SubField< T, Dim, M, C, typename SubFieldTraits< T, Dim, S, S2 >::Return_t > operator[](const S2 &s)
Definition: SubField.h:58
SubField< T, Dim, M, C, S > & operator=(const PETE_Expr< B > &b)
Definition: SubField.h:100
void operator=(T)
Definition: SubField.hpp:36
static void combine(const S1 &, const S2 &, S3 &, unsigned int &, BareField< T, Dim > &)