feat: add analysis state and base

This commit is contained in:
김경종
2026-06-09 15:12:41 +09:00
parent 7ea08441ed
commit 87529c811a
18 changed files with 1159 additions and 0 deletions
+115
View File
@@ -0,0 +1,115 @@
#include "fesa/core/AnalysisState.hpp"
#include <algorithm>
#include <stdexcept>
#include <utility>
namespace fesa::core {
AnalysisState::AnalysisState()
: AnalysisState(0) {}
AnalysisState::AnalysisState(std::size_t dof_count)
: dof_count_(0),
current_time_(0.0),
increment_index_(0),
iteration_index_(0) {
resize(dof_count);
}
std::size_t AnalysisState::dofCount() const noexcept {
return dof_count_;
}
void AnalysisState::resize(std::size_t dof_count) {
dof_count_ = dof_count;
displacement_.assign(dof_count_, 0.0);
external_force_.assign(dof_count_, 0.0);
internal_force_.assign(dof_count_, 0.0);
residual_.assign(dof_count_, 0.0);
reaction_.assign(dof_count_, 0.0);
}
const std::vector<double>& AnalysisState::displacement() const noexcept {
return displacement_;
}
const std::vector<double>& AnalysisState::externalForce() const noexcept {
return external_force_;
}
const std::vector<double>& AnalysisState::internalForce() const noexcept {
return internal_force_;
}
const std::vector<double>& AnalysisState::residual() const noexcept {
return residual_;
}
const std::vector<double>& AnalysisState::reaction() const noexcept {
return reaction_;
}
void AnalysisState::setDisplacement(std::vector<double> values) {
setVector(displacement_, std::move(values));
}
void AnalysisState::setExternalForce(std::vector<double> values) {
setVector(external_force_, std::move(values));
}
void AnalysisState::setInternalForce(std::vector<double> values) {
setVector(internal_force_, std::move(values));
}
void AnalysisState::setResidual(std::vector<double> values) {
setVector(residual_, std::move(values));
}
void AnalysisState::setReaction(std::vector<double> values) {
setVector(reaction_, std::move(values));
}
void AnalysisState::clearForces() noexcept {
zero(external_force_);
zero(internal_force_);
zero(residual_);
zero(reaction_);
}
double AnalysisState::currentTime() const noexcept {
return current_time_;
}
void AnalysisState::setCurrentTime(double value) noexcept {
current_time_ = value;
}
std::int64_t AnalysisState::incrementIndex() const noexcept {
return increment_index_;
}
void AnalysisState::setIncrementIndex(std::int64_t value) noexcept {
increment_index_ = value;
}
std::int64_t AnalysisState::iterationIndex() const noexcept {
return iteration_index_;
}
void AnalysisState::setIterationIndex(std::int64_t value) noexcept {
iteration_index_ = value;
}
void AnalysisState::setVector(std::vector<double>& target, std::vector<double> values) {
if (values.size() != dof_count_) {
throw std::invalid_argument("analysis state vector size mismatch");
}
target = std::move(values);
}
void AnalysisState::zero(std::vector<double>& values) noexcept {
std::fill(values.begin(), values.end(), 0.0);
}
} // namespace fesa::core