1
// Copyright (C) 2007 Kristian B. Oelgaard.
2
// Licensed under the GNU LGPL Version 2.1.
4
// First added: 2007-11-23
5
// Last changed: 2007-11-23
7
#include <dolfin/MeshEditor.h>
8
#include <dolfin/UnitInterval.h>
10
using namespace dolfin;
12
//-----------------------------------------------------------------------------
13
UnitInterval::UnitInterval(uint nx) : Mesh()
16
error("Size of unit interval must be at least 1.");
18
rename("mesh", "Mesh of the unit interval (0,1)");
20
// Open mesh for editing
22
editor.open(*this, CellType::interval, 1, 1);
24
// Create vertices and cells:
25
editor.initVertices((nx+1));
28
// Create main vertices:
29
for (uint ix = 0; ix <= nx; ix++)
31
const real x = static_cast<real>(ix) / static_cast<real>(nx);
32
editor.addVertex(ix, x);
36
for (uint ix = 0; ix < nx; ix++) {
38
const uint v1 = v0 + 1;
39
editor.addCell(ix, v0, v1);
46
//-----------------------------------------------------------------------------