20# include "bitpit_common.hpp"
21# include "bitpit_SA.hpp"
29namespace CGAlgorithms{
34 std::vector<std::array<double,3>> &Vertex,
35 std::vector<std::vector<int>> &Simplex,
36 std::vector<std::vector<std::vector<int>>> &Adjacency,
37 std::vector<double> &val,
41 std::vector<bool> &flag
89double value = 1.0e+18, value_0 = 1.0e+18;
90std::array<double,3> P0;
104W = Simplex[T][(i+1) % Simplex[T].size()];
108 value = std::min(value, value_0 + g *
norm2(Vertex[V] - P0));
110if (Adjacency[T][i][0] >= 0) {
111 m = Adjacency[T][i].size();
112 for (k = 0; k < m; k++) {
113 A = Adjacency[T][i][k];
115 if (Simplex[A][0] == V) { j = 1; }
121 value = std::min(value, value_0 + g *
norm2(Vertex[V] - P0));
127value = std::min(val[V], value);
134 std::vector<std::array<double,3>> &Vertex,
135 std::vector<std::vector<int>> &Simplex,
136 std::vector<std::vector<std::vector<int>>> &Adjacency,
137 std::vector<double> &val,
177int nVertex = Vertex.size();
179std::vector<bool> inserted(nVertex,
false);
180std::vector<int> idummy1D(2, -1);
183std::vector< std::array<int,2> > map(nVertex), *map_ = ↦
191for (V = 0; V < nVertex; V++) {
201for (T = 0; T < nSimplex; T++) {
202 m = Simplex[T].size();
203 for (i = 0; i < m; i++) {
214 heap.insert(val[V], idummy1D);
226while (heap.heap_size > 0) {
229 heap.extract(ddummy, idummy1D);
238 j = (i + 1) % Simplex[T].size();
241 val[W] = grad1DUpdate(nSimplex, Vertex, Simplex, Adjacency, val, T, j, g, inserted);
245 if (Adjacency[T][i][0] >= 0) {
246 m = Adjacency[T][i].size();
247 for (k = 0; k < m; k++) {
248 A = Adjacency[T][i][k];
250 if (Simplex[A][0] == V) { j = 1; }
253 val[W] = grad1DUpdate(nSimplex, Vertex, Simplex, Adjacency, val, A, j, g, inserted);
256 heap.modify(map[W][1], val[W], idummy1D);
267 std::vector<std::array<double,3>> &Vertex,
268 std::vector<std::vector<int>> &Simplex,
269 std::vector<std::vector<std::vector<int>>> &ring_1,
270 std::vector<double> &val,
274 std::vector<bool> &flag
321double value = 1.0e+18;
335for (j = 0; j < ring_1[V].size(); ++j) {
338 m = (k - 1 + Simplex[A].size()) % Simplex[A].size();
341 value = std::min(value, val[W] + g *
norm2(Vertex[V] - Vertex[W]));
343 m = (k + 1) % Simplex[A].size();
346 value = std::min(value, val[W] + g *
norm2(Vertex[V] - Vertex[W]));
351value = std::min(val[V], value);
358 std::vector<std::array<double,3>> &Vertex,
359 std::vector<std::vector<int>> &Simplex,
360 std::vector<double> &val,
395int nVertex = Vertex.size();
397std::vector<bool> inserted(nVertex,
false);
398std::vector<int> idummy1D(2, -1);
399std::vector<std::vector<std::vector<int>>> Ring1(nVertex);
400std::vector< std::array<int,2> > map(nVertex), *map_ = ↦
409for (V = 0; V < nVertex; V++) {
416for (T = 0; T < nSimplex; T++) {
417 m = Simplex[T].size();
418 for (i = 0; i < m; ++i) {
422 Ring1[V].push_back(idummy1D);
432for (T = 0; T < nSimplex; T++) {
433 m = Simplex[T].size();
434 for (i = 0; i < m; i++) {
445 heap.insert(val[V], idummy1D);
457while (heap.heap_size > 0) {
460 heap.extract(ddummy, idummy1D);
469 for (j = 0; j < Ring1[V].size(); ++j) {
472 m = (k - 1 + Simplex[A].size()) % Simplex[A].size();
475 val[W] = grad2DUpdate(nSimplex, Vertex, Simplex, Ring1, val, A, m, g, inserted);
478 heap.modify(map[W][1], val[W], idummy1D);
480 m = (k + 1) % Simplex[A].size();
483 val[W] = grad2DUpdate(nSimplex, Vertex, Simplex, Ring1, val, A, m, g, inserted);
486 heap.modify(map[W][1], val[W], idummy1D);
496 std::vector<std::array<double,3>> &Vertex,
497 std::vector<std::vector<int>> &Simplex,
498 std::vector<std::vector<int>> &Adjacency,
499 std::vector<double> &val,
502 std::vector<bool> &flag
548double value = 1.0e+18;
558m = Adjacency[T].size();
559for (j = 0; j < m; ++j) {
562 value = std::min(value, val[A] + g *
norm2(Vertex[T] - Vertex[A]));
567value = std::min(val[T], value);
574 std::vector<std::array<double,3>> &Vertex,
575 std::vector<std::vector<int>> &Simplex,
576 std::vector<std::vector<int>> &Adjacency,
577 std::vector<double> &val,
616std::vector<bool> inserted(nSimplex,
false);
617std::vector< std::array<int,2> > map(nSimplex), *map_ = ↦
625for (T = 0; T < nSimplex; T++) {
635for (T = 0; T < nSimplex; T++) {
644 heap.insert(val[T], idummy);
655while (heap.heap_size > 0) {
658 heap.extract(ddummy, idummy);
665 m = Adjacency[T].size();
666 for (j = 0; j < m; ++j) {
669 val[A] = grad2DUpdate(nSimplex, Vertex, Simplex, Adjacency, val, A, g, inserted);
671 heap.modify(map[A][1], val[A], idummy);
class for min priority queue.
double norm2(const std::array< T, d > &x)
#define BITPIT_UNUSED(variable)