gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
partitionRegion.h
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #ifndef PARTITION_REGION_H
7 #define PARTITION_REGION_H
8 
9 #include "GModel.h"
10 #include "discreteRegion.h"
11 
13 private:
14  std::vector<int> _partitions;
16 
17 public:
18  partitionRegion(GModel *model, int num, const std::vector<int> &partitions)
19  : discreteRegion(model, num), _partitions(partitions),
20  _parentEntity(nullptr)
21  {
22  }
24  : discreteRegion(model, num), _partitions(), _parentEntity(nullptr)
25  {
26  }
27  partitionRegion(GModel *model, const std::vector<int> &partitions)
28  : discreteRegion(model), _partitions(partitions), _parentEntity(nullptr)
29  {
30  }
31  virtual ~partitionRegion() {}
32  virtual GeomType geomType() const { return PartitionVolume; }
33  virtual void setParentEntity(GEntity *r) { _parentEntity = r; }
34  virtual GEntity *getParentEntity() { return _parentEntity; }
35  virtual void setPartitions(std::vector<int> &partitions)
36  {
37  _partitions = partitions;
38  }
39  virtual const std::vector<int> &getPartitions() const { return _partitions; }
40  virtual int getPartition(std::size_t index) const
41  {
42  return _partitions[index];
43  }
44  virtual std::size_t numPartitions() const { return _partitions.size(); }
45 };
46 
48  : public std::binary_function<partitionRegion *, partitionRegion *, bool> {
49  bool operator()(const partitionRegion *e1, const partitionRegion *e2) const
50  {
51  if(e1->numPartitions() < e2->numPartitions()) return true;
52  if(e1->numPartitions() > e2->numPartitions()) return false;
53  for(std::size_t i = 0; i < e1->numPartitions(); i++) {
54  if(e1->getPartition(i) < e2->getPartition(i)) return true;
55  if(e1->getPartition(i) > e2->getPartition(i)) return false;
56  }
57  return false;
58  }
59 };
60 
61 #endif
partitionRegion::geomType
virtual GeomType geomType() const
Definition: partitionRegion.h:32
partitionRegion::_partitions
std::vector< int > _partitions
Definition: partitionRegion.h:14
Less_partitionRegion
Definition: partitionRegion.h:48
GEntity::model
GModel * model() const
Definition: GEntity.h:277
discreteRegion.h
Less_partitionRegion::operator()
bool operator()(const partitionRegion *e1, const partitionRegion *e2) const
Definition: partitionRegion.h:49
partitionRegion::getPartition
virtual int getPartition(std::size_t index) const
Definition: partitionRegion.h:40
partitionRegion::partitionRegion
partitionRegion(GModel *model, int num, const std::vector< int > &partitions)
Definition: partitionRegion.h:18
partitionRegion::getPartitions
virtual const std::vector< int > & getPartitions() const
Definition: partitionRegion.h:39
GEntity
Definition: GEntity.h:31
GEntity::PartitionVolume
@ PartitionVolume
Definition: GEntity.h:124
partitionRegion::setPartitions
virtual void setPartitions(std::vector< int > &partitions)
Definition: partitionRegion.h:35
discreteRegion
Definition: discreteRegion.h:13
partitionRegion::partitionRegion
partitionRegion(GModel *model, int num)
Definition: partitionRegion.h:23
partitionRegion::numPartitions
virtual std::size_t numPartitions() const
Definition: partitionRegion.h:44
partitionRegion::_parentEntity
GEntity * _parentEntity
Definition: partitionRegion.h:15
GModel
Definition: GModel.h:44
partitionRegion
Definition: partitionRegion.h:12
partitionRegion::~partitionRegion
virtual ~partitionRegion()
Definition: partitionRegion.h:31
partitionRegion::getParentEntity
virtual GEntity * getParentEntity()
Definition: partitionRegion.h:34
partitionRegion::partitionRegion
partitionRegion(GModel *model, const std::vector< int > &partitions)
Definition: partitionRegion.h:27
GEntity::GeomType
GeomType
Definition: GEntity.h:88
partitionRegion::setParentEntity
virtual void setParentEntity(GEntity *r)
Definition: partitionRegion.h:33
GModel.h