41 #pragma GCC diagnostic ignored "-Wunused-variable" 42 #pragma GCC diagnostic ignored "-Wunused-parameter" 44 #include <Epetra_ConfigDefs.h> 47 #include <Epetra_MpiComm.h> 49 #include <Epetra_SerialComm.h> 53 #pragma GCC diagnostic warning "-Wunused-variable" 54 #pragma GCC diagnostic warning "-Wunused-parameter" 57 #include <lifev/core/mesh/MeshUtility.hpp> 60 #include <lifev/electrophysiology/solver/ElectroETAMonodomainSolver.hpp> 63 #include <lifev/electrophysiology/solver/IonicModels/IonicAlievPanfilov.hpp> 66 #include <lifev/core/LifeV.hpp> 69 #include <lifev/electrophysiology/stimulus/StimulusPacingProtocol.hpp> 74 using namespace LifeV;
77 #define solutionNorm 38.2973164904655
88 MPI_Init (&argc, &argv);
89 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
90 if ( Comm->MyPID() == 0 )
92 std::cout <<
"% using MPI" << std::endl;
99 std::string problemFolder = commandLine
.follow ( "Output", 2
, "-o", "--output" );
101 if ( problemFolder.compare (
"./") )
103 problemFolder +=
"/";
105 if ( Comm->MyPID() == 0 )
107 mkdir ( problemFolder.c_str(), 0777 );
115 typedef RegionMesh<LinearTetra> mesh_Type;
117 typedef std::function < Real (
const Real& ,
121 const ID& ) > function_Type;
123 typedef ElectroETAMonodomainSolver< mesh_Type, IonicAlievPanfilov > monodomainSolver_Type;
124 typedef std::shared_ptr< monodomainSolver_Type > monodomainSolverPtr_Type;
127 typedef std::shared_ptr<vector_Type> vectorPtr_Type;
135 if ( Comm->MyPID() == 0 )
137 std::cout <<
"Importing parameters list...";
139 Teuchos::ParameterList monodomainList = * ( Teuchos::getParametersFromXmlFile (
"MonodomainSolverParamList.xml" ) );
140 if ( Comm->MyPID() == 0 )
142 std::cout <<
" Done!" << std::endl;
151 if ( Comm->MyPID() == 0 )
153 std::cout <<
"Building Constructor for Aliev Panfilov model ... ";
155 std::shared_ptr<IonicAlievPanfilov> model (
new IonicAlievPanfilov() );
156 if ( Comm->MyPID() == 0 )
158 std::cout <<
" Done!" << std::endl;
167 std::string meshName = monodomainList.get (
"mesh_name",
"lid16.mesh");
168 std::string meshPath = monodomainList.get (
"mesh_path",
"./");
180 if ( Comm->MyPID() == 0 )
182 std::cout <<
"Building Monodomain Solvers... ";
185 monodomainSolverPtr_Type monodomain (
new monodomainSolver_Type ( meshName, meshPath, dataFile, model ) );
186 if ( Comm->MyPID() == 0 )
188 std::cout <<
" Splitting solver done... ";
195 std::vector<Real> scale (3, 1.0);
198 std::vector<Real> rotate (3, 0.0);
199 std::vector<Real> translate (3, 0.0);
200 MeshUtility::MeshTransformer<mesh_Type> transformer (* (monodomain -> localMeshPtr() ) );
201 transformer.transformMesh (scale, rotate, translate);
207 monodomain -> setInitialConditions();
212 monodomain -> setParameters ( monodomainList );
217 if ( Comm->MyPID() == 0 )
219 std::cout <<
"\nSetting fibers: " ;
227 monodomain -> setupFibers();
228 function_Type fibreFunction = &fiberDistribution;
229 ElectrophysiologyUtility::setFibersFromFunction (monodomain -> fiberPtr(), monodomain -> localMeshPtr(), fibreFunction);
230 ElectrophysiologyUtility::normalize (* (monodomain -> fiberPtr() ) );
236 bool randomNoise = monodomainList.get (
"noise",
false);
239 std::vector<
bool> component (3,
false);
241 Real magnitude = monodomainList.get (
"noise_magnitude", 1e-3);
242 ElectrophysiologyUtility::addNoiseToFibers (* (monodomain -> fiberPtr() ), magnitude, component );
244 if ( Comm->MyPID() == 0 )
246 std::cout <<
"Done! \n" ;
252 monodomain -> exportFiberDirection (problemFolder);
257 if ( Comm->MyPID() == 0 )
259 std::cout <<
"\nSetup operators: " ;
261 monodomain -> setupLumpedMassMatrix();
262 monodomain -> setupStiffnessMatrix();
263 monodomain -> setupGlobalMatrix();
264 if ( Comm->MyPID() == 0 )
266 std::cout <<
"Done! \n" ;
272 ExporterHDF5< RegionMesh <LinearTetra> > exporter;
273 monodomain -> setupExporter ( exporter, monodomainList.get (
"OutputFile",
"Solution"), problemFolder );
274 monodomain -> exportSolution ( exporter, 0);
279 if ( Comm->MyPID() == 0 )
281 std::cout <<
"\nstart solving: " ;
284 Real dt = monodomain -> timeStep();
286 Real TF = monodomainList.get (
"endTime", 48.0);
287 Int iter = monodomainList.get (
"saveStep", 1.0) / dt;
293 StimulusPacingProtocol pacing;
299 if ( Comm->MyPID() == 0 )
301 std::cout <<
"Importing pacing protocol parameters ...";
303 std::string pacingListFileName = monodomainList.get (
"pacing_parameter_list_filename",
"PacingParameters.xml");
304 Teuchos::ParameterList pacingList = * ( Teuchos::getParametersFromXmlFile ( pacingListFileName ) );
305 if ( Comm->MyPID() == 0 )
307 std::cout <<
" Done!" << std::endl;
310 pacing.setParameters (pacingList);
311 pacing.setTimeStep ( monodomain -> timeStep() );
317 for (
Real t = monodomain -> initialTime(); t < TF;)
323 monodomain -> setAppliedCurrentFromElectroStimulus ( pacing, t);
331 monodomain -> solveOneStepGatingVariablesFE();
332 monodomain -> solveOneICIStep();
337 if (loop % iter == 0 )
339 if ( Comm->MyPID() == 0 )
341 std::cout <<
"\ntime = " << t;
343 exporter.postProcess (t);
351 exporter.closeFile();
357 Real newSolutionNorm = monodomain -> potentialPtr() -> norm2();
360 MPI_Barrier (MPI_COMM_WORLD);
367 std::cout <<
"\nTest Failed: " << err <<
"\n" <<
"\nSolution Norm: " << newSolutionNorm <<
"\n";
383 Real r = std::sqrt ( (y - y0) * (y - y0) + (z - z0) * (z - z0) );
VectorEpetra - The Epetra Vector format Wrapper.
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
int32_type Int
Generic integer data.
Real fiberDistribution(const Real &, const Real &, const Real &y, const Real &z, const ID &id)
double Real
Generic real data.
int main(int argc, char **argv)
const std::string follow(const char *Default, unsigned No, const char *Option,...)