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 <string>
00034 #include <vector>
00035 
00036 #include "UblasIncludes.hpp"
00037 
00038 #include "ArchiveLocationInfo.hpp"
00039 #include "ChasteParameters.hpp"
00040 #include "SimpleStimulus.hpp"
00041 #include "ChasteCuboid.hpp"
00042 
00043 #include <boost/shared_ptr.hpp>
00044 
00045 #include <boost/serialization/access.hpp>
00046 #include <boost/serialization/split_member.hpp>
00047 
00048 // Needs to be included last
00049 #include <boost/serialization/export.hpp>
00050 
00051 
00062 class HeartConfig
00063 {
00064 private:
00071     void CheckTimeSteps() const;
00072 
00074     friend class boost::serialization::access;
00081     template<class Archive>
00082     void save(Archive & archive, const unsigned int version) const
00083     {
00084         mpInstance->Write( true );
00085     }
00086 
00093     template<class Archive>
00094     void load(Archive & archive, const unsigned int version)
00095     {
00096         std::string defaults_filename_xml = ArchiveLocationInfo::GetArchiveDirectory() + "ChasteDefaults.xml";
00097         HeartConfig::Instance()->SetDefaultsFile(defaults_filename_xml);
00098 
00099         std::string parameters_filename_xml = ArchiveLocationInfo::GetArchiveDirectory() + "ChasteParameters.xml";
00100         HeartConfig::Instance()->SetParametersFile(parameters_filename_xml);
00101     }
00102     BOOST_SERIALIZATION_SPLIT_MEMBER()
00103 
00104 
00105 
00106 public:
00112     static HeartConfig* Instance();
00113 
00119     void SetUseFixedSchemaLocation(bool useFixedSchemaLocation);
00120 
00124     void SetDefaultsFile(const std::string& rFileName);
00129     void SetParametersFile(const std::string& rFileName);
00138     void Write(bool useArchiveLocationInfo=false);
00139 
00144     static void Reset();
00145 
00146     /*
00147      *  Get methods
00148      */
00149     // Simulation
00150     unsigned GetSpaceDimension() const; 
00151     double GetSimulationDuration() const; 
00157     domain_type GetDomain() const;
00165     ionic_models_available_type GetDefaultIonicModel() const;
00166 
00178      void GetIonicModelRegions(std::vector<ChasteCuboid>& definedRegions,
00179                                std::vector<ionic_models_available_type>& ionicModels) const;
00180 
00181 
00182     bool IsMeshProvided() const; 
00183     bool GetCreateMesh() const; 
00184     bool GetCreateSlab() const; 
00185     bool GetCreateSheet() const; 
00186     bool GetCreateFibre() const; 
00187     bool GetLoadMesh() const; 
00188 
00189 
00192     void GetSlabDimensions(c_vector<double, 3>& slabDimensions) const;
00196     void GetSheetDimensions(c_vector<double, 2>& sheetDimensions) const;
00200     void GetFibreLength(c_vector<double, 1>& fibreLength) const;
00201     double GetInterNodeSpace() const; 
00203     std::string GetMeshName() const;
00205     media_type GetConductivityMedia() const;
00216     void GetStimuli(std::vector<boost::shared_ptr<SimpleStimulus> >& rStimuliApplied, std::vector<ChasteCuboid>& rStimulatedAreas) const;
00217 
00228     void GetCellHeterogeneities(std::vector<ChasteCuboid>& cellHeterogeneityAreas,
00229                                 std::vector<double>& scaleFactorGks,
00230                                 std::vector<double>& scaleFactorIto,
00231                                 std::vector<double>& scaleFactorGkr) const;
00232     bool GetConductivityHeterogeneitiesProvided() const; 
00241     void GetConductivityHeterogeneities(std::vector<ChasteCuboid>& conductivitiesHeterogeneityAreas,
00242                                         std::vector< c_vector<double,3> >& intraConductivities,
00243                                         std::vector< c_vector<double,3> >& extraConductivities) const;
00244     std::string GetOutputDirectory() const; std::string GetOutputFilenamePrefix() const;
00256 
00257     // Physiological
00262     void GetIntracellularConductivities(c_vector<double, 3>& intraConductivities) const;
00267     void GetIntracellularConductivities(c_vector<double, 2>& intraConductivities) const;
00272     void GetIntracellularConductivities(c_vector<double, 1>& intraConductivities) const;
00273 
00278     void GetExtracellularConductivities(c_vector<double, 3>& extraConductivities) const;
00283     void GetExtracellularConductivities(c_vector<double, 2>& extraConductivities) const;
00288     void GetExtracellularConductivities(c_vector<double, 1>& extraConductivities) const;
00289 
00290     double GetBathConductivity() const; 
00293     double GetSurfaceAreaToVolumeRatio() const; 
00295     double GetCapacitance() const; 
00297     // Numerical
00298     double GetOdeTimeStep() const; 
00299     double GetPdeTimeStep() const; 
00300     double GetPrintingTimeStep() const; 
00302     bool GetUseAbsoluteTolerance() const; 
00303     double GetAbsoluteTolerance() const; 
00305     bool GetUseRelativeTolerance() const; 
00306     double GetRelativeTolerance() const;  
00308     const char* GetKSPSolver() const; 
00309     const char* GetKSPPreconditioner() const; 
00311     // Post processing
00316     bool IsPostProcessingRequested() const;
00317 
00321     bool IsApdMapsRequested() const;
00327     void GetApdMaps(std::vector<std::pair<double,double> >& apd_maps) const;
00328 
00332     bool IsUpstrokeTimeMapsRequested() const;
00338     void GetUpstrokeTimeMaps (std::vector<double>& upstroke_time_maps) const;
00339 
00345     bool IsMaxUpstrokeVelocityMapRequested() const;
00346 
00350     bool IsConductionVelocityMapsRequested() const;
00351 
00357     void GetConductionVelocityMaps(std::vector<unsigned>& conduction_velocity_maps) const;
00358 
00359 
00360     /*
00361      *  Set methods
00362      */
00363     // Simulation
00367     void SetSpaceDimension(unsigned spaceDimension);
00371     void SetSimulationDuration(double simulationDuration);
00378     void SetDomain(domain_type domain);
00386     void SetDefaultIonicModel(ionic_models_available_type ionicModel);
00387 
00395     void SetSlabDimensions(double x, double y, double z, double inter_node_space);
00402     void SetSheetDimensions(double x, double y, double inter_node_space);
00408     void SetFibreLength(double x, double inter_node_space);
00409 
00416     void SetMeshFileName(std::string meshPrefix, media_type fibreDefinition=media_type::NoFibreOrientation);
00417 
00426     void SetConductivityHeterogeneities(std::vector< c_vector<double,3> >& cornerA,
00427                                         std::vector< c_vector<double,3> >& cornerB,
00428                                         std::vector< c_vector<double,3> >& intraConductivities,
00429                                         std::vector< c_vector<double,3> >& extraConductivities);
00430 
00434     void SetOutputDirectory(const std::string& rOutputDirectory);
00445     void SetOutputFilenamePrefix(const std::string& rOutputFilenamePrefix);
00446 
00447     // Physiological
00452     void SetIntracellularConductivities(const c_vector<double, 3>& intraConductivities);
00457     void SetIntracellularConductivities(const c_vector<double, 2>& intraConductivities);
00462     void SetIntracellularConductivities(const c_vector<double, 1>& intraConductivities);
00463 
00468     void SetExtracellularConductivities(const c_vector<double, 3>& extraConductivities);
00473     void SetExtracellularConductivities(const c_vector<double, 2>& extraConductivities);
00478     void SetExtracellularConductivities(const c_vector<double, 1>& extraConductivities);
00479 
00485     void SetBathConductivity(double bathConductivity);
00486 
00491     void SetSurfaceAreaToVolumeRatio(double ratio);
00492 
00497     void SetCapacitance(double capacitance);
00498 
00499     // Numerical
00506     void SetOdePdeAndPrintingTimeSteps(double odeTimeStep, double pdeTimeStep, double printingTimeStep);
00511     void SetOdeTimeStep(double odeTimeStep);
00516     void SetPdeTimeStep(double pdeTimeStep);
00517 
00522      void SetPrintingTimeStep(double printingTimeStep);
00523 
00527     void SetUseRelativeTolerance(double relativeTolerance);
00531     void SetUseAbsoluteTolerance(double absoluteTolerance);
00532 
00536     void SetKSPSolver(const char* kspSolver);
00540     void SetKSPPreconditioner(const char* kspPreconditioner);
00541 
00548     void SetApdMaps(const std::vector<std::pair<double,double> >& apd_maps);
00549 
00554     void SetUpstrokeTimeMaps (std::vector<double>& upstroke_time_maps);
00555 
00556     ~HeartConfig(); 
00557 protected:
00558     // Only to be accessed by the tests
00559     friend class TestHeartConfig;
00560 
00561 private:
00562     /*Constructor is private, since the class is only accessed by the singleton instance() method*/
00563     HeartConfig();
00564 
00568     boost::shared_ptr<chaste_parameters_type> mpUserParameters;
00572     boost::shared_ptr<chaste_parameters_type> mpDefaultParameters;
00573 
00575     static std::auto_ptr<HeartConfig> mpInstance;
00576     
00581     bool mUseFixedSchemaLocation;
00582 
00592     template<class TYPE>
00593     TYPE* DecideLocation(TYPE* params_ptr, TYPE* defaults_ptr, const std::string& nameParameter) const;
00594 
00599     boost::shared_ptr<chaste_parameters_type> ReadFile(const std::string& rFileName);
00600 
00601 };
00602 
00603 // Declare identifier for the serializer
00604 BOOST_CLASS_EXPORT(HeartConfig);
00605 
00606 #endif /*HEARTCONFIG_HPP_*/

Generated on Tue Aug 4 16:10:22 2009 for Chaste by  doxygen 1.5.5