16 double tolerance = 1.0e-8;
17 double dvarphi = 2.0*M_PI/num_angles;
22 for (
int a=0; a<num_angles; a++)
24 double varphi = 0.5*dvarphi + a*dvarphi;
27 omega.
x = cos(varphi);
28 omega.
y = sin(varphi);
34 for (
size_t c=0; c<num_loc_cells; c++)
38 for (
size_t c=0; c<num_loc_cells; c++)
42 size_t num_edges = face->
edges.size();
43 for (
size_t e=0; e<num_edges; e++)
45 int v0i = face->
edges[e][0];
46 int v1i = face->
edges[e][1];
51 double mu = omega.
Dot(n);
52 int neighbor = face->
edges[e][2];
53 if ( (mu > (0.0 + tolerance)) and (neighbor >= 0))
80 if (topological_order.empty())
83 <<
"Function CheckCyclicDependencies. Detected cyclic depency.";
94 <<
"Cyclic dependency check complete. No cycles or "
95 <<
"bad mesh elements were detected";
103 std::vector<double> areas;
104 std::vector<double> histo_bins;
105 std::vector<int> histo;
107 int num_negative_areas = 0;
112 size_t num_loc_cells = poly_faces_.size();
113 areas.resize(num_loc_cells);
114 double max_area = 0.0;
115 for (
size_t c=0; c<num_loc_cells; c++)
119 size_t num_edges = face->
edges.size();
121 for (
size_t e=0; e<num_edges; e++)
123 int v0i = face->
edges[e][0];
124 int v1i = face->
edges[e][1];
131 area += 0.5*(v01.
x*v02.
y - v01.
y*v02.
x);
139 num_negative_areas += 1;
143 std::sort(areas.begin(),areas.end(),std::greater<double>());
146 histo_bins.resize(10);
148 histo_bins[0] = max_area*1.05;
149 for (
int i=1;i<10; i++)
150 histo_bins[i] = histo_bins[i-1]/2.0;
153 for (
auto area : areas)
156 for (
int i=0;i<10; i++)
159 if (area <= histo_bins[i])
164 histo[home_bin] += 1;
168 std::stringstream output;
169 for (
int i=0;i<10; i++)
172 snprintf(buff,100,
"%11.3e",histo_bins[i]);
174 output <<
"Areas < " << buff <<
" = " << histo[i] <<
"\n";
176 output <<
"Number of negative or zero faces = " << num_negative_areas;
187 std::vector<double> &x_cuts,
188 std::vector<double> &y_cuts)
190 Chi::log.
Log() <<
"X-cuts to be logged: " << x_cuts.size();
194 Chi::log.
Log() <<
"Y-cuts to be logged: " << y_cuts.size();
199 size_t I = x_cuts.size();
200 size_t J = y_cuts.size();
202 std::vector<std::vector<int>> IJ_bins(I+1,std::vector<int>(J+1,0));
204 for (
auto& poly_face : poly_faces_)
208 for (
size_t i=0; i<I; ++i)
210 if (poly_face->face_centroid.x >= x_cuts[i])
213 for (
size_t j=0; j<J; ++j)
215 if (poly_face->face_centroid.y >= y_cuts[j])
219 IJ_bins[ref_i][ref_j] += 1;
223 int max_bin_size = 0;
224 int tot_bin_size = 0;
225 int i_max = 0, j_max = 0;
227 for (
int i=0; i<(I+1); ++i)
229 for (
int j=0; j<(J+1); ++j)
231 if (IJ_bins[i][j] > max_bin_size)
233 max_bin_size = IJ_bins[i][j];
237 tot_bin_size += IJ_bins[i][j];
241 double average = tot_bin_size/((double)(I+1)*(J+1));
243 Chi::log.
Log() <<
"Average faces per set: " << average;
245 <<
"Maximum faces per set: " << max_bin_size
246 <<
" at (i,j)= ( " << i_max <<
" , " << j_max <<
" )";
248 if (i_max == I)
Chi::log.
Log() <<
"X greater than " << x_cuts[i_max-1];
253 <<
"X greater than " << x_cuts[i_max-1]
254 <<
" and less than " << x_cuts[i_max];
256 if (j_max == J)
Chi::log.
Log() <<
"Y greater than " << y_cuts[j_max-1];
261 <<
"Y greater than " << y_cuts[j_max-1]
262 <<
" and less than " << y_cuts[j_max];
265 <<
"Max-to-average ratio: " << max_bin_size/average;
static void Exit(int error_code)
LogStream Log(LOG_LVL level=LOG_0)
std::vector< size_t > GenerateTopologicalSort()
void AddVertex(size_t id, void *context=nullptr)
bool AddEdge(size_t from, size_t to, double weight=1.0)
void ComputeLoadBalancing(std::vector< double > &x_cuts, std::vector< double > &y_cuts)
void CheckCyclicDependencies(int num_angles)
std::vector< chi_mesh::PolyFace * > poly_faces_
Polygonal faces.
std::vector< chi_mesh::Vertex > vertices_
std::vector< int * > edges
chi_mesh::Vertex face_centroid
Vector3 Cross(const Vector3 &that) const
Vector3 Dot(const chi_mesh::TensorRank2Dim3 &that) const