1
// Copyright (C) 2009 Anders Logg.
2
// Licensed under the GNU LGPL Version 2.1.
4
// First added: 2009-02-11
5
// Last changed: 2009-03-02
7
// This demo program demonstrates how to extract matching sub meshes
12
using namespace dolfin;
16
// Structure sub domain
17
class Structure : public SubDomain
19
bool inside(const double* x, bool on_boundary) const
21
return x[0] > 1.4 - DOLFIN_EPS and x[0] < 1.6 + DOLFIN_EPS and x[1] < 0.6 + DOLFIN_EPS;
26
Rectangle mesh(0.0, 0.0, 3.0, 1.0, 60, 20);
28
// Create sub domain markers and mark everything as 0
29
MeshFunction<unsigned int> sub_domains(mesh, mesh.topology().dim());
32
// Mark structure domain as 1
34
structure.mark(sub_domains, 1);
37
SubMesh fluid_mesh(mesh, sub_domains, 0);
38
SubMesh structure_mesh(mesh, sub_domains, 1);
40
// Move structure mesh
41
MeshGeometry& geometry = structure_mesh.geometry();
42
for (VertexIterator v(structure_mesh); !v.end(); ++v)
44
const double* x = v->x();
45
geometry.x(v->index())[0] += 0.1*x[0]*x[1];
48
// Move fluid mesh according to structure mesh
49
fluid_mesh.move(structure_mesh);