Use range-based for in OperatorAssembler

parent 7e1e1b3f
Pipeline #17114 passed with stage
in 59 minutes and 41 seconds
#ifndef OPERATOR_ASSEMBLER_HH
#define OPERATOR_ASSEMBLER_HH
#include <dune/grid/common/rangegenerators.hh>
#include <dune/istl/matrix.hh>
#include <dune/istl/matrixindexset.hh>
......@@ -67,24 +69,21 @@ class OperatorAssembler
template <class LocalAssemblerType, bool lumping>
void addIndicesStaticLumping(LocalAssemblerType& localAssembler, Dune::MatrixIndexSet& indices) const
{
typedef typename GridView::template Codim<0>::Iterator ElementIterator;
typedef typename LocalAssemblerType::BoolMatrix BoolMatrix;
typedef typename TrialBasis::LinearCombination LinearCombination;
ElementIterator it = tBasis_.getGridView().template begin<0>();
ElementIterator end = tBasis_.getGridView().template end<0>();
for (; it != end; ++it)
for (const auto& element : Dune::elements(tBasis_.getGridView()))
{
// get shape functions
const typename TrialBasis::LocalFiniteElement& tFE = tBasis_.getLocalFiniteElement(*it);
const typename AnsatzBasis::LocalFiniteElement& aFE = aBasis_.getLocalFiniteElement(*it);
const typename TrialBasis::LocalFiniteElement& tFE = tBasis_.getLocalFiniteElement(element);
const typename AnsatzBasis::LocalFiniteElement& aFE = aBasis_.getLocalFiniteElement(element);
BoolMatrix localIndices(tFE.localBasis().size(), aFE.localBasis().size());
localAssembler.indices(*it, localIndices, tFE, aFE);
localAssembler.indices(element, localIndices, tFE, aFE);
for (size_t i=0; i<tFE.localBasis().size(); ++i)
{
int rowIndex = tBasis_.index(*it, i);
int rowIndex = tBasis_.index(element, i);
const LinearCombination& rowConstraints = tBasis_.constraints(rowIndex);
bool rowIsConstrained = tBasis_.isConstrained(rowIndex);
for (size_t j=0; j<aFE.localBasis().size(); ++j)
......@@ -103,7 +102,7 @@ class OperatorAssembler
}
else
{
int colIndex = aBasis_.index(*it, j);
int colIndex = aBasis_.index(element, j);
const LinearCombination& colConstraints = aBasis_.constraints(colIndex);
bool colIsConstrained = aBasis_.isConstrained(colIndex);
if (rowIsConstrained and colIsConstrained)
......@@ -137,24 +136,21 @@ class OperatorAssembler
template <class LocalAssemblerType, class GlobalMatrixType, bool lumping>
void addEntriesStaticLumping(LocalAssemblerType& localAssembler, GlobalMatrixType& A) const
{
typedef typename GridView::template Codim<0>::Iterator ElementIterator;
typedef typename LocalAssemblerType::LocalMatrix LocalMatrix;
typedef typename TrialBasis::LinearCombination LinearCombination;
ElementIterator it = tBasis_.getGridView().template begin<0>();
ElementIterator end = tBasis_.getGridView().template end<0>();
for (; it != end; ++it)
for (const auto& element : Dune::elements(tBasis_.getGridView()))
{
// get shape functions
const typename TrialBasis::LocalFiniteElement& tFE = tBasis_.getLocalFiniteElement(*it);
const typename AnsatzBasis::LocalFiniteElement& aFE = aBasis_.getLocalFiniteElement(*it);
const typename TrialBasis::LocalFiniteElement& tFE = tBasis_.getLocalFiniteElement(element);
const typename AnsatzBasis::LocalFiniteElement& aFE = aBasis_.getLocalFiniteElement(element);
LocalMatrix localA(tFE.localBasis().size(), aFE.localBasis().size());
localAssembler.assemble(*it, localA, tFE, aFE);
localAssembler.assemble(element, localA, tFE, aFE);
for (size_t i=0; i<tFE.localBasis().size(); ++i)
{
int rowIndex = tBasis_.index(*it, i);
int rowIndex = tBasis_.index(element, i);
const LinearCombination& rowConstraints = tBasis_.constraints(rowIndex);
bool rowIsConstrained = tBasis_.isConstrained(rowIndex);
for (size_t j=0; j<aFE.localBasis().size(); ++j)
......@@ -174,7 +170,7 @@ class OperatorAssembler
}
else
{
int colIndex = aBasis_.index(*it, j);
int colIndex = aBasis_.index(element, j);
const LinearCombination& colConstraints = aBasis_.constraints(colIndex);
bool colIsConstrained = aBasis_.isConstrained(colIndex);
if (rowIsConstrained and colIsConstrained)
......
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