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

Port preCICE integration to version 3 #666

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

davidscn
Copy link
Contributor

@davidscn davidscn commented Jun 5, 2024

Since a while already, preCICE version 3 is released. This is a breaking release with a couple of changes.

The new preCICE API interface uses std::span to interface with user-provided vectors, which becomes a bit ugly in the current implementation, as we don't use and pass over full vectors, but we use a static array and only pass the 'active' entries over to preCICE, necessitating to specify the span range manually. I kept it in this way to make the migration a pure technical one.

While running the test case for the preCICE coupling, the fluid solver segfaulted at timestep number two somehwere in ExaDG. Since I don't have Trilinos compiled into my local deal.II, I tried using MultigridCoarseGridPreconditioner::PointJacobi (the AMG requires Trilinos). My best guess is that this causes trouble in the SolverCG (this is at least, where the segfault stems from), maybe it's not even supported. I need to take a closer look.

preCICE version 3 now also supports a proper time interpolation for coupling data. Therefore, I have to update the handling of time-related data later on to make this work with ExaDG and adaptive timestepping. Maybe I will open an issue on this, as I am not sure (a) where the BDF time integrator evaluates the spatial operator in time, i.e., at which time the coupling data has to be retrieved from preCICE and (b) where the time-step size calculation takes place in ExaDG and how to synchronize it with preCICE.

Still, I would first consider to pursue the technical update before adding new features.

@davidscn
Copy link
Contributor Author

davidscn commented Jun 5, 2024

Hm compiling and running the whole setup in debug gives me

dealii/source/grid/tria.cc> in function
    const dealii::Manifold<dim, spacedim>& dealii::Triangulation<dim, spacedim>::get_manifold(dealii::types::manifold_id) const [with int dim = 2; int spacedim = 2; dealii::types::manifold_id = unsigned int]
Additional information: 
    No manifold of the manifold id 0 has been attached to the
    triangulation. Please attach the right manifold with
    Triangulation::set_manifold().

but even attaching some manifold in create_grid doesn't resolve the issue. I think there might be some helper triangulation in one of the utility functions called, which is lacking a manifold, but I can't figure out where (and which setting necessitates the manifold).

@kronbichler
Copy link
Contributor

I did fix one of those cases in #667 - is that the place you were looking at? If not, I am happy to check in other places as well.

@davidscn
Copy link
Contributor Author

davidscn commented Jun 6, 2024

I was looking at the perpendicular flap case. Trying the same as you suggested (using numbers::flat_manifold_id) doesn't resolve the issue here. I can also provide the full stacktrace, although it is a bit messy:

  Viscous step:
  Solver viscous step:                       CG
  Maximum number of iterations:              1000
  Absolute solver tolerance:                 1.0000e-08
  Relative solver tolerance:                 1.0000e-06
  Maximum size of Krylov space:              30
  Preconditioner viscous step:               PointJacobi
  Update preconditioner viscous:             false

--------------------------------------------------------
An error occurred in line <12502> of file <~/dealii/source/grid/tria.cc> in function
    const dealii::Manifold<dim, spacedim>& dealii::Triangulation<dim, spacedim>::get_manifold(dealii::types::manifold_id) const [with int dim = 2; int spacedim = 2; dealii::types::manifold_id = unsigned int]
Additional information: 
    No manifold of the manifold id 0 has been attached to the
    triangulation. Please attach the right manifold with
    Triangulation::set_manifold().

Stacktrace:
-----------
#0  ~/dealii/build/lib/libdeal_II.g.so.9.6.0-pre: dealii::Triangulation<2, 2>::get_manifold(unsigned int) const
#1  ~/dealii/build/lib/libdeal_II.g.so.9.6.0-pre: dealii::TriaAccessor<1, 2, 2>::get_manifold() const
#2  ~/dealii/build/lib/libdeal_II.g.so.9.6.0-pre: 
#3  ~/dealii/build/lib/libdeal_II.g.so.9.6.0-pre: 
#4  ~/dealii/build/lib/libdeal_II.g.so.9.6.0-pre: dealii::TriaAccessor<1, 2, 2>::center(bool, bool) const
#5  ~/dealii/build/lib/libdeal_II.g.so.9.6.0-pre: dealii::Triangulation<2, 2>::DistortedCellList dealii::internal::TriangulationImplementation::Implementation::execute_refinement_isotropic<2, 2>(dealii::Triangulation<2, 2>&, bool)
#6  ~/dealii/build/lib/libdeal_II.g.so.9.6.0-pre: dealii::Triangulation<2, 2>::DistortedCellList dealii::internal::TriangulationImplementation::Implementation::execute_refinement<2>(dealii::Triangulation<2, 2>&, bool)
#7  ~/dealii/build/lib/libdeal_II.g.so.9.6.0-pre: dealii::internal::TriangulationImplementation::PolicyWrapper<2, 2, dealii::internal::TriangulationImplementation::Implementation>::execute_refinement(dealii::Triangulation<2, 2>&, bool)
#8  ~/dealii/build/lib/libdeal_II.g.so.9.6.0-pre: dealii::Triangulation<2, 2>::execute_refinement()
#9  ~/dealii/build/lib/libdeal_II.g.so.9.6.0-pre: dealii::Triangulation<2, 2>::execute_coarsening_and_refinement()
#10  ~/dealii/build/lib/libdeal_II.g.so.9.6.0-pre: dealii::parallel::distributed::Triangulation<2, 2>::copy_local_forest_to_triangulation()
#11  ~/dealii/build/lib/libdeal_II.g.so.9.6.0-pre: dealii::parallel::distributed::Triangulation<2, 2>::execute_coarsening_and_refinement()
#12  ~/dealii/build/lib/libdeal_II.g.so.9.6.0-pre: dealii::Triangulation<2, 2>::refine_global(unsigned int)
#13  ~/exadg/build_debug/applications/fluid_structure_interaction/perpendicular_flap/solver_precice: ExaDG::FluidFSI::Application<2, double>::create_grid(ExaDG::Grid<2>&, std::shared_ptr<dealii::Mapping<2, 2> >&, std::shared_ptr<ExaDG::MultigridMappings<2, double> >&)::{lambda(dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&)#1}::operator()(dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&) const
#14  ~/exadg/build_debug/applications/fluid_structure_interaction/perpendicular_flap/solver_precice: void std::__invoke_impl<void, ExaDG::FluidFSI::Application<2, double>::create_grid(ExaDG::Grid<2>&, std::shared_ptr<dealii::Mapping<2, 2> >&, std::shared_ptr<ExaDG::MultigridMappings<2, double> >&)::{lambda(dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&)#1}&, dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&>(std::__invoke_other, ExaDG::FluidFSI::Application<2, double>::create_grid(ExaDG::Grid<2>&, std::shared_ptr<dealii::Mapping<2, 2> >&, std::shared_ptr<ExaDG::MultigridMappings<2, double> >&)::{lambda(dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&)#1}&, dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int&&, std::vector<unsigned int, std::allocator<unsigned int> > const&)
#15  ~/exadg/build_debug/applications/fluid_structure_interaction/perpendicular_flap/solver_precice: std::enable_if<is_invocable_r_v<void, ExaDG::FluidFSI::Application<2, double>::create_grid(ExaDG::Grid<2>&, std::shared_ptr<dealii::Mapping<2, 2> >&, std::shared_ptr<ExaDG::MultigridMappings<2, double> >&)::{lambda(dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&)#1}&, dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&>, void>::type std::__invoke_r<void, ExaDG::FluidFSI::Application<2, double>::create_grid(ExaDG::Grid<2>&, std::shared_ptr<dealii::Mapping<2, 2> >&, std::shared_ptr<ExaDG::MultigridMappings<2, double> >&)::{lambda(dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&)#1}&, dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&>(ExaDG::FluidFSI::Application<2, double>::create_grid(ExaDG::Grid<2>&, std::shared_ptr<dealii::Mapping<2, 2> >&, std::shared_ptr<ExaDG::MultigridMappings<2, double> >&)::{lambda(dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&)#1}&, dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int&&, std::vector<unsigned int, std::allocator<unsigned int> > const&)
#16  ~/exadg/build_debug/applications/fluid_structure_interaction/perpendicular_flap/solver_precice: std::_Function_handler<void (dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&), ExaDG::FluidFSI::Application<2, double>::create_grid(ExaDG::Grid<2>&, std::shared_ptr<dealii::Mapping<2, 2> >&, std::shared_ptr<ExaDG::MultigridMappings<2, double> >&)::{lambda(dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&)#1}>::_M_invoke(std::_Any_data const&, dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int&&, std::vector<unsigned int, std::allocator<unsigned int> > const&)
#17  ~/exadg/build_debug/applications/fluid_structure_interaction/perpendicular_flap/solver_precice: std::function<void (dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&)>::operator()(dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > >, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::TriaIterator<dealii::CellAccessor<2, 2> > > > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&) const
#18  ~/exadg/build_debug/applications/fluid_structure_interaction/perpendicular_flap/solver_precice: void ExaDG::GridUtilities::create_triangulation<2>(std::shared_ptr<dealii::Triangulation<2, 2> >&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::Triangulation<2, 2>::cell_iterator>, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::Triangulation<2, 2>::cell_iterator> > >&, ompi_communicator_t* const&, ExaDG::GridData const&, bool, std::function<void (dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::Triangulation<2, 2>::cell_iterator>, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::Triangulation<2, 2>::cell_iterator> > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&)> const&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&)
#19  ~/exadg/build_debug/applications/fluid_structure_interaction/perpendicular_flap/solver_precice: void ExaDG::GridUtilities::create_triangulation_with_multigrid<2>(ExaDG::Grid<2>&, ompi_communicator_t* const&, ExaDG::GridData const&, bool, std::function<void (dealii::Triangulation<2, 2>&, std::vector<dealii::GridTools::PeriodicFacePair<dealii::Triangulation<2, 2>::cell_iterator>, std::allocator<dealii::GridTools::PeriodicFacePair<dealii::Triangulation<2, 2>::cell_iterator> > >&, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> > const&)> const&, std::vector<unsigned int, std::allocator<unsigned int> >)
#20  ~/exadg/build_debug/applications/fluid_structure_interaction/perpendicular_flap/solver_precice: ExaDG::FluidFSI::Application<2, double>::create_grid(ExaDG::Grid<2>&, std::shared_ptr<dealii::Mapping<2, 2> >&, std::shared_ptr<ExaDG::MultigridMappings<2, double> >&)
#21  ~/exadg/build_debug/applications/fluid_structure_interaction/perpendicular_flap/solver_precice: ExaDG::FluidFSI::ApplicationBase<2, double>::setup(std::shared_ptr<ExaDG::Grid<2> >&, std::shared_ptr<dealii::Mapping<2, 2> >&, std::shared_ptr<ExaDG::MultigridMappings<2, double> >&)
#22  ~/exadg/build_debug/applications/fluid_structure_interaction/perpendicular_flap/solver_precice: ExaDG::FSI::SolverFluid<2, double>::setup(std::shared_ptr<ExaDG::FluidFSI::ApplicationBase<2, double> >, ompi_communicator_t*, bool)
--------------------------------------------------------

From what I understand, this stems from the lambda called here

GridUtilities::create_triangulation_with_multigrid<dim>(grid,
this->mpi_comm,
this->param.grid,
this->param.involves_h_multigrid(),
lambda_create_triangulation,
{} /* no local refinements */);

and the global refinement (a few lines above the cited code) therein. However, the triangulation within the lambda should contain the manifold after applying the suggestion, so I am not sure what else to change.

@kronbichler
Copy link
Contributor

Thank you for the input, I can reproduce this as well. I need to have a deeper look at what happens.

@kronbichler
Copy link
Contributor

It seems that this has the origin in dealii/dealii#11566. I did observe some strange entries in the manifold ids.

@kronbichler
Copy link
Contributor

Regarding

While running the test case for the preCICE coupling, the fluid solver segfaulted at timestep number two somehwere in ExaDG. Since I don't have Trilinos compiled into my local deal.II, I tried using MultigridCoarseGridPreconditioner::PointJacobi (the AMG requires Trilinos). My best guess is that this causes trouble in the SolverCG (this is at least, where the segfault stems from), maybe it's not even supported. I need to take a closer look.

This should work. I also see a problem in applications/fluid_structure_interaction/cylinder_with_flag, see #664 (comment) - so there is something strange in the multigrid setup. I hope to find it soon.

@kronbichler
Copy link
Contributor

With all this minor issues, I did not have the change to thank you for the actual porting work, this is highly appreciated! I will look into it soon.

@davidscn
Copy link
Contributor Author

davidscn commented Jun 6, 2024

With all this minor issues, I did not have the change to thank you for the actual porting work, this is highly appreciated! I will look into it soon.

Thank you for your efforts. Do let me know in case I can test something!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants