-
Notifications
You must be signed in to change notification settings - Fork 707
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix find_all_active_cells_around_point()
Co-authored-by: Magdalena Schreter <schreter.magdalena@gmail.com>
- Loading branch information
Showing
4 changed files
with
150 additions
and
6 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
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
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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) 2001 - 2020 by the deal.II authors | ||
// | ||
// This file is part of the deal.II library. | ||
// | ||
// The deal.II library is free software; you can use it, redistribute | ||
// it, and/or modify it under the terms of the GNU Lesser General | ||
// Public License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// The full text of the license can be found in the file LICENSE.md at | ||
// the top level directory of deal.II. | ||
// | ||
// --------------------------------------------------------------------- | ||
|
||
// find_all_active_cells_around_point for neighbor cells at different levels. | ||
|
||
#include <deal.II/dofs/dof_handler.h> | ||
|
||
#include <deal.II/fe/fe_q.h> | ||
#include <deal.II/fe/mapping_q.h> | ||
|
||
#include <deal.II/grid/grid_generator.h> | ||
#include <deal.II/grid/grid_out.h> | ||
#include <deal.II/grid/grid_tools.h> | ||
#include <deal.II/grid/tria.h> | ||
|
||
#include "../tests.h" | ||
|
||
|
||
template <int dim, int spacedim> | ||
void | ||
print_result(const Mapping<dim, spacedim> & mapping, | ||
const Triangulation<dim, spacedim> &tria, | ||
const Point<dim> p) | ||
{ | ||
deallog << "Testing " << dim << "D with point " << p << " tolerance default " | ||
<< std::endl; | ||
auto c_p = GridTools::find_all_active_cells_around_point(mapping, tria, p); | ||
for (auto i : c_p) | ||
deallog << "Cell: " << i.first->id() << " unit point " << i.second | ||
<< std::endl; | ||
deallog << std::endl; | ||
} | ||
|
||
template <int dim, int spacedim> | ||
void | ||
test() | ||
{ | ||
Triangulation<dim, spacedim> tria; | ||
GridGenerator::subdivided_hyper_cube( | ||
tria, 2, 0 /*left*/, 1 /*right*/, true /*colorize*/); | ||
|
||
// In every cycle cells at the boundary face x=0 are refined. | ||
for (unsigned int i = 1; i < 3; ++i) | ||
{ | ||
for (const auto &cell : tria.active_cell_iterators()) | ||
if (cell->at_boundary(0)) | ||
cell->set_refine_flag(); | ||
|
||
tria.execute_coarsening_and_refinement(); | ||
} | ||
|
||
MappingQ<dim> mapping(2); | ||
|
||
// Point at the edge between cells of different levels | ||
Point<dim> point_at_edge; | ||
|
||
point_at_edge[dim - 1] = 0.25; | ||
print_result(mapping, tria, point_at_edge); | ||
|
||
if (dim > 1) | ||
{ | ||
for (unsigned d = 0; d < dim; ++d) | ||
point_at_edge[d] = 0.25; | ||
|
||
print_result(mapping, tria, point_at_edge); | ||
} | ||
|
||
// debug | ||
if (false) | ||
{ | ||
std::ofstream output_file("grid_" + std::to_string(dim) + ".vtu"); | ||
GridOut().write_vtu(tria, output_file); | ||
} | ||
}; | ||
|
||
|
||
int | ||
main() | ||
{ | ||
initlog(); | ||
deallog << std::setprecision(10); | ||
test<1, 1>(); | ||
test<2, 2>(); | ||
test<3, 3>(); | ||
return 0; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
DEAL::Testing 1D with point 0.2500000000 tolerance default | ||
DEAL::Cell: 0_1:1 unit point 0.000000000 | ||
DEAL::Cell: 0_2:01 unit point 1.000000000 | ||
DEAL:: | ||
DEAL::Testing 2D with point 0.000000000 0.2500000000 tolerance default | ||
DEAL::Cell: 0_2:02 unit point 0.000000000 1.000000000 | ||
DEAL::Cell: 0_2:20 unit point 0.000000000 0.000000000 | ||
DEAL:: | ||
DEAL::Testing 2D with point 0.2500000000 0.2500000000 tolerance default | ||
DEAL::Cell: 0_1:1 unit point 0.000000000 1.000000000 | ||
DEAL::Cell: 0_1:3 unit point 0.000000000 0.000000000 | ||
DEAL::Cell: 0_2:03 unit point 1.000000000 1.000000000 | ||
DEAL::Cell: 0_2:21 unit point 1.000000000 0.000000000 | ||
DEAL:: | ||
DEAL::Testing 3D with point 0.000000000 0.000000000 0.2500000000 tolerance default | ||
DEAL::Cell: 0_2:04 unit point 0.000000000 0.000000000 1.000000000 | ||
DEAL::Cell: 0_2:40 unit point 0.000000000 0.000000000 0.000000000 | ||
DEAL:: | ||
DEAL::Testing 3D with point 0.2500000000 0.2500000000 0.2500000000 tolerance default | ||
DEAL::Cell: 0_1:1 unit point 0.000000000 1.000000000 1.000000000 | ||
DEAL::Cell: 0_1:3 unit point 0.000000000 0.000000000 1.000000000 | ||
DEAL::Cell: 0_1:5 unit point 0.000000000 1.000000000 0.000000000 | ||
DEAL::Cell: 0_1:7 unit point 0.000000000 0.000000000 0.000000000 | ||
DEAL::Cell: 0_2:07 unit point 1.000000000 1.000000000 1.000000000 | ||
DEAL::Cell: 0_2:25 unit point 1.000000000 0.000000000 1.000000000 | ||
DEAL::Cell: 0_2:43 unit point 1.000000000 1.000000000 0.000000000 | ||
DEAL::Cell: 0_2:61 unit point 1.000000000 0.000000000 0.000000000 | ||
DEAL:: |