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

Method BlockJacobiPrecond

linalg/blockjacobi.cpp:317–582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315 ///
316 template <class TM, class TV_ROW, class TV_COL>
317 BlockJacobiPrecond<TM, TV_ROW, TV_COL> ::
318 BlockJacobiPrecond (shared_ptr<const SparseMatrix<TM,TV_ROW,TV_COL>> amat,
319 shared_ptr<Table<int>> ablocktable, bool cumulate_block_diags)
320 : BaseBlockJacobiPrecond(ablocktable), mat(amat),
321 invdiag(ablocktable->Size())
322 {
323 static Timer t("BlockJacobiPrecond ctor"); RegionTimer reg(t);
324 static Timer tinv("BlockJacobiPrecond ctor inv");
325 static Timer tget("BlockJacobiPrecond ctor get");
326 static Timer tprep("BlockJacobiPrecond ctor prep");
327 static Timer tpar("BlockJacobiPrecond ctor par");
328 cout << IM(3) << "BlockJacobi Preconditioner, constructor called, #blocks = " << blocktable->Size() << endl;
329
330
331 // double prevtime = WallTime();
332
333
334 // find nze element in all blocks together
335 /*
336 nze = 0;
337 for (auto block : *blocktable)
338 for (auto row : block)
339 nze += amat.GetRowIndices(row).Size();
340 */
341 nze =
342 ParallelReduce (blocktable->Size(),
343 [&] (size_t i)
344 {
345 size_t nze = 0;
346 for (auto row : (*blocktable)[i])
347 nze += amat->GetRowIndices(row).Size();
348 return nze;
349 },
350 [] (size_t a, size_t b) { return a+b; },
351 size_t(0));
352
353 /*
354 size_t totmem = 0;
355 for (auto i : Range (*blocktable))
356 totmem += sqr ((*blocktable)[i].Size());
357 */
358 size_t totmem =
359 ParallelReduce (blocktable->Size(),
360 [&] (size_t i) { return sqr ((*blocktable)[i].Size()); },
361 [] (size_t a, size_t b) { return a+b; },
362 size_t(0));
363
364 bigmem.SetSize(totmem);
365
366 cout << IM(5) << "avg entrysize: " << blocktable->AsArray().Size()/blocktable->Size() << endl;
367 cout << IM(5) << "avg entrysize^2: " << totmem/blocktable->Size() << endl;
368
369 totmem = 0;
370 for (auto i : Range (*blocktable))
371 {
372 size_t bs = (*blocktable)[i].Size();
373 new ( & invdiag[i] ) FlatMatrix<TM> (bs, bs, bigmem.Addr(totmem));
374 totmem += sqr (bs);

Callers

nothing calls this directly

Calls 14

IMClass · 0.85
AsArrayMethod · 0.80
AddrMethod · 0.80
StopMethod · 0.80
GetParallelDofsMethod · 0.80
GetDistantProcsMethod · 0.80
AddMethod · 0.80
RangeFunction · 0.70
CalcInverseFunction · 0.50
SizeMethod · 0.45
SetSizeMethod · 0.45
GetCommunicatorMethod · 0.45

Tested by

no test coverage detected