Skip to content

Commit

Permalink
split t8_cmesh_is_commited into two funtions
Browse files Browse the repository at this point in the history
  • Loading branch information
sandro-elsweijer committed Mar 3, 2024
1 parent 6234992 commit 9aba998
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/t8_cmesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ int
t8_cmesh_is_initialized (t8_cmesh_t cmesh);

/** Check whether a cmesh is not NULL, initialized and committed.
* In addition, it asserts that the cmesh is consistent as much as possible.
* \param [in] cmesh This cmesh is examined. May be NULL.
* \return True if cmesh is not NULL and
* \ref t8_cmesh_init has been called on it
Expand All @@ -91,6 +90,13 @@ t8_cmesh_is_initialized (t8_cmesh_t cmesh);
int
t8_cmesh_is_committed (const t8_cmesh_t cmesh);

/** Test if a cmesh is valid as much as possible.
* \param [in] cmesh The cmesh to be validated.
* \return True if th cmesh is valid.
*/
int
t8_cmesh_validate (const t8_cmesh_t cmesh);

#ifdef T8_ENABLE_DEBUG
/** After a cmesh is committed, check whether all trees in a cmesh do have positive volume.
* Returns true if all trees have positive volume.
Expand Down
7 changes: 7 additions & 0 deletions src/t8_cmesh/t8_cmesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ t8_cmesh_check_trees_per_eclass (t8_cmesh_t cmesh)
int
t8_cmesh_is_committed (const t8_cmesh_t cmesh)
{
return cmesh != NULL && t8_refcount_is_active (&cmesh->rc) && cmesh->committed;
}

int
t8_cmesh_validate (const t8_cmesh_t cmesh)
{
T8_ASSERT (t8_cmesh_is_committed (cmesh));
static int is_checking = 0;

/* We run into a stackoverflow if routines that we call here,
Expand Down
2 changes: 1 addition & 1 deletion src/t8_cmesh/t8_cmesh_commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ t8_cmesh_commit (t8_cmesh_t cmesh, sc_MPI_Comm comm)
" %li ghosts.\n",
(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 (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 9aba998

Please sign in to comment.