-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec7f382
commit 9fc6f27
Showing
1 changed file
with
42 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,50 @@ | ||
#include <catch2/catch_test_macros.hpp> | ||
|
||
#include <mpi.h> | ||
// Copyright (C) 2024 Paul Kühner | ||
// | ||
// This file is part of DOLFINx (https://www.fenicsproject.org) | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
#include "dolfinx/mesh/generation.h" | ||
#include <catch2/catch_test_macros.hpp> | ||
#include <mpi.h> | ||
|
||
using namespace dolfinx; | ||
|
||
TEST_CASE("Generation", "create_interval") | ||
{ | ||
mesh::Mesh<double> mesh = mesh::create_interval(MPI_COMM_SELF, 4, {0., 1.}); | ||
|
||
{ | ||
int comp_result; | ||
MPI_Comm_compare(mesh.comm(), MPI_COMM_SELF, &comp_result); | ||
CHECK(comp_result == MPI_CONGRUENT); | ||
} | ||
|
||
CHECK(mesh.geometry().dim() == 1); | ||
auto vertices = mesh.geometry().x(); | ||
CHECK(vertices[0*3] == 0.0); | ||
CHECK(vertices[1*3] == 0.25); | ||
CHECK(vertices[2*3] == 0.5); | ||
CHECK(vertices[3*3] == 0.75); | ||
CHECK(vertices[4*3] == 1.0); | ||
|
||
mesh.topology()->create_connectivity(0, 1); | ||
auto point_conn = mesh.topology()->connectivity(0, 1); | ||
|
||
CHECK(point_conn->num_nodes() == 5); | ||
|
||
CHECK(point_conn->num_links(0) == 1); | ||
CHECK(point_conn->num_links(1) == 2); | ||
CHECK(point_conn->num_links(2) == 2); | ||
CHECK(point_conn->num_links(3) == 2); | ||
CHECK(point_conn->num_links(4) == 1); | ||
|
||
CHECK(point_conn->links(0)[0] == 0); | ||
CHECK(point_conn->links(1)[0] == 0); | ||
CHECK(point_conn->links(1)[1] == 1); | ||
CHECK(point_conn->links(2)[0] == 1); | ||
CHECK(point_conn->links(2)[1] == 2); | ||
CHECK(point_conn->links(3)[0] == 2); | ||
CHECK(point_conn->links(3)[1] == 3); | ||
CHECK(point_conn->links(4)[0] == 3); | ||
mesh::Mesh<double> mesh = mesh::create_interval(MPI_COMM_SELF, 4, {0., 1.}); | ||
|
||
{ | ||
int comp_result; | ||
MPI_Comm_compare(mesh.comm(), MPI_COMM_SELF, &comp_result); | ||
CHECK(comp_result == MPI_CONGRUENT); | ||
} | ||
|
||
CHECK(mesh.geometry().dim() == 1); | ||
auto vertices = mesh.geometry().x(); | ||
CHECK(vertices[0 * 3] == 0.0); | ||
CHECK(vertices[1 * 3] == 0.25); | ||
CHECK(vertices[2 * 3] == 0.5); | ||
CHECK(vertices[3 * 3] == 0.75); | ||
CHECK(vertices[4 * 3] == 1.0); | ||
|
||
mesh.topology()->create_connectivity(0, 1); | ||
auto point_conn = mesh.topology()->connectivity(0, 1); | ||
|
||
CHECK(point_conn->num_nodes() == 5); | ||
|
||
CHECK(point_conn->num_links(0) == 1); | ||
CHECK(point_conn->num_links(1) == 2); | ||
CHECK(point_conn->num_links(2) == 2); | ||
CHECK(point_conn->num_links(3) == 2); | ||
CHECK(point_conn->num_links(4) == 1); | ||
|
||
CHECK(point_conn->links(0)[0] == 0); | ||
CHECK(point_conn->links(1)[0] == 0); | ||
CHECK(point_conn->links(1)[1] == 1); | ||
CHECK(point_conn->links(2)[0] == 1); | ||
CHECK(point_conn->links(2)[1] == 2); | ||
CHECK(point_conn->links(3)[0] == 2); | ||
CHECK(point_conn->links(3)[1] == 3); | ||
CHECK(point_conn->links(4)[0] == 3); | ||
} | ||
|
||
// TODO extend for further mesh types. |