File: Node.h

package info (click to toggle)
stopt 5.12%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 8,860 kB
  • sloc: cpp: 70,456; python: 5,950; makefile: 72; sh: 57
file content (102 lines) | stat: -rw-r--r-- 2,984 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright (C) 2016 EDF
// All Rights Reserved
// This code is published under the GNU Lesser General Public License (GNU LGPL)
#ifndef NODE_H
#define NODE_H
#include <Eigen/Dense>
#include <vector>
#include <memory>


/** \file Node.h
 * \brief Permit to store  some son nodes, each son node contraining the some number of particules
 *     \author Xavier Warin
*/
namespace StOpt
{

/// \class Node Node.h
/// Utilitary to split meshes
class Node
{
private :

    std::vector< Eigen::ArrayXi  > m_partNumberBySon ; ///< for each son , defines the particles number belonging to this node
    std::vector<  std::unique_ptr< Node> > m_sonNodes ; ///< nodes son of current one
    Eigen::ArrayXd m_coordVertex ; ///< coordinate of the vertex of the meshes
    int m_iDim ; ///< current dimension treated

public :

    /// \brief Default node constructor
    Node(int p_iDim): m_iDim(p_iDim) {}

    /// \brief get son
    /// \param p_iSon  son number
    std::unique_ptr< Node> &getSon(int p_iSon)
    {
        assert(p_iSon <  m_sonNodes.size());
        return m_sonNodes[p_iSon];
    }

    /// \brief accessor
    ///@{
    inline int getSonNumber() const
    {
        return  m_sonNodes.size() ;
    }
    inline  const std::vector< Eigen::ArrayXi  >   &getPartNumberBySon() const
    {
        return  m_partNumberBySon;
    }
    inline  int getIDim() const
    {
        return m_iDim ;
    }
    inline const Eigen::ArrayXd &getCoordVertex() const
    {
        return m_coordVertex ;
    }
    ///@}

    /// \brief  sons creation
    void createSon()
    {
        if (m_iDim > 0)
        {
            int m_sonNumber = m_partNumberBySon.size();
            /* m_sonNodes.reserve(m_sonNumber); */
            m_sonNodes.resize(m_sonNumber);
            for (int i = 0; i < m_sonNumber; ++i)
                /* not implemented yet in compilers */
                /* m_sonNodes.push_back(std::make_unique<Node>(m_iDim-1); */
            {
                std::unique_ptr<Node> ptr(new Node(m_iDim - 1));
                m_sonNodes[i] = std::unique_ptr<Node>(std::move(ptr));
            }
        }
    }

    ///\brief Get particules number associated to one son
    /// \param p_iSon  son number
    inline const  Eigen::ArrayXi   &getParticleSon(const int &p_iSon) const
    {
        return  m_partNumberBySon[p_iSon];
    }

    ///\brief Organize a partition of the particles in current direction
    /// \param p_globalSetOfParticles  global set of particles (nb particiles , dimension)
    /// \param p_nbPartition    number of partition to achive in this direction
    /// \param p_partToSplit    define the set of the numbers of the particles to split
    void partitionDomain(const Eigen::ArrayXXd &p_globalSetOfParticles, const int &p_nbPartition,
                         const Eigen::ArrayXi &p_partToSplit);

    /// \brief test if a node is a leaf
    bool isItLeaf() const
    {
        return (m_sonNodes.size() == 0);
    }

} ;
}
#endif /* NODE_H */