diff --git a/src/fe_engine/element.hh b/src/fe_engine/element.hh index 4ec8329b0..d79b72b73 100644 --- a/src/fe_engine/element.hh +++ b/src/fe_engine/element.hh @@ -1,117 +1,112 @@ /** * @file element.hh * * @author Nicolas Richart * * @date creation: Tue Sep 02 2014 * @date last modification: Sat Jul 11 2015 * * @brief Element helper class * * @section LICENSE * * Copyright (©) 2014, 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * Akantu is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Akantu is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with Akantu. If not, see . * */ /* -------------------------------------------------------------------------- */ #include "aka_common.hh" /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_ELEMENT_HH__ #define __AKANTU_ELEMENT_HH__ namespace akantu { /* -------------------------------------------------------------------------- */ /* Element */ /* -------------------------------------------------------------------------- */ -class Element; -extern const Element ElementNull; - class Element { - /* ------------------------------------------------------------------------ */ - /* Constructors/Destructors */ - /* ------------------------------------------------------------------------ */ public: - explicit 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; - } + ElementType type; + UInt element; + GhostType ghost_type; + // ElementKind kind; - virtual ~Element() = default; + // ElementType type{_not_defined}; + // UInt element{0}; + // GhostType ghost_type{_not_ghost}; + // ElementKind kind{_ek_regular}; /* ------------------------------------------------------------------------ */ /* Methods */ /* ------------------------------------------------------------------------ */ public: + inline ElementKind kind() const; + inline bool operator==(const Element & elem) const { - return ((element == elem.element) - && (type == elem.type) - && (ghost_type == elem.ghost_type) - && (kind == elem.kind)); + return std::tie(type, element, ghost_type) == + std::tie(elem.type, elem.element, elem.ghost_type); } inline bool operator!=(const Element & elem) const { - return ((element != elem.element) - || (type != elem.type) - || (ghost_type != elem.ghost_type) - || (kind != elem.kind)); + return std::tie(type, element, ghost_type) != + std::tie(elem.type, elem.element, elem.ghost_type); } - 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; - } - - /// function to print the containt of the class - virtual void printself(std::ostream & stream, int indent = 0) const; + // inline bool operator==(const Element & elem) const { + // return ((element == elem.element) && (type == elem.type) && + // (ghost_type == elem.ghost_type) && (kind == elem.kind)); + // } - /* ------------------------------------------------------------------------ */ - /* Accessors */ - /* ------------------------------------------------------------------------ */ -public: - const ElementType & getType(){return type;} - const UInt & getIndex(){return element;}; - const GhostType & getGhostType(){return ghost_type;} - const ElementKind & getElementKind(){return kind;} + // inline bool operator!=(const Element & elem) const { + // return ((element != elem.element) || (type != elem.type) || + // (ghost_type != elem.ghost_type) || (kind != elem.kind)); + // } - /* ------------------------------------------------------------------------ */ - /* Class Members */ - /* ------------------------------------------------------------------------ */ -public: - ElementType type; - UInt element; - GhostType ghost_type; - ElementKind kind; + inline bool operator<(const Element & rhs) const; }; -} // akantu +/// standard output stream operator +inline std::ostream & operator<<(std::ostream & stream, const Element & _this) { + stream << "Element [" << _this.type << ", " << _this.element << ", " + << _this.ghost_type << "]"; + return stream; +} + +namespace { +const Element ElementNull{_not_defined, UInt(-1), _casper}; +// Element{_not_defined, 0, _casper, _ek_not_defined}; +} + +/* -------------------------------------------------------------------------- */ +inline bool Element::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 ((rhs == ElementNull) || + std::tie(ghost_type, type, element) < + std::tie(rhs.ghost_type, rhs.type, rhs.element)); +} + +} // namespace akantu #endif /* __AKANTU_ELEMENT_HH__ */ diff --git a/src/fe_engine/fe_engine_template_tmpl_field.hh b/src/fe_engine/fe_engine_template_tmpl_field.hh index 572f594e6..205071102 100644 --- a/src/fe_engine/fe_engine_template_tmpl_field.hh +++ b/src/fe_engine/fe_engine_template_tmpl_field.hh @@ -1,426 +1,426 @@ /** * @file fe_engine_template_tmpl_field.hh * * @author Nicolas Richart * * @date creation Tue Jul 25 2017 * * @brief implementation of the assemble field s functions * * @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 "fe_engine_template.hh" /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_FE_ENGINE_TEMPLATE_TMPL_FIELD_HH__ #define __AKANTU_FE_ENGINE_TEMPLATE_TMPL_FIELD_HH__ namespace akantu { /* -------------------------------------------------------------------------- */ /* Matrix lumping functions */ /* -------------------------------------------------------------------------- */ namespace fe_engine { namespace details { namespace { template void fillField(const Functor & field_funct, Array & field, UInt nb_element, UInt nb_integration_points, const ElementType & type, const GhostType & ghost_type) { UInt nb_degree_of_freedom = field.getNbComponent(); field.resize(nb_integration_points * nb_element); auto field_it = field.begin_reinterpret( nb_degree_of_freedom, nb_integration_points, nb_element); - Element el(type, 0, ghost_type); + Element el{type, 0, ghost_type}; for (; el.element < nb_element; ++el.element, ++field_it) { field_funct(*field_it, el); } } } // namespace } // namespace details } // namespace fe_engine /** * Helper class to be able to write a partial specialization on the element kind */ namespace fe_engine { namespace details { template struct AssembleLumpedTemplateHelper {}; #define ASSEMBLE_LUMPED(type) \ fem.template assembleFieldLumped(field_funct, lumped, dof_id, \ dof_manager, ghost_type) #define AKANTU_SPECIALIZE_ASSEMBLE_HELPER(kind) \ template <> struct AssembleLumpedTemplateHelper { \ template