Files
FESADev/src/fesa/analysis/hht_reduced_integrator.h
T

75 lines
2.8 KiB
C++

#ifndef FESA_ANALYSIS_HHT_REDUCED_INTEGRATOR_H_
#define FESA_ANALYSIS_HHT_REDUCED_INTEGRATOR_H_
#include <utility>
#include "analysis/hht_reduced_internal.h"
namespace fesa::hht_reduced_internal {
struct ReducedHistory {
Vector p{0U};
Vector velocity{0U};
Vector acceleration{0U};
Vector algorithmic_acceleration{0U};
Vector z{0U};
};
/// @brief Keeps every private predictor compensation channel before a trial.
struct ReducedShellPredictor {
Vector pp{0U};
Vector vpp{0U};
Vector coordinate_low{0U};
Vector increment_trace{0U};
Vector increment_trace_compensation{0U};
Vector increment_trace_absolute_sum{0U};
};
struct ReducedShellRateRequest {
const FixedChart& chart;
const ReducedHistory& history;
const Vector& trial_algorithmic;
const Vector& vpp;
bool copy_translation_rates;
const Vector& retained_velocity;
const Vector& retained_acceleration;
double h;
const HhtParameters& parameters;
};
struct ReducedShellTrialRates {
Vector velocity{0U};
Vector acceleration{0U};
};
/// @brief Handles private shell predictors and exact sparse rate
/// reconstruction.
/// @note Chart/root/solver are non-owning call views; no history is committed.
class ShellHhtIntegrator {
public:
virtual ~ShellHhtIntegrator() = default;
virtual ReducedShellPredictor
Predict(const ReducedHistory& history, double h,
const HhtParameters& parameters) const = 0;
/// @note Output buffers have history.p.Size() entries and do not alias any
/// request input or each other. The caller owns their allocation/lifetime.
virtual void EvaluateRates(const ReducedShellRateRequest& request,
Vector& velocity, Vector& acceleration) const = 0;
virtual Result<ReconstructedRates>
ReconstructPhysicalRates(const FixedChart& chart, const EmbeddingRoot& root,
const Vector& velocity, const Vector& acceleration,
TangentSolver& solver) const = 0;
};
/// @brief Sequences one private predictor, pending endpoint and commit.
/// @note Callables are synchronous borrowed views. They retain all original
/// evaluation/diagnostic/commit policy; no accepted history is owned here.
template <typename Evaluate, typename Commit>
Status RunReducedHhtStep(const ShellHhtIntegrator& integrator,
const ReducedHistory& history, double h,
const HhtParameters& parameters,
Evaluate&& evaluate, Commit&& commit) {
auto predictor = integrator.Predict(history, h, parameters);
auto pending = evaluate(integrator, std::move(predictor));
if (!pending.HasValue()) return pending.GetStatus();
return commit(std::move(pending.Value()));
}
} // namespace fesa::hht_reduced_internal
#endif // FESA_ANALYSIS_HHT_REDUCED_INTEGRATOR_H_