ergo
grid_stream.h
Go to the documentation of this file.
1 /* Ergo, version 3.8, a program for linear scaling electronic structure
2  * calculations.
3  * Copyright (C) 2019 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek,
4  * and Anastasia Kruchinina.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * Primary academic reference:
20  * Ergo: An open-source program for linear-scaling electronic structure
21  * calculations,
22  * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia
23  * Kruchinina,
24  * SoftwareX 7, 107 (2018),
25  * <http://dx.doi.org/10.1016/j.softx.2018.03.005>
26  *
27  * For further information about Ergo, see <http://www.ergoscf.org>.
28  */
29 
32 #if !defined(_GRID_STREAM_H_)
33 #define _GRID_STREAM_H_ 1
34 
35 #include "sparse_matrix.h"
36 #include "grid_params.h"
37 
38 class ErgoGridStream;
39 
41  const GridGenMolInfo& molInfo);
42 
44  Dft::SparsePattern *pattern);
45 
46 unsigned grid_stream_generate(ErgoGridStream *stream, const char *fname,
47  int noOfThreads);
48 
49 void grid_stream_free(ErgoGridStream *stream);
50 
51 #endif /* _GRID_STREAM_H_ */
52 
template_blas_sqrt
Treal template_blas_sqrt(Treal x)
StreamSaveContext::shlBlocks
int(* shlBlocks)[2]
Definition: grid_stream.cc:464
Stream
Streamlined, abstract grid generation class.
Definition: grid_stream.cc:481
lebedev_laikov.h
Box::size
real size(int dim) const
Definition: dft_common.h:141
Box::contains
bool contains(const real *p) const
Determines whether given point is inside the box.
Definition: dft_common.h:152
Vector3D
A representation of Vector or point in cartesian space.
Definition: molecule.h:60
Stream::~Stream
~Stream()
Definition: grid_stream.cc:950
sparse_matrix.h
realtype.h
Definition of the main floating-point datatype used; the ergo_real type.
BoxPartitioner::atomFactors
real * atomFactors
a triangular array
Definition: grid_stream.cc:176
RadialGrid::setAngularFixed
void setAngularFixed(int minAng, int maxAng)
Definition: grid_stream.cc:103
Stream::atomTypes
std::vector< RadialGrid * > atomTypes
We store just one entry per atom type - there is no reason to have thousands identical copies.
Definition: grid_stream.cc:517
GridGenMolInfo::getAtom
virtual void getAtom(int icent, int *cnt, real(*coor)[3], int *charge, int *mult) const =0
grid_stream_set_sparse_pattern
void grid_stream_set_sparse_pattern(ErgoGridStream *stream, Dft::SparsePattern *pattern)
Definition: grid_stream.cc:1020
RadialGrid::getPointCount
unsigned getPointCount() const
Definition: grid_stream.cc:86
dft_common.h
Common DFT routines. Mostly functional mixing.
ThreadInfo::res
bool res
Definition: grid_stream.cc:836
StreamSaveContext::StreamSaveContext
StreamSaveContext(FILE *f, BoxPartitioner &p, unsigned maxShells, unsigned rank)
Definition: grid_stream.cc:469
ThreadInfo::f
FILE * f
Definition: grid_stream.cc:830
Stream::saveThread
static void * saveThread(void *data)
Definition: grid_stream.cc:839
ActiveBfShells::~ActiveBfShells
~ActiveBfShells()
Definition: grid_stream.cc:433
ActiveBfShells::ggmi
const GridGenMolInfo & ggmi
Definition: grid_stream.cc:422
RadialGrid::RadialGrid
RadialGrid(int charge_, RadialScheme *rs, int angMin, int angMax)
Definition: grid_stream.cc:132
LOG_CAT_ERROR
#define LOG_CAT_ERROR
Definition: output.h:47
ThreadInfo::stream
const Stream * stream
Definition: grid_stream.cc:829
AtomicGrid::radius
real radius() const
Returns "radius" of an atomic grid.
Definition: grid_stream.cc:150
ergo_real
double ergo_real
Definition: realtype.h:69
BoxPartitioner::rj
real * rj
Definition: grid_stream.cc:172
ErgoGridStream::ergoShells
Grid::ActiveBfShells ergoShells
Definition: grid_stream.cc:974
BoxPartitioner::vec
long_real * vec
Definition: grid_stream.cc:174
BoxPartitioner::maxPointCnt
unsigned maxPointCnt
Definition: grid_stream.cc:180
AtomicGrid
Definition: grid_stream.cc:143
END_NAMESPACE
#define END_NAMESPACE(x)
Definition: sparse_pattern.h:42
AtomicGrid::getRadialGrid
const RadialGrid & getRadialGrid() const
Definition: grid_stream.cc:147
Box::getDistanceTo
real getDistanceTo(const real *v) const
Returns the shortest distance of the border of the box to the specified point in space.
Definition: dft_common.cc:90
WEIGHT_THRESHOLD
static const real WEIGHT_THRESHOLD
Ignore all grid points that partitioning scales down by more than WEIGHT_THRESHOLD.
Definition: grid_stream.cc:72
RadialGrid::rad
real * rad
Array of radial grid points.
Definition: grid_stream.cc:78
Stream::activeShells
ActiveBfShells & activeShells
Definition: grid_stream.cc:519
ThreadInfo::box
const Box * box
Definition: grid_stream.cc:831
Dft::GridParams::radialGridScheme
RadialScheme radialGridScheme
Definition: grid_params.h:69
ActiveBfShells::ActiveBfShells
ActiveBfShells(const GridGenMolInfo &ggmi_)
Definition: grid_stream.cc:425
Stream::saveBatch
unsigned saveBatch(unsigned batchLength, real(*coor)[3], real *weight, unsigned nBlocks, int(*shlBlocks)[2], FILE *f) const
Saves a batch of grid points to given file.
Definition: grid_stream.cc:576
Box::overlapsWith
bool overlapsWith(const real *center, real radius) const
Definition: dft_common.h:143
real
ergo_real real
Definition: test.cc:46
real
ergo_real real
Definition: grid_stream.cc:66
Atom
Simple atom representation by its charge and cartesian coordinates.
Definition: molecule.h:51
Stream::getAtomicGrid
const AtomicGrid & getAtomicGrid(unsigned i) const
Definition: grid_stream.cc:533
BoxPartitioner::getFactor
real getFactor(int i, int j) const
Definition: grid_stream.cc:196
ThreadInfo::myRank
unsigned myRank
Definition: grid_stream.cc:834
grid_stream_new
ErgoGridStream * grid_stream_new(const struct Dft::GridParams &ggs, const GridGenMolInfo &molInfo)
Creates the grid object.
Definition: grid_stream.cc:999
Dft::GridParams::angmax
int angmax
Definition: grid_params.h:66
Box::lo
real lo[3]
Definition: dft_common.h:167
charge
int charge
Definition: grid_test.cc:51
RadialGrid::nAngular
int * nAngular
array of sizes of corresponding angular grids.
Definition: grid_stream.cc:80
Dft::GridParams::radint
ergo_real radint
Definition: grid_params.h:64
Dft::GridParams::GC2
@ GC2
Definition: grid_params.h:67
RadialSchemeGC2
Definition: grid_atomic.h:60
RadialSchemeLMG
Definition: grid_atomic.h:76
ll_sphere
int ll_sphere(int N, real *X, real *Y, real *Z, real *W)
ll_sphere fills in arrays X, Y, Z and W with the cartesian coordinates and weights of the grid points...
Definition: lebedev_laikov.cc:317
grid_stream_generate
unsigned grid_stream_generate(ErgoGridStream *stream, const char *fname, int noOfThreads)
Generate grid for given molecule.
Definition: grid_stream.cc:1033
Stream::addAtom
void addAtom(const Atom &at, int atomNo)
Definition: grid_stream.cc:504
Stream::angularMax
int angularMax
Definition: grid_stream.cc:522
Box::getMaxDim
int getMaxDim() const
Return the index of the largest Cartesian dimension: 0 for x, 1 for y and 2 for z.
Definition: dft_common.cc:111
RadialGrid
A grid describing a radial grid for an atom with a specific charge.
Definition: grid_stream.cc:76
StreamSaveContext::stream
FILE * stream
Definition: grid_stream.cc:463
ll_order
int ll_order(int npoint)
ll_order returns order of the smallest angular grid that has at least that many grid points as specif...
Definition: lebedev_laikov.cc:118
Dft::GridParams
A structure describing the grid settings.
Definition: grid_params.h:59
Stream::noOfAtoms
unsigned noOfAtoms() const
Definition: grid_stream.cc:539
StreamSaveContext
Saves the grid saving context.
Definition: grid_stream.cc:462
Stream::radialScheme
RadialScheme * radialScheme
Definition: grid_stream.cc:520
Stream::atoms
std::vector< AtomicGrid > atoms
Definition: grid_stream.cc:518
BoxPartitioner::maxRelevantAtoms
unsigned maxRelevantAtoms
Definition: grid_stream.cc:182
GridGenMolInfo::noOfShells
int noOfShells
Definition: grid_interface.h:49
RadialGrid::getCharge
int getCharge() const
Definition: grid_stream.cc:84
RadialScheme::init
virtual void init(int myNumber, int charge, real threshold)=0
StreamSaveContext::boxCount
unsigned boxCount
Definition: grid_stream.cc:467
ThreadInfo::atoms
const unsigned * atoms
Definition: grid_stream.cc:833
grid_stream.h
Streaming grid generator.
BoxPartitioner::invAtomDistances
real * invAtomDistances
a triangular array
Definition: grid_stream.cc:175
AtomicGrid::charge
int charge() const
Definition: grid_stream.cc:153
StreamSaveContext::savedPoints
unsigned savedPoints
Definition: grid_stream.cc:466
BraggRadii
const real BraggRadii[]
vector of atoms' Bragg radii.
Definition: grid_atomic.cc:39
BoxPartitioner::process
unsigned process(unsigned atomNumber, const std::vector< AtomicGrid > &atomGrids, int noOfRelevantAtoms, const unsigned *relevantAtoms, unsigned batchLength, real(*coor)[3], real *w)
Applies the partitioning factors to the the grid points associated with given atom.
Definition: grid_stream.cc:345
RadialGrid::weights
real * weights
Array of the weights associated with the grid points.
Definition: grid_stream.cc:79
grid_atomic.h
Stream::saveAtomsRecursively
bool saveAtomsRecursively(StreamSaveContext &ssc, const Box &box, unsigned cnt, const unsigned atoms[], int depth) const
This is a recursive procedure that generates the grid points that lie in the specified bounding box.
Definition: grid_stream.cc:735
GridGenMolInfo::getBlocks
virtual void getBlocks(const real *center, real cellsz, const real *rshell, int *nblcnt, int(*iblcks)[2]) const =0
Stream::expectedPoints
unsigned expectedPoints
Definition: grid_stream.cc:525
Box
Class Box provides an ability to determine box containing all Objects.
Definition: dft_common.h:137
AtomicGrid::AtomicGrid
AtomicGrid(const Atom &atom, const RadialGrid *rg)
Definition: grid_stream.cc:162
Dft::GridParams::LMG
@ LMG
Definition: grid_params.h:67
GridGenMolInfo::noOfAtoms
int noOfAtoms
Definition: grid_interface.h:47
Util::TimeMeter::print
void print(int area, const char *routine)
Definition: utilities.h:111
RadialGrid::charge
int charge
Definition: grid_stream.cc:98
getBoundingBox
void getBoundingBox(Box &box, Iterator start, Iterator end)
Definition: dft_common.h:172
Vector3D::v
ergo_real v[3]
Definition: molecule.h:61
BoxPartitioner::p_kg
long_real * p_kg
Definition: grid_stream.cc:173
AtomicGrid::getPointCount
unsigned getPointCount() const
Definition: grid_stream.cc:154
RadialScheme::gridSize
int gridSize
Definition: grid_atomic.h:52
utilities.h
Basic OS access utilities.
ThreadInfo::atomCnt
unsigned atomCnt
Definition: grid_stream.cc:832
ActiveBfShells::getMaxShells
int getMaxShells() const
Definition: grid_stream.cc:430
ThreadInfo
Definition: grid_stream.cc:827
LOG_CAT_INFO
#define LOG_CAT_INFO
Definition: output.h:49
StreamSaveContext::myRank
unsigned myRank
Definition: grid_stream.cc:468
BoxPartitioner::maxAtomPointCnt
unsigned maxAtomPointCnt
Definition: grid_stream.cc:181
Stream::fileSaveMutex
static pthread_mutex_t fileSaveMutex
Definition: grid_stream.cc:514
AtomicGrid::rGrid
const RadialGrid * rGrid
Definition: grid_stream.cc:144
BoxPartitioner::prepare
void prepare(const std::vector< AtomicGrid > &atoms, unsigned noOfRelevantAtoms, const unsigned *relevantAtoms, unsigned pointCnt, const real(*gridPoints)[3])
Definition: grid_stream.cc:250
grid_stream_generate
unsigned grid_stream_generate(ErgoGridStream *stream, const char *fname, int noOfThreads)
Generate grid for given molecule.
Definition: grid_stream.cc:1033
ThreadInfo::tid
pthread_t tid
Definition: grid_stream.cc:828
Dft::GridParams::TURBO
@ TURBO
Definition: grid_params.h:67
long_real
ergo_long_real long_real
Definition: grid_atomic.h:43
grid_params.h
Code organizing various settings related to grids used for numerical integration.
GridGenMolInfo::setShellRadii
virtual void setShellRadii(real *shellRadii) const =0
BoxPartitioner
"Block" partitioning is the only one implemented now...
Definition: grid_stream.cc:170
RadialScheme::generate
virtual void generate(real *r, real *w)=0
Stream::forceCubic
bool forceCubic
Definition: grid_stream.cc:492
ActiveBfShells::setForBox
void setForBox(const Box &b, int *nBlocks, int(*shlBlocks)[2]) const
the start and stop+1 indexes.
Definition: grid_stream.cc:449
BoxPartitioner::apasc
real apasc
Definition: grid_stream.cc:178
grid_stream_free
void grid_stream_free(ErgoGridStream *stream)
Definition: grid_stream.cc:1064
BoxPartitioner::HARDNESS
static const int HARDNESS
Definition: grid_stream.cc:177
Stream::Stream
Stream(ActiveBfShells &abs, RadialScheme *rs, real radint, int angmin, int angmax, real boxSize, bool forceCubic)
The Stream constructor.
Definition: grid_stream.cc:940
Stream::sparsePattern
Dft::SparsePattern * sparsePattern
Definition: grid_stream.cc:490
BraggSize
const unsigned BraggSize
Number of defined elements in BraggRadii array.
Definition: grid_atomic.cc:75
BoxPartitioner::~BoxPartitioner
~BoxPartitioner()
Definition: grid_stream.cc:239
Stream::noOfThreads
int noOfThreads
Definition: grid_stream.cc:526
ActiveBfShells
A class that is able to quickly determine the active shells that overlap with given box in space.
Definition: grid_stream.cc:421
ActiveBfShells::getNoOfShells
static int getNoOfShells(int nBlocks, int(*shlBlocks)[2])
Definition: grid_stream.cc:439
Box::hi
real hi[3]
Definition: dft_common.h:168
Atom::charge
ergo_real charge
Definition: molecule.h:52
BoxPartitioner::BoxPartitioner
BoxPartitioner()
Initializez the BoxPartitioner object.
Definition: grid_stream.cc:215
molecule.h
Class representing a molecule as a set of atoms with assiciated coordinates and charges of the atomic...
grid_stream_new
ErgoGridStream * grid_stream_new(const struct Dft::GridParams &gss, const GridGenMolInfo &molInfo)
Creates the grid object.
Definition: grid_stream.cc:999
RadialScheme
RadialScheme describes the radial grid.
Definition: grid_atomic.h:50
ll_npoint
int ll_npoint(int lvalue)
ll_npoint returns number of angular grid points for given L-angular polynomial integration accuracy.
Definition: lebedev_laikov.cc:51
ActiveBfShells::rShell2
real * rShell2
Definition: grid_stream.cc:423
Stream::addAtom
void addAtom(const real coor[3], int charge, int atomNo)
Definition: grid_stream.cc:545
AtomicGrid::AtomicGrid
AtomicGrid(const AtomicGrid &a)
Definition: grid_stream.cc:156
StreamSaveContext::~StreamSaveContext
~StreamSaveContext()
Definition: grid_stream.cc:473
RadialGrid::~RadialGrid
~RadialGrid()
Definition: grid_stream.cc:92
ErgoGridStream
Ergo-specific GridStream implementation.
Definition: grid_stream.cc:973
BoxPartitioner::getInvDistanceBetweenAtoms
real getInvDistanceBetweenAtoms(int i, int j) const
return distance between given pair of relevant atoms.
Definition: grid_stream.cc:191
ErgoGridStream::gsSettings
const Dft::GridParams & gsSettings
Definition: grid_stream.cc:976
Stream::getPointCount
unsigned getPointCount() const
Definition: grid_stream.cc:489
Stream::savedPoints
unsigned savedPoints
Definition: grid_stream.cc:524
RadialSchemeTurbo
Definition: grid_atomic.h:68
Stream::angularMin
int angularMin
Definition: grid_stream.cc:522
BoxPartitioner::xpasc
real xpasc[HARDNESS]
Definition: grid_stream.cc:178
AtomicGrid::center
Vector3D center
Definition: grid_stream.cc:146
Stream::radialThreshold
real radialThreshold
Definition: grid_stream.cc:521
Atom::coords
ergo_real coords[3]
Definition: molecule.h:53
Stream::boxSize
real boxSize
Definition: grid_stream.cc:483
grid_stream_set_sparse_pattern
void grid_stream_set_sparse_pattern(ErgoGridStream *stream, Dft::SparsePattern *pattern)
Definition: grid_stream.cc:1020
GridGenMolInfo
GridGenMolInfo is an abstract class providing information about the molecule so that the grid generat...
Definition: grid_interface.h:45
RadialGrid::noOfRadPoints
int noOfRadPoints
Definition: grid_stream.cc:81
do_output
void do_output(int logCategory, int logArea, const char *format,...)
Definition: output.cc:53
Dft::GridParams::angmin
int angmin
Definition: grid_params.h:65
StreamSaveContext::partitioner
BoxPartitioner & partitioner
Definition: grid_stream.cc:465
grid_stream_free
void grid_stream_free(ErgoGridStream *stream)
Definition: grid_stream.cc:1064
RadialGrid::getRadius
real getRadius() const
Definition: grid_stream.cc:85
BoxPartitioner::coor
const real(* coor)[3]
Definition: grid_stream.cc:171
Stream::saveToFile
bool saveToFile(const char *fname, int noOfThreads)
Generates the grid and saves it to the file with given name.
Definition: grid_stream.cc:874
ErgoGridStream::ErgoGridStream
ErgoGridStream(const Dft::GridParams &gss, const GridGenMolInfo &molInfo, RadialScheme *rs)
Definition: grid_stream.cc:981
LOG_AREA_DFT
#define LOG_AREA_DFT
Definition: output.h:62
AtomicGrid::AtomicGrid
AtomicGrid(const real c[3], const RadialGrid *rg)
Definition: grid_stream.cc:159
Util::TimeMeter
Time-measuring class.
Definition: utilities.h:80
output.h
Functionality for writing output messages to a text file.
BoxPartitioner::LDA
int LDA
Definition: grid_stream.cc:183
Stream::saveAtomGridInBox
unsigned saveAtomGridInBox(unsigned iAtom, const Box &box, BoxPartitioner &partitioner, unsigned cnt, const unsigned atoms[], int(*shlBlocks)[2], FILE *stream) const
Method saves all grid points associated with specified atom, located in the specified box.
Definition: grid_stream.cc:607
BEGIN_NAMESPACE
#define BEGIN_NAMESPACE(x)
Definition: sparse_pattern.h:41
ThreadInfo::savedPoints
unsigned savedPoints
Definition: grid_stream.cc:835