peclet.voro 1.0.4
Device-native moving-particle Voronoi dynamics
Loading...
Searching...
No Matches
voro_bindings_optim.hpp
Go to the documentation of this file.
1
3#ifndef PECLET_VORO_BINDINGS_OPTIM_HPP
4#define PECLET_VORO_BINDINGS_OPTIM_HPP
5
8
9namespace peclet::voro::pybind {
10
11// The CG preconditioner / descent method of the mesh optimisers, as a string mode.
12constexpr const char* kMethodList = "'jacobi', 'colored_gs', 'graphamg', 'steepest'";
13inline peclet::voro::Precond parseMethod(const std::string& m, const char* fn) {
14 if (m == "jacobi")
16 if (m == "colored_gs")
18 if (m == "graphamg")
20 if (m == "steepest")
22 throw std::invalid_argument(std::string("voro: ") + fn + "(method='" + m +
23 "') is not a method; accepted: " + kMethodList + ".");
24}
25
26inline OptimizeResult makeOptimizeResult(std::vector<real_t> pos,
27 std::optional<std::vector<real_t>> w,
28 const peclet::voro::OtResult& R) {
30 r.positions = nb::cast(toNumpy3(std::move(pos)));
31 r.weights = w ? nb::cast(toNumpy1(std::move(*w))) : nb::none();
32 r.iters = R.iters;
35 r.converged = R.converged;
36 r.num_empty = (int)R.nEmpty;
37 return r;
38}
39
40} // namespace peclet::voro::pybind
41
42#endif // PECLET_VORO_BINDINGS_OPTIM_HPP
Energy-minimisation mesh optimiser over seed positions (pure Voronoi) and, optionally,...
Definition voro_bindings_common.hpp:45
nb::ndarray< nb::numpy, real_t > toNumpy3(std::vector< real_t > v)
Definition voro_bindings_common.hpp:225
nb::ndarray< nb::numpy, real_t > toNumpy1(std::vector< real_t > v)
Definition voro_bindings_common.hpp:229
constexpr const char * kMethodList
Definition voro_bindings_optim.hpp:12
OptimizeResult makeOptimizeResult(std::vector< real_t > pos, std::optional< std::vector< real_t > > w, const peclet::voro::OtResult &R)
Definition voro_bindings_optim.hpp:26
peclet::voro::Precond parseMethod(const std::string &m, const char *fn)
Definition voro_bindings_optim.hpp:13
Precond
Definition mesh_optimizer.hpp:47
Definition ot_optimizer.hpp:46
double meanVolErr
mean |V_i − V_set_i|
Definition ot_optimizer.hpp:49
double maxVolErr
max_i |V_i − V_set_i|
Definition ot_optimizer.hpp:48
long nEmpty
buried/empty cells at the final state (should be 0 for a feasible target)
Definition ot_optimizer.hpp:51
int iters
Definition ot_optimizer.hpp:47
bool converged
Definition ot_optimizer.hpp:50
Definition voro_bindings_common.hpp:237
bool converged
Definition voro_bindings_common.hpp:242
nb::object positions
(N,3) float64
Definition voro_bindings_common.hpp:238
int iters
Definition voro_bindings_common.hpp:240
int num_empty
Definition voro_bindings_common.hpp:243
nb::object weights
(N,) float64 when the power weights were optimised, else None
Definition voro_bindings_common.hpp:239
double max_vol_err
Definition voro_bindings_common.hpp:241
double mean_vol_err
Definition voro_bindings_common.hpp:241
Internal helpers shared by the translation units of the peclet.voro nanobind module.