File: geometrygrid-coordfunction-copyconstructor.cc

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 (63 lines) | stat: -rw-r--r-- 1,541 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
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
/*
 * Test that an implicit copy generator is available for classes derived from
 * - Dune::AnalyticalCoordFunction
 * - Dune::DiscreteCoordFunction
 *
 * See https://gitlab.dune-project.org/flyspray/FS/issues/1463
 */

#include <dune/grid/geometrygrid/coordfunction.hh>

class Analytical
  : public Dune::AnalyticalCoordFunction<double, 3, 3, Analytical>
{
  using Base = Dune::AnalyticalCoordFunction<double, 3, 3, Analytical>;
  Base::RangeVector offset_;
public:
  Analytical(Base::RangeVector offset)
    : offset_(offset)
    { /* Nothing. */ }

  void evaluate(const Base::DomainVector& x, Base::RangeVector& y) const
    {
      y = x;
      y += offset_;
    }
};

class Discrete
  : public Dune::DiscreteCoordFunction<double, 3, Discrete>
{
  using Base = Dune::DiscreteCoordFunction<double, 3, Discrete>;
  Base::RangeVector offset_;
public:
  Discrete(Base::RangeVector offset)
    : offset_(offset)
    { /* Nothing. */ }

  template<class HostEntity>
  void evaluate(const HostEntity& hostEntity, unsigned int corner, Base::RangeVector& y) const
    {
      y = hostEntity.geometry().corner(corner);
      y += offset_;
    }
};

int main()
{
  {
    Analytical a({1., 2., 3.});
    Analytical b = a;
    [[maybe_unused]] Analytical c(b);
  }

  {
    Discrete a({1., 2., 3.});
    Discrete b = a;
    [[maybe_unused]] Discrete c(b);
  }

  return 0;
}