spaceGraph.hh

Go to the documentation of this file.
1 
7 #ifndef space_graph_hh
8 #define space_graph_hh
9 
10 #include "space/space.hh"
11 #include "toolbox/graph.hh"
12 
13 namespace concepts
14 {
15 
16  // ********************************************************* SpaceGraph<F> **
17  template<class F>
18  class SpaceGraph
19  {
20  protected:
21  typedef typename F::type type;
22  typedef typename F::type::type t_type;
24  public:
25  virtual void FillGraph(const F & spc, const int power=2, const bool verbose=false);
26  virtual Graph<typename F::type*> getGraph() const;
27  virtual void SplitGraph(const int nPparts);
28  virtual Sequence<typename F::type*> getSubDomain(const int Part) const;
29  virtual Sequence<bool> getSubDomainBool(const int Part) const;
30 
31  SpaceGraph(const F & spc, const int power=2, const bool verbose=false)
32  {
33  this->graph_.EmptyGraph();
34  this->FillGraph(spc, power, verbose);
35  };
36 
37  SpaceGraph(const std::unique_ptr<F> p_spc, const int power=2, const bool verbose=false)
38  {
39  this->graph_.EmptyGraph();
40  this->FillGraph(*p_spc, power, verbose);
41  };
42 
43  SpaceGraph(const F* p_spc, const int power=2, const bool verbose=false)
44  {
45  this->graph_.EmptyGraph();
46  this->FillGraph(*p_spc, power, verbose);
47  };
48 
49  SpaceGraph() {};
50  };
51 
52  template<class F>
53  void SpaceGraph<F>::FillGraph(const F & spc, const int power, const bool verbose)
54  {
55  this->graph_.EmptyGraph();
56 
57  std::unique_ptr<typename F::Scanner> sc(spc.scan());
58  while(*sc)
59  {
60  type & elm = (*sc)++;
61  int Weight = 1, BaseWeight = elm.T().n();
62  for (int i=0; i < power; i++)
63  Weight *= BaseWeight;
64 
65  this->graph_.addVertex(&elm, Weight);
66 
67  DEBUGL(verbose, "Added vertex at address " << &elm << " of weight " << Weight << " to this graph");
68  }
69  }
70 
71  template<class F>
73  {
74  return this->graph_;
75  }
76 
77  template<class F>
78  void SpaceGraph<F>::SplitGraph(const int nbParts)
79  {
80  this->graph_.SetSubdomains(nbParts);
81  }
82 
83  template<class F>
85  {
86  return this->graph_.GetSubdomain(Part);
87  }
88 
89  template<class F>
91  {
92  return this->graph_.GetSubdomainBool(Part);
93  }
94 
95 }
96 
97 
98 #endif // space_graph_hh
virtual Sequence< bool > getSubDomainBool(const int Part) const
Definition: spaceGraph.hh:90
SpaceGraph(const std::unique_ptr< F > p_spc, const int power=2, const bool verbose=false)
Definition: spaceGraph.hh:37
virtual Graph< typename F::type * > getGraph() const
Definition: spaceGraph.hh:72
virtual Sequence< typename F::type * > getSubDomain(const int Part) const
Definition: spaceGraph.hh:84
void EmptyGraph()
Definition: graph.hh:95
virtual void SplitGraph(const int nPparts)
Definition: spaceGraph.hh:78
SpaceGraph(const F &spc, const int power=2, const bool verbose=false)
Definition: spaceGraph.hh:31
#define DEBUGL(doit, msg)
Sequence with operations, output operator, and method of the particular element types.
Definition: sequence.hh:39
virtual void FillGraph(const F &spc, const int power=2, const bool verbose=false)
Definition: spaceGraph.hh:53
F::type::type t_type
Definition: spaceGraph.hh:22
SpaceGraph(const F *p_spc, const int power=2, const bool verbose=false)
Definition: spaceGraph.hh:43
Graph< type * > graph_
Definition: spaceGraph.hh:23
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich