Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p4est initialization in t8_cmesh_new_from_p4est does not work #903

Open
lukasdreyer opened this issue Jan 24, 2024 · 0 comments
Open

p4est initialization in t8_cmesh_new_from_p4est does not work #903

lukasdreyer opened this issue Jan 24, 2024 · 0 comments

Comments

@lukasdreyer
Copy link
Collaborator

t8_cmesh_new_from_p4est checks that p4est was initialized, and does it itself if it was not initialized before.

But forgetting to initialize p4est leads to memory balance errors as shown below:

#include <t8_cmesh/t8_cmesh_examples.h>

int
main (int argc, char **argv)
{
  t8_cmesh_t          cmesh;
  p4est_connectivity_t *conn;

  SC_CHECK_MPI(sc_MPI_Init (&argc, &argv));

  sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_ESSENTIAL);
//  p4est_init (NULL, SC_LP_DEFAULT);
  t8_init (SC_LP_DEFAULT);
  
  conn = p4est_connectivity_new_brick (1, 1, 0, 0);
  cmesh = t8_cmesh_new_from_p4est (conn, sc_MPI_COMM_WORLD, 0);
  
  t8_cmesh_destroy (&cmesh);
  p4est_connectivity_destroy (conn);

  sc_finalize ();
  SC_CHECK_MPI (sc_MPI_Finalize ());
  return 0;
}

leads to

[libsc] This is libsc 2.8.5.67-edbe8-dirty
[t8] This is t8 1.6.1.130-4af3-dirty
[t8] CPP                      mpicc -E
[t8] CPPFLAGS                 
[t8] CC                       mpicc
[t8] CFLAGS                   -Wall -O0 -g
[t8] LDFLAGS                  
[t8] LIBS                     -lz -lm  -lstdc++
[libsc 0] Invalid package id -1
[t8] WARNING: p4est is not yet initialized. Doing it now for you.
[p4est] This is p4est 2.8.5.69-aee0b-dirty
[t8 0] Registering geometry t8_geom_linear_2
[t8 0] Committing geom handler. Set 't8_geom_linear_2' as active geometry.
[t8 0] Cmesh is not partitioned.
[t8 0] committed cmesh with 1 local and 1 global trees and 0 ghosts.
[libsc 0] Memory balance (p4est)
[0] Memory balance (default)
Abort: Finalize
Abort: ../../t8code/sc/src/sc.c:1404
Abort
Aborted

but reintroducing the p4est_init call in the main resolves the memory balance issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant