8 MappableContainer::MappableContainer(
const Mesh& m)
31 if (&
mesh() != &invariant->mesh()) {
32 for (
const Tuple& ct :
mesh().map_tuples(invariant->mesh(), t)) {
33 if (!invariant->before(t)) {
38 if (!invariant->before(t)) {
45 bool MappableContainer::after(
46 const std::vector<Tuple>& top_dimension_tuples_before,
47 const std::vector<Tuple>& top_dimension_tuples_after)
const
50 if (&
mesh() != &invariant->mesh()) {
53 mesh().top_simplex_type(),
54 top_dimension_tuples_after);
58 mesh().top_simplex_type(),
59 top_dimension_tuples_before);
61 if (!invariant->after(mapped_tuples_before, mapped_tuples_after)) {
65 if (!invariant->after(top_dimension_tuples_before, top_dimension_tuples_after)) {
69 assert(&
mesh() != &invariant->mesh());
77 bool MappableContainer::directly_modified_after(
78 const std::vector<simplex::Simplex>& simplices_before,
79 const std::vector<simplex::Simplex>& simplices_after)
const
82 if (&
mesh() != &invariant->mesh()) {
83 auto mapped_simplices_after =
mesh().
map(invariant->mesh(), simplices_after);
85 [&]() {
return mesh().
map(invariant->mesh(), simplices_before); });
86 if (!invariant->directly_modified_after(
87 mapped_simplices_before,
88 mapped_simplices_after)) {
92 if (!invariant->directly_modified_after(simplices_before, simplices_after)) {
112 const std::vector<std::shared_ptr<Mappable>>& MappableContainer::invariants()
const
117 std::map<Mesh const*, std::vector<std::shared_ptr<Mappable>>>
122 throw std::runtime_error(
"Untested code. Potentially wrong.");
124 for (std::shared_ptr<Mappable> inv :
m_mappables) {
131 for (
const auto& [mptr, i] : sub_map) {
132 auto& vec = mesh_invariants_map[mptr];
133 vec.insert(vec.end(), i.begin(), i.end());
136 mesh_invariants_map[&(inv->mesh())].push_back(inv);
std::vector< Tuple > map_tuples(const Mesh &other_mesh, const simplex::Simplex &my_simplex) const
maps a simplex from this mesh to any other mesh
std::vector< simplex::Simplex > map(const Mesh &other_mesh, const simplex::Simplex &my_simplex) const
maps a simplex from this mesh to any other mesh
decltype(auto) parent_scope(Functor &&f, Args &&... args) const
Evaluate the passed in function inside the parent scope.
std::map< Mesh const *, std::vector< std::shared_ptr< Mappable > > > get_map_mesh_to_invariants()
void add(std::shared_ptr< Mappable > mappable)
const std::shared_ptr< Mappable > & get(int64_t index) const
MappableContainer & operator=(const MappableContainer &)
std::vector< std::shared_ptr< Mappable > > m_mappables
virtual const Mesh & mesh() const =0