Page MenuHomec4science

block.hh
No OneTemporary

File Metadata

Created
Sat, Sep 28, 03:04

block.hh

/**
* @file block.hh
* @author Till Junge <junge@lsmspc42.epfl.ch>
* @date Wed Apr 4 15:28:40 2012
*
* @brief Block geometry class
*
* @section LICENSE
*
* <insert lisence here>
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __cadd_mesh_BLOCK_HH__
#define __cadd_mesh_BLOCK_HH__
#include "common.hh"
#include "geometry.hh"
/*! \brief implementation of the Geometry interface for blocks aligned with
coordinate axes*/
template<Uint DIM>
class Block:public Geometry<DIM> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
// min_max is x_min, x_max, y_min, y_max ...
Block(const std::vector<Real> & min_max, std::string name = "");
Block(const Real * min_max, std::string _name = "");
Block(const Block & other);
virtual ~Block(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
virtual Geometry<DIM> * resolveType() const {
return newGeom<DIM>(*this);
}
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
virtual void shift (const PointRef<DIM> & offset);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
/* Returns the minimum value of all constraint violations (negative return
value means point is inside and return value from the nearest boundary)
The tolerance is interpreted inclusively on the lower bounds and
exclusively on the upper bounds*/
virtual bool is_inside(const Real * point, Real tol) const {
return this->from_border(point, tol).is_inside;}
virtual InsideObject from_border(const Real * point, Real tol) const;
// for instance x_min of a geom in latticespacings
virtual Real min_in_direction(const Real * dir, const Real & unit = 1) const;
// idem
virtual Real max_in_direction(const Real * dir, const Real & unit = 1) const;
// idem
virtual Real size_in_direction(const Real * dir, const Real & unit = 1) const;
virtual void generate_surface_points(const Mesh<DIM> & auxiliary,
const std::vector<Real> & refinement,
const Real step_size[DIM],
const Real & repr_const,
const bool periodicity[DIM],
PointContainer<DIM> & points) const;
virtual void complement_periodically(const Mesh<DIM> & auxiliary,
const std::vector<Real> & refinement,
const PointContainer<DIM> & points,
PointContainer<DIM> & complement,
int direction,
Uint dim) const;
std::vector<Real> bounds () {
std::vector<Real> bounds;
for (Uint i = 0 ; i < DIM*2 ; ++i) {
bounds.push_back(this->min_max[i]);
}
return bounds;
}
private:
Real min_max[2*DIM];
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
/// standard output stream operator
template <Uint DIM>
inline std::ostream & operator <<(std::ostream & stream, const Block<DIM> & _this)
{
_this.printself(stream);
return stream;
}
#endif /* __cadd_mesh_BLOCK_HH__ */

Event Timeline