diff --git a/packages/core.cmake b/packages/core.cmake index 624062ca5..d871e30b8 100644 --- a/packages/core.cmake +++ b/packages/core.cmake @@ -1,529 +1,531 @@ #=============================================================================== # @file core.cmake # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Mon Nov 21 2011 # @date last modification: Mon Jan 18 2016 # # @brief package description for core # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de # Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des # Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu 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 Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . # #=============================================================================== package_declare(core NOT_OPTIONAL DESCRIPTION "core package for Akantu" FEATURES_PUBLIC cxx_strong_enums cxx_defaulted_functions cxx_deleted_functions cxx_auto_type cxx_decltype_auto FEATURES_PRIVATE cxx_lambdas cxx_nullptr cxx_range_for cxx_delegating_constructors DEPENDS INTERFACE akantu_iterators Boost) package_declare_sources(core common/aka_array.cc common/aka_array.hh common/aka_array_tmpl.hh common/aka_array_printer.hh common/aka_bbox.hh common/aka_blas_lapack.hh common/aka_circular_array.hh common/aka_circular_array_inline_impl.hh common/aka_common.cc common/aka_common.hh common/aka_common_inline_impl.hh common/aka_csr.hh common/aka_element_classes_info_inline_impl.hh common/aka_enum_macros.hh common/aka_error.cc common/aka_error.hh common/aka_event_handler_manager.hh common/aka_extern.cc common/aka_factory.hh common/aka_fwd.hh common/aka_grid_dynamic.hh common/aka_math.cc common/aka_math.hh common/aka_math_tmpl.hh common/aka_named_argument.hh common/aka_random_generator.hh common/aka_safe_enum.hh common/aka_typelist.hh common/aka_types.hh common/aka_visitor.hh common/aka_voigthelper.hh common/aka_voigthelper_tmpl.hh common/aka_voigthelper.cc common/aka_warning.hh common/aka_warning_restore.hh fe_engine/element_class.hh fe_engine/element_class_tmpl.hh fe_engine/element_classes/element_class_hexahedron_8_inline_impl.hh fe_engine/element_classes/element_class_hexahedron_20_inline_impl.hh fe_engine/element_classes/element_class_pentahedron_6_inline_impl.hh fe_engine/element_classes/element_class_pentahedron_15_inline_impl.hh fe_engine/element_classes/element_class_point_1_inline_impl.hh fe_engine/element_classes/element_class_quadrangle_4_inline_impl.hh fe_engine/element_classes/element_class_quadrangle_8_inline_impl.hh fe_engine/element_classes/element_class_segment_2_inline_impl.hh fe_engine/element_classes/element_class_segment_3_inline_impl.hh fe_engine/element_classes/element_class_tetrahedron_10_inline_impl.hh fe_engine/element_classes/element_class_tetrahedron_4_inline_impl.hh fe_engine/element_classes/element_class_triangle_3_inline_impl.hh fe_engine/element_classes/element_class_triangle_6_inline_impl.hh fe_engine/element_type_conversion.hh fe_engine/fe_engine.cc fe_engine/fe_engine.hh fe_engine/fe_engine_inline_impl.hh fe_engine/fe_engine_template.hh fe_engine/fe_engine_template_tmpl_field.hh fe_engine/fe_engine_template_tmpl.hh fe_engine/geometrical_element_property.hh fe_engine/geometrical_element_property.cc fe_engine/gauss_integration.cc fe_engine/gauss_integration_tmpl.hh fe_engine/integrator.hh fe_engine/integrator_gauss.hh fe_engine/integrator_gauss_inline_impl.hh fe_engine/interpolation_element_tmpl.hh fe_engine/integration_point.hh fe_engine/shape_functions.hh fe_engine/shape_functions.cc fe_engine/shape_functions_inline_impl.hh fe_engine/shape_lagrange_base.cc fe_engine/shape_lagrange_base.hh fe_engine/shape_lagrange_base_inline_impl.hh fe_engine/shape_lagrange.hh fe_engine/shape_lagrange_inline_impl.hh fe_engine/element.hh io/dumper/dumpable.hh io/dumper/dumpable.cc io/dumper/dumpable_dummy.hh io/dumper/dumpable_inline_impl.hh io/dumper/dumper_field.hh io/dumper/dumper_material_padders.hh io/dumper/dumper_filtered_connectivity.hh io/dumper/dumper_element_partition.hh io/mesh_io.cc io/mesh_io.hh io/mesh_io/mesh_io_diana.cc io/mesh_io/mesh_io_diana.hh io/mesh_io/mesh_io_msh.cc io/mesh_io/mesh_io_msh.hh io/parser/algebraic_parser.hh io/parser/input_file_parser.hh io/parser/parsable.cc io/parser/parsable.hh io/parser/parser.cc io/parser/parser_real.cc io/parser/parser_random.cc io/parser/parser_types.cc io/parser/parser_input_files.cc io/parser/parser.hh io/parser/parser_tmpl.hh io/parser/parser_grammar_tmpl.hh io/parser/cppargparse/cppargparse.hh io/parser/cppargparse/cppargparse.cc io/parser/cppargparse/cppargparse_tmpl.hh io/parser/parameter_registry.cc io/parser/parameter_registry.hh io/parser/parameter_registry_tmpl.hh mesh/element_group.cc mesh/element_group.hh mesh/element_group_inline_impl.hh mesh/element_type_map.cc mesh/element_type_map.hh mesh/element_type_map_tmpl.hh mesh/element_type_map_filter.hh mesh/group_manager.cc mesh/group_manager.hh mesh/group_manager_inline_impl.hh mesh/mesh.cc mesh/mesh.hh mesh/mesh_periodic.cc mesh/mesh_accessor.hh mesh/mesh_events.hh mesh/mesh_filter.hh mesh/mesh_global_data_updater.hh mesh/mesh_data.cc mesh/mesh_data.hh mesh/mesh_data_tmpl.hh mesh/mesh_inline_impl.hh mesh/node_group.cc mesh/node_group.hh mesh/node_group_inline_impl.hh mesh/mesh_iterators.hh mesh_utils/mesh_partition.cc mesh_utils/mesh_partition.hh mesh_utils/mesh_partition/mesh_partition_mesh_data.cc mesh_utils/mesh_partition/mesh_partition_mesh_data.hh mesh_utils/mesh_partition/mesh_partition_scotch.hh mesh_utils/mesh_utils_pbc.cc mesh_utils/mesh_utils.cc mesh_utils/mesh_utils.hh mesh_utils/mesh_utils_distribution.cc mesh_utils/mesh_utils_distribution.hh mesh_utils/mesh_utils.hh mesh_utils/mesh_utils_inline_impl.hh mesh_utils/global_ids_updater.hh mesh_utils/global_ids_updater.cc mesh_utils/global_ids_updater_inline_impl.hh model/common/boundary_condition/boundary_condition.hh model/common/boundary_condition/boundary_condition_functor.hh model/common/boundary_condition/boundary_condition_functor_inline_impl.hh model/common/boundary_condition/boundary_condition_tmpl.hh model/common/constitutive_laws/constitutive_law_non_local_interface.hh model/common/constitutive_laws/constitutive_law_non_local_interface_tmpl.hh + model/common/constitutive_laws/constitutive_law.hh + model/common/constitutive_laws/constitutive_law_tmpl.hh model/common/constitutive_laws/constitutive_laws_handler.hh model/common/constitutive_laws/constitutive_laws_handler_tmpl.hh model/common/constitutive_laws/internal_field.hh model/common/constitutive_laws/internal_field_tmpl.hh model/common/constitutive_laws/random_internal_field.hh model/common/constitutive_laws/random_internal_field_tmpl.hh model/common/non_local_toolbox/neighborhood_base.hh model/common/non_local_toolbox/neighborhood_base.cc model/common/non_local_toolbox/neighborhood_base_inline_impl.hh model/common/non_local_toolbox/neighborhoods_criterion_evaluation/neighborhood_max_criterion.hh model/common/non_local_toolbox/neighborhoods_criterion_evaluation/neighborhood_max_criterion.cc model/common/non_local_toolbox/neighborhoods_criterion_evaluation/neighborhood_max_criterion_inline_impl.hh model/common/non_local_toolbox/non_local_manager.hh model/common/non_local_toolbox/non_local_manager.cc model/common/non_local_toolbox/non_local_manager_inline_impl.hh model/common/non_local_toolbox/non_local_manager_callback.hh model/common/non_local_toolbox/non_local_neighborhood_base.hh model/common/non_local_toolbox/non_local_neighborhood_base.cc model/common/non_local_toolbox/non_local_neighborhood.hh model/common/non_local_toolbox/non_local_neighborhood_tmpl.hh model/common/non_local_toolbox/non_local_neighborhood_inline_impl.hh model/common/non_local_toolbox/base_weight_function.hh model/common/non_local_toolbox/base_weight_function_inline_impl.hh model/common/model_solver.cc model/common/model_solver.hh model/common/solver_callback.hh model/common/solver_callback.cc model/common/dof_manager/dof_manager.cc model/common/dof_manager/dof_manager.hh model/common/dof_manager/dof_manager_default.cc model/common/dof_manager/dof_manager_default.hh model/common/dof_manager/dof_manager_default_inline_impl.hh model/common/dof_manager/dof_manager_inline_impl.hh model/common/non_linear_solver/non_linear_solver.cc model/common/non_linear_solver/non_linear_solver.hh model/common/non_linear_solver/non_linear_solver_default.hh model/common/non_linear_solver/non_linear_solver_lumped.cc model/common/non_linear_solver/non_linear_solver_lumped.hh model/common/time_step_solvers/time_step_solver.hh model/common/time_step_solvers/time_step_solver.cc model/common/time_step_solvers/time_step_solver_default.cc model/common/time_step_solvers/time_step_solver_default.hh model/common/time_step_solvers/time_step_solver_default_explicit.hh model/common/integration_scheme/generalized_trapezoidal.cc model/common/integration_scheme/generalized_trapezoidal.hh model/common/integration_scheme/integration_scheme.cc model/common/integration_scheme/integration_scheme.hh model/common/integration_scheme/integration_scheme_1st_order.cc model/common/integration_scheme/integration_scheme_1st_order.hh model/common/integration_scheme/integration_scheme_2nd_order.cc model/common/integration_scheme/integration_scheme_2nd_order.hh model/common/integration_scheme/newmark-beta.cc model/common/integration_scheme/newmark-beta.hh model/common/integration_scheme/pseudo_time.cc model/common/integration_scheme/pseudo_time.hh model/model.cc model/model.hh model/model_inline_impl.hh model/model_options.hh solver/solver_vector.hh solver/solver_vector_default.cc solver/solver_vector_default.hh solver/solver_vector_default_tmpl.hh solver/solver_vector_distributed.cc solver/solver_vector_distributed.hh solver/sparse_matrix.cc solver/sparse_matrix.hh solver/sparse_matrix_aij.cc solver/sparse_matrix_aij.hh solver/sparse_matrix_aij_inline_impl.hh solver/sparse_matrix_inline_impl.hh solver/sparse_solver.cc solver/sparse_solver.hh solver/sparse_solver_inline_impl.hh solver/terms_to_assemble.hh synchronizer/communication_buffer_inline_impl.hh synchronizer/communication_descriptor.hh synchronizer/communication_descriptor_tmpl.hh synchronizer/communication_request.hh synchronizer/communication_tag.hh synchronizer/communications.hh synchronizer/communications_tmpl.hh synchronizer/communicator.cc synchronizer/communicator.hh synchronizer/communicator_dummy_inline_impl.hh synchronizer/communicator_event_handler.hh synchronizer/communicator_inline_impl.hh synchronizer/data_accessor.cc synchronizer/data_accessor.hh synchronizer/dof_synchronizer.cc synchronizer/dof_synchronizer.hh synchronizer/dof_synchronizer_inline_impl.hh synchronizer/element_info_per_processor.cc synchronizer/element_info_per_processor.hh synchronizer/element_info_per_processor_tmpl.hh synchronizer/element_synchronizer.cc synchronizer/element_synchronizer.hh synchronizer/facet_synchronizer.cc synchronizer/facet_synchronizer.hh synchronizer/facet_synchronizer_inline_impl.hh synchronizer/grid_synchronizer.cc synchronizer/grid_synchronizer.hh synchronizer/grid_synchronizer_tmpl.hh synchronizer/master_element_info_per_processor.cc synchronizer/node_info_per_processor.cc synchronizer/node_info_per_processor.hh synchronizer/node_synchronizer.cc synchronizer/node_synchronizer.hh synchronizer/node_synchronizer_inline_impl.hh synchronizer/periodic_node_synchronizer.cc synchronizer/periodic_node_synchronizer.hh synchronizer/slave_element_info_per_processor.cc synchronizer/synchronizer.cc synchronizer/synchronizer.hh synchronizer/synchronizer_impl.hh synchronizer/synchronizer_impl_tmpl.hh synchronizer/synchronizer_registry.cc synchronizer/synchronizer_registry.hh synchronizer/synchronizer_tmpl.hh synchronizer/communication_buffer.hh ) set(AKANTU_SPIRIT_SOURCES io/mesh_io/mesh_io_abaqus.cc io/parser/parser_real.cc io/parser/parser_random.cc io/parser/parser_types.cc io/parser/parser_input_files.cc PARENT_SCOPE ) package_declare_elements(core ELEMENT_TYPES _point_1 _segment_2 _segment_3 _triangle_3 _triangle_6 _quadrangle_4 _quadrangle_8 _tetrahedron_4 _tetrahedron_10 _pentahedron_6 _pentahedron_15 _hexahedron_8 _hexahedron_20 KIND regular GEOMETRICAL_TYPES _gt_point _gt_segment_2 _gt_segment_3 _gt_triangle_3 _gt_triangle_6 _gt_quadrangle_4 _gt_quadrangle_8 _gt_tetrahedron_4 _gt_tetrahedron_10 _gt_hexahedron_8 _gt_hexahedron_20 _gt_pentahedron_6 _gt_pentahedron_15 INTERPOLATION_TYPES _itp_lagrange_point_1 _itp_lagrange_segment_2 _itp_lagrange_segment_3 _itp_lagrange_triangle_3 _itp_lagrange_triangle_6 _itp_lagrange_quadrangle_4 _itp_serendip_quadrangle_8 _itp_lagrange_tetrahedron_4 _itp_lagrange_tetrahedron_10 _itp_lagrange_hexahedron_8 _itp_serendip_hexahedron_20 _itp_lagrange_pentahedron_6 _itp_lagrange_pentahedron_15 GEOMETRICAL_SHAPES _gst_point _gst_triangle _gst_square _gst_prism GAUSS_INTEGRATION_TYPES _git_point _git_segment _git_triangle _git_tetrahedron _git_pentahedron INTERPOLATION_KIND _itk_lagrangian FE_ENGINE_LISTS gradient_on_integration_points interpolate_on_integration_points interpolate compute_normals_on_integration_points inverse_map contains compute_shapes compute_shapes_derivatives get_shapes_derivatives lagrange_base assemble_fields ) package_declare_documentation_files(core manual.sty manual.cls manual.tex manual-macros.sty manual-titlepages.tex manual-authors.tex manual-changelog.tex manual-introduction.tex manual-gettingstarted.tex manual-io.tex manual-feengine.tex manual-elements.tex manual-appendix-elements.tex manual-appendix-packages.tex manual-backmatter.tex manual-bibliography.bib manual-bibliographystyle.bst figures/bc_and_ic_example.pdf figures/boundary.pdf figures/boundary.svg figures/dirichlet.pdf figures/dirichlet.svg # figures/doc_wheel.pdf # figures/doc_wheel.svg figures/hot-point-1.png figures/hot-point-2.png figures/insertion.pdf figures/interpolate.pdf figures/interpolate.svg figures/vectors.pdf figures/vectors.svg figures/elements/hexahedron_8.pdf figures/elements/hexahedron_8.svg figures/elements/quadrangle_4.pdf figures/elements/quadrangle_4.svg figures/elements/quadrangle_8.pdf figures/elements/quadrangle_8.svg figures/elements/segment_2.pdf figures/elements/segment_2.svg figures/elements/segment_3.pdf figures/elements/segment_3.svg figures/elements/tetrahedron_10.pdf figures/elements/tetrahedron_10.svg figures/elements/tetrahedron_4.pdf figures/elements/tetrahedron_4.svg figures/elements/triangle_3.pdf figures/elements/triangle_3.svg figures/elements/triangle_6.pdf figures/elements/triangle_6.svg figures/elements/xtemp.pdf ) package_declare_documentation(core "This package is the core engine of \\akantu. It depends on:" "\\begin{itemize}" "\\item A C++ compiler (\\href{http://gcc.gnu.org/}{GCC} >= 4, or \\href{https://software.intel.com/en-us/intel-compilers}{Intel})." "\\item The cross-platform, open-source \\href{http://www.cmake.org/}{CMake} build system." "\\item The \\href{http://www.boost.org/}{Boost} C++ portable libraries." "\\item The \\href{http://www.zlib.net/}{zlib} compression library." "\\end{itemize}" "" "Under Ubuntu (14.04 LTS) the installation can be performed using the commands:" "\\begin{command}" " > sudo apt-get install cmake libboost-dev zlib1g-dev g++" "\\end{command}" "" "Under Mac OS X the installation requires the following steps:" "\\begin{itemize}" "\\item Install Xcode" "\\item Install the command line tools." "\\item Install the MacPorts project which allows to automatically" "download and install opensource packages." "\\end{itemize}" "Then the following commands should be typed in a terminal:" "\\begin{command}" " > sudo port install cmake gcc48 boost" "\\end{command}" ) find_program(READLINK_COMMAND readlink) find_program(ADDR2LINE_COMMAND addr2line) find_program(PATCH_COMMAND patch) mark_as_advanced(READLINK_COMMAND) mark_as_advanced(ADDR2LINE_COMMAND) package_declare_extra_files_to_package(core SOURCES common/aka_element_classes_info.hh.in common/aka_config.hh.in ) if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.9)) package_set_compile_flags(core CXX "-Wno-undefined-var-template") endif() if(DEFINED AKANTU_CXX11_FLAGS) package_declare(core_cxx11 NOT_OPTIONAL DESCRIPTION "C++ 11 additions for Akantu core" COMPILE_FLAGS CXX "${AKANTU_CXX11_FLAGS}") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.6") set(AKANTU_CORE_CXX11 OFF CACHE BOOL "C++ 11 additions for Akantu core - not supported by the selected compiler" FORCE) endif() endif() package_declare_documentation(core_cxx11 "This option activates some features of the C++11 standard. This is usable with GCC>=4.7 or Intel>=13.") else() if(CMAKE_VERSION VERSION_LESS 3.1) message(FATAL_ERROR "Since version 3.0 Akantu requires at least c++11 capable compiler") endif() endif() diff --git a/src/model/common/constitutive_laws/constitutive_law.hh b/src/model/common/constitutive_laws/constitutive_law.hh index 73e579590..fef4dde4e 100644 --- a/src/model/common/constitutive_laws/constitutive_law.hh +++ b/src/model/common/constitutive_laws/constitutive_law.hh @@ -1,196 +1,182 @@ /** * @file constitutive_law.hh * * @author Daniel Pino Muñoz * @author Nicolas Richart * @author Marco Vocialta * * @date creation: Fri Jun 18 2010 * @date last modification: Wed Feb 21 2018 * - * @brief Mother class for all constitutive laws + * @brief Mother class for all constitutive laws * * * Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * Akantu is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Akantu 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 Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with Akantu. If not, see . * */ - - /* -------------------------------------------------------------------------- */ -#include "aka_memory.hh" #include "data_accessor.hh" #include "parsable.hh" #include "parser.hh" +#include "mesh_events.hh" /* -------------------------------------------------------------------------- */ #include "internal_field.hh" #include "random_internal_field.hh" /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_CONSTITUTIVE_LAW_HH__ #define __AKANTU_CONSTITUTIVE_LAW_HH__ /* -------------------------------------------------------------------------- */ - -namespace akantu { - class Model; - class ConstitutiveLaw; -} // namespace akantu - - namespace akantu { -template -class ConstitutiveLaw : public DataAccessor, - public Parsable { +template +class ConstitutiveLaw : public DataAccessor, public Parsable { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: - - using ConstitutiveLawsHandler = ConstitutiveLawsHandler_; - ConstitutiveLaw(const ConstitutiveLaw & law) = delete; - ConstitutiveLaw & operator=(const ConstitutiveLaw & law) = delete; + ConstitutiveLaw & operator=(const ConstitutiveLaw & law) = delete; /// Initialize constitutive law with defaults - ConstitutiveLaw(ConstitutiveLawsHandler& handler, const ID & id = "", - ElementKind element_kind = _ek_regular); + ConstitutiveLaw(ConstitutiveLawsHandler & handler, const ID & id = "", + ElementKind element_kind = _ek_regular); /// Destructor ~ConstitutiveLaw() override; protected: void initialize(); - /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: template void registerInternal(InternalField & /*vect*/) { AKANTU_TO_IMPLEMENT(); } template void unregisterInternal(InternalField & /*vect*/) { AKANTU_TO_IMPLEMENT(); } /// initialize the constitutive law computed parameter virtual void initConstitutiveLaw(); - + /// save the internals in the previous_state if needed virtual void savePreviousState(); /// restore the internals from previous_state if needed virtual void restorePreviousState(); - + /// add an element to the local mesh filter inline UInt addElement(ElementType type, UInt element, GhostType ghost_type); inline UInt addElement(const Element & element); /// add many elements at once void addElements(const Array & elements_to_add); /// remove many element at once void removeElements(const Array & elements_to_remove); /// function to print the contain of the class void printself(std::ostream & stream, int indent = 0) const override; - protected: /// resize the internals arrrays virtual void resizeInternals(); /// function called to update the internal parameters when the - /// modifiable parameters are modified + /// modifiable parameters are modified virtual void updateInternalParameters() {} +public: + virtual void onElementsAdded(const Array & /*unused*/, + const NewElementsEvent & /*unused*/); + + virtual void onElementsRemoved(const Array & element_list, + const ElementTypeMapArray & new_numbering, + const RemovedElementsEvent & event); public: template const InternalField & getInternal(const ID & id) const; template InternalField & getInternal(const ID & id); template inline bool isInternal(const ID & id, const ElementKind & element_kind) const; - template inline void setParam(const ID & param, T value); inline const Parameter & getParam(const ID & param) const; template void flattenInternal(const std::string & field_id, ElementTypeMapArray & internal_flat, const GhostType ghost_type = _not_ghost, ElementKind element_kind = _ek_not_defined) const; - /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: AKANTU_GET_MACRO(Name, name, const std::string &); - + AKANTU_GET_MACRO(ID, id, const ID &); AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(ElementFilter, element_filter, UInt); template ElementTypeMap getInternalDataPerElem(const ID & id, ElementKind element_kind) const; - protected: bool isInit() const { return is_init; } - + /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// boolean to know if the constitutive law has been initialized bool is_init{false}; std::map *> internal_vectors_real; std::map *> internal_vectors_uint; std::map *> internal_vectors_bool; - protected: ID id; /// constitutive law name std::string name; - + /// list of element handled by the constitutive law ElementTypeMapArray element_filter; // Constitutive law handler for which this is a constitutive law ConstitutiveLawsHandler & handler; }; } // namespace akantu -#include "constitutive_laws_tmpl.hh" - +#include "constitutive_law_tmpl.hh" #endif - diff --git a/src/model/common/constitutive_laws/constitutive_law_inline_impl.hh b/src/model/common/constitutive_laws/constitutive_law_inline_impl.hh deleted file mode 100644 index 0111ae309..000000000 --- a/src/model/common/constitutive_laws/constitutive_law_inline_impl.hh +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @file constitutive_laws_inline_impl.hh - * - * @author Daniel Pino Muñoz - * @author Nicolas Richart - * @author Marco Vocialta - * @author Mohit Pundir - * - * @date creation: Tue Jul 27 2010 - * @date last modification: Tue Feb 20 2018 - * - * @brief Implementation of the inline functions of the class - * constitutive law - * - * - * Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne) - * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) - * - * Akantu is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) any - * later version. - * - * Akantu 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 Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Akantu. If not, see . - * - */ - -/* -------------------------------------------------------------------------- */ -#include "constitutive_laws.hh" -/* -------------------------------------------------------------------------- */ - -#ifndef AKANTU_CONSTITUTIVE_LAW_HH__ -#define AKANTU_CONSTITUTIVE_LAW_HH__ - -namespace akantu { - - -} - -#endif diff --git a/src/model/common/constitutive_laws/constitutive_law_selector.hh b/src/model/common/constitutive_laws/constitutive_law_selector.hh new file mode 100644 index 000000000..8d692358b --- /dev/null +++ b/src/model/common/constitutive_laws/constitutive_law_selector.hh @@ -0,0 +1,110 @@ +/** + * @file constitutive_law_selector.hh + * + * @author Nicolas Richart + * + * @date creation ven mar 26 2021 + * + * @brief class to dispatch cl to elements + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * Akantu is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * Akantu 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 Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Akantu. If not, see . + * + */ +/* -------------------------------------------------------------------------- */ +#include "element_type_map.hh" +/* -------------------------------------------------------------------------- */ +#include +/* -------------------------------------------------------------------------- */ + +#ifndef AKANTU_CONSTITUTIVE_LAW_SELECTOR_HH +#define AKANTU_CONSTITUTIVE_LAW_SELECTOR_HH + +namespace akantu { + +/** + * main class to assign same or different constitutive_laws for different + * elements + */ +class ConstitutiveLawSelector : public std::enable_shared_from_this { +public: + ConstitutiveLawSelector() = default; + virtual ~ConstitutiveLawSelector() = default; + virtual inline UInt operator()(const Element & element) { + if (fallback_selector) { + return (*fallback_selector)(element); + } + + return fallback_value; + } + + inline void setFallback(UInt f) { fallback_value = f; } + inline void + setFallback(const std::shared_ptr & fallback_selector) { + this->fallback_selector = fallback_selector; + } + + inline void setFallback(ConstitutiveLawSelector & fallback_selector) { + this->fallback_selector = fallback_selector.shared_from_this(); + } + + inline std::shared_ptr & getFallbackSelector() { + return this->fallback_selector; + } + + inline UInt getFallbackValue() const { return this->fallback_value; } + +protected: + UInt fallback_value{0}; + std::shared_ptr fallback_selector; +}; + +/* -------------------------------------------------------------------------- */ +/** + * class that assigns the first constitutive_law to regular elements by default + */ +class DefaultConstitutiveLawSelector : public ConstitutiveLawSelector { +public: + explicit DefaultConstitutiveLawSelector( + const ElementTypeMapArray & constitutive_law_index) + : constitutive_law_index(constitutive_law_index) {} + + UInt operator()(const Element & element) override { + if (not constitutive_law_index.exists(element.type, element.ghost_type)) { + return ConstitutiveLawSelector::operator()(element); + } + + const auto & mat_indexes = constitutive_law_index(element.type, element.ghost_type); + if (element.element < mat_indexes.size()) { + auto && tmp_mat = mat_indexes(element.element); + if (tmp_mat != UInt(-1)) { + return tmp_mat; + } + } + + return ConstitutiveLawSelector::operator()(element); + } + +private: + const ElementTypeMapArray & constitutive_law_index; +}; + +} // akantu + + +#endif /* AKANTU_CONSTITUTIVE_LAW_SELECTOR_HH */ diff --git a/src/model/common/constitutive_laws/constitutive_law_tmpl.hh b/src/model/common/constitutive_laws/constitutive_law_tmpl.hh index 9ea7efeb9..aa1593808 100644 --- a/src/model/common/constitutive_laws/constitutive_law_tmpl.hh +++ b/src/model/common/constitutive_laws/constitutive_law_tmpl.hh @@ -1,580 +1,565 @@ /** * @file constitutive_law_tmpl.hh * * @author Guillaume Anciaux * @author Aurelia Isabel Cuba Ramos * @author Daniel Pino Muñoz * @author Nicolas Richart * @author Marco Vocialta * * @date creation: Tue Jul 27 2010 * @date last modification: Wed Feb 21 2018 * * @brief Implementation of the templated part of the constitutive law class * * * Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * Akantu is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Akantu 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 Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with Akantu. If not, see . * */ /* -------------------------------------------------------------------------- */ +#include "constitutive_law.hh" #include "constitutive_laws_handler.hh" /* -------------------------------------------------------------------------- */ -#ifndef AKANTU_CONSTITUTIVE_TMPL_HH__ -#define AKANTU_CONSTITUTIVE_TMPL_HH__ +#ifndef AKANTU_CONSTITUTIVE_LAW_TMPL_HH +#define AKANTU_CONSTITUTIVE_LAW_TMPL_HH namespace akantu { -template -ConstitutiveLaw::ConstitutiveLaw(ConstitutiveLawsHandler_ & handler, - const ID & id, - ElementKind element_kind) - : Parsable(ParserType::_constitutive_law, id), handler(handler), - id(id), element_filter("element_filter", id) { - - AKANTU_DEBUG_IN(); - +template +ConstitutiveLaw::ConstitutiveLaw( + ConstitutiveLawsHandler_ & handler, const ID & id, ElementKind element_kind) + : Parsable(ParserType::_constitutive_law, id), handler(handler), id(id), + element_filter("element_filter", id) { /// for each connectivity types allocate the element filer array of the /// constitutive law element_filter.initialize(handler.getMesh(), _spatial_dimension = handler.getSpatialDimension(), _element_kind = element_kind); - - this->initialize(); - AKANU_DEBUG_OUT(); - + this->initialize(); } - + /* -------------------------------------------------------------------------- */ -template -void ConstitutiveLaw::initialize(){ +template +void ConstitutiveLaw::initialize() { registerParam("name", name, std::string(), _pat_parsable | _pat_readable); } - /* -------------------------------------------------------------------------- */ -template -void ConstitutiveLaw::initConstitutiveLaw() { - +template +void ConstitutiveLaw::initConstitutiveLaw() { this->resizeInternals(); - updateInternalParmaters(); + this->updateInternalParmaters(); is_init = true; - } - /* -------------------------------------------------------------------------- */ -template +template void ConstitutiveLaw::savePreviousState() { - AKANTU_DEBUG_IN(); - for (auto pair : internal_vectors_real) { if (pair.second->hasHistory()) { pair.second->saveCurrentValues(); } } - - AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ -template +template void ConstitutiveLaw::restorePreviousState() { - AKANTU_DEBUG_IN(); - for (auto pair : internal_vectors_real) { if (pair.second->hasHistory()) { pair.second->restorePreviousValues(); } } - - AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ -template +template void ConstitutiveLaw::resizeInternals() { - - AKANTU_DEBUG_IN(); for (auto it = internal_vectors_real.begin(); it != internal_vectors_real.end(); ++it) { it->second->resize(); } for (auto it = internal_vectors_uint.begin(); it != internal_vectors_uint.end(); ++it) { it->second->resize(); } for (auto it = internal_vectors_bool.begin(); it != internal_vectors_bool.end(); ++it) { it->second->resize(); } - AKANTU_DEBUG_OUT(); } - - /* -------------------------------------------------------------------------- */ -template -void ConstitutiveLaw::addElements(const Array & elements_to_add) { +template +void ConstitutiveLaw::addElements( + const Array & elements_to_add) { AKANTU_DEBUG_IN(); UInt law_id = handler.getConstitutiveLawIndex(name); for (const auto & element : elements_to_add) { auto index = this->addElement(element); handler.constitutive_law_index(element) = law_id; handler.constitutive_law_local_numbering(element) = index; } this->resizeInternals(); AKANTU_DEBUG_OUT(); } - /* -------------------------------------------------------------------------- */ -template -void ConstitutiveLaw::removeElements(const Array & elements_to_remove) { +template +void ConstitutiveLaw::removeElements( + const Array & elements_to_remove) { AKANTU_DEBUG_IN(); auto el_begin = elements_to_remove.begin(); auto el_end = elements_to_remove.end(); if (elements_to_remove.empty()) { return; } auto & mesh = handler.getMesh(); ElementTypeMapArray constitutive_law_local_new_numbering( "remove constitutive law filter elem", id); constitutive_law_local_new_numbering.initialize( mesh, _element_filter = &element_filter, _element_kind = _ek_not_defined, _with_nb_element = true); ElementTypeMapArray element_filter_tmp("element_filter_tmp", id); element_filter_tmp.initialize(mesh, _element_filter = &element_filter, _element_kind = _ek_not_defined); ElementTypeMap new_ids, element_ids; for_each_element( mesh, [&](auto && el) { if (not new_ids(el.type, el.ghost_type)) { element_ids(el.type, el.ghost_type) = 0; } auto & element_id = element_ids(el.type, el.ghost_type); auto l_el = Element{el.type, element_id, el.ghost_type}; if (std::find(el_begin, el_end, el) != el_end) { constitutive_law_local_new_numbering(l_el) = UInt(-1); return; } element_filter_tmp(el.type, el.ghost_type).push_back(el.element); if (not new_ids(el.type, el.ghost_type)) { new_ids(el.type, el.ghost_type) = 0; } auto & new_id = new_ids(el.type, el.ghost_type); constitutive_law_local_new_numbering(l_el) = new_id; handler.constitutive_law_local_numbering(el) = new_id; ++new_id; ++element_id; }, _element_filter = &element_filter, _element_kind = _ek_not_defined); for (auto ghost_type : ghost_types) { for (const auto & type : element_filter.elementTypes( _ghost_type = ghost_type, _element_kind = _ek_not_defined)) { element_filter(type, ghost_type) .copy(element_filter_tmp(type, ghost_type)); } } for (auto it = internal_vectors_real.begin(); it != internal_vectors_real.end(); ++it) { it->second->removeIntegrationPoints(constitutive_law_local_new_numbering); } for (auto it = internal_vectors_uint.begin(); it != internal_vectors_uint.end(); ++it) { it->second->removeIntegrationPoints(constitutive_law_local_new_numbering); } for (auto it = internal_vectors_bool.begin(); it != internal_vectors_bool.end(); ++it) { it->second->removeIntegrationPoints(constitutive_law_local_new_numbering); } AKANTU_DEBUG_OUT(); } - /* -------------------------------------------------------------------------- */ -template -void ConstitutiveLaw::onElementsAdded(const Array & /*unused*/, - const NewElementsEvent & /*unused*/) { +template +void ConstitutiveLaw::onElementsAdded( + const Array & /*unused*/, const NewElementsEvent & /*unused*/) { this->resizeInternals(); } /* -------------------------------------------------------------------------- */ -template +template void ConstitutiveLaw::onElementsRemoved( const Array & element_list, const ElementTypeMapArray & new_numbering, - [[gnu::unused]] const RemovedElementsEvent & event) { + const RemovedElementsEvent & /*event*/) { UInt my_num = handler.getInternalIndexFromID(getID()); ElementTypeMapArray constitutive_law_local_new_numbering( "remove constitutive law filter elem", getID()); auto el_begin = element_list.begin(); auto el_end = element_list.end(); for (auto && gt : ghost_types) { for (auto && type : new_numbering.elementTypes(_all_dimensions, gt, _ek_not_defined)) { if (not element_filter.exists(type, gt) || element_filter(type, gt).empty()) { continue; } auto & elem_filter = element_filter(type, gt); auto & law_indexes = this->handler.constitutive_law_index(type, gt); - auto & law_loc_num = this->handler.constitutive_law_local_numbering(type, gt); + auto & law_loc_num = + this->handler.constitutive_law_local_numbering(type, gt); auto nb_element = this->handler.getMesh().getNbElement(type, gt); // all constitutive laws will resized to the same size... law_indexes.resize(nb_element); law_loc_num.resize(nb_element); if (!constitutive_law_local_new_numbering.exists(type, gt)) { - constitutive_law_local_new_numbering.alloc(elem_filter.size(), 1, type, gt); + constitutive_law_local_new_numbering.alloc(elem_filter.size(), 1, type, + gt); } auto & law_renumbering = constitutive_law_local_new_numbering(type, gt); const auto & renumbering = new_numbering(type, gt); Array elem_filter_tmp; UInt ni = 0; Element el{type, 0, gt}; for (UInt i = 0; i < elem_filter.size(); ++i) { el.element = elem_filter(i); if (std::find(el_begin, el_end, el) == el_end) { UInt new_el = renumbering(el.element); AKANTU_DEBUG_ASSERT(new_el != UInt(-1), "A not removed element as been badly renumbered"); elem_filter_tmp.push_back(new_el); law_renumbering(i) = ni; law_indexes(new_el) = my_num; law_loc_num(new_el) = ni; ++ni; } else { law_renumbering(i) = UInt(-1); } } elem_filter.resize(elem_filter_tmp.size()); elem_filter.copy(elem_filter_tmp); } } for (auto it = internal_vectors_real.begin(); it != internal_vectors_real.end(); ++it) { it->second->removeIntegrationPoints(constitutive_law_local_new_numbering); } for (auto it = internal_vectors_uint.begin(); it != internal_vectors_uint.end(); ++it) { it->second->removeIntegrationPoints(constitutive_law_local_new_numbering); } for (auto it = internal_vectors_bool.begin(); it != internal_vectors_bool.end(); ++it) { it->second->removeIntegrationPoints(constitutive_law_local_new_numbering); } } - - -inline UInt ConstitutiveLaw::addElement(ElementType type, UInt element, - GhostType ghost_type) { +/* -------------------------------------------------------------------------- */ +template +inline UInt ConstitutiveLaw::addElement( + ElementType type, UInt element, GhostType ghost_type) { Array & el_filter = this->element_filter(type, ghost_type); el_filter.push_back(element); return el_filter.size() - 1; } /* -------------------------------------------------------------------------- */ -inline UInt ConstitutiveLaw::addElement(const Element & element) { +template +inline UInt +ConstitutiveLaw::addElement(const Element & element) { return this->addElement(element.type, element.element, element.ghost_type); } - /* -------------------------------------------------------------------------- */ -inline const Parameter & ConstitutiveLaw::getParam(const ID & param) const { +template +inline const Parameter & +ConstitutiveLaw::getParam(const ID & param) const { try { return get(param); } catch (...) { AKANTU_EXCEPTION("No parameter " << param << " in the constitutive law" << getID()); } } /* -------------------------------------------------------------------------- */ +template template -inline void ConstitutiveLaw::setParam(const ID & param, T value) { +inline void +ConstitutiveLaw::setParam(const ID & param, T value) { try { set(param, value); } catch (...) { AKANTU_EXCEPTION("No parameter " << param << " in the constitutive law " << getID()); } updateInternalParameters(); } - - /* -------------------------------------------------------------------------- */ -template +template template <> -inline void -ConstitutiveLaw::registerInternal(InternalField & vect) { +inline void ConstitutiveLaw::registerInternal( + InternalField & vect) { internal_vectors_real[vect.getID()] = &vect; } -template +template template <> -inline void -ConstitutiveLaw::registerInternal(InternalField & vect) { +inline void ConstitutiveLaw::registerInternal( + InternalField & vect) { internal_vectors_uint[vect.getID()] = &vect; } -template +template template <> -inline void -ConstitutiveLaw::registerInternal(InternalField & vect) { +inline void ConstitutiveLaw::registerInternal( + InternalField & vect) { internal_vectors_bool[vect.getID()] = &vect; } /* -------------------------------------------------------------------------- */ -template +template template <> -inline void -ConstitutiveLaw::unregisterInternal(InternalField & vect) { +inline void ConstitutiveLaw::unregisterInternal( + InternalField & vect) { internal_vectors_real.erase(vect.getID()); } -template +template template <> -inline void -ConstitutiveLaw::unregisterInternal(InternalField & vect) { +inline void ConstitutiveLaw::unregisterInternal( + InternalField & vect) { internal_vectors_uint.erase(vect.getID()); } -template +template template <> -inline void -ConstitutiveLaw::unregisterInternal(InternalField & vect) { +inline void ConstitutiveLaw::unregisterInternal( + InternalField & vect) { internal_vectors_bool.erase(vect.getID()); } - - /* -------------------------------------------------------------------------- */ -template -template -const InternalField & -ConstituitveLaw::getInternal([[gnu::unused]] const ID & int_id) const { +template +template +const InternalField & ConstituitveLaw::getInternal( + const ID & /*int_id*/) const { AKANTU_TO_IMPLEMENT(); return NULL; } /* -------------------------------------------------------------------------- */ template -InternalField & ConstituitveLaw::getInternal([[gnu::unused]] const ID & int_id) { +InternalField & +ConstituitveLaw::getInternal(const ID & /*int_id*/) { AKANTU_TO_IMPLEMENT(); return NULL; } /* -------------------------------------------------------------------------- */ template <> -const InternalField & ConstituitveLaw::getInternal(const ID & int_id) const { +const InternalField & +ConstituitveLaw::getInternal( + const ID & int_id) const { auto it = internal_vectors_real.find(getID() + ":" + int_id); if (it == internal_vectors_real.end()) { AKANTU_SILENT_EXCEPTION("The material " << name << "(" << getID() << ") does not contain an internal " << int_id << " (" << (getID() + ":" + int_id) << ")"); } return *it->second; } /* -------------------------------------------------------------------------- */ -template <> InternalField & ConstituitveLaw::getInternal(const ID & int_id) { +template <> +InternalField & +ConstituitveLaw::getInternal(const ID & int_id) { auto it = internal_vectors_real.find(getID() + ":" + int_id); if (it == internal_vectors_real.end()) { AKANTU_SILENT_EXCEPTION("The material " << name << "(" << getID() << ") does not contain an internal " << int_id << " (" << (getID() + ":" + int_id) << ")"); } return *it->second; } /* -------------------------------------------------------------------------- */ template <> -const InternalField & ConstituitveLaw::getInternal(const ID & int_id) const { +const InternalField & +ConstituitveLaw::getInternal( + const ID & int_id) const { auto it = internal_vectors_uint.find(getID() + ":" + int_id); if (it == internal_vectors_uint.end()) { AKANTU_SILENT_EXCEPTION("The material " << name << "(" << getID() << ") does not contain an internal " << int_id << " (" << (getID() + ":" + int_id) << ")"); } return *it->second; } /* -------------------------------------------------------------------------- */ -template <> InternalField & ConstituitveLaw::getInternal(const ID & int_id) { +template <> +InternalField & +ConstituitveLaw::getInternal(const ID & int_id) { auto it = internal_vectors_uint.find(getID() + ":" + int_id); if (it == internal_vectors_uint.end()) { AKANTU_SILENT_EXCEPTION("The material " << name << "(" << getID() << ") does not contain an internal " << int_id << " (" << (getID() + ":" + int_id) << ")"); } return *it->second; } - /* -------------------------------------------------------------------------- */ -template -inline bool ConstitutiveLaw::isInternal(const ID & /*id*/, - ElementKind /*element_kind*/) const { +template +inline bool ConstitutiveLaw::isInternal( + const ID & /*id*/, ElementKind /*element_kind*/) const { AKANTU_TO_IMPLEMENT(); } -template +/* -------------------------------------------------------------------------- */ +template template <> -inline bool -ConstitutiveLaw::isInternal(const ID & id, - ElementKind element_kind) const { +inline bool ConstitutiveLaw::isInternal( + const ID & id, ElementKind element_kind) const { auto internal_array = internal_vectors_real.find(this->getID() + ":" + id); - return not (internal_array == internal_vectors_real.end() || - internal_array->second->getElementKind() != element_kind); + return not(internal_array == internal_vectors_real.end() || + internal_array->second->getElementKind() != element_kind); } - /* -------------------------------------------------------------------------- */ template inline ElementTypeMap -ConstitutiveLaw::getInternalDataPerElem(const ID & field_id, - ElementKind element_kind) const { - +ConstitutiveLaw::getInternalDataPerElem( + const ID & field_id, ElementKind element_kind) const { + if (!this->template isInternal(field_id, element_kind)) { - AKANTU_EXCEPTION("Cannot find internal field " << id << " in the constitutive law " - << this->name); + AKANTU_EXCEPTION("Cannot find internal field " + << id << " in the constitutive law " << this->name); } const InternalField & internal_field = this->template getInternal(field_id); const FEEngine & fe_engine = internal_field.getFEEngine(); UInt nb_data_per_quad = internal_field.getNbComponent(); ElementTypeMap res; for (auto ghost_type : ghost_types) { for (auto & type : internal_field.elementTypes(ghost_type)) { UInt nb_quadrature_points = fe_engine.getNbIntegrationPoints(type, ghost_type); res(type, ghost_type) = nb_data_per_quad * nb_quadrature_points; } } return res; } - /* -------------------------------------------------------------------------- */ template -void ConstitutiveLaw::flattenInternal(const std::string & field_id, - ElementTypeMapArray & internal_flat, - const GhostType ghost_type, - ElementKind element_kind) const { +void ConstitutiveLaw::flattenInternal( + const std::string & field_id, ElementTypeMapArray & internal_flat, + const GhostType ghost_type, ElementKind element_kind) const { if (!this->template isInternal(field_id, element_kind)) { - AKANTU_EXCEPTION("Cannot find internal field " << id << " in the constitutive law " - << this->name); + AKANTU_EXCEPTION("Cannot find internal field " + << id << " in the constitutive law " << this->name); } const InternalField & internal_field = this->template getInternal(field_id); const FEEngine & fe_engine = internal_field.getFEEngine(); const Mesh & mesh = fe_engine.getMesh(); for (auto && type : internal_field.filterTypes(ghost_type)) { const Array & src_vect = internal_field(type, ghost_type); const Array & filter = internal_field.getFilter(type, ghost_type); // total number of elements in the corresponding mesh UInt nb_element_dst = mesh.getNbElement(type, ghost_type); // number of element in the internal field UInt nb_element_src = filter.size(); // number of quadrature points per elem UInt nb_quad_per_elem = fe_engine.getNbIntegrationPoints(type); // number of data per quadrature point UInt nb_data_per_quad = internal_field.getNbComponent(); if (!internal_flat.exists(type, ghost_type)) { internal_flat.alloc(nb_element_dst * nb_quad_per_elem, nb_data_per_quad, type, ghost_type); } if (nb_element_src == 0) { continue; } // number of data per element UInt nb_data = nb_quad_per_elem * nb_data_per_quad; Array & dst_vect = internal_flat(type, ghost_type); dst_vect.resize(nb_element_dst * nb_quad_per_elem); auto it_dst = make_view(dst_vect, nb_data).begin(); for (auto && data : zip(filter, make_view(src_vect, nb_data))) { it_dst[std::get<0>(data)] = std::get<1>(data); } } -} - } -#endif +} // namespace akantu + +#endif // AKANTU_CONSTITUTIVE_LAW_TMPL_HH diff --git a/src/model/common/constitutive_laws/constitutive_laws_handler.hh b/src/model/common/constitutive_laws/constitutive_laws_handler.hh index 9c6b8ef4f..3ad3c9435 100644 --- a/src/model/common/constitutive_laws/constitutive_laws_handler.hh +++ b/src/model/common/constitutive_laws/constitutive_laws_handler.hh @@ -1,291 +1,291 @@ /** * @file constitutive_laws_handler.hh * * @author Nicolas Richart * @author Mohit Pundir * * @date creation ven mar 26 2021 * * @brief A handler for multiple consistutive laws * * @section LICENSE * * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * Akantu is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Akantu 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 Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with Akantu. If not, see . * */ /* -------------------------------------------------------------------------- */ #include "constitutive_law.hh" +#include "constitutive_law_selector.hh" #include "mesh.hh" #include "mesh_events.hh" #include "non_local_manager_callback.hh" /* -------------------------------------------------------------------------- */ #ifndef AKANTU_CONSTITUTIVE_LAWS_HANDLER_HH #define AKANTU_CONSTITUTIVE_LAWS_HANDLER_HH namespace akantu { -template class ConstitutiveLawSelector; class NonLocalManager; } // namespace akantu /* -------------------------------------------------------------------------- */ namespace akantu { -template +template class ConstitutiveLawsHandler : public NonLocalManagerCallback { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: ConstitutiveLawsHandler(const Mesh & mesh, UInt spatial_dimension, const ID & parent_id) - : constitutive_law_index("constitutive_law index", id), + : constitutive_law_index("constitutive_law index", parent_id), constitutive_law_local_numbering("constitutive_law local numbering", - id) { + parent_id) { constitutive_law_selector = std::make_shared( constitutive_law_index); constitutive_law_index.initialize(mesh, _element_kind = _ek_not_defined, _default_value = UInt(-1), _with_nb_element = true); constitutive_law_local_numbering.initialize( mesh, _element_kind = _ek_not_defined, _with_nb_element = true); } virtual ~ConstitutiveLawsHandler(); class NewConstitutiveLawElementsEvent : public NewElementsEvent { public: AKANTU_GET_MACRO_NOT_CONST(ConstitutiveLawList, constitutive_law, Array &); AKANTU_GET_MACRO(ConstitutiveLawList, constitutive_law, const Array &); protected: Array constitutive_law; }; /* ------------------------------------------------------------------------ */ /* ConstitutiveLaws */ /* ------------------------------------------------------------------------ */ public: /// register an empty constitutive_law of a given type auto & registerNewConstitutiveLaw(const ID & cl_name, const ID & cl_type, const ID & opt_param); /// reassigns constitutive_laws depending on the constitutive_law selector virtual void reassignConstitutiveLaw(); template void for_each_constitutive_law(Func && func) { for (auto && constitutive_law : constitutive_laws) { std::forward(func)( aka::as_type(*constitutive_laws)); } } protected: /// register a constitutive_law in the dynamic database auto & registerNewConstitutiveLaw(const ParserSection & cl_section); /// read the constitutive_law files to instantiate all the constitutive_laws void instantiateConstitutiveLaws(); /// set the element_id_by_constitutive_law and add the elements to the good /// constitutive_laws virtual void assignConstitutiveLawToElements( const ElementTypeMapArray * filter = nullptr); protected: void splitElementByConstitutiveLaw( const Array & elements, std::vector> & elements_per_cl) const; template void splitByConstitutiveLaw(const Array & elements, Operation && op) const; /* ------------------------------------------------------------------------ */ /* Dumpable interface (kept for convenience) and dumper relative functions */ /* ------------------------------------------------------------------------ */ public: //! decide wether a field is a constitutive_law internal or not bool isInternal(const std::string & field_name, ElementKind element_kind); //! give the amount of data per element virtual ElementTypeMap getInternalDataPerElem(const std::string & field_name, ElementKind kind); //! flatten a given constitutive_law internal field ElementTypeMapArray & flattenInternal(const std::string & field_name, ElementKind kind, GhostType ghost_type = _not_ghost); //! flatten all the registered constitutive_law internals void flattenAllRegisteredInternals(ElementKind kind); /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: /// get an iterable on the constitutive_laws inline decltype(auto) getConstitutiveLaws(); /// get an iterable on the constitutive_laws inline decltype(auto) getConstitutiveLaws() const; /// get a particular constitutive_law (by numerical constitutive_law index) inline auto & getConstitutiveLaw(UInt cl_index); /// get a particular constitutive_law (by numerical constitutive_law index) inline const auto & getConstitutiveLaw(UInt cl_index) const; /// get a particular constitutive_law (by constitutive_law name) inline auto & getConstitutiveLaw(const std::string & name); /// get a particular constitutive_law (by constitutive_law name) inline const auto & getConstitutiveLaw(const std::string & name) const; /// get a particular constitutive_law id from is name inline UInt getConstitutiveLawIndex(const std::string & name) const; /// give the number of constitutive_laws inline UInt getNbConstitutiveLaws() const { return constitutive_laws.size(); } /// give the constitutive_law internal index from its id Int getInternalIndexFromID(const ID & id) const; AKANTU_GET_MACRO(ConstitutiveLawByElement, constitutive_law_index, const ElementTypeMapArray &); AKANTU_GET_MACRO(ConstitutiveLawLocalNumbering, constitutive_law_local_numbering, const ElementTypeMapArray &); /// vectors containing local constitutive_law element index for each global /// element index AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(ConstitutiveLawByElement, constitutive_law_index, UInt); AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(ConstitutiveLawLocalNumbering, constitutive_law_local_numbering, UInt); AKANTU_GET_MACRO_NOT_CONST(ConstitutiveLawSelector, *constitutive_law_selector, ConstitutiveLawSelector &); /// Access the non_local_manager interface AKANTU_GET_MACRO(NonLocalManager, *non_local_manager, NonLocalManager &); void setConstitutiveLawSelector( std::shared_ptr constitutive_law_selector) { this->constitutive_law_selector = std::move(constitutive_law_selector); } /* ------------------------------------------------------------------------ */ /* Data Accessor inherited members */ /* ------------------------------------------------------------------------ */ public: UInt getNbData(const Array & elements, const SynchronizationTag & tag) const override; void packData(CommunicationBuffer & buffer, const Array & elements, const SynchronizationTag & tag) const override; void unpackData(CommunicationBuffer & buffer, const Array & elements, const SynchronizationTag & tag) override; /* ------------------------------------------------------------------------ */ /* Mesh Event Handler inherited members */ /* ------------------------------------------------------------------------ */ protected: void onElementsAdded(const Array & element_list, const NewElementsEvent & event) override; void onElementsRemoved(const Array & element_list, const ElementTypeMapArray & new_numbering, const RemovedElementsEvent & event) override; /* ------------------------------------------------------------------------ */ /* NonLocalManager inherited members */ /* ------------------------------------------------------------------------ */ protected: void initializeNonLocal() override; void updateDataForNonLocalCriterion(ElementTypeMapReal & criterion) override; void computeNonLocalStresses(GhostType ghost_type) override; void insertIntegrationPointsInNeighborhoods(GhostType ghost_type) override; /// update the values of the non local internal void updateLocalInternal(ElementTypeMapReal & internal_flat, GhostType ghost_type, ElementKind kind) override; /// copy the results of the averaging in the constitutive_laws void updateNonLocalInternal(ElementTypeMapReal & internal_flat, GhostType ghost_type, ElementKind kind) override; /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// id of the derived class const ID & parent_id; /// underlying mesh const Mesh & _mesh; /// spatial_dimension of the derived model UInt _spatial_dimension{_all_dimensions}; /// mapping between constitutive_law name and constitutive_law internal id std::map constitutive_laws_names_to_id; /// Arrays containing the constitutive_law index for each element ElementTypeMapArray constitutive_law_index; /// Arrays containing the position in the element filter of the /// constitutive_law (constitutive_law's local numbering) ElementTypeMapArray constitutive_law_local_numbering; /// list of used constitutive_laws - std::vector> constitutive_laws; + std::vector> constitutive_laws; /// class defining of to choose a constitutive_law std::shared_ptr constitutive_law_selector; using flatten_internal_map = std::map, std::unique_ptr>>; /// map a registered internals to be flattened for dump purposes flatten_internal_map registered_internals; /// tells if the constitutive_law are instantiated bool are_constitutive_laws_instantiated{false}; /// non local manager std::unique_ptr non_local_manager; template friend class ConstitutiveLaw; }; } // namespace akantu #endif /* AKANTU_CONSTITUTIVE_LAWS_HANDLER_HH */ diff --git a/src/model/solid_mechanics/material_selector.hh b/src/model/solid_mechanics/material_selector.hh index 311c72adb..0b1d2a99d 100644 --- a/src/model/solid_mechanics/material_selector.hh +++ b/src/model/solid_mechanics/material_selector.hh @@ -1,163 +1,97 @@ /** * @file material_selector.hh * * @author Lucas Frerot * @author Nicolas Richart * * @date creation: Wed Nov 13 2013 * @date last modification: Mon Dec 18 2017 * * @brief class describing how to choose a material for a given element * * * Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * Akantu is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Akantu 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 Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with Akantu. If not, see . * */ /* -------------------------------------------------------------------------- */ #include "element.hh" #include "mesh.hh" /* -------------------------------------------------------------------------- */ #include /* -------------------------------------------------------------------------- */ #ifndef AKANTU_MATERIAL_SELECTOR_HH_ #define AKANTU_MATERIAL_SELECTOR_HH_ /* -------------------------------------------------------------------------- */ namespace akantu { class SolidMechanicsModel; -/** - * main class to assign same or different materials for different - * elements - */ -class MaterialSelector : public std::enable_shared_from_this { -public: - MaterialSelector() = default; - virtual ~MaterialSelector() = default; - virtual inline UInt operator()(const Element & element) { - if (fallback_selector) { - return (*fallback_selector)(element); - } - - return fallback_value; - } - - inline void setFallback(UInt f) { fallback_value = f; } - inline void - setFallback(const std::shared_ptr & fallback_selector) { - this->fallback_selector = fallback_selector; - } - - inline void setFallback(MaterialSelector & fallback_selector) { - this->fallback_selector = fallback_selector.shared_from_this(); - } - - inline std::shared_ptr & getFallbackSelector() { - return this->fallback_selector; - } - - inline UInt getFallbackValue() const { return this->fallback_value; } - -protected: - UInt fallback_value{0}; - std::shared_ptr fallback_selector; -}; - -/* -------------------------------------------------------------------------- */ -/** - * class that assigns the first material to regular elements by default - */ -class DefaultMaterialSelector : public MaterialSelector { -public: - explicit DefaultMaterialSelector( - const ElementTypeMapArray & material_index) - : material_index(material_index) {} - - UInt operator()(const Element & element) override { - if (not material_index.exists(element.type, element.ghost_type)) { - return MaterialSelector::operator()(element); - } - - const auto & mat_indexes = material_index(element.type, element.ghost_type); - if (element.element < mat_indexes.size()) { - auto && tmp_mat = mat_indexes(element.element); - if (tmp_mat != UInt(-1)) { - return tmp_mat; - } - } - - return MaterialSelector::operator()(element); - } - -private: - const ElementTypeMapArray & material_index; -}; - +using DefaultMaterialSelector = DedfaultConstitutiveLawSelector; /* -------------------------------------------------------------------------- */ /** * Use elemental data to assign materials */ template class ElementDataMaterialSelector : public MaterialSelector { public: ElementDataMaterialSelector(const ElementTypeMapArray & element_data, const SolidMechanicsModel & model, UInt first_index = 1) : element_data(element_data), model(model), first_index(first_index) {} inline T elementData(const Element & element) { DebugLevel dbl = debug::getDebugLevel(); debug::setDebugLevel(dblError); T data = element_data(element.type, element.ghost_type)(element.element); debug::setDebugLevel(dbl); return data; } inline UInt operator()(const Element & element) override { return MaterialSelector::operator()(element); } protected: /// list of element with the specified data (i.e. tag value) const ElementTypeMapArray & element_data; /// the model that the materials belong const SolidMechanicsModel & model; /// first material index: equal to 1 if none specified UInt first_index; }; /* -------------------------------------------------------------------------- */ /** * class to use mesh data information to assign different materials * where name is the tag value: tag_0, tag_1 */ template class MeshDataMaterialSelector : public ElementDataMaterialSelector { public: MeshDataMaterialSelector(const std::string & name, const SolidMechanicsModel & model, UInt first_index = 1); }; } // namespace akantu #endif /* AKANTU_MATERIAL_SELECTOR_HH_ */ diff --git a/src/model/solid_mechanics/solid_mechanics_model.hh b/src/model/solid_mechanics/solid_mechanics_model.hh index d895436a1..ff8c82b57 100644 --- a/src/model/solid_mechanics/solid_mechanics_model.hh +++ b/src/model/solid_mechanics/solid_mechanics_model.hh @@ -1,483 +1,495 @@ /** * @file solid_mechanics_model.hh * * @author Guillaume Anciaux * @author Daniel Pino Muñoz * @author Nicolas Richart * * @date creation: Tue Jul 27 2010 * @date last modification: Wed Feb 21 2018 * * @brief Model of Solid Mechanics * * * Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * Akantu is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Akantu 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 Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with Akantu. If not, see . * */ /* -------------------------------------------------------------------------- */ #include "boundary_condition.hh" #include "constitutive_laws_handler.hh" #include "data_accessor.hh" #include "fe_engine.hh" #include "model.hh" #include "solid_mechanics_model_event_handler.hh" /* -------------------------------------------------------------------------- */ #ifndef AKANTU_SOLID_MECHANICS_MODEL_HH_ #define AKANTU_SOLID_MECHANICS_MODEL_HH_ namespace akantu { class Material; class MaterialSelector; class DumperIOHelper; template class IntegratorGauss; template class ShapeLagrange; } // namespace akantu /* -------------------------------------------------------------------------- */ namespace akantu { /* -------------------------------------------------------------------------- */ class SolidMechanicsModel : public Model, public DataAccessor, public DataAccessor, public BoundaryCondition, public ConstitutiveLawsHandler, public EventHandlerManager { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: using MyFEEngineType = FEEngineTemplate; protected: using EventManager = EventHandlerManager; public: SolidMechanicsModel(Mesh & mesh, UInt dim = _all_dimensions, const ID & id = "solid_mechanics_model", ModelType model_type = ModelType::_solid_mechanics_model); ~SolidMechanicsModel() override; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ protected: /// initialize completely the model void initFullImpl( const ModelOptions & options = SolidMechanicsModelOptions()) override; public: /// initialize all internal arrays for materials virtual void initMaterials(); protected: /// initialize the model void initModel() override; /// function to print the containt of the class void printself(std::ostream & stream, int indent = 0) const override; /// get some default values for derived classes std::tuple getDefaultSolverID(const AnalysisMethod & method) override; /* ------------------------------------------------------------------------ */ /* Solver interface */ /* ------------------------------------------------------------------------ */ public: /// assembles the stiffness matrix, virtual void assembleStiffnessMatrix(); /// assembles the internal forces in the array internal_forces virtual void assembleInternalForces(); protected: /// callback for the solver, this adds f_{ext} - f_{int} to the residual void assembleResidual() override; /// callback for the solver, this adds f_{ext} or f_{int} to the residual void assembleResidual(const ID & residual_part) override; bool canSplitResidual() override { return true; } /// get the type of matrix needed MatrixType getMatrixType(const ID & matrix_id) override; /// callback for the solver, this assembles different matrices void assembleMatrix(const ID & matrix_id) override; /// callback for the solver, this assembles the stiffness matrix void assembleLumpedMatrix(const ID & matrix_id) override; /// callback for the solver, this is called at beginning of solve void predictor() override; /// callback for the solver, this is called at end of solve void corrector() override; /// callback for the solver, this is called at beginning of solve void beforeSolveStep() override; /// callback for the solver, this is called at end of solve void afterSolveStep(bool converged = true) override; /// Callback for the model to instantiate the matricees when needed void initSolver(TimeStepSolverType time_step_solver_type, NonLinearSolverType non_linear_solver_type) override; protected: /* ------------------------------------------------------------------------ */ TimeStepSolverType getDefaultSolverType() const override; /* ------------------------------------------------------------------------ */ ModelSolverOptions getDefaultSolverOptions(const TimeStepSolverType & type) const override; public: bool isDefaultSolverExplicit() { return method == _explicit_lumped_mass || method == _explicit_consistent_mass; } protected: /// update the current position vector void updateCurrentPosition(); /* ------------------------------------------------------------------------ */ /* Materials (solid_mechanics_model_material.cc) */ /* ------------------------------------------------------------------------ */ public: /// apply a constant eigen_grad_u on all quadrature points of a given material virtual void applyEigenGradU(const Matrix & prescribed_eigen_grad_u, const ID & material_name, GhostType ghost_type = _not_ghost); /* ------------------------------------------------------------------------ */ /* Mass (solid_mechanics_model_mass.cc) */ /* ------------------------------------------------------------------------ */ public: /// assemble the lumped mass matrix void assembleMassLumped(); /// assemble the mass matrix for consistent mass resolutions void assembleMass(); protected: /// assemble the lumped mass matrix for local and ghost elements void assembleMassLumped(GhostType ghost_type); /// assemble the mass matrix for either _ghost or _not_ghost elements void assembleMass(GhostType ghost_type); /// fill a vector of rho void computeRho(Array & rho, ElementType type, GhostType ghost_type); /// compute the kinetic energy Real getKineticEnergy(); Real getKineticEnergy(ElementType type, UInt index); /// compute the external work (for impose displacement, the velocity should be /// given too) Real getExternalWork(); /* ------------------------------------------------------------------------ */ /* Data Accessor inherited members */ /* ------------------------------------------------------------------------ */ public: UInt getNbData(const Array & elements, const SynchronizationTag & tag) const override; void packData(CommunicationBuffer & buffer, const Array & elements, const SynchronizationTag & tag) const override; void unpackData(CommunicationBuffer & buffer, const Array & elements, const SynchronizationTag & tag) override; UInt getNbData(const Array & dofs, const SynchronizationTag & tag) const override; void packData(CommunicationBuffer & buffer, const Array & dofs, const SynchronizationTag & tag) const override; void unpackData(CommunicationBuffer & buffer, const Array & dofs, const SynchronizationTag & tag) override; /* ------------------------------------------------------------------------ */ /* Mesh Event Handler inherited members */ /* ------------------------------------------------------------------------ */ protected: void onNodesAdded(const Array & nodes_list, const NewNodesEvent & event) override; void onNodesRemoved(const Array & element_list, const Array & new_numbering, const RemovedNodesEvent & event) override; void onElementsAdded(const Array & element_list, const NewElementsEvent & event) override; void onElementsRemoved(const Array & element_list, const ElementTypeMapArray & new_numbering, const RemovedElementsEvent & event) override; void onElementsChanged(const Array & /*unused*/, const Array & /*unused*/, const ElementTypeMapArray & /*unused*/, const ChangedElementsEvent & /*unused*/) override{}; /* ------------------------------------------------------------------------ */ /* Dumpable interface (kept for convenience) and dumper relative functions */ /* ------------------------------------------------------------------------ */ public: virtual void onDump(); std::shared_ptr createNodalFieldReal(const std::string & field_name, const std::string & group_name, bool padding_flag) override; std::shared_ptr createNodalFieldBool(const std::string & field_name, const std::string & group_name, bool padding_flag) override; std::shared_ptr createElementalField(const std::string & field_name, const std::string & group_name, bool padding_flag, UInt spatial_dimension, ElementKind kind) override; void dump(const std::string & dumper_name) override; void dump(const std::string & dumper_name, UInt step) override; void dump(const std::string & dumper_name, Real time, UInt step) override; void dump() override; void dump(UInt step) override; void dump(Real time, UInt step) override; /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: /// return the dimension of the system space AKANTU_GET_MACRO(SpatialDimension, Model::spatial_dimension, UInt); /// set the value of the time step void setTimeStep(Real time_step, const ID & solver_id = "") override; /// get the value of the conversion from forces/ mass to acceleration AKANTU_GET_MACRO(F_M2A, f_m2a, Real); /// set the value of the conversion from forces/ mass to acceleration AKANTU_SET_MACRO(F_M2A, f_m2a, Real); /// get the SolidMechanicsModel::displacement array AKANTU_GET_MACRO_DEREF_PTR_NOT_CONST(Displacement, displacement); /// get the SolidMechanicsModel::displacement array AKANTU_GET_MACRO_DEREF_PTR(Displacement, displacement); /// get the SolidMechanicsModel::previous_displacement array AKANTU_GET_MACRO_DEREF_PTR(PreviousDisplacement, previous_displacement); /// get the SolidMechanicsModel::current_position array const Array & getCurrentPosition(); /// get the SolidMechanicsModel::displacement_increment array AKANTU_GET_MACRO_DEREF_PTR(Increment, displacement_increment); /// get the SolidMechanicsModel::displacement_increment array AKANTU_GET_MACRO_DEREF_PTR_NOT_CONST(Increment, displacement_increment); /// get the lumped SolidMechanicsModel::mass array AKANTU_GET_MACRO_DEREF_PTR(Mass, mass); /// get the SolidMechanicsModel::velocity array AKANTU_GET_MACRO_DEREF_PTR_NOT_CONST(Velocity, velocity); /// get the SolidMechanicsModel::velocity array AKANTU_GET_MACRO_DEREF_PTR(Velocity, velocity); /// get the SolidMechanicsModel::acceleration array AKANTU_GET_MACRO_DEREF_PTR_NOT_CONST(Acceleration, acceleration); /// get the SolidMechanicsModel::acceleration array AKANTU_GET_MACRO_DEREF_PTR(Acceleration, acceleration); /// get the SolidMechanicsModel::external_force array AKANTU_GET_MACRO_DEREF_PTR_NOT_CONST(ExternalForce, external_force); /// get the SolidMechanicsModel::external_force array AKANTU_GET_MACRO_DEREF_PTR(ExternalForce, external_force); /// get the SolidMechanicsModel::force array (external forces) [[deprecated("Use getExternalForce instead of this function")]] Array & getForce() { return getExternalForce(); } /// get the SolidMechanicsModel::internal_force array (internal forces) AKANTU_GET_MACRO_DEREF_PTR_NOT_CONST(InternalForce, internal_force); /// get the SolidMechanicsModel::internal_force array (internal forces) AKANTU_GET_MACRO_DEREF_PTR(InternalForce, internal_force); /// get the SolidMechanicsModel::blocked_dofs array AKANTU_GET_MACRO_DEREF_PTR_NOT_CONST(BlockedDOFs, blocked_dofs); /// get the SolidMechanicsModel::blocked_dofs array AKANTU_GET_MACRO_DEREF_PTR(BlockedDOFs, blocked_dofs); /// get an iterable on the materials - inline decltype(auto) getMaterials(); + inline decltype(auto) getMaterials() { + this->getConstitutiveLaws(); + } /// get an iterable on the materials - inline decltype(auto) getMaterials() const; + inline decltype(auto) getMaterials() const { + this->getConstitutiveLaws(); + } /// get a particular material (by numerical material index) - inline Material & getMaterial(UInt mat_index); + inline Material & getMaterial(UInt mat_index) { + this->getConstitutiveLaw(mat_index); + } /// get a particular material (by numerical material index) - inline const Material & getMaterial(UInt mat_index) const; + inline const Material & getMaterial(UInt mat_index) const { + this->getConstitutiveLaw(mat_index); + } /// get a particular material (by material name) - inline Material & getMaterial(const std::string & name); + inline Material & getMaterial(const std::string & name) { + this->getConstitutiveLaw(name); + } /// get a particular material (by material name) - inline const Material & getMaterial(const std::string & name) const; + inline const Material & getMaterial(const std::string & name) const { + this->getConstitutiveLaw(name); + } /// get a particular material id from is name inline UInt getMaterialIndex(const std::string & name) const; /// give the number of materials inline UInt getNbMaterials() const { return getNbConstitutiveLaws(); } /// compute the stable time step Real getStableTimeStep(); /// get the energies Real getEnergy(const std::string & energy_id); /// compute the energy for an element Real getEnergy(const std::string & energy_id, ElementType type, UInt index); /// compute the energy for an element Real getEnergy(const std::string & energy_id, const Element & element) { return getEnergy(energy_id, element.type, element.element); } /// compute the energy for an element group Real getEnergy(const ID & energy_id, const ID & group_id); // this function is kept for backward compatinility decltype(auto) getMaterialByElement() const { return this->getConstitutiveLawByElement(); } // this function is kept for backward compatinility decltype(auto) getMaterialLocalNumbering() const { return this->getConstitutiveLawLocalNumbering(); } // this function is kept for backward compatinility decltype(auto) getMaterialByElement(ElementType type, GhostType ghost_type = _not_ghost) const { return this->getConstitutiveLawByElement(type, ghost_type); } // this function is kept for backward compatinility decltype(auto) getMaterialLocalNumbering(ElementType type, GhostType ghost_type = _not_ghost) const { return this->getConstitutiveLawLocalNumbering(type, ghost_type); } // this function is kept for backward compatinility decltype(auto) getMaterialSelector() { return this->getConstitutiveLawSelector(); } // this function is kept for backward compatinility void setMaterialSelector(std::shared_ptr material_selector) { this->setConstitutiveLawSelector(std::move(material_selector)); } /// get the FEEngine object to integrate or interpolate on the boundary FEEngine & getFEEngineBoundary(const ID & name = "") override; protected: /// compute the stable time step Real getStableTimeStep(GhostType ghost_type); /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// release version of the displacement array UInt displacement_release{0}; /// release version of the current_position array UInt current_position_release{0}; /// Check if materials need to recompute the mass array bool need_to_reassemble_lumped_mass{true}; /// Check if materials need to recompute the mass matrix bool need_to_reassemble_mass{true}; protected: /// conversion coefficient form force/mass to acceleration Real f_m2a{1.0}; /// displacements array std::unique_ptr> displacement; /// displacements array at the previous time step (used in finite deformation) std::unique_ptr> previous_displacement; /// increment of displacement std::unique_ptr> displacement_increment; /// lumped mass array std::unique_ptr> mass; /// velocities array std::unique_ptr> velocity; /// accelerations array std::unique_ptr> acceleration; /// external forces array std::unique_ptr> external_force; /// internal forces array std::unique_ptr> internal_force; /// array specifing if a degree of freedom is blocked or not std::unique_ptr> blocked_dofs; /// array of current position used during update residual std::unique_ptr> current_position; }; /* -------------------------------------------------------------------------- */ namespace BC { namespace Neumann { using FromStress = FromHigherDim; using FromTraction = FromSameDim; } // namespace Neumann } // namespace BC } // namespace akantu /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ #include "material.hh" #include "parser.hh" /* -------------------------------------------------------------------------- */ #endif /* AKANTU_SOLID_MECHANICS_MODEL_HH_ */