39 #pragma GCC diagnostic ignored "-Wunused-variable" 40 #pragma GCC diagnostic ignored "-Wunused-parameter" 42 #include <Epetra_ConfigDefs.h> 45 #include <Epetra_MpiComm.h> 47 #include <Epetra_SerialComm.h> 51 #pragma GCC diagnostic warning "-Wunused-variable" 52 #pragma GCC diagnostic warning "-Wunused-parameter" 55 #include <lifev/core/mesh/MeshUtility.hpp> 58 #include <lifev/electrophysiology/solver/ElectroETAMonodomainSolver.hpp> 61 #include <lifev/electrophysiology/solver/IonicModels/IonicAlievPanfilov.hpp> 64 #include <lifev/core/LifeV.hpp> 69 using namespace LifeV;
82 MPI_Init (&argc, &argv);
83 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
84 if ( Comm->MyPID() == 0 )
86 std::cout <<
"% using MPI" << std::endl;
94 std::string problemFolder = commandLine
.follow ( "Output", 2
, "-o", "--output" );
96 if ( problemFolder.compare (
"./") )
100 if ( Comm->MyPID() == 0 )
102 mkdir ( problemFolder.c_str(), 0777 );
110 typedef RegionMesh<LinearTetra> mesh_Type;
112 typedef std::function < Real (
const Real& ,
116 const ID& ) > function_Type;
118 typedef ElectroETAMonodomainSolver< mesh_Type, IonicAlievPanfilov > monodomainSolver_Type;
119 typedef std::shared_ptr< monodomainSolver_Type > monodomainSolverPtr_Type;
122 typedef std::shared_ptr<vector_Type> vectorPtr_Type;
130 if ( Comm->MyPID() == 0 )
132 std::cout <<
"Importing parameters list...";
134 Teuchos::ParameterList monodomainList = * ( Teuchos::getParametersFromXmlFile (
"MonodomainSolverParamList.xml" ) );
135 if ( Comm->MyPID() == 0 )
137 std::cout <<
" Done!" << std::endl;
146 if ( Comm->MyPID() == 0 )
148 std::cout <<
"Building Constructor for Minimal Model with parameters ... ";
150 std::shared_ptr<IonicAlievPanfilov> model (
new IonicAlievPanfilov() );
151 if ( Comm->MyPID() == 0 )
153 std::cout <<
" Done!" << std::endl;
161 std::string meshName = monodomainList.get (
"mesh_name",
"lid16.mesh");
162 std::string meshPath = monodomainList.get (
"mesh_path",
"./");
174 if ( Comm->MyPID() == 0 )
176 std::cout <<
"Building Monodomain Solvers... ";
179 monodomainSolverPtr_Type monodomain (
new monodomainSolver_Type ( meshName, meshPath, dataFile, model ) );
180 if ( Comm->MyPID() == 0 )
182 std::cout <<
" Splitting solver done... ";
189 std::vector<Real> scale (3, 1.0);
192 std::vector<Real> rotate (3, 0.0);
193 std::vector<Real> translate (3, 0.0);
194 MeshUtility::MeshTransformer<mesh_Type> transformer (* (monodomain -> localMeshPtr() ) );
195 transformer.transformMesh (scale, rotate, translate);
202 std::string prefix = monodomainList.get (
"importPrefix",
"ciccia");
203 std::string dir = monodomainList.get (
"importDir",
"./");
204 monodomain -> importSolution (prefix, dir, 100.0);
205 Real solutionNorm = monodomain -> potentialPtr() -> norm2();
212 if ( Comm->MyPID() == 0 )
214 std::cout <<
"\nInitializing potential: " ;
217 Real initialTime = monodomainList.get (
"importTime", 0.0);
218 monodomain -> importSolution (prefix, dir, initialTime);
220 if ( Comm->MyPID() == 0 )
222 std::cout <<
"Done! \n" ;
229 monodomain -> setParameters ( monodomainList );
235 if ( Comm->MyPID() == 0 )
237 std::cout <<
"\nImporting fibers: " ;
241 fibers[0] = monodomainList.get (
"fibers_X", 0.0);
242 fibers[1] = monodomainList.get (
"fibers_Y", 0.0);
243 fibers[2] = monodomainList.get (
"fibers_Z", 1.0);
245 monodomain -> setupFibers (fibers);
246 if ( Comm->MyPID() == 0 )
248 std::cout <<
"Done! \n" ;
255 monodomain -> exportFiberDirection (problemFolder);
261 if ( Comm->MyPID() == 0 )
263 std::cout <<
"\nSetup operators: " ;
265 monodomain -> setupLumpedMassMatrix();
266 monodomain -> setupStiffnessMatrix();
267 monodomain -> setupGlobalMatrix();
268 if ( Comm->MyPID() == 0 )
270 std::cout <<
"Done! \n" ;
277 ExporterHDF5< RegionMesh <LinearTetra> > exporter;
278 monodomain -> setupExporter ( exporter, monodomainList.get (
"OutputFile",
"Solution"), problemFolder );
279 monodomain -> exportSolution ( exporter, initialTime);
285 if ( Comm->MyPID() == 0 )
287 std::cout <<
"\nstart solving: " ;
290 Real dt = monodomain -> timeStep();
291 Real cutTime = monodomainList.get (
"cutTime", 150.0);
293 Real TF = monodomain -> endTime();
295 Int iter = monodomainList.get (
"saveStep", 1.0) / dt;
301 vectorPtr_Type spiral (
new vector_Type ( ( monodomain -> globalSolution().at (0) ) -> map() ) );
302 function_Type f = &cut;
303 monodomain -> feSpacePtr() -> interpolate (
304 static_cast<FESpace<RegionMesh<LinearTetra>, MapEpetra>::function_Type> (f),
312 for (
Real t = initialTime; t < (TF - dt * 1e-4);)
317 if (t >= cutTime && t <= cutTime + dt)
319 * (monodomain -> potentialPtr() ) *= *spiral;
321 monodomain -> solveOneStepGatingVariablesFE();
322 monodomain -> solveOneICIStep();
323 if (loop % iter == 0 )
325 exporter.postProcess (t);
332 exporter.closeFile();
339 Real newSolutionNorm = monodomain -> potentialPtr() -> norm2();
342 MPI_Barrier (MPI_COMM_WORLD);
345 Real err = std::abs (newSolutionNorm - solutionNorm) / std::abs (solutionNorm);
346 std::cout << std::setprecision (20) <<
"\nError: " << err <<
"\nSolution Norm: " << newSolutionNorm <<
"\n";
347 std::cout << std::setprecision (20) <<
"\nImported solution Norm: " << solutionNorm <<
"\n";
350 std::cout <<
"\nTest Failed: " << err <<
"\n" <<
"\nSolution Norm: " << newSolutionNorm <<
"\n";
VectorEpetra - The Epetra Vector format Wrapper.
Real initialCondition(const Real &, const Real &x, const Real &, const Real &, const ID &)
Real cut(const Real &, const Real &, const Real &y, const Real &, const ID &)
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
int32_type Int
Generic integer data.
double Real
Generic real data.
int main(int argc, char **argv)
const std::string follow(const char *Default, unsigned No, const char *Option,...)