Skip to content
Snippets Groups Projects
Commit 3495e9a5 authored by akbib's avatar akbib Committed by akbib
Browse files

Store a copy of the gridview in an auto_ptr

[[Imported from SVN: r8817]]
parent d5fdaf87
Branches
Tags
No related merge requests found
......@@ -30,13 +30,18 @@ public:
DeformationFunction(const GridView& gridView,
const CoefficientVectorType& deformation)
: gridView_(gridView),
deformation_(deformation)
: deformation_(deformation)
{
if(gridView_.size(dim) != deformation_.size())
gridView_ = std::auto_ptr<GridView>(new GridView(gridView));
if(gridView_->size(dim) != deformation_.size())
DUNE_THROW(Dune::Exception,"The deformation coefficient vector doesn't match the gridview!");
}
void setGridView(const GridView& gridView) {
gridView_ = std::auto_ptr<GridView>(new GridView(gridView));
}
//! Change the deformation vector
void setDeformation(const CoefficientVectorType& deformation)
{
......@@ -47,7 +52,7 @@ public:
void evaluate ( const typename GridView::template Codim<dim>::Entity& hostVertex, unsigned int corner,
Dune::FieldVector<double,dim> &y ) const
{
const typename GridView::IndexSet& indexSet = gridView_.indexSet();
const typename GridView::IndexSet& indexSet = gridView_->indexSet();
int idx = indexSet.index(hostVertex);
y = hostVertex.geometry().corner(0) + deformation_[idx];
......@@ -57,7 +62,7 @@ public:
void evaluate (const typename GridView::template Codim<0>::Entity& hostEntity, unsigned int corner,
typename Base::RangeVector& y ) const
{
const typename GridView::IndexSet& indexSet = gridView_.indexSet();
const typename GridView::IndexSet& indexSet = gridView_->indexSet();
int idx = indexSet.subIndex(hostEntity, corner,dim);
y = hostEntity.geometry().corner(corner) + deformation_[idx];
......@@ -65,16 +70,17 @@ public:
//! Adapt to changes in the host grid
void adapt() {
if (deformation_.size() != gridView_.size(dim)) {
if (deformation_.size() != gridView_->size(dim)) {
std::cout<<"Warning removing all data from DeformationFunction! \n";
deformation_.resize(gridView_.size(dim));
deformation_.resize(gridView_->size(dim));
deformation_ = 0;
}
}
private:
//! The gridview of the undeformed grid
const GridView& gridView_;
std::auto_ptr<GridView> gridView_;
//! The coefficient vector of the displacements of the vertices of the gridview
CoefficientVectorType deformation_;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment