BoundaryConstraint.cpp 1.22 KB
Newer Older
1
2
#include "BoundaryConstraint.h"
#include "DartConstraint.h"
3
#include "Mesh.h"
4
5
6
7
8
9
10
11
12
13
14

void BoundaryConstraint::add_to_queue(std::vector<std::unique_ptr<InsertionQueuer>> &queue, std::vector<DartConstraint> &constraints, size_t dart_constraint) {
    if (UniformDiscretization) {
        for (size_t dc : DartConstraints) {
            size_t dart = constraints[dc].dart();
            queue.push_back(std::make_unique<MidpointQueuer>(dart));
        }
    } else {
        size_t dart = constraints[dart_constraint].dart();
        queue.push_back(std::make_unique<MidpointQueuer>(dart));
    }
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
}

void BoundaryConstraint::refine(Mesh &m, double_t tol) {
    double_t err_max{DBL_MAX};

    while (err_max > tol) {
        err_max = 0.0;
        for (size_t i : DartConstraints) {
            DartConstraint const &dc = m.dart_constraint(i);

            double_t len_c = ConstraintCurve->length(dc.S0, dc.S1);
            double_t len_e = m.edge(dc.dart()).length(m);
            double_t err_i = std::abs(len_c - len_e) / len_c;

            if (err_i > tol) {
                m.add_to_queue(std::make_unique<MidpointQueuer>(dc.dart()));

                err_max = std::max(err_max, err_i);
            }
        }

        m.insert_from_queue();
    }
38
}