MPQC  3.0.0-alpha
grid.h
1 //
2 // grid.h
3 //
4 // Copyright (C) 2006 Toon Verstraelen.
5 //
6 // Author: Toon Verstraelen
7 //
8 // This file is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2, or (at your option)
11 // any later version.
12 //
13 // This file is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with the MPQC; see the file COPYING. If not, write to
20 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 //
22 
23 #ifndef _util_misc_grid_h
24 #define _util_misc_grid_h
25 
26 #include <chemistry/molecule/molecule.h>
27 #include <util/class/class.h>
28 #include <util/misc/runnable.h>
29 #include <util/misc/units.h>
30 
31 namespace sc {
32 
35 class Grid: public DescribedClass {
36  public:
37  int numx;
38  int numy;
39  int numz;
40  SCVector3 origin;
41  SCVector3 axisx;
42  SCVector3 axisy;
43  SCVector3 axisz;
44  Ref<Units> unit;
73  Grid(const Ref<KeyVal> &);
74  Grid(int numx = 1, int numy = 1, int numz = 1,
75  SCVector3 origin = SCVector3(0.0, 0.0, 0.0),
76  SCVector3 axisx = SCVector3(1.0, 0.0, 0.0),
77  SCVector3 axisy = SCVector3(0.0, 1.0, 0.0),
78  SCVector3 axisz = SCVector3(0.0, 0.0, 1.0),
79  Ref<Units> unit = new Units("bohr")
80  );
81 };
82 
85 class WriteGrid: public Runnable {
86  private:
87  void wf_mpqc(std::ostream &out);
88  void wf_gaussian_cube(std::ostream &out);
89  void wf_vtk2(std::ostream &out);
90  void wf_mpqc_raw(std::ostream &out);
91  protected:
92  std::string filename_;
93  Ref<Grid> grid_;
94  std::string format_;
95  void (WriteGrid::*write_format_)(std::ostream &out);
98  virtual void initialize() = 0;
103  virtual void label(char* buffer) = 0;
105  virtual Ref<Molecule> get_molecule() = 0;
107  virtual double calculate_value(SCVector3 point) = 0;
108  public:
132  WriteGrid(const Ref<KeyVal> &);
134  void run();
135 };
136 
142 #ifdef MPQC_NEW_FEATURES
143 , virtual public DescribedXMLWritable
144 #endif // MPQC_NEW_FEATURES
145 {
146  public:
147  // see wf_gaussian_cube
148  struct DimensionMap {
149  virtual int operator()(int d) const {
150  return d;
151  }
152  };
153 
154  private:
160  void wf_gaussian_cube(std::ostream &out, const DimensionMap& dmap);
161  protected:
162  std::string filename_;
163  Ref<Grid> grid_;
164  std::string format_;
165  void (WriteVectorGrid::*write_format_)(std::ostream &out, const DimensionMap& dmap);
166 
169  virtual void initialize() = 0;
174  virtual void label(char* buffer) = 0;
176  virtual Ref<Molecule> get_molecule() = 0;
178  virtual void calculate_values(const std::vector<SCVector3>& Points, std::vector<double>& Vals)=0;
180  virtual std::size_t ndim() const =0;
182  virtual const DimensionMap& dimension_map() const =0;
183  public:
202  WriteVectorGrid(const Ref<KeyVal> &);
203  WriteVectorGrid(const Ref<sc::Grid> & grid,
204  std::string gridformat, std::string gridfile);
206  void run();
207 
208 #ifdef MPQC_NEW_FEATURES
209  virtual boost::property_tree::ptree& write_xml(boost::property_tree::ptree& parent, const XMLWriter& writer);
210 #endif
211 };
212 
213 }
214 
215 #endif
216 
217 // Local Variables:
218 // mode: c++
219 // c-file-style: "CLJ"
220 // End:
sc::WriteGrid::get_molecule
virtual Ref< Molecule > get_molecule()=0
Returns the molecule around which the grid values are calculated.
sc::WriteGrid::calculate_value
virtual double calculate_value(SCVector3 point)=0
Returns the value of the scalar function at the given coordinate.
sc::WriteVectorGrid::calculate_values
virtual void calculate_values(const std::vector< SCVector3 > &Points, std::vector< double > &Vals)=0
Returns the value of the vector function at the given coordinate.
sc::WriteVectorGrid
WriteVectorGrid provides an interface for writing the value of a vector function evaluated at a given...
Definition: grid.h:141
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::WriteVectorGrid::DimensionMap
Definition: grid.h:148
sc::WriteVectorGrid::initialize
virtual void initialize()=0
Prepares some pre-calculated values before the repetitive grid calculations are perfomed.
sc::WriteGrid::initialize
virtual void initialize()=0
Prepares some pre-caculated values before the repetitive grid calculations are perfomed.
sc::WriteVectorGrid::run
void run()
Writes the grid data.
sc::WriteGrid::label
virtual void label(char *buffer)=0
A label that identifies the scalar function evaluated at the grid points, is written to the buffer ar...
sc::DescribedXMLWritable
Definition: xml.h:50
sc::WriteVectorGrid::get_molecule
virtual Ref< Molecule > get_molecule()=0
Returns the molecule around which the grid values are calculated.
sc::Grid
The Grid class defines a finite regular Carthesian grid.
Definition: grid.h:35
sc::WriteGrid
The abstract WriteGrid class provides an interface for writing the value of a scalar function evaluat...
Definition: grid.h:85
sc::WriteVectorGrid::WriteVectorGrid
WriteVectorGrid(const Ref< KeyVal > &)
The KeyVal constructor.
sc::WriteGrid::run
void run()
Writes the grid data.
sc::Runnable
The Runnable class is a DescribedClass with a pure virtual run member.
Definition: runnable.h:36
sc::XMLWriter
Definition: xmlwriter.h:215
sc::DescribedClass
Classes which need runtime information about themselves and their relationship to other classes can v...
Definition: class.h:233
sc::Grid::Grid
Grid(const Ref< KeyVal > &)
The KeyVal constructor.
sc::WriteVectorGrid::label
virtual void label(char *buffer)=0
A label that identifies the scalar function evaluated at the grid points, is written to the buffer ar...
sc::SCVector3
a 3-element version of SCVector
Definition: vector3.h:43
sc::WriteVectorGrid::ndim
virtual std::size_t ndim() const =0
number of dimensions of the vector
sc::WriteVectorGrid::dimension_map
virtual const DimensionMap & dimension_map() const =0
dimension map
sc::WriteGrid::WriteGrid
WriteGrid(const Ref< KeyVal > &)
The KeyVal constructor.
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
sc::Units
The Units class is used to perform unit conversions.
Definition: units.h:38

Generated at Sun Jan 26 2020 23:24:00 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.