G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsINSPrecondBlocks.h
Go to the documentation of this file.
1
12#pragma once
13
15
17#include <gsSolver/gsMatrixOp.h>
18
19namespace gismo
20{
21
22// === BASE BLOCKS ==== //
23
26template <class T>
28{
29
30public:
32
33protected: // *** Class members ***
34
35 gsSparseSolver<T>* m_pSolver;
36 gsOptionList m_opt;
37
38public: // *** Smart pointers ***
39
40 typedef memory::shared_ptr<gsINSPrecondBlock> Ptr;
41 typedef memory::unique_ptr<gsINSPrecondBlock> uPtr;
42
43public: // *** Constructor/destructor ***
44
47 {
48 m_pSolver = NULL;
49 }
50
54 {
55 m_opt = opt;
56
57 m_pSolver = createLinSolver();
58 setupLinSolver(*m_pSolver);
59 }
60
61 virtual ~gsINSPrecondBlock()
62 {
63 if (m_pSolver)
64 {
65 delete m_pSolver;
66 m_pSolver = NULL;
67 }
68 }
69
70public: // *** Member functions ***
71
74
78
79 virtual std::string getName() const
81
82}; // class gsINSPrecondBlock
83
84
97template <class T>
99{
100
101public:
103
104protected: // *** Class members ***
105
106 std::vector<gsSparseSolver<T>* > m_solvers;
107
108protected: // *** Base class members ***
109
110 using Base::m_opt;
111
112public: // *** Smart pointers ***
113
114 typedef memory::shared_ptr<gsINSPrecondBlockMod> Ptr;
115 typedef memory::unique_ptr<gsINSPrecondBlockMod> uPtr;
116
117
118public: // *** Constructor/destructor ***
119
123 {
124 m_opt = opt;
125 int dim = m_opt.getInt("dim");
126
127 m_solvers.resize(dim);
128
129 for (int i = 0; i < dim; i++)
130 {
131 m_solvers[i] = this->createLinSolver();
132 this->setupLinSolver(*m_solvers[i]);
133 }
134 }
135
136 virtual ~gsINSPrecondBlockMod()
137 {
138 for (int i = 0; i < (int)m_solvers.size(); i++)
139 {
140 if (m_solvers[i])
141 {
142 delete m_solvers[i];
143 m_solvers[i] = NULL;
144 }
145 }
146 }
147
148}; // class gsINSPrecondBlockMod
149
150
151// === BLOCK F ==== //
152
165template <class T, int MatOrder>
167{
168
169public:
171
172protected: // *** Class members ***
173
174 const gsSparseMatrix<T, MatOrder> m_blockF1;
175 int m_size;
176
177protected: // *** Base class members ***
178
179 using Base::m_pSolver;
180 using Base::m_opt;
181
182public: // *** Smart pointers ***
183
184 typedef memory::shared_ptr<gsINSPrecondBlockF> Ptr;
185 typedef memory::unique_ptr<gsINSPrecondBlockF> uPtr;
186
187public: // *** Constructor/destructor ***
188
193 Base(opt), m_blockF1(matNS.block(0, 0, opt.getInt("udofs"), opt.getInt("udofs")))
194 {
195 m_size = opt.getInt("dim") * opt.getInt("udofs");
196
197 m_pSolver->compute(m_blockF1);
198 }
199
200public: // *** Static functions ***
201
205 static uPtr make(const gsSparseMatrix<T, MatOrder>& matNS, const gsOptionList& opt)
206 {
208 }
209
210public: // *** Member functions ***
211
216 void apply(const gsMatrix<T> & input, gsMatrix<T> & x) const;
217
218
219public: // *** Getters/setters ***
220
222 int rows() const { return m_size; }
223
225 int cols() const { return m_size; }
226
228 virtual std::string getName() const
229 {
230 return "FdiagEqual";
231 }
232
233}; // class gsINSPrecondBlockF
234
235
236// === BLOCK Fwhole ==== //
237
250template <class T, int MatOrder>
252{
253
254public:
256
257protected: // *** Class members ***
258
259 const gsSparseMatrix<T, MatOrder> m_blockA;
260 int m_size;
261
262protected: // *** Base class members ***
263
264 using Base::m_pSolver;
265
266public: // *** Smart pointers ***
267
268 typedef memory::shared_ptr<gsINSPrecondBlockFwhole> Ptr;
269 typedef memory::unique_ptr<gsINSPrecondBlockFwhole> uPtr;
270
271public: // *** Constructor/destructor ***
272
277 Base(opt), m_blockA(matNS.block(0, 0, opt.getInt("dim")*opt.getInt("udofs"), opt.getInt("dim")*opt.getInt("udofs")))
278 {
279 m_size = opt.getInt("dim") * opt.getInt("udofs");
280
281 m_pSolver->compute(m_blockA);
282 }
283
284public: // *** Static functions ***
285
289 static uPtr make(const gsSparseMatrix<T, MatOrder>& matNS, const gsOptionList& opt)
290 {
292 }
293
294public: // *** Member functions ***
295
300 void apply(const gsMatrix<T> & input, gsMatrix<T> & x) const;
301
302public: // *** Getters/setters ***
303
305 int rows() const { return m_size; }
306
308 int cols() const { return m_size; }
309
311 virtual std::string getName() const
312 {
313 return "Fwhole";
314 }
315
316}; // class gsINSPrecondBlockFwhole
317
318
319// === BLOCK Fdiag ==== //
320
333template <class T, int MatOrder>
335{
336
337public:
339
340protected: // *** Class members ***
341 std::vector<gsSparseMatrix<T, MatOrder> > m_diagBlocks;
342 int m_size;
343
344protected: // *** Base class members ***
345
346 using Base::m_solvers;
347 using Base::Base::m_opt;
348
349public: // *** Smart pointers ***
350
351 typedef memory::shared_ptr<gsINSPrecondBlockFdiag> Ptr;
352 typedef memory::unique_ptr<gsINSPrecondBlockFdiag> uPtr;
353
354public: // *** Constructor/destructor ***
355
360 Base(opt)
361 {
362 int dim = opt.getInt("dim");
363 m_size = dim * opt.getInt("udofs");
364
365 m_diagBlocks.resize(dim);
366
367 for (int i = 0; i < dim; i++)
368 {
369 int udofs = opt.getInt("udofs");
370 m_diagBlocks[i] = matNS.block(i*udofs, i*udofs, udofs, udofs);
371 m_solvers[i]->compute(m_diagBlocks[i]);
372 }
373 }
374
375public: // *** Static functions ***
376
380 static uPtr make(const gsSparseMatrix<T, MatOrder>& matNS, const gsOptionList& opt)
381 {
383 }
384
385public: // *** Member functions ***
386
391 void apply(const gsMatrix<T> & input, gsMatrix<T> & x) const;
392
393public: // *** Getters/setters ***
394
396 int rows() const { return m_size; }
397
399 int cols() const { return m_size; }
400
402 virtual std::string getName() const
403 {
404 return "Fdiag";
405 }
406
407}; // class gsINSPrecondBlockFdiag
408
409
410// === BLOCK Fmod ==== //
411
424template <class T, int MatOrder>
426{
427
428public:
430
431protected: // *** Class members ***
432
433 const gsSparseMatrix<T, MatOrder>& m_matRef;
434 std::vector<gsSparseMatrix<T, MatOrder> > m_diagBlocks;
435 int m_size;
436
437protected: // *** Base class members ***
438
439 using Base::m_solvers;
440 using Base::Base::m_opt;
441
442public: // *** Smart pointers ***
443
444 typedef memory::shared_ptr<gsINSPrecondBlockFmod> Ptr;
445 typedef memory::unique_ptr<gsINSPrecondBlockFmod> uPtr;
446
447public: // *** Constructor/destructor ***
448
453 Base(opt), m_matRef(matNS)
454 {
455 int dim = opt.getInt("dim");
456 int udofs = opt.getInt("udofs");
457 m_size = dim * udofs;
458
459 m_diagBlocks.resize(dim);
460
461 for (int i = 0; i < dim; i++)
462 {
463 m_diagBlocks[i] = m_matRef.block(i*udofs, i*udofs, udofs, udofs);
464 m_solvers[i]->compute(m_diagBlocks[i]);
465 }
466 }
467
468public: // *** Static functions ***
469
473 static uPtr make(const gsSparseMatrix<T, MatOrder>& matNS, const gsOptionList& opt)
474 {
476 }
477
478public: // *** Member functions ***
479
484 void apply(const gsMatrix<T> & input, gsMatrix<T> & x) const;
485
486public: // *** Getters/setters ***
487
489 int rows() const { return m_size; }
490
492 int cols() const { return m_size; }
493
495 virtual std::string getName() const
496 {
497 return "Fmod";
498 }
499
500}; // class gsINSPrecondBlockFmod
501
502
503// === BLOCK Bt ==== //
504
505template <class T, int MatOrder>
506class gsINSPrecondBlockBt : public gsLinearOperator<T>
507{
508
509public:
510 typedef gsLinearOperator<T> Base;
511
512protected: // *** Class members ***
513
515
516public: // *** Smart pointers ***
517
518 typedef memory::shared_ptr<gsINSPrecondBlockBt> Ptr;
519 typedef memory::unique_ptr<gsINSPrecondBlockBt> uPtr;
520
521public: // *** Constructor/destructor ***
522
526 gsINSPrecondBlockBt(const gsSparseMatrix<T, MatOrder>& matNS, const gsOptionList& opt)
527 {
528 int dim = opt.getInt("dim");
529 int udofs = opt.getInt("udofs");
530 m_mat = matNS.block(0, dim * udofs, dim * udofs, matNS.cols() - dim * udofs);
531 }
532
533public: // *** Static functions ***
534
538 static uPtr make(const gsSparseMatrix<T, MatOrder>& matNS, const gsOptionList& opt)
539 {
540 return memory::make_unique(new gsINSPrecondBlockBt<T, MatOrder>(matNS, opt));
541 }
542
543public: // *** Member functions ***
544
549 void apply(const gsMatrix<T> & input, gsMatrix<T> & x) const;
550
551public: // *** Getters/setters ***
552
554 int rows() const { return m_mat.rows(); }
555
557 int cols() const { return m_mat.cols(); }
558
559}; // class gsINSPrecondBlockBt
560
561
562// === Schur LSC ==== //
563
564template <class T, int MatOrder>
565class gsINSPrecondSchurLSC : public gsINSPrecondBlock<T>
566{
567
568public:
569 typedef gsINSPrecondBlock<T> Base;
570
571protected: // *** Class members ***
572
573 gsSparseMatrix<T, MatOrder> m_mat1, m_mat2;
574
575protected: // *** Base class members ***
576
577 using Base::m_pSolver;
578
579public: // *** Smart pointers ***
580
581 typedef memory::shared_ptr<gsINSPrecondSchurLSC> Ptr;
582 typedef memory::unique_ptr<gsINSPrecondSchurLSC> uPtr;
583
584public: // *** Constructor/destructor ***
585
589 gsINSPrecondSchurLSC(const std::map<std::string, gsSparseMatrix<T, MatOrder> >& mat, const gsOptionList& opt) :
590 Base(opt)
591 {
592 // S = - (B * velM^-1 * BT) * (B * velM^-1 * F * velM^-1 * BT)^-1 * (B * velM^-1 * BT)
593 // denote S = - mat1 * mat2^-1 * mat1
594
595 int dim = opt.getInt("dim");
596 int udofs = opt.getInt("udofs");
597 int uSize = dim * udofs; // number of all velocity dofs (all components)
598 int pdofs = opt.getInt("pdofs"); // number of pressure dofs
599
600 const gsSparseMatrix<T, MatOrder>& matNS = mat.at("matNS");
601 const gsSparseMatrix<T, MatOrder>& velM = mat.at("matMu");
602
603 gsSparseMatrix<T, MatOrder> velMinv(uSize, uSize); // approximation of velocity mass matrix inverse
604
605 diagInvMatrix_into(velM, velMinv, uSize / velM.rows(), opt.getSwitch("lumpingM"));
606
607 // TODO: could be more efficient if the matrices not involving block F were not updated (they do not change)
608 gsSparseMatrix<T, MatOrder> BMinv, MinvBt;
609 BMinv = matNS.block(uSize, 0, pdofs, uSize) * velMinv; // B * velM^-1
610 MinvBt = velMinv * matNS.block(0, uSize, uSize, pdofs); // velM^-1 * BT
611
612 m_mat1 = BMinv * matNS.block(0, uSize, uSize, pdofs); // B * velM^-1 * BT
613 m_mat2 = BMinv * matNS.block(0, 0, uSize, uSize) * MinvBt; // B * velM^-1 * F * velM^-1 * BT
614
615 m_pSolver->compute(m_mat1);
616 }
617
618public: // *** Static functions ***
619
623 static uPtr make(const std::map<std::string, gsSparseMatrix<T, MatOrder> >& mat, const gsOptionList& opt)
624 {
625 return memory::make_unique(new gsINSPrecondSchurLSC<T, MatOrder>(mat, opt));
626 }
627
628public: // *** Member functions ***
629
634 void apply(const gsMatrix<T>& input, gsMatrix<T>& x) const;
635
636public: // *** Getters/setters ***
637
639 int rows() const { return m_mat2.rows(); }
640
642 int cols() const { return m_mat2.cols(); }
643
644}; // class gsINSPrecondSchurLSC
645
646
647// === Schur PCD ==== //
648
649template <class T, int MatOrder>
650class gsINSPrecondSchurPCD : public gsINSPrecondBlock<T>
651{
652
653public:
654 typedef gsINSPrecondBlock<T> Base;
655
656protected: // *** Class members ***
657
658 gsSparseMatrix<T, MatOrder> m_matAp, m_matFp, m_matMp;
659 gsSparseSolver<T>* m_pMassSolver;
660
661protected: // *** Base class members ***
662
663 using Base::m_pSolver;
664
665public: // *** Smart pointers ***
666
667 typedef memory::shared_ptr<gsINSPrecondSchurPCD> Ptr;
668 typedef memory::unique_ptr<gsINSPrecondSchurPCD> uPtr;
669
670public: // *** Constructor/destructor ***
671
675 gsINSPrecondSchurPCD(const std::map<std::string, gsSparseMatrix<T, MatOrder> >& mat, const gsOptionList& opt) :
676 Base(opt)
677 {
678 // S = - Ap * Fp^-1 * Mp
679
680 m_matAp = mat.at("matAp");
681 m_matFp = mat.at("matFp");
682 m_matMp = mat.at("matMp");
683
684 m_pMassSolver = this->createLinSolver();
685 this->setupLinSolver(*m_pMassSolver);
686
687 m_pSolver->compute(m_matAp);
688 m_pMassSolver->compute(m_matMp);
689 }
690
691 ~gsINSPrecondSchurPCD()
692 {
693 if (m_pMassSolver)
694 {
695 delete m_pMassSolver;
696 m_pMassSolver = NULL;
697 }
698 }
699
700public: // *** Static functions ***
701
705 static uPtr make(const std::map<std::string, gsSparseMatrix<T, MatOrder> >& mat, const gsOptionList& opt)
706 {
707 return memory::make_unique(new gsINSPrecondSchurPCD<T, MatOrder>(mat, opt));
708 }
709
710public: // *** Member functions ***
711
716 void apply(const gsMatrix<T>& input, gsMatrix<T>& x) const;
717
718public: // *** Getters/setters ***
719
721 int rows() const { return m_matAp.rows(); }
722
724 int cols() const { return m_matAp.cols(); }
725
726}; // class gsINSPrecondSchurPCD
727
728
729// === Schur PCDmod ==== //
730
731template <class T, int MatOrder>
732class gsINSPrecondSchurPCDmod : public gsINSPrecondSchurPCD<T, MatOrder>
733{
734
735public:
736 typedef gsINSPrecondSchurPCD<T, MatOrder> Base;
737
738protected: // *** Base class members ***
739
740 using Base::m_matAp;
741 using Base::m_matFp;
742 using Base::m_matMp;
743 using Base::m_pMassSolver;
744 using Base::Base::m_pSolver;
745
746public: // *** Smart pointers ***
747
748 typedef memory::shared_ptr<gsINSPrecondSchurPCDmod> Ptr;
749 typedef memory::unique_ptr<gsINSPrecondSchurPCDmod> uPtr;
750
751public: // *** Constructor/destructor ***
752
756 gsINSPrecondSchurPCDmod(const std::map<std::string, gsSparseMatrix<T, MatOrder> >& mat, const gsOptionList& opt) :
757 Base(mat, opt)
758 {
759 // S = - Mp * Fp^-1 * Ap
760 }
761
762public: // *** Static functions ***
763
767 static uPtr make(const std::map<std::string, gsSparseMatrix<T, MatOrder> >& mat, const gsOptionList& opt)
768 {
769 return memory::make_unique(new gsINSPrecondSchurPCDmod<T, MatOrder>(mat, opt));
770 }
771
772public: // *** Member functions ***
773
778 void apply(const gsMatrix<T>& input, gsMatrix<T>& x) const;
779
780}; // class gsINSPrecondSchurPCDmod
781
782
783// === Schur AL ==== //
784
785template <class T, int MatOrder>
786class gsINSPrecondSchurAL : public gsINSPrecondBlock<T>
787{
788
789public:
790 typedef gsINSPrecondBlock<T> Base;
791
792protected: // *** Class members ***
793
794 real_t m_const;
796
797public: // *** Smart pointers ***
798
799 typedef memory::shared_ptr<gsINSPrecondSchurAL> Ptr;
800 typedef memory::unique_ptr<gsINSPrecondSchurAL> uPtr;
801
802public: // *** Constructor/destructor ***
803
807 gsINSPrecondSchurAL(const std::map<std::string, gsSparseMatrix<T, MatOrder> >& mat, const gsOptionList& opt)
808 {
809 // S = - (gamma + nu) Mp
810
811 const gsSparseMatrix<T, MatOrder>& presM = mat.at("matMp");
812
813 m_const = opt.getReal("visc") + opt.getReal("gamma");
814
815 diagInvMatrix_into(presM, m_mat, 1, opt.getSwitch("lumpingM"));
816 }
817
818public: // *** Static functions ***
819
823 static uPtr make(const std::map<std::string, gsSparseMatrix<T, MatOrder> >& mat, const gsOptionList& opt)
824 {
825 return memory::make_unique(new gsINSPrecondSchurAL<T, MatOrder>(mat, opt));
826 }
827
828public: // *** Member functions ***
829
834 void apply(const gsMatrix<T> & input, gsMatrix<T> & x) const
835 {
836 GISMO_ASSERT(input.rows() == this->rows(), "Wrong input size.");
837 x.resize(this->rows(), 1);
838
839 x = - m_const * m_mat * input;
840 }
841
842public: // *** Getters/setters ***
843
845 int rows() const { return m_mat.rows(); }
846
848 int cols() const { return m_mat.cols(); }
849
850}; // class gsINSPrecondSchurAL
851
852
853// === Schur SIMPLE ==== //
854
855template <class T, int MatOrder>
856class gsINSPrecondSchurSIMPLE : public gsINSPrecondBlock<T>
857{
858
859public:
860 typedef gsINSPrecondBlock<T> Base;
861
862protected: // *** Class members ***
863
865
866protected: // *** Base class members ***
867
868 using Base::m_pSolver;
869
870public: // *** Smart pointers ***
871
872 typedef memory::shared_ptr<gsINSPrecondSchurSIMPLE> Ptr;
873 typedef memory::unique_ptr<gsINSPrecondSchurSIMPLE> uPtr;
874
875
876public: // *** Constructor/destructor ***
877
881 gsINSPrecondSchurSIMPLE(const std::map<std::string, gsSparseMatrix<T, MatOrder> >& mat, const gsOptionList& opt) :
882 Base(opt)
883 {
884 // S = - B Dinv Bt
885 int dim = opt.getInt("dim");
886 int udofs = opt.getInt("udofs");
887 int uSize = dim * udofs;
888 int pdofs = opt.getInt("pdofs");
889
890 const gsSparseMatrix<T, MatOrder>& matNS = mat.at("matNS");
891
892 gsSparseMatrix<T, MatOrder> blockA = matNS.block(0, 0, uSize, uSize);
893 gsSparseMatrix<T, MatOrder> Dinv(uSize, uSize); // approximation of A inverse
894 diagInvMatrix_into(blockA, Dinv, 1, opt.getSwitch("lumpingA"));
895
896 m_mat = - matNS.block(uSize, 0, pdofs, uSize) * Dinv * matNS.block(0, uSize, uSize, pdofs);
897
898 m_pSolver->compute(m_mat);
899 }
900
901public: // *** Static functions ***
902
906 static uPtr make(const std::map<std::string, gsSparseMatrix<T, MatOrder> >& mat, const gsOptionList& opt)
907 {
908 return memory::make_unique(new gsINSPrecondSchurSIMPLE<T, MatOrder>(mat, opt));
909 }
910
911public: // *** Member functions ***
912
917 void apply(const gsMatrix<T> & input, gsMatrix<T> & x) const
918 {
919 GISMO_ASSERT(input.rows() == this->rows(), "Wrong input size.");
920 x.resize(this->rows(), 1);
921
922 x = m_pSolver->solve(input);
923 }
924
925public: // *** Getters/setters ***
926
928 int rows() const { return m_mat.rows(); }
929
931 int cols() const { return m_mat.cols(); }
932
933}; // class gsINSPrecondSchurSIMPLE
934
935
936// === Schur MSIMPLER ==== //
937
938template <class T, int MatOrder>
939class gsINSPrecondSchurMSIMPLER : public gsINSPrecondBlock<T>
940{
941
942public:
943 typedef gsINSPrecondBlock<T> Base;
944
945protected: // *** Class members ***
946
948
949protected: // *** Base class members ***
950
951 using Base::m_pSolver;
952
953public: // *** Smart pointers ***
954
955 typedef memory::shared_ptr<gsINSPrecondSchurMSIMPLER> Ptr;
956 typedef memory::unique_ptr<gsINSPrecondSchurMSIMPLER> uPtr;
957
958public: // *** Constructor/destructor ***
959
963 gsINSPrecondSchurMSIMPLER(const std::map<std::string, gsSparseMatrix<T, MatOrder> >& mat, const gsOptionList& opt) :
964 Base(opt)
965 {
966 // S = - B velMinv Bt
967 int dim = opt.getInt("dim");
968 int udofs = opt.getInt("udofs");
969 int uSize = dim * udofs;
970 int pdofs = opt.getInt("pdofs");
971
972 const gsSparseMatrix<T, MatOrder>& matNS = mat.at("matNS");
973 const gsSparseMatrix<T, MatOrder>& velM = mat.at("matMu");
974
975 gsSparseMatrix<T, MatOrder> velMinv(uSize, uSize); // approximation of velocity mass matrix inverse
976 diagInvMatrix_into(velM, velMinv, uSize / velM.rows(), opt.getSwitch("lumpingM"));
977
978 m_mat = - matNS.block(uSize, 0, pdofs, uSize) * velMinv * matNS.block(0, uSize, uSize, pdofs);
979
980 m_pSolver->compute(m_mat);
981 }
982
983public: // *** Static functions ***
984
988 static uPtr make(const std::map<std::string, gsSparseMatrix<T, MatOrder> >& mat, const gsOptionList& opt)
989 {
990 return memory::make_unique(new gsINSPrecondSchurMSIMPLER<T, MatOrder>(mat, opt));
991 }
992
993public: // *** Member functions ***
994
999 void apply(const gsMatrix<T> & input, gsMatrix<T> & x) const
1000 {
1001 GISMO_ASSERT(input.rows() == this->rows(), "Wrong input size.");
1002 x.resize(this->rows(), 1);
1003
1004 x = m_pSolver->solve(input);
1005 }
1006
1007public: // *** Getters/setters ***
1008
1010 int rows() const { return m_mat.rows(); }
1011
1013 int cols() const { return m_mat.cols(); }
1014
1015}; // class gsINSPrecondSchurMSIMPLER
1016
1017
1018// === Schur Stokes ==== //
1019
1020template <class T, int MatOrder>
1021class gsINSPrecondSchurStokes : public gsINSPrecondBlock<T>
1022{
1023
1024public:
1025 typedef gsINSPrecondBlock<T> Base;
1026
1027protected: // *** Class members ***
1028
1030 T m_visc;
1031
1032public: // *** Smart pointers ***
1033
1034 typedef memory::shared_ptr<gsINSPrecondSchurStokes> Ptr;
1035 typedef memory::unique_ptr<gsINSPrecondSchurStokes> uPtr;
1036
1037public: // *** Constructor/destructor ***
1038
1042 gsINSPrecondSchurStokes(const std::map<std::string, gsSparseMatrix<T, MatOrder> >& mat, const gsOptionList& opt)
1043 {
1044 // S = diag(Mp)
1045
1046 m_visc = opt.getReal("visc");
1047
1048 const gsSparseMatrix<T, MatOrder>& presM = mat.at("matMp");
1049 diagInvMatrix_into(presM, m_mat, 1, opt.getSwitch("lumpingM"));
1050 }
1051
1052public: // *** Static functions ***
1053
1057 static uPtr make(const std::map<std::string, gsSparseMatrix<T, MatOrder> >& mat, const gsOptionList& opt)
1058 {
1059 return memory::make_unique(new gsINSPrecondSchurStokes<T, MatOrder>(mat, opt));
1060 }
1061
1062public: // *** Member functions ***
1063
1068 void apply(const gsMatrix<T> & input, gsMatrix<T> & x) const
1069 {
1070 GISMO_ASSERT(input.rows() == this->rows(), "Wrong input size.");
1071 x.resize(this->rows(), 1);
1072
1073 x = - m_visc * m_mat * input;
1074 }
1075
1076public: // *** Getters/setters ***
1077
1079 int rows() const { return m_mat.rows(); }
1080
1082 int cols() const { return m_mat.cols(); }
1083
1084}; // class gsINSPrecondSchurStokes
1085
1086
1087} // namespace gismo
1088
1089#ifndef GISMO_BUILD_LIB
1090#include GISMO_HPP_HEADER(gsINSPrecondBlocks.hpp)
1091#endif
Class for block F of block preconditioner of the form.
Definition gsINSPrecondBlocks.h:167
static uPtr make(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Returns a unique pointer to a newly created instance.
Definition gsINSPrecondBlocks.h:205
gsINSPrecondBlockF(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Constructor.
Definition gsINSPrecondBlocks.h:192
int cols() const
Returns the number of columns of the block.
Definition gsINSPrecondBlocks.h:225
virtual std::string getName() const
Returns the block name as a string.
Definition gsINSPrecondBlocks.h:228
void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
Apply the block. Computes the vector \fx = F^{-1} y\f.
Definition gsINSPrecondBlocks.hpp:60
int rows() const
Returns the number of rows of the block.
Definition gsINSPrecondBlocks.h:222
Base class for block F of block preconditioner of the form.
Definition gsINSPrecondBlocks.h:335
static uPtr make(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Returns a unique pointer to a newly created instance.
Definition gsINSPrecondBlocks.h:380
gsINSPrecondBlockFdiag(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Constructor.
Definition gsINSPrecondBlocks.h:359
int cols() const
Returns the number of columns of the block.
Definition gsINSPrecondBlocks.h:399
virtual std::string getName() const
Returns the block name as a string.
Definition gsINSPrecondBlocks.h:402
void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
Apply the block. Computes the vector \fx = F^{-1} y\f.
Definition gsINSPrecondBlocks.hpp:82
int rows() const
Returns the number of rows of the block.
Definition gsINSPrecondBlocks.h:396
Base class for block F of (modified) block preconditioner of the form.
Definition gsINSPrecondBlocks.h:426
static uPtr make(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Returns a unique pointer to a newly created instance.
Definition gsINSPrecondBlocks.h:473
gsINSPrecondBlockFmod(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Constructor.
Definition gsINSPrecondBlocks.h:452
int cols() const
Returns the number of columns of the block.
Definition gsINSPrecondBlocks.h:492
virtual std::string getName() const
Returns the block name as a string.
Definition gsINSPrecondBlocks.h:495
void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
Apply the block. Computes the vector \fx = F^{-1} y\f.
Definition gsINSPrecondBlocks.hpp:97
int rows() const
Returns the number of rows of the block.
Definition gsINSPrecondBlocks.h:489
Class for block F of block preconditioner of the form.
Definition gsINSPrecondBlocks.h:252
static uPtr make(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Returns a unique pointer to a newly created instance.
Definition gsINSPrecondBlocks.h:289
gsINSPrecondBlockFwhole(const gsSparseMatrix< T, MatOrder > &matNS, const gsOptionList &opt)
Constructor.
Definition gsINSPrecondBlocks.h:276
int cols() const
Returns the number of columns of the block.
Definition gsINSPrecondBlocks.h:308
virtual std::string getName() const
Returns the block name as a string.
Definition gsINSPrecondBlocks.h:311
void apply(const gsMatrix< T > &input, gsMatrix< T > &x) const
Apply the block. Computes the vector \fx = F^{-1} y\f.
Definition gsINSPrecondBlocks.hpp:72
int rows() const
Returns the number of rows of the block.
Definition gsINSPrecondBlocks.h:305
Base class for block F of (modified) block preconditioner of the form.
Definition gsINSPrecondBlocks.h:99
gsINSPrecondBlockMod(const gsOptionList &opt)
Constructor.
Definition gsINSPrecondBlocks.h:122
A base class for individual blocks of block preconditioners.
Definition gsINSPrecondBlocks.h:28
void setupLinSolver(gsSparseSolver< T > &solver)
Set up the linear solver for the block.
Definition gsINSPrecondBlocks.hpp:38
gsINSPrecondBlock()
Constructor.
Definition gsINSPrecondBlocks.h:46
gsSparseSolver< T > * createLinSolver()
Returns a pointer to new linear solver (direct or iterative).
Definition gsINSPrecondBlocks.hpp:20
gsINSPrecondBlock(const gsOptionList &opt)
Constructor.
Definition gsINSPrecondBlocks.h:53
Simple abstract class for discrete operators.
Definition gsLinearOperator.h:29
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Class which holds a list of parameters/options, and provides easy access to them.
Definition gsOptionList.h:33
bool getSwitch(const std::string &label) const
Reads value for option label from options.
Definition gsOptionList.cpp:51
const index_t & getInt(const std::string &label) const
Reads value for option label from options.
Definition gsOptionList.cpp:37
Real getReal(const std::string &label) const
Reads value for option label from options.
Definition gsOptionList.cpp:44
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition gsSparseMatrix.h:139
Abstract class for solvers. The solver interface is base on 3 methods: -compute set the system matrix...
Definition gsSparseSolver.h:67
#define GISMO_NO_IMPLEMENTATION
Definition gsDebug.h:129
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Simple abstract class for (discrete) linear operators.
Simple adapter classes to use matrices or linear solvers as gsLinearOperators.
unique_ptr< T > make_unique(T *x)
Definition gsMemory.h:198
The G+Smo namespace, containing all definitions for the library.
void diagInvMatrix_into(const gsSparseMatrix< T, MatOrder > &mat, gsSparseMatrix< T, MatOrder > &diagInv, int repeat, bool lumping=false)
Fill a diagonal approximation of an inverse matrix.
Definition gsFlowUtils.h:137