-
Notifications
You must be signed in to change notification settings - Fork 707
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
Changed extract_dofs so that it works in parallel #8302
Merged
Merged
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
512346e
changed extract_dofs so that it works in parallel
mathsen a9d66b5
Added small test for extract_dofs() with DoFHandler and hp::DoFHandle…
mathsen da6dae2
Changed dof_tools_12a to include more complicated FE systems and outp…
mathsen 9b0adf6
Fixed indentation
mathsen df81f5b
Added more detailed explanation about the output of the test
mathsen a9b4991
explained in more detail the behaviour of extract_dofs
mathsen c562fd1
united extract_dofs() for DoFHandler and hp::DoFHandler, drawback: au…
mathsen 32e5379
Update so that extract_dofs() doesn't depend on dim or spacedim templ…
mathsen b55c887
Indendation...
mathsen d1b227f
Renamed dof_tools_fake.inst.in, added changelog entry
mathsen 7bda90f
Forgot to push dof_tools_common_fake_hp.h in last commit
mathsen 07e917a
added mpirun=1 so that test 12a just runs with MPI
mathsen 61f233a
fixed typo in include guard
mathsen e04d12b
Fixed regression with older compilers
mathsen File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) 2003 - 2018 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. | ||
// | ||
// --------------------------------------------------------------------- | ||
#include <deal.II/base/logstream.h> | ||
|
||
#include <deal.II/distributed/tria.h> | ||
|
||
#include <deal.II/dofs/dof_accessor.h> | ||
#include <deal.II/dofs/dof_handler.h> | ||
#include <deal.II/dofs/dof_tools.h> | ||
|
||
#include <deal.II/fe/fe_q.h> | ||
#include <deal.II/fe/mapping_q_generic.h> | ||
|
||
#include <deal.II/grid/grid_generator.h> | ||
#include <deal.II/grid/grid_out.h> | ||
#include <deal.II/grid/tria_iterator.h> | ||
|
||
#include <algorithm> | ||
#include <fstream> | ||
#include <iomanip> | ||
#include <string> | ||
|
||
#include "../tests.h" | ||
|
||
// check | ||
// DoFTools::extract_dofs as in dof_tools_12 in parallel for fewer elements | ||
|
||
void | ||
output_bool_vector(std::vector<bool> &v) | ||
{ | ||
for (unsigned int i = 0; i < v.size(); ++i) | ||
deallog << (v[i] ? '1' : '0'); | ||
deallog << std::endl; | ||
} | ||
|
||
|
||
template <int dim, typename DoFHandlerType> | ||
void | ||
check_this(const DoFHandlerType &dof_handler) | ||
{ | ||
IndexSet locally_relevant_dofs; | ||
DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs); | ||
|
||
std::vector<bool> selected_dofs(dof_handler.n_locally_owned_dofs()); | ||
std::vector<bool> mask(dof_handler.get_fe().n_components(), false); | ||
|
||
// only select first component | ||
mask[0] = true; | ||
DoFTools::extract_dofs(dof_handler, ComponentMask(mask), selected_dofs); | ||
if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0) | ||
{ | ||
output_bool_vector(selected_dofs); | ||
} | ||
|
||
// also select last component | ||
mask.back() = true; | ||
DoFTools::extract_dofs(dof_handler, ComponentMask(mask), selected_dofs); | ||
if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0) | ||
{ | ||
output_bool_vector(selected_dofs); | ||
} | ||
} | ||
|
||
|
||
template <int dim> | ||
void | ||
check(const FiniteElement<dim> &fe, const std::string &name) | ||
{ | ||
deallog << "Checking " << name << " in " << dim << "d:" << std::endl; | ||
|
||
// create tria and dofhandler | ||
// objects. set different boundary | ||
// and sub-domain ids | ||
parallel::distributed::Triangulation<dim> tria(MPI_COMM_WORLD); | ||
GridGenerator::hyper_cube(tria, 0., 1.); | ||
tria.refine_global(1); | ||
for (unsigned int ref = 0; ref < 2; ++ref) | ||
{ | ||
for (auto &cell : tria.active_cell_iterators()) | ||
if (cell->is_locally_owned() && cell->center()(0) < .5 && | ||
cell->center()(1) < .5) | ||
cell->set_refine_flag(); | ||
tria.execute_coarsening_and_refinement(); | ||
} | ||
|
||
DoFHandler<dim> dof_handler(tria); | ||
dof_handler.distribute_dofs(fe); | ||
|
||
// setup hp DoFHandler | ||
hp::FECollection<dim> fe_collection(fe); | ||
hp::DoFHandler<dim> hp_dof_handler(tria); | ||
hp_dof_handler.distribute_dofs(fe_collection); | ||
|
||
check_this<dim, DoFHandler<dim>>(dof_handler); | ||
check_this<dim, hp::DoFHandler<dim>>(hp_dof_handler); | ||
} | ||
|
||
|
||
#define CHECK(EL, deg, dim) \ | ||
{ \ | ||
FE_##EL<dim> EL(deg); \ | ||
check(EL, #EL #deg); \ | ||
} | ||
|
||
#define CHECK_ALL(EL, deg) \ | ||
{ \ | ||
CHECK(EL, deg, 2); \ | ||
CHECK(EL, deg, 3); \ | ||
} | ||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); | ||
mpi_initlog(); | ||
CHECK_ALL(Q, 1); | ||
|
||
CHECK_ALL(Q, 2); | ||
|
||
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,21 @@ | ||
|
||
DEAL::Checking Q1 in 2d: | ||
DEAL::111111111111111 | ||
DEAL::111111111111111 | ||
DEAL::111111111111111 | ||
DEAL::111111111111111 | ||
DEAL::Checking Q1 in 3d: | ||
DEAL::111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::Checking Q2 in 2d: | ||
DEAL::111111111111111111111111111111111111111111111 | ||
DEAL::111111111111111111111111111111111111111111111 | ||
DEAL::111111111111111111111111111111111111111111111 | ||
DEAL::111111111111111111111111111111111111111111111 | ||
DEAL::Checking Q2 in 3d: | ||
DEAL::11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 |
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,21 @@ | ||
|
||
DEAL::Checking Q1 in 2d: | ||
DEAL::11111111111111111111111111111111111111111 | ||
DEAL::11111111111111111111111111111111111111111 | ||
DEAL::11111111111111111111111111111111111111111 | ||
DEAL::11111111111111111111111111111111111111111 | ||
DEAL::Checking Q1 in 3d: | ||
DEAL::11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::Checking Q2 in 2d: | ||
DEAL::111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::Checking Q2 in 3d: | ||
DEAL::11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
DEAL::11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, you are only ever checking
FE_Q
elements, i.e. scalar ones with only one component. Thus, the size ofmask
is one and you are testing the same thing twice.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! You are absolutely right, I added vector valued elements and (most) of the elements of dof_tools_common.
I also use now "MPILogInitAll" to get the output of all processes, but, as you said, the selected_dofs vectors are just the locally owned vectors, which are not mapped to global DoF indices. I don't think that this is a problem in this testing scenario, or am I wrong there? Therefore I wouldn't change this, if there is no objection.
Greetings
Mathias
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's not a problem that you are considering the locally owned degrees of freedom. At least for me, it is just unintuitive that the vector returned doesn't correspond to actual degrees of freedoms but has to be mapped using the
IndexSet
of locally owned DoFs to make sense (with a distributed mesh). We often define a separate function returning anIndexSet
instead of astd::vector<bool>
when porting functions from serialTriangulations
to distributed ones. Of course, this behavior was pre-existing for the non-hp version and it's fine to extend that behavior to the hp case. Nevertheless, I would appreciate a comment in the documentation on how to interpret the returned object.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
masterleinad: OK, I understand. I explained this fact in the comment of the beginning of the test, or is there another place, where this should go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not being precise. Such a comment should go to
dealii/include/deal.II/dofs/dof_tools.h
Lines 1318 to 1350 in 6e6a2bf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't understand this, it was just "obvious" to me, that this is, what the function does. I have added a little note in the description and hope this is OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that looks OK. How did you verify the correctness of the test output? 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't... correct until someone else proofs the opposite ;)
//Edit: To be more precise, the main code change (extract_dofs()) works in a convergence test for me for a real world incompressible flow problem with a vector valued FE. So I strongly assume that the main change here does what it should do. Nevertheless I didn't check the output of the test file.