HeartConfig.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
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      *  Get methods
00063      */
00064     // Simulation
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     // Physiological
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     // Numerical
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      *  Set methods
00131      */
00132     // Simulation
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     // Physiological
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     // Numerical
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     // Only to be accesed by the tests
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     // Misc
00196     template<class TYPE>
00197     TYPE* DecideLocation(TYPE* ptr1, TYPE* ptr2, const std::string& nameParameter) const;
00198     //Utility method to parse an XML parameters file
00199     chaste_parameters_type* ReadFile(std::string fileName);
00200 
00201 };
00202 
00203 #endif /*HEARTCONFIG_HPP_*/

Generated on Wed Mar 18 12:51:52 2009 for Chaste by  doxygen 1.5.5