diff --git a/packages/00_core.cmake b/packages/00_core.cmake index 022353baa..5cccc510f 100644 --- a/packages/00_core.cmake +++ b/packages/00_core.cmake @@ -1,363 +1,361 @@ #=============================================================================== # @file core.cmake # # @author Guillaume Anciaux # @author Nicolas Richart # # @date Mon Nov 21 18:19:15 2011 # # @brief package description for core # # @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 . # #=============================================================================== set(AKANTU_CORE ON CACHE INTERNAL "core package for Akantu" FORCE) set(AKANTU_CORE_FILES common/aka_array.cc common/aka_array.hh common/aka_array_tmpl.hh common/aka_blas_lapack.hh - common/aka_circular_vector.hh - common/aka_circular_vector_inline_impl.cc + common/aka_circular_array.hh + common/aka_circular_array_inline_impl.cc common/aka_common.cc common/aka_common.hh common/aka_common_inline_impl.cc common/aka_csr.hh common/aka_error.cc common/aka_error.hh - common/aka_event_handler.hh + common/aka_event_handler_manager.hh common/aka_extern.cc common/aka_fwd.hh - common/aka_grid.hh common/aka_grid_dynamic.hh - common/aka_grid_tmpl.hh common/aka_math.cc common/aka_math.hh common/aka_math_tmpl.hh common/aka_memory.cc common/aka_memory.hh common/aka_memory_inline_impl.cc common/aka_random_generator.hh common/aka_safe_enum.hh common/aka_static_memory.cc common/aka_static_memory.hh common/aka_static_memory_inline_impl.cc common/aka_static_memory_tmpl.hh common/aka_typelist.hh common/aka_types.hh common/aka_visitor.hh common/aka_voigthelper.hh common/aka_voigthelper.cc fem/by_element_type.hh fem/by_element_type_tmpl.hh fem/element_class.cc fem/element_class.hh fem/element_class_tmpl.hh fem/element_classes/element_class_hexahedron_8_inline_impl.cc fem/element_classes/element_class_pentahedron_6_inline_impl.cc fem/element_classes/element_class_point_1_inline_impl.cc fem/element_classes/element_class_quadrangle_4_inline_impl.cc fem/element_classes/element_class_quadrangle_8_inline_impl.cc fem/element_classes/element_class_segment_2_inline_impl.cc fem/element_classes/element_class_segment_3_inline_impl.cc fem/element_classes/element_class_tetrahedron_10_inline_impl.cc fem/element_classes/element_class_tetrahedron_4_inline_impl.cc fem/element_classes/element_class_triangle_3_inline_impl.cc fem/element_classes/element_class_triangle_6_inline_impl.cc fem/element_group.cc fem/element_group.hh fem/element_group_inline_impl.cc fem/fem.cc fem/fem.hh fem/fem_inline_impl.cc fem/fem_template.hh fem/fem_template_tmpl.hh fem/geometrical_data_tmpl.hh fem/geometrical_element.cc fem/group_manager.cc fem/group_manager.hh fem/group_manager_inline_impl.cc fem/integration_element.cc fem/integrator.hh fem/integrator_gauss.hh fem/integrator_gauss_inline_impl.cc fem/interpolation_element.cc fem/interpolation_element_tmpl.hh fem/mesh.cc fem/mesh.hh fem/mesh_filter.hh fem/mesh_data.cc fem/mesh_data.hh fem/mesh_data_tmpl.hh fem/mesh_inline_impl.cc fem/node_group.cc fem/node_group.hh fem/node_group_inline_impl.cc fem/shape_functions.hh fem/shape_functions_inline_impl.cc fem/shape_lagrange.cc fem/shape_lagrange.hh fem/shape_lagrange_inline_impl.cc fem/shape_linked.cc fem/shape_linked.hh fem/shape_linked_inline_impl.cc io/dumper/dumpable.hh io/dumper/dumpable_inline_impl.hh io/mesh_io.cc io/mesh_io.hh io/mesh_io/mesh_io_abaqus.cc io/mesh_io/mesh_io_abaqus.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/model_io.cc io/model_io.hh io/parser/algebraic_parser.hh io/parser/input_file_parser.hh io/parser/parsable.cc io/parser/parsable.hh io/parser/parsable_tmpl.hh io/parser/parser.cc io/parser/parser.hh io/parser/parser_tmpl.hh io/parser/cppargparse/cppargparse.hh io/parser/cppargparse/cppargparse.cc io/parser/cppargparse/cppargparse_tmpl.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_pbc.cc mesh_utils/mesh_utils.cc mesh_utils/mesh_utils.hh mesh_utils/mesh_utils_inline_impl.cc mesh_utils/mesh_graph.cc mesh_utils/mesh_graph.hh model/boundary_condition.hh model/boundary_condition_functor.hh model/boundary_condition_functor_inline_impl.cc model/boundary_condition_tmpl.hh model/integration_scheme/generalized_trapezoidal.hh model/integration_scheme/generalized_trapezoidal_inline_impl.cc model/integration_scheme/integration_scheme_1st_order.hh model/integration_scheme/integration_scheme_2nd_order.hh model/integration_scheme/newmark-beta.hh model/integration_scheme/newmark-beta_inline_impl.cc model/model.cc model/model.hh model/model_inline_impl.cc model/solid_mechanics/material.cc model/solid_mechanics/material.hh model/solid_mechanics/material_inline_impl.cc model/solid_mechanics/material_list.hh model/solid_mechanics/material_random_internal.hh model/solid_mechanics/material_selector.hh model/solid_mechanics/material_selector_tmpl.hh model/solid_mechanics/materials/internal_field.hh model/solid_mechanics/materials/internal_field_tmpl.hh model/solid_mechanics/materials/material_elastic.cc model/solid_mechanics/materials/material_elastic.hh model/solid_mechanics/materials/material_elastic_inline_impl.cc model/solid_mechanics/materials/material_thermal.cc model/solid_mechanics/materials/material_thermal.hh model/solid_mechanics/materials/random_internal_field.hh model/solid_mechanics/materials/random_internal_field_tmpl.hh model/solid_mechanics/solid_mechanics_model.cc model/solid_mechanics/solid_mechanics_model.hh model/solid_mechanics/solid_mechanics_model_inline_impl.cc model/solid_mechanics/solid_mechanics_model_mass.cc model/solid_mechanics/solid_mechanics_model_material.cc model/solid_mechanics/solid_mechanics_model_tmpl.hh model/solid_mechanics/solid_mechanics_model_event_handler.hh solver/solver.cc solver/solver.hh solver/sparse_matrix.cc solver/sparse_matrix.hh solver/sparse_matrix_inline_impl.cc synchronizer/communication_buffer.hh synchronizer/communication_buffer_inline_impl.cc synchronizer/data_accessor.cc synchronizer/data_accessor.hh synchronizer/data_accessor_inline_impl.cc synchronizer/distributed_synchronizer.cc synchronizer/distributed_synchronizer.hh synchronizer/distributed_synchronizer_tmpl.hh synchronizer/dof_synchronizer.cc synchronizer/dof_synchronizer.hh synchronizer/dof_synchronizer_inline_impl.cc synchronizer/filtered_synchronizer.cc synchronizer/filtered_synchronizer.hh synchronizer/mpi_type_wrapper.hh synchronizer/pbc_synchronizer.cc synchronizer/pbc_synchronizer.hh synchronizer/real_static_communicator.hh synchronizer/static_communicator.cc synchronizer/static_communicator.hh synchronizer/static_communicator_dummy.hh synchronizer/static_communicator_inline_impl.hh synchronizer/synchronizer.cc synchronizer/synchronizer.hh synchronizer/synchronizer_registry.cc synchronizer/synchronizer_registry.hh ) set(AKANTU_CORE_DEB_DEPEND libboost-dev ) set(AKANTU_CORE_TESTS test_csr test_facet_element_mapping test_facet_extraction_tetrahedron_4 test_facet_extraction_triangle_3 test_grid test_interpolate_stress test_local_material test_material_damage_non_local test_material_thermal test_matrix test_mesh_boundary test_mesh_data test_mesh_io_msh test_mesh_io_msh_physical_names test_mesh_partitionate_mesh_data test_parser test_pbc_tweak test_purify_mesh test_solid_mechanics_model_bar_traction2d test_solid_mechanics_model_bar_traction2d_structured test_solid_mechanics_model_bar_traction2d_structured_pbc test_solid_mechanics_model_boundary_condition test_solid_mechanics_model_circle_2 test_solid_mechanics_model_cube3d test_solid_mechanics_model_cube3d_pbc test_solid_mechanics_model_cube3d_tetra10 test_solid_mechanics_model_square test_solid_mechanics_model_material_eigenstrain test_static_memory test_surface_extraction_tetrahedron_4 test_surface_extraction_triangle_3 test_vector test_vector_iterator test_weight test_math ) set(AKANTU_CORE_MANUAL_FILES manual.sty manual.cls manual.tex manual-macros.sty manual-titlepages.tex manual-introduction.tex manual-gettingstarted.tex manual-io.tex manual-solidmechanicsmodel.tex manual-lumping.tex manual-elements.tex manual-appendix-elements.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/dynamic_analysis.png figures/explicit_dynamic.pdf figures/explicit_dynamic.svg figures/hooke_law.pdf figures/hot-point-1.png figures/hot-point-2.png figures/implicit_dynamic.pdf figures/implicit_dynamic.svg figures/implicit_static.pdf figures/implicit_static.svg figures/insertion.pdf figures/interpolate.pdf figures/interpolate.svg figures/law.pdf figures/static_analysis.png figures/stress_strain_el.pdf figures/tangent.pdf figures/tangent.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 ) find_program(READLINK_COMMAND readlink) find_program(ADDR2LINE_COMMAND addr2line) mark_as_advanced(READLINK_COMMAND) mark_as_advanced(ADDR2LINE_COMMAND) include(CheckFunctionExists) check_function_exists(clock_gettime _clock_gettime) if(NOT _clock_gettime) set(AKANTU_USE_OBSOLETE_GETTIMEOFDAY ON) else() set(AKANTU_USE_OBSOLETE_GETTIMEOFDAY OFF) endif() list(APPEND AKANTU_BOOST_COMPONENTS graph ) diff --git a/src/common/aka_bounding_box.hh b/src/common/aka_bounding_box.hh index cae080b21..58deea204 100644 --- a/src/common/aka_bounding_box.hh +++ b/src/common/aka_bounding_box.hh @@ -1,222 +1,243 @@ /** * @file aka_bounding_box.hh * @author David Kammer * @author Alejandro Aragon * @date Thu Jan 12 15:25:57 2012 * * @brief class for a bounding box * * @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 . * */ /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_AKA_BOUNDING_BOX_HH__ #define __AKANTU_AKA_BOUNDING_BOX_HH__ #include #include #include "aka_common.hh" #include "aka_point.hh" __BEGIN_AKANTU__ using std::cout; using std::endl; template class BoundingBox; /// considers bounding box with respect to a list of points and adaptes it template BoundingBox computeBoundingBox(const point_container& points) { typedef typename point_container::const_iterator point_iterator; point_iterator it = points.begin(); assert(it != points.end()); BoundingBox bbox(*it); for (++it; it != points.end(); ++it) bbox += *it; return bbox; } template BoundingBox createPointList(const nodes_container& nodes, const Array& coord); template class BoundingBox : public Bounding_volume { public: typedef Bounding_volume base_type; typedef typename base_type::point_type point_type; typedef typename point_type::value_type value_type; static int dim() { return d; } private: /// minimum point point_type min_; /// maximum point point_type max_; public: - // default constructor, creates an inconsistent bounding box + /// default constructor, creates an inconsistent bounding box BoundingBox() : base_type(), min_(inf), max_(-inf) {} - // point constructor, sets the bounding box to the point + /// point constructor, sets the bounding box to the point BoundingBox(const point_type& p1) : base_type(), min_(p1), max_(p1) {} - // two-point constructor, calculates minimum and maximum points + /// two-point constructor, calculates minimum and maximum points BoundingBox(const point_type& p1, const point_type& p2, bool compute = true) : base_type(), min_(p1), max_(p2) { if (compute) for (Int i=0; i BoundingBox(iterator first, iterator last) : base_type(), min_(*first), max_(*first) { ++first; for (; first != last; ++first) this->operator+=(*first); } + /// returns the measure of the bounding box: the measure is the volume of the box value_type measure() const { value_type v = 1; for (int i=0; ioperator+=(bbox.min_); this->operator+=(bbox.max_); return *this; } + /// is the point p geometrically inside of the bounding box? bool operator&(const point_type& p) const { Real e = 2*std::numeric_limits::epsilon(); for (Int i=0; i::epsilon(); for (Int i=0; i BoundingBox operator+(const BoundingBox& b1, const BoundingBox& b2) { BoundingBox r(b1); return r += b2; } template std::ostream& operator<<(std::ostream&, const BoundingBox&); __END_AKANTU__ #endif /* __AKANTU_AKA_BOUNDING_BOX_HH__ */ diff --git a/src/common/aka_circular_vector.hh b/src/common/aka_circular_array.hh similarity index 89% rename from src/common/aka_circular_vector.hh rename to src/common/aka_circular_array.hh index 6573dd7f0..965af0026 100644 --- a/src/common/aka_circular_vector.hh +++ b/src/common/aka_circular_array.hh @@ -1,135 +1,138 @@ /** - * @file aka_circular_vector.hh + * @file aka_circular_array.hh * * @author David Simon Kammer * * @date Fri Nov 11 15:24:34 2011 * - * @brief class of circular vector + * @brief class of circular array * * @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 . * */ /* -------------------------------------------------------------------------- */ -#ifndef __AKANTU_AKA_CIRCULAR_VECTOR_HH__ -#define __AKANTU_AKA_CIRCULAR_VECTOR_HH__ +#ifndef __AKANTU_AKA_CIRCULAR_ARRAY_HH__ +#define __AKANTU_AKA_CIRCULAR_ARRAY_HH__ /* -------------------------------------------------------------------------- */ #include /* -------------------------------------------------------------------------- */ #include "aka_common.hh" #include "aka_array.hh" /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ template class CircularArray : protected Array { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: typedef typename Array::value_type value_type; typedef typename Array::reference reference; typedef typename Array::pointer_type pointer_type; typedef typename Array::const_reference const_reference; - /// Allocation of a new vector with a default value + /// Allocation of a new array with a default value CircularArray(UInt size, UInt nb_component = 1, const_reference value = value_type(), const ID & id = "") : Array(size, nb_component, value, id), start_position(0), end_position(size-1) { AKANTU_DEBUG_IN(); AKANTU_DEBUG_OUT(); }; virtual ~CircularArray() { AKANTU_DEBUG_IN(); AKANTU_DEBUG_OUT(); }; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: - /// advance start and end position by one + /** + advance start and end position by one: + the first element is now at the end of the array + **/ inline void makeStep(); /// function to print the contain of the class virtual void printself(std::ostream & stream, int indent = 0) const; private: /* ------------------------------------------------------------------------ */ /* Operators */ /* ------------------------------------------------------------------------ */ public: inline reference operator()(UInt i, UInt j = 0); inline const_reference operator()(UInt i, UInt j = 0) const; /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: UInt getSize() const{ return this->size; }; /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: - /// indice of first element in this circular vector + /// indice of first element in this circular array UInt start_position; - /// indice of last element in this circular vector + /// indice of last element in this circular array UInt end_position; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ #if defined (AKANTU_INCLUDE_INLINE_IMPL) -# include "aka_circular_vector_inline_impl.cc" +# include "aka_circular_array_inline_impl.cc" #endif /// standard output stream operator template inline std::ostream & operator <<(std::ostream & stream, const CircularArray & _this) { _this.printself(stream); return stream; } __END_AKANTU__ -#endif /* __AKANTU_AKA_CIRCULAR_VECTOR_HH__ */ +#endif /* __AKANTU_AKA_CIRCULAR_ARRAY_HH__ */ diff --git a/src/common/aka_circular_vector_inline_impl.cc b/src/common/aka_circular_array_inline_impl.cc similarity index 90% rename from src/common/aka_circular_vector_inline_impl.cc rename to src/common/aka_circular_array_inline_impl.cc index 1be6f2aad..ca4409987 100644 --- a/src/common/aka_circular_vector_inline_impl.cc +++ b/src/common/aka_circular_array_inline_impl.cc @@ -1,82 +1,82 @@ /** - * @file aka_circular_vector_inline_impl.cc + * @file aka_circular_array_inline_impl.cc * * @author David Simon Kammer * * @date Fri Nov 11 15:24:34 2011 * - * @brief implementation of circular vector + * @brief implementation of circular array * * @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 . * */ /* -------------------------------------------------------------------------- */ /* Inline Functions Array */ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ template inline typename CircularArray::reference CircularArray::operator()(UInt i, UInt j) { AKANTU_DEBUG_ASSERT(end_position != start_position, - "The vector \"" << this->id << "\" is empty"); + "The array \"" << this->id << "\" is empty"); AKANTU_DEBUG_ASSERT((i < (end_position - start_position + this->allocated_size) % this->allocated_size + 1) && (j < this->nb_component), "The value at position [" << i << "," << j - << "] is out of range in vector \"" << this->id << "\""); + << "] is out of range in array \"" << this->id << "\""); return this->values[((i+start_position)%this->allocated_size)*this->nb_component + j]; } /* -------------------------------------------------------------------------- */ template inline typename CircularArray::const_reference CircularArray::operator()(UInt i, UInt j) const { AKANTU_DEBUG_ASSERT(end_position != start_position, - "The vector \"" << this->id << "\" is empty"); + "The array \"" << this->id << "\" is empty"); AKANTU_DEBUG_ASSERT((i < (end_position - start_position + this->allocated_size) % this->allocated_size + 1) && (j < this->nb_component), "The value at position [" << i << "," << j - << "] is out of range in vector \"" << this->id << "\""); + << "] is out of range in array \"" << this->id << "\""); return this->values[((i+start_position)%this->allocated_size)*this->nb_component + j]; } /* -------------------------------------------------------------------------- */ template inline void CircularArray::makeStep() { AKANTU_DEBUG_IN(); start_position = (start_position+1) % this->allocated_size; end_position = (end_position+1) % this->allocated_size; AKANTU_DEBUG_OUT(); } /* -------------------------------------------------------------------------- */ template void CircularArray::printself(std::ostream & stream, int indent) const { std::string space; for(Int i = 0; i < indent; i++, space += AKANTU_INDENT); stream << space << "CircularArray<" << debug::demangle(typeid(T).name()) << "> [" << std::endl; stream << space << " + start_position : " << this->start_position << std::endl; stream << space << " + end_position : " << this->end_position << std::endl; Array::printself(stream, indent+1); stream << space << "]" << std::endl; } diff --git a/src/common/aka_event_handler.hh b/src/common/aka_event_handler_manager.hh similarity index 94% rename from src/common/aka_event_handler.hh rename to src/common/aka_event_handler_manager.hh index 5443e271f..72bb2cc26 100644 --- a/src/common/aka_event_handler.hh +++ b/src/common/aka_event_handler_manager.hh @@ -1,89 +1,89 @@ /** - * @file aka_event_handler.hh + * @file aka_event_handler_manager.hh * * @author Nicolas Richart * * @date Thu Aug 23 16:39:04 2012 * * @brief Base of Event Handler classes * * @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 . * */ /* -------------------------------------------------------------------------- */ -#ifndef __AKANTU_AKA_EVENT_HANDLER_HH__ -#define __AKANTU_AKA_EVENT_HANDLER_HH__ +#ifndef __AKANTU_AKA_EVENT_HANDLER_MANAGER_HH__ +#define __AKANTU_AKA_EVENT_HANDLER_MANAGER_HH__ /* -------------------------------------------------------------------------- */ #include "aka_common.hh" /* -------------------------------------------------------------------------- */ #include /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ template class EventHandlerManager { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: virtual ~EventHandlerManager() {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: void registerEventHandler(EventHandler & event_handler) { event_handlers.insert(&event_handler); } void unregisterEventHandler(EventHandler & event_handler) { event_handlers.erase(&event_handler); } template void sendEvent(const Event & event) { typename std::set::iterator it = event_handlers.begin(); typename std::set::iterator end = event_handlers.end(); for(;it != end; ++it) (*it)->sendEvent(event); } /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// list of the event handlers std::set event_handlers; }; __END_AKANTU__ -#endif /* __AKANTU_AKA_EVENT_HANDLER_HH__ */ +#endif /* __AKANTU_AKA_EVENT_HANDLER_MANAGER_HH__ */ diff --git a/src/common/aka_fwd.hh b/src/common/aka_fwd.hh index bbea15454..7acd8855c 100644 --- a/src/common/aka_fwd.hh +++ b/src/common/aka_fwd.hh @@ -1,66 +1,68 @@ /** * @file aka_fwd.hh * @author Nicolas Richart * @author Alejandro M. Aragón * @date Thu Jan 3 15:15:00 2013 * - * @brief File containing forward declarations in akantu + * @brief File containing forward declarations in akantu. + * This file helps if circular #include would be needed because two classes + * refer both to each other. This file usually does not need any modification. * * @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 . * */ /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_FWD_HH__ #define __AKANTU_FWD_HH__ namespace cppargparse { class ArgumentParser; } namespace akantu { // forward declaration template struct ContactData; template class Matrix; template class Vector; template class Tensor3; template::value > class Array; template class SpatialGrid; // Model element template class ModelElement; extern const Array empty_filter; class Parser; class ParserSection; extern Parser static_parser; extern cppargparse::ArgumentParser static_argparser; } #endif /* __AKANTU_FWD_HH__ */ diff --git a/src/common/aka_grid.hh b/src/common/aka_grid.hh deleted file mode 100644 index 57cd196f6..000000000 --- a/src/common/aka_grid.hh +++ /dev/null @@ -1,144 +0,0 @@ -/** - * @file aka_grid.hh - * - * @author Nicolas Richart - * - * @date Wed Aug 31 11:09:48 2011 - * - * @brief A regular grid that can contain information per cells - * - * @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 "aka_common.hh" -/* -------------------------------------------------------------------------- */ - -#ifndef __AKANTU_AKA_GRID_HH__ -#define __AKANTU_AKA_GRID_HH__ - -__BEGIN_AKANTU__ - -class Mesh; - -template -class RegularGrid { - /* ------------------------------------------------------------------------ */ - /* Constructors/Destructors */ - /* ------------------------------------------------------------------------ */ -public: - - RegularGrid() {}; - - RegularGrid(UInt dimension, Real * lower_bounds, - Real * upper_bounds, Real * spacing); - virtual ~RegularGrid() {}; - - class Cell; - - /* ------------------------------------------------------------------------ */ - /* Methods */ - /* ------------------------------------------------------------------------ */ -public: - void saveAsMesh(Mesh & mesh) const; - - // void beginInsertions() { data.countToCSR(); data.resizeCols(); data.beginInsertions(); } - // void endInsertions() { data.endInsertions(); } - void insert(const T & d, const Vector & position); - - // inline void count(const Vector & position); - inline Cell getCell(const Vector & position) const; - inline UInt getCell(Real position, UInt direction) const; - - /// function to print the contain of the class - virtual void printself(std::ostream & stream, int indent = 0) const; - - typedef typename Array::template iterator iterator; - typedef typename Array::template const_iterator const_iterator; - - inline iterator beginCell(const Cell & cell); - inline iterator endCell(const Cell cell); - inline const_iterator beginCell(const Cell & cell) const; - inline const_iterator endCell(const Cell & cell) const; - - class neighbor_cells_iterator; - - inline neighbor_cells_iterator beginNeighborCells(const Cell & cell); - inline neighbor_cells_iterator endNeighborCells(const Cell & cell); - - /* ------------------------------------------------------------------------ */ - /* Accessors */ - /* ------------------------------------------------------------------------ */ -public: - inline UInt getNbCells(UInt dim) const { return nb_cells[dim]; }; - - AKANTU_GET_MACRO(Dimension, dimension, UInt) - - friend class Cell; - - void getLocalLowerBounds(Real * x_min) const - { for (UInt i = 0; i < dimension; ++i) x_min[i] = lower_bounds[i]; } - void getLocalUpperBounds(Real * x_max) const - { for (UInt i = 0; i < dimension; ++i) x_max[i] = upper_bounds[i]; } - - void getSpacing(Real * sp) const - { for (UInt i = 0; i < dimension; ++i) sp[i] = spacing[i]; } - - - - /* ------------------------------------------------------------------------ */ - /* Class Members */ - /* ------------------------------------------------------------------------ */ -private: - - Array< Array > data; - // CSR data; - - UInt dimension; - - Real lower_bounds[3]; - Real upper_bounds[3]; - - UInt nb_cells[3]; - - UInt total_nb_cells; - - Real spacing[3]; -}; - - -/* -------------------------------------------------------------------------- */ -/* inline functions */ -/* -------------------------------------------------------------------------- */ - -#include "aka_grid_tmpl.hh" - -/// standard output stream operator -template -inline std::ostream & operator <<(std::ostream & stream, const RegularGrid & _this) -{ - _this.printself(stream); - return stream; -} - - -__END_AKANTU__ - -#endif /* __AKANTU_AKA_GRID_HH__ */ diff --git a/src/common/aka_grid_tmpl.hh b/src/common/aka_grid_tmpl.hh deleted file mode 100644 index 037b3adf9..000000000 --- a/src/common/aka_grid_tmpl.hh +++ /dev/null @@ -1,413 +0,0 @@ -/** - * @file aka_grid_tmpl.hh - * - * @author Nicolas Richart - * - * @date Wed Aug 31 11:09:48 2011 - * - * @brief implementation of template functions of the RegularGrid class - * - * @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 . - * - */ - -/* -------------------------------------------------------------------------- */ - -/* -------------------------------------------------------------------------- */ -template -RegularGrid::RegularGrid(UInt dimension, Real * lower_bounds, - Real * upper_bounds, Real * spacing) : dimension(dimension) { - - // UInt total_nb_cells = 1; - total_nb_cells = 1; - this->dimension = dimension; - - std::fill_n(this->upper_bounds, 3, 0); - std::fill_n(this->lower_bounds, 3, 0); - std::fill_n(this->spacing, 3, 0); - std::fill_n(this->nb_cells, 3, 0); - - for (UInt i = 0; i < dimension; ++i) { - // +2 to add an extra cell on each side - - this->nb_cells[i] = UInt(std::ceil((upper_bounds[i] - lower_bounds[i]) / spacing[i])) + 2; - this->lower_bounds[i] = lower_bounds[i] - spacing[i]; - this->upper_bounds[i] = this->lower_bounds[i] + this->nb_cells[i] * spacing[i]; - - this->spacing[i] = spacing[i]; - - total_nb_cells *= this->nb_cells[i]; - } - this->data.resize(total_nb_cells); -} - - -/* -------------------------------------------------------------------------- */ -template -class RegularGrid::Cell { -public: - Cell() { - id = 0; - position[0] = position[1] = position[2] = 0; - grid = NULL; - } - - Cell(const RegularGrid & grid) : grid(&grid) { id = 0; std::fill_n(position, 3, 0); } - - Cell(const Cell & cell) { - if(&cell != this) { - id = cell.id; - position[0] = cell.position[0]; - position[1] = cell.position[1]; - position[2] = cell.position[2]; - grid = cell.grid; - } - } - - Cell & operator=(const Cell & cell) { - if(&cell != this) { - id = cell.id; - position[0] = cell.position[0]; - position[1] = cell.position[1]; - position[2] = cell.position[2]; - grid = cell.grid; - } - return *this; - } - - bool operator==(const Cell & cell) const { return id == cell.id; } - bool operator!=(const Cell & cell) const { return id != cell.id; } - - inline void updateID() { - id = 0; - for (UInt i = grid->getDimension() - 1; i > 0; --i) { - id += position[i]; - id *= grid->getNbCells(i - 1); - } - id += position[0]; - } - - friend class RegularGrid; - friend class GridSynchronizer; -private: - const RegularGrid * grid; - - UInt id; - UInt position[3]; -}; - -/* -------------------------------------------------------------------------- */ -template -inline typename RegularGrid::iterator RegularGrid::beginCell(const typename RegularGrid::Cell & cell) { - return data(cell.id).begin(); -} - -/* -------------------------------------------------------------------------- */ -template -inline typename RegularGrid::iterator RegularGrid::endCell(const typename RegularGrid::Cell cell) { - return data(cell.id).end(); -} - -/* -------------------------------------------------------------------------- */ -template -inline typename RegularGrid::const_iterator RegularGrid::beginCell(const typename RegularGrid::Cell & cell) const { - return data(cell.id).begin(); -} - -/* -------------------------------------------------------------------------- */ -template -inline typename RegularGrid::const_iterator RegularGrid::endCell(const typename RegularGrid::Cell & cell) const { - return data(cell.id).end(); -} - - -/* -------------------------------------------------------------------------- */ -template -void RegularGrid::insert(const T & d, const Vector & position) { - Cell cell = getCell(position); - UInt num_cell = cell.id; - AKANTU_DEBUG_ASSERT(num_cell < total_nb_cells, - "The position of " << d << " is not in the grid (" << num_cell - << " > " << total_nb_cells << ") [" - << cell.position[0] << ", " << cell.position[1] << ", "<< cell.position[2] << "] : " - << position << " -- grid info " << *this); - data(num_cell).push_back(d); -} - -// /* -------------------------------------------------------------------------- */ -// template -// void RegularGrid::count(const Vector & position) { -// Cell cell = getCell(position); -// UInt num_cell = cell.id; -// // std::cout << num_cell << " - " -// // << cell.position[0] << ", " << cell.position[1] << ", " << cell.position[2] << " : " -// // << position[0] << ", " << position[1] << ", " << position[2] -// // << std::endl; -// data.rowOffset(num_cell)++; -// } - -/* -------------------------------------------------------------------------- */ -template -inline typename RegularGrid::Cell RegularGrid::getCell(const Vector & position) const { - Cell cell(*this); - for (UInt i = 0; i < dimension; ++i) { - cell.position[i] = getCell(position(i), i); - } - - cell.updateID(); - - return cell; -} - -/* -------------------------------------------------------------------------- */ -template -inline UInt RegularGrid::getCell(Real position, UInt direction) const { - return UInt(std::floor((position - lower_bounds[direction]) / spacing[direction])); -} - -/* -------------------------------------------------------------------------- */ -template -struct RegularGrid::neighbor_cells_iterator : private std::iterator { - neighbor_cells_iterator(const RegularGrid & grid, - const Cell & cell, - bool end) : cell(cell), grid(grid) { - std::fill_n(position_start, 3, -1); - std::fill_n(position_end , 3, 1); - - for (UInt i = 0; i < 3; ++i) { - if((grid.getNbCells(i) == 0) || // no cells in this direction - (cell.position[i] == 0)) // first cell in this direction - position_start[i] = 0; - - if((grid.getNbCells(i) == 0) || // no cells in this direction - (cell.position[i] == grid.getNbCells(i) - 1)) // last cell in this direction - position_end[i] = 0; - position[i] = end ? position_end[i] : position_start[i]; - } - - updateIt(); - if(end) { (this->it)++; } - }; - - neighbor_cells_iterator(const neighbor_cells_iterator & it) : cell(it.cell), - it(it.it), - grid(it.grid) { - std::copy(it.position , it.position + 3, position ); - std::copy(it.position_start, it.position_start + 3, position_start); - std::copy(it.position_end , it.position_end + 3, position_end ); - }; - - neighbor_cells_iterator& operator++() { - bool last = false; - if(position[0] < position_end[0]) { - position[0]++; - } else { - position[0] = position_start[0]; - if(position[1] < position_end[1]) { - position[1]++; - } else { - position[1] = position_start[1]; - if(position[2] < position_end[2]) { - position[2]++; - } else { - last = true; - } - } - } - - if(last) ++it; - else { - updateIt(); - } - return *this; - }; - - neighbor_cells_iterator operator++(int) { neighbor_cells_iterator tmp(*this); operator++(); return tmp; }; - bool operator==(const neighbor_cells_iterator& rhs) { return cell == rhs.cell && it = rhs.it; }; - bool operator!=(const neighbor_cells_iterator& rhs) { return cell != rhs.cell || it != rhs.it; }; - - Cell operator*() { - Cell cur_cell(grid); - for (UInt i = 0; i < 3; ++i) cur_cell.position[i] = cell.position[i] + position[i]; - cur_cell.updateID(); - return cur_cell; - }; - -private: - void updateIt() { - it = 0; - for (UInt i = 0; i < 3; ++i) it = it * 3 + (position[i] + 1); - } - -private: - // UInt cur_cell; //current position of the iterator - const Cell & cell; //central cell - UInt it; // number representing the current neighbor in base 3; - - Int position_start[3], position_end[3], position[3]; - - const RegularGrid & grid; -}; - -/* -------------------------------------------------------------------------- */ -template -inline typename RegularGrid::neighbor_cells_iterator RegularGrid::beginNeighborCells(const typename RegularGrid::Cell & cell) { - return neighbor_cells_iterator(*this, cell, false); -} - -template -inline typename RegularGrid::neighbor_cells_iterator RegularGrid::endNeighborCells(const typename RegularGrid::Cell & cell) { - return neighbor_cells_iterator(*this, cell, true); -} - - -/* -------------------------------------------------------------------------- */ -template -void RegularGrid::printself(std::ostream & stream, int indent) const { - std::string space; - for(Int i = 0; i < indent; i++, space += AKANTU_INDENT); - - std::streamsize prec = stream.precision(); - std::ios_base::fmtflags ff = stream.flags(); - - stream.setf (std::ios_base::showbase); - stream.precision(5); - - - stream << space << "RegularGrid<" << debug::demangle(typeid(T).name()) << "> [" << std::endl; - stream << space << " + dimension : " << this->dimension << std::endl; - stream << space << " + lower_bounds : {" - << this->lower_bounds[0] << ", " - << this->lower_bounds[1] << ", " - << this->lower_bounds[2] << "}" << std::endl; - stream << space << " + upper_bounds : {" - << this->upper_bounds[0] << ", " - << this->upper_bounds[1] << ", " - << this->upper_bounds[2] << "}" << std::endl; - stream << space << " + spacing : {" - << this->spacing[0] << ", " - << this->spacing[1] << ", " - << this->spacing[2] << "}" << std::endl; - stream << space << " + nb_cells : " << this->total_nb_cells << " - {" - << this->nb_cells[0] << ", " - << this->nb_cells[1] << ", " - << this->nb_cells[2] << "}" << std::endl; - stream << space << "]" << std::endl; - - stream.precision(prec); - stream.flags(ff); - -} - - -/* -------------------------------------------------------------------------- */ -__END_AKANTU__ - -#include "mesh.hh" - -__BEGIN_AKANTU__ - -template -void RegularGrid::saveAsMesh(Mesh & mesh) const { - Array & nodes = const_cast &>(mesh.getNodes()); - UInt nb_nodes = 1; - - - for (UInt i = 0; i < dimension; ++i) { - nb_nodes *= (nb_cells[i] + 1); - } - nodes.resize(nb_nodes); - - if(dimension == 1) { - for (UInt n = 0; n < nb_nodes; ++n) { - nodes(n, 0) = n * spacing[0] + lower_bounds[0]; - } - - mesh.addConnectivityType(_segment_2); - Array & connectivity = const_cast &>(mesh.getConnectivity(_segment_2)); - connectivity.resize(total_nb_cells); - - for (UInt e = 0; e < nb_cells[0]; ++e) { - connectivity(e, 0) = e; - connectivity(e, 1) = e + 1; - } - } - - if(dimension == 2) { - UInt nnx = nb_cells[0] + 1; - UInt nny = nb_cells[1] + 1; - - for (UInt nx = 0; nx < nnx; ++nx) { - for (UInt ny = 0; ny < nny; ++ny) { - UInt n = nx * nny + ny; - nodes(n, 0) = nx * spacing[0] + lower_bounds[0]; - nodes(n, 1) = ny * spacing[1] + lower_bounds[1]; - } - } - - mesh.addConnectivityType(_quadrangle_4); - Array & connectivity = const_cast &>(mesh.getConnectivity(_quadrangle_4)); - connectivity.resize(total_nb_cells); - for (UInt ex = 0; ex < nb_cells[0]; ++ex) { - for (UInt ey = 0; ey < nb_cells[1]; ++ey) { - UInt e = (ex * nb_cells[1] + ey); - connectivity(e, 0) = ex * nny + ey; - connectivity(e, 1) = (ex + 1) * nny + ey; - connectivity(e, 2) = (ex + 1) * nny + ey + 1; - connectivity(e, 3) = ex * nny + ey + 1; - } - } - } - - if(dimension == 3) { - UInt nnx = nb_cells[0] + 1; - UInt nny = nb_cells[1] + 1; - UInt nnz = nb_cells[2] + 1; - - for (UInt nx = 0; nx < nnx; ++nx) { - for (UInt ny = 0; ny < nny; ++ny) { - for (UInt nz = 0; nz < nnz; ++nz) { - UInt n = (nx * nny + ny) * nnz + nz; - nodes(n, 0) = nx * spacing[0] + lower_bounds[0]; - nodes(n, 1) = ny * spacing[1] + lower_bounds[1]; - nodes(n, 2) = nz * spacing[2] + lower_bounds[2]; - } - } - } - - mesh.addConnectivityType(_hexahedron_8); - Array & connectivity = const_cast &>(mesh.getConnectivity(_hexahedron_8)); - connectivity.resize(total_nb_cells); - for (UInt ex = 0; ex < nb_cells[0]; ++ex) { - for (UInt ey = 0; ey < nb_cells[1]; ++ey) { - for (UInt ez = 0; ez < nb_cells[2]; ++ez) { - UInt e = (ex * nb_cells[1] + ey) * nb_cells[2] + ez; - connectivity(e, 0) = (ex * nny + ey ) * nnz + ez; - connectivity(e, 1) = ((ex+1) * nny + ey ) * nnz + ez; - connectivity(e, 2) = ((ex+1) * nny + ey+1) * nnz + ez; - connectivity(e, 3) = (ex * nny + ey+1) * nnz + ez; - connectivity(e, 4) = (ex * nny + ey ) * nnz + ez+1; - connectivity(e, 5) = ((ex+1) * nny + ey ) * nnz + ez+1; - connectivity(e, 6) = ((ex+1) * nny + ey+1) * nnz + ez+1; - connectivity(e, 7) = (ex * nny + ey+1) * nnz + ez+1; - } - } - } - } -} diff --git a/src/fem/mesh.hh b/src/fem/mesh.hh index 45e4993e3..2403c3f0f 100644 --- a/src/fem/mesh.hh +++ b/src/fem/mesh.hh @@ -1,668 +1,668 @@ /** * @file mesh.hh * * @author Guillaume Anciaux * @author Marco Vocialta * @author Nicolas Richart * @author Dana Christen * @author David Kammer * * @date Fri Jun 18 11:47:19 2010 * * @brief the class representing the meshes * * @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 . * */ /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_MESH_HH__ #define __AKANTU_MESH_HH__ /* -------------------------------------------------------------------------- */ #include "aka_config.hh" #include "aka_common.hh" #include "aka_memory.hh" #include "aka_array.hh" #include "element_class.hh" #include "by_element_type.hh" -#include "aka_event_handler.hh" +#include "aka_event_handler_manager.hh" #include "group_manager.hh" /* -------------------------------------------------------------------------- */ #include /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ /* Element */ /* -------------------------------------------------------------------------- */ class Element; extern const Element ElementNull; class Element { public: Element(ElementType type = _not_defined, UInt element = 0, GhostType ghost_type = _not_ghost, ElementKind kind = _ek_regular) : type(type), element(element), ghost_type(ghost_type), kind(kind) {}; Element(const Element & element) { this->type = element.type; this->element = element.element; this->ghost_type = element.ghost_type; this->kind = element.kind; } inline bool operator==(const Element & elem) const { return ((element == elem.element) && (type == elem.type) && (ghost_type == elem.ghost_type) && (kind == elem.kind)); } inline bool operator!=(const Element & elem) const { return ((element != elem.element) || (type != elem.type) || (ghost_type != elem.ghost_type) || (kind != elem.kind)); } bool operator<(const Element& rhs) const { bool res = (rhs == ElementNull) || ((this->kind < rhs.kind) || ((this->kind == rhs.kind) && ((this->ghost_type < rhs.ghost_type) || ((this->ghost_type == rhs.ghost_type) && ((this->type < rhs.type) || ((this->type == rhs.type) && (this->element < rhs.element))))))); return res; } virtual ~Element() {}; /// function to print the containt of the class virtual void printself(std::ostream & stream, int indent = 0) const; public: ElementType type; UInt element; GhostType ghost_type; ElementKind kind; }; struct CompElementLess { bool operator() (const Element& lhs, const Element& rhs) const { return lhs < rhs; } }; __END_AKANTU__ #include "mesh_data.hh" __BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ /* Mesh modifications events */ /* -------------------------------------------------------------------------- */ template class MeshEvent { public: virtual ~MeshEvent() {} const Array & getList() const { return list; } Array & getList() { return list; } protected: Array list; }; class Mesh; class NewNodesEvent : public MeshEvent { public: virtual ~NewNodesEvent() {}; }; class RemovedNodesEvent : public MeshEvent { public: virtual ~RemovedNodesEvent() {}; inline RemovedNodesEvent(const Mesh & mesh); AKANTU_GET_MACRO_NOT_CONST(NewNumbering, new_numbering, Array &); AKANTU_GET_MACRO(NewNumbering, new_numbering, const Array &); private: Array new_numbering; }; class NewElementsEvent : public MeshEvent { public: virtual ~NewElementsEvent() {}; }; class RemovedElementsEvent : public MeshEvent { public: virtual ~RemovedElementsEvent() {}; inline RemovedElementsEvent(const Mesh & mesh); AKANTU_GET_MACRO(NewNumbering, new_numbering, const ByElementTypeUInt &); AKANTU_GET_MACRO_NOT_CONST(NewNumbering, new_numbering, ByElementTypeUInt &); AKANTU_GET_MACRO_BY_ELEMENT_TYPE(NewNumbering, new_numbering, UInt); AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(NewNumbering, new_numbering, UInt); protected: ByElementTypeUInt new_numbering; }; /* -------------------------------------------------------------------------- */ class MeshEventHandler { public: virtual ~MeshEventHandler() {}; /* ------------------------------------------------------------------------ */ /* Internal code */ /* ------------------------------------------------------------------------ */ private: inline void sendEvent(const NewNodesEvent & event) { onNodesAdded (event.getList(), event); } inline void sendEvent(const RemovedNodesEvent & event) { onNodesRemoved(event.getList(), event.getNewNumbering(), event); } inline void sendEvent(const NewElementsEvent & event) { onElementsAdded (event.getList(), event); } inline void sendEvent(const RemovedElementsEvent & event) { onElementsRemoved(event.getList(), event.getNewNumbering(), event); } template friend class EventHandlerManager; /* ------------------------------------------------------------------------ */ /* Interface */ /* ------------------------------------------------------------------------ */ public: virtual void onNodesAdded (__attribute__((unused)) const Array & nodes_list, __attribute__((unused)) const NewNodesEvent & event) { } virtual void onNodesRemoved(__attribute__((unused)) const Array & nodes_list, __attribute__((unused)) const Array & new_numbering, __attribute__((unused)) const RemovedNodesEvent & event) { } virtual void onElementsAdded (__attribute__((unused)) const Array & elements_list, __attribute__((unused)) const NewElementsEvent & event) { } virtual void onElementsRemoved(__attribute__((unused)) const Array & elements_list, __attribute__((unused)) const ByElementTypeUInt & new_numbering, __attribute__((unused)) const RemovedElementsEvent & event) { } }; /* -------------------------------------------------------------------------- */ /* Mesh */ /* -------------------------------------------------------------------------- */ /** * @class Mesh this contain the coordinates of the nodes in the Mesh.nodes * Array, and the connectivity. The connectivity are stored in by element * types. * * To know all the element types present in a mesh you can get the * Mesh::ConnectivityTypeList * * In order to loop on all element you have to loop on all types like this : * @code{.cpp} Mesh::type_iterator it = mesh.firstType(dim, ghost_type); Mesh::type_iterator end = mesh.lastType(dim, ghost_type); for(; it != end; ++it) { UInt nb_element = mesh.getNbElement(*it); const Array & conn = mesh.getConnectivity(*it); for(UInt e = 0; e < nb_element; ++e) { ... } } @endcode */ class Mesh : protected Memory, public EventHandlerManager, public GroupManager { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: /// constructor that create nodes coordinates array Mesh(UInt spatial_dimension, const ID & id = "mesh", const MemoryID & memory_id = 0); /// constructor that use an existing nodes coordinates array, by knowing its ID Mesh(UInt spatial_dimension, const ID & nodes_id, const ID & id, const MemoryID & memory_id = 0); /** * constructor that use an existing nodes coordinates * array, by getting the vector of coordinates */ Mesh(UInt spatial_dimension, Array & nodes, const ID & id = "mesh", const MemoryID & memory_id = 0); virtual ~Mesh(); /// @typedef ConnectivityTypeList list of the types present in a Mesh typedef std::set ConnectivityTypeList; /// read the mesh from a file void read (const std::string & filename, const MeshIOType & mesh_io_type = _miot_auto); /// write the mesh to a file void write(const std::string & filename, const MeshIOType & mesh_io_type = _miot_auto); private: /// initialize the connectivity to NULL and other stuff void init(); /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// function to print the containt of the class virtual void printself(std::ostream & stream, int indent = 0) const; /// function that computes the bounding box (fills xmin, xmax) void computeBoundingBox(); #ifdef AKANTU_CORE_CXX11 /// translate the mesh by the given amount in x[, y[, z]] directions template void translate(Args... params); #endif /// init a by-element-type real vector with provided ids template void initByElementTypeArray(ByElementTypeArray & v, UInt nb_component, UInt spatial_dimension, const bool & flag_nb_node_per_elem_multiply = false, ElementKind element_kind = _ek_regular, bool size_to_nb_element = false) const; /// @todo: think about nicer way to do it template void initByElementTypeArray(ByElementTypeArray & v, UInt nb_component, UInt spatial_dimension, GhostType ghost_type, const bool & flag_nb_node_per_elem_multiply = false, ElementKind element_kind = _ek_regular, bool size_to_nb_element = false) const; /// @todo: think about nicer way to do it /// extract coordinates of nodes from an element template inline void extractNodalValuesFromElement(const Array & nodal_values, T * elemental_values, UInt * connectivity, UInt n_nodes, UInt nb_degree_of_freedom) const; /// extract coordinates of nodes from a reversed element inline void extractNodalCoordinatesFromPBCElement(Real * local_coords, UInt * connectivity, UInt n_nodes); /// convert a element to a linearized element inline UInt elementToLinearized(const Element & elem) const; /// convert a linearized element to an element inline Element linearizedToElement (UInt linearized_element) const; /// update the types offsets array for the conversions inline void updateTypesOffsets(const GhostType & ghost_type); /// add a Array of connectivity for the type . inline void addConnectivityType(const ElementType & type, const GhostType & ghost_type = _not_ghost); /* ------------------------------------------------------------------------ */ template inline void sendEvent(Event & event) { // if(event.getList().getSize() != 0) EventHandlerManager::sendEvent(event); } /* ------------------------------------------------------------------------ */ template inline void removeNodesFromArray(Array & vect, const Array & new_numbering); /// initialize normals void initNormals(); /// init facets' mesh Mesh & initMeshFacets(const ID & id = "mesh_facets"); /// define parent mesh void defineMeshParent(const Mesh & mesh); /// get global connectivity array void getGlobalConnectivity(ByElementTypeUInt & global_connectivity, UInt dimension, GhostType ghost_type); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: /// get the id of the mesh AKANTU_GET_MACRO(ID, Memory::id, const ID &); /// get the spatial dimension of the mesh = number of component of the coordinates AKANTU_GET_MACRO(SpatialDimension, spatial_dimension, UInt); /// get the nodes Array aka coordinates AKANTU_GET_MACRO(Nodes, *nodes, const Array &); AKANTU_GET_MACRO_NOT_CONST(Nodes, *nodes, Array &); /// get the normals for the elements AKANTU_GET_MACRO_BY_ELEMENT_TYPE(Normals, normals, Real); /// get the number of nodes AKANTU_GET_MACRO(NbNodes, nodes->getSize(), UInt); /// get the Array of global ids of the nodes (only used in parallel) AKANTU_GET_MACRO(GlobalNodesIds, *nodes_global_ids, const Array &); /// get the global id of a node inline UInt getNodeGlobalId(UInt local_id) const; /// get the global number of nodes inline UInt getNbGlobalNodes() const; /// get the nodes type Array AKANTU_GET_MACRO(NodesType, nodes_type, const Array &); protected: AKANTU_GET_MACRO_NOT_CONST(NodesType, nodes_type, Array &); public: inline Int getNodeType(UInt local_id) const; /// say if a node is a pure ghost node inline bool isPureGhostNode(UInt n) const; /// say if a node is pur local or master node inline bool isLocalOrMasterNode(UInt n) const; inline bool isLocalNode(UInt n) const; inline bool isMasterNode(UInt n) const; inline bool isSlaveNode(UInt n) const; AKANTU_GET_MACRO(XMin, lower_bounds[0], Real); AKANTU_GET_MACRO(YMin, lower_bounds[1], Real); AKANTU_GET_MACRO(ZMin, lower_bounds[2], Real); AKANTU_GET_MACRO(XMax, upper_bounds[0], Real); AKANTU_GET_MACRO(YMax, upper_bounds[1], Real); AKANTU_GET_MACRO(ZMax, upper_bounds[2], Real); inline void getLowerBounds(Real * lower) const; inline void getUpperBounds(Real * upper) const; inline void getLocalLowerBounds(Real * lower) const; inline void getLocalUpperBounds(Real * upper) const; /// get the connectivity Array for a given type AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(Connectivity, connectivities, UInt); AKANTU_GET_MACRO_BY_ELEMENT_TYPE(Connectivity, connectivities, UInt); AKANTU_GET_MACRO(Connectivities, connectivities, const ByElementTypeArray &); /// get the number of element of a type in the mesh inline UInt getNbElement(const ElementType & type, const GhostType & ghost_type = _not_ghost) const; /// get the number of element for a given ghost_type and a given dimension inline UInt getNbElement(const UInt spatial_dimension = _all_dimensions, const GhostType & ghost_type = _not_ghost, const ElementKind & kind = _ek_not_defined) const; /// get the connectivity list either for the elements or the ghost elements inline const ConnectivityTypeList & getConnectivityTypeList(const GhostType & ghost_type = _not_ghost) const; /// compute the barycenter of a given element inline void getBarycenter(UInt element, const ElementType & type, Real * barycenter, GhostType ghost_type = _not_ghost) const; inline void getBarycenter(const Element & element, Vector & barycenter) const; /// get the element connected to a subelement const Array< std::vector > & getElementToSubelement(const ElementType & el_type, const GhostType & ghost_type = _not_ghost) const; /// get the element connected to a subelement Array< std::vector > & getElementToSubelement(const ElementType & el_type, const GhostType & ghost_type = _not_ghost); /// get the subelement connected to an element const Array & getSubelementToElement(const ElementType & el_type, const GhostType & ghost_type = _not_ghost) const; /// get the subelement connected to an element Array & getSubelementToElement(const ElementType & el_type, const GhostType & ghost_type = _not_ghost); /// get a name field associated to the mesh template inline const Array & getData(const std::string & data_name, const ElementType & el_type, const GhostType & ghost_type = _not_ghost) const; /// get a name field associated to the mesh template inline Array & getData(const std::string & data_name, const ElementType & el_type, const GhostType & ghost_type = _not_ghost); /// get a name field associated to the mesh template inline const ByElementTypeArray & getData(const std::string & data_name) const; /// get a name field associated to the mesh template inline ByElementTypeArray & getData(const std::string & data_name); /// templated getter returning the pointer to data in MeshData (modifiable) template inline Array * getDataPointer(const std::string & data_name, const ElementType & el_type, const GhostType & ghost_type = _not_ghost, UInt nb_component = 1, bool size_to_nb_element = true, bool resize_with_parent = false); /// Facets mesh accessor AKANTU_GET_MACRO(MeshFacets, *mesh_facets, const Mesh &); AKANTU_GET_MACRO_NOT_CONST(MeshFacets, *mesh_facets, Mesh &); /// Parent mesh accessor AKANTU_GET_MACRO(MeshParent, *mesh_parent, const Mesh &); inline bool isMeshFacets() const {return is_mesh_facets;} /* ------------------------------------------------------------------------ */ /* Wrappers on ElementClass functions */ /* ------------------------------------------------------------------------ */ public: /// get the number of nodes per element for a given element type static inline UInt getNbNodesPerElement(const ElementType & type); /// get the number of nodes per element for a given element type considered as /// a first order element static inline ElementType getP1ElementType(const ElementType & type); /// get the kind of the element type static inline ElementKind getKind(const ElementType & type); /// get spatial dimension of a type of element static inline UInt getSpatialDimension(const ElementType & type); /// get number of facets of a given element type static inline UInt getNbFacetsPerElement(const ElementType & type); /// get local connectivity of a facet for a given facet type static inline MatrixProxy getFacetLocalConnectivity(const ElementType & type); /// get connectivity of facets for a given element inline Matrix getFacetConnectivity(UInt element, const ElementType & type, const GhostType & ghost_type) const; /// get the type of the surface element associated to a given element static inline ElementType getFacetType(const ElementType & type); /* ------------------------------------------------------------------------ */ /* Element type Iterator */ /* ------------------------------------------------------------------------ */ typedef ByElementTypeArray::type_iterator type_iterator; inline type_iterator firstType(UInt dim = _all_dimensions, GhostType ghost_type = _not_ghost, ElementKind kind = _ek_regular) const { return connectivities.firstType(dim, ghost_type, kind); } inline type_iterator lastType(UInt dim = _all_dimensions, GhostType ghost_type = _not_ghost, ElementKind kind = _ek_regular) const { return connectivities.lastType(dim, ghost_type, kind); } /* ------------------------------------------------------------------------ */ /* Private methods for friends */ /* ------------------------------------------------------------------------ */ private: friend class MeshIOMSH; friend class MeshIOMSHStruct; friend class MeshIODiana; friend class MeshUtils; friend class DistributedSynchronizer; template friend class SpatialGrid; #if defined(AKANTU_COHESIVE_ELEMENT) friend class CohesiveElementInserter; #endif AKANTU_GET_MACRO(NodesPointer, nodes, Array *); /// get a pointer to the nodes_global_ids Array and create it if necessary inline Array * getNodesGlobalIdsPointer(); /// get a pointer to the nodes_type Array and create it if necessary inline Array * getNodesTypePointer(); /// get a pointer to the connectivity Array for the given type and create it if necessary inline Array * getConnectivityPointer(const ElementType & type, const GhostType & ghost_type = _not_ghost); /// get a pointer to the element_to_subelement Array for the given type and create it if necessary inline Array< std::vector > * getElementToSubelementPointer(const ElementType & type, const GhostType & ghost_type = _not_ghost); /// get a pointer to the subelement_to_element Array for the given type and create it if necessary inline Array * getSubelementToElementPointer(const ElementType & type, const GhostType & ghost_type = _not_ghost); AKANTU_GET_MACRO_NOT_CONST(MeshData, mesh_data, MeshData &); /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// array of the nodes coordinates Array * nodes; /// global node ids Array * nodes_global_ids; /// node type, -3 pure ghost, -2 master for the node, -1 normal node, i in /// [0-N] slave node and master is proc i Array nodes_type; /// global number of nodes; UInt nb_global_nodes; /// boolean to know if the nodes have to be deleted with the mesh or not bool created_nodes; /// all class of elements present in this mesh (for heterogenous meshes) ByElementTypeUInt connectivities; /// map to normals for all class of elements present in this mesh ByElementTypeReal normals; /// list of all existing types in the mesh ConnectivityTypeList type_set; /// the spatial dimension of this mesh UInt spatial_dimension; /// types offsets Array types_offsets; /// list of all existing types in the mesh ConnectivityTypeList ghost_type_set; /// ghost types offsets Array ghost_types_offsets; /// min of coordinates Real lower_bounds[3]; /// max of coordinates Real upper_bounds[3]; /// size covered by the mesh on each direction Real size[3]; /// local min of coordinates Real local_lower_bounds[3]; /// local max of coordinates Real local_upper_bounds[3]; /// Extra data loaded from the mesh file MeshData mesh_data; /// facets' mesh Mesh * mesh_facets; /// parent mesh (this is set for mesh_facets meshes) const Mesh * mesh_parent; /// defines if current mesh is mesh_facets or not bool is_mesh_facets; }; /* -------------------------------------------------------------------------- */ /* Inline functions */ /* -------------------------------------------------------------------------- */ /// standard output stream operator inline std::ostream & operator <<(std::ostream & stream, const Element & _this) { _this.printself(stream); return stream; } #include "mesh_inline_impl.cc" #include "by_element_type_tmpl.hh" /// standard output stream operator inline std::ostream & operator <<(std::ostream & stream, const Mesh & _this) { _this.printself(stream); return stream; } __END_AKANTU__ #endif /* __AKANTU_MESH_HH__ */ diff --git a/src/model/solid_mechanics/contact/friction_coefficient/historic_velocity_fric_coef.hh b/src/model/solid_mechanics/contact/friction_coefficient/historic_velocity_fric_coef.hh index 5fae49df3..5cabd163d 100644 --- a/src/model/solid_mechanics/contact/friction_coefficient/historic_velocity_fric_coef.hh +++ b/src/model/solid_mechanics/contact/friction_coefficient/historic_velocity_fric_coef.hh @@ -1,139 +1,139 @@ /** * @file historic_velocity_fric_coef.hh * * @author David Simon Kammer * * @date Fri Nov 11 16:56:08 2011 * * @brief friction coefficient that depends on the historic of velocity * * @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 . * */ /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_HISTORIC_VELOCITY_FRIC_COEF_HH__ #define __AKANTU_HISTORIC_VELOCITY_FRIC_COEF_HH__ /* -------------------------------------------------------------------------- */ #include "aka_common.hh" -#include "aka_circular_vector.hh" +#include "aka_circular_array.hh" #include "contact_rigid.hh" #include "friction_coefficient.hh" __BEGIN_AKANTU__ class HistoricVelocityFricCoef : public virtual FrictionCoefficient { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: /// \warning DO NOT USE THIS CLASS !!! HistoricVelocityFricCoef(ContactRigid & contact, const Surface & master_surface, const Real beta); // constructur when this class is not used HistoricVelocityFricCoef(ContactRigid & contact, const Surface & master_surface); virtual ~HistoricVelocityFricCoef(); /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// compute the history of relative sliding velocity virtual void initializeComputeFricCoef(); /// implementation of the friction coefficient formula virtual Real computeFricCoef(UInt impactor_node_index) = 0; // virtual Real computeFricCoef(UInt impactor_node_index) { return 0.;}; // for testing /// function to print the contain of the class //virtual void printself(std::ostream & stream, int indent = 0) const; private: // computes the tangential velocity of the master element void computeTangentialMasterVelocity(UInt impactor_index, ContactRigid::ImpactorInformationPerMaster * impactor_info, Real * tangential_master_velocity); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: /// spatial dimension of contact UInt spatial_dimension; protected: /// weight parameter Real beta; /// weights Array * weights; /// history of sliding velocities CircularArray< Array * > * historic_velocities; /// order of information Array nodes; /// if node is active in this time step Array active; /// time since node came in contact Array contact_time; /// keep information about stick status of active impactor node Array * node_stick_status; //public: // for testing /// relative sliding velocities for each active impactor node Array * generalized_sliding_velocities; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ //#include "historic_velocity_fric_coef_inline_impl.cc" /* /// standard output stream operator inline std::ostream & operator <<(std::ostream & stream, const HistoricVelocityFricCoef & _this) { _this.printself(stream); return stream; } */ __END_AKANTU__ #endif /* __AKANTU_HISTORIC_VELOCITY_FRIC_COEF_HH__ */ diff --git a/src/model/solid_mechanics/materials/material_non_local.hh b/src/model/solid_mechanics/materials/material_non_local.hh index 975572807..7e27b46c0 100644 --- a/src/model/solid_mechanics/materials/material_non_local.hh +++ b/src/model/solid_mechanics/materials/material_non_local.hh @@ -1,180 +1,179 @@ /** * @file material_non_local.hh * * @author Nicolas Richart * * @date Wed Aug 31 11:09:48 2011 * * @brief Material class that handle the non locality of a law for example damage. * * @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 "aka_common.hh" #include "material.hh" -#include "aka_grid.hh" #include "aka_grid_dynamic.hh" #include "fem.hh" #include "weight_function.hh" namespace akantu { class GridSynchronizer; } /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_MATERIAL_NON_LOCAL_HH__ #define __AKANTU_MATERIAL_NON_LOCAL_HH__ __BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ template class WeightFunction = BaseWeightFunction> class MaterialNonLocal : public virtual Material { /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ public: MaterialNonLocal(SolidMechanicsModel & model, const ID & id = ""); virtual ~MaterialNonLocal(); template class PairList : public ByElementType< ByElementTypeArray > {}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /// initialize the material computed parameter virtual void initMaterial(); virtual void updateResidual(GhostType ghost_type); virtual void computeAllNonLocalStresses(GhostType ghost_type = _not_ghost); void savePairs(const std::string & filename) const; void neighbourhoodStatistics(const std::string & filename) const; protected: void updatePairList(const ByElementTypeReal & quadrature_points_coordinates); void computeWeights(const ByElementTypeReal & quadrature_points_coordinates); void createCellList(ByElementTypeReal & quadrature_points_coordinates); void cleanupExtraGhostElement(const ByElementType & nb_ghost_protected); void fillCellList(const ByElementTypeReal & quadrature_points_coordinates, const GhostType & ghost_type); /// constitutive law virtual void computeNonLocalStresses(GhostType ghost_type = _not_ghost) = 0; template void weightedAvergageOnNeighbours(const ByElementTypeArray & to_accumulate, ByElementTypeArray & accumulated, UInt nb_degree_of_freedom, GhostType ghost_type2 = _not_ghost) const; virtual inline UInt getNbDataForElements(const Array & elements, SynchronizationTag tag) const; virtual inline void packElementData(CommunicationBuffer & buffer, const Array & elements, SynchronizationTag tag) const; virtual inline void unpackElementData(CommunicationBuffer & buffer, const Array & elements, SynchronizationTag tag); // virtual inline void onElementsAdded(const Array & element_list); virtual inline void onElementsRemoved(const Array & element_list, const ByElementTypeUInt & new_numbering, const RemovedElementsEvent & event); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: void registerNonLocalVariable(InternalField & local, InternalField & non_local, UInt nb_degree_of_freedom) { ID id = local.getID(); NonLocalVariable & non_local_variable = non_local_variables[id]; non_local_variable.local = &local; non_local_variable.non_local = &non_local; non_local_variable.nb_component = nb_degree_of_freedom; } AKANTU_GET_MACRO(PairList, pair_list, const PairList &) Real getRadius() const { return weight_func->getRadius(); } AKANTU_GET_MACRO(CellList, *spatial_grid, const SpatialGrid &) /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ protected: /// the weight function used WeightFunction * weight_func; private: /// the pairs of quadrature points PairList pair_list; /// the weights associated to the pairs PairList pair_weight; /// the regular grid to construct/update the pair lists SpatialGrid * spatial_grid; /// the types of the existing pairs typedef std::set< std::pair > pair_type; pair_type existing_pairs[2]; /// count the number of calls of computeStress UInt compute_stress_calls; struct NonLocalVariable { InternalField * local; InternalField * non_local; UInt nb_component; }; std::map non_local_variables; bool is_creating_grid; GridSynchronizer * grid_synchronizer; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ #include "material_non_local_inline_impl.cc" __END_AKANTU__ #endif /* __AKANTU_MATERIAL_NON_LOCAL_HH__ */ diff --git a/src/model/solid_mechanics/solid_mechanics_model_material.cc b/src/model/solid_mechanics/solid_mechanics_model_material.cc index d61a8cfbb..4f4f210dc 100644 --- a/src/model/solid_mechanics/solid_mechanics_model_material.cc +++ b/src/model/solid_mechanics/solid_mechanics_model_material.cc @@ -1,217 +1,218 @@ /** * @file solid_mechanics_model_material.cc * * @author Guillaume Anciaux * @author Nicolas Richart * * @date Fri Nov 26 00:17:56 2010 * * @brief instatiation of materials * * @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 "solid_mechanics_model.hh" #include "material_list.hh" #include "aka_math.hh" /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ #define AKANTU_INTANTIATE_MATERIAL_BY_DIM_NO_TMPL(dim, elem) \ registerNewMaterial< BOOST_PP_ARRAY_ELEM(1, elem)< dim > >(section) #define AKANTU_INTANTIATE_MATERIAL_BY_DIM_TMPL_EACH(r, data, i, elem) \ BOOST_PP_EXPR_IF(BOOST_PP_NOT_EQUAL(0, i), else ) \ if(opt_param == BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2, 0, elem))) { \ registerNewMaterial< BOOST_PP_ARRAY_ELEM(1, data)< BOOST_PP_ARRAY_ELEM(0, data), \ BOOST_PP_SEQ_ENUM(BOOST_PP_TUPLE_ELEM(2, 1, elem)) > >(section); \ } #define AKANTU_INTANTIATE_MATERIAL_BY_DIM_TMPL(dim, elem) \ BOOST_PP_SEQ_FOR_EACH_I(AKANTU_INTANTIATE_MATERIAL_BY_DIM_TMPL_EACH, \ (2, (dim, BOOST_PP_ARRAY_ELEM(1, elem))), \ BOOST_PP_ARRAY_ELEM(2, elem)) \ else { \ AKANTU_INTANTIATE_MATERIAL_BY_DIM_NO_TMPL(dim, elem); \ } #define AKANTU_INTANTIATE_MATERIAL_BY_DIM(dim, elem) \ BOOST_PP_IF(BOOST_PP_EQUAL(3, BOOST_PP_ARRAY_SIZE(elem) ), \ AKANTU_INTANTIATE_MATERIAL_BY_DIM_TMPL, \ AKANTU_INTANTIATE_MATERIAL_BY_DIM_NO_TMPL)(dim, elem) #define AKANTU_INTANTIATE_MATERIAL(elem) \ switch(spatial_dimension) { \ case 1: { AKANTU_INTANTIATE_MATERIAL_BY_DIM(1, elem); break; } \ case 2: { AKANTU_INTANTIATE_MATERIAL_BY_DIM(2, elem); break; } \ case 3: { AKANTU_INTANTIATE_MATERIAL_BY_DIM(3, elem); break; } \ } #define AKANTU_INTANTIATE_MATERIAL_IF(elem) \ if (mat_type == BOOST_PP_STRINGIZE(BOOST_PP_ARRAY_ELEM(0, elem))) { \ AKANTU_INTANTIATE_MATERIAL(elem); \ } #define AKANTU_INTANTIATE_OTHER_MATERIAL(r, data, elem) \ else AKANTU_INTANTIATE_MATERIAL_IF(elem) #define AKANTU_INSTANTIATE_MATERIALS() \ do { \ AKANTU_INTANTIATE_MATERIAL_IF(BOOST_PP_SEQ_HEAD(AKANTU_MATERIAL_LIST)) \ BOOST_PP_SEQ_FOR_EACH(AKANTU_INTANTIATE_OTHER_MATERIAL, \ _, \ BOOST_PP_SEQ_TAIL(AKANTU_MATERIAL_LIST)) \ else { \ if(getStaticParser().isPermissive()) \ AKANTU_DEBUG_INFO("Malformed material file " << \ ": unknown material type '" \ << mat_type << "'"); \ else \ AKANTU_DEBUG_WARNING("Malformed material file " \ <<": unknown material type " << mat_type \ << ". This is perhaps a user" \ << " defined material ?"); \ } \ } while(0) /* -------------------------------------------------------------------------- */ void SolidMechanicsModel::instantiateMaterials() { std::pair sub_sect = getStaticParser().getSubSections(_st_material); Parser::const_section_iterator it = sub_sect.first; for (; it != sub_sect.second; ++it) { const ParserSection & section = *it; std::string mat_type = section.getName(); std::string opt_param = section.getOption(); AKANTU_INSTANTIATE_MATERIALS(); } are_materials_instantiated = true; } /* -------------------------------------------------------------------------- */ void SolidMechanicsModel::initMaterials() { AKANTU_DEBUG_ASSERT(materials.size() != 0, "No material to initialize !"); if(!are_materials_instantiated) instantiateMaterials(); Material ** mat_val = &(materials.at(0)); Element element; element.ghost_type = _not_ghost; Mesh::type_iterator it = mesh.firstType(spatial_dimension, _not_ghost, _ek_not_defined); Mesh::type_iterator end = mesh.lastType(spatial_dimension, _not_ghost, _ek_not_defined); // Fill the element material array from the material selector for(; it != end; ++it) { UInt nb_element = mesh.getNbElement(*it, _not_ghost); element.type = *it; element.kind = mesh.getKind(element.type); Array & el_id_by_mat = element_index_by_material(*it, _not_ghost); for (UInt el = 0; el < nb_element; ++el) { element.element = el; UInt mat_index = (*material_selector)(element); - AKANTU_DEBUG_ASSERT(mat_index < materials.size(), "The material selector returned an index that does not exists"); + AKANTU_DEBUG_ASSERT(mat_index < materials.size(), + "The material selector returned an index that does not exists"); el_id_by_mat(el, 0) = mat_index; } } // synchronize the element material arrays synch_registry->synchronize(_gst_material_id); /// fill the element filters of the materials using the element_material arrays for(UInt g = _not_ghost; g <= _ghost; ++g) { GhostType gt = (GhostType) g; it = mesh.firstType(spatial_dimension, gt, _ek_not_defined); end = mesh.lastType(spatial_dimension, gt, _ek_not_defined); for(; it != end; ++it) { UInt nb_element = mesh.getNbElement(*it, gt); Array & el_id_by_mat = element_index_by_material(*it, gt); for (UInt el = 0; el < nb_element; ++el) { UInt mat_index = el_id_by_mat(el, 0); UInt index = mat_val[mat_index]->addElement(*it, el, gt); el_id_by_mat(el, 1) = index; } } } std::vector::iterator mat_it; for(mat_it = materials.begin(); mat_it != materials.end(); ++mat_it) { /// init internals properties (*mat_it)->initMaterial(); } synch_registry->synchronize(_gst_smm_init_mat); // initialize mass switch(method) { case _explicit_lumped_mass: assembleMassLumped(); break; case _explicit_consistent_mass: case _implicit_dynamic: assembleMass(); break; case _static: break; default: AKANTU_EXCEPTION("analysis method not recognised by SolidMechanicsModel"); break; } // initialize the previous displacement array if at least on material needs it for (mat_it = materials.begin(); mat_it != materials.end(); ++mat_it) { Material & mat = **mat_it; if (mat.isFiniteDeformation() || mat.isInelasticDeformation()) { initArraysPreviousDisplacment(); break; } } } /* -------------------------------------------------------------------------- */ Int SolidMechanicsModel::getInternalIndexFromID(const ID & id) const { AKANTU_DEBUG_IN(); std::vector::const_iterator first = materials.begin(); std::vector::const_iterator last = materials.end(); for (; first != last; ++first) if ((*first)->getID() == id) { AKANTU_DEBUG_OUT(); return (first - materials.begin()); } AKANTU_DEBUG_OUT(); return -1; } __END_AKANTU__ diff --git a/src/synchronizer/static_communicator.hh b/src/synchronizer/static_communicator.hh index 3f76a2c1e..05b582eb5 100644 --- a/src/synchronizer/static_communicator.hh +++ b/src/synchronizer/static_communicator.hh @@ -1,200 +1,200 @@ /** * @file static_communicator.hh * * @author Nicolas Richart * * @date Wed Sep 01 17:57:12 2010 * * @brief Class handling the parallel communications * * @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 . * */ /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_STATIC_COMMUNICATOR_HH__ #define __AKANTU_STATIC_COMMUNICATOR_HH__ /* -------------------------------------------------------------------------- */ #include "aka_common.hh" -#include "aka_event_handler.hh" +#include "aka_event_handler_manager.hh" /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ #define AKANTU_COMMUNICATOR_LIST_0 BOOST_PP_SEQ_NIL #include "static_communicator_dummy.hh" #define AKANTU_COMMUNICATOR_LIST_1 \ BOOST_PP_SEQ_PUSH_BACK(AKANTU_COMMUNICATOR_LIST_0, \ (_communicator_dummy, (StaticCommunicatorDummy, BOOST_PP_NIL))) #if defined(AKANTU_USE_MPI) # include "static_communicator_mpi.hh" # define AKANTU_COMMUNICATOR_LIST_ALL \ BOOST_PP_SEQ_PUSH_BACK(AKANTU_COMMUNICATOR_LIST_1, \ (_communicator_mpi, (StaticCommunicatorMPI, BOOST_PP_NIL))) #else # define AKANTU_COMMUNICATOR_LIST_ALL AKANTU_COMMUNICATOR_LIST_1 #endif // AKANTU_COMMUNICATOR_LIST #include "real_static_communicator.hh" /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ class RealStaticCommunicator; struct FinalizeCommunicatorEvent { FinalizeCommunicatorEvent(const StaticCommunicator & comm) : communicator(comm) {} const StaticCommunicator & communicator; }; class CommunicatorEventHandler { public: virtual ~CommunicatorEventHandler() {} virtual void onCommunicatorFinalize(__attribute__((unused)) const StaticCommunicator & communicator) { } protected: inline void sendEvent(const FinalizeCommunicatorEvent & event) { onCommunicatorFinalize(event.communicator); } template friend class EventHandlerManager; }; class StaticCommunicator : public EventHandlerManager{ /* ------------------------------------------------------------------------ */ /* Constructors/Destructors */ /* ------------------------------------------------------------------------ */ protected: StaticCommunicator(int & argc, char ** & argv, CommunicatorType type = _communicator_mpi); public: virtual ~StaticCommunicator() { FinalizeCommunicatorEvent event(*this); this->sendEvent(event); delete real_static_communicator; }; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: /* ------------------------------------------------------------------------ */ /* Point to Point */ /* ------------------------------------------------------------------------ */ template inline void send(T * buffer, Int size, Int receiver, Int tag); template inline void receive(T * buffer, Int size, Int sender, Int tag); template inline CommunicationRequest * asyncSend(T * buffer, Int size, Int receiver, Int tag); template inline CommunicationRequest * asyncReceive(T * buffer, Int size, Int sender, Int tag); template inline void probe(Int sender, Int tag, CommunicationStatus & status); /* ------------------------------------------------------------------------ */ /* Collectives */ /* ------------------------------------------------------------------------ */ template inline void allReduce(T * values, Int nb_values, const SynchronizerOperation & op); template inline void allGather(T * values, Int nb_values); template inline void allGatherV(T * values, Int * nb_values); template inline void gather(T * values, Int nb_values, Int root = 0); template inline void gatherV(T * values, Int * nb_values, Int root = 0); template inline void broadcast(T * values, Int nb_values, Int root = 0); inline void barrier(); /* ------------------------------------------------------------------------ */ /* Request handling */ /* ------------------------------------------------------------------------ */ inline bool testRequest(CommunicationRequest * request); inline void wait(CommunicationRequest * request); inline void waitAll(std::vector & requests); inline void freeCommunicationRequest(CommunicationRequest * request); inline void freeCommunicationRequest(std::vector & requests); /* ------------------------------------------------------------------------ */ /* Accessors */ /* ------------------------------------------------------------------------ */ public: virtual Int getNbProc() const { return real_static_communicator->psize; }; virtual Int whoAmI() const { return real_static_communicator->prank; }; AKANTU_GET_MACRO(RealStaticCommunicator, *real_static_communicator, const RealStaticCommunicator &); static StaticCommunicator & getStaticCommunicator(CommunicatorType type = _communicator_mpi); static StaticCommunicator & getStaticCommunicator(int & argc, char ** & argv, CommunicatorType type = _communicator_mpi); static bool isInstantiated() { return is_instantiated; }; /* ------------------------------------------------------------------------ */ /* Class Members */ /* ------------------------------------------------------------------------ */ private: static bool is_instantiated; static StaticCommunicator * static_communicator; RealStaticCommunicator * real_static_communicator; CommunicatorType real_type; }; /* -------------------------------------------------------------------------- */ /* inline functions */ /* -------------------------------------------------------------------------- */ #include "static_communicator_inline_impl.hh" /* -------------------------------------------------------------------------- */ /* Inline Functions ArrayBase */ /* -------------------------------------------------------------------------- */ inline std::ostream & operator<<(std::ostream & stream, const CommunicationRequest & _this) { _this.printself(stream); return stream; } __END_AKANTU__ #endif /* __AKANTU_STATIC_COMMUNICATOR_HH__ */