#include #include #include namespace { int fail() { return 1; } } // namespace int main() { fesa::fem::DofManager dofs; dofs.define_node_dofs(fesa::core::NodeId{2}, { fesa::model::DofComponent::ux, fesa::model::DofComponent::uy }); dofs.define_node_dofs(fesa::core::NodeId{1}, { fesa::model::DofComponent::uy, fesa::model::DofComponent::ux }); dofs.apply_boundary_condition({ fesa::core::NodeId{1}, fesa::model::DofComponent::ux, 0.0 }); dofs.number_equations(); const fesa::fem::DofKey n1ux{fesa::core::NodeId{1}, fesa::model::DofComponent::ux}; const fesa::fem::DofKey n1uy{fesa::core::NodeId{1}, fesa::model::DofComponent::uy}; const fesa::fem::DofKey n2ux{fesa::core::NodeId{2}, fesa::model::DofComponent::ux}; const fesa::fem::DofKey n2uy{fesa::core::NodeId{2}, fesa::model::DofComponent::uy}; if (dofs.total_dof_count() != 4 || dofs.constrained_dof_count() != 1 || dofs.free_dof_count() != 3) { return fail(); } if (dofs.equation_id(n1ux) != 0 || dofs.equation_id(n1uy) != 1 || dofs.equation_id(n2ux) != 2 || dofs.equation_id(n2uy) != 3) { return fail(); } if (!dofs.is_constrained(n1ux) || dofs.free_equation_id(n1ux).has_value()) { return fail(); } if (!dofs.free_equation_id(n1uy).has_value() || *dofs.free_equation_id(n1uy) != 0 || *dofs.free_equation_id(n2ux) != 1 || *dofs.free_equation_id(n2uy) != 2) { return fail(); } const auto full = dofs.expand_free_vector({11.0, 22.0, 33.0}); if (full.size() != 4 || full[0] != 0.0 || full[1] != 11.0 || full[2] != 22.0 || full[3] != 33.0) { return fail(); } const auto& pattern = dofs.sparse_pattern(); if (pattern.size() != 9 || pattern.front() != std::pair{0, 0} || pattern.back() != std::pair{2, 2}) { return fail(); } try { (void)dofs.equation_id({fesa::core::NodeId{99}, fesa::model::DofComponent::ux}); return fail(); } catch (const std::invalid_argument&) { } return 0; }