DUNE-FEM (unstable)
recipe-iterate-over-grid.cc
See explanation at Iterating over a grid
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file COPYING in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
// C++ includes
#include<math.h>
#include<iostream>
// dune-common includes
#include<dune/common/parallel/mpihelper.hh>
#include<dune/common/parametertreeparser.hh>
#include<dune/common/timer.hh>
// dune-grid includes
#include <dune/grid/yaspgrid.hh>
int main(int argc, char** argv)
{
// Maybe initialize Mpi
// [set up grid]
const int dim = 4;
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;
if (!e.type().isCube()) std::cout << "not a cube" << std::endl;
// [iterate over grid view]
; // codim=0
; // codim=dim
; // codim=dim-1
; // codim=1
// [access to subentities]
const int mycodim = 2;
for (unsigned int i=0; i<e.subEntities(mycodim); ++i)
[[maybe_unused]] auto v = e.template subEntity<codim>(i);
}
static DUNE_EXPORT MPIHelper & instance(int &argc, char **&argv)
Get the singleton instance of the helper.
Definition: mpihelper.hh:252
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.
A simple timing class.
|
Legal Statements / Impressum |
Hosted by TU Dresden |
generated with Hugo v0.111.3
(Nov 12, 23:30, 2024)