LifeV
HeartMonodomainSolver.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief Class for solving the Monodomain equations in electrophysiology.
30 
31  @date 11-2007
32  @author Lucia Mirabella <lucia.mirabella@mail.polimi.it> and Mauro Perego <mauro.perego@polimi.it>
33 
34  @contributors J.Castelneau (INRIA), Ricardo Ruiz-Baier <ricardo.ruiz@epfl.ch>
35  @mantainer Ricardo Ruiz-Baier <ricardo.ruiz@epfl.ch>
36  @last update 11-2010
37  */
38 
39 #ifndef _MONODOMAINSOLVER_H_
40 #define _MONODOMAINSOLVER_H_
41 
42 #include <lifev/core/array/MatrixElemental.hpp>
43 #include <lifev/core/array/VectorElemental.hpp>
44 #include <lifev/core/fem/AssemblyElemental.hpp>
45 #include <lifev/core/fem/Assembly.hpp>
46 #include <lifev/core/fem/BCManage.hpp>
47 #include <lifev/core/algorithm/SolverAztecOO.hpp>
48 #include <lifev/core/array/MapEpetra.hpp>
49 #include <lifev/core/array/MatrixEpetra.hpp>
50 #include <lifev/core/array/VectorEpetra.hpp>
51 #include <lifev/core/fem/SobolevNorms.hpp>
52 #include <lifev/core/fem/GeometricMap.hpp>
53 #include <lifev/heart/solver/HeartMonodomainData.hpp>
54 #include <lifev/core/util/LifeChrono.hpp>
55 #include <boost/shared_ptr.hpp>
56 #include <lifev/core/fem/FESpace.hpp>
57 #include <lifev/heart/solver/HeartStiffnessFibers.hpp>
58 #include <lifev/core/fem/TimeAdvanceBDF.hpp>
59 
60 namespace LifeV
61 {
62 
63 //! monodomainSolver - Class featuring the usual solver for monodomain equations
64 
65 template < typename Mesh,
66  typename SolverType = LifeV::SolverAztecOO >
68 {
69 
70 public:
71 
72  //! @name Type definitions
73  //@{
74 
76  typedef Real ( *Function ) ( const Real& t,
77  const Real& x,
78  const Real& y,
79  const Real& z,
80  const ID& id );
81  typedef std::function < Real ( Real const&, Real const&, Real const&,
82  Real const&, ID const& ) > source_Type;
83 
84  typedef Mesh mesh_Type;
85  typedef BCHandler bcHandlerRaw_Type;
87 
88  typedef typename SolverType::matrix_type matrix_Type;
90  typedef typename SolverType::vector_type vector_Type;
91 
92  typedef typename SolverType::prec_raw_type preconditionerRaw_Type;
93  typedef typename SolverType::prec_type preconditioner_Type;
94 
95 
96  //@}
97 
98 
99 
100  //! @name Constructors & Destructor
101  //@{
102 
103  //! Constructor
104  /*!
105  * @param dataType
106  * @param potential FE space
107  * @param bcHandler boundary conditions for potential
108  * @param Epetra communicator
109  */
110 
111  HeartMonodomainSolver ( const data_type& dataType,
112  FESpace<Mesh, MapEpetra>& uFESpace,
113  BCHandler& bcHandler,
114  std::shared_ptr<Epetra_Comm>& comm);
115 
116  //! Destructor
117  virtual ~HeartMonodomainSolver() {}
118 
119  //@}
120 
121  //! @name Methods
122  //@{
123 
124  //! Updates sources, bc treatment and solve the monodomain system
125  virtual void PDEiterate ( bcHandlerRaw_Type& bch );
126 
127  //! Sets up the system solver
128  virtual void setup ( const GetPot& dataFile );
129 
130  //! Builds time independent parts of PDE system
131  virtual void buildSystem();
132 
133  //! Updates time dependent parts of PDE system
134  virtual void updatePDESystem (Real alpha, vector_Type& sourceVec);
135 
136  //! Updates time dependent parts of PDE system
137  virtual void updatePDESystem ( vector_Type& sourceVec );
138 
139  //! Initialize
140  void initialize ( const source_Type& );
141  void initialize ( const Function& );
142  void initialize ( const vector_Type& );
143 
144  //! Returns the local solution vector
146  {
148  }
149 
150  const vector_Type& fiberVector() const
151  {
152  return M_fiberVector;
153  }
154 
155  //! Returns the local residual vector
156  const vector_Type& residual() const
157  {
158  return M_residual;
159  }
160 
161  //! Returns u FE space
163  {
164  return M_uFESpace;
165  }
166 
167  //! Setting of the boundary conditions
168  void setBC ( BCHandler& BCh_u )
169  {
170  M_BChandlerElectric = &BCh_u;
171  M_setBC = true;
172  }
173 
174  //! Postprocessing
175  void postProcessing (bool _writeMesh = false);
176 
178  {
179  M_resetPreconditioner = true;
180  }
181 
182  //! Return maps
184  {
185  return *M_localMap.map (Repeated);
186  }
187 
189  {
190  return *M_localMapVector.map (Repeated);
191  }
192 
193  MapEpetra const& getMap() const
194  {
195  return M_localMap;
196  }
197 
198  void recomputeMatrix (bool const recomp)
199  {
201  }
202 
204  {
205  return *M_massMatrix;
206  }
207 
208  //@}
209 protected:
210 
211  //! Solves PDE system
213 
214  //! Apply BC
216 
217  //! Data
219 
220  //! u FE space
222 
223  //! MPI communicator
224  //Epetra_Comm* M_comm;
227 
228  //! Monodomain BC
230  bool M_setBC;
231 
232  //! Map
235 
236  //! mass matrix
238 
239  //! Stiff matrix: D*stiff
241 
243 
244  //! Right hand side for the PDE
246 
247  //! Global solution _u
249 
250  //! Local fibers vector
252 
253  //! residual
255 
256  //! Solver
257  SolverType M_linearSolver;
258 
260 
262 
263  //! Boolean that indicates if output is sent to cout
264  bool M_verbose;
265 
266  //! Boolean that indicates if the matrix is updated for the current iteration
267  bool M_updated;
268 
269  //! Boolean that indicates if the precond has to be recomputed
272 
273  //! Integer storing the max number of solver iteration with prec recomputing
275 
276  //! Boolean that indicates if the matrix has to be recomputed
278 
279 private:
280 
281  //! Elementary matrices
283  MatrixElemental M_massElementaryMatrix;
285  UInt dim_u() const
286  {
287  return M_uFESpace.dim();
288  }
289 
290 }; // class MonodomainSolver
291 
292 
293 
294 //
295 // IMPLEMENTATION
296 //
297 
298 //! Constructors
299 template<typename Mesh, typename SolverType>
300 HeartMonodomainSolver<Mesh, SolverType>::
302  FESpace<Mesh, MapEpetra>& uFESpace,
303  BCHandler& BCh_u,
304  std::shared_ptr<Epetra_Comm>& comm ) :
305  M_data ( dataType ),
306  M_uFESpace ( uFESpace ),
307  M_comm ( comm ),
308  M_me ( M_comm->MyPID() ),
309  M_BChandlerElectric ( &BCh_u ),
310  M_setBC ( true ),
311  M_localMap ( M_uFESpace.map() ),
313  M_massMatrix ( ),
314  M_stiffnessMatrix ( ),
315  M_matrNoBC ( ),
316  M_rhsNoBC ( M_localMap ),
320  M_linearSolver ( ),
321  M_preconditioner ( ),
322  M_verbose ( M_me == 0),
323  M_updated ( false ),
324  M_reusePreconditioner ( true ),
325  M_resetPreconditioner ( true ),
326  M_maxIteration ( -1 ),
327  M_recomputeMatrix ( false ),
330 {
331 
332  if (M_data.hasFibers() )
333  {
334  std::stringstream MyPID;
335  ifstream fibers (M_data.fibersFile().c_str() );
336 
337  std::cout << "fiber_file: " << M_data.fibersFile().c_str() << std::endl;
338  UInt NumGlobalElements = M_localMapVector.map (Repeated)->NumGlobalElements();
339  std::vector<Real> fiber_global_vector (NumGlobalElements);
340 
341  for ( UInt i = 0; i < NumGlobalElements; ++i)
342  {
343  fibers >> fiber_global_vector[i];
344  }
345  UInt NumMyElements = M_localMapVector.map (Repeated)->NumMyElements();
346  for (UInt j = 0; j < NumMyElements; ++j)
347  {
348  UInt ig = M_localMapVector.map (Repeated)->MyGlobalElements() [j];
349  M_fiberVector[ig] = fiber_global_vector[ig];
350  }
351  std::cout << std::endl;
352  fiber_global_vector.clear();
353  }
354 }
355 
356 
357 template<typename Mesh, typename SolverType>
358 void HeartMonodomainSolver<Mesh, SolverType>::setup ( const GetPot& dataFile )
359 {
360 
361  M_diagonalize = dataFile ( "electric/space_discretization/diagonalize", 1. );
362 
363  M_reusePreconditioner = dataFile ( "electric/prec/reuse", true);
364 
365  M_linearSolver.setCommunicator (M_comm);
366 
367  M_linearSolver.setDataFromGetPot ( dataFile, "electric/solver" );
368 
369  M_maxIteration = dataFile ( "electric/solver/max_iter", -1);
370 
371  std::string precType = dataFile ( "electric/prec/prectype", "Ifpack");
372 
373  M_preconditioner.reset ( PRECFactory::instance().createObject ( precType ) );
374  ASSERT (M_preconditioner.get() != 0, "monodomainSolver : Preconditioner not set");
375 
376  M_preconditioner->setDataFromGetPot ( dataFile, "electric/prec" );
377 }
378 
379 
380 template<typename Mesh, typename SolverType>
381 void HeartMonodomainSolver<Mesh, SolverType>::buildSystem()
382 {
383  M_massMatrix.reset ( new matrix_Type (M_localMap) );
384  M_stiffnessMatrix.reset ( new matrix_Type (M_localMap) );
385 
386  if (M_verbose)
387  {
388  std::cout << " f- Computing constant matrices ... ";
389  }
390 
391  LifeChrono chrono;
392 
393  LifeChrono chronoDer;
394  LifeChrono chronoStiff;
395  LifeChrono chronoMass;
396 
397 
398  LifeChrono chronoStiffAssemble;
399  LifeChrono chronoMassAssemble;
400  LifeChrono chronoZero;
401 
402  M_comm->Barrier();
403 
404  chrono.start();
405 
406  //! Elementary computation and matrix assembling
407  //! Loop on elements
408 
409  for ( UInt iVol = 0; iVol < M_uFESpace.mesh()->numVolumes(); iVol++ )
410  {
411  chronoZero.start();
412 
413  M_stiffnessElementaryMatrix.zero();
414  M_massElementaryMatrix.zero();
415 
416  chronoZero.stop();
417 
418  chronoStiff.start();
420  {
421  case 0:
422  M_uFESpace.fe().updateFirstDeriv ( M_uFESpace.mesh()->volumeList ( iVol ) );
423  if (M_data.hasFibers() )
424  {
425  stiff ( M_data.longitudinalConductivity(),
426  M_data.transversalConductivity(),
427  M_fiberVector,
428  M_stiffnessElementaryMatrix,
429  M_uFESpace.fe(),
430  M_uFESpace.dof(),
431  0,
432  0);
433  }
434  else
435  {
436  AssemblyElemental::stiff ( M_data.diffusivity(), M_stiffnessElementaryMatrix, M_uFESpace.fe(), 0, 0 );
437  }
438  break;
439 
440  case 1:
441  M_uFESpace.fe().updateFirstDerivQuadPt ( M_uFESpace.mesh()->volumeList ( iVol ) );
442  if (M_data.hasFibers() )
443  {
444  stiff ( M_data.reducedConductivitySphere(),
445  M_data.longitudinalConductivity(),
446  M_data.transversalConductivity(),
447  M_fiberVector,
448  M_stiffnessElementaryMatrix,
449  M_uFESpace.fe(),
450  M_uFESpace.dof(), 0, 0);
451  }
452  else
453  {
454  stiff ( M_data.reducedConductivitySphere(),
455  M_data.diffusivity(), M_stiffnessElementaryMatrix,
456  M_uFESpace.fe(),
457  M_uFESpace.dof(),
458  0,
459  0);
460  }
461  break;
462  case 2:
463  M_uFESpace.fe().updateFirstDerivQuadPt ( M_uFESpace.mesh()->volumeList ( iVol ) );
464  if (M_data.hasFibers() )
465  {
466  stiff ( M_data.reducedConductivityCylinder(),
467  M_data.longitudinalConductivity(),
468  M_data.transversalConductivity(),
469  M_fiberVector,
470  M_stiffnessElementaryMatrix,
471  M_uFESpace.fe(),
472  M_uFESpace.dof(),
473  0,
474  0);
475  }
476  else
477  {
478  stiff ( M_data.reducedConductivityCylinder(),
479  M_data.diffusivity(),
480  M_stiffnessElementaryMatrix,
481  M_uFESpace.fe(),
482  M_uFESpace.dof(),
483  0,
484  0);
485  }
486  break;
487  case 3:
488  M_uFESpace.fe().updateFirstDerivQuadPt ( M_uFESpace.mesh()->volumeList ( iVol ) );
489  if (M_data.hasFibers() )
490  {
491  stiff ( M_data.reducedConductivityBox(),
492  M_data.longitudinalConductivity(),
493  M_data.transversalConductivity(),
494  M_fiberVector,
495  M_stiffnessElementaryMatrix,
496  M_uFESpace.fe(),
497  M_uFESpace.dof(),
498  0,
499  0);
500  }
501  else
502  {
503  stiff ( M_data.reducedConductivityBox(),
504  M_data.diffusivity(),
505  M_stiffnessElementaryMatrix,
506  M_uFESpace.fe(),
507  M_uFESpace.dof(),
508  0,
509  0);
510  }
511  break;
512  }
513  chronoStiff.stop();
514 
515  chronoMass.start();
516  AssemblyElemental::mass ( 1., M_massElementaryMatrix, M_uFESpace.fe(), 0, 0 );
517  chronoMass.stop();
518 
519 
520  chronoStiffAssemble.start();
521  assembleMatrix ( *M_stiffnessMatrix,
522  M_stiffnessElementaryMatrix,
523  M_uFESpace.fe(),
524  M_uFESpace.fe(),
525  M_uFESpace.dof(),
526  M_uFESpace.dof(),
527  0, 0,
528  0, 0);
529  chronoStiffAssemble.stop();
530 
531 
532  chronoMassAssemble.start();
533  assembleMatrix ( *M_massMatrix,
534  M_massElementaryMatrix,
535  M_uFESpace.fe(),
536  M_uFESpace.fe(),
537  M_uFESpace.dof(),
538  M_uFESpace.dof(),
539  0, 0,
540  0, 0);
541  chronoMassAssemble.stop();
542 
543  }
544 
546 
547  M_comm->Barrier();
548 
549  chrono.stop();
550  if (M_verbose)
551  {
552  std::cout << "done in " << chrono.diff() << " s.\n" << std::flush;
553  }
554 
555  if (M_verbose)
556  {
557  std::cout << " f- Finalizing the matrices ... " << std::flush;
558  }
559  chrono.start();
560 
561  M_stiffnessMatrix->globalAssemble();
562  M_massMatrix->globalAssemble();
563 
564  M_comm->Barrier();
565 
566  M_matrNoBC.reset (new matrix_Type (M_localMap, M_stiffnessMatrix->meanNumEntries() ) );
567 
568  //! Computing 1/dt * M + K
569 
570  *M_matrNoBC += *M_stiffnessMatrix;
571 
572  *M_matrNoBC += *M_massMatrix * massCoefficient;
573 
574  M_matrNoBC->globalAssemble();
575 
576  chrono.stop();
577  if (M_verbose)
578  {
579  std::cout << "done in " << chrono.diff() << " s." << std::endl;
580  }
581 
582  if (false)
583  std::cout << "partial times: \n"
584  << " Der " << chronoDer.diffCumul() << " s.\n"
585  << " Zero " << chronoZero.diffCumul() << " s.\n"
586  << " Stiff " << chronoStiff.diffCumul() << " s.\n"
587  << " Stiff Assemble " << chronoStiffAssemble.diffCumul() << " s.\n"
588  << " Mass " << chronoMass.diffCumul() << " s.\n"
589  << " Mass Assemble " << chronoMassAssemble.diffCumul() << " s.\n"
590  << std::endl;
591 
592 }
593 
594 template<typename Mesh, typename SolverType>
595 void HeartMonodomainSolver<Mesh, SolverType>::
596 initialize ( const source_Type& u0 )
597 {
598 
599  vector_Type u (M_uFESpace.map() );
600 
601  M_uFESpace.interpolate (u0, u, 0.);
602 
603  initialize (u);
604 }
605 
606 
607 
608 template<typename Mesh, typename SolverType>
609 void HeartMonodomainSolver<Mesh, SolverType>::
610 initialize ( const Function& u0 )
611 {
612 
613  vector_Type u (M_uFESpace.map() );
614  M_uFESpace.interpolate (u0, u, 0.);
615 
616  initialize (u);
617 }
618 
619 
620 template<typename Mesh, typename SolverType>
621 void HeartMonodomainSolver<Mesh, SolverType>::
622 initialize ( const vector_Type& u0 )
623 {
624 
626 
627 }
628 
629 
630 template<typename Mesh, typename SolverType>
631 void HeartMonodomainSolver<Mesh, SolverType>::
633  vector_Type& sourceVec )
634 {
635 
636  LifeChrono chrono;
637 
638  if (M_verbose)
639  std::cout << " f- Updating mass term and right hand side... "
640  << std::flush;
641 
642  chrono.start();
643 
644  M_rhsNoBC = sourceVec;
645  M_rhsNoBC.globalAssemble();
646 
647  chrono.stop();
648 
649  if (M_verbose)
650  {
651  std::cout << "done in " << chrono.diff() << " s.\n" << std::flush;
652  }
653 
654  M_updated = false;
655 
656  if (M_recomputeMatrix)
657  {
659  }
660 
661  if (M_verbose)
662  std::cout << " f- Copying the matrices ... "
663  << std::flush;
664 
665  chrono.start();
666 
667  M_matrNoBC.reset (new matrix_Type (M_localMap, M_stiffnessMatrix->meanNumEntries() ) );
668 
669  *M_matrNoBC += *M_stiffnessMatrix;
670 
671  *M_matrNoBC += *M_massMatrix * alpha;
672 
673 
674  chrono.stop();
675  if (M_verbose) std::cout << "done in " << chrono.diff() << " s.\n"
676  << std::flush;
677 
678 
679 
680  M_updated = true;
681  M_matrNoBC->globalAssemble();
682 
683 }
684 
685 template<typename Mesh, typename SolverType>
686 void HeartMonodomainSolver<Mesh, SolverType>::
688 {
689 
690  LifeChrono chrono;
691 
692  if (M_verbose)
693  std::cout << " f- Updating right hand side... "
694  << std::flush;
695 
696  chrono.start();
697 
698  M_rhsNoBC = sourceVec;
699  M_rhsNoBC.globalAssemble();
700 
701  chrono.stop();
702 
703  if (M_verbose)
704  {
705  std::cout << "done in " << chrono.diff() << " s.\n" << std::flush;
706  }
707 
708 }
709 
710 
711 
712 template<typename Mesh, typename SolverType>
713 void HeartMonodomainSolver<Mesh, SolverType>::PDEiterate ( bcHandlerRaw_Type& bch )
714 {
715 
716  LifeChrono chrono;
717  chrono.start();
718 
719  matrixPtr_Type matrFull ( new matrix_Type (*M_matrNoBC) );
720  vector_Type rhsFull = M_rhsNoBC;
721 
722  chrono.stop();
723 
724  if (M_verbose)
725  std::cout << "done in " << chrono.diff() << " s.\n"
726  << std::flush;
727 
728  // boundary conditions update
729  M_comm->Barrier();
730  if (M_verbose) std::cout << " f- Applying boundary conditions ... "
731  << std::flush;
732 
733  chrono.start();
734 
735  applyBoundaryConditions ( *matrFull, rhsFull, bch);
736 
737  chrono.stop();
738 
739  M_comm->Barrier();
740 
741  if (M_verbose)
742  {
743  std::cout << "done in " << chrono.diff() << " s.\n" << std::flush;
744  }
745 
746  //! Solving the system
747  solveSystem ( matrFull, rhsFull );
748 
749  // M_residual = M_rhsNoBC;
750  // M_residual -= *M_matrNoBC*M_solutionTransmembranePotential;
751 
752 } // iterate()
753 
754 
755 
756 template<typename Mesh, typename SolverType>
757 void HeartMonodomainSolver<Mesh, SolverType>::solveSystem ( matrixPtr_Type matrFull,
758  vector_Type& rhsFull )
759 {
760  LifeChrono chrono;
761 
762  if (M_verbose)
763  {
764  std::cout << " f- Setting up the solver ... ";
765  }
766 
767  chrono.start();
768  M_linearSolver.setMatrix (*matrFull);
769  chrono.stop();
770 
771  if (M_verbose)
772  std::cout << "done in " << chrono.diff() << " s.\n"
773  << std::flush;
774 
776  {
777  chrono.start();
778 
779  if (M_verbose)
780  {
781  std::cout << " f- Computing the precond ... ";
782  }
783 
784  M_preconditioner->buildPreconditioner (matrFull);
785 
786  Real condest = M_preconditioner->condest();
787 
788  M_linearSolver.setPreconditioner (M_preconditioner);
789 
790  chrono.stop();
791  if (M_verbose)
792  {
793  std::cout << "done in " << chrono.diff() << " s.\n";
794  std::cout << "Estimated condition number = " << condest << "\n" << std::flush;
795  }
796 
797  M_resetPreconditioner = false;
798  }
799  else
800  {
801  if (M_verbose)
802  {
803  std::cout << "f- Reusing precond ... \n" << std::flush;
804  }
805  }
806 
807 
808  chrono.start();
809 
810  if (M_verbose)
811  {
812  std::cout << "f- Solving system ... ";
813  }
814 
815  Int numIter = M_linearSolver.solve (M_solutionTransmembranePotential, rhsFull);
816 
817  chrono.stop();
818 
819  if (M_verbose)
820  {
821  std::cout << "\ndone in " << chrono.diff()
822  << " s. ( " << numIter << " iterations. ) \n"
823  << std::flush;
824  }
825 
826 
827  if (numIter > M_maxIteration)
828  {
829  M_resetPreconditioner = true;
830  }
831 
832  M_comm->Barrier();
833 
834 }
835 
836 
837 
838 template<typename Mesh, typename SolverType>
840  vector_Type& rhs,
841  bcHandlerRaw_Type& BCh )
842 {
843 
844  // BC manage for the PDE
845  if ( !BCh.bcUpdateDone() )
846  {
847  BCh.bcUpdate ( *M_uFESpace.mesh(), M_uFESpace.feBd(), M_uFESpace.dof() );
848  }
849 
850  vector_Type rhsFull (M_rhsNoBC, Repeated, Zero);
851 
852  bcManage ( matrix, rhs, *M_uFESpace.mesh(), M_uFESpace.dof(),
853  BCh, M_uFESpace.feBd(), 1., M_data.time() );
854 
855  rhs = rhsFull;
856  if ( BCh.hasOnlyEssential() && M_diagonalize )
857  {
858  matrix.diagonalize ( 1 * dim_u(),
860  rhs,
861  0.);
862  }
863 
864 } // applyBoundaryCondition
865 
866 
867 } // namespace LifeV
868 
869 
870 #endif //_MONODOMAINSOLVER_H_
virtual void updatePDESystem(vector_Type &sourceVec)
Updates time dependent parts of PDE system.
virtual void buildSystem()
Builds time independent parts of PDE system.
vector_Type M_fiberVector
Local fibers vector.
double operator()(const char *VarName, const double &Default) const
Definition: GetPot.hpp:2033
const Real & volumeSurfaceRatio() const
Chi.
HeartMonodomainSolver(const data_type &dataType, FESpace< Mesh, MapEpetra > &uFESpace, BCHandler &bcHandler, std::shared_ptr< Epetra_Comm > &comm)
Constructor.
SolverType::vector_type vector_Type
std::function< Real(Real const &, Real const &, Real const &, Real const &, ID const &) > source_Type
void initialize(const vector_Type &)
FESpace - Short description here please!
Definition: FESpace.hpp:78
matrixPtr_Type M_stiffnessMatrix
Stiff matrix: D*stiff.
const vector_Type & residual() const
Returns the local residual vector.
bool M_verbose
Boolean that indicates if output is sent to cout.
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
void setBC(BCHandler &BCh_u)
Setting of the boundary conditions.
vector_Type M_rhsNoBC
Right hand side for the PDE.
SolverType::matrix_type matrix_Type
Epetra_Import const & importer()
Getter for the Epetra_Import.
Definition: MapEpetra.cpp:394
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
uint32_type ID
IDs.
Definition: LifeV.hpp:194
std::shared_ptr< bcHandlerRaw_Type > bcHandler_Type
const vector_Type & solutionTransmembranePotential() const
Returns the local solution vector.
virtual void updatePDESystem(Real alpha, vector_Type &sourceVec)
Updates time dependent parts of PDE system.
void initialize(const source_Type &)
Initialize.
bool M_recomputeMatrix
Boolean that indicates if the matrix has to be recomputed.
virtual void PDEiterate(bcHandlerRaw_Type &bch)
Updates sources, bc treatment and solve the monodomain system.
void postProcessing(bool _writeMesh=false)
Postprocessing.
double Real
Generic real data.
Definition: LifeV.hpp:175
const Real & membraneCapacitance() const
Cm.
virtual void setup(const GetPot &dataFile)
Sets up the system solver.
int operator()(const char *VarName, int Default) const
Definition: GetPot.hpp:2021
const Int & heartDiffusionFactor() const
SolverType::prec_type preconditioner_Type
BCHandler * M_BChandlerElectric
Monodomain BC.
FESpace< Mesh, MapEpetra > & M_uFESpace
u FE space
void solveSystem(matrixPtr_Type matrFull, vector_Type &rhsFull)
Solves PDE system.
void applyBoundaryConditions(matrix_Type &matrix, vector_Type &rhs, bcHandlerRaw_Type &BCh)
Apply BC.
bool operator()(const char *VarName, bool Default) const
Definition: GetPot.hpp:2008
matrixPtr_Type M_massMatrix
mass matrix
const vector_Type & fiberVector() const
FESpace< Mesh, MapEpetra > & potentialFESpace()
Returns u FE space.
const std::shared_ptr< Epetra_Comm > M_comm
MPI communicator.
Int M_maxIteration
Integer storing the max number of solver iteration with prec recomputing.
MatrixElemental M_stiffnessElementaryMatrix
Elementary matrices.
vector_Type M_solutionTransmembranePotential
Global solution _u.
SolverType::prec_raw_type preconditionerRaw_Type
virtual ~HeartMonodomainSolver()
Destructor.
std::shared_ptr< matrix_Type > matrixPtr_Type
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
bool M_updated
Boolean that indicates if the matrix is updated for the current iteration.
bool M_reusePreconditioner
Boolean that indicates if the precond has to be recomputed.