OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Field.h
Go to the documentation of this file.
1/***************************************************************************
2 *
3 * The IPPL Framework
4 *
5 ***************************************************************************/
6
7#ifndef FIELD_H
8#define FIELD_H
9
10// include files
11#include "Field/BareField.h"
12#include "Field/FieldSpec.h"
13#include "Field/LField.h"
14#include "Field/BCond.h"
15#include "Field/ReductionLoc.h"
16#include "SubField/SubField.h"
19
20// forward declarations
21template <class T, unsigned D, unsigned B, class M, class C>
22class IndexedField;
23
24/***********************************************************************
25 This is the user visible Field of type T.
26 It doesn't even really do expression evaluation; that is
27 handled with the templates in PETE.h
28***********************************************************************/
29
30template<class T, unsigned Dim,
32 class C=typename M::DefaultCentering >
33class Field : public BareField<T,Dim>, public DataSource {
34
35 friend class BareFieldIterator<T,Dim>;
36
37public:
38 //# public typedefs
39 typedef M Mesh_t;
40 typedef C Centering_t;
46
47 // A default constructor, which should be used only if the user calls the
48 // 'initialize' function before doing anything else. There are no special
49 // checks in the rest of the Field methods to check that the Field has
50 // been properly initialized.
52
53 // Destroy the Field.
54 virtual ~Field();
55
56 // Create a new Field with a given layout and optional guard cells.
57 // The default type of BCond lets you add new ones dynamically.
58 // The makeMesh() global function is a way to allow for different types of
59 // constructor arguments for different mesh types.
66 constexpr Field(Field<T,Dim,M,C>&) = default;
67
68 // Constructors including a Mesh object as argument:
73 const BConds<T,Dim,M,C>&);
75 const GuardCellSizes<Dim>&);
77
78 // Initialize the Field, if it was constructed from the default constructor.
79 // This should NOT be called if the Field was constructed by providing
80 // a FieldLayout or FieldSpec
85 const BConds<T,Dim,M,C>&);
87 const GuardCellSizes<Dim>&);
89
90 // Initialize the Field, also specifying a mesh
92 void initialize(Mesh_t&, Layout_t &, const bool); //UL: for pinned memory allocation
96 const BConds<T,Dim,M,C>&);
98 const GuardCellSizes<Dim>&);
100
101 // Definitions for accessing boundary conditions.
102 const bcond_value& getBCond(int bc) const { return *(Bc[bc]); }
103 bcond_value& getBCond(int bc) { return *(Bc[bc]); }
104 const bcond_container& getBConds() const { return Bc; }
108
109 // Access to the mesh
110 Mesh_t& get_mesh() const { return *mesh; }
111
112 // When we apply a bracket it converts the type to IndexedField so
113 // that we can check at compile time that we have the right number
114 // of indexes and brackets. There are a number of different types
115 // which we can use to index a Field in order to get a reference to
116 // a subset of that Field.
121
122 // Assignment from constants and other arrays.
124 assign(*this,x);
125 return *this;
126 }
127
129 assign(*this,x);
130 return *this;
131 }
132
133 template<class X>
135 assign(*this,x);
136 return *this;
137 }
138
139 template<class B>
141 assign(*this,x);
142 return *this;
143 }
144
145 // If you make any modifications using an iterator, you must call this.
146 void fillGuardCells(bool reallyFill = true) const;
147
148 // I/O (special stuff not inherited from BareField):
149 // Print out contents of Centering class
150 void print_Centerings(std::ostream&);
151
152 //
153 // virtual functions for FieldLayoutUser's (and other UserList users)
154 //
155
156 // Repartition onto a new layout, or when the mesh changes
157 virtual void Repartition(UserList *);
158
159 // Tell this object that an object is being deleted
161
162protected:
163 // a virtual function which is called by this base class to get a
164 // specific instance of DataSourceObject based on the type of data
165 // and the connection method (the argument to the call).
167 int);
168
169private:
170 // The boundary conditions.
172
173 // The Mesh object, and a flag indicating if we constructed it
176
177 // store the given mesh object pointer, and the flag whether we own it or not.
178 // if we own it, we must make sure to delete it when this Field is deleted.
179 void store_mesh(Mesh_t*, bool);
180
181 // delete the mesh object, if necessary; otherwise, just zero the pointer
183};
184
185#include "Field/Field.hpp"
186
187#endif
const unsigned Dim
void assign(const BareField< T, Dim > &a, RHS b, OP op, ExprTag< true >)
Definition: Field.h:33
bcond_iterator begin_BConds()
Definition: Field.h:106
Field(Layout_t &, const BConds< T, Dim, M, C > &, const GuardCellSizes< Dim > &)
virtual ~Field()
void initialize(Layout_t &)
Field(Mesh_t &, Layout_t &, const BConds< T, Dim, M, C > &)
const bcond_value & getBCond(int bc) const
Definition: Field.h:102
const Field< T, Dim, M, C > & operator=(const PETE_Expr< B > &x)
Definition: Field.h:140
Field(Mesh_t &, Layout_t &, const BConds< T, Dim, M, C > &, const GuardCellSizes< Dim > &)
const Field< T, Dim, M, C > & operator=(const Field< T, Dim, M, C > &x)
Definition: Field.h:128
virtual void notifyUserOfDelete(UserList *)
bool WeOwnMesh
Definition: Field.h:175
Field(Mesh_t &, Layout_t &, const GuardCellSizes< Dim > &, const BConds< T, Dim, M, C > &)
Field(Layout_t &, const GuardCellSizes< Dim > &)
void initialize(Layout_t &, const BConds< T, Dim, M, C > &)
IndexedField< T, Dim, 1, M, C > operator[](int)
BCondBase< T, Dim, M, C > bcond_value
Definition: Field.h:44
Field(Mesh_t &, Layout_t &)
SubField< T, Dim, M, C, SIndex< Dim > > operator[](const SIndex< Dim > &)
void fillGuardCells(bool reallyFill=true) const
void initialize(Mesh_t &, Layout_t &, const bool)
void initialize(Mesh_t &, Layout_t &, const GuardCellSizes< Dim > &)
void delete_mesh()
Field(Mesh_t &, FieldSpec< T, Dim, M, C > &)
Mesh_t & get_mesh() const
Definition: Field.h:110
BConds< T, Dim, M, C > bcond_container
Definition: Field.h:43
void store_mesh(Mesh_t *, bool)
const Field< T, Dim, M, C > & operator=(T x)
Definition: Field.h:123
bcond_container::iterator bcond_iterator
Definition: Field.h:45
bcond_container Bc
Definition: Field.h:171
bcond_value & getBCond(int bc)
Definition: Field.h:103
Field(Mesh_t &, Layout_t &, const GuardCellSizes< Dim > &)
void initialize(Mesh_t &, Layout_t &)
Field(Layout_t &)
void initialize(Mesh_t &, FieldSpec< T, Dim, M, C > &)
void initialize(Mesh_t &, Layout_t &, const GuardCellSizes< Dim > &, const BConds< T, Dim, M, C > &)
virtual void Repartition(UserList *)
bcond_iterator end_BConds()
Definition: Field.h:107
C Centering_t
Definition: Field.h:40
constexpr Field(Field< T, Dim, M, C > &)=default
void initialize(Layout_t &, const BConds< T, Dim, M, C > &, const GuardCellSizes< Dim > &)
Field(FieldSpec< T, Dim, M, C > &)
IndexedField< T, Dim, Dim, M, C > operator[](const NDIndex< Dim > &)
void initialize(Mesh_t &, Layout_t &, const BConds< T, Dim, M, C > &, const GuardCellSizes< Dim > &)
Mesh_t * mesh
Definition: Field.h:174
M Mesh_t
Definition: Field.h:39
Field(Layout_t &, const GuardCellSizes< Dim > &, const BConds< T, Dim, M, C > &)
const bcond_container & getBConds() const
Definition: Field.h:104
void initialize(Layout_t &, const GuardCellSizes< Dim > &, const BConds< T, Dim, M, C > &)
bcond_container & getBConds()
Definition: Field.h:105
void initialize(FieldSpec< T, Dim, M, C > &)
IndexedField< T, Dim, 1, M, C > operator[](const Index &)
void initialize(Layout_t &, const GuardCellSizes< Dim > &)
virtual DataSourceObject * createDataSourceObject(const char *, DataConnect *, int)
FieldLayout< Dim > Layout_t
Definition: Field.h:42
void print_Centerings(std::ostream &)
void initialize(Mesh_t &, Layout_t &, const BConds< T, Dim, M, C > &)
const Field< T, Dim, M, C > & operator=(const BareField< X, Dim > &x)
Definition: Field.h:134
BareField< T, Dim > Base_t
Definition: Field.h:41
Field(Layout_t &, const BConds< T, Dim, M, C > &)
vmap< int, RefCountedP< BCondBase< T, D, M, C > > >::iterator iterator
Definition: BCond.h:202
Definition: Index.h:237
Definition: SIndex.h:64
Definition: PETE.h:77
iterator end()
Definition: vmap.h:108
iterator begin()
Definition: vmap.h:107