00001 /* 00002 00003 Copyright (C) University of Oxford, 2005-2010 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 #include <cassert> 00031 00032 #include "AbstractOdeSystemInformation.hpp" 00033 #include "Exception.hpp" 00034 00035 AbstractOdeSystemInformation::AbstractOdeSystemInformation() 00036 : mInitialised(false) 00037 { 00038 } 00039 00040 AbstractOdeSystemInformation::~AbstractOdeSystemInformation() 00041 { 00042 } 00043 00044 void AbstractOdeSystemInformation::SetInitialConditions(const std::vector<double>& rInitialConditions) 00045 { 00046 assert(mInitialised); 00047 mInitialConditions = rInitialConditions; 00048 } 00049 00050 void AbstractOdeSystemInformation::SetInitialConditionsComponent(unsigned index, double initialCondition) throw(std::out_of_range) 00051 { 00052 assert(mInitialised); 00053 mInitialConditions.at(index) = initialCondition; 00054 } 00055 00056 std::vector<double> AbstractOdeSystemInformation::GetInitialConditions() const 00057 { 00058 assert(mInitialised); 00059 return mInitialConditions; 00060 } 00061 00062 const std::vector<std::string>& AbstractOdeSystemInformation::rGetVariableNames() const 00063 { 00064 assert(mInitialised); 00065 return mVariableNames; 00066 } 00067 00068 const std::vector<std::string>& AbstractOdeSystemInformation::rGetVariableUnits() const 00069 { 00070 assert(mInitialised); 00071 return mVariableUnits; 00072 } 00073 00074 unsigned AbstractOdeSystemInformation::GetStateVariableNumberByName(const std::string& rName) const 00075 { 00076 assert(mInitialised); 00077 unsigned var_number = 0u; 00078 std::vector<std::string>::const_iterator it = mVariableNames.begin(); 00079 for ( ; it != mVariableNames.end() && *it != rName; ++it, ++var_number); 00080 if (it == mVariableNames.end()) 00081 { 00082 EXCEPTION("State variable '" + rName + "' does not exist"); 00083 } 00084 return var_number; 00085 } 00086 00087 std::string AbstractOdeSystemInformation::GetStateVariableUnitsByNumber(unsigned varNumber) const 00088 { 00089 assert(mInitialised); 00090 return mVariableUnits.at(varNumber); 00091 } 00092 00093 00094 const std::vector<std::string>& AbstractOdeSystemInformation::rGetParameterNames() const 00095 { 00096 assert(mInitialised); 00097 return mParameterNames; 00098 } 00099 00100 const std::vector<std::string>& AbstractOdeSystemInformation::rGetParameterUnits() const 00101 { 00102 assert(mInitialised); 00103 return mParameterUnits; 00104 }