/*******************************************************************************
 * Copyright (C) 2017-2026 Theodore Chang
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
/**
 * @class B31
 * @brief The B31 class.
 * @author tlc
 * @date 11/10/2017
 * @version 0.1.1
 * @file B31.h
 * @addtogroup Beam
 * @ingroup Element
 * @{
 */

#ifndef B31_H
#define B31_H

#include <Element/SectionElement.h>
#include <Element/Utility/Orientation.h>

class B31 final : public SectionElement3D {
    struct IntegrationPoint final {
        double coor, weight;
        unique_ptr<Section> b_section;
        mat strain_mat; // axial strain, curvature about the z-axis (major), curvature about the y-axis (minor)
        IntegrationPoint(double, double, unique_ptr<Section>&&);
    };

    static constexpr unsigned b_node = 2, b_dof = 6, b_size = b_dof * b_node;

    static const span b_span;

    const unsigned orientation_tag, int_pt_num;

    const double length = 0., torsion_stiff = 0.;

    std::vector<IntegrationPoint> int_pt;

    unique_ptr<Orientation> b_trans;

public:
    B31(
        unsigned,     // tag
        uvec&&,       // node tags
        unsigned,     // section tag
        unsigned,     // orientation tag
        unsigned = 6, // integration points
        bool = false  // nonlinear geometry switch
    );

    int initialize(const shared_ptr<DomainBase>&) override;

    int update_status() override;

    int commit_status() override;
    int clear_status() override;
    int reset_status() override;

    [[nodiscard]] std::vector<vec> record(OutputType) const override;

    void print() override;

#ifdef SUANPAN_VTK
    [[nodiscard]] vtkSmartPointer<vtkCell> GetCell() const override;

    mat GetData(OutputType) override;
    mat GetDeformation(double) override;
#endif
};

#endif

//! @}
