From 2b7f0c3d3f9078c3b3fcbf1d4b840eec24938c8b Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Mon, 8 Mar 2010 17:14:36 +0000 Subject: [PATCH] template parameter of PlanarRodAssembler is a GridView now instead of a GridType [[Imported from SVN: r5693]] --- rodobstacle.cc | 2 +- src/rodassembler.cc | 56 ++++++++++++++++++++++----------------------- src/rodassembler.hh | 17 ++++++-------- 3 files changed, 35 insertions(+), 40 deletions(-) diff --git a/rodobstacle.cc b/rodobstacle.cc index c6938d88..396df875 100644 --- a/rodobstacle.cc +++ b/rodobstacle.cc @@ -181,7 +181,7 @@ int main (int argc, char *argv[]) try MatrixType hessianMatrix; - PlanarRodAssembler<GridType> rodAssembler(grid); + PlanarRodAssembler<GridType::LeafGridView> rodAssembler(grid.leafView()); rodAssembler.setParameters(1, 350000, 350000); diff --git a/src/rodassembler.cc b/src/rodassembler.cc index db05fafb..b30a8094 100644 --- a/src/rodassembler.cc +++ b/src/rodassembler.cc @@ -214,19 +214,19 @@ getResultantForce(const BoundaryPatchBase<PatchGridView>& boundary, } -template <class GridType> -void PlanarRodAssembler<GridType>::getNeighborsPerVertex(Dune::MatrixIndexSet& nb) const +template <class GridView> +void PlanarRodAssembler<GridView>::getNeighborsPerVertex(Dune::MatrixIndexSet& nb) const { - const int gridDim = GridType::dimension; - const typename GridType::Traits::LevelIndexSet& indexSet = grid_->levelIndexSet(grid_->maxLevel()); + const int gridDim = GridView::dimension; + const typename GridView::IndexSet& indexSet = this->gridView_.indexSet(); int i, j; - int n = grid_->size(grid_->maxLevel(), gridDim); + int n = this->gridView_.size(gridDim); nb.resize(n, n); - ElementIterator it = grid_->template lbegin<0>( grid_->maxLevel() ); - ElementIterator endit = grid_->template lend<0> ( grid_->maxLevel() ); + ElementIterator it = this->gridView_.template begin<0>(); + ElementIterator endit = this->gridView_.template end<0> (); for (; it!=endit; ++it) { @@ -247,20 +247,20 @@ void PlanarRodAssembler<GridType>::getNeighborsPerVertex(Dune::MatrixIndexSet& n } -template <class GridType> -void PlanarRodAssembler<GridType>:: +template <class GridView> +void PlanarRodAssembler<GridView>:: assembleMatrix(const std::vector<RigidBodyMotion<2> >& sol, Dune::BCRSMatrix<MatrixBlock>& matrix) { - const typename GridType::Traits::LevelIndexSet& indexSet = grid_->levelIndexSet(grid_->maxLevel()); + const typename GridView::IndexSet& indexSet = this->gridView_.indexSet(); Dune::MatrixIndexSet neighborsPerVertex; getNeighborsPerVertex(neighborsPerVertex); matrix = 0; - ElementIterator it = grid_->template lbegin<0>( grid_->maxLevel() ); - ElementIterator endit = grid_->template lend<0> ( grid_->maxLevel() ); + ElementIterator it = this->gridView_.template begin<0>(); + ElementIterator endit = this->gridView_.template end<0> (); Dune::Matrix<MatrixBlock> mat; @@ -301,14 +301,14 @@ assembleMatrix(const std::vector<RigidBodyMotion<2> >& sol, -template <class GridType> +template <class GridView> template <class MatrixType> -void PlanarRodAssembler<GridType>:: +void PlanarRodAssembler<GridView>:: getLocalMatrix( EntityType &entity, const std::vector<RigidBodyMotion<2> >& localSolution, const int matSize, MatrixType& localMat) const { - const typename GridType::Traits::LevelIndexSet& indexSet = grid_->levelIndexSet(grid_->maxLevel()); + const typename GridView::IndexSet& indexSet = this->gridView_.indexSet(); /* ndof is the number of vectors of the element */ int ndof = matSize; @@ -453,22 +453,21 @@ getLocalMatrix( EntityType &entity, } -template <class GridType> -void PlanarRodAssembler<GridType>:: +template <class GridView> +void PlanarRodAssembler<GridView>:: assembleGradient(const std::vector<RigidBodyMotion<2> >& sol, Dune::BlockVector<Dune::FieldVector<double, blocksize> >& grad) const { - const typename GridType::Traits::LevelIndexSet& indexSet = grid_->levelIndexSet(grid_->maxLevel()); - const int maxlevel = grid_->maxLevel(); + const typename GridView::IndexSet& indexSet = this->gridView_.indexSet(); - if (sol.size()!=grid_->size(maxlevel, gridDim)) + if (sol.size()!=this->gridView_.size(gridDim)) DUNE_THROW(Dune::Exception, "Solution vector doesn't match the grid!"); grad.resize(sol.size()); grad = 0; - ElementIterator it = grid_->template lbegin<0>(maxlevel); - ElementIterator endIt = grid_->template lend<0>(maxlevel); + ElementIterator it = this->gridView_.template begin<0>(); + ElementIterator endIt = this->gridView_.template end<0>(); // Loop over all elements for (; it!=endIt; ++it) { @@ -555,20 +554,19 @@ assembleGradient(const std::vector<RigidBodyMotion<2> >& sol, } -template <class GridType> -double PlanarRodAssembler<GridType>:: +template <class GridView> +double PlanarRodAssembler<GridView>:: computeEnergy(const std::vector<RigidBodyMotion<2> >& sol) const { - const int maxlevel = grid_->maxLevel(); double energy = 0; - const typename GridType::Traits::LevelIndexSet& indexSet = grid_->levelIndexSet(maxlevel); + const typename GridView::IndexSet& indexSet = this->gridView_.indexSet(); - if (sol.size()!=grid_->size(maxlevel, gridDim)) + if (sol.size()!=this->gridView_.size(gridDim)) DUNE_THROW(Dune::Exception, "Solution vector doesn't match the grid!"); - ElementIterator it = grid_->template lbegin<0>(maxlevel); - ElementIterator endIt = grid_->template lend<0>(maxlevel); + ElementIterator it = this->gridView_.template begin<0>(); + ElementIterator endIt = this->gridView_.template end<0>(); // Loop over all elements for (; it!=endIt; ++it) { diff --git a/src/rodassembler.hh b/src/rodassembler.hh index 2cc2023c..af2b47d6 100644 --- a/src/rodassembler.hh +++ b/src/rodassembler.hh @@ -79,15 +79,15 @@ public: /** \brief The FEM operator for a 2D extensible, shearable rod */ -template <class GridType> -class PlanarRodAssembler : public GeodesicFEAssembler<typename GridType::LeafGridView, RigidBodyMotion<2> > +template <class GridView> +class PlanarRodAssembler : public GeodesicFEAssembler<GridView, RigidBodyMotion<2> > { - typedef typename GridType::template Codim<0>::Entity EntityType; - typedef typename GridType::template Codim<0>::LevelIterator ElementIterator; + typedef typename GridView::template Codim<0>::Entity EntityType; + typedef typename GridView::template Codim<0>::Iterator ElementIterator; //! Dimension of the grid. This needs to be one! - enum { gridDim = GridType::dimension }; + enum { gridDim = GridView::dimension }; enum { elementOrder = 1}; @@ -97,8 +97,6 @@ class PlanarRodAssembler : public GeodesicFEAssembler<typename GridType::LeafGri //! typedef Dune::FieldMatrix<double, blocksize, blocksize> MatrixBlock; - const GridType* grid_; - /** \brief Material constants */ double B; double A1; @@ -107,9 +105,8 @@ class PlanarRodAssembler : public GeodesicFEAssembler<typename GridType::LeafGri public: //! ??? - PlanarRodAssembler(const GridType &grid) - : GeodesicFEAssembler<typename GridType::LeafGridView, RigidBodyMotion<2> >(grid.leafView(),NULL), - grid_(&grid) + PlanarRodAssembler(const GridView &gridView) + : GeodesicFEAssembler<GridView, RigidBodyMotion<2> >(gridView,NULL) { B = 1; A1 = 1; -- GitLab