Periodic Boundary conditions on Step-3 tutorial with dim != spacedim

47 views
Skip to first unread message

Malhar T.

unread,
Nov 22, 2020, 4:10:56 PM11/22/20
to deal.II User Group
Hello All !

I was trying the step-3 with periodic boundary conditions and dim = 2 and spacedim = 3. The main reason behind this is I want to test periodic boundary conditions for dim != spacedim. I have tested the code for dim = spacedim = 2 and the periodic boundary conditions and it works (never mind the results for now !). I have also tested the code for dim = 2 and spacedim = 3 without periodic boundary conditions and it works too. But only when I add periodic conditions for that case, the issue arises.

I got the following error,
error: undefined reference to 'void dealii::DoFTools::make_periodicity_constraints<2, 3, double>(dealii::DoFHandler<2, 3> const&, unsigned int, unsigned int, unsigned int, dealii::AffineConstraints<double>&, dealii::ComponentMask const&, double)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/step1.dir/build.make:139: step1] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/step1.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
​
The version that I am using is 9.3.0-pre. Although I am not really great at C++ but according to the template and source, it should have worked, but I could not find anything here. I tried running it without template arguments or with only '2' as a template argument, but couldn't make it work. I have attached the code which I have tried, and also the code dim = 2 and spacedim = 3 without periodic boundary conditions. Any help will be greatly appreciated.

Thank You
step-3WithPBC.cpp
step-3WithoutPBC.cpp

Timo Heister

unread,
Nov 22, 2020, 7:44:26 PM11/22/20
to dea...@googlegroups.com
Hi Malhar,

if you look at
https://github.com/dealii/dealii/blob/a56c8585863b774de9dce5f7dd5c334ef56f3a51/source/dofs/dof_tools_constraints.inst.in#L69

you can see that it is only instantiated for
DoFHandler<deal_II_dimension>
meaning only for dim=spacedim (the second argument is the default right now).

Instead, we would need to move the instantiation down into a loop that
has two loops over dim and instantiate it for all pairs like it is
done for
https://github.com/dealii/dealii/blob/a56c8585863b774de9dce5f7dd5c334ef56f3a51/source/dofs/dof_tools_constraints.inst.in#L123

Do you want to try if you can make this work? I am not sure if the
implementation will work correctly, but we can check that in a second
step.
If this works, we would appreciate a pull request from you to fix this!

Best,
Timo
> --
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
> ---
> You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/e11a9f41-4750-459d-bedc-ef0b3ae83dddn%40googlegroups.com.



--
Timo Heister
http://www.math.clemson.edu/~heister/

Malhar T.

unread,
Nov 23, 2020, 3:54:45 AM11/23/20
to deal.II User Group
Hello Timo,
Thank you for your reply. Yeah, I would definitely like try and make it work. So, what I did was, I made some small changes in the file 'dof_tools_constraints.inst.in '.
I just added spacedim loop for the first two 'for loop' blocks.
This is how it looks after the changes,
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
  {

#if deal_II_dimension <= deal_II_space_dimension
    template void DoFTools::make_periodicity_constraints(
      const DoFHandler<deal_II_dimension, deal_II_space_dimension>::face_iterator &,
      const DoFHandler<deal_II_dimension, deal_II_space_dimension>::face_iterator &,
      AffineConstraints<double> &,
      const ComponentMask &,
      bool,
      bool,
      bool,
      const FullMatrix<double> &,
      const std::vector<unsigned int> &,
     const double);

#ifdef DEAL_II_WITH_COMPLEX_VALUES
    template void DoFTools::make_periodicity_constraints(
      const DoFHandler<deal_II_dimension, deal_II_space_dimension>::face_iterator &,
      const DoFHandler<deal_II_dimension, deal_II_space_dimension>::face_iterator &,
      AffineConstraints<std::complex<double>> &,
      const ComponentMask &,
      bool,
      bool,
      bool,
      const FullMatrix<double> &,
      const std::vector<unsigned int> &,
      std::complex<double>);
#endif

#endif
  }

for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
  {

#if deal_II_dimension <= deal_II_space_dimension

    template void DoFTools::make_periodicity_constraints<deal_II_dimension,
                                                         deal_II_space_dimension,
                                                         double>(
      const std::vector<GridTools::PeriodicFacePair<
        DoFHandler<deal_II_dimension, deal_II_space_dimension>::cell_iterator>> &,
      AffineConstraints<double> &,
      const ComponentMask &,
      const std::vector<unsigned int> &,
      const double);

#ifdef DEAL_II_WITH_COMPLEX_VALUES
    template void DoFTools::make_periodicity_constraints<deal_II_dimension,
                                                         deal_II_space_dimension,
                                                         std::complex<double>>(
      const std::vector<GridTools::PeriodicFacePair<
        DoFHandler<deal_II_dimension, deal_II_space_dimension>::cell_iterator>> &,
      AffineConstraints<std::complex<double>> &,
      const ComponentMask &,
      const std::vector<unsigned int> &,
      const std::complex<double>);
#endif

    template void DoFTools::make_periodicity_constraints(
      const DoFHandler<deal_II_dimension, deal_II_space_dimension> &,
      const types::boundary_id,
      const types::boundary_id,
      const unsigned int,
      AffineConstraints<double> &,
      const ComponentMask &,
      const double);

#ifdef DEAL_II_WITH_COMPLEX_VALUES
    template void DoFTools::make_periodicity_constraints(
      const DoFHandler<deal_II_dimension, deal_II_space_dimension> &,
      const types::boundary_id,
      const types::boundary_id,
      const unsigned int,
      AffineConstraints<std::complex<double>> &,
      const ComponentMask &,
      const std::complex<double>);
#endif

    template void DoFTools::make_periodicity_constraints(
      const DoFHandler<deal_II_dimension, deal_II_space_dimension> &,
      const types::boundary_id,
      const unsigned int,
      AffineConstraints<double> &,
      const ComponentMask &,
      const double);

#ifdef DEAL_II_WITH_COMPLEX_VALUES
    template void DoFTools::make_periodicity_constraints(
      const DoFHandler<deal_II_dimension, deal_II_space_dimension> &,
      const types::boundary_id,
      const unsigned int,
      AffineConstraints<std::complex<double>> &,
      const ComponentMask &,
      const std::complex<double>);

#endif
#endif
  }
​
Although the build was successful, I am not sure how to check if its implemented correctly or not. One more slightly basic question, do I need to build all the other files if I only changed this one file? Does it not detect that only one file was changed? This is the way one goes about changing stuff right?

Also, I will be sure to put a pull request if it works.

Thank You

Timo Heister

unread,
Nov 23, 2020, 9:48:54 AM11/23/20
to dea...@googlegroups.com
> Thank you for your reply. Yeah, I would definitely like try and make it work. So, what I did was, I made some small changes in the file 'dof_tools_constraints.inst.in '.
> I just added spacedim loop for the first two 'for loop' blocks.

Yes, this is probably all that is needed.

> Although the build was successful, I am not sure how to check if its implemented correctly or not.

I would typically go about this in the following ways:
1. Look over the implementation and think about if the operations make sense.
2. Create a small test, run it, and make sure you are not running into
Assert/crashes.
3. Set up a test problem where you can verify that things work correctly.

It sounds like you should be able to make 2) and 3) work with the
modified step-3 that you posted.

One more slightly basic question, do I need to build all the other
files if I only changed this one file? Does it not detect that only
one file was changed? This is the way one goes about changing stuff
right?

If you run "make", we automatically detect everything that needs to be
rebuilt and do exactly that. You might need a "make install" as well,
depending on how you specify the location of your deal.II library.

> Also, I will be sure to put a pull request if it works.

Awesome! Let us know if you need help at any point.
Reply all
Reply to author
Forward
0 new messages