~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to src/kernel/mesh/Cell.cpp

  • Committer: Johannes Ring
  • Date: 2008-03-05 22:43:06 UTC
  • Revision ID: johannr@simula.no-20080305224306-2npsdyhfdpl2esji
The BIG commit!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright (C) 2006-2007 Anders Logg.
2
 
// Licensed under the GNU LGPL Version 2.1.
3
 
//
4
 
// Modified by Johan Hoffman 2006.
5
 
//
6
 
// First added:  2006-01-01
7
 
// Last changed: 2007-04-16
8
 
 
9
 
#include <dolfin/Cell.h>
10
 
#include <dolfin/Vertex.h>
11
 
 
12
 
using namespace dolfin;
13
 
 
14
 
//-----------------------------------------------------------------------------
15
 
Point Cell::midpoint()
16
 
{
17
 
  uint num_vertices = 0; 
18
 
  
19
 
  real x = 0.0;
20
 
  real y = 0.0;
21
 
  real z = 0.0;
22
 
  
23
 
  for (VertexIterator v(*this); !v.end(); ++v)
24
 
  {
25
 
    x += v->point().x();
26
 
    y += v->point().y();
27
 
    z += v->point().z();
28
 
 
29
 
    num_vertices++;
30
 
  }
31
 
 
32
 
  x /= real(num_vertices);
33
 
  y /= real(num_vertices);
34
 
  z /= real(num_vertices);
35
 
 
36
 
  Point p(x, y, z);
37
 
  return p;
38
 
}
39
 
//-----------------------------------------------------------------------------
40
 
 
41