File: assemble_utils.cpp

package info (click to toggle)
dolfinx-mpc 0.5.0.post0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,112 kB
  • sloc: python: 5,998; cpp: 5,196; makefile: 67
file content (29 lines) | stat: -rw-r--r-- 872 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright (C) 2022 Jorgen S. Dokken
//
// This file is part of DOLFINX_MPC
//
// SPDX-License-Identifier:    MIT

#include "assemble_utils.h"
#include <algorithm>

std::vector<std::int32_t> dolfinx_mpc::compute_local_slave_index(
    const std::span<const std::int32_t>& slaves, const std::uint32_t num_dofs,
    const int bs, const std::span<const std::int32_t> cell_dofs,
    const std::vector<std::int8_t>& is_slave)
{
  std::vector<std::int32_t> local_index(slaves.size());

  for (std::uint32_t i = 0; i < num_dofs; i++)
    for (int j = 0; j < bs; j++)
    {
      const std::int32_t dof = cell_dofs[i] * bs + j;
      if (is_slave[dof])
      {
        auto it = std::find(slaves.begin(), slaves.end(), dof);
        const auto slave_index = std::distance(slaves.begin(), it);
        local_index[slave_index] = i * bs + j;
      }
    }
  return local_index;
};