You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let vertex_face_map = mesh.vertex_cell_connectivity();
1345
+
let vertex_normals = mesh.mesh.par_vertex_normals();
1346
+
1347
+
letmut flipped_faces = HashMap::new();
1348
+
for i in0..vertex_normals.len(){
1349
+
let n1 = vertex_normals[i];
1350
+
for j in0..vertex_face_map[i].len(){
1351
+
let tri = vertex_face_map[i][j];
1352
+
let n2 = tri_normals[tri];
1353
+
let angle = n1.angle(&n2).to_f64().unwrap();
1354
+
if angle > std::f64::consts::PI*0.99{
1355
+
flipped_faces.insert(tri,(i, angle));
1356
+
}
1357
+
}
1358
+
}
1359
+
1360
+
if !flipped_faces.is_empty(){
1361
+
letmut error_strings = Vec::new();
1362
+
error_strings.push(format!("Mesh is not consistently oriented. Found {} faces with normals flipped relative to adjacent vertices.", flipped_faces.len()));
1363
+
if postprocessing.check_mesh_debug{
1364
+
for(tri,(i, angle))in flipped_faces.iter(){
1365
+
error_strings.push(format!(
1366
+
"\tAngle between normals of face {} and vertex {} is {:.2}°",
1367
+
tri,
1368
+
i,
1369
+
angle.to_degrees()
1370
+
));
1371
+
}
1372
+
}
1373
+
Err(anyhow!(error_strings.join("\n")))
1374
+
}else{
1375
+
Ok(())
1376
+
}
1377
+
}
1378
+
(None,Some(_mesh)) => {
1379
+
info!(
1380
+
"Checking for normal orientation not implemented for quad mesh at the moment."
1381
+
);
1382
+
returnOk(());
1383
+
}
1384
+
_ => unreachable!(),
1385
+
}{
1386
+
error!("Checked mesh orientation (flipped normals), problems were found!");
1387
+
error!("{}", err);
1388
+
returnErr(anyhow!("{}", err))
1389
+
.context("Checked mesh orientation (flipped normals), problems were found!")
1390
+
.context(format!(
1391
+
"Problem found with mesh file \"{}\"",
1392
+
paths.output_file.display()
1393
+
));
1394
+
}else{
1395
+
info!("Checked mesh orientation (flipped normals), no problems were found.");
error_strings.push(format!("\n\tTriangle {}, boundary edge {:?} is located in cell with {:?} with center coordinates {:?} and edge length {}.", tri_idx, edge, cell_index, cell_center, grid.cell_size()));
172
+
error_strings.push(format!("\tTriangle {}, boundary edge {:?} is located in cell with {:?} with center coordinates {:?} and edge length {}.", tri_idx, edge, cell_index, cell_center, grid.cell_size()));
173
173
}else{
174
174
error_strings.push(format!(
175
-
"\n\tCannot get cell index for edge {:?} of triangle {}",
175
+
"\tCannot get cell index for edge {:?} of triangle {}",
0 commit comments