EMSolver.hpp 19.6 KB
Newer Older
Simone Rossi's avatar
Simone Rossi committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//@HEADER
/*
 *******************************************************************************

 Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
 Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University

 This file is part of LifeV.

 LifeV is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 LifeV is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public License
 along with LifeV.  If not, see <http://www.gnu.org/licenses/>.

 *******************************************************************************
 */
//@HEADER
/*!
 @file
 @brief Class for solving the Monodomain equations in electrophysiology.

 @date 02-2013
 @author Simone Rossi <simone.rossi@epfl.ch>

 @last update 02-2013

 This class provides interfaces to solve the monodomain equation
 ( reaction diffusion equation ) using the ETA framework.
 The solution can be performed using three different methods:
 -operator splitting method (at this point available only with forward Euler
 for the reaction step and backward Euler for the diffusion step. );
 -Ionic Currents Interpolation (at this point only forward Euler);
 -State Variable interpolation (at this point only forward Euler).
 */

#ifndef _EMSOLVER_H_
#define _EMSOLVER_H_

Simone Rossi's avatar
Simone Rossi committed
47
#include <lifev/core/mesh/MeshLoadingUtility.hpp>
Simone Rossi's avatar
Simone Rossi committed
48

Simone Rossi's avatar
Simone Rossi committed
49
#include <lifev/em/solver/electrophysiology/EMMonodomainSolver.hpp>
Simone Rossi's avatar
Simone Rossi committed
50
51
52
53
54
55
56
#include <lifev/em/solver/mechanics/EMStructuralOperator.hpp>
#include <lifev/em/solver/mechanics/EMStructuralConstitutiveLaw.hpp>
#include <lifev/structure/solver/StructuralConstitutiveLawData.hpp>


#include <lifev/em/solver/activation/activeStressModels/ActiveStressActivation.hpp>

Simone Rossi's avatar
Simone Rossi committed
57
58
59
60
61
62
63
64
65
66
67
//
//#include <lifev/em/solver/EMStructuralOperator.hpp>
//#include <lifev/em/solver/EMGeneralizedActiveHolzapfelOgdenMaterial.hpp>
//#include <lifev/em/solver/EMActiveStrainSolver.hpp>
//#include <lifev/core/interpolation/RBFlocallyRescaledVectorial.hpp>
//#include <lifev/core/interpolation/RBFlocallyRescaledScalar.hpp>
//#include <lifev/core/interpolation/RBFrescaledVectorial.hpp>
//#include <lifev/core/interpolation/RBFrescaledScalar.hpp>
////#include <lifev/core/interpolation/RBFscalar.hpp>
//#include <lifev/core/interpolation/RBFvectorial.hpp>
//
Simone Rossi's avatar
Simone Rossi committed
68
#include <lifev/bc_interface/3D/bc/BCInterface3D.hpp>
Simone Rossi's avatar
Simone Rossi committed
69
70
71
//
//
//#include <lifev/em/solver/EMEvaluate.hpp>
Simone Rossi's avatar
Simone Rossi committed
72
73
74
75
76
77

namespace LifeV
{

//! EMSolver - Class featuring the solution of the electromechanical problem with monodomain equation

Simone Rossi's avatar
Simone Rossi committed
78
template<typename Mesh , typename ElectroSolver, typename ActivationModel>
Simone Rossi's avatar
Simone Rossi committed
79
80
class EMSolver
{
Simone Rossi's avatar
Simone Rossi committed
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
public:
	typedef Mesh                                              mesh_Type;

	typedef boost::shared_ptr<mesh_Type>                      meshPtr_Type;

	typedef Epetra_Comm                                       comm_Type;

	typedef boost::shared_ptr<Epetra_Comm>                    commPtr_Type;

	typedef VectorEpetra                                      vector_Type;

	typedef StructuralConstitutiveLawData                     structureData_Type;

	typedef boost::shared_ptr<structureData_Type>             structureDataPtr_Type;

	typedef EMStructuralOperator< mesh_Type >                 structuralOperator_Type;

	typedef boost::shared_ptr< structuralOperator_Type >      structuralOperatorPtr_Type;

	typedef BCHandler                                          bc_Type;

	typedef boost::shared_ptr< bc_Type >                       bcPtr_Type;

	typedef StructuralOperator< mesh_Type >                   physicalSolver_Type;

	typedef BCInterface3D< bc_Type, physicalSolver_Type >  bcInterface_Type;
Simone Rossi's avatar
Simone Rossi committed
107

Simone Rossi's avatar
Simone Rossi committed
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
	typedef boost::shared_ptr< bcInterface_Type >              bcInterfacePtr_Type;

	typedef boost::shared_ptr<ActivationModel>                 activationModelPtr_Type;

	typedef ElectroSolver                                      electroSolver_Type;

	typedef boost::shared_ptr<electroSolver_Type>              electroSolverPtr_Type;

	typedef ElectroIonicModel                                  ionicModel_Type;

	typedef boost::shared_ptr<ionicModel_Type>                 ionicModelPtr_Type;

	typedef ExporterHDF5< Mesh >                               exporter_Type;

	typedef boost::shared_ptr<ExporterHDF5< Mesh > >           exporterPtr_Type;

    typedef FESpace< RegionMesh<LinearTetra>, MapEpetra >      solidFESpace_Type;

    typedef boost::shared_ptr<solidFESpace_Type>                solidFESpacePtr_Type;

    typedef ETFESpace< RegionMesh<LinearTetra>, MapEpetra, 3, 3 > solidETFESpace_Type;

    typedef boost::shared_ptr<solidETFESpace_Type>              solidETFESpacePtr_Type;

    typedef boost::function < Real (const Real& t,
                                    const Real &   x,
                                    const Real &   y,
                                    const Real& z,
                                    const ID&   /*i*/ ) >       function_Type;



    EMSolver();
Simone Rossi's avatar
Simone Rossi committed
141
142

	EMSolver(const EMSolver& solver);
Simone Rossi's avatar
Simone Rossi committed
143

Simone Rossi's avatar
Simone Rossi committed
144

Simone Rossi's avatar
Simone Rossi committed
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304

	inline void loadMesh(std::string meshName, std::string meshPath)
	{
        std::cout << "EMS - Loading mesh\n";
		MeshUtility::loadMesh (M_localMeshPtr, M_fullMeshPtr, meshName, meshPath);
	}

	inline void setupElectroExporter( std::string problemFolder = "./", std::string outputFileName = "MechanicalSolution" )
	{
		M_electroSolverPtr -> setupExporter(*M_electroExporterPtr, outputFileName, problemFolder);
	}

    inline void setupActivationExporter( std::string problemFolder = "./", std::string outputFileName = "ActivationSolution" )
    {
    	EMUtility::setupExporter<Mesh>(*M_activationExporterPtr, M_localMeshPtr, M_commPtr, outputFileName, problemFolder);
    }

    inline void setupMechanicsExporter( std::string problemFolder = "./", std::string outputFileName = "ElectroSolution" )
    {
    	if(M_mechanicsExporterPtr)
    	EMUtility::setupExporter<Mesh>(*M_mechanicsExporterPtr, M_localMeshPtr, M_commPtr, outputFileName, problemFolder);
    }

    void setupExporters(std::string problemFolder   = "./",
    		            std::string electroFileName = "ElectroSolution",
    		            std::string activationFileName  = "ActivationSolution",
    		            std::string mechanicsFileName  = "MechanicalSolution");

	void setupElectroSolver( GetPot& dataFile, Teuchos::ParameterList& list, short int ionicModelSize);
	void setupElectroSolver( GetPot& dataFile, Teuchos::ParameterList& list, std::string ionicModelName);

	void setupMechanicalSolver( GetPot& dataFile);

	void setupMechanicalBC(std::string data_file_name,
                           std::string section,
                           solidFESpacePtr_Type dFESpace);

	inline void setupActivation(const MapEpetra& map)
	{
		if(M_commPtr -> MyPID()==0)
		{
			std::cout << "EMS - setting up activation solver\n";
		}
		M_activationModelPtr.reset( new ActivationModel(map) );
	}

	void setup(GetPot& dataFile, Teuchos::ParameterList& list, short int ionicModelSize, commPtr_Type commPtr);
	void setup(GetPot& dataFile, Teuchos::ParameterList& list, std::string ionicModelName, commPtr_Type commPtr);

	inline void buildMechanicalSystem()
	{
	    M_EMStructuralOperatorPtr -> buildSystem (1.0);
	}

	inline void buildElectroSystem()
	{
	    M_electroSolverPtr -> setupMatrices();
	}

	inline  void buildSystem()
	{
		buildMechanicalSystem(); buildElectroSystem();
	}

	inline void initializeElectroVariables()
	{
		M_electroSolverPtr -> setInitialConditions();
	}

	inline void initialize()
	{
		initializeElectroVariables();
	}

	inline bcInterfacePtr_Type bcInterfacePtr()
	{
		return M_bcInterfacePtr;
	}


	inline void setupMechanicalFiberVector( Real fx, Real fy, Real fz )
	{
	    M_EMStructuralOperatorPtr -> EMMaterial() -> setupFiberVector( fx, fy, fz);
	}

	inline void setupElectroFiberVector( VectorSmall<3>& fibers)
	{
		M_electroSolverPtr -> setupFibers (fibers);
	}


	inline void setupFiberVector( Real fx, Real fy, Real fz )
	{
		VectorSmall<3> f; f[0]=fx; f[1]=fy; f[2]=fz;
		setupElectroFiberVector(f);
		M_EMStructuralOperatorPtr -> EMMaterial() -> setFiberVectorPtr ( M_electroSolverPtr -> fiberPtr() );
	}

	inline electroSolverPtr_Type electroSolverPtr()
	{
		return M_electroSolverPtr;
	}

	inline structuralOperator_Type structuralOperatorPtr()
	{
		return M_EMStructuralOperatorPtr;
	}

	inline activationModelPtr_Type  activationModelPtr()
	{
		return M_activationModelPtr;
	}

	void saveSolution(Real time);

	void closeExporters();

	void oneWayCoupling();

	void twoWayCoupling();

	inline void setAppliedCurrent(function_Type& stimulus, Real time = 0.0)
	{
		M_electroSolverPtr -> setAppliedCurrentFromFunction(stimulus, time);
	}


	inline void solveMechanics()
	{
		M_EMStructuralOperatorPtr -> iterate( M_bcInterfacePtr -> handler() );
	}

	inline void solveElectrophysiology(function_Type& stimulus, Real time = 0.0);


	inline void solveActivation(UInt index, Real dt);
	//	inline bcInterface_Type bcInterface()
//	{
//		return *M_bcInterfacePtr;
//	}

protected:
	electroSolverPtr_Type                M_electroSolverPtr;
	activationModelPtr_Type              M_activationModelPtr;
	bcInterfacePtr_Type                  M_bcInterfacePtr;
	structuralOperatorPtr_Type           M_EMStructuralOperatorPtr;

	exporterPtr_Type                     M_electroExporterPtr;
	exporterPtr_Type                     M_activationExporterPtr;
	exporterPtr_Type                     M_mechanicsExporterPtr;

	meshPtr_Type                         M_localMeshPtr;
	meshPtr_Type                         M_fullMeshPtr;
	vectorPtr_Type                       M_activationTime;

    bool                                 M_oneWayCoupling;

	commPtr_Type                         M_commPtr;


Simone Rossi's avatar
Simone Rossi committed
305
};
Simone Rossi's avatar
Simone Rossi committed
306
307
308

/////////////////////
// CONSTRUCTORS
Simone Rossi's avatar
Simone Rossi committed
309
310
311
312
313
314
315
316
317
318
319
320
321
322
template<typename Mesh , typename ElectroSolver, typename ActivationModel>
EMSolver<Mesh, ElectroSolver, ActivationModel>::EMSolver() :
    M_electroSolverPtr       ( ),
    M_activationModelPtr    ( ),
    M_bcInterfacePtr        ( ),
    M_EMStructuralOperatorPtr(),
    M_electroExporterPtr ( ),
    M_activationExporterPtr ( ),
    M_mechanicsExporterPtr  ( ),
    M_localMeshPtr      ( ),
    M_fullMeshPtr      ( ),
    M_activationTime     ( ),
    M_oneWayCoupling     (true),
    M_commPtr               ( )
Simone Rossi's avatar
Simone Rossi committed
323
324
325
326
327
328
{
}


/////////////////////
// COPY CONSTRUCTORS
Simone Rossi's avatar
Simone Rossi committed
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
template<typename Mesh , typename ElectroSolver, typename ActivationModel>
EMSolver<Mesh, ElectroSolver, ActivationModel>::EMSolver(const EMSolver& solver) :
    M_electroSolverPtr(solver.M_electroSolverPtr),
    M_activationModelPtr(solver.M_activationModelPtr),
    M_bcInterfacePtr        ( solver.M_bcInterfacePtr),
    M_EMStructuralOperatorPtr(solver.M_EMStructuralOperatorPtr),
    M_electroExporterPtr ( solver.M_electroExporterPtr),
    M_activationExporterPtr ( solver.M_activationExporterPtr),
    M_mechanicsExporterPtr  ( solver.M_mechanicsExporterPtr),
    M_localMeshPtr      ( solver.M_localMeshPtr),
    M_fullMeshPtr      ( solver.M_fullMeshPtr),
    M_activationTime     ( solver.M_activationTime),
    M_oneWayCoupling     ( solver.M_oneWayCoupling),
    M_commPtr               ( solver.M_commPtr)

{
}


/////////////////////
// Setting up the electrophysiology solver
template<typename Mesh , typename ElectroSolver, typename ActivationModel>
void
EMSolver<Mesh, ElectroSolver, ActivationModel>::setup( GetPot& dataFile,
		                                               Teuchos::ParameterList& list,
		                                               short int ionicModelSize,
		                                               commPtr_Type commPtr)
{
	M_commPtr = commPtr;
	setupElectroSolver( dataFile, list, ionicModelSize );
	setupMechanicalSolver( dataFile );
	setupActivation( M_electroSolverPtr -> potentialPtr() ->map() );
}


/////////////////////
// Setting up the electrophysiology solver
template<typename Mesh , typename ElectroSolver, typename ActivationModel>
void
EMSolver<Mesh, ElectroSolver, ActivationModel>::setup( GetPot& dataFile,
		                                               Teuchos::ParameterList& list,
		                                               std::string ionicModelName,
		                                               commPtr_Type commPtr)
Simone Rossi's avatar
Simone Rossi committed
372
{
Simone Rossi's avatar
Simone Rossi committed
373
374
375
376
377
378
379
380
	M_commPtr = commPtr;
	setupElectroSolver( dataFile, list, ionicModelName );
	if(M_commPtr -> MyPID()==0)
	{
		std::cout << "EMS - electro solver setup done! ";
	}
	setupMechanicalSolver( dataFile );
	setupActivation( M_electroSolverPtr -> potentialPtr() ->map() );
Simone Rossi's avatar
Simone Rossi committed
381
382
}

Simone Rossi's avatar
Simone Rossi committed
383

Simone Rossi's avatar
Simone Rossi committed
384
/////////////////////
Simone Rossi's avatar
Simone Rossi committed
385
386
387
388
389
390
391
392
393
394
// Setting up the electrophysiology solver
template<typename Mesh , typename ElectroSolver, typename ActivationModel>
void
EMSolver<Mesh, ElectroSolver, ActivationModel>::setupElectroSolver( GetPot& dataFile, Teuchos::ParameterList& list, short int ionicModelSize)
{
}

template<typename Mesh , typename ElectroSolver, typename ActivationModel>
void
EMSolver<Mesh, ElectroSolver, ActivationModel>::setupElectroSolver( GetPot& dataFile, Teuchos::ParameterList& list,  std::string ionicModelName)
Simone Rossi's avatar
Simone Rossi committed
395
{
Simone Rossi's avatar
Simone Rossi committed
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
	if(M_commPtr -> MyPID()==0)
	{
		std::cout << "EMS - creating ionic model ";
	}
	ionicModelPtr_Type ionicModelPtr;
    ionicModelPtr.reset(ionicModel_Type::IonicModelFactory::instance().createObject ( ionicModelName ));

	if(M_commPtr -> MyPID()==0)
	{
		std::cout << "EMS - setting up electrophysiology solver ";
	}

	M_electroSolverPtr.reset( new ElectroSolver() );
	M_electroSolverPtr -> setIonicModelPtr(ionicModelPtr);
	if(M_localMeshPtr)
	{
		M_electroSolverPtr -> setLocalMeshPtr(M_localMeshPtr);
		if(M_fullMeshPtr)
		{
			M_electroSolverPtr -> setFullMeshPtr(M_fullMeshPtr);
		}
		M_electroSolverPtr ->  setup(dataFile, ionicModelPtr->Size() );
	}
	M_electroSolverPtr -> setParameters ( list );
	if(M_commPtr -> MyPID()==0)
	{
		std::cout << "... `Done\n";
	}

Simone Rossi's avatar
Simone Rossi committed
425
426
427
}


Simone Rossi's avatar
Simone Rossi committed
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
/////////////////////
// Setting up the electrophysiology solver
template<typename Mesh , typename ElectroSolver, typename ActivationModel>
void
EMSolver<Mesh, ElectroSolver, ActivationModel>::setupMechanicalSolver( GetPot& dataFile)
{
	if(M_commPtr -> MyPID()==0)
	{
		std::cout << "EMS - setting up mechanical solver\n";
	}
    boost::shared_ptr<StructuralConstitutiveLawData> dataStructure (new StructuralConstitutiveLawData( ) );
    dataStructure->setup (dataFile);

    std::string dOrder =  dataFile ( "solid/space_discretization/order", "P1");
    solidFESpacePtr_Type dFESpace ( new solidFESpace_Type (M_localMeshPtr, dOrder, 3, M_commPtr) );
    solidETFESpacePtr_Type dETFESpace ( new solidETFESpace_Type ( M_localMeshPtr,
    		                                                      & (dFESpace->refFE() ),
    		                                                      & (dFESpace->fe().geoMap() ),
    		                                                      M_commPtr) );
    std::string data_file_name = dataFile.get(0,"NO_DATA_FILENAME_FOUND");

    setupMechanicalBC(data_file_name, "solid",  dFESpace);
    M_EMStructuralOperatorPtr.reset(new structuralOperator_Type() );
    M_EMStructuralOperatorPtr->setup( dataStructure,
    		                         dFESpace,
    		                         dETFESpace,
    		                         M_bcInterfacePtr->handler(),
    		                         M_commPtr);
    M_EMStructuralOperatorPtr->setDataFromGetPot (dataFile);

}

/////////////////////
// Setting up the electrophysiology solver
template<typename Mesh , typename ElectroSolver, typename ActivationModel>
void
EMSolver<Mesh, ElectroSolver, ActivationModel>::setupMechanicalBC(std::string data_file_name,
                       std::string section,
                       solidFESpacePtr_Type dFESpace)
{
	if(M_commPtr -> MyPID()==0)
	{
		std::cout << "EMS - setting up bc interface\n";
	}
	M_bcInterfacePtr.reset(new bcInterface_Type() );
    M_bcInterfacePtr->createHandler();
    M_bcInterfacePtr->fillHandler ( data_file_name, "solid" );
    M_bcInterfacePtr->handler()->bcUpdate( *dFESpace->mesh(), dFESpace->feBd(), dFESpace->dof() );
}


/////////////////////
//Setup exporters
template<typename Mesh , typename ElectroSolver, typename ActivationModel>
void
EMSolver<Mesh, ElectroSolver, ActivationModel>::setupExporters(std::string problemFolder,
													    	   std::string electroFileName,
														       std::string activationFileName,
															   std::string mechanicsFileName)
{
	if(M_commPtr -> MyPID()==0)
	{
		std::cout << "EMS - setting up exporters\n";
	}
	M_electroExporterPtr.reset(new exporter_Type() );
	setupElectroExporter(problemFolder, electroFileName);
	M_activationExporterPtr.reset(new exporter_Type() );
	setupActivationExporter(problemFolder, activationFileName );
	M_activationExporterPtr -> addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField,
			                              "Activation",
			                              M_electroSolverPtr -> feSpacePtr(),
			                              M_activationModelPtr -> activationPtr(),
			                              UInt (0) );
	M_mechanicsExporterPtr.reset(new exporter_Type() );

	setupMechanicsExporter(problemFolder, mechanicsFileName);
	M_mechanicsExporterPtr -> addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
			                             "displacement",
			                             M_EMStructuralOperatorPtr -> dispFESpacePtr(),
			                             M_EMStructuralOperatorPtr -> displacementPtr(),
			                             UInt (0) );
	M_mechanicsExporterPtr -> addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
			                             "fibers",
			                             M_EMStructuralOperatorPtr -> dispFESpacePtr(),
			                             M_EMStructuralOperatorPtr -> EMMaterial() -> fiberVectorPtr(),
			                             UInt (0) );
}

template<typename Mesh , typename ElectroSolver, typename ActivationModel>
void
EMSolver<Mesh, ElectroSolver, ActivationModel>::saveSolution(Real time)
{
	M_electroExporterPtr -> postProcess(time);
	M_activationExporterPtr -> postProcess(time);
	M_mechanicsExporterPtr -> postProcess(time);
}

template<typename Mesh , typename ElectroSolver, typename ActivationModel>
void
EMSolver<Mesh, ElectroSolver, ActivationModel>::closeExporters()
{
	M_electroExporterPtr -> closeFile();
	M_activationExporterPtr -> closeFile();
	M_mechanicsExporterPtr -> closeFile();
}


///////////////////////////////
template<typename Mesh , typename ElectroSolver, typename ActivationModel>
void
EMSolver<Mesh, ElectroSolver, ActivationModel>::oneWayCoupling()
{
	M_electroSolverPtr -> setMechanicsModifiesConductivity(false);
	M_electroSolverPtr -> displacementPtr().reset();
	M_EMStructuralOperatorPtr -> EMMaterial() -> setActivationPtr( M_activationModelPtr -> activationPtr() );
}

template<typename Mesh , typename ElectroSolver, typename ActivationModel>
void
EMSolver<Mesh, ElectroSolver, ActivationModel>::twoWayCoupling()
{
	M_electroSolverPtr -> setMechanicsModifiesConductivity(true);
	M_electroSolverPtr -> setDisplacementPtr( M_EMStructuralOperatorPtr -> displacementPtr() );
	M_EMStructuralOperatorPtr -> EMMaterial() -> setActivationPtr( M_activationModelPtr -> activationPtr() );
}

////////////////////////////
template<typename Mesh , typename ElectroSolver, typename ActivationModel>
void
EMSolver<Mesh, ElectroSolver, ActivationModel>::solveElectrophysiology(function_Type& stimulus, Real time )
{
	setAppliedCurrent ( stimulus, time );
    M_electroSolverPtr -> solveOneStepGatingVariablesFE();
    M_electroSolverPtr -> solveOneICIStep();
}

template<typename Mesh , typename ElectroSolver, typename ActivationModel>
void
EMSolver<Mesh, ElectroSolver, ActivationModel>::solveActivation(UInt index, Real dt)
{
	M_activationModelPtr -> solveModel( *( (M_electroSolverPtr -> globalSolution())[index] ), dt);
}

Simone Rossi's avatar
Simone Rossi committed
571
572
573

} // namespace LifeV

Simone Rossi's avatar
Simone Rossi committed
574
575
576



Simone Rossi's avatar
Simone Rossi committed
577
#endif //_MONODOMAINSOLVER_H_