Skip to content

Commit

Permalink
Fixed indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tunxu committed Jan 30, 2025
1 parent 9f91688 commit af47744
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 132 deletions.
44 changes: 20 additions & 24 deletions src/t8_cmesh/t8_cmesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ t8_cmesh_validate_geometry (const t8_cmesh_t cmesh, const int check_for_negative
t8_debugf ("Detected incompatible geometry for tree %li\n", (long) itree);
return false;
}
else if (check_for_negative_volume){
else if (check_for_negative_volume) {
/* Check for negative volume. This only makes sense if the geometry is valid for the tree. */
const int negative_volume
= cmesh->geometry_handler->tree_negative_volume (cmesh, t8_cmesh_get_global_id (cmesh, itree));
Expand Down Expand Up @@ -589,68 +589,64 @@ t8_cmesh_is_equal_ext (const t8_cmesh_t cmesh_a, const t8_cmesh_t cmesh_b, const
}
/* check entries that are numbers */
if (cmesh_a->committed != cmesh_b->committed || cmesh_a->dimension != cmesh_b->dimension
|| cmesh_a->set_partition != cmesh_b->set_partition || cmesh_a->mpirank != cmesh_b->mpirank
|| cmesh_a->mpisize != cmesh_b->mpisize || cmesh_a->num_trees != cmesh_b->num_trees
|| cmesh_a->num_local_trees != cmesh_b->num_local_trees || cmesh_a->num_ghosts != cmesh_b->num_ghosts
|| cmesh_a->first_tree != cmesh_b->first_tree)
{
|| cmesh_a->set_partition != cmesh_b->set_partition || cmesh_a->mpirank != cmesh_b->mpirank
|| cmesh_a->mpisize != cmesh_b->mpisize || cmesh_a->num_trees != cmesh_b->num_trees
|| cmesh_a->num_local_trees != cmesh_b->num_local_trees || cmesh_a->num_ghosts != cmesh_b->num_ghosts
|| cmesh_a->first_tree != cmesh_b->first_tree) {
return 0;
}
/* check arrays */
if (memcmp (cmesh_a->num_trees_per_eclass, cmesh_b->num_trees_per_eclass, T8_ECLASS_COUNT * sizeof (t8_gloidx_t)))
{
if (memcmp (cmesh_a->num_trees_per_eclass, cmesh_b->num_trees_per_eclass, T8_ECLASS_COUNT * sizeof (t8_gloidx_t))) {
return 0;
}

if (memcmp (cmesh_a->num_local_trees_per_eclass, cmesh_b->num_local_trees_per_eclass,
T8_ECLASS_COUNT * sizeof (t8_locidx_t)))
{
T8_ECLASS_COUNT * sizeof (t8_locidx_t))) {
return 0;
}

if (same_tree_order){
if (same_tree_order) {
/* check tree_offsets */
if (cmesh_a->tree_offsets != NULL) {
if (cmesh_b->tree_offsets == NULL) {
return 0;
}
else {
if (!t8_shmem_array_is_equal (cmesh_a->tree_offsets, cmesh_b->tree_offsets))
return 0;
return 0;
}
}
}
/* check trees */
if (same_tree_order)
{
if (same_tree_order) {
if (cmesh_a->committed && !t8_cmesh_trees_is_equal (cmesh_a, cmesh_a->trees, cmesh_b->trees, 1)) {
/* if we have committed check tree arrays */
t8_global_productionf("Failed on equal trees");
t8_global_productionf ("Failed on equal trees");
return 0;
}
else {
if (!cmesh_a->committed && !t8_stash_is_equal (cmesh_a->stash, cmesh_b->stash)) {
/* if we have not committed check stash arrays */
return 0;
/* if we have not committed check stash arrays */
return 0;
}
}
}
else{
else {
if (cmesh_a->committed && !t8_cmesh_trees_is_equal (cmesh_a, cmesh_a->trees, cmesh_b->trees, 0)) {
/* if we have committed check tree arrays */
t8_global_productionf("Failed on equal trees %i", t8_cmesh_trees_is_equal (cmesh_a, cmesh_a->trees, cmesh_b->trees, 0));
t8_global_productionf ("Failed on equal trees %i",
t8_cmesh_trees_is_equal (cmesh_a, cmesh_a->trees, cmesh_b->trees, 0));
return 0;
}
else {
if (!cmesh_a->committed && !t8_stash_is_equal (cmesh_a->stash, cmesh_b->stash)) {
/* if we have not committed check stash arrays */
return 0;
/* if we have not committed check stash arrays */
return 0;
}
}
}

return 1;


return 1;
}

int
Expand Down
113 changes: 53 additions & 60 deletions src/t8_cmesh/t8_cmesh_trees.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1172,54 +1172,55 @@ t8_cmesh_trees_is_face_consistent (const t8_cmesh_t cmesh, const t8_cmesh_trees_
return ret;
}

static bool t8_cmesh_tree_is_equal(const t8_gloidx_t tree_id_a, const t8_gloidx_t tree_id_b, const t8_cmesh_trees_t trees_a, const t8_cmesh_trees_t trees_b, const bool check_face_neighbors)
static bool
t8_cmesh_tree_is_equal (const t8_gloidx_t tree_id_a, const t8_gloidx_t tree_id_b, const t8_cmesh_trees_t trees_a,
const t8_cmesh_trees_t trees_b, const bool check_face_neighbors)
{
/* Get the treea and their face neighbors */

t8_locidx_t *face_neighborsa, *face_neighborsb;
int8_t *ttfa, *ttfb;
size_t attsizea, attsizeb;
t8_attribute_info_struct_t *first_atta, *first_attb;
char *atta, *attb;

const t8_ctree_t treea = t8_cmesh_trees_get_tree_ext (trees_a, tree_id_a, &face_neighborsa, &ttfa);
const t8_ctree_t treeb = t8_cmesh_trees_get_tree_ext (trees_b, tree_id_b, &face_neighborsb, &ttfb);
/* Compare tree entries */
if (!(treea->eclass == treeb->eclass && treea->num_attributes == treeb->num_attributes
&& treea->treeid == treeb->treeid))
{
t8_locidx_t *face_neighborsa, *face_neighborsb;
int8_t *ttfa, *ttfb;
size_t attsizea, attsizeb;
t8_attribute_info_struct_t *first_atta, *first_attb;
char *atta, *attb;

const t8_ctree_t treea = t8_cmesh_trees_get_tree_ext (trees_a, tree_id_a, &face_neighborsa, &ttfa);
const t8_ctree_t treeb = t8_cmesh_trees_get_tree_ext (trees_b, tree_id_b, &face_neighborsb, &ttfb);
/* Compare tree entries */
if (!(treea->eclass == treeb->eclass && treea->num_attributes == treeb->num_attributes
&& treea->treeid == treeb->treeid)) {
return 0;
}
t8_eclass_t eclass = treea->eclass;
/* Compare face neighbors */
if (check_face_neighbors) {
if (memcmp (face_neighborsa, face_neighborsb, t8_eclass_num_faces[eclass] * sizeof (t8_locidx_t))
|| memcmp (ttfa, ttfb, t8_eclass_num_faces[eclass] * sizeof (int8_t))) {
return 0;
}
t8_eclass_t eclass = treea->eclass;
/* Compare face neighbors */
if (check_face_neighbors){
if (memcmp (face_neighborsa, face_neighborsb, t8_eclass_num_faces[eclass] * sizeof (t8_locidx_t))
|| memcmp (ttfa, ttfb, t8_eclass_num_faces[eclass] * sizeof (int8_t)))
{
return 0;
}
}
/* Compare attributes */
attsizea = t8_cmesh_trees_attribute_size (treea);
attsizeb = t8_cmesh_trees_attribute_size (treeb);
if (attsizea != attsizeb) {
}
/* Compare attributes */
attsizea = t8_cmesh_trees_attribute_size (treea);
attsizeb = t8_cmesh_trees_attribute_size (treeb);
if (attsizea != attsizeb) {
return 0;
}
if (attsizea > 0) {
/* Get pointers to all attributes */
first_atta = T8_TREE_ATTR_INFO (treea, 0);
first_attb = T8_TREE_ATTR_INFO (treeb, 0);
atta = (char *) T8_TREE_ATTR (treea, first_atta);
attb = (char *) T8_TREE_ATTR (treeb, first_attb);
if (memcmp (atta, attb, attsizea)) {
return 0;
}
if (attsizea > 0) {
/* Get pointers to all attributes */
first_atta = T8_TREE_ATTR_INFO (treea, 0);
first_attb = T8_TREE_ATTR_INFO (treeb, 0);
atta = (char *) T8_TREE_ATTR (treea, first_atta);
attb = (char *) T8_TREE_ATTR (treeb, first_attb);
if (memcmp (atta, attb, attsizea)) {
return 0;
}
}
}
return 1;
}

int
t8_cmesh_trees_is_equal (const t8_cmesh_t cmesh, const t8_cmesh_trees_t trees_a, const t8_cmesh_trees_t trees_b, const int same_tree_order)
t8_cmesh_trees_is_equal (const t8_cmesh_t cmesh, const t8_cmesh_trees_t trees_a, const t8_cmesh_trees_t trees_b,
const int same_tree_order)
{
int is_equal;
t8_locidx_t num_trees, num_ghost, ighost;
Expand All @@ -1245,24 +1246,21 @@ t8_cmesh_trees_is_equal (const t8_cmesh_t cmesh, const t8_cmesh_trees_t trees_a,
num_ghost = cmesh->num_ghosts;

/* We now compare all trees and their attributes */
if(!same_tree_order){
if (!same_tree_order) {
for (t8_locidx_t itree = 0; itree < num_trees; itree++) {
for (t8_locidx_t jtree = 0; jtree < num_trees; jtree++){
if (t8_cmesh_tree_is_equal(itree, jtree, trees_a, trees_b, false)){
for (t8_locidx_t jtree = 0; jtree < num_trees; jtree++) {
if (t8_cmesh_tree_is_equal (itree, jtree, trees_a, trees_b, false)) {
break;
}
else if(jtree == num_trees){
else if (jtree == num_trees) {
return 0;
}
}
}
}
else
{
for (t8_locidx_t itree = 0; itree < num_trees; itree++)
{
if (!t8_cmesh_tree_is_equal(itree, itree, trees_a, trees_b, true))
{
}
else {
for (t8_locidx_t itree = 0; itree < num_trees; itree++) {
if (!t8_cmesh_tree_is_equal (itree, itree, trees_a, trees_b, true)) {
return 0;
}
}
Expand All @@ -1273,35 +1271,30 @@ t8_cmesh_trees_is_equal (const t8_cmesh_t cmesh, const t8_cmesh_trees_t trees_a,
ghostb = t8_cmesh_trees_get_ghost_ext (trees_b, ighost, &gface_neighborsb, &ttfb);
/* Compare ghost entries */
is_equal = ghosta->eclass == ghostb->eclass && ghosta->num_attributes == ghostb->num_attributes
&& ghosta->treeid == ghostb->treeid;
if (!is_equal)
{
&& ghosta->treeid == ghostb->treeid;
if (!is_equal) {
return 0;
}
eclass = ghosta->eclass;
/* Compare face neighbors */
is_equal = !memcmp (gface_neighborsa, gface_neighborsb, t8_eclass_num_faces[eclass] * sizeof (t8_gloidx_t))
&& !memcmp (ttfa, ttfb, t8_eclass_num_faces[eclass] * sizeof (int8_t));
if (!is_equal)
{
&& !memcmp (ttfa, ttfb, t8_eclass_num_faces[eclass] * sizeof (int8_t));
if (!is_equal) {
return 0;
}
/* Compare attributes */
attsizea = t8_cmesh_trees_ghost_attribute_size (ghosta);
attsizeb = t8_cmesh_trees_ghost_attribute_size (ghostb);
if (attsizea != attsizeb)
{
if (attsizea != attsizeb) {
return 0;
}
if (attsizea > 0)
{
if (attsizea > 0) {
/* Get pointers to all attributes */
first_atta = T8_GHOST_ATTR_INFO (ghosta, 0);
first_attb = T8_GHOST_ATTR_INFO (ghostb, 0);
atta = (char *) T8_GHOST_ATTR (ghosta, first_atta);
attb = (char *) T8_GHOST_ATTR (ghostb, first_attb);
if (memcmp (atta, attb, attsizea))
{
if (memcmp (atta, attb, attsizea)) {
return 0;
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/t8_cmesh/t8_cmesh_vtk_mesh_reader.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,4 @@
#ifndef T8_CMESH_SAVE_HXX
#define T8_CMESH_SAVE_HXX



#endif /* T8_CMESH_SAVE_HXX */
#endif /* T8_CMESH_SAVE_HXX */
2 changes: 1 addition & 1 deletion src/t8_geometry/t8_geometry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ t8_geometry_tree_negative_volume (const t8_cmesh_t cmesh, const t8_gloidx_t gtre
int
t8_geometry_get_num_geometries (const t8_cmesh_t cmesh)
{
if (cmesh->geometry_handler == nullptr){
if (cmesh->geometry_handler == nullptr) {
return 0;
}
return cmesh->geometry_handler->get_num_geometries ();
Expand Down
28 changes: 14 additions & 14 deletions src/t8_vtk/t8_vtk_write_ASCII.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -793,13 +793,13 @@ t8_forest_vtk_write_ASCII (t8_forest_t forest, const char *fileprefix, const int
T8_ASSERT (forest != NULL);
T8_ASSERT (t8_forest_is_committed (forest));
T8_ASSERT (fileprefix != NULL);
if (forest->cmesh->geometry_handler == nullptr){
t8_errorf("Error: Forest could not be written as vtk since it does not have geometries.\n");
return false;
}
if (forest->cmesh->geometry_handler->get_num_geometries() == 0){
t8_errorf("Error: Forest could not be written as vtk since it does not have geometries.\n");
return false;
if (forest->cmesh->geometry_handler == nullptr) {
t8_errorf ("Error: Forest could not be written as vtk since it does not have geometries.\n");
return false;
}
if (forest->cmesh->geometry_handler->get_num_geometries () == 0) {
t8_errorf ("Error: Forest could not be written as vtk since it does not have geometries.\n");
return false;
}
if (forest->ghosts == NULL || forest->ghosts->num_ghosts_elements == 0) {
/* Never write ghost elements if there aren't any */
Expand Down Expand Up @@ -940,13 +940,13 @@ t8_cmesh_vtk_write_file_ext (const t8_cmesh_t cmesh, const char *fileprefix, con
T8_ASSERT (t8_cmesh_is_committed (cmesh));
T8_ASSERT (fileprefix != NULL);

if (cmesh->geometry_handler == nullptr){
t8_errorf("Error: Cmesh could not be written as vtk since it does not have geometries.\n");
return false;
}
if (cmesh->geometry_handler->get_num_geometries() == 0){
t8_errorf("Error: Cmesh could not be written as vtk since it does not have geometries.\n");
return false;
if (cmesh->geometry_handler == nullptr) {
t8_errorf ("Error: Cmesh could not be written as vtk since it does not have geometries.\n");
return false;
}
if (cmesh->geometry_handler->get_num_geometries () == 0) {
t8_errorf ("Error: Cmesh could not be written as vtk since it does not have geometries.\n");
return false;
}

if (cmesh->mpirank == 0) {
Expand Down
Loading

0 comments on commit af47744

Please sign in to comment.