...
  View open merge request
Commits (6)
  • Carsten Gräser's avatar
    Add algorithms for working with function space bases · cb02ff82
    Carsten Gräser authored
    This is a collection of algorithms working on function space bases.
    It does e.g. allow to
    * loop over all (local view, local index set) pairs for a given basis
    * loop over all DOFs associated to an intersection
    * loop over all boundary DOFs
    
    This is not realized by fixed utility methods that do, e.g., mark
    the DOFs. Instead these are stl-like algorithms invoke given callback
    functions. This allows for greater flexibility and composability.
    
    The namespace TreeAlgorithms contains some algorithms for looping
    over a type tree. These are proposed for dune-typetree. However I
    copied them here to simplify the implementation. They can be removed
    once they have arrived in dune-typetree.
    
    Furthermore the algorithms for looping over sub-sub-entities of a
    sub-entity in a reference element may be moved to dune-geometry.
    cb02ff82
  • Carsten Gräser's avatar
    Implement boundary DOF marking by basis algorithms · e2fe491c
    Carsten Gräser authored
    The new algorithms allow to easily mark the boundary DOFs
    without relying on geometric information.
    e2fe491c
  • Carsten Gräser's avatar
  • Carsten Gräser's avatar
    (Try to) make gcc-4.9 happy · 294698cc
    Carsten Gräser authored
    Gcc-4.9 has problems in capturing constants by reference.
    Since simply capturing by value also fails, we explicit
    do the copy here.
    294698cc
  • Carsten Gräser's avatar
    [bugfix] Add missing header · 1b1314e0
    Carsten Gräser authored
    This only showed up after reworking the reference elements.
    But it's not a bug in dune-geometry, because this only
    worked here by accident.
    1b1314e0
  • Carsten Gräser's avatar
    Use forEachNode() in bindTree() · 9e4f4516
    Carsten Gräser authored
    This is just for demonstration. Unfortunately it only
    works when making the non-const methods of BasisNodeMixIn
    public because you cannot list lambdas as friends. However,
    I believe that this is not a big problem, because we only
    ever handout a const tree such that these functions are
    hidden from the user anyway.
    9e4f4516
add_subdirectory("test")
install(FILES
algorithms.hh
basistags.hh
bsplinebasis.hh
compositebasis.hh
......
This diff is collapsed.
......@@ -7,6 +7,8 @@
#include <dune/typetree/traversal.hh>
#include <dune/typetree/visitor.hh>
#include <dune/functions/functionspacebases/algorithms.hh>
namespace Dune {
namespace Functions {
......@@ -158,7 +160,7 @@ namespace Dune {
return offset_;
}
protected:
// protected:
void setOffset(const size_type offset)
{
......@@ -266,8 +268,15 @@ namespace Dune {
template<typename Tree, typename Entity>
void bindTree(Tree& tree, const Entity& entity, std::size_t offset = 0)
{
BindVisitor<Entity,std::size_t> visitor(entity,offset);
TypeTree::applyToTree(tree,visitor);
TreeAlgorithms::forEachNode(tree, [&](auto& node, auto treePath) {
node.setOffset(offset);
}, [&](auto& node, auto treePath) {
node.setOffset(offset);
node.bind(entity);
offset += node.size();
}, [&](auto& node, auto treePath) {
node.setSize(offset - node.offset());
});
}
template<typename Tree>
......
......@@ -23,6 +23,7 @@
#include <dune/functions/functionspacebases/pqknodalbasis.hh>
#include <dune/functions/gridfunctions/discreteglobalbasisfunction.hh>
#include <dune/functions/gridfunctions/gridviewfunction.hh>
#include <dune/functions/functionspacebases/algorithms.hh>
using namespace Dune;
......@@ -259,17 +260,15 @@ void boundaryTreatment (const FEBasis& feBasis,
const FieldVector<double,FEBasis::GridView::dimension>& bbox,
std::vector<char>& dirichletNodes )
{
using Coordinate = typename FEBasis::GridView::template Codim<0>::Geometry::GlobalCoordinate;
// Interpolating the indicator function of the boundary will
// mark all boundary dofs.
interpolate(feBasis, Dune::TypeTree::hybridTreePath(), dirichletNodes,
[&bbox](Coordinate x){
bool isBoundary = false;
for (std::size_t j=0; j<x.size(); j++)
isBoundary = isBoundary || x[j] < 1e-8 || x[j] > bbox[j]-1e-8;
return isBoundary;
});
using namespace Dune::Functions::BasisAlgorithms;
dirichletNodes.resize(feBasis.size());
for(auto&& entry: dirichletNodes)
entry = false;
forEachBoundaryDOF(feBasis, [&](std::size_t localIndex, auto&& localView, auto&& localIndexSet, auto&& intersection) {
dirichletNodes[localIndexSet.index(localIndex)] = true;
});
}
......