#ifndef FESA_ANALYSIS_NONLINEAR_ANALYSIS_STATE_H_ #define FESA_ANALYSIS_NONLINEAR_ANALYSIS_STATE_H_ #include #include #include #include "fesa/core/source_identity.h" #include "fesa/core/status.h" #include "fesa/fem/dof_manager.h" #include "fesa/math/vector.h" #include "fesa/model/domain.h" #include "fesa/results/result_records.h" namespace fesa { /// @brief Stores one fixed-reference baseline orientation for a source node. struct NonlinearNodeBaseline { EntityIndex node_index; SourceEntityId source_id; std::array, 3> triad; std::array director; }; /// @brief Carries the complete stable-order nonlinear node baseline. struct NonlinearStateBaselineInput { std::vector node_baselines; }; /// @brief Owns one complete nonlinear trial or committed state identity. struct NonlinearTrialState { std::uint32_t increment_index; double load_factor; bool is_factor_zero_baseline; std::vector nodal_internal_order; std::vector nodal_source_ids; Vector generalized_coordinates; Vector displacement; Vector rotation_vector; std::vector, 3>> nodal_triad; std::vector> nodal_director; Vector internal_force; Vector external_force; Vector residual; Vector reaction; std::vector shell_results; double physical_strain_energy; std::array global_equilibrium; }; /// @brief Stores one authoritative nonlinear increment frame. struct AcceptedFrameState { std::uint32_t frame_index; std::uint32_t increment_index; double load_factor; std::uint32_t iteration_count; bool is_factor_one; std::vector nodal_internal_order; std::vector nodal_source_ids; Vector generalized_coordinates; Vector displacement; Vector rotation_vector; std::vector, 3>> nodal_triad; std::vector> nodal_director; Vector internal_force; Vector external_force; Vector residual; Vector reaction; std::vector shell_results; double physical_strain_energy; std::array global_equilibrium; }; /// @brief Owns committed nonlinear state and validated accepted frames. class NonlinearAnalysisState { public: /// @brief Creates the factor-zero committed state from fixed node baselines. /// @param domain Immutable owner of stable node and shell-element identities. /// @param dofs Owner of the full global [u, phi] dimension. /// @param baseline One finite triad/director entry per Domain node. /// @return A factor-zero state or a structured model failure. static Result Create( const Domain& domain, const DofManager& dofs, const NonlinearStateBaselineInput& baseline); /// @brief Returns an independent trial initialized from committed state. /// @return A copy that the caller may mutate without changing committed state. Result BeginTrialFromCommitted() const; /// @brief Atomically appends one complete validated accepted frame. /// @param frame Converged factor-ordered state with full residual evidence. /// @return Success after replacing committed state and appending the frame. Status CommitAcceptedFrame(const AcceptedFrameState& frame); /// @brief Discards caller-owned trial work without changing committed state. void DiscardTrial() noexcept; /// @brief Returns accepted frames in stable load-factor order. const std::vector& AcceptedFrames() const noexcept; /// @brief Returns the current committed factor-zero or accepted state. const NonlinearTrialState& CommittedState() const noexcept; private: /// @brief Retains the validated immutable inventory for frame commits. NonlinearAnalysisState(NonlinearTrialState committed_state, std::size_t full_dof_count, std::vector shell_element_order); NonlinearTrialState committed_state_; std::size_t full_dof_count_; std::vector shell_element_order_; std::vector accepted_frames_; }; } // namespace fesa #endif // FESA_ANALYSIS_NONLINEAR_ANALYSIS_STATE_H_