Skip to content
Snippets Groups Projects
Commit c2bc8b65 authored by Oliver Sander's avatar Oliver Sander
Browse files

a new constructor for uniform grids

[[Imported from SVN: r1161]]
parent d230b8be
No related branches found
No related tags found
No related merge requests found
......@@ -198,9 +198,12 @@ namespace Dune {
* \todo Replace this by a true leaf iterator */
typedef OneDGridLevelIterator<0,dim,dimworld, All_Partition> LeafIterator;
/** \brief Constructor with an explicit set of coordinates */
OneDGrid(const SimpleVector<OneDCType>& coords);
/** \brief Constructor for a uniform grid */
OneDGrid(int numElements, double leftBoundary, double rightBoundary);
OneDGrid();
//! Desctructor
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
template <int dim, int dimworld>
OneDGrid<dim,dimworld>::OneDGrid(int numElements, double leftBoundary, double rightBoundary)
{
// Init grid hierarchy
vertices.resize(1);
elements.resize(1);
// Init vertex set
for (int i=0; i<numElements+1; i++) {
double newCoord = leftBoundary + i*(rightBoundary-leftBoundary) / numElements;
OneDGridEntity<1,1,1>* newVertex = new OneDGridEntity<1,1,1>(0, newCoord);
newVertex->index_ = i;
vertices[0].insert_after(vertices[0].rbegin, newVertex);
}
// Init element set
OneDGridEntity<1,1,1>* it = vertices[0].begin;
for (int i=0; i<numElements; i++) {
OneDGridEntity<0,1,1>* newElement = new OneDGridEntity<0,1,1>(0);
newElement->geo_.vertex[0] = it;
it = it->succ_;
newElement->geo_.vertex[1] = it;
newElement->index_ = i;
elements[0].insert_after(elements[0].rbegin, newElement);
}
}
template <int dim, int dimworld>
OneDGrid<dim,dimworld>::OneDGrid(const SimpleVector<OneDCType>& coords)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment