Andlon/dynamecs

Provide convenience register_insert_components functions and similar

Opened this issue · 0 comments

Andlon commented

Currently inserting several components for the same entity is very verbose:

universe.register_insert_component(obj, Name::from("box"));
universe.register_insert_component(obj, initial_state);
universe.register_insert_component(
    obj,
    MassDistribution::for_mesh_with_uniform_density(&mesh, density),
);
universe.register_insert_component(
    obj,
    ElasticSolidMaterial::for_mesh_with_uniform_parameters(&mesh, NeoHookeanMaterial, lame),
);
universe.register_insert_component(obj, FiniteElementDomain { mesh });

We could provide [register_]insert_components functions that allow you to simplify the above to

universe.register_insert_components(obj, (
    Name::from("box"),
    initial_state,
    MassDistribution::for_mesh_with_uniform_density(&mesh, density),
    ElasticSolidMaterial::for_mesh_with_uniform_parameters(&mesh, NeoHookeanMaterial, lame),
    FiniteElementDomain { mesh }
));