36 #include "PseudoEcgCalculator.hpp" 37 #include "HeartRegionCodes.hpp" 38 #include "HeartConfig.hpp" 40 #include "Version.hpp" 43 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
45 c_vector<double,PROBLEM_DIM>& rU,
46 c_matrix<double,PROBLEM_DIM,SPACE_DIM>& rGradU)
48 c_vector<double,SPACE_DIM> r_vector = rX.
rGetLocation()- mProbeElectrode.rGetLocation();
49 double norm_r = norm_2(r_vector);
50 if (norm_r <= DBL_EPSILON)
52 EXCEPTION(
"Probe is on a mesh Gauss point.");
54 c_vector<double,SPACE_DIM> grad_one_over_r = - (r_vector)*
SmallPow( (1/norm_r) , 3);
55 matrix_row<c_matrix<double, PROBLEM_DIM, SPACE_DIM> > grad_u_row(rGradU, 0);
56 double integrand = inner_prod(grad_u_row, grad_one_over_r);
58 return -mDiffusionCoefficient*integrand;
61 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
65 const std::string& rHdf5FileName,
66 const std::string& rVariableName,
67 unsigned timestepStride)
69 mProbeElectrode(rProbeElectrode),
70 mVariableName(rVariableName),
71 mTimestepStride(timestepStride)
81 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
93 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
99 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
102 assert(diffusionCoefficient>=0);
106 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
112 double pseudo_ecg_at_one_timestep;
115 pseudo_ecg_at_one_timestep = this->
Calculate(
mrMesh, solution_at_one_time_step);
123 return pseudo_ecg_at_one_timestep;
126 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM,
unsigned PROBLEM_DIM>
132 std::stringstream stream;
137 out_stream p_file=out_stream(NULL);
141 *p_file <<
"#Time(ms)\tPseudo-ECG\n";
148 *p_file << time_points[time_step] <<
"\t" <<pseudo_ecg_at_one_timestep <<
"\n";
void SetDiffusionCoefficient(double diffusionCoefficient)
static bool IsRegionBath(HeartRegionType regionId)
unsigned GetNumberOfRows()
double GetIntegrand(ChastePoint< SPACE_DIM > &rX, c_vector< double, PROBLEM_DIM > &rU, c_matrix< double, PROBLEM_DIM, SPACE_DIM > &rGradU)
c_vector< double, DIM > & rGetLocation()
double SmallPow(double x, unsigned exponent)
double GetWithDefault(unsigned i, double def=0.0) const
#define EXCEPTION(message)
AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > & mrMesh
bool ShouldSkipThisElement(Element< ELEMENT_DIM, SPACE_DIM > &rElement)
void GetVariableOverNodes(Vec data, const std::string &rVariableName, unsigned timestep=0)
double mDiffusionCoefficient
out_stream OpenOutputFile(const std::string &rFileName, std::ios_base::openmode mode=std::ios::out|std::ios::trunc) const
double Calculate(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, Vec solution)
std::string mVariableName
std::vector< double > GetUnlimitedDimensionValues()
PseudoEcgCalculator(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, const ChastePoint< SPACE_DIM > &rProbeElectrode, const FileFinder &rDirectory, const std::string &rHdf5FileName, const std::string &rVariableName="V", unsigned timestepStride=1)
std::vector< double > GetVariableOverTime(const std::string &rVariableName, unsigned nodeIndex)
ChastePoint< SPACE_DIM > mProbeElectrode
unsigned GetUnsignedAttribute()
static std::string GetProvenanceString()
Hdf5DataReader * mpDataReader
static HeartConfig * Instance()
double ComputePseudoEcgAtOneTimeStep(unsigned timeStep)