void CSpace::put_coordinates(RealMatrix& coordinates, const Uint elem_idx) const { if (bound_fields().has_coordinates()) { CConnectivity::ConstRow indexes = indexes_for_element(elem_idx); Field& coordinates_field = bound_fields().coordinates(); cf_assert(coordinates.rows() == indexes.size()); cf_assert(coordinates.cols() == coordinates_field.row_size()); for (Uint i=0; i<coordinates.rows(); ++i) { for (Uint j=0; j<coordinates.cols(); ++j) { coordinates(i,j) = coordinates_field[i][j]; } } } else { const ShapeFunction& space_sf = shape_function(); const CEntities& geometry = support(); const ElementType& geometry_etype = element_type(); const ShapeFunction& geometry_sf = geometry_etype.shape_function(); RealMatrix geometry_coordinates = geometry.get_coordinates(elem_idx); cf_assert(coordinates.rows() == space_sf.nb_nodes()); cf_assert(coordinates.cols() == geometry_etype.dimension()); for (Uint node=0; node<space_sf.nb_nodes(); ++node) { coordinates.row(node) = geometry_sf.value( space_sf.local_coordinates().row(node) ) * geometry_coordinates; } } }
void Reconstruct::configure_from_to() { std::vector<std::string> from_to; option("from_to").put_value(from_to); if (is_not_null(m_from)) remove_component(*m_from); m_from = create_component("from_"+from_to[0],from_to[0]).as_ptr<ShapeFunction>(); if (is_not_null(m_to)) remove_component(*m_to); m_to = create_component("to_"+from_to[1],from_to[1]).as_ptr<ShapeFunction>(); m_value_reconstruction_matrix.resize(m_to->nb_nodes(),m_from->nb_nodes()); m_gradient_reconstruction_matrix.resize(m_to->dimensionality()); for (Uint d=0; d<m_gradient_reconstruction_matrix.size(); ++d) m_gradient_reconstruction_matrix[d].resize(m_to->nb_nodes(),m_from->nb_nodes()); for (Uint to_node=0; to_node<m_to->nb_nodes(); ++to_node) { m_value_reconstruction_matrix.row(to_node) = m_from->value( m_to->local_coordinates().row(to_node) ); RealMatrix grad = m_from->gradient( m_to->local_coordinates().row(to_node) ); for (Uint d=0; d<m_to->dimensionality(); ++d) m_gradient_reconstruction_matrix[d].row(to_node) = grad.row(d); } }