1
// Copyright (C) 2007-2008 Anders Logg.
2
// Licensed under the GNU LGPL Version 2.1.
4
// First added: 2007-04-24
5
// Last changed: 2008-02-13
7
// This demo program demonstrates how to mark sub domains
8
// of a mesh and store the sub domain markers as a mesh
9
// function to a DOLFIN XML file.
11
// The sub domain markers produced by this demo program
12
// are the ones used for the Stokes demo programs.
16
using namespace dolfin;
20
// Sub domain for no-slip (everything except inflow and outflow)
21
class Noslip : public SubDomain
23
bool inside(const real* x, bool on_boundary) const
29
// Sub domain for inflow (right)
30
class Inflow : public SubDomain
32
bool inside(const real* x, bool on_boundary) const
34
return x[0] > 1.0 - DOLFIN_EPS && on_boundary;
38
// Sub domain for outflow (left)
39
class Outflow : public SubDomain
41
bool inside(const real* x, bool on_boundary) const
43
return x[0] < DOLFIN_EPS && on_boundary;
48
Mesh mesh("../../../../../data/meshes/dolfin-2.xml.gz");
50
// Create mesh function over the cell facets
51
MeshFunction<unsigned int> sub_domains(mesh, mesh.topology().dim() - 1);
53
// Mark all facets as sub domain 3
56
// Mark no-slip facets as sub domain 0
58
noslip.mark(sub_domains, 0);
60
// Mark inflow as sub domain 1
62
inflow.mark(sub_domains, 1);
64
// Mark outflow as sub domain 2
66
outflow.mark(sub_domains, 2);
68
// Save sub domains to file
69
File file("subdomains.xml");