25#ifndef CUBOID_GEOMETRY_MINIMIZER_H
26#define CUBOID_GEOMETRY_MINIMIZER_H
30template <
typename T>
class CuboidGeometry3D;
31template <
typename T>
class IndicatorF3D;
32template <
typename T>
class Cuboid3D;
38 cGeometry.
shrink(indicatorF);
40 while (cGeometry.
getNc() < nC) {
42 T iCVolume[cGeometry.
getNc()];
44 for (
int iC = 0; iC < cGeometry.
getNc(); iC++) {
45 iCVolume[iC] = cGeometry.
get(iC).getLatticeVolume();
46 if ( iCVolume[iC] > iCVolume[maxiC] ) {
52 auto& largest = cGeometry.
get(maxiC);
53 if (largest.getNx() >= largest.getNy() && largest.getNx() >= largest.getNz()) {
55 largest.divide(2,1,1, cGeometry.
cuboids());
57 else if (largest.getNy() >= largest.getNx() && largest.getNy() >= largest.getNz()) {
59 largest.divide(1,2,1, cGeometry.
cuboids());
63 largest.divide(1,1,2, cGeometry.
cuboids());
78 while ( initalNc % 2 == 0 ) {
83 cGeometry.
split(0, initalNc);
84 cGeometry.
shrink(indicatorF);
95 std::vector<int> factors;
98 for (
int i : {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71}) {
99 while (initalNc % i == 0) {
101 factors.push_back(i);
106 for (
int i = factors.size() - 1; i >= 0; i--) {
107 int currentNc = cGeometry.
cuboids().size();
108 for (
int iC = 0; iC < currentNc; iC++) {
111 cGeometry.
shrink(indicatorF);
113 for (
int iC = 0; iC < currentNc; iC++) {
A cuboid geometry represents a voxel mesh.
void splitByWeight(int iC, int p, IndicatorF3D< T > &indicatorF)
Splits cuboid iC, removes it and adds p cuboids of same weight.
Cuboid3D< T > & get(int iC)
Read and write access to a single cuboid.
void shrink(int iC, IndicatorF3D< T > &indicatorF)
Shrink cuboid iC so that no empty planes are left.
std::vector< Cuboid3D< T > > & cuboids()
void split(int iC, int p)
Splits cuboid iC, removes it and adds p cuboids of same volume.
void remove(int iC)
Removes the cuboid iC.
int getNc() const
Returns the number of cuboids in the structure.
void setWeights(IndicatorF3D< T > &indicatorF)
Sets the number of full cells of each cuboid.
IndicatorF3D is an application from .
Top level namespace for all of OpenLB.
void minimizeByVolume(CuboidGeometry3D< T > &cGeometry, IndicatorF3D< T > &indicatorF, int nC)
Splits into nC cuboids by-volume.
void continueMinimizeByVolume(CuboidGeometry3D< T > &cGeometry, IndicatorF3D< T > &indicatorF, int nC)
Splits largest cuboid by-volume until there are nC cuboids.
void minimizeByWeight(CuboidGeometry3D< T > &cGeometry, IndicatorF3D< T > &indicatorF, int nC)