Exemple #1
0
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;
        }
    }
}
inline void copy(const std::vector<Real>& vector, RealMatrix& realmatrix)
{
  cf3_assert(realmatrix.size() == vector.size());
  for (Uint row=0; row<realmatrix.rows(); ++row)
  {
    for (Uint col=0; col<realmatrix.cols(); ++col)
    {
      realmatrix(row,col) = vector[realmatrix.cols()*row + col];
    }
  }
}
Exemple #3
0
vector<double> calculatePercentageContacts(const RealMatrix& M) {
  vector<long> sum(M.cols()-1, 0);

  for (uint i=1; i<M.cols(); ++i)
    for (uint j=0; j<M.rows(); ++j)
      sum[i-1] += M(j, i);
  

  vector<double> occ(M.cols()-1, 0.0);
  for (uint i=0; i<M.cols()-1; ++i)
    occ[i] = static_cast<double>(sum[i]) / M.rows();

  return(occ);
}
Exemple #4
0
void CElements::put_coordinates(RealMatrix& elem_coords, const Uint elem_idx) const
{
  const CTable<Real>& coords_table = nodes().coordinates();
  CConnectivity::ConstRow elem_nodes = node_connectivity()[elem_idx];

  const Uint nb_nodes=elem_coords.rows();
  const Uint dim=elem_coords.cols();


  for(Uint node = 0; node != nb_nodes; ++node)
    for (Uint d=0; d<dim; ++d)
      elem_coords(node,d) = coords_table[elem_nodes[node]][d];
}
Exemple #5
0
void CCellFaces::put_coordinates(RealMatrix& elem_coords, const Uint face_idx) const
{
  const CTable<Real>& coords_table = nodes().coordinates();
  std::vector<Uint> face_nodes = m_cell_connectivity->face_nodes(face_idx);

  const Uint nb_nodes=elem_coords.rows();
  const Uint dim=elem_coords.cols();

  cf_assert(nb_nodes == face_nodes.size());
  cf_assert(dim==coords_table.row_size());

  for(Uint node = 0; node != nb_nodes; ++node)
    for (Uint d=0; d<dim; ++d)
      elem_coords(node,d) = coords_table[face_nodes[node]][d];

}
 void check_close(const RealMatrix& a, const RealMatrix& b, const Real eps)
 {
   for(Uint i = 0; i != a.rows(); ++i)
     for(Uint j = 0; j != a.cols(); ++j)
       BOOST_CHECK_CLOSE(a(i,j), b(i,j), eps);
 }