20 #ifndef JDFTX_CORE_SCALARFIELD_H 21 #define JDFTX_CORE_SCALARFIELD_H 32 #include <core/scalar.h> 34 #include <core/ManagedMemory.h> 35 #include <electronic/matrix.h> 44 typedef std::shared_ptr<ScalarFieldData>
ScalarField;
51 #define DECLARE_DATA_PREF_ACCESS \ 52 DataType* dataPref(bool shouldAbsorbScale=true) { return dataGpu(shouldAbsorbScale); } \ 53 const DataType* dataPref(bool shouldAbsorbScale=true) const { return dataGpu(shouldAbsorbScale); } 55 #define DECLARE_DATA_PREF_ACCESS \ 56 DataType* dataPref(bool shouldAbsorbScale=true) { return data(shouldAbsorbScale); } \ 57 const DataType* dataPref(bool shouldAbsorbScale=true) const { return data(shouldAbsorbScale); } 72 void*
data(
bool shouldAbsorbScale=
true);
73 const void*
data(
bool shouldAbsorbScale=
true)
const;
75 void*
dataGpu(
bool shouldAbsorbScale=
true);
76 const void*
dataGpu(
bool shouldAbsorbScale=
true)
const;
79 DECLARE_DATA_PREF_ACCESS
83 FieldData(
const GridInfo& gInfo,
string category,
int nElem,
int nDoublesPerElem=1,
bool onGpu=
false);
100 #define DECLARE_DATA_ACCESS \ 101 DataType* data(bool shouldAbsorbScale=true) { return (DataType*)FieldData::data(shouldAbsorbScale); } \ 102 const DataType* data(bool shouldAbsorbScale=true) const { return (const DataType*)FieldData::data(shouldAbsorbScale); } \ 103 DataType* dataGpu(bool shouldAbsorbScale=true) { return (DataType*)FieldData::dataGpu(shouldAbsorbScale); } \ 104 const DataType* dataGpu(bool shouldAbsorbScale=true) const { return (const DataType*)FieldData::dataGpu(shouldAbsorbScale); } 106 #define DECLARE_DATA_ACCESS \ 107 DataType* data(bool shouldAbsorbScale=true) { return (DataType*)FieldData::data(shouldAbsorbScale); } \ 108 const DataType* data(bool shouldAbsorbScale=true) const { return (const DataType*)FieldData::data(shouldAbsorbScale); } 120 DECLARE_DATA_PREF_ACCESS
137 DECLARE_DATA_PREF_ACCESS
155 DECLARE_DATA_PREF_ACCESS
171 DECLARE_DATA_PREF_ACCESS
194 #undef DECLARE_DATA_PREF_ACCESS 195 #undef DECLARE_DATA_ACCESS 198 #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:134
Reciprocal space complex scalar field data Do not use this data structure directly or from a simple p...
Definition: ScalarField.h:168
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:68
General complex matrix.
Definition: matrix.h:58
std::shared_ptr< ScalarFieldTildeData > ScalarFieldTilde
A smart reference-counting pointer to ScalarFieldTildeData.
Definition: ScalarField.h:45
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:93
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:153
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:47
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:118
void allReduce(MPIUtil::ReduceOp op, bool safeMode=false)
apply all-to-all reduction
Definition: ScalarField.h:90
complex DataType
Type of data in container (useful for templating)
Definition: ScalarField.h:135
void copyData(const FieldData &other)
copy data and scale (used by clone())
int nElem
number of elements = gInfo.nG
Definition: ScalarField.h:182
void send(int dest, int tag=0) const
send to another process
Definition: ScalarField.h:87
DECLARE_DATA_PREF_ACCESS bool isOnGpu() const
Check where the data is (for #ifdef simplicity exposed even when no GPU_ENABLED)
Definition: ScalarField.h:81
double * data
cpu data pointer
Definition: ScalarField.h:183
double scale
overall scale factor of the data array
Definition: ScalarField.h:64
std::shared_ptr< complexScalarFieldData > complexScalarField
A smart reference-counting pointer to complexScalarFieldData.
Definition: ScalarField.h:46
void zero()
set all elements to zero
Base class for ScalarFieldData and ScalarFieldTildeData.
Definition: ScalarField.h:61
void recv(int src, int tag=0)
receive from another process
Definition: ScalarField.h:88
void DataType
this base class has no specific data type
Definition: ScalarField.h:70
Real space complex scalar field data Do not use this data structure directly or from a simple pointer...
Definition: ScalarField.h:152
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:180
int nElem
number of elements = #gInfo.nr
Definition: ScalarField.h:63
std::shared_ptr< ScalarFieldData > ScalarField
A smart reference-counting pointer to ScalarFieldData.
Definition: ScalarField.h:41
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:169
void bcast(int root=0)
synchronize across processes (using value on specified root process)
Definition: ScalarField.h:89
double * dataGpu
gpu data pointer (unlike above classes, both cpu and gpu stored simultaneously)
Definition: ScalarField.h:185
Real space real scalar field data Do not use this data structure directly or from a simple pointer Sc...
Definition: ScalarField.h:117
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:187
const GridInfo & gInfo
simulation grid info
Definition: ScalarField.h:65