PSCF v1.1
DField.h
1#ifndef PSPG_DFIELD_H
2#define PSPG_DFIELD_H
3
4/*
5* PSCF Package
6*
7* Copyright 2016 - 2022, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <util/global.h>
12
13namespace Pscf {
14namespace Pspg
15{
16
17 using namespace Util;
18
28 template <typename Data>
29 class DField
30 {
31
32 public:
33
37 DField();
38
44 virtual ~DField();
45
53 void allocate(int capacity);
54
60 void deallocate();
61
65 bool isAllocated() const;
66
72 int capacity() const;
73
77 Data* cDField();
78
82 const Data* cDField() const;
83
89 virtual DField<Data>& operator = (const DField<Data>& other);
90
96 DField(const DField& other);
97
98 protected:
99
101 Data* data_;
102
105
106 };
107
108 /*
109 * Return allocated size.
110 */
111 template <typename Data>
112 inline int DField<Data>::capacity() const
113 { return capacity_; }
114
115 /*
116 * Get a pointer to the underlying C array.
117 */
118 template <typename Data>
120 { return data_; }
121
122 /*
123 * Get a pointer to const to the underlying C array.
124 */
125 template <typename Data>
126 inline const Data* DField<Data>::cDField() const
127 { return data_; }
128
129 /*
130 * Return true if the Field has been allocated, false otherwise.
131 */
132 template <typename Data>
133 inline bool DField<Data>::isAllocated() const
134 { return (bool)data_; }
135
136}
137}
138#include "DField.tpp"
139#endif
Dynamic array on the GPU with alligned data.
Definition: DField.h:30
virtual DField< Data > & operator=(const DField< Data > &other)
Assignment operator.
Definition: DField.tpp:110
Data * cDField()
Return pointer to underlying C array.
Definition: DField.h:119
void allocate(int capacity)
Allocate the underlying C array on the device.
Definition: DField.tpp:52
int capacity_
Allocated size of the data_ array.
Definition: DField.h:104
void deallocate()
Dellocate the underlying C array.
Definition: DField.tpp:70
Data * data_
Pointer to an array of Data elements on the device / GPU.
Definition: DField.h:101
virtual ~DField()
Destructor.
Definition: DField.tpp:36
DField()
Default constructor.
Definition: DField.tpp:27
const Data * cDField() const
Return pointer to const to underlying C array.
Definition: DField.h:126
int capacity() const
Return allocated size.
Definition: DField.h:112
bool isAllocated() const
Return true if the Field has been allocated, false otherwise.
Definition: DField.h:133
File containing preprocessor macros for error handling.
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
Definition: accumulators.mod:1