LifeV
lifev/electrophysiology/unit/test_StimulusSingleSource/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/StimulusSingleSource.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 std::string stimulus_datafile_name = command_line.follow ("StimulationParameters.xml", 2, "-s", "--stimulus");
89  Teuchos::ParameterList stimulusList = * ( Teuchos::getParametersFromXmlFile ( stimulus_datafile_name ) );
90 
91  StimulusSingleSource 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  if ( Comm->MyPID() == 0 )
105  {
106  std::cerr << "Starting test" << std::endl;
107  }
108  Teuchos::ScalarTraits<Real>::seedrandom (time (NULL) );
109  for (ID i = 0; i < 100; i++)
110  {
111  Real x, y, z, t;
112  x = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_X", 1.0 ) ) * DeltaX;
113  y = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_Y", 1.0 ) ) * DeltaY;
114  z = (Teuchos::ScalarTraits<Real>::random() + stimulusList.get ( "pacing_site_Z", 1.0 ) ) * DeltaZ;
115  t = (Teuchos::ScalarTraits<Real>::random() + 1.0 ) * DeltaX;
116  stimulus.appliedCurrent ( t, x, y, z, i );
117  }
118  if ( Comm->MyPID() == 0 )
119  {
120  std::cerr << "Ending test" << std::endl;
121  }
122 
123  MPI_Barrier (MPI_COMM_WORLD);
124  MPI_Finalize();
125 
126  return ( EXIT_SUCCESS );
127 }
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)
const std::string follow(const char *Default, unsigned No, const char *Option,...)
Definition: GetPot.hpp:1510