feat(cpp-object-oriented-modular-refactoring): step 13 - element-definition-domain

This commit is contained in:
KOKO\Mimi
2026-08-16 09:10:38 +09:00
parent cf6fc6e1d9
commit 19ba02a6a4
26 changed files with 740 additions and 242 deletions
+29 -27
View File
@@ -51,19 +51,19 @@ Result<SparseMatrix> SparseAssembler::AssembleStiffness(
std::to_string(dofs.FullDofCount()),
"DofManager dimensions do not match the active model nodes.");
}
if (!model.ActiveElements().empty() && !domain.ShellElements().empty()) {
if (!model.ActiveBeamElements().empty() && !domain.ShellElements().Empty()) {
return AssemblyFailure(
"unsupported-mixed-element-model", {domain.SourcePath(), 0U},
"B33:FESA-MITC4",
"Sparse assembly does not support mixed beam and shell models.");
}
if (!domain.ShellElements().empty()) {
if (domain.ShellElements().size() >
if (!domain.ShellElements().Empty()) {
if (domain.ShellElements().Size() >
(std::numeric_limits<std::size_t>::max)() / kShellContributionCount) {
return AssemblyFailure(
"invalid-assembly-dimensions", {domain.SourcePath(), 0U},
std::to_string(domain.ShellElements().size()),
std::to_string(domain.ShellElements().Size()),
"Shell contribution storage exceeds the addressable range.");
}
@@ -88,12 +88,12 @@ Result<SparseMatrix> SparseAssembler::AssembleStiffness(
std::array<std::size_t, kShellElementDofCount> scatter;
};
std::vector<ShellInput> inputs;
inputs.reserve(domain.ShellElements().size());
inputs.reserve(domain.ShellElements().Size());
for (std::size_t element_order = 0U;
element_order < domain.ShellElements().size(); ++element_order) {
element_order < domain.ShellElements().Size(); ++element_order) {
const auto& element = domain.ShellElements()[element_order];
if (element.material_index >= domain.Materials().size() ||
element.section_index >= domain.ShellSections().size()) {
if (element.material_index >= domain.LinearElasticMaterials().Size() ||
element.section_index >= domain.ShellSections().Size()) {
return AssemblyFailure(
"invalid-assembly-element", element.location,
element.source_id.source_label_text,
@@ -102,7 +102,7 @@ Result<SparseMatrix> SparseAssembler::AssembleStiffness(
ShellInput input{};
input.section = &domain.ShellSections()[element.section_index];
input.material = &domain.Materials()[element.material_index];
input.material = &domain.LinearElasticMaterials()[element.material_index];
try {
input.scatter =
dofs.ShellElementScatter(static_cast<EntityIndex>(element_order));
@@ -191,28 +191,28 @@ Result<SparseMatrix> SparseAssembler::AssembleStiffness(
dofs.GetSparsePattern());
}
if (model.ActiveElements().size() >
if (model.ActiveBeamElements().size() >
(std::numeric_limits<std::size_t>::max)() / kBeamContributionCount) {
return AssemblyFailure(
"invalid-assembly-dimensions", {domain.SourcePath(), 0U},
std::to_string(model.ActiveElements().size()),
std::to_string(model.ActiveBeamElements().size()),
"Element contribution storage exceeds the addressable range.");
}
std::vector<std::array<std::size_t, kBeamElementDofCount>> scatters;
scatters.reserve(model.ActiveElements().size());
for (const EntityIndex element_index : model.ActiveElements()) {
if (element_index >= domain.Elements().size()) {
scatters.reserve(model.ActiveBeamElements().size());
for (const EntityIndex element_index : model.ActiveBeamElements()) {
if (element_index >= domain.BeamElements().Size()) {
return AssemblyFailure("invalid-assembly-element",
{domain.SourcePath(), 0U},
std::to_string(element_index),
"Active element index is outside the Domain.");
}
const auto& element = domain.Elements()[element_index];
const auto& element = domain.BeamElements()[element_index];
if (element.node_indices[0U] >= domain.Nodes().size() ||
element.node_indices[1U] >= domain.Nodes().size() ||
element.material_index >= domain.Materials().size() ||
element.section_index >= domain.Sections().size()) {
element.material_index >= domain.LinearElasticMaterials().Size() ||
element.section_index >= domain.Sections().Size()) {
return AssemblyFailure(
"invalid-assembly-element", element.location,
element.source_id.source_label_text,
@@ -247,18 +247,20 @@ Result<SparseMatrix> SparseAssembler::AssembleStiffness(
scatters.push_back(scatter);
}
std::vector<BeamElementBuffer> local_buffers(model.ActiveElements().size());
std::vector<BeamElementBuffer> local_buffers(
model.ActiveBeamElements().size());
std::vector<std::optional<Status>> local_failures(
model.ActiveElements().size());
model.ActiveBeamElements().size());
parallel_for.Execute(
model.ActiveElements().size(), [&](const std::size_t element_order) {
const EntityIndex element_index = model.ActiveElements()[element_order];
const auto& definition = domain.Elements()[element_index];
const auto beam =
EulerBeam3D::Create(domain.Nodes()[definition.node_indices[0U]],
domain.Nodes()[definition.node_indices[1U]],
domain.Sections()[definition.section_index],
domain.Materials()[definition.material_index]);
model.ActiveBeamElements().size(), [&](const std::size_t element_order) {
const EntityIndex element_index =
model.ActiveBeamElements()[element_order];
const auto& definition = domain.BeamElements()[element_index];
const auto beam = EulerBeam3D::Create(
domain.Nodes()[definition.node_indices[0U]],
domain.Nodes()[definition.node_indices[1U]],
domain.Sections()[definition.section_index],
domain.LinearElasticMaterials()[definition.material_index]);
if (!beam.HasValue()) {
local_failures[element_order] = beam.GetStatus();
return;