Page MenuHomec4science

solvers.cpp
No OneTemporary

File Metadata

Created
Tue, May 21, 07:54

solvers.cpp

/**
* @file
*
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2017 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Tamaas 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.
*
* Tamaas 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 Tamaas. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "wrap.hh"
#include "contact_solver.hh"
#include "polonsky_keer_rey.hh"
#include "kato.hh"
#include "beck_teboulle.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
namespace wrap {
/* -------------------------------------------------------------------------- */
using namespace py::literals;
/* -------------------------------------------------------------------------- */
void wrapSolvers(py::module& mod) {
py::class_<ContactSolver>(mod, "ContactSolver")
.def(py::init<Model&, const GridBase<Real>&, Real>(), "model"_a,
"surface"_a, "tolerance"_a)
.def("setMaxIterations", &ContactSolver::setMaxIterations, "max_iter"_a)
.def("setDumpFrequency", &ContactSolver::setDumpFrequency, "dump_freq"_a)
.def("addFunctionalTerm", &ContactSolver::addFunctionalTerm);
py::class_<PolonskyKeerRey, ContactSolver> pkr(mod, "PolonskyKeerRey");
pkr.def(py::init<Model&, const GridBase<Real>&, Real, PolonskyKeerRey::type,
PolonskyKeerRey::type>(),
"model"_a, "surface"_a, "tolerance"_a, "primal_type"_a,
"constraint_type"_a, py::keep_alive<1, 2>(), py::keep_alive<1, 3>())
.def("solve", &PolonskyKeerRey::solve, "target"_a)
.def("computeError", &PolonskyKeerRey::computeError);
py::enum_<PolonskyKeerRey::type>(pkr, "type")
.value("gap", PolonskyKeerRey::gap)
.value("pressure", PolonskyKeerRey::pressure)
.export_values();
py::class_<Kato, ContactSolver> kato(mod, "Kato");
kato.def(py::init<Model&, const GridBase<Real>&, Real, Real>(),
"model"_a, "surface"_a, "tolerance"_a, "mu"_a,
py::keep_alive<1, 2>(), py::keep_alive<1, 3>())
.def("solve", &Kato::solve, "p0"_a)
.def("solveRelaxed", &Kato::solveRelaxed, "g0"_a)
.def("computeCost", &Kato::computeCost);
py::class_<BeckTeboulle, ContactSolver> bt(mod, "BeckTeboulle");
bt.def(py::init<Model&, const GridBase<Real>&, Real, Real>(),
"model"_a, "surface"_a, "tolerance"_a, "mu"_a,
py::keep_alive<1, 2>(), py::keep_alive<1, 3>())
.def("solve", &BeckTeboulle::solve, "p0"_a)
.def("solveRelaxed", &BeckTeboulle::solveRelaxed, "g0"_a)
.def("computeCost", &BeckTeboulle::computeCost);
}
} // namespace wrap
__END_TAMAAS__

Event Timeline