AbstractOdeSystemInformation.cpp

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

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