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

Test extract constant modes 04 #13513

Closed
wants to merge 6 commits into from
Closed

Test extract constant modes 04 #13513

wants to merge 6 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Mar 8, 2022

This PR provides as first step towards the solution of #12854 a currently failing test for the function extract_constant_modes. Thanks to @sebproell the problem with either FE_Q or FE_Nothing was solved in #13313, however, in my multiphysics problem I have a vector-valued problem, where I use a FESystem similar to step-46 (Q_1 x Z , Z x Q_1). This testcase throws the following assert message:

An error occurred in line <2489> of file <../source/fe/fe_system.cc> in function
    std::pair<dealii::Table<2, bool>, std::vector<unsigned int> > dealii::FESystem<dim, spacedim>::get_constant_modes() const [with int dim = 2; int spacedim = 2]
The violated condition was: 
    ::dealii::deal_II_exceptions::internals::compare_for_equality(components.size(), constant_modes.n_rows())
Additional information: 
    Dimension 1 not equal to 2.
Stacktrace:
-----------
#0  /usr/local/lib/libdeal_II.g.so.10.0.0-pre: dealii::FESystem<2, 2>::get_constant_modes() const
#1  /usr/local/lib/libdeal_II.g.so.10.0.0-pre: void dealii::DoFTools::extract_constant_modes<2, 2>(dealii::DoFHandler<2, 2> const&, dealii::ComponentMask const&, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >&)

@marcfehling
Copy link
Member

You also need to add an output file that contains the expected output. Otherwise your test won't be picked up by the testsuite. See also here.

@drwells drwells added the Tests label Mar 9, 2022
@peterrum
Copy link
Member

@gfcas?

@peterrum peterrum added this to the Release 9.4 milestone Apr 24, 2022
@ghost
Copy link
Author

ghost commented Apr 26, 2022

I know this is still open, but I don't have time for it currently, unfortunately. I would still like to contribute.
I'll see what I can do.

@ghost
Copy link
Author

ghost commented May 11, 2022

@peterrum maybe you can postpone the milestone to a later verison. The test case I considered would introduce a possible failing test and at the moment I can not garantuee to be finisched for the release. Sorry!

@peterrum peterrum modified the milestones: Release 9.4, Release 9.5 May 11, 2022
@ghost
Copy link
Author

ghost commented May 18, 2022

Now I had some time to learn the testsuite and got this test ready even before the 9.4 release. However, the test should currently fail as this case is not yet implemented.

Instead of

DoFTools::extract_constant_modes(dof_handler, component_mask, constant_modes);

I used the following piece of code to generate the output as it should be:

{
   const IndexSet index_set =
     DoFTools::extract_dofs(dof_handler, component_mask);

   AssertDimension(constant_modes[component].size(),
                   dof_handler.n_locally_owned_dofs());
   for (unsigned int i = 0; i < dof_handler.n_locally_owned_dofs(); ++i)
     {
       if (index_set.is_element(i))
         {
           constant_modes[component][i] = true;
         }
       else
         {
           constant_modes[component][i] = false;
         }
     }
}

@ghost
Copy link
Author

ghost commented May 18, 2022

Now there is also a parallel test ready. @marcfehling @peterrum what's your opinion?

@ghost
Copy link
Author

ghost commented May 19, 2022

Sorry, I noticed still an error in the manual extraction. The supposed output is now updated and for completeness the manual code snippet is:

// Define set of constant modes
  std::vector<std::vector<bool>> constant_modes(
    fe_collection.n_components(),
    std::vector<bool>(dof_handler.n_locally_owned_dofs(), false));

  // Extract constant modes manually
  for (unsigned int component = 0; component < fe_collection.n_components();
       ++component)
    {
      AssertDimension(constant_modes[component].size(),
                      dof_handler.n_locally_owned_dofs());

      const FEValuesExtractors::Scalar component_extractor(component);
      const ComponentMask              component_mask(
        fe_collection.component_mask(component_extractor));

      const IndexSet component_index_set =
        DoFTools::extract_dofs(dof_handler, component_mask);

      for (unsigned int i = 0;
           i < dof_handler.locally_owned_dofs().n_elements();
           ++i)
        {
          if (component_index_set.is_element(
                dof_handler.locally_owned_dofs().nth_index_in_set(i)))
            {
              constant_modes[component][i] = true;
            }
          else
            {
              constant_modes[component][i] = false;
            }
        }
    }

@ghost
Copy link
Author

ghost commented May 19, 2022

The tests of course fail at the moment, as this feature is not yet implemented.

@ghost
Copy link
Author

ghost commented Dec 1, 2022

Unfortunately I have currently no time to work on this. I close this and think again on this problem.

@ghost ghost closed this Dec 1, 2022
@ghost ghost deleted the test_extract_constant_modes_04 branch December 1, 2022 14:30
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants