00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef HEARTCONFIG_HPP_
00031 #define HEARTCONFIG_HPP_
00032
00033 #include "UblasCustomFunctions.hpp"
00034 #include "ChasteParameters.hpp"
00035 #include <iostream>
00036 #include "Exception.hpp"
00037 #include <vector>
00038 #include "AbstractStimulusFunction.hpp"
00039 #include "SimpleStimulus.hpp"
00040 #include "ChasteCuboid.hpp"
00041 #include "OutputFileHandler.hpp"
00042
00043 class HeartConfig
00044 {
00045 private:
00046 void CheckTimeSteps() const;
00047
00048 public:
00054 static HeartConfig* Instance();
00055
00056 void SetDefaultsFile(std::string fileName);
00057 void SetParametersFile(std::string fileName);
00058 void Write(std::string dirName, std::string fileName);
00059 static void Reset();
00060
00061
00062
00063
00064
00065 unsigned GetSpaceDimension() const;
00066 double GetSimulationDuration() const;
00067 domain_type GetDomain() const;
00068 ionic_models_available_type GetDefaultIonicModel() const;
00069 void GetIonicModelRegions(std::vector<ChasteCuboid>& definedRegions,
00070 std::vector<ionic_models_available_type>& ionicModels) const;
00071
00072
00073 bool GetIsMeshProvided() const;
00074 bool GetCreateMesh() const;
00075 bool GetCreateSlab() const;
00076 bool GetCreateSheet() const;
00077 bool GetCreateFibre() const;
00078 bool GetLoadMesh() const;
00079
00080 void GetSlabDimensions(c_vector<double, 3>& slabDimensions) const;
00081 void GetSheetDimensions(c_vector<double, 2>& sheetDimensions) const;
00082 void GetFibreLength(c_vector<double, 1>& fibreLength) const;
00083 double GetInterNodeSpace() const;
00084
00085 std::string GetMeshName() const;
00086 media_type GetConductivityMedia() const;
00087
00088 void GetStimuli(std::vector<SimpleStimulus>& stimuliApplied, std::vector<ChasteCuboid>& stimulatedAreas) const;
00089 void GetCellHeterogeneities(std::vector<ChasteCuboid>& cellHeterogeneityAreas,
00090 std::vector<double>& scaleFactorGks,
00091 std::vector<double>& scaleFactorIto,
00092 std::vector<double>& scaleFactorGkr) const;
00093 bool GetConductivityHeterogeneitiesProvided() const;
00094 void GetConductivityHeterogeneities(std::vector<ChasteCuboid>& conductivitiesHeterogeneityAreas,
00095 std::vector< c_vector<double,3> >& intraConductivities,
00096 std::vector< c_vector<double,3> >& extraConductivities) const;
00097 std::string GetOutputDirectory() const;
00098 std::string GetOutputFilenamePrefix() const;
00099
00100
00101 void GetIntracellularConductivities(c_vector<double, 3>& intraConductivities) const;
00102 void GetIntracellularConductivities(c_vector<double, 2>& intraConductivities) const;
00103 void GetIntracellularConductivities(c_vector<double, 1>& intraConductivities) const;
00104
00105 void GetExtracellularConductivities(c_vector<double, 3>& extraConductivities) const;
00106 void GetExtracellularConductivities(c_vector<double, 2>& extraConductivities) const;
00107 void GetExtracellularConductivities(c_vector<double, 1>& extraConductivities) const;
00108
00109 double GetBathConductivity() const;
00110
00111 double GetSurfaceAreaToVolumeRatio() const;
00112 double GetCapacitance() const;
00113
00114
00115 double GetOdeTimeStep() const;
00116 double GetPdeTimeStep() const;
00117 double GetPrintingTimeStep() const;
00118
00119 bool GetUseAbsoluteTolerance() const;
00120 double GetAbsoluteTolerance() const;
00121
00122 bool GetUseRelativeTolerance() const;
00123 double GetRelativeTolerance() const;
00124
00125 const char* GetKSPSolver() const;
00126 const char* GetKSPPreconditioner() const;
00127
00128
00129
00130
00131
00132
00133 void SetSpaceDimension(unsigned spaceDimension);
00134 void SetSimulationDuration(double simulationDuration);
00135 void SetDomain(domain_type domain);
00136 void SetDefaultIonicModel(ionic_models_available_type ionicModel);
00137
00138 void SetSlabDimensions(double x, double y, double z, double inter_node_space);
00139 void SetSheetDimensions(double x, double y, double inter_node_space);
00140 void SetFibreLength(double x, double inter_node_space);
00141
00142 void SetMeshFileName(std::string meshPrefix, media_type fibreDefinition=media_type::NoFibreOrientation);
00143 void SetConductivityHeterogeneities(std::vector< c_vector<double,3> >& cornerA,
00144 std::vector< c_vector<double,3> >& cornerB,
00145 std::vector< c_vector<double,3> >& intraConductivities,
00146 std::vector< c_vector<double,3> >& extraConductivities);
00147
00148 void SetOutputDirectory(std::string outputDirectory);
00149 void SetOutputFilenamePrefix(std::string outputFilenamePrefix);
00150
00151
00152 void SetIntracellularConductivities(const c_vector<double, 3>& intraConductivities);
00153 void SetIntracellularConductivities(const c_vector<double, 2>& intraConductivities);
00154 void SetIntracellularConductivities(const c_vector<double, 1>& intraConductivities);
00155
00156 void SetExtracellularConductivities(const c_vector<double, 3>& extraConductivities);
00157 void SetExtracellularConductivities(const c_vector<double, 2>& extraConductivities);
00158 void SetExtracellularConductivities(const c_vector<double, 1>& extraConductivities);
00159
00160 void SetBathConductivity(double bathConductivity);
00161
00162 void SetSurfaceAreaToVolumeRatio(double ratio);
00163 void SetCapacitance(double capacitance);
00164
00165
00166 void SetOdePdeAndPrintingTimeSteps(double odeTimeStep, double pdeTimeStep, double printingTimeStep);
00167 void SetOdeTimeStep(double odeTimeStep);
00168 void SetPdeTimeStep(double pdeTimeStep);
00169 void SetPrintingTimeStep(double printingTimeStep);
00170
00171 void SetUseRelativeTolerance(double relativeTolerance);
00172 void SetUseAbsoluteTolerance(double absoluteTolerance);
00173
00174 void SetKSPSolver(const char* kspSolver);
00175 void SetKSPPreconditioner(const char* kspPreconditioner);
00176
00177 ~HeartConfig();
00178 protected:
00179
00180 friend class TestHeartConfig;
00181
00182 chaste_parameters_type* UserParameters();
00183 chaste_parameters_type* DefaultParameters();
00184
00185
00186 private:
00187 HeartConfig();
00188
00189 chaste_parameters_type* mpUserParameters;
00190 chaste_parameters_type* mpDefaultParameters;
00191
00193 static std::auto_ptr<HeartConfig> mpInstance;
00194
00195
00196 template<class TYPE>
00197 TYPE* DecideLocation(TYPE* ptr1, TYPE* ptr2, const std::string& nameParameter) const;
00198
00199 chaste_parameters_type* ReadFile(std::string fileName);
00200
00201 };
00202
00203 #endif