/* SPDX-FileCopyrightText: Copyright (c) 2022 - 2026, the adamantine authors. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #ifndef MECHANICAL_PHYSICS_HH #define MECHANICAL_PHYSICS_HH #include #include #include #include #include #include #include #include #include #include namespace adamantine { template class MechanicalPhysics { public: /** * Constructor. */ MechanicalPhysics(MPI_Comm const &communicator, unsigned int const fe_degree, Geometry &geometry, Boundary const &boundary, MaterialProperty &material_properties, std::vector const &initial_temperatures); /** * Setup the DoFHandler, the AffineConstraints, and the * MechanicalOperator. */ void setup_dofs(std::vector>> const &body_forces = std::vector>>()); /** * Same as above when solving a thermo-mechanical problem. */ void setup_dofs( dealii::DoFHandler const &thermal_dof_handler, dealii::LA::distributed::Vector const &temperature, std::vector const &has_melted, bool rebuild_matrix, std::vector>> const &body_forces = std::vector>>()); /** * Recompute the right-hand-side. */ void update_rhs(std::vector>> const &body_forces = std::vector>>()); /** * Same as above when solving a thermo-mechanical problem */ void update_rhs( dealii::DoFHandler const &thermal_dof_handler, dealii::LA::distributed::Vector const &temperature, std::vector const &has_melted, std::vector>> const &body_forces = std::vector>>()); /** * Prepare displacement and stresses to be communicated when activating cells * or refining the mesh. */ void prepare_transfer_mpi(); /** * Complete transfer of displacment and stress data after activating cells or * refining the mesh. */ void complete_transfer_mpi(); /** * Solve the mechanical problem and return the displacement. */ dealii::LA::distributed::Vector solve(); /** * Return the DoFHandler. */ dealii::DoFHandler &get_dof_handler(); /** * Return the AffineConstraints. */ dealii::AffineConstraints &get_affine_constraints(); /** * Return the stress tensor associated to each quadrature point. */ std::vector>> & get_stress_tensor(); private: // Compute the stress using linear combination of isotropic and kinematic // hardening in the book Plasticity Modeling & Computation from Ronaldo I. // Borja. void compute_stress( dealii::LA::distributed::Vector const &displacement); /** * Associated Geometry. */ Geometry &_geometry; /** * Associated Boundary. */ Boundary _boundary; /** * Associated MaterialProperty. */ MaterialProperty &_material_properties; /** * Associated FECollection. */ dealii::hp::FECollection _fe_collection; /** * Associated DoFHandler. */ dealii::DoFHandler _dof_handler; /** * Associated AffineConstraints. */ dealii::AffineConstraints _affine_constraints; /** * Associated QCollection. */ dealii::hp::QCollection _q_collection; /** * Pointer to the MechanicalOperator */ std::unique_ptr> _mechanical_operator; /** * Reference temperature for each material followed by the initial * temperature of the substrate. An empty vector denotes a mechanical-only * simulation. */ std::vector _reference_temperatures; /** * Non-owning pointer to the thermal DoFHandler. */ dealii::DoFHandler const *_thermal_dof_handler = nullptr; /** * Current temperature field. */ dealii::LA::distributed::Vector _temperature; /** * Indicator for cells that have melted at least once. */ std::vector _has_melted; /** * Whether to include a gravitional body force in the calculation. */ bool _include_gravity; /** * Save displacement from the previous time step. */ dealii::LA::distributed::Vector _old_displacement; /** * Plastic internal variable related to the strain */ std::vector> _plastic_internal_variable; /** * Hydrostatic thermal stress at the previous mechanical solve. */ std::vector> _thermal_stress; /** * Stress tensor at each (cell, quadrature point). */ std::vector>> _stress; /** * Back stress tensor at each (cell, quadrature point). */ std::vector>> _back_stress; /** * Solution transfer object used for updating _old_displacement when the * triangulation is updated when adding material */ #if DEAL_II_VERSION_GTE(9, 7, 0) dealii::SolutionTransfer< #else dealii::parallel::distributed::SolutionTransfer< #endif dim, dealii::LA::distributed::Vector> _solution_transfer; /** * Object used for interpolating to and from the closest quadrature point in * the cell data transfer object. */ ClosestQuadPointAdaptation> _closest_quad_point_adaptation; /** * Cell data transfer object used for updating _plastic_internal_variable, * _thermal_stress, _stress, and _back_stress when the triangulation is * updated when adding material */ dealii::parallel::distributed::CellDataTransfer< dim, dim, std::vector>>> _cell_data_transfer; /** * Temporary storaged used by _cell_data_transfer */ std::vector>> _data_to_transfer; }; template inline dealii::DoFHandler & MechanicalPhysics::get_dof_handler() { return _dof_handler; } template inline dealii::AffineConstraints & MechanicalPhysics::get_affine_constraints() { return _affine_constraints; } template inline std::vector>> & MechanicalPhysics::get_stress_tensor() { return _stress; } } // namespace adamantine #endif