Integrate Refactor solver sources and dual MSVC CMake builds
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
@@ -13,6 +14,8 @@
|
||||
|
||||
#include "fesa/elements/thermal_element_layout.h"
|
||||
|
||||
#include "assembly/ordered_contribution_internal.h"
|
||||
|
||||
namespace fesa {
|
||||
namespace {
|
||||
|
||||
@@ -92,6 +95,7 @@ struct SumInterval {
|
||||
|
||||
struct LocalContribution {
|
||||
std::optional<ThermalShell> kernel;
|
||||
std::unique_ptr<ThermalElement> element;
|
||||
std::array<std::size_t, 20> scatter{};
|
||||
std::vector<CooContribution> conductivity;
|
||||
std::vector<CooContribution> capacity;
|
||||
@@ -105,8 +109,8 @@ Result<SparseMatrix> AssembleError(const SparseMatrix& matrix,
|
||||
bool capacity) {
|
||||
std::vector<SumInterval> sums(matrix.Values().size());
|
||||
for (const auto& contribution : local) {
|
||||
const Matrix& error = capacity ? contribution.kernel->CapacityError()
|
||||
: contribution.kernel->ConductivityError();
|
||||
const Matrix& error = capacity ? contribution.element->CapacityError()
|
||||
: contribution.element->ConductivityError();
|
||||
const auto& values =
|
||||
capacity ? contribution.capacity : contribution.conductivity;
|
||||
for (const auto& value : values) {
|
||||
@@ -215,16 +219,21 @@ Result<ThermalAssembly> AssembleThermal(const AnalysisModel& model,
|
||||
std::copy(scatter.Value().begin(), scatter.Value().end(),
|
||||
output.scatter.begin());
|
||||
output.kernel = std::move(kernel.Value());
|
||||
// local is fully sized before workers run; this optional cannot move
|
||||
// until every local matrix/error consumer has finished.
|
||||
output.element = std::make_unique<Ds4ThermalAdapter>(*output.kernel);
|
||||
output.conductivity.reserve(400);
|
||||
output.capacity.reserve(400);
|
||||
const Matrix& conductivity_matrix = output.element->Conductivity();
|
||||
const Matrix& capacity_matrix = output.element->Capacity();
|
||||
for (std::size_t i = 0; i < 20; ++i)
|
||||
for (std::size_t j = 0; j < 20; ++j) {
|
||||
output.conductivity.push_back({output.scatter[i], output.scatter[j],
|
||||
output.kernel->Conductivity()(i, j),
|
||||
index, 20 * i + j});
|
||||
output.capacity.push_back({output.scatter[i], output.scatter[j],
|
||||
output.kernel->Capacity()(i, j), index,
|
||||
20 * i + j});
|
||||
assembly_internal::AppendLocalMatrixEntry(
|
||||
output.scatter, i, j, conductivity_matrix(i, j), index,
|
||||
output.conductivity);
|
||||
assembly_internal::AppendLocalMatrixEntry(
|
||||
output.scatter, i, j, capacity_matrix(i, j), index,
|
||||
output.capacity);
|
||||
}
|
||||
});
|
||||
std::vector<CooContribution> conductivity;
|
||||
@@ -310,7 +319,11 @@ ThermalAssembly::ThermalAssembly(
|
||||
input_error_{std::move(input_error)},
|
||||
element_order_{std::move(element_order)},
|
||||
kernels_{std::move(kernels)},
|
||||
scatters_{std::move(scatters)} {}
|
||||
scatters_{std::move(scatters)} {
|
||||
elements_.reserve(kernels_.size());
|
||||
for (const auto& kernel : kernels_)
|
||||
elements_.push_back(std::make_unique<Ds4ThermalAdapter>(kernel));
|
||||
}
|
||||
const SparseMatrix& ThermalAssembly::Conductivity() const noexcept {
|
||||
return conductivity_;
|
||||
}
|
||||
@@ -330,6 +343,10 @@ const Vector& ThermalAssembly::HeatInputError() const noexcept {
|
||||
const std::vector<EntityIndex>& ThermalAssembly::ElementOrder() const noexcept {
|
||||
return element_order_;
|
||||
}
|
||||
const std::vector<std::unique_ptr<ThermalElement>>&
|
||||
ThermalAssembly::Elements() const noexcept {
|
||||
return elements_;
|
||||
}
|
||||
const std::vector<ThermalShell>& ThermalAssembly::Kernels() const noexcept {
|
||||
return kernels_;
|
||||
}
|
||||
@@ -358,7 +375,7 @@ Result<std::vector<ThermalElementFlux>> ThermalAssembly::RecoverFlux(
|
||||
std::array<double, 20> local{};
|
||||
for (std::size_t p = 0; p < 20; ++p)
|
||||
local[p] = temperature[scatters_[index][p]];
|
||||
const auto result = kernels_[index].Recover(local);
|
||||
const auto result = elements_[index]->Recover(local);
|
||||
if (!result.HasValue()) {
|
||||
status[index] = result.GetStatus();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user