File: adaptcallback.hh

package info (click to toggle)
dune-grid 2.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,472 kB
  • sloc: cpp: 60,883; python: 1,438; perl: 191; makefile: 12; sh: 3
file content (146 lines) | stat: -rw-r--r-- 3,824 bytes parent folder | download | duplicates (2)
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
140
141
142
143
144
145
146
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_GRID_COMMON_ADAPTCALLBACK_HH
#define DUNE_GRID_COMMON_ADAPTCALLBACK_HH

/** \file
 *  \author Martin Nolte
 *  \brief  interfaces and wrappers needed for the callback adaptation provided
 *          by AlbertaGrid and dune-ALUGrid
 */

namespace Dune
{

  // Internal Forward Declarations
  // -----------------------------

  template< class Grid, class Impl >
  class AdaptDataHandle;



  // AdaptDataHandleInterface
  // ------------------------

  /** \brief Interface class for the Grid's adapt method where the
            parameter is a AdaptDataHandleInterface.
  */
  template< class Grid, class Impl >
  class AdaptDataHandleInterface
  {
    typedef AdaptDataHandleInterface< Grid, Impl > This;

    friend class AdaptDataHandle< Grid, Impl >;

  public:
    typedef typename Grid::template Codim< 0 >::Entity Entity;

  private:
    AdaptDataHandleInterface ()
    {}

    AdaptDataHandleInterface ( const This & );
    This &operator= ( const This & );

  public:
    /** \brief call back for activity to take place on father
              and all descendants before the descendants are removed

       \param father  entity where all descendants are going to be removed
    */
    void preCoarsening ( const Entity &father )
    {
      asImp().preCoarsening( father );
    }

    /** \brief call back for activity to take place on newly created
              elements below the father element.

       \param father  entity where all descendants were newly created
    */
    void postRefinement ( const Entity &father )
    {
      asImp().postRefinement( father );
    }

    void restrictLocal( const Entity &father, const Entity& son, bool initialize )
    {
      asImp().restrictLocal( father, son, initialize );
    }

    void prolongLocal( const Entity &father, const Entity& son, bool initialize )
    {
      asImp().prolongLocal( father, son, initialize );
    }

  protected:
    const Impl &asImp () const { return static_cast< const Impl & >( *this ); }
    Impl &asImp () { return static_cast< Impl & >( *this ); }
  };



  // AdaptDataHandle
  // ---------------

  template< class Grid, class Impl >
  class AdaptDataHandle
    : public AdaptDataHandleInterface< Grid, Impl >
  {
    typedef AdaptDataHandle< Grid, Impl > This;
    typedef AdaptDataHandleInterface< Grid, Impl > Base;

  public:
    typedef typename Base::Entity Entity;

  protected:
    AdaptDataHandle ()
    {}

  private:
    AdaptDataHandle ( const This & );
    This &operator= ( const This & );

    void preCoarsening ( const Entity &father );
    void postRefinement ( const Entity &father );
  };


  // CombinedAdaptProlongRestrict
  // ----------------------------

  //! class for combining 2 index sets together for adaptation process
  template <class A, class B >
  class CombinedAdaptProlongRestrict
  {
    //! space A and B
    A& _a;
    B& _b;
  public:
    //! constructor storing the two references
    CombinedAdaptProlongRestrict ( A& a, B& b ) : _a ( a ) , _b ( b )
    {}

    //! restrict data to father
    template <class Entity>
    void restrictLocal ( const Entity &father, const Entity &son, bool initialize )
    {
      _a.restrictLocal(father,son,initialize);
      _b.restrictLocal(father,son,initialize);
    }

    //! prolong data to children
    template <class Entity>
    void prolongLocal ( const Entity &father, const Entity &son, bool initialize )
    {
      _a.prolongLocal(father,son,initialize);
      _b.prolongLocal(father,son,initialize);
    }
  };

} // end namespace Dune

#endif