Page MenuHomec4science

lattice.hh
No OneTemporary

File Metadata

Created
Wed, Jun 5, 11:05

lattice.hh

/**
* @file lattice.hh
* @author Till Junge <junge@lsmspc42.epfl.ch>
* @date Fri Apr 13 11:08:40 2012
*
* @brief interface to lattices
*
* @section LICENSE
*
* <insert lisence here>
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __CADD_MESHER_LATTICE_HH__
#define __CADD_MESHER_LATTICE_HH__
#include "common.hh"
#include "point_container.hh"
#include "gsl/gsl_matrix.h"
#include <sstream>
/*! \class Lattice Base class of lattices, can also be used to create custom lattices
*/
template <Uint DIM>
class Lattice {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
/*! Constructor
* \param constants array of lattice constants in \a x, \a y and \a z
* direction of the lattice
* \param miller matrix of Miller indices (as 1D array of size \a DIM * \a DIM
* ). The rows are the Miller vectors to be aligned with the corresponding
* direction of the global coordinate system. If \a NULL, the identity is
* used.*/
Lattice(Real * constants, Real * miller = NULL) throw(std::string);
Lattice(const Lattice & other);
virtual ~Lattice();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
virtual Lattice * resolveType() const = 0;
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
void fillAtoms(int * lattice_coords, PointContainer<DIM> & container);
/*! fill the atoms into a PointContainer with an offset given
* by the coordinates fo the south-west corner of the lattice
* \param sw_coords coordinates of the south-west corner of the lattice
* \param container reference to PointContainer to fill
*/
void fillAtoms(Real * sw_coords, PointContainer<DIM> & container);
/*! returns the rotation matrix which rotates the lattice back into reference
* configuration*/
gsl_matrix * getRotationTranspose() { return this->rotation_matrix;}
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/*! returns the lattice constant in a given direction (in the lattice
* reference orientation)
* \param direction */
inline const Real & getConstant(Uint direction) const {return this->constants[direction];}
/*! returns the geometric mean of the constants. Hopefully this is a good measure.
* The geometric mean is defined as \f[G = \sqrt[n]{x_1 x_2 \cdots x_n}\f] */
inline const Real & getRepresentativeConstant() const {return this->constants[DIM];}
/*! returns the direction of a lattice vector in the global coordinate system
* \param direction */
inline const Real * getLatticeVector(Uint direction) {
return gsl_matrix_ptr(this->rotation_matrix, direction, 0);
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
Real constants [DIM + 1];
gsl_matrix * millers;
gsl_matrix * rotation_matrix;
PointContainer<DIM> atoms;
private:
static std::string lattice_type;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
/// standard output stream operator
template<Uint DIM>
inline std::ostream & operator <<(std::ostream & stream, const Lattice<DIM> & _this)
{
_this.printself(stream);
return stream;
}
template <Uint DIM, typename subLattice>
Lattice<DIM> * newLattice(const subLattice & lattice) {
return static_cast<Lattice<DIM>*>(new subLattice(lattice));
}
#endif /* __CADD_MESHER_LATTICE_HH__ */

Event Timeline