Dune Core Modules (2.9.0)


See explanation at Iterating over a grid

// SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file COPYING in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
// always include the config file
#include "config.h"
// C++ includes
// dune-common includes
// dune-grid includes
int main(int argc, char** argv)
// Maybe initialize Mpi
[[maybe_unused]] Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc, argv);
// [set up grid]
const int dim = 4;
using Grid = Dune::YaspGrid<dim>;
Dune::FieldVector<double,dim> len; for (auto& l : len) l=1.0;
std::array<int,dim> cells; for (auto& c : cells) c=4;
Grid grid(len,cells);
// [extract gridview]
auto gv = grid.leafGridView();
// [iterate over codim]
const int codim = 2;
for (const auto& e : entities(gv,Dune::Codim<codim>{}))
if (!e.type().isCube()) std::cout << "not a cube" << std::endl;
// [iterate over grid view]
for ([[maybe_unused]] const auto& e : elements(gv))
; // codim=0
for ([[maybe_unused]] const auto& e : vertices(gv))
; // codim=dim
for ([[maybe_unused]] const auto& e : edges(gv))
; // codim=dim-1
for ([[maybe_unused]] const auto& e : facets(gv))
; // codim=1
// [access to subentities]
const int mycodim = 2;
for (const auto& e : elements(gv))
for (unsigned int i=0; i<e.subEntities(mycodim); ++i)
[[maybe_unused]] auto v = e.template subEntity<codim>(i);
vector space out of a tensor product of fields.
Definition: fvector.hh:95
A real mpi helper.
Definition: mpihelper.hh:179
[ provides Dune::Grid ]
Definition: yaspgrid.hh:163
IteratorRange<... > vertices(const GV &gv)
Iterates over all vertices (entities with dimension 0) of a GridView.
IteratorRange<... > elements(const GV &gv)
Iterates over all elements / cells (entities with codimension 0) of a GridView.
IteratorRange<... > entities(const GV &gv, Codim< codim > cd)
Iterates over all entities of a GridView with the given codimension.
IteratorRange<... > facets(const GV &gv)
Iterates over all facets (entities with codimension 1) of a GridView.
IteratorRange<... > edges(const GV &gv)
Iterates over all edges (entities with dimension 1) of a GridView.
Helpers for dealing with MPI.
Various parser methods to get data into a ParameterTree object.
Static tag representing a codimension.
Definition: dimension.hh:24
A simple timing class.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 22, 22:30, 2024)