3#include <wmtk/ExecutionScheduler.hpp>
4#include <wmtk/threading/collector.hpp>
5#include <wmtk/threading/parallel_for.hpp>
26template <
class Mesh,
class Emit>
27OpList<typename Mesh::Tuple> parallel_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 OpList<Tuple> collect;
32 std::mutex collect_mutex;
34 threading::parallel_for(
35 threading::range(0, m.cell_capacity()),
36 [&](
const threading::range& r) {
38 for (size_t i = r.begin(); i < r.end(); i++) {
39 if (!m.tuple_from_cell(i).is_valid(m)) {
42 for (size_t j = 0; j < n_edges; j++) {
43 const Tuple e = m.tuple_from_edge(i, j);
44 if (e.eid(m) == n_edges * i + j) {
52 std::lock_guard<std::mutex> lock(collect_mutex);
53 collect.append(std::move(local));
60template <
class Mesh,
class Emit>
61OpList<typename Mesh::Tuple> parallel_collect_face_ops(Mesh& m,
int num_threads, Emit&& emit)
63 using Tuple =
typename Mesh::Tuple;
64 constexpr size_t n_faces = Mesh::FACES_PER_CELL;
67 "parallel_collect_face_ops requires a mesh with faces below its cells");
68 OpList<Tuple> collect;
69 std::mutex collect_mutex;
71 threading::parallel_for(
72 threading::range(0, m.cell_capacity()),
73 [&](
const threading::range& r) {
75 for (size_t i = r.begin(); i < r.end(); i++) {
76 if (!m.tuple_from_cell(i).is_valid(m)) {
79 for (size_t j = 0; j < n_faces; j++) {
80 const Tuple f = m.tuple_from_face(i, j);
81 if (f.fid(m) == n_faces * i + j) {
89 std::lock_guard<std::mutex> lock(collect_mutex);
90 collect.append(std::move(local));