// Copyright (C) 2017 Chris N. Richardson and Garth N. Wells
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see .
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "casters.h"
namespace py = pybind11;
namespace dolfin_wrappers
{
void generation(py::module& m)
{
// dolfin::IntervalMesh
py::class_, dolfin::Mesh>(m, "IntervalMesh")
.def(py::init())
.def(py::init([](const MPICommWrapper comm, std::size_t n, double a, double b)
{ return std::unique_ptr(new dolfin::IntervalMesh(comm.get(), n, a, b)); }));
// dolfin::UnitIntervalMesh
py::class_,
dolfin::IntervalMesh, dolfin::Mesh>(m, "UnitIntervalMesh")
.def(py::init())
.def(py::init([](const MPICommWrapper comm, std::size_t n)
{ return std::unique_ptr(new dolfin::UnitIntervalMesh(comm.get(), n)); }))
.def_static("create", [](std::size_t n)
{ return dolfin::UnitIntervalMesh::create(n); })
.def_static("create", [](const MPICommWrapper comm, std::size_t n)
{ return dolfin::UnitIntervalMesh::create(comm.get(), n); });
// dolfin::RectangleMesh
py::class_, dolfin::Mesh>(m, "RectangleMesh")
.def_static("create", [](std::array p, std::array n,
dolfin::CellType::Type cell_type, std::string diagonal)
{ return dolfin::RectangleMesh::create(p, n, cell_type, diagonal); },
py::arg("p"), py::arg("n"), py::arg("cell_type"), py::arg("diagonal")="right")
.def_static("create", [](const MPICommWrapper comm, std::array p,
std::array n, dolfin::CellType::Type cell_type,
std::string diagonal)
{ return dolfin::RectangleMesh::create(comm.get(), p, n, cell_type, diagonal); },
py::arg("comm"), py::arg("p"), py::arg("n"), py::arg("cell_type"),
py::arg("diagonal")="right")
// Remove
.def(py::init(),
py::arg("p0"), py::arg("p1"), py::arg("nx"), py::arg("ny"), py::arg("diagonal")="right")
.def(py::init([](const MPICommWrapper comm, const dolfin::Point& p0, const dolfin::Point& p1,
std::size_t nx, std::size_t ny, std::string diagonal="right")
{ return std::unique_ptr(new dolfin::RectangleMesh(comm.get(), p0, p1, nx, ny, diagonal)); }),
py::arg("comm"), py::arg("p0"), py::arg("p1"), py::arg("nx"), py::arg("ny"), py::arg("diagonal")="right");
// dolfin::UnitSquareMesh
py::class_, dolfin::Mesh>(m, "UnitSquareMesh")
.def(py::init(), py::arg("nx"), py::arg("ny"), py::arg("diagonal")="right")
.def(py::init([](const MPICommWrapper comm, std::size_t nx, std::size_t ny, std::string diagonal="right")
{ return std::unique_ptr(new dolfin::UnitSquareMesh(comm.get(), nx, ny, diagonal)); }),
py::arg("comm"), py::arg("nx"), py::arg("ny"), py::arg("diagonal")="right")
.def_static("create", [](std::array n, dolfin::CellType::Type cell_type,
std::string diagonal)
{ return dolfin::UnitSquareMesh::create(n, cell_type, diagonal); },
py::arg("n"), py::arg("cell_type"), py::arg("diagonal")="right")
.def_static("create", [](const MPICommWrapper comm, std::array n,
dolfin::CellType::Type cell_type, std::string diagonal="right")
{ return dolfin::UnitSquareMesh::create(comm.get(), n, cell_type, diagonal); },
py::arg("comm"), py::arg("n"), py::arg("cell_type"), py::arg("diagonal")="right")
// Remove below for 2018.1 release
.def_static("create", [](std::size_t nx, std::size_t ny, dolfin::CellType::Type cell_type)
{ return dolfin::UnitSquareMesh::create({nx, ny}, cell_type); },
py::arg("nx"), py::arg("ny"), py::arg("cell_type"))
.def_static("create", [](const MPICommWrapper comm, std::size_t nx, std::size_t ny,
dolfin::CellType::Type cell_type)
{ return dolfin::UnitSquareMesh::create(comm.get(), {nx, ny}, cell_type); },
py::arg("comm"), py::arg("nx"), py::arg("ny"), py::arg("cell_type"));
// dolfin::UnitCubeMesh
py::class_, dolfin::Mesh>(m, "UnitCubeMesh")
.def(py::init())
.def(py::init([](const MPICommWrapper comm, std::size_t nx, std::size_t ny, std::size_t nz)
{ return std::unique_ptr(new dolfin::UnitCubeMesh(comm.get(), nx, ny, nz)); }),
py::arg("comm"), py::arg("nx"), py::arg("ny"), py::arg("nz"))
.def_static("create", [](std::array n, dolfin::CellType::Type cell_type)
{ return dolfin::UnitCubeMesh::create(n, cell_type); },
py::arg("n"), py::arg("cell_type"))
.def_static("create", [](const MPICommWrapper comm, std::array n,
dolfin::CellType::Type cell_type)
{ return dolfin::UnitCubeMesh::create(comm.get(), n, cell_type); },
py::arg("comm"), py::arg("n"), py::arg("cell_type"))
// Remove below for 2018.1 release
.def_static("create", [](std::size_t nx, std::size_t ny, std::size_t nz,
dolfin::CellType::Type cell_type)
{ return dolfin::UnitCubeMesh::create({nx, ny, nz}, cell_type); },
py::arg("nx"), py::arg("ny"), py::arg("nz"), py::arg("cell_type"))
.def_static("create", [](const MPICommWrapper comm, std::size_t nx, std::size_t ny, std::size_t nz,
dolfin::CellType::Type cell_type)
{ return dolfin::UnitCubeMesh::create(comm.get(), {nx, ny, nz}, cell_type); },
py::arg("comm"), py::arg("nx"), py::arg("ny"), py::arg("nz"), py::arg("cell_type"));
// dolfin::UnitDiscMesh
py::class_(m, "UnitDiscMesh")
.def_static("create", [](const MPICommWrapper comm, std::size_t n, std::size_t degree, std::size_t gdim)
{ return dolfin::UnitDiscMesh::create(comm.get(), n, degree, gdim); });
// dolfin::SphericalShellMesh
py::class_(m, "SphericalShellMesh")
.def_static("create", [](const MPICommWrapper comm, std::size_t degree)
{ return dolfin::SphericalShellMesh::create(comm.get(), degree); });
// dolfin::UnitTriangleMesh
py::class_(m, "UnitTriangleMesh")
.def_static("create", &dolfin::UnitTriangleMesh::create);
// dolfin::BoxMesh
py::class_, dolfin::Mesh>(m, "BoxMesh")
.def(py::init())
.def(py::init([](const MPICommWrapper comm, const dolfin::Point& p0, const dolfin::Point& p1,
std::size_t nx, std::size_t ny, std::size_t nz)
{ return std::unique_ptr(new dolfin::BoxMesh(comm.get(), p0, p1, nx, ny, nz)); }),
py::arg("comm"), py::arg("p0"), py::arg("p1"), py::arg("nx"), py::arg("ny"), py::arg("nz"))
.def_static("create", [](std::array p, std::array n,
dolfin::CellType::Type cell_type)
{ return dolfin::BoxMesh::create(p, n, cell_type); },
py::arg("p"), py::arg("n"), py::arg("cell_type"))
.def_static("create", [](const MPICommWrapper comm, std::array p,
std::array n, dolfin::CellType::Type cell_type)
{ return dolfin::BoxMesh::create(comm.get(), p, n, cell_type); },
py::arg("comm"), py::arg("p"), py::arg("n"), py::arg("cell_type"));
}
}