| 1 |
"""This demo demonstrates how to move the vertex coordinates of a |
| 2 |
boundary mesh and then updating the interior vertex coordinates of the |
| 3 |
original mesh by suitably interpolating the vertex coordinates (useful |
| 4 |
for implementation of ALE methods).""" |
| 5 |
|
| 6 |
# Copyright (C) 2008 Solveig Bruvoll and Anders Logg |
| 7 |
# |
| 8 |
# This file is part of DOLFIN. |
| 9 |
# |
| 10 |
# DOLFIN is free software: you can redistribute it and/or modify |
| 11 |
# it under the terms of the GNU Lesser General Public License as published by |
| 12 |
# the Free Software Foundation, either version 3 of the License, or |
| 13 |
# (at your option) any later version. |
| 14 |
# |
| 15 |
# DOLFIN is distributed in the hope that it will be useful, |
| 16 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
# GNU Lesser General Public License for more details. |
| 19 |
# |
| 20 |
# You should have received a copy of the GNU Lesser General Public License |
| 21 |
# along with DOLFIN. If not, see <http://www.gnu.org/licenses/>. |
| 22 |
# |
| 23 |
# First added: 2008-05-02 |
| 24 |
# Last changed: 2008-12-12 |
| 25 |
|
| 26 |
from dolfin import * |
| 27 |
import matplotlib.pyplot as plt |
| 28 |
|
| 29 |
|
| 30 |
# Create mesh |
| 31 |
mesh = UnitSquareMesh(20, 20) |
| 32 |
|
| 33 |
# Create boundary mesh |
| 34 |
boundary = BoundaryMesh(mesh, "exterior") |
| 35 |
|
| 36 |
# Move vertices in boundary |
| 37 |
for x in boundary.coordinates(): |
| 38 |
x[0] *= 3.0 |
| 39 |
x[1] += 0.1*sin(5.0*x[0]) |
| 40 |
|
| 41 |
# Move mesh |
| 42 |
ALE.move(mesh, boundary) |
| 43 |
|
| 44 |
# Plot mesh |
| 45 |
plot(mesh) |
| 46 |
plt.show() |
| 47 |
|
| 48 |
# Write mesh to file |
| 49 |
File("deformed_mesh.pvd") << mesh |