3#include <wmtk/ExecutionScheduler.hpp>
4#include <wmtk/threading/collector.hpp>
5#include <wmtk/threading/parallel_for.hpp>
25template <
class Mesh,
class Emit>
26std::vector<std::pair<Op, typename Mesh::Tuple>>
27parallel_collect_edge_ops(Mesh& m,
int num_threads, Emit&& emit)
29 using Tuple =
typename Mesh::Tuple;
30 constexpr size_t n_edges = Mesh::EDGES_PER_CELL;
31 threading::collector<std::pair<Op, Tuple>> collect;
33 threading::parallel_for(
34 threading::range(0, m.cell_capacity()),
35 [&](
const threading::range& r) {
36 std::vector<std::pair<Op, Tuple>> local;
37 for (size_t i = r.begin(); i < r.end(); i++) {
38 if (!m.tuple_from_cell(i).is_valid(m)) {
41 for (size_t j = 0; j < n_edges; j++) {
42 const Tuple e = m.tuple_from_edge(i, j);
43 if (e.eid(m) == n_edges * i + j) {
51 collect.append(local);
55 return collect.data();
58template <
class Mesh,
class Emit>
59std::vector<std::pair<Op, typename Mesh::Tuple>>
60parallel_collect_face_ops(Mesh& m,
int num_threads, Emit&& emit)
62 using Tuple =
typename Mesh::Tuple;
63 constexpr size_t n_faces = Mesh::FACES_PER_CELL;
66 "parallel_collect_face_ops requires a mesh with faces below its cells");
67 threading::collector<std::pair<Op, Tuple>> collect;
69 threading::parallel_for(
70 threading::range(0, m.cell_capacity()),
71 [&](
const threading::range& r) {
72 std::vector<std::pair<Op, Tuple>> local;
73 for (size_t i = r.begin(); i < r.end(); i++) {
74 if (!m.tuple_from_cell(i).is_valid(m)) {
77 for (size_t j = 0; j < n_faces; j++) {
78 const Tuple f = m.tuple_from_face(i, j);
79 if (f.fid(m) == n_faces * i + j) {
87 collect.append(local);
91 return collect.data();