~ubuntu-branches/ubuntu/maverick/dolfin/maverick

« back to all changes in this revision

Viewing changes to dolfin/mesh/UnitInterval.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Johannes Ring
  • Date: 2009-10-12 14:13:18 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20091012141318-hkbxl0sq555vqv7d
Tags: 0.9.4-1
* New upstream release. This version cleans up the design of the
  function class by adding a new abstraction for user-defined
  functions called Expression. A number of minor bugfixes and
  improvements have also been made.
* debian/watch: Update for new flat directory structure.
* Update debian/copyright.
* debian/rules: Use explicit paths to PETSc 3.0.0 and SLEPc 3.0.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
// First added:  2007-11-23
5
5
// Last changed: 2008-11-13
6
6
 
 
7
#include <dolfin/main/MPI.h>
 
8
#include "MeshPartitioning.h"
7
9
#include "MeshEditor.h"
8
10
#include "UnitInterval.h"
9
11
 
12
14
//-----------------------------------------------------------------------------
13
15
UnitInterval::UnitInterval(uint nx) : Mesh()
14
16
{
 
17
  // Receive mesh according to parallel policy
 
18
  if (MPI::is_receiver()) { MeshPartitioning::partition(*this); return; }
 
19
 
15
20
  if ( nx < 1 )
16
21
    error("Size of unit interval must be at least 1.");
17
22
 
22
27
  editor.open(*this, CellType::interval, 1, 1);
23
28
 
24
29
  // Create vertices and cells:
25
 
  editor.initVertices((nx+1));
26
 
  editor.initCells(nx);
 
30
  editor.init_vertices((nx+1));
 
31
  editor.init_cells(nx);
27
32
 
28
33
  // Create main vertices:
29
34
  for (uint ix = 0; ix <= nx; ix++)
30
35
  {
31
36
    const double x = static_cast<double>(ix) / static_cast<double>(nx);
32
 
    editor.addVertex(ix, x);
 
37
    editor.add_vertex(ix, x);
33
38
  }
34
39
 
35
40
  // Create intervals
36
41
  for (uint ix = 0; ix < nx; ix++) {
37
42
        const uint v0 = ix;
38
43
        const uint v1 = v0 + 1;
39
 
        editor.addCell(ix, v0, v1);
 
44
        editor.add_cell(ix, v0, v1);
40
45
  }
41
46
 
42
47
  // Close mesh editor
43
48
  editor.close();
 
49
 
 
50
  // Broadcast mesh according to parallel policy
 
51
  if (MPI::is_broadcaster()) { MeshPartitioning::partition(*this); return; }
44
52
}
45
53
//-----------------------------------------------------------------------------