| 1 |
// Copyright (C) 2017 Chris Richardson and Garth N. Wells |
| 2 |
// |
| 3 |
// This file is part of DOLFIN. |
| 4 |
// |
| 5 |
// DOLFIN is free software: you can redistribute it and/or modify |
| 6 |
// it under the terms of the GNU Lesser General Public License as published by |
| 7 |
// the Free Software Foundation, either version 3 of the License, or |
| 8 |
// (at your option) any later version. |
| 9 |
// |
| 10 |
// DOLFIN is distributed in the hope that it will be useful, |
| 11 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
// GNU Lesser General Public License for more details. |
| 14 |
// |
| 15 |
// You should have received a copy of the GNU Lesser General Public License |
| 16 |
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
#include <memory> |
| 19 |
#include <pybind11/pybind11.h> |
| 20 |
|
| 21 |
#include <dolfin/ale/ALE.h> |
| 22 |
#include <dolfin/ale/MeshDisplacement.h> |
| 23 |
#include <dolfin/common/Variable.h> |
| 24 |
#include <dolfin/function/Expression.h> |
| 25 |
#include <dolfin/function/GenericFunction.h> |
| 26 |
#include <dolfin/mesh/BoundaryMesh.h> |
| 27 |
#include <dolfin/mesh/Mesh.h> |
| 28 |
|
| 29 |
namespace py = pybind11; |
| 30 |
|
| 31 |
namespace dolfin_wrappers |
| 32 |
{ |
| 33 |
// Interface for dolfin/ale |
| 34 |
void ale(py::module& m) |
| 35 |
{ |
| 36 |
// dolfin::MeshDisplacement |
| 37 |
py::class_<dolfin::MeshDisplacement, std::shared_ptr<dolfin::MeshDisplacement>, |
| 38 |
dolfin::Expression>(m, "MeshDisplacement") |
| 39 |
.def(py::init<std::shared_ptr<const dolfin::Mesh>>()); |
| 40 |
|
| 41 |
// ALE static functions |
| 42 |
py::class_<dolfin::ALE> |
| 43 |
(m, "ALE") |
| 44 |
.def_static("move", [](std::shared_ptr<dolfin::Mesh> mesh, const dolfin::BoundaryMesh bmesh) |
| 45 |
{ return dolfin::ALE::move(mesh, bmesh); }) |
| 46 |
.def_static("move", [](std::shared_ptr<dolfin::Mesh> mesh0, const dolfin::Mesh& mesh1) |
| 47 |
{ return dolfin::ALE::move(mesh0, mesh1); }) |
| 48 |
.def_static("move", [](dolfin::Mesh& mesh, const dolfin::GenericFunction& disp) |
| 49 |
{ dolfin::ALE::move(mesh, disp); }) |
| 50 |
.def_static("move", [](dolfin::Mesh& mesh, const py::object disp) |
| 51 |
{ |
| 52 |
auto _disp = disp.attr("_cpp_object").cast<const dolfin::GenericFunction*>(); |
| 53 |
dolfin::ALE::move(mesh, *_disp); |
| 54 |
}); |
| 55 |
} |
| 56 |
} |