コード例 #1
0
void DirichletBoundaryCondition::getEssentialBCValues(
    const double t, NumLib::IndexValueVector<GlobalIndexType>& bc_values) const
{
    // TODO: Reenable when fixed ;)
    //if (_already_computed)
        //return;

    _already_computed = true;

    SpatialPosition pos;

    bc_values.ids.clear();
    bc_values.values.clear();

    // convert mesh node ids to global index for the given component
    bc_values.ids.reserve(bc_values.ids.size() + _mesh_node_ids.size());
    bc_values.values.reserve(bc_values.values.size() + _mesh_node_ids.size());
    for (auto const id : _mesh_node_ids)
    {
        pos.setNodeID(id);
        MeshLib::Location l(_mesh_id, MeshLib::MeshItemType::Node, id);
        // TODO: that might be slow, but only done once
        const auto g_idx =
            _dof_table.getGlobalIndex(l, _variable_id, _component_id);
        if (g_idx == NumLib::MeshComponentMap::nop)
            continue;
        // For the DDC approach (e.g. with PETSc option), the negative
        // index of g_idx means that the entry by that index is a ghost one,
        // which should be dropped. Especially for PETSc routines MatZeroRows
        // and MatZeroRowsColumns, which are called to apply the Dirichlet BC,
        // the negative index is not accepted like other matrix or vector
        // PETSc routines. Therefore, the following if-condition is applied.
        if (g_idx >= 0) {
            bc_values.ids.emplace_back(g_idx);
            bc_values.values.emplace_back(_parameter(t, pos).front());
        }
    }
}
コード例 #2
0
void DirichletBoundaryCondition::getEssentialBCValues(
    const double t, GlobalVector const& /*x*/,
    NumLib::IndexValueVector<GlobalIndexType>& bc_values) const
{
    SpatialPosition pos;

    bc_values.ids.clear();
    bc_values.values.clear();

    // convert mesh node ids to global index for the given component
    bc_values.ids.reserve(bc_values.ids.size() + _bc_mesh.getNumberOfNodes());
    bc_values.values.reserve(bc_values.values.size() +
                             _bc_mesh.getNumberOfNodes());
    for (auto const* const node : _bc_mesh.getNodes())
    {
        auto const id = node->getID();
        pos.setNodeID(node->getID());
        // TODO: that might be slow, but only done once
        auto const global_index = _dof_table_boundary->getGlobalIndex(
            {_bc_mesh.getID(), MeshLib::MeshItemType::Node, id}, _variable_id,
            _component_id);
        if (global_index == NumLib::MeshComponentMap::nop)
            continue;
        // For the DDC approach (e.g. with PETSc option), the negative
        // index of global_index means that the entry by that index is a ghost
        // one, which should be dropped. Especially for PETSc routines
        // MatZeroRows and MatZeroRowsColumns, which are called to apply the
        // Dirichlet BC, the negative index is not accepted like other matrix or
        // vector PETSc routines. Therefore, the following if-condition is
        // applied.
        if (global_index >= 0)
        {
            bc_values.ids.emplace_back(global_index);
            bc_values.values.emplace_back(_parameter(t, pos).front());
        }
    }
}