/** * @file data_accessor_inline_impl.cc * * @author Aurelia Isabel Cuba Ramos * @author David Simon Kammer * @author Nicolas Richart * * @date creation: Wed Sep 18 2013 * @date last modification: Thu Oct 15 2015 * * @brief Implementation of the inline functions of the DataAccessor 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 . * */ /* -------------------------------------------------------------------------- */ template inline void DataAccessor::packUnpackNodalDataHelper(Array & data, CommunicationBuffer & buffer, const Array & elements, const Mesh & mesh) { UInt nb_component = data.getNbComponent(); UInt nb_nodes_per_element = 0; ElementType current_element_type = _not_defined; GhostType current_ghost_type = _casper; UInt * conn = NULL; Array::const_iterator it = elements.begin(); Array::const_iterator end = elements.end(); for (; it != end; ++it) { const Element & el = *it; if(el.type != current_element_type || el.ghost_type != current_ghost_type) { current_element_type = el.type; current_ghost_type = el.ghost_type; conn = mesh.getConnectivity(el.type, el.ghost_type).storage(); nb_nodes_per_element = Mesh::getNbNodesPerElement(el.type); } UInt el_offset = el.element * nb_nodes_per_element; for (UInt n = 0; n < nb_nodes_per_element; ++n) { UInt offset_conn = conn[el_offset + n]; Vector data_vect(data.storage() + offset_conn * nb_component, nb_component); if(pack_helper) buffer << data_vect; else buffer >> data_vect; } } } /* -------------------------------------------------------------------------- */ template inline void DataAccessor::packUnpackElementalDataHelper(ElementTypeMapArray & data_to_pack, CommunicationBuffer & buffer, const Array & element, bool per_quadrature_point_data, const FEEngine & fem) { ElementType current_element_type = _not_defined; GhostType current_ghost_type = _casper; UInt nb_quad_per_elem = 0; UInt nb_component = 0; Array * vect = NULL; Array::const_iterator it = element.begin(); Array::const_iterator end = element.end(); for (; it != end; ++it) { const Element & el = *it; if(el.type != current_element_type || el.ghost_type != current_ghost_type) { current_element_type = el.type; current_ghost_type = el.ghost_type; vect = &data_to_pack(el.type, el.ghost_type); if(per_quadrature_point_data) nb_quad_per_elem = fem.getNbIntegrationPoints(el.type, el.ghost_type); else nb_quad_per_elem = 1; nb_component = vect->getNbComponent(); } Vector data(vect->storage() + el.element * nb_component * nb_quad_per_elem, nb_component * nb_quad_per_elem); if(pack_helper) buffer << data; else buffer >> data; } } /* -------------------------------------------------------------------------- */ template inline void DataAccessor::packUnpackDOFDataHelper(Array & data, CommunicationBuffer & buffer, const Array & dofs) { Array::const_scalar_iterator it_dof = dofs.begin(); Array::const_scalar_iterator end_dof = dofs.end(); T * data_ptr = data.storage(); for (; it_dof != end_dof; ++it_dof) { if(pack_helper) buffer << data_ptr[*it_dof]; else buffer >> data_ptr[*it_dof]; } }