Beispiel #1
0
void LocalToGlobalIndexMap::findGlobalIndicesWithElementID(
    ElementIterator first, ElementIterator last,
    std::vector<MeshLib::Node*> const& nodes, std::size_t const mesh_id,
    const int comp_id, const int comp_id_write)
{
    std::unordered_set<MeshLib::Node*> const set_nodes(nodes.begin(), nodes.end());

    // For each element find the global indices for node/element
    // components.
    for (ElementIterator e = first; e != last; ++e)
    {
        LineIndex indices;
        indices.reserve((*e)->getNumberOfNodes());

        for (auto* n = (*e)->getNodes();
             n < (*e)->getNodes()+(*e)->getNumberOfNodes(); ++n)
        {
            // Check if the element's node is in the given list of nodes.
            if (set_nodes.find(*n)==set_nodes.end())
                continue;
            MeshLib::Location l(
                mesh_id, MeshLib::MeshItemType::Node, (*n)->getID());
            indices.push_back(_mesh_component_map.getGlobalIndex(l, comp_id));
        }

        indices.shrink_to_fit();
        _rows((*e)->getID(), comp_id_write) = std::move(indices);
    }
}
void
LocalToGlobalIndexMap::findGlobalIndices(
    ElementIterator first, ElementIterator last,
    std::size_t const mesh_id,
    const unsigned comp_id, const unsigned comp_id_write)
{
    _rows.resize(std::distance(first, last), _mesh_subsets.size());

    // For each element find the global indices for node/element
    // components.
    std::size_t elem_id = 0;
    for (ElementIterator e = first; e != last; ++e, ++elem_id)
    {
        std::size_t const nnodes = (*e)->getNumberOfNodes();

        LineIndex indices;
        indices.reserve(nnodes);

        for (unsigned n = 0; n < nnodes; n++)
        {
            MeshLib::Location l(mesh_id,
                                MeshLib::MeshItemType::Node,
                                (*e)->getNode(n)->getID());
            indices.push_back(_mesh_component_map.getGlobalIndex(l, comp_id));
        }

        _rows(elem_id, comp_id_write) = std::move(indices);
    }
}
Beispiel #3
0
std::size_t
LocalToGlobalIndexMap::getNumberOfElementComponents(std::size_t const mesh_item_id) const
{
    std::size_t n = 0;
    for (Table::Index c = 0; c < _rows.cols(); ++c)
    {
        if (!_rows(mesh_item_id, c).empty())
            n++;
    }
    return n;
}
Beispiel #4
0
std::size_t
LocalToGlobalIndexMap::getNumberOfElementDOF(std::size_t const mesh_item_id) const
{
    std::size_t ndof = 0;

    for (Table::Index c = 0; c < _rows.cols(); ++c)
    {
        ndof += _rows(mesh_item_id, c).size();
    }

    return ndof;
}
Beispiel #5
0
std::vector<int> LocalToGlobalIndexMap::getElementVariableIDs(
    std::size_t const mesh_item_id) const
{
    std::vector<int> vec;
    for (int i = 0; i < getNumberOfVariables(); i++)
    {
        for (int j=0; j<getNumberOfVariableComponents(i); j++)
        {
            auto comp_id = getGlobalComponent(i, j);
            if (!_rows(mesh_item_id, comp_id).empty())
                vec.push_back(i);
        }
    }
    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

    return vec;
}
Beispiel #6
0
void LocalToGlobalIndexMap::findGlobalIndices(
    ElementIterator first, ElementIterator last,
    std::vector<MeshLib::Node*> const& nodes, std::size_t const mesh_id,
    const int comp_id, const int comp_id_write)
{
    _rows.resize(std::distance(first, last), _mesh_subsets.size());

    std::unordered_set<MeshLib::Node*> const set_nodes(nodes.begin(), nodes.end());

    // For each element find the global indices for node/element
    // components.
    std::size_t elem_id = 0;
    for (ElementIterator e = first; e != last; ++e, ++elem_id)
    {
        LineIndex indices;
        indices.reserve((*e)->getNumberOfNodes());

        for (auto* n = (*e)->getNodes();
             n < (*e)->getNodes() + (*e)->getNumberOfNodes(); ++n)
        {
            // Check if the element's node is in the given list of nodes.
            if (set_nodes.find(*n)==set_nodes.end())
                continue;
            MeshLib::Location l(
                mesh_id, MeshLib::MeshItemType::Node, (*n)->getID());
            auto const global_index =
                _mesh_component_map.getGlobalIndex(l, comp_id);
            if (global_index == std::numeric_limits<GlobalIndexType>::max())
            {
                continue;
            }
            indices.push_back(global_index);
        }

        indices.shrink_to_fit();
        _rows(elem_id, comp_id_write) = std::move(indices);
    }
}
Beispiel #7
0
LocalToGlobalIndexMap::RowColumnIndices LocalToGlobalIndexMap::operator()(
    std::size_t const mesh_item_id, const int component_id) const
{
    return RowColumnIndices(_rows(mesh_item_id, component_id),
                            _columns(mesh_item_id, component_id));
}