2#ifndef model_SimplexFactory_H_
3#define model_SimplexFactory_H_
11 template <
short int dim,
short int order>
class Simplex;
13 template <
short int dim,
short int order>
18 using Pointer = std::shared_ptr<Simplex<dim, order>>;
34 if constexpr (
order == dim)
36 static_assert(
sizeof...(Args) == 1);
37 if (existing->region->regionID !=
size_t(std::get<0>(std::tie(args...))))
39 throw std::runtime_error(
"A volume simplex cannot belong to two regions");
45 if constexpr (
order > 0)
48 for (
const auto &child : simplex->children())
50 child->addParent(simplex);
57 std::map<KeyType, Pointer>
result;
58 for (
const auto &entry : *
this)
60 if (
const auto simplex = entry.second.lock())
62 result.emplace(entry.first, simplex);
69 for (
auto entry = this->begin(); entry != this->
end();)
71 if (entry->second.expired())
73 entry = this->erase(entry);
85 for (
size_t k = 0;
k <
result.size(); ++
k)
105 std::apply([owner](
auto &...
factory) { ((
factory.mesh = owner), ...); }, factories);
109 return std::get<order>(factories);
111 template <
short int order>
const auto &
factory()
const
113 return std::get<order>(factories);
117 std::apply([](
auto &...
factory) { (
factory.clear(), ...); }, factories);
const auto & factory() const
SimplexFactories(SimplicialMesh< dim > *owner)
SimplexFactory & operator=(const SimplexFactory &)=delete
auto liveSimplices() const
SimplicialMesh< dim > * mesh
SimplexFactory(const SimplexFactory &)=delete
auto faces(const KeyType &id)
WeakPtrFactory< SimplexFactory< dim, order >, Simplex< dim, order > > Base
std::shared_ptr< Simplex< dim, order > > Pointer
typename SimplexTraits< dim, order >::SimplexIDType KeyType
Pointer getOrCreate(const KeyType &input, const Args &...args)
std::tuple< SimplexFactory< dim, short(orders)>... > Type
static SimplexTraits< dim, order-1 >::SimplexIDType faceID(const SimplexIDType &xID, const size_t &j)
static SimplexIDType sortID(const SimplexIDType &vIN)
std::array< std::shared_ptr< Simplex< dim, order-1 > >, nFaces > BaseArrayType
SimplexID< nVertices > SimplexIDType
SharedPtrType create(const Args &...args)
SharedPtrType get(const KeyType &key) const