Integrate Refactor solver sources and dual MSVC CMake builds

This commit is contained in:
KOKO\Mimi
2026-10-18 02:10:51 +09:00
parent 7ee32e5837
commit 12d51480de
218 changed files with 17842 additions and 9689 deletions
@@ -2,6 +2,7 @@
#include <cstddef>
#include <filesystem>
#include <limits>
#include <stdexcept>
#include <string>
#include <utility>
@@ -185,6 +186,24 @@ TEST(EssentialConstraints, HandlesNoAllAndMixedConstraints) {
ExpectShape(all.Value().k_cc, 6U, 6U);
EXPECT_EQ(all.Value().k_cc.Values(), full.Values());
fesa::Vector full_load{6U};
for (std::size_t i = 0U; i < full_load.Size(); ++i)
full_load[i] = static_cast<double>(i) - 2.0;
auto empty_rhs = policy.EffectiveFreeRhs(
full_load, all.Value().k_fc, all_constraints.PrescribedValues(),
all_constraints);
ASSERT_TRUE(empty_rhs.HasValue());
EXPECT_EQ(empty_rhs.Value().Size(), 0U);
auto full_rhs = policy.EffectiveFreeRhs(
full_load, none.Value().k_fc, no_constraints.PrescribedValues(),
no_constraints);
ASSERT_TRUE(full_rhs.HasValue());
for (std::size_t i = 0U; i < full_load.Size(); ++i) {
EXPECT_EQ(full_rhs.Value()[i], static_cast<double>(i) - 2.0);
EXPECT_EQ(full_load[i], static_cast<double>(i) - 2.0);
}
const auto mixed_constraints = MakeDofs({{"1", 3, 4, 0.0, {{}, 12U}}});
auto mixed = policy.Partition(full, mixed_constraints);
ASSERT_TRUE(mixed.HasValue());
@@ -316,3 +335,52 @@ TEST(EssentialConstraints, RejectsDimensionOrOrderMismatch) {
fesa::Vector{4U}, fesa::Vector{2U}, dofs)),
std::invalid_argument);
}
TEST(EssentialConstraints, PreservesEliminationFailureOrderAndInputs) {
const fesa::EssentialConstraintPolicy policy;
const auto dofs = MakeDofs({{"1", 2, 2, 2.0, {{}, 12U}},
{"1", 5, 5, -1.0, {{}, 13U}}});
const double maximum = (std::numeric_limits<double>::max)();
fesa::Vector load{6U};
load[0U] = std::numeric_limits<double>::infinity();
fesa::Vector prescribed{2U};
prescribed[0U] = std::numeric_limits<double>::infinity();
prescribed[1U] = 1.0;
const auto kfc = MakeMatrix(4U, 2U, {0.4 * maximum, 0.8 * maximum,
maximum, 0.0, 0.0, 0.0, 0.0, 0.0});
const auto original_values = kfc.Values();
const auto original_pattern = dofs.GetSparsePattern();
auto candidate = policy.EffectiveFreeRhs(
load, MakeMatrix(3U, 2U, std::vector<double>(6U)), prescribed, dofs);
ASSERT_FALSE(candidate.HasValue());
EXPECT_EQ(candidate.GetStatus().Diagnostics()[0U].code,
"invalid-load-dimensions");
candidate = policy.EffectiveFreeRhs(load, kfc, prescribed, dofs);
ASSERT_FALSE(candidate.HasValue());
EXPECT_EQ(candidate.GetStatus().Diagnostics()[0U].entity_identity,
"full-load:0");
EXPECT_EQ(load[0U], std::numeric_limits<double>::infinity());
EXPECT_EQ(prescribed[0U], std::numeric_limits<double>::infinity());
load[0U] = 7.0;
prescribed[0U] = 2.0;
candidate = policy.EffectiveFreeRhs(load, kfc, prescribed, dofs);
ASSERT_FALSE(candidate.HasValue());
EXPECT_EQ(candidate.GetStatus().Category(), fesa::FailureCategory::kModel);
ASSERT_EQ(candidate.GetStatus().Diagnostics().size(), 1U);
const auto& diagnostic = candidate.GetStatus().Diagnostics()[0U];
EXPECT_EQ(diagnostic.code, "nonfinite-load-accumulation");
EXPECT_EQ(diagnostic.keyword, "LOAD_ASSEMBLER");
EXPECT_EQ(diagnostic.entity_identity, "0");
EXPECT_TRUE(diagnostic.location.file.empty());
EXPECT_EQ(diagnostic.location.line, 0U);
EXPECT_EQ(diagnostic.message,
"Kfc times prescribed displacement produced a nonfinite row sum.");
EXPECT_EQ(load[0U], 7.0);
EXPECT_EQ(prescribed[0U], 2.0);
EXPECT_EQ(prescribed[1U], 1.0);
EXPECT_EQ(kfc.Values(), original_values);
EXPECT_EQ(dofs.GetSparsePattern().row_offsets, original_pattern.row_offsets);
EXPECT_EQ(dofs.GetSparsePattern().column_indices,
original_pattern.column_indices);
}