example3.cc 1.19 KB
Newer Older
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
#include "config.h"

#include <dune/common/parallel/mpihelper.hh>
#include <dune/curvedsurfacegrid/curvedsurfacegrid.hh>
#include <dune/curvedsurfacegrid/gridfunctions/discretegridviewfunction.hh>
#include <dune/functions/functionspacebases/interpolate.hh>
#include <dune/grid/io/file/gmshreader.hh>

using namespace Dune;

#if HAVE_DUNE_FOAMGRID
  #include <dune/foamgrid/foamgrid.hh>
  using GridType = FoamGrid<2,3>;
#elif HAVE_DUNE_ALUGRID
  #include <dune/alugrid/grid.hh>
  using GridType = Dune::ALUGrid<2,3,Dune::simplex,Dune::conforming>;
#endif

int main(int argc, char** argv)
{
  MPIHelper::instance(argc, argv);

  // Construct a reference grid
  auto refGrid = GmshReader<GridType>::read(DUNE_GRID_PATH "sphere.msh");
  auto gv = refGrid->leafGridView();

  // Define a discrete grid-function on the reference grid
  // with dim(range) = 3 and polynomial order k
  auto f = discreteGridViewFunction<3>(gv, /*order*/ 3);

  // Interpolate the parametrization into the grid-function
  auto sphere = [](const auto& x) { return x / x.two_norm(); };
  Functions::interpolate(f.basis(), f.coefficients(), sphere);

  // Wrap the reference grid and the grid-function
  CurvedSurfaceGrid grid{*refGrid, f};
}