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

Remove old backward compatible code with Boundary #5932

Closed
wants to merge 4 commits into from

Conversation

luca-heltai
Copy link
Member

@luca-heltai luca-heltai commented Feb 20, 2018

Fixes #5931

@luca-heltai
Copy link
Member Author

/run-tests

@drwells
Copy link
Member

drwells commented Feb 20, 2018

9.0 is supposed to still support using Boundary objects. Does this break that support?

This should fix #5931 but I am not sure if it is possible to fix that bug and also preserve compatibility with the old way of doing curved boundaries.

@luca-heltai
Copy link
Member Author

we support Boundary objects. We no longer support curved parts of the domain defined by boundary_ids.
This was deprecated a long time ago.

@luca-heltai
Copy link
Member Author

that is, if you attach a boundary object, you can still do it, but you are now obliged to use manifold_ids and not boundary_ids.

@jppelteret
Copy link
Member

jppelteret commented Feb 20, 2018

Thanks @luca-heltai, that seems to have done the job. Do you mind if I push a unit test to your branch?

@luca-heltai
Copy link
Member Author

not at all. Go ahead!

@jppelteret
Copy link
Member

Whoops, there's a bit more fallout than I would have expected (or hoped for)... I guess @drwells was right about this breaking compatibility.

97% tests passed, 103 tests failed out of 3511

Total Test time (real) = 4349.56 sec

The following tests FAILED:
	 16 - numerics/no_flux_04.debug (Failed)
	 31 - numerics/no_flux_hp_03.debug (Failed)
	 33 - numerics/no_flux_hp_05.debug (Failed)
	 44 - numerics/no_flux_10.debug (Failed)
	 45 - numerics/normal_flux_03.debug (Failed)
	 47 - numerics/project_01_curved_boundary.debug (Failed)
	 50 - numerics/no_flux_15.debug (Failed)
	 57 - numerics/no_flux_03.debug (Failed)
	 77 - numerics/no_flux_hp_04.debug (Failed)
	 81 - numerics/no_flux_05.debug (Failed)
	114 - numerics/project_boundary_01.debug (Failed)
	178 - mappings/mapping.debug (Failed)
	213 - mappings/mapping_c1.debug (Failed)
	322 - dofs/range_based_for_step-6.debug (Failed)
	619 - multigrid/step-16-03.debug (Failed)
	648 - multigrid/step-16.debug (Failed)
	661 - multigrid/step-16-07.debug (Failed)
	684 - manifold/spherical_manifold_12.debug (Failed)
	685 - manifold/transfinite_manifold_02.debug (Failed)
	712 - manifold/spherical_manifold_10.debug (Failed)
	732 - manifold/spherical_manifold_09.debug (Failed)
	1143 - hp/project_01_curved_boundary.debug (Failed)
	1197 - hp/step-5.debug (Failed)
	1202 - hp/step-6.debug (Failed)
	1228 - hp/step-2.debug (Failed)
	1258 - hp/step-10.debug (Failed)
	1276 - hp/step-11.debug (Failed)
	1485 - codim_one/data_out_03.debug (Failed)
	1500 - codim_one/boundary_indicator_01.debug (Failed)
	1503 - codim_one/extract_boundary_mesh_02.debug (Failed)
	1516 - codim_one/extract_boundary_mesh_10.debug (Failed)
	1519 - codim_one/grid_refinement.debug (Failed)
	1532 - codim_one/extract_boundary_mesh_04.debug (Failed)
	1539 - codim_one/extract_boundary_mesh_03.debug (Failed)
	1540 - codim_one/mapping_02.debug (Failed)
	1544 - codim_one/transform_01.debug (Failed)
	1551 - codim_one/bem.debug (Failed)
	1725 - vector_tools/boundaries_complex_hp.debug (Failed)
	1729 - vector_tools/boundaries.debug (Failed)
	1730 - vector_tools/boundaries_complex.debug (Failed)
	1757 - grid/grid_transform_3d.debug (Failed)
	1818 - grid/grid_hyper_shell.debug (Failed)
	1843 - grid/grid_transform.debug (Failed)
	1848 - grid/grid_generator_01a.debug (Failed)
	1856 - grid/grid_output_input.debug (Failed)
	1858 - grid/grid_generator_01b.debug (Failed)
	1859 - grid/grid_tools_03.debug (Failed)
	1872 - grid/grid_hyper_shell_05.debug (Failed)
	1885 - grid/grid_hyper_shell_03.debug (Failed)
	1901 - grid/grid_out.debug (Failed)
	1913 - grid/grid_transform_coefficient.debug (Failed)
	1938 - grid/merge_triangulations_03.debug (Failed)
	1948 - grid/grid_hyper_shell_04.debug (Failed)
	1949 - grid/grid_hyper_shell_02.debug (Failed)
	2316 - fe/fe_dgq_hessian_divergence_theorem.debug (Failed)
	2328 - fe/fe_q_gradient_divergence_theorem.debug (Failed)
	2333 - fe/cell_similarity_08.debug (Failed)
	2338 - fe/cell_similarity_dgp_nonparametric_05.debug (Failed)
	2350 - fe/fe_nedelec_hessian_divergence_theorem.debug (Failed)
	2376 - fe/cell_similarity_dgp_nonparametric_07.debug (Failed)
	2391 - fe/fe_q_hessian_divergence_theorem.debug (Failed)
	2410 - fe/cell_similarity_05.debug (Failed)
	2429 - fe/cell_similarity_dgp_nonparametric_06.debug (Failed)
	2452 - fe/fe_q_hierarchical_3rd_derivative_divergence_theorem.debug (Failed)
	2459 - fe/cell_similarity_dgp_monomial_06.debug (Failed)
	2466 - fe/cell_similarity_dgp_nonparametric_08.debug (Failed)
	2467 - fe/cell_similarity_dgp_monomial_05.debug (Failed)
	2483 - fe/fe_nedelec_gradient_divergence_theorem.debug (Failed)
	2487 - fe/cell_similarity_dgp_monomial_08.debug (Failed)
	2488 - fe/cell_similarity_11.debug (Failed)
	2519 - fe/fe_dgp_3rd_derivative_divergence_theorem.debug (Failed)
	2530 - fe/fe_system_3rd_derivative_divergence_theorem.debug (Failed)
	2552 - fe/fe_q_3rd_derivative_divergence_theorem.debug (Failed)
	2582 - fe/fe_dgq_gradient_divergence_theorem.debug (Failed)
	2632 - fe/fe_dgq_3rd_derivative_divergence_theorem.debug (Failed)
	2641 - fe/cell_similarity_dgp_monomial_07.debug (Failed)
	2644 - fe/cell_similarity_06.debug (Failed)
	2659 - fe/cell_similarity_07.debug (Failed)
	2663 - bits/step-6-racoptimize-2.debug (Failed)
	2707 - bits/cone_04.debug (Failed)
	2721 - bits/step-10-high-order.debug (Failed)
	2763 - bits/joa_1.debug (Failed)
	2791 - bits/find_cell_13.debug (Failed)
	2795 - bits/cylinder_02.debug (Failed)
	2804 - bits/find_cell_alt_7.debug (Failed)
	2810 - bits/cylinder_04.debug (Failed)
	2814 - bits/step-5.debug (Failed)
	2822 - bits/step-6.debug (Failed)
	2823 - bits/cylinder_01.debug (Failed)
	2852 - bits/cone_03.debug (Failed)
	2856 - bits/volume_2.debug (Failed)
	2862 - bits/find_cell_alt_1.debug (Failed)
	2868 - bits/step-2.debug (Failed)
	2878 - bits/cone_02.debug (Failed)
	2880 - bits/find_cell_1.debug (Failed)
	2896 - bits/cone_01.debug (Failed)
	2904 - bits/find_cell_2.debug (Failed)
	2907 - bits/step-10.debug (Failed)
	2911 - bits/volume_3.debug (Failed)
	2912 - bits/step-6-racoptimize.debug (Failed)
	2915 - bits/find_cell_alt_2.debug (Failed)
	2925 - bits/step-11.debug (Failed)
	2941 - bits/cylinder_03.debug (Failed)
Errors while running CTest

@jppelteret jppelteret added the WIP label Feb 20, 2018
@drwells
Copy link
Member

drwells commented Feb 21, 2018

I took a look at grid/grid_out.cc. It looks like most of these tests fail because GridGenerator sets boundary IDs which were (before this PR) used as manifold IDs (for curving the boundary).

@luca-heltai
Copy link
Member Author

luca-heltai commented Feb 21, 2018

It looks like most of these tests fail because GridGenerator sets boundary IDs which were (before this PR) used as manifold IDs (for curving the boundary).

Well, this is behaviour that has to change. GridGenerator should also set manifold_ids. Since now we know that we can use both, at the end of every generated grid, I'd simply copy the boundary ids over to the manifold ids.

@jppelteret
Copy link
Member

I agree with @luca-heltai. The colorize flag should colourise the boundary and manifold IDs (and we should state that this is the case).

@jppelteret jppelteret self-requested a review February 27, 2018 20:59
@jppelteret
Copy link
Member

Thanks for working on the broken tests and documentation @luca-heltai. I'd like to have a look through the changes, but only tomorrow if you don't mind.

@luca-heltai
Copy link
Member Author

I'll let the tester talk. There will be other broken tests, I fear. i didn't check them all. Hopefully less than what they were...
:)

@jppelteret
Copy link
Member

Well, if there are more tests that need some TLC then I'll try to contribute some fixes as well.

@jppelteret
Copy link
Member

Arg, so much for getting to this yesterday. Sorry :-/ I will endeavour to fix some of the tests on the weekend...

@jppelteret
Copy link
Member

@luca-heltai I think that we'll have to adjust the remaining tests by hand. I guess that many of them rely on the boundary and manifold ID's automatically having the same value, regardless of the colorize flag being used. e.g. in vector_tools/boundaries.debug:

  if (dim==2)
    {
      GridGenerator::hyper_ball(tr, Point<dim>(), 1);
    }
  else
    GridGenerator::hyper_cube(tr, -1./std::sqrt(static_cast<double>(dim)),1./std::sqrt(static_cast<double>(dim)));
  // GridTools::copy_boundary_to_manifold_id(tr); // Should slot this in here
  static const SphericalManifold<dim> boundary;
  if (dim != 1)
    {
      tr.set_manifold (0, boundary);
    }

I'll try to work through these during the course of the week.

@luca-heltai
Copy link
Member Author

@jppelteret I'm not sure what to do... the main source of troubles stems from the fact that the default boundary indicator is 0 for all grids, while the default manifold indicator is numbers::flat_manifold_indicator (which is incidentally the same as numbers::invalid_manifold_indicator).

Should we make the decision that the default manifold indicator on the boundary should be 0? If this is so, there is one single place to change, which is when we create the triangulation and the initial manifold indicator on the boundary faces.

I would be in favour of having the user specify explicitly a manifold indicator, if he so wishes, either by setting colorize to true, or by doing it by hand.

@luca-heltai
Copy link
Member Author

The second choice is naturally more expensive... we'd have to change manually 100 tests...

@jppelteret
Copy link
Member

Should we make the decision that the default manifold indicator on the boundary should be 0? If this is so, there is one single place to change, which is when we create the triangulation and the initial manifold indicator on the boundary faces.

I think that this would be a safe thing to do since 0 is a reserved indicator id (to the best of my recollection, you can't call set_boundary_id(0)). So I am in favour of doing this, and it certainly wouldn't conflict with what I had presented in #5931.

@bangerth
Copy link
Member

bangerth commented Mar 6, 2018 via email

@luca-heltai
Copy link
Member Author

I agree with you @bangerth , that's why I have not yet really put myself into this PR...

What is your suggestion? Would you agree that colorize should assign both manifold and boundary ids? This seems reasonable (and this PR does only this, so far), so users can attach manifolds to the boundary, and/or use boundary conditions judiciously.

The main problem lies in the fact that most of our tests exploit the old convention. I'm willing to add all necessary calls to copy_boundary_to_manifold_ids in the tests, if this is the right way to go...

@bangerth
Copy link
Member

bangerth commented Mar 6, 2018 via email

@jppelteret
Copy link
Member

Independent of the question in the user group this morning, I started thinking about this again. My first thought was that we could do is adjust to boundary to manifold id copy function in GridTools to

  template <int dim, int spacedim>
  void copy_boundary_to_manifold_id(Triangulation<dim, spacedim> &tria,
                                    const bool reset_boundary_ids=false,
                                    const bool retain_flat_manifold_ids=true);

but I don't think that this would work for GridGenerator::hyper_cube_with_cylindrical_hole that has a mix of flat and curved boundaries. But maybe introducing a filter like

  template <int dim, int spacedim>
  void copy_boundary_to_manifold_id(Triangulation<dim, spacedim> &tria,
                                    const std::vector<types::boundary_id> retain_flat_manifold_id_on_boundary,
                                    const bool reset_boundary_ids=false);

would be more flexible. I'd be happy to implement and integrate this if its agreed to be the right approach.

@jppelteret
Copy link
Member

Correction: I meant

const std::set<types::boundary_id> retain_flat_manifold_id_on_boundary

To be more general, this parameter could be called retain_manifold_id_on_boundary just in case we ever introduce other special manifold id's (we currently have flat_manifold_id == invalid_manifold_id).

@jppelteret jppelteret added this to the Release 9.0 milestone Mar 29, 2018
@drwells
Copy link
Member

drwells commented Apr 5, 2018

I suspect that I will be outvoted on this one (which is fine) but I would like to at least state my opinion regarding how we should proceed.

The proposed compatibility break is very large. I suspect that users are already working around this bug in their own grid generator functions and changing the colorization and boundary handling will change their code. I know that we deprecated this behavior a long time ago, but given the large number of failing tests (and the fact that we need to redo boundary/manifold ID handling for all GridGenerator functions) I think it would be best to leave this bug alone for 9.0 and then break everything at once when we remove Boundary and related classes in 9.1.

@luca-heltai
Copy link
Member Author

@drwells , I think this has waited long enough. I think we ought to have a solid distinction between Manifolds and boundary conditions in 9.0.
We have been trying to keep backward compatibility since 8.4, and this has lead to many places that do the same thing in slightly different ways, and many unresolved issues and bugs.

I personally think that we should not fear breaking compatibility in our test suite. It is good that 100 tests fail, because it means we are stressing this part of the library at least with 100 different tests.

I'd vote the following

  • detach Manifolds from boundary_ids (currently this is false for backward compatibility with 8.4, and this PR would fix this point)
  • get Clone manifolds + std::unique_ptr in Tria #6182 merged
  • Add to each Triangulation we create internally the correct manifold, with manifold ids and boundary ids independent on one-another, and document what manifold_ids and what manifolds are used in the documentation
  • Let the colorize flag be used only for boundary conditions

@bangerth
Copy link
Member

bangerth commented Apr 7, 2018

I agree with all of this. In particular, I'm in favor of completely separating boundary indicators and manifold ids. The fact that we ever treated them the same is a historical accident, and at one point or other, we will have to bite the bullet and make them separate.

The question is then just how we deal with the large number of failing tests.

@bangerth bangerth mentioned this pull request Apr 7, 2018
Copy link
Member

@bangerth bangerth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked this through and I like it. If we can find a way to fix up the various tests, that would be fantastic and then this can be merged.

@luca-heltai -- I particularly appreciate you taking the time to properly document what each of the grid generator functions does with the boundary and manifold ids.

@luca-heltai
Copy link
Member Author

I'm waiting for #6182 to be merged, before I proceed with this.

@drwells
Copy link
Member

drwells commented Apr 12, 2018

It looks like the consensus is to go forward with this change.

We need to fix 94 failing tests: I am willing to help with thi process. How about I fix the tests in bits/ and get a commit merged onto this branch?

@luca-heltai
Copy link
Member Author

before we proceed, let me make an alternative PR, where I don't simply copy over, but make sure that manifold ids are set if and only if they are necessary.

@tjhei
Copy link
Member

tjhei commented Apr 12, 2018

In particular, I'm in favor of completely separating boundary indicators and manifold ids.

Yes, that makes sense. Things to keep in mind:

  1. How do you handle import from files? Often, file formats only support a single id for faces (for example gmsh physical objects). Is this boundary, manifold, or both?
  2. How do you handle colorize true/false?

But then that doesn't seem to apply to cases such as hyper_cube(). Maybe the
concept of colorization wasn't fully thought through?

I think it is annoying having to manually assign different boundary ids after the fact but it is also annoying having to specify boundary conditions for a colorized hyper_cube if you just want Dirichlet conditions. Maybe we could switch to always colorize if we had some more convenience functions like "all boundaries" or "boundaries {1,4,5,6}".

Another thought might be what we do in ASPECT: we give string names to the individual boundaries (like "left", "cylinder", etc.). Internally, they could be mapped back to ids...

@luca-heltai
Copy link
Member Author

How do you handle import from files? Often, file formats only support a single id for faces (for example gmsh physical objects). Is this boundary, manifold, or both?

for now, this is just boundary. We could (in the future), allow one to set input flags to import single ids as manifold instead. For the moment no attempt at traducing this to manifold information was done.

How do you handle colorize true/false?

The same way it was done before. Simply now it has to be interpreted as something related to boundary conditions only, and has nothing to do with geometry.

But then that doesn't seem to apply to cases such as hyper_cube(). Maybe the
concept of colorization wasn't fully thought through?

This was my main reason to rethink this PR and go towards #6233. Colorize should be used for boundary ids. There is no need to colorise manifold ids. We know what geometry we are generating, so the manifold is always set to the correct value, and the right Manifold is attached, for each triangulation we construct.

I think it is annoying having to manually assign different boundary ids after the fact but it is also annoying having to specify boundary conditions for a colorized hyper_cube if you just want Dirichlet conditions. Maybe we could switch to always colorize if we had some more convenience functions like "all boundaries" or "boundaries {1,4,5,6}".

Maybe not in this PR... what we want to do for boundary condition indicators should have nothing to do with manifold indicators, and PR #6233 does not impact any decision you may want to take later on for boundary ids.

Another thought might be what we do in ASPECT: we give string names to the individual boundaries (like "left", "cylinder", etc.). Internally, they could be mapped back to ids...

Again, maybe not in this PR.

@drwells
Copy link
Member

drwells commented Apr 14, 2018

I am trying to get up to date with these boundary patches. Does #6233 supercede this PR?

@luca-heltai luca-heltai deleted the fix-manifold branch April 11, 2020 16:22
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

6 participants