Page MenuHomec4science

intersection_octree.hh
No OneTemporary

File Metadata

Created
Fri, Nov 22, 08:10

intersection_octree.hh

/**
* @file intersection_octree.hh
*
* @author Ali Falsafi <ali.falsafi@epfl.ch>
*
* @date May 2018
*
* @brief common operations on pixel addressing
*
* Copyright © 2018 Ali Falsafi
*
* µSpectre is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3, or (at
* your option) any later version.
*
* µSpectre is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Emacs; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef INTERSECTION_OCTREE_H
#define INTERSECTION_OCTREE_H
#include <vector>
#include "common/ccoord_operations.hh"
#include "common/common.hh"
#include "cell/cell_base.hh"
#include "materials/material_base.hh"
#include "common/intersection_volume_calculator.hh"
namespace muSpectre {
template<Dim_t DimS>
class RootNode;
template<Dim_t DimS>
class Node
{
public:
using Rcoord = Rcoord_t<DimS>; //!< physical coordinates type
using Ccoord = Ccoord_t<DimS>; //!< cell coordinates type
using RootNode_t = RootNode<DimS>;
//! Default constructor
Node() = delete;
// Construct by origin, lenghts, and depth
Node(const Rcoord &new_origin, const Ccoord &new_lenghts,
int depth, RootNode_t& root, bool is_root );
// Construct by cell
// Node(const CellBase<DimS, DimS>& cell, RootNode_t& root);
//! Copy constructor
Node(const Node &other) = delete;
//! Move constructor
Node(Node &&other) = default;
//! Destructor
virtual ~Node() = default;
//This function checks the status of the node and orders its devision into
//smaller nodes or asssign material to it
virtual void check_node();
//This function gives the ratio of the node which happens to be inside the precipitate
//and assign materila to it if node is a pixel or divide it furhter if it is not
void split_node(Real ratio);
//this function constructs children of a node
void divide_node();
protected:
//
RootNode_t& root_node;
Rcoord origin, Rlengths{};
Ccoord Clengths{};
int depth;
bool is_pixel;
int children_no;
std::vector<Node> children{};
};
template<Dim_t DimS>
class RootNode: public Node<DimS>
{
friend class Node<DimS>;
public:
using Rcoord = Rcoord_t<DimS>; //!< physical coordinates type
using Ccoord = Ccoord_t<DimS>; //!< cell coordinates type
using Parent = Node<DimS>; //!< base class
//!Default Constructor
RootNode() = delete ;
//! Constructing a root node for a cell and a preticipate inside that cell
RootNode(CellBase<DimS, DimS>& cell,
std::vector<Rcoord> vert_precipitate);
//! Copy constructor
RootNode(const RootNode &other) = delete;
//! Move constructor
RootNode(RootNode &&other) = default;
//! Destructor
~RootNode() = default;
//returns the pixels which have intersection raio with the preipitate
std::vector<Ccoord> get_intersected_pixels ();
//return the intersection ratios of corresponding to the pixels returned by get_intersected_pixels()
std::vector<Real> get_intersection_ratios ();
//checking rootnode:
void check_root_node();
protected:
CellBase<DimS, DimS>& cell;
Rcoord cell_length, pixel_lengths;
Ccoord cell_resolution;
int max_resolution ;
int max_depth;
std::vector<Rcoord> precipitate_vertices{};
std::vector<Ccoord> intersected_pixels{};
std::vector<Real> intersection_ratios{};
};
} //muSpectre
#endif /* INTERSECTION_OCTREE_H */

Event Timeline