Skip to content

Commit

Permalink
Merge pull request #974 from DLR-AMR/enhancement-split_cmesh_commit_a…
Browse files Browse the repository at this point in the history
…nd_geometry_checks

Split cmesh commit and geometry checks
  • Loading branch information
sandro-elsweijer authored Mar 5, 2024
2 parents 3e711d7 + b507afe commit fdd353a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/t8_cmesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ int
t8_cmesh_is_committed (const t8_cmesh_t cmesh);

#ifdef T8_ENABLE_DEBUG
/** Check the geometry of the mesh for validity.
* \param [in] cmesh This cmesh is examined.
* \return True if the geometry of the cmesh is valid.
*/
bool
t8_cmesh_validate_geometry (const t8_cmesh_t cmesh);

/** After a cmesh is committed, check whether all trees in a cmesh do have positive volume.
* Returns true if all trees have positive volume.
* \param [in] cmesh This cmesh is examined. May be NULL.
Expand Down
15 changes: 13 additions & 2 deletions src/t8_cmesh/t8_cmesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ t8_cmesh_is_committed (const t8_cmesh_t cmesh)

#ifdef T8_ENABLE_DEBUG
/* TODO: check more conditions that must always hold after commit */
if ((!t8_cmesh_trees_is_face_consistent (cmesh, cmesh->trees)) || (!t8_cmesh_no_negative_volume (cmesh))
|| (!t8_cmesh_check_trees_per_eclass (cmesh))) {
if ((!t8_cmesh_trees_is_face_consistent (cmesh, cmesh->trees)) || (!t8_cmesh_check_trees_per_eclass (cmesh))) {
is_checking = 0;
return 0;
}
Expand All @@ -122,6 +121,18 @@ t8_cmesh_is_committed (const t8_cmesh_t cmesh)
return 1;
}

#ifdef T8_ENABLE_DEBUG
bool
t8_cmesh_validate_geometry (const t8_cmesh_t cmesh)
{
/* Geometry handler is not constructed yet */
if (cmesh->geometry_handler == NULL) {
return 1;
}
return t8_cmesh_no_negative_volume (cmesh);
}
#endif /* T8_ENABLE_DEBUG */

/* Check whether a given communicator assigns the same rank and mpisize
* as stored in a given cmesh. */
int
Expand Down
1 change: 1 addition & 0 deletions src/t8_cmesh/t8_cmesh_commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ t8_cmesh_commit (t8_cmesh_t cmesh, sc_MPI_Comm comm)
(long) cmesh->num_local_trees, (long long) cmesh->num_trees, (long) cmesh->num_ghosts);

T8_ASSERT (t8_cmesh_is_committed (cmesh));
T8_ASSERT (t8_cmesh_validate_geometry (cmesh));
/* If profiling is enabled, we measure the runtime of commit. */
if (cmesh->profile != NULL) {
cmesh->profile->commit_runtime = sc_MPI_Wtime () - cmesh->profile->commit_runtime;
Expand Down

0 comments on commit fdd353a

Please sign in to comment.