33 #ifndef __H__UG__load_balancing_impl__
34 #define __H__UG__load_balancing_impl__
49 template <
class TElem,
class TIterator,
class TAAPos>
51 TIterator begin, TIterator end,
52 int numCellsX,
int numCellsY,
int numCellsZ,
60 typedef typename TAAPos::ValueType vector_t;
64 TAPosition_has_to_be_at_least_two_dimensional);
66 UG_ASSERT(shOut.
grid(),
"A grid has to be associated with the "
67 "specified subset handler.");
69 if((numCellsX < 1) || (numCellsY < 1) || (numCellsZ < 1)){
70 UG_THROW(
"At least one cell per direction should be specified.");
78 for(TIterator iter = begin; iter != end; ++iter){
79 if(cbConsiderElem(*iter))
80 elems.push_back(*iter);
86 vector_t tmin(0), tmax(0);
89 vector<Vertex*> vrts, associatedVrts;
90 for(TIterator iter = begin; iter != end; ++iter){
92 for(
size_t i = 0; i < vrts.size(); ++i){
94 associatedVrts.push_back(vrts[i]);
102 associatedVrts.end(), aaPos);
109 number width = max.x() - min.x();
110 number height = max.y() - min.y();
111 number depth = max.z() - min.z();
113 if((width <
SMALL) && numCellsX > 1){
114 UG_LOG(
"Can't execute PartitionElements_Rectangle: Geometry has no width.\n");
117 if((height <
SMALL) && numCellsY > 1){
118 UG_LOG(
"Can't execute PartitionElements_Rectangle: Geometry has no height.\n");
121 if((depth <
SMALL) && numCellsZ > 1){
122 UG_LOG(
"Can't execute PartitionElements_Rectangle: Geometry has no height.\n");
129 for(
typename vector<TElem*>::iterator iter = elems.begin();
130 iter != elems.end(); ++iter)
139 xInd = (int)((
number)numCellsX * (center.x() - min.x()) / width);
142 yInd = (int)((
number)numCellsY * (center.y() - min.y()) / height);
145 zInd = (int)((
number)numCellsZ * (center.z() - min.z()) / depth);
148 int si = zInd * numCellsX * numCellsY + yInd * numCellsX + xInd;
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
void end_marking()
ends a marking sequence. Call this method when you're done with marking.
Definition: grid.cpp:1285
bool is_marked(GridObject *obj) const
returns true if the object is marked, false if not.
Definition: grid_impl.hpp:843
void mark(GridObject *obj)
marks the object. Calls are only valid between calls to Grid::begin_marking and Grid::end_marking.
Definition: grid_impl.hpp:773
void begin_marking()
begin marking.
Definition: grid.cpp:1262
Partitions elements of a grid into several subsets.
Definition: subset_handler_grid.h:53
void assign_subset(Vertex *elem, int subsetIndex)
assigns a vertex to a subset.
Definition: subset_handler_grid.cpp:204
Grid * grid() const
returns a pointer to the grid on which the subset-handler works.
Definition: subset_handler_interface.cpp:304
UG_API void CollectAssociated(std::vector< Vertex * > &vVertexOut, Grid &grid, GridObject *obj, bool clearContainer=true)
Definition: grid_util_impl.hpp:169
bool PartitionElements_RegularGrid(SubsetHandler &shOut, TIterator begin, TIterator end, int numCellsX, int numCellsY, int numCellsZ, TAAPos &aaPos, typename Grid::traits< TElem >::callback cbConsiderElem=ConsiderAll(), int bucketSubset=-1)
Partitions the elements in the grid by sorting them into a regular grid.
Definition: load_balancing_impl.hpp:50
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_THROW(msg)
Definition: error.h:57
#define UG_STATIC_ASSERT(expr, msg)
Checks an expression at compile-time and raises a compile-error if the expression equals 0.
Definition: static_assert.h:63
#define UG_LOG(msg)
Definition: log.h:367
double number
Definition: types.h:124
void CalculateCenter(vector_t ¢erOut, const vector_t *pointSet, size_t numPoints)
calculates the center of a point-set
Definition: math_util_impl.hpp:98
void VecCopy(vector_target_t &target, const vector_source_t &source, typename vector_target_t::value_type fill)
Copy contents between vectors of possibly different types.
Definition: math_vector_functions_common_impl.hpp:56
Definition: smart_pointer.h:814
const number SMALL
Definition: math_constants.h:41
AABox< typename TAAPos::ValueType > CalculateBoundingBox(Vertex *e, TAAPos aaPos)
calculates the smallest axis aligned box that contains the given vertex
Definition: bounding_box_util.h:43
boost::function< bool(base_object *)> callback
callback type for the elements base type.
Definition: grid.h:150