Skip to content

Add constraints support for dune-functions basis

Carsten Gräser requested to merge feature/constraints into master

This adds a class AffineConstraints for storing contraints for general dune-functions bases and a method makeContinuityConstraints() for computing the constraints for the H^1-conforming subspace for classical FE spaces on grid with hanging nodes.

This is experimental and the interface may change. Also some features are still missing:

  • The code is generic and should work with nested bases and subspace bases. But this has not been tested so far.
  • One may want to generalize makeContinuityConstraints() such that one can extend an existing constraints object. This way one could add constraints for different branches in the tree one after the other. Update: There is now also computeContinuityConstraints() to add the constraints to an existing constraints object.
  • Currently constraints are stored in a simple std::unordered_map<std::map<Index,Coeff>> data structure. Maybe this could be more efficient in a vector-based data structure or a sparse matrix. I had a compress method in mind that transforms into a more efficient storage once the contraints are fully build. But in my tests copying into a vector-bases data structure did not improve significantly, probably because the number of entries is relatively small.
  • The constraints class is called AffineConstraints because it is intended to also hold Dirichlet constraints. This feature is currently missing. Update: This now also includes computeBoundaryConstraints() for computing constraints for Dirichlet BCs.

Update: Using the functions compute*Constraints() that modify a constraints object it is possible to combine different constraints, e.g. for hanging nodes and Dirichlet values:

// Create empty constraints object
auto constraints = makeAffineConstraints(basis);

// Insert constraints for hanging node
computeContinuityConstraints(constraints, basis);

// Insert constraints for Dirichlet-values on a BoundaryPatch
computeBoundaryConstraints(constraints, basis, dirichletValueFunction, boundaryPatch);

This also adds an adaptive Poisson example demonstrating the use.

Edited by Carsten Gräser

Merge request reports

Loading