Commit 5806f08a authored by Carsten Gräser's avatar Carsten Gräser

Use index transformation for demonstration

This uses a manual index transformation to implement
the Taylor-Hood basis with flat interleaved indices
for the velocities by transforming blocked interleaved
multi-indices.
parent 8bb1b2df
Pipeline #17563 passed with stage
in 81 minutes and 38 seconds
......@@ -30,6 +30,7 @@
#include <dune/functions/functionspacebases/lagrangebasis.hh>
#include <dune/functions/functionspacebases/subspacebasis.hh>
#include <dune/functions/functionspacebases/boundarydofs.hh>
#include <dune/functions/functionspacebases/transformedindexbasis.hh>
#include <dune/functions/gridfunctions/discreteglobalbasisfunction.hh>
#include <dune/functions/gridfunctions/gridviewfunction.hh>
......@@ -339,15 +340,40 @@ int main (int argc, char *argv[]) try
#else
using namespace Functions::BasisFactory;
static const std::size_t p = 1; // pressure order for Taylor-Hood
// Create an index transformation that transforms
// the BlockedInterleaved indices of the power pre-basis
// to FlatInterleaved indices.
auto transformation = Experimental::indexTransformation(
[](auto& multiIndex, const auto& basis) {
if (multiIndex[0] == 0)
{
multiIndex[1] = multiIndex[1]*dim + multiIndex[2];
multiIndex.resize(2);
}
},
[](const auto& prefix, const auto& basis) -> std::size_t {
if (prefix.size()>1)
return 0;
if ((prefix.size()==1) and (prefix[0]==0))
return basis.size(prefix) * dim;
return basis.size(prefix);
},
Dune::Indices::_2, Dune::Indices::_3);
// This basis should behave like the basis created
// with the FlatInterleaved index merging strategy
// in the commented code above.
auto taylorHoodBasis = makeBasis(
gridView,
composite(
power<dim>(
lagrange<p+1>(),
flatInterleaved()),
lagrange<p>()
));
gridView,
Experimental::transformIndices(
composite(
power<dim>(
lagrange<K+1>()
),
lagrange<K>()),
transformation));
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment