LifeV
lifev/electrophysiology/unit/test_StimulusPacingProtocol/main.cpp
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
30 
31  @date
32  @author
33  @contributor
34  @mantainer
35  */
36 
37 // Tell the compiler to ignore specific kind of warnings:
38 #pragma GCC diagnostic ignored "-Wunused-variable"
39 #pragma GCC diagnostic ignored "-Wunused-parameter"
40 
41 #include <Epetra_ConfigDefs.h>
42 #ifdef EPETRA_MPI
43 #include <mpi.h>
44 #include <Epetra_MpiComm.h>
45 #else
46 #include <Epetra_SerialComm.h>
47 #endif
48 
49 //Tell the compiler to restore the warning previously silented
50 #pragma GCC diagnostic warning "-Wunused-variable"
51 #pragma GCC diagnostic warning "-Wunused-parameter"
52 
53 #include <fstream>
54 #include <string>
55 
56 
57 #include <lifev/electrophysiology/solver/ElectroETAMonodomainSolver.hpp>
58 
59 
60 #include <lifev/electrophysiology/stimulus/StimulusPacingProtocol.hpp>
61 #include <lifev/core/LifeV.hpp>
62 
63 #include <Teuchos_RCP.hpp>
64 #include <Teuchos_ParameterList.hpp>
65 #include "Teuchos_XMLParameterListHelpers.hpp"
66 #include <Teuchos_ScalarTraitsDecl.hpp>
67 
68 #include <sys/stat.h>
69 #include <time.h> /* time */
70 
71 using namespace LifeV;
72 
73 Int main ( Int argc, char** argv )
74 {
75 
76  // bool verbose = false;
77 
78  //! Initializing Epetra communicator
79  MPI_Init (&argc, &argv);
80  std::shared_ptr<Epetra_Comm> Comm ( new Epetra_MpiComm (MPI_COMM_WORLD) );
81 
82  //*********************************************//
83  // creating output folder
84  //*********************************************//
85  GetPot command_line (argc, argv);
86 
87 
88  const string stimulus_datafile_name = command_line.follow ("StimulationParameters.xml", 2, "-s", "--stimulus");
89  Teuchos::ParameterList stimulusList = * ( Teuchos::getParametersFromXmlFile ( stimulus_datafile_name ) );
90 
91  StimulusPacingProtocol stimulus;
92  stimulus.setParameters ( stimulusList );
93  if ( Comm->MyPID() == 0 )
94  {
95  stimulus.showMe();
96  }
97 
98  Real DeltaX, DeltaY, DeltaZ, DeltaT;
99  DeltaX = 1000;
100  DeltaY = 1000;
101  DeltaZ = 1000;
102  DeltaT = 1000;
103 
104  Teuchos::ScalarTraits<Real>::seedrandom (time (NULL) );
105  stimulus.setPacingProtocol ("FCL");
106  if ( Comm->MyPID() == 0 )
107  {
108  std::cerr << "Starting test" << std::endl;
109  }
110 
111 
112  for (ID i = 0; i < 100; i++)
113  {
114  Real x, y, z, t;
115  x = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_X", 1.0 ) ) * DeltaX;
116  y = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_Y", 1.0 ) ) * DeltaY;
117  z = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_Z", 1.0 ) ) * DeltaZ;
118  t = (Teuchos::ScalarTraits<Real>::random() + 1.0 ) * DeltaX;
119  stimulus.appliedCurrent ( t, x, y, z, i );
120  }
121 
122  stimulus.setPacingProtocol ("FCL-ExtraSt");
123 
124  for (ID i = 0; i < 100; i++)
125  {
126  Real x, y, z, t;
127  x = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_X", 1.0 ) ) * DeltaX;
128  y = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_Y", 1.0 ) ) * DeltaY;
129  z = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_Z", 1.0 ) ) * DeltaZ;
130  t = (Teuchos::ScalarTraits<Real>::random() + 1.0 ) * DeltaX;
131  stimulus.appliedCurrent ( t, x, y, z, i );
132  }
133  stimulus.setPacingProtocol ("S1S2Pro");
134 
135  for (ID i = 0; i < 100; i++)
136  {
137  Real x, y, z, t;
138  x = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_X", 1.0 ) ) * DeltaX;
139  y = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_Y", 1.0 ) ) * DeltaY;
140  z = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_Z", 1.0 ) ) * DeltaZ;
141  t = (Teuchos::ScalarTraits<Real>::random() + 1.0 ) * DeltaX;
142  stimulus.appliedCurrent ( t, x, y, z, i );
143  }
144 
145  stimulus.setPacingProtocol ("DynPro");
146 
147  for (ID i = 0; i < 100; i++)
148  {
149  Real x, y, z, t;
150  x = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_X", 1.0 ) ) * DeltaX;
151  y = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_Y", 1.0 ) ) * DeltaY;
152  z = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_Z", 1.0 ) ) * DeltaZ;
153  t = (Teuchos::ScalarTraits<Real>::random() + 1.0 ) * DeltaX;
154  stimulus.appliedCurrent ( t, x, y, z, i );
155  }
156 
157  if ( Comm->MyPID() == 0 )
158  {
159  std::cerr << "Ending test" << std::endl;
160  }
161 
162 
163  MPI_Barrier (MPI_COMM_WORLD);
164  MPI_Finalize();
165 
166  return ( EXIT_SUCCESS );
167 }
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
Definition: GetPot.hpp:507
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
uint32_type ID
IDs.
Definition: LifeV.hpp:194
double Real
Generic real data.
Definition: LifeV.hpp:175
int main(int argc, char **argv)