Wildmeshing Toolkit
Loading...
Searching...
No Matches
src
wmtk
utils
Preallocation.hpp
1
#pragma once
2
3
#include <nlohmann/json.hpp>
4
5
namespace
wmtk {
6
7
// Applies a JSON-configured preallocation factor to a mesh, if present.
8
//
9
// The mesh storage (connectivity + attributes) is preallocated to
10
// max(floor, ceil(factor * live_count)) at init / consolidation; operations grab
11
// fresh slots from that headroom and fail (are retried later) once it is
12
// exhausted. The default (see TetMesh/TriMesh) suits the bundled integration
13
// tests; set "preallocation_factor" in the component's JSON to tune it per input
14
// (e.g. lower for pure-decimation runs, higher for aggressive refinement).
15
template
<
class
Mesh>
16
inline
void
set_preallocation_factor_from_json(Mesh& mesh,
const
nlohmann::json& j)
17
{
18
if
(j.contains(
"preallocation_factor"
)) {
19
mesh.set_preallocation_factor(j[
"preallocation_factor"
].
template
get<double>());
20
}
21
}
22
23
}
// namespace wmtk
Generated by
1.9.8