Chaste  Build::
SolutionDependentDiscreteSource.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 "SolutionDependentDiscreteSource.hpp"
37 #include "AbstractCellPopulation.hpp"
38 #include "VesselNetwork.hpp"
39 #include "GeometryTools.hpp"
40 
41 template<unsigned DIM>
43  : DiscreteSource<DIM>(),
44  mpSolution(),
45  mConstantInUSinkRatePerSolutionQuantity(0.0*unit::per_second),
46  mLinearInUSinkRatePerSolutionQuantity(0.0*unit::metre_cubed_per_mole_per_second)
47 {
48 
49 }
50 
51 template<unsigned DIM>
53 {
54 
55 }
56 
57 template<unsigned DIM>
58 boost::shared_ptr<SolutionDependentDiscreteSource<DIM> > SolutionDependentDiscreteSource<DIM>::Create()
59 {
60  MAKE_PTR(SolutionDependentDiscreteSource<DIM>, pSelf);
61  return pSelf;
62 }
63 
64 template<unsigned DIM>
65 std::vector<units::quantity<unit::concentration_flow_rate> > SolutionDependentDiscreteSource<DIM>::GetConstantInUMeshValues()
66 {
67  if(!this->mpMesh)
68  {
69  EXCEPTION("A mesh is required for this type of source");
70  }
71 
72  std::vector<units::quantity<unit::concentration_flow_rate> > values(this->mpMesh->GetNumElements(), 0.0*unit::mole_per_metre_cubed_per_second);
73  if(mpSolution.size() != this->mpMesh->GetNumElements())
74  {
75  EXCEPTION("A solution sampled on the mesh is required for this type of source");
76  }
77  for(unsigned idx=0; idx<this->mpMesh->GetNumElements(); idx++)
78  {
80  }
81  return values;
82 }
83 
84 template<unsigned DIM>
85 std::vector<units::quantity<unit::rate> > SolutionDependentDiscreteSource<DIM>::GetLinearInUMeshValues()
86 {
87  if(!this->mpMesh)
88  {
89  EXCEPTION("A mesh is required for this type of source");
90  }
91 
92  std::vector<units::quantity<unit::rate> > values(this->mpMesh->GetNumElements(), 0.0*unit::per_second);
93  if(mpSolution.size() != this->mpMesh->GetNumElements())
94  {
95  EXCEPTION("A solution sampled on the mesh is required for this type of source");
96  }
97  for(unsigned idx=0; idx<this->mpMesh->GetNumElements(); idx++)
98  {
100  }
101  return values;
102 }
103 
104 template<unsigned DIM>
105 std::vector<units::quantity<unit::concentration_flow_rate> > SolutionDependentDiscreteSource<DIM>::GetConstantInURegularGridValues()
106 {
107  std::vector<units::quantity<unit::concentration_flow_rate> > values(this->mpRegularGrid->GetNumberOfPoints(), 0.0*unit::mole_per_metre_cubed_per_second);
108  if(mpSolution.size() != this->mpRegularGrid->GetNumberOfPoints())
109  {
110  EXCEPTION("A solution sampled on the grid is required for this type of source");
111  }
112  for(unsigned idx=0; idx<this->mpRegularGrid->GetNumberOfPoints(); idx++)
113  {
115  }
116  return values;
117 }
118 
119 template<unsigned DIM>
121 {
122  std::vector<units::quantity<unit::rate> > values(this->mpRegularGrid->GetNumberOfPoints(), 0.0*unit::per_second);
123  if(mpSolution.size() != this->mpRegularGrid->GetNumberOfPoints())
124  {
125  EXCEPTION("A solution sampled on the grid is required for this type of source");
126  }
127  for(unsigned idx=0; idx<this->mpRegularGrid->GetNumberOfPoints(); idx++)
128  {
130  }
131  return values;
132 }
133 
134 template<unsigned DIM>
135 void SolutionDependentDiscreteSource<DIM>::SetSolution(std::vector<units::quantity<unit::concentration> > solution)
136 {
137  mpSolution = solution;
138 }
139 
140 template<unsigned DIM>
142 {
144 }
145 
146 template<unsigned DIM>
147 void SolutionDependentDiscreteSource<DIM>::SetLinearInUSinkRatePerSolutionQuantity(units::quantity<unit::rate_per_concentration> value)
148 {
150 }
151 
152 // Explicit instantiation
void SetSolution(std::vector< units::quantity< unit::concentration > > solution)
virtual std::vector< units::quantity< unit::rate > > GetLinearInURegularGridValues()
virtual std::vector< units::quantity< unit::concentration_flow_rate > > GetConstantInURegularGridValues()
boost::shared_ptr< RegularGrid< DIM > > mpRegularGrid
void SetConstantInUSinkRatePerSolutionQuantity(units::quantity< unit::rate > value)
static boost::shared_ptr< SolutionDependentDiscreteSource< DIM > > Create()
units::quantity< unit::rate_per_concentration > mLinearInUSinkRatePerSolutionQuantity
void SetLinearInUSinkRatePerSolutionQuantity(units::quantity< unit::rate_per_concentration > value)
units::quantity< unit::rate > mConstantInUSinkRatePerSolutionQuantity
virtual std::vector< units::quantity< unit::concentration_flow_rate > > GetConstantInUMeshValues()
std::vector< units::quantity< unit::concentration > > mpSolution
virtual std::vector< units::quantity< unit::rate > > GetLinearInUMeshValues()
boost::shared_ptr< DiscreteContinuumMesh< DIM, DIM > > mpMesh