20 #ifndef JDFTX_CORE_SCALARFIELD_H 21 #define JDFTX_CORE_SCALARFIELD_H 32 #include <core/scalar.h> 34 #include <core/ManagedMemory.h> 43 typedef std::shared_ptr<ScalarFieldData>
ScalarField;
50 #define DECLARE_DATA_PREF_ACCESS \ 51 DataType* dataPref(bool shouldAbsorbScale=true) { return dataGpu(shouldAbsorbScale); } \ 52 const DataType* dataPref(bool shouldAbsorbScale=true) const { return dataGpu(shouldAbsorbScale); } 54 #define DECLARE_DATA_PREF_ACCESS \ 55 DataType* dataPref(bool shouldAbsorbScale=true) { return data(shouldAbsorbScale); } \ 56 const DataType* dataPref(bool shouldAbsorbScale=true) const { return data(shouldAbsorbScale); } 71 void*
data(
bool shouldAbsorbScale=
true);
72 const void*
data(
bool shouldAbsorbScale=
true)
const;
74 void*
dataGpu(
bool shouldAbsorbScale=
true);
75 const void*
dataGpu(
bool shouldAbsorbScale=
true)
const;
78 DECLARE_DATA_PREF_ACCESS
82 FieldData(
const GridInfo& gInfo,
string category,
int nElem,
int nDoublesPerElem=1,
bool onGpu=
false);
99 #define DECLARE_DATA_ACCESS \ 100 DataType* data(bool shouldAbsorbScale=true) { return (DataType*)FieldData::data(shouldAbsorbScale); } \ 101 const DataType* data(bool shouldAbsorbScale=true) const { return (const DataType*)FieldData::data(shouldAbsorbScale); } \ 102 DataType* dataGpu(bool shouldAbsorbScale=true) { return (DataType*)FieldData::dataGpu(shouldAbsorbScale); } \ 103 const DataType* dataGpu(bool shouldAbsorbScale=true) const { return (const DataType*)FieldData::dataGpu(shouldAbsorbScale); } 105 #define DECLARE_DATA_ACCESS \ 106 DataType* data(bool shouldAbsorbScale=true) { return (DataType*)FieldData::data(shouldAbsorbScale); } \ 107 const DataType* data(bool shouldAbsorbScale=true) const { return (const DataType*)FieldData::data(shouldAbsorbScale); } 119 DECLARE_DATA_PREF_ACCESS
135 DECLARE_DATA_PREF_ACCESS
153 DECLARE_DATA_PREF_ACCESS
168 DECLARE_DATA_PREF_ACCESS
191 #undef DECLARE_DATA_PREF_ACCESS 192 #undef DECLARE_DATA_ACCESS 195 #endif //JDFTX_CORE_SCALARFIELD_H Reciprocal space real scalar field data Do not use this data structure directly or from a simple poin...
Definition: ScalarField.h:132
Reciprocal space complex scalar field data Do not use this data structure directly or from a simple p...
Definition: ScalarField.h:165
void allReduce(MPIUtil::ReduceOp op, bool safeMode=false, bool ignoreComplexCheck=false)
apply all-to-all reduction (see MPIUtil::allReduce). Optionally ignore unsupported operations for com...
Simulation grid descriptor.
Definition: GridInfo.h:45
void send(int dest, int tag=0) const
send to another process
void zero()
initialize to zero
Definition: ScalarField.h:67
std::shared_ptr< ScalarFieldTildeData > ScalarFieldTilde
A smart reference-counting pointer to ScalarFieldTildeData.
Definition: ScalarField.h:44
Base class for managed-memory objects (that could potentially live on GPUs as well) ...
Definition: ManagedMemory.h:26
void setGzero(const VectorFieldTilde &X, vector3<> v)
set G=0 components
Definition: VectorField.h:158
void absorbScale() const
absorb scale factor into data
Used to prevent direct use of ScalarField constructors, and force the shared_ptr usage.
Definition: ScalarField.h:92
complex * dataGpu()
Get a gpu data pointer (must be called from GPU owner thread)
vector3 getGzero(const VectorFieldTilde &X)
return G=0 components
Definition: VectorField.h:157
complex DataType
Type of data in container (useful for templating)
Definition: ScalarField.h:151
bool isOnGpu() const
Check where the data is (for #ifdef simplicity exposed even when no GPU_ENABLED)
Definition: ManagedMemory.h:46
std::shared_ptr< complexScalarFieldTildeData > complexScalarFieldTilde
A smart reference-counting pointer to complexScalarFieldTildeData.
Definition: ScalarField.h:46
Tptr clone(const Tptr &X)
Clone (NOTE: operator= is by reference for the ScalarField classes)
Definition: Operators.h:111
double DataType
Type of data in container (useful for templating)
Definition: ScalarField.h:117
void allReduce(MPIUtil::ReduceOp op, bool safeMode=false)
apply all-to-all reduction
Definition: ScalarField.h:89
complex DataType
Type of data in container (useful for templating)
Definition: ScalarField.h:133
void copyData(const FieldData &other)
copy data and scale (used by clone())
int nElem
number of elements = gInfo.nG
Definition: ScalarField.h:179
void send(int dest, int tag=0) const
send to another process
Definition: ScalarField.h:86
DECLARE_DATA_PREF_ACCESS bool isOnGpu() const
Check where the data is (for #ifdef simplicity exposed even when no GPU_ENABLED)
Definition: ScalarField.h:80
double * data
cpu data pointer
Definition: ScalarField.h:180
double scale
overall scale factor of the data array
Definition: ScalarField.h:63
std::shared_ptr< complexScalarFieldData > complexScalarField
A smart reference-counting pointer to complexScalarFieldData.
Definition: ScalarField.h:45
void zero()
set all elements to zero
Base class for ScalarFieldData and ScalarFieldTildeData.
Definition: ScalarField.h:60
void recv(int src, int tag=0)
receive from another process
Definition: ScalarField.h:87
void DataType
this base class has no specific data type
Definition: ScalarField.h:69
Real space complex scalar field data Do not use this data structure directly or from a simple pointer...
Definition: ScalarField.h:150
complex * data()
Return a pointer to the actual data Return a CPU pointer to the actual data, will move data from GPU ...
Special class for storing real reciprocal-space kernels encountered ever so often for convolutions...
Definition: ScalarField.h:177
int nElem
number of elements = #gInfo.nr
Definition: ScalarField.h:62
std::shared_ptr< ScalarFieldData > ScalarField
A smart reference-counting pointer to ScalarFieldData.
Definition: ScalarField.h:40
void bcast(int root=0)
synchronize across processes (using value on specified root process)
Complex number (need to define our own because we need operators for gpu code as well) ...
Definition: scalar.h:49
complex DataType
Type of data in container (useful for templating)
Definition: ScalarField.h:166
void bcast(int root=0)
synchronize across processes (using value on specified root process)
Definition: ScalarField.h:88
double * dataGpu
gpu data pointer (unlike above classes, both cpu and gpu stored simultaneously)
Definition: ScalarField.h:182
Real space real scalar field data Do not use this data structure directly or from a simple pointer Sc...
Definition: ScalarField.h:116
void recv(int src, int tag=0)
receive from another process
double * dataPref
points to data or dataGpu depending on GPU_ENABLED
Definition: ScalarField.h:184
const GridInfo & gInfo
simulation grid info
Definition: ScalarField.h:64