MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / MasterInverse

Method MasterInverse

parallel/parallel_matrices.cpp:30–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29 template <typename TM>
30 MasterInverse<TM> :: MasterInverse (const SparseMatrixTM<TM> & mat,
31 shared_ptr<BitArray> subset,
32 shared_ptr<ParallelDofs> hpardofs)
33
34 : BaseMatrix(hpardofs), loc2glob(hpardofs -> GetCommunicator().Size())
35 {
36 inv = nullptr;
37
38 auto & comm = paralleldofs->GetCommunicator();
39 int id = comm.Rank();
40 int ntasks = comm.Size();
41
42 // consistent enumeration
43
44 int ndof = paralleldofs->GetNDofLocal();
45
46 Array<int> global_nums(ndof);
47 global_nums = -1;
48 int num_master_dofs = 0;
49 for (int i = 0; i < ndof; i++)
50 if (paralleldofs -> IsMasterDof (i) && (!subset || (subset && subset->Test(i))))
51 global_nums[i] = num_master_dofs++;
52
53
54 Array<int> first_master_dof(ntasks);
55 comm.AllGather (num_master_dofs, first_master_dof);
56
57 int num_glob_dofs = 0;
58 for (int i = 0; i < ntasks; i++)
59 {
60 int cur = first_master_dof[i];
61 first_master_dof[i] = num_glob_dofs;
62 num_glob_dofs += cur;
63 }
64
65 for (int i = 0; i < ndof; i++)
66 if (global_nums[i] != -1)
67 global_nums[i] += first_master_dof[id];
68
69 paralleldofs -> ScatterDofData (global_nums);
70
71
72 /*
73 cout << "TESTING" << endl;
74 for (int i = 0; i < ndof; i++)
75 *testout << "dof" << i << " = " << pardofs->GetDofNodes()[i] << " free = " << subset->Test(i) << endl;
76 *testout << "global_nums = " << endl << global_nums << endl;
77
78
79 const MeshAccess & ma = pardofs->GetMeshAccess();
80
81 for (int dest = 0; dest < ntasks; dest++)
82 {
83 *testout << "shared dofs with proc " << dest << endl;
84 *testout << "exdofs " << endl << pardofs->GetExchangeDofs (dest) << endl;
85 Array<int> procs;
86 for (int i = 0; i < ma.GetNFaces(); i++)
87 {

Callers

nothing calls this directly

Calls 14

IMClass · 0.85
swapFunction · 0.85
GetNDofLocalMethod · 0.80
IsMasterDofMethod · 0.80
ScatterDofDataMethod · 0.80
GetInverseTypeMethod · 0.80
AddMethod · 0.80
SetInverseTypeMethod · 0.80
SizeMethod · 0.45
GetCommunicatorMethod · 0.45
AppendMethod · 0.45
HeightMethod · 0.45

Tested by

no test coverage detected