Chaste  Build::
AbstractDiscreteContinuumSolver.cpp
1 /*
2 
3 Copyright (c) 2005-2016, University of Oxford.
4  All rights reserved.
5 
6  University of Oxford means the Chancellor, Masters and Scholars of the
7  University of Oxford, having an administrative office at Wellington
8  Square, Oxford OX1 2JD, UK.
9 
10  This file is part of Chaste.
11 
12  Redistribution and use in source and binary forms, with or without
13  modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34  */
35 
36 #include "AbstractDiscreteContinuumSolver.hpp"
37 #include "BaseUnits.hpp"
38 
39 template<unsigned DIM>
41  : mpNetwork(),
42  mpCellPopulation(NULL),
43  mCellPopulationReferenceLength(BaseUnits::Instance()->GetReferenceLengthScale()),
44  mCellPopulationReferenceConcentration(BaseUnits::Instance()->GetReferenceConcentrationScale()),
45  mpOutputFileHandler(),
46  mFilename(),
47  mLabel("Default"),
48  IsSetupForSolve(false),
49  mWriteSolution(false),
50  mpPde(),
51  mpNonLinearPde(),
52  mBoundaryConditions(),
53  mReferenceConcentration(BaseUnits::Instance()->GetReferenceConcentrationScale()),
54  mSolution(),
55  mConcentrations(),
56  mHasRegularGrid(false),
57  mHasUnstructuredGrid(false)
58 {
59 
60 }
61 
62 template<unsigned DIM>
64 {
65 
66 }
67 
68 template<unsigned DIM>
70 {
71  mBoundaryConditions.push_back(pBoundaryCondition);
72 }
73 
74 template<unsigned DIM>
76 {
77  return bool(mpCellPopulation);
78 }
79 
80 template<unsigned DIM>
81 std::vector<units::quantity<unit::concentration> > AbstractDiscreteContinuumSolver<DIM>::GetConcentrations()
82 {
83  return mConcentrations;
84 }
85 
86 template<unsigned DIM>
88 {
89  return mLabel;
90 }
91 
92 template<unsigned DIM>
93 boost::shared_ptr<AbstractDiscreteContinuumLinearEllipticPde<DIM, DIM> > AbstractDiscreteContinuumSolver<DIM>::GetPde()
94 {
95  if(!mpPde)
96  {
97  EXCEPTION("A pde has not been set.");
98  }
99  return mpPde;
100 }
101 
102 template<unsigned DIM>
103 boost::shared_ptr<AbstractDiscreteContinuumNonLinearEllipticPde<DIM, DIM> > AbstractDiscreteContinuumSolver<DIM>::GetNonLinearPde()
104 {
105  if(!mpNonLinearPde)
106  {
107  EXCEPTION("A nonlinear pde has not been set.");
108  }
109  return mpNonLinearPde;
110 }
111 
112 template<unsigned DIM>
114 {
116 }
117 
118 template<unsigned DIM>
120 {
121  return mSolution;
122 }
123 
124 template<unsigned DIM>
126 {
127  return mHasRegularGrid;
128 }
129 
130 template<unsigned DIM>
132 {
133  return mHasUnstructuredGrid;
134 }
135 
136 template<unsigned DIM>
137 void AbstractDiscreteContinuumSolver<DIM>::SetCellPopulation(AbstractCellPopulation<DIM>& rCellPopulation,
138  units::quantity<unit::length> cellPopulationReferenceLength,
139  units::quantity<unit::concentration> cellPopulationReferenceConcentration)
140 {
141  mpCellPopulation = &rCellPopulation;
142  mCellPopulationReferenceLength = cellPopulationReferenceLength;
143  mCellPopulationReferenceConcentration = cellPopulationReferenceConcentration;
144 }
145 
146 template<unsigned DIM>
147 void AbstractDiscreteContinuumSolver<DIM>::SetFileHandler(boost::shared_ptr<OutputFileHandler> pOutputFileHandler)
148 {
149  mpOutputFileHandler = pOutputFileHandler;
150 }
151 
152 template<unsigned DIM>
153 void AbstractDiscreteContinuumSolver<DIM>::SetFileName(const std::string& rFilename)
154 {
155  mFilename = rFilename;
156 }
157 
158 template<unsigned DIM>
159 void AbstractDiscreteContinuumSolver<DIM>::SetLabel(const std::string& rLabel)
160 {
161  mLabel = rLabel;
162 }
163 
164 template<unsigned DIM>
166 {
167  mpPde = pPde;
168 }
169 
170 template<unsigned DIM>
172 {
173  mpNonLinearPde = pPde;
174 }
175 
176 template<unsigned DIM>
177 void AbstractDiscreteContinuumSolver<DIM>::SetReferenceConcentration(units::quantity<unit::concentration> referenceConcentration)
178 {
179  mReferenceConcentration = referenceConcentration;
180 }
181 
182 template<unsigned DIM>
184 {
185  mpNetwork = pNetwork;
186 }
187 
188 template<unsigned DIM>
190 {
191  mWriteSolution = write;
192 }
193 
194 template<unsigned DIM>
195 void AbstractDiscreteContinuumSolver<DIM>::UpdateSolution(const std::vector<double>& data)
196 {
197  mSolution = data;
198 }
199 
200 template<unsigned DIM>
201 void AbstractDiscreteContinuumSolver<DIM>::UpdateSolution(const std::vector<units::quantity<unit::concentration> >& data)
202 {
203  mConcentrations = data;
204 }
205 
206 // Explicit instantiation
207 template class AbstractDiscreteContinuumSolver<2> ;
208 template class AbstractDiscreteContinuumSolver<3> ;
virtual std::vector< units::quantity< unit::concentration > > GetConcentrations()
void SetCellPopulation(AbstractCellPopulation< DIM > &rCellPopulation, units::quantity< unit::length > cellPopulationReferenceLength, units::quantity< unit::concentration > cellPopulationReferenceConcentration)
virtual void UpdateSolution(const std::vector< double > &rData)
void SetNonLinearPde(boost::shared_ptr< AbstractDiscreteContinuumNonLinearEllipticPde< DIM, DIM > > pPde)
void SetPde(boost::shared_ptr< AbstractDiscreteContinuumLinearEllipticPde< DIM, DIM > > pPde)
boost::shared_ptr< AbstractDiscreteContinuumLinearEllipticPde< DIM, DIM > > mpPde
void SetReferenceConcentration(units::quantity< unit::concentration > referenceConcentration)
boost::shared_ptr< OutputFileHandler > mpOutputFileHandler
void SetFileHandler(boost::shared_ptr< OutputFileHandler > pOutputFileHandler)
AbstractCellPopulation< DIM > * mpCellPopulation
std::vector< units::quantity< unit::concentration > > mConcentrations
boost::shared_ptr< AbstractDiscreteContinuumLinearEllipticPde< DIM, DIM > > GetPde()
void AddBoundaryCondition(boost::shared_ptr< DiscreteContinuumBoundaryCondition< DIM > > pBoundaryCondition)
void SetVesselNetwork(boost::shared_ptr< VesselNetwork< DIM > > pNetwork)
std::vector< boost::shared_ptr< DiscreteContinuumBoundaryCondition< DIM > > > mBoundaryConditions
boost::shared_ptr< AbstractDiscreteContinuumNonLinearEllipticPde< DIM, DIM > > GetNonLinearPde()
boost::shared_ptr< AbstractDiscreteContinuumNonLinearEllipticPde< DIM, DIM > > mpNonLinearPde
boost::shared_ptr< VesselNetwork< DIM > > mpNetwork
units::quantity< unit::concentration > mReferenceConcentration
units::quantity< unit::concentration > mCellPopulationReferenceConcentration
units::quantity< unit::concentration > GetReferenceConcentration()
units::quantity< unit::length > mCellPopulationReferenceLength
void SetFileName(const std::string &rFilename)