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

Enhance cmesh testing #871

Merged
merged 36 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
26520c8
Add a generator for cmeshes depending on an num_trees-type parameter
Davknapp Nov 23, 2023
e4834aa
indentation
Davknapp Nov 23, 2023
db0899d
WIP: Started another generator
Davknapp Nov 23, 2023
90dbbd3
WIP iterate over two different generators
Davknapp Nov 24, 2023
8f3b239
WIP: use only one class for the cmesh_generators
Davknapp Nov 28, 2023
48baaea
WIP Update initializer
Davknapp Nov 28, 2023
bb06e40
First working version
Davknapp Nov 29, 2023
6484c79
Add Comment
Davknapp Nov 29, 2023
ec4ce9b
Update comment
Davknapp Nov 29, 2023
d99a17e
Iterate until last cmesh
Davknapp Nov 29, 2023
7d6e57b
Merge remote-tracking branch 'origin/main' into enhance-cmesh-testing
Davknapp Jan 17, 2024
199e4f4
Fix typo
Davknapp Jan 17, 2024
21858dd
templated cmesh_test
Davknapp Feb 2, 2024
a3c0fec
Added copy and creator function, added examples
Davknapp Feb 5, 2024
660e4b5
Print example-name
Davknapp Feb 5, 2024
732c65b
Update filenames, remove namespace from test
Davknapp Feb 5, 2024
b070470
Merge remote-tracking branch 'origin/main' into enhance-cmesh-testing
Davknapp Feb 5, 2024
9799e88
Remove hypercube_pad example_set, because geometries are complicated
Davknapp Feb 5, 2024
db336a0
Merge remote-tracking branch 'origin/main' into enhance-cmesh-testing
Davknapp Feb 5, 2024
bef252c
More comments
Davknapp Feb 5, 2024
d51b0e7
Give parametrized examples more structure
Davknapp Feb 6, 2024
0e83002
Iterator implementation
Davknapp Feb 7, 2024
c1482dd
Iterator working
Davknapp Feb 7, 2024
b67bbc9
STL FTW
Davknapp Feb 7, 2024
844f914
updated names of the classes
Davknapp Feb 7, 2024
d3258a4
Merge remote-tracking branch 'origin/main' into enhance-cmesh-testing
Davknapp Feb 7, 2024
807ed99
pretty output
Davknapp Feb 7, 2024
46ee186
fix bug in Communicator print
Davknapp Feb 7, 2024
f96ab2c
Added test for the cmesh-testcase generator
Davknapp Feb 7, 2024
2ef492e
Clean-up
Davknapp Feb 8, 2024
35d12df
Test the parameter-generator and some minor improvements
Davknapp Feb 8, 2024
699c633
Add file
Davknapp Feb 8, 2024
d4ae510
Merge remote-tracking branch 'origin/main' into enhance-cmesh-testing
Davknapp Feb 9, 2024
45a7fbb
base_example -> cmesh_example_base
Davknapp Feb 9, 2024
f48f3f0
Rename classes
Davknapp Feb 9, 2024
9864ad9
Use new feature in the copy-test
Davknapp Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ t8code_googletest_programs = \
test/t8_gtest_basics \
test/t8_schemes/t8_gtest_ancestor \
test/t8_cmesh/t8_gtest_hypercube \
test/t8_cmesh/t8_gtest_cmesh_copy \
test/t8_schemes/t8_gtest_element_count_leaves \
test/t8_schemes/t8_gtest_element_ref_coords \
test/t8_geometry/t8_gtest_geometry \
Expand Down Expand Up @@ -67,7 +66,8 @@ t8code_googletest_programs = \
test/t8_forest_incomplete/t8_gtest_empty_local_tree \
test/t8_forest_incomplete/t8_gtest_empty_global_tree \
test/t8_schemes/t8_gtest_default \
test/t8_schemes/t8_gtest_child_parent_face
test/t8_schemes/t8_gtest_child_parent_face \
test/t8_cmesh_generator/t8_gtest_cmesh_generator_test

test_t8_IO_t8_gtest_vtk_reader_SOURCES = \
test/t8_gtest_main.cxx \
Expand Down Expand Up @@ -173,10 +173,6 @@ test_t8_cmesh_t8_gtest_cmesh_partition_SOURCES = \
test/t8_gtest_main.cxx \
test/t8_cmesh/t8_gtest_cmesh_partition.cxx

test_t8_cmesh_t8_gtest_cmesh_copy_SOURCES = \
test/t8_gtest_main.cxx \
test/t8_cmesh/t8_gtest_cmesh_copy.cxx

test_t8_cmesh_t8_gtest_cmesh_set_partition_offsets_SOURCES = \
test/t8_gtest_main.cxx \
test/t8_cmesh/t8_gtest_cmesh_set_partition_offsets.cxx
Expand Down Expand Up @@ -289,6 +285,10 @@ test_t8_schemes_t8_gtest_child_parent_face_SOURCES = \
test/t8_gtest_main.cxx \
test/t8_schemes/t8_gtest_child_parent_face.cxx

test_t8_cmesh_generator_t8_gtest_cmesh_generator_test_SOURCES = \
test/t8_gtest_main.cxx \
test/t8_cmesh_generator/t8_gtest_cmesh_generator_test.cxx

#define ld and cpp flags for all targets
t8_gtest_target_ld_add = $(LDADD) test/libgtest.la
t8_gtest_target_ld_flags = $(AM_LDFLAGS) -pthread
Expand Down Expand Up @@ -397,10 +397,6 @@ test_t8_cmesh_t8_gtest_cmesh_partition_LDADD = $(t8_gtest_target_ld_add)
test_t8_cmesh_t8_gtest_cmesh_partition_LDFLAGS = $(t8_gtest_target_ld_flags)
test_t8_cmesh_t8_gtest_cmesh_partition_CPPFLAGS = $(t8_gtest_target_cpp_flags)

test_t8_cmesh_t8_gtest_cmesh_copy_LDADD = $(t8_gtest_target_ld_add)
test_t8_cmesh_t8_gtest_cmesh_copy_LDFLAGS = $(t8_gtest_target_ld_flags)
test_t8_cmesh_t8_gtest_cmesh_copy_CPPFLAGS = $(t8_gtest_target_cpp_flags)

test_t8_cmesh_t8_gtest_cmesh_set_partition_offsets_LDADD = $(t8_gtest_target_ld_add)
test_t8_cmesh_t8_gtest_cmesh_set_partition_offsets_LDFLAGS = $(t8_gtest_target_ld_flags)
test_t8_cmesh_t8_gtest_cmesh_set_partition_offsets_CPPFLAGS = $(t8_gtest_target_cpp_flags)
Expand Down Expand Up @@ -517,6 +513,10 @@ test_t8_schemes_t8_gtest_child_parent_face_LDADD = $(t8_gtest_target_ld_add)
test_t8_schemes_t8_gtest_child_parent_face_LDFLAGS = $(t8_gtest_target_ld_flags)
test_t8_schemes_t8_gtest_child_parent_face_CPPFLAGS = $(t8_gtest_target_cpp_flags)

test_t8_cmesh_generator_t8_gtest_cmesh_generator_test_LDADD = $(t8_gtest_target_ld_add)
test_t8_cmesh_generator_t8_gtest_cmesh_generator_test_LDFLAGS = $(t8_gtest_target_ld_flags)
test_t8_cmesh_generator_t8_gtest_cmesh_generator_test_CPPFLAGS = $(t8_gtest_target_cpp_flags)

# If we did not configure t8code with MPI we need to build Googletest
# without MPI support.
if !T8_ENABLE_MPI
Expand Down Expand Up @@ -545,7 +545,6 @@ test_t8_schemes_t8_gtest_find_parent_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags
test_t8_schemes_t8_gtest_equal_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags)
test_t8_cmesh_t8_gtest_cmesh_face_is_boundary_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags)
test_t8_cmesh_t8_gtest_cmesh_partition_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags)
test_t8_cmesh_t8_gtest_cmesh_copy_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags)
test_t8_cmesh_t8_gtest_cmesh_set_partition_offsets_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags)
test_t8_forest_t8_gtest_element_volume_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags)
test_t8_cmesh_t8_gtest_multiple_attributes_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags)
Expand Down Expand Up @@ -575,6 +574,8 @@ test_t8_forest_incomplete_t8_gtest_empty_local_tree_CPPFLAGS += $(t8_gtest_targe
test_t8_forest_incomplete_t8_gtest_empty_global_tree_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags)
test_t8_schemes_t8_gtest_default_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags)
test_t8_schemes_t8_gtest_child_parent_face_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags)
test_t8_cmesh_generator_t8_gtest_cmesh_generator_test_CPPFLAGS += $(t8_gtest_target_mpi_cpp_flags)

endif

# Build Googletest library
Expand Down
6 changes: 2 additions & 4 deletions test/t8_cmesh/t8_gtest_cmesh_copy.cxx
jmark marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <t8_schemes/t8_default/t8_default_cxx.hxx>
#include "t8_cmesh/t8_cmesh_trees.h"
#include "t8_cmesh/t8_cmesh_partition.h"
#include <t8_cmesh/t8_cmesh_testcases.h>
#include <test/t8_gtest_macros.hxx>

/* We create and commit a cmesh, then derive a new cmesh
Expand All @@ -45,9 +44,8 @@ class t8_cmesh_copy: public testing::TestWithParam<int> {
/* Skip test since cmesh copy is not yet working. See https://github.com/DLR-AMR/t8code/issues/920 */
GTEST_SKIP ();
cmesh_id = GetParam ();

/* Create cmesh from cmesh_id */
cmesh_original = t8_test_create_cmesh (cmesh_id);

/* Initialized test cmesh that we derive in the test */
t8_cmesh_init (&cmesh);
}
Expand Down Expand Up @@ -83,5 +81,5 @@ TEST_P (t8_cmesh_copy, test_cmesh_copy)
EXPECT_TRUE (t8_cmesh_is_equal (cmesh, cmesh_original));
}

/* Test all cmeshes over all different inputs */
/* Test all cmeshes over all different inputs*/
INSTANTIATE_TEST_SUITE_P (t8_gtest_cmesh_copy, t8_cmesh_copy, AllCmeshs);
60 changes: 60 additions & 0 deletions test/t8_cmesh_generator/t8_cmesh_example_sets.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
This file is part of t8code.
t8code is a C library to manage a collection (a forest) of multiple
connected adaptive space-trees of general element classes in parallel.

Copyright (C) 2024 the developers

t8code is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

t8code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with t8code; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef T8_GTEST_CMESH_COMM_CREATOR_HXX
#define T8_GTEST_CMESH_COMM_CREATOR_HXX

#include <vector>

#include "test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_prism_cake_param.hxx"
#include "test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_from_class_param.hxx"
#include "test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_new_bigmesh_param.hxx"
#include "test/t8_cmesh_generator/t8_gtest_cmesh_cartestian_product.hxx"
#include "test/t8_cmesh_generator/t8_gtest_cmesh_sum_of_sets.hxx"

T8_EXTERN_C_BEGIN ();

/**
* lambda to pass to an INSTANTIATE_TEST_SUITE_P to print the current base_example
*
*/
auto pretty_print_base_example = [] (const testing::TestParamInfo<base_example *> &info) {
std::string name;
info.param->param_to_string (name);
return name;
};

namespace cmesh_list
{
std::vector<example_parameter_combinator *> cart_prod_vec
jmark marked this conversation as resolved.
Show resolved Hide resolved
= { new_from_class::cmesh_example, new_prism_cake::cmesh_example, new_bigmesh::cmesh_example };

cmesh_sum_of_sets cmesh_sums (cart_prod_vec);

} // namespace cmesh_list

#define AllCmeshsParam \
::testing::ValuesIn (cmesh_list::cmesh_sums.cmesh_examples.begin (), cmesh_list::cmesh_sums.cmesh_examples.end ())

T8_EXTERN_C_END ();

#endif /* T8_GTEST_CMESH_COMM_CREATOR_HXX */
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
This file is part of t8code.
t8code is a C library to manage a collection (a forest) of multiple
connected adaptive space-trees of general element classes in parallel.

Copyright (C) 2024 the developers

t8code is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

t8code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with t8code; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef T8_CMESH_NEW_BIGMESH_PARAM_HXX
#define T8_CMESH_NEW_BIGMESH_PARAM_HXX

#include "test/t8_cmesh_generator/t8_gtest_cmesh_cartestian_product.hxx"
#include "test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_params.hxx"
#include "t8_cmesh/t8_cmesh_examples.h"
#include <t8_eclass.h>

namespace new_bigmesh
{
std::function<t8_cmesh_t (t8_eclass_t, int, sc_MPI_Comm)> bigmesh = t8_cmesh_new_bigmesh;

std::string
make_param_string (const t8_eclass_t eclass, const int num_trees, const sc_MPI_Comm comm)
{
std::string delimiter = std::string ("_");
std::string params = delimiter + t8_eclass_to_string[eclass] + delimiter + std::to_string (num_trees) + delimiter
+ cmesh_params::comm_to_string (comm);
return params;
}

std::function<std::string (const t8_eclass_t, const int, const sc_MPI_Comm)> make_param_string_wrapper
= make_param_string;

example_parameter_combinator *cmesh_example
= (example_parameter_combinator *) new cmesh_cartesian_product_params<decltype (cmesh_params::eclasses.begin ()),
decltype (cmesh_params::large_mesh.begin ()),
decltype (cmesh_params::my_comms.begin ())> (
std::make_pair (cmesh_params::eclasses.begin (), cmesh_params::eclasses.end ()),
std::make_pair (cmesh_params::large_mesh.begin (), cmesh_params::large_mesh.end ()),
std::make_pair (cmesh_params::my_comms.begin (), cmesh_params::my_comms.end ()), bigmesh, make_param_string_wrapper,
"t8_cmesh_new_bigmesh_");
} // namespace new_bigmesh

#endif /* T8_CMESH_NEW_BIGMESH_PARAM_HXX */
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
This file is part of t8code.
t8code is a C library to manage a collection (a forest) of multiple
connected adaptive space-trees of general element classes in parallel.

Copyright (C) 2024 the developers

t8code is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

t8code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with t8code; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include "test/t8_cmesh_generator/t8_gtest_cmesh_cartestian_product.hxx"
#include "test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_params.hxx"
#include <t8_cmesh/t8_cmesh_examples.h>
#include <t8_eclass.h>

#ifndef T8_CMESH_NEW_FROM_CLASS_PARAM
#define T8_CMESH_NEW_FROM_CLASS_PARAM

namespace new_from_class
{

std::string
make_param_string (const t8_eclass_t &eclass, const sc_MPI_Comm &comm)
{
std::string delimiter = std::string ("_");
std::string params
= delimiter + std::string (t8_eclass_to_string[eclass]) + delimiter + cmesh_params::comm_to_string (comm);
return params;
}

std::function<std::string (const t8_eclass_t &, const sc_MPI_Comm &)> print_function = make_param_string;

std::function<t8_cmesh_t (t8_eclass_t, sc_MPI_Comm)> new_from_class_wrapper = t8_cmesh_new_from_class;

example_parameter_combinator *cmesh_example
= (example_parameter_combinator *) new cmesh_cartesian_product_params<decltype (cmesh_params::eclasses.begin ()),
decltype (cmesh_params::my_comms.begin ())> (
std::make_pair (cmesh_params::eclasses.begin (), cmesh_params::eclasses.end ()),
std::make_pair (cmesh_params::my_comms.begin (), cmesh_params::my_comms.end ()), new_from_class_wrapper,
print_function, "t8_cmesh_new_from_class_");

} // namespace new_from_class

#endif /* T8_CMESH_NEW_FROM_CLASS_PARAM */
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
This file is part of t8code.
t8code is a C library to manage a collection (a forest) of multiple
connected adaptive space-trees of general element classes in parallel.

Copyright (C) 2024 the developers

t8code is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

t8code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with t8code; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include "test/t8_cmesh_generator/t8_gtest_cmesh_cartestian_product.hxx"
#include "test/t8_cmesh_generator/t8_cmesh_parametrized_examples/t8_cmesh_params.hxx"
#include <t8_cmesh/t8_cmesh_examples.h>

#ifndef T8_CMESH_NEW_PRISM_CAKE_PARAM_HXX
#define T8_CMESH_NEW_PRISM_CAKE_PARAM_HXX

namespace new_prism_cake
{
std::function<t8_cmesh_t (sc_MPI_Comm, int)> prism_cake = t8_cmesh_new_prism_cake;

std::string
make_param_string (const sc_MPI_Comm &comm, const int &num_prisms)
{
std::string delimiter = std::string ("_");
std::string params = delimiter + cmesh_params::comm_to_string (comm) + delimiter + std::to_string (num_prisms);
return params;
}

std::function<std::string (const sc_MPI_Comm &, const int &)> make_param_string_wrapper = make_param_string;

example_parameter_combinator *cmesh_example
= (example_parameter_combinator *) new cmesh_cartesian_product_params<decltype (cmesh_params::my_comms.begin ()),
decltype (cmesh_params::num_prisms.begin ())> (
std::make_pair (cmesh_params::my_comms.begin (), cmesh_params::my_comms.end ()),
std::make_pair (cmesh_params::num_prisms.begin (), cmesh_params::num_prisms.end ()), prism_cake,
make_param_string_wrapper, "t8_cmesh_new_prism_cake_");
} // namespace new_prism_cake

#endif /* T8_CMESH_NEW_PRISM_CAKE_PARAM_HXX */
Loading