Commit f9941a65 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

add example for using a grid-creator as grid-function in curvedsurfacegrid

parent 47ee067e
......@@ -21,4 +21,12 @@ if (dune-foamgrid_FOUND OR dune-alugrid_FOUND)
"DUNE_GRID_PATH=\"${PROJECT_SOURCE_DIR}/doc/grids/\"")
target_link_dune_default_libraries(example3)
endif ()
if (dune-vtk_FOUND)
# This example required dune-vtk
add_executable(example4 example4.cc)
target_compile_definitions(example4 PRIVATE
"DUNE_GRID_PATH=\"${PROJECT_SOURCE_DIR}/doc/grids/\"")
target_link_dune_default_libraries(example4)
endif ()
endif ()
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <dune/common/parallel/mpihelper.hh> // An initializer of MPI
#include <dune/common/exceptions.hh> // We use exceptions
#include <dune/grid/uggrid.hh>
#include <dune/grid/utility/structuredgridfactory.hh>
#include <dune/vtk/vtkreader.hh>
#include <dune/vtk/gridcreators/lagrangegridcreator.hh>
#include <dune/vtk/writers/vtkunstructuredgridwriter.hh>
#include <dune/vtk/datacollectors/lagrangedatacollector.hh>
#include <dune/foamgrid/foamgrid.hh>
#include <dune/curvedsurfacegrid/curvedsurfacegrid.hh>
#include <dune/curvedsurfacegrid/geometries/sphere.hh>
#include <dune/grid/io/file/gmshreader.hh>
using namespace Dune;
template <int order, class Grid>
void write_grid (const Grid& grid, std::string filename)
{
Vtk::LagrangeDataCollector dataCollector{grid.leafGridView(), order};
VtkUnstructuredGridWriter vtkWriter{dataCollector, Vtk::ASCII};
vtkWriter.write(filename);
}
int main(int argc, char** argv)
{
Dune::MPIHelper::instance(argc, argv);
using GridType = FoamGrid<2, 3>;
{
// Construct a reference grid
auto refGrid = GmshReader<GridType>::read(DUNE_GRID_PATH "sphere.msh");
// Define the geometry mapping
auto sphere = sphereGridFunction<GridType>(1.0);
// Wrap the reference grid to build a curved grid
CurvedSurfaceGrid grid{*refGrid, sphere};
write_grid<3>(grid, "sphere_order3.vtu");
}
using GridCreator = Vtk::LagrangeGridCreator<GridType>;
GridFactory<GridType> factory;
GridCreator creator(factory);
VtkReader reader(creator);
reader.read("sphere_order3.vtu");
std::unique_ptr grid = reader.createGrid();
using CurvedType = CurvedSurfaceGrid<GridCreator, /*order=*/3>;
CurvedType curvedGrid{*grid, creator};
write_grid<3>(*grid, "sphere_order3_test.vtu");
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment