~ubuntu-branches/ubuntu/vivid/dune-grid/vivid

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_ONE_D_GEOMETRY_HH
#define DUNE_ONE_D_GEOMETRY_HH

#include <dune/geometry/axisalignedcubegeometry.hh>

#include <dune/grid/common/geometry.hh>

#include <dune/grid/onedgrid/onedgridentity.hh>

/** \file
 * \brief The OneDGridElement class and its specializations
 */

namespace Dune {

  // forward declaration
  template <int codim, int dim, class GridImp>
  class OneDGridEntity;

  /** \brief Unspecialized class.  Not used for anything */
  template<int mydim, int coorddim, class GridImp>
  class OneDGridGeometry;

  template<class GridImp>
  class OneDGridGeometry <0, 1, GridImp> :
    public GeometryDefaultImplementation <0, 1, GridImp,OneDGridGeometry>
  {

    template <int codim_, int dim_, class GridImp_>
    friend class OneDGridEntity;
    template <int mydim_, int coorddim_, class GridImp_>
    friend class OneDGridGeometry;

  public:

    OneDGridGeometry() : storeCoordsLocally_(false) {}

    //! return the element type identifier (vertex)
    GeometryType type () const {return GeometryType(0);}

    //! here we have always an affine geometry
    bool affine() const { return true; }

    //! return the number of corners of this element (==1)
    int corners () const {return 1;}

    /** \brief access to coordinates of a corner */
    const FieldVector< typename GridImp::ctype, 1 > corner ( const int i ) const
    {
      return (storeCoordsLocally_ ? pos_ : target_->pos_);
    }

    /** \brief Maps a local coordinate within reference element to
     * global coordinate in element  */
    FieldVector<typename GridImp::ctype, 1> global (const FieldVector<typename GridImp::ctype, 0>& local) const {
      return (storeCoordsLocally_) ? pos_ : target_->pos_;
    }

    /** \brief Maps a global coordinate within the element to a
     * local coordinate in its reference element */
    FieldVector<typename GridImp::ctype, 0> local (const FieldVector<typename GridImp::ctype, 1>& global) const {
      FieldVector<typename GridImp::ctype, 0> l;
      return l;
    }

    /** \brief !!!

       This method really doesn't make much sense for a zero-dimensional
       object.  It always returns '1'.
     */
    typename GridImp::ctype integrationElement (const FieldVector<typename GridImp::ctype, 0>& local) const {
      return 1;
    }

    //! The Jacobian matrix of the mapping from the reference element to this element
    const FieldMatrix< typename GridImp::ctype, 0, 1 > &
    jacobianTransposed ( const FieldVector< typename GridImp::ctype, 0 > &local ) const
    {
      return jacTransposed_;
    }

    //! The Jacobian matrix of the mapping from the reference element to this element
    const FieldMatrix<typename GridImp::ctype,1,0>& jacobianInverseTransposed (const FieldVector<typename GridImp::ctype, 0>& local) const {
      return jacInverse_;
    }

    void setPosition(const typename GridImp::ctype& p) {
      storeCoordsLocally_ = true;
      pos_[0] = p;
    }

    //private:
    bool storeCoordsLocally_;

    // Stores the element corner positions if it is returned as geometryInFather
    FieldVector<typename GridImp::ctype,1> pos_;

    OneDEntityImp<0>* target_;

    FieldMatrix< typename GridImp::ctype, 0, 1 > jacTransposed_;
    FieldMatrix<typename GridImp::ctype,1,0> jacInverse_;
  };

  //**********************************************************************
  //
  // --OneDGridGeometry
  /** \brief Defines the geometry part of a mesh entity.
   * \ingroup OneDGrid
   */
  template<int mydim, int coorddim, class GridImp>
  class OneDGridGeometry :
    public AxisAlignedCubeGeometry<typename GridImp::ctype, mydim, coorddim>
  {
  public:
    OneDGridGeometry(const FieldVector<double,1>& left, const FieldVector<double,1>& right)
      : AxisAlignedCubeGeometry<typename GridImp::ctype, mydim, coorddim>(left,right)
    {}
  };

  namespace FacadeOptions
  {

    /** \brief Switch on the new implementation for the Geometry interface class
     * \deprecated Eventually the new implementation will be hardwired,
     *             and this switch may disappear without prior warning!
     */
    template< int mydim, int cdim, class GridImp>
    struct StoreGeometryReference<mydim,cdim,GridImp,OneDGridGeometry>
    {
      static const bool v = false;
    };

  }

}  // namespace Dune

#endif