Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/grower.h
[mareframe] / trunk / gadget / grower.h Repository:
ViewVC logotype

Annotation of /trunk/gadget/grower.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #ifndef grower_h
2 :     #define grower_h
3 :    
4 :     #include "areatime.h"
5 :     #include "conversionindex.h"
6 :     #include "commentstream.h"
7 :     #include "popinfomatrix.h"
8 :     #include "doublematrixptrvector.h"
9 :     #include "livesonareas.h"
10 :     #include "formulavector.h"
11 :     #include "keeper.h"
12 :     #include "growthcalc.h"
13 :    
14 :     /**
15 :     * \class Grower
16 :     * \brief This is the class used to calculate, and implement, the affect of growth on the stock
17 :     *
18 :     * This class calculates the growth of the stock, according to the different growth functions derived from the GrowthCalcBase class. Since the growth calculations can take place on a coarser scale than the stock is defined on, the calculated growth is then interpolated to take the length group of the stock into account. This growth is then implemented by moving the fish up from the old length groups to the new length groups, taking care to ensure that the fish that would move to beyond the largest length group are kept in the plus group.
19 :     */
20 :     class Grower : public HasName, protected LivesOnAreas {
21 :     public:
22 :     /**
23 :     * \brief This is the Grower constructor
24 :     * \param infile is the CommentStream to read the growth data from
25 :     * \param OtherLgrpDiv is the LengthGroupDivision of the stock
26 :     * \param GivenLgrpDiv is the LengthGroupDivision that the growth will be calculated on
27 :     * \param Areas is the IntVector of areas that the stock lives on
28 :     * \param TimeInfo is the TimeClass for the current model
29 :     * \param keeper is the Keeper for the current model
30 :     * \param refWeight is the name of the file containing the reference weight information for the stock
31 :     * \param givenname is the name of the stock for this Grower class
32 :     * \param Area is the AreaClass for the current model
33 :     * \param lenindex is the CharPtrVector of the lengths used for the growth of the stock
34 :     */
35 :     Grower(CommentStream& infile, const LengthGroupDivision* const OtherLgrpDiv,
36 :     const LengthGroupDivision* const GivenLgrpDiv, const IntVector& Areas,
37 :     const TimeClass* const TimeInfo, Keeper* const keeper, const char* refWeight,
38 :     const char* givenname, const AreaClass* const Area, const CharPtrVector& lenindex);
39 :     /**
40 :     * \brief This is the default Grower destructor
41 :     */
42 :     ~Grower();
43 :     /**
44 :     * \brief This will calculate the growth of the stock for the current timestep on a given area
45 :     * \param area is the area that the growth is being calculated on
46 :     * \param Area is the AreaClass for the current model
47 :     * \param TimeInfo is the TimeClass for the current model
48 :     * \param FeedingLevel is the DoubleVector of the feeding level of the stock
49 :     * \param Consumption is the DoubleVector of the maximum consumption of the stock
50 :     */
51 :     void calcGrowth(int area, const AreaClass* const Area, const TimeClass* const TimeInfo,
52 :     const DoubleVector& FeedingLevel, const DoubleVector& Consumption);
53 :     /**
54 :     * \brief This will calculate the growth of the stock for the current timestep on a given area
55 :     * \param area is the area that the growth is being calculated on
56 :     * \param Area is the AreaClass for the current model
57 :     * \param TimeInfo is the TimeClass for the current model
58 :     */
59 :     void calcGrowth(int area, const AreaClass* const Area, const TimeClass* const TimeInfo);
60 :     /**
61 :     * \brief This will implement the calculated changes due to growth of the stock
62 :     * \param area is the area that the growth is being calculated on
63 :     * \param NumberInArea is the PopInfoVector giving the current population of the stock
64 :     * \param Lengths is the LengthGroupDivision of the stock
65 :     */
66 :     void implementGrowth(int area, const PopInfoVector& NumberInArea,
67 :     const LengthGroupDivision* const Lengths);
68 :     /**
69 :     * \brief This will implement the calculated changes due to growth of the stock
70 :     * \param area is the area that the growth is being calculated on
71 :     * \param Lengths is the LengthGroupDivision of the stock
72 :     */
73 :     void implementGrowth(int area, const LengthGroupDivision* const Lengths);
74 :     /**
75 :     * \brief This will calculate the amount of the stock that is on a given area and timestep
76 :     * \param NumberInArea is the PopInfoVector giving the amount of the stock in the area
77 :     * \param area is the area that the growth is being calculated on
78 :     */
79 :     void Sum(const PopInfoVector& NumberInArea, int area);
80 :     /**
81 :     * \brief This will reset the growth information for the current model run
82 :     */
83 :     void Reset();
84 :     /**
85 :     * \brief This function will print the growth data
86 :     * \param outfile is the ofstream that all the model information gets sent to
87 :     */
88 :     void Print(ofstream& outfile) const;
89 :     /**
90 :     * \brief This function will return the calculated length increase due to growth on an area
91 :     * \param area is the area that the growth is being calculated on
92 :     * \return lgrowth, a DoubleMatrix containing the length increase
93 :     */
94 :     const DoubleMatrix& getLengthIncrease(int area) const { return *lgrowth[this->areaNum(area)]; };
95 :     /**
96 :     * \brief This function will return the calculated weight increase due to growth on an area
97 :     * \param area is the area that the growth is being calculated on
98 :     * \return wgrowth, a DoubleMatrix containing the weight increase
99 :     */
100 :     const DoubleMatrix& getWeightIncrease(int area) const { return *wgrowth[this->areaNum(area)]; };
101 :     /**
102 :     * \brief This function will return the fixed weight increase due to growth on an area
103 :     * \param area is the area that the growth is being calculated on
104 :     * \return interpWeightGrowth, a DoubleVector containing the weight increase
105 :     */
106 :     const DoubleVector& getWeight(int area) const { return interpWeightGrowth[this->areaNum(area)]; };
107 :     /**
108 :     * \brief This will return the flag used to denote whether the weights have been fixed or not
109 :     * \return fixedweights
110 :     */
111 :     int getFixedWeights() { return fixedweights; };
112 :     protected:
113 :     /**
114 :     * \brief This is the PopInfoMatrix used to store information about the current population of the stock that is to grow according to the growth calculations
115 :     */
116 :     PopInfoMatrix numGrow;
117 :     /**
118 :     * \brief This is the LengthGroupDivision used to store length information
119 :     */
120 :     LengthGroupDivision* LgrpDiv;
121 :     /**
122 :     * \brief This is the ConversionIndex used to convert from the stock LengthGroupDivision to the LengthGroupDivision used for the growth calculation
123 :     */
124 :     ConversionIndex* CI;
125 :     /**
126 :     * \brief This is the DoubleMatrix used to store the increase in length on the current timestep
127 :     * \note The indices for this object are [area][stock length]
128 :     */
129 :     DoubleMatrix interpLengthGrowth;
130 :     /**
131 :     * \brief This is the DoubleMatrix used to store the increase in weight on the current timestep
132 :     * \note The indices for this object are [area][stock length]
133 :     */
134 :     DoubleMatrix interpWeightGrowth;
135 :     /**
136 :     * \brief This is the DoubleMatrix used to store the calculated increase in length on the current timestep
137 :     * \note The indices for this object are [area][length]
138 :     */
139 :     DoubleMatrix calcLengthGrowth;
140 :     /**
141 :     * \brief This is the DoubleMatrix used to store the calculated increase in weight on the current timestep
142 :     * \note The indices for this object are [area][length]
143 :     */
144 :     DoubleMatrix calcWeightGrowth;
145 :     /**
146 :     * \brief This is the DoubleMatrixPtrVector used to store the calculated increase in length for each length group on the current timestep
147 :     * \note The indices for this object are [area][change in length][stock length]
148 :     */
149 :     DoubleMatrixPtrVector lgrowth;
150 :     /**
151 :     * \brief This is the DoubleMatrixPtrVector used to store the calculated increase in weight for each length group on the current timestep
152 :     * \note The indices for this object are [area][change in length][stock length]
153 :     */
154 :     DoubleMatrixPtrVector wgrowth;
155 :     /**
156 :     * \brief This is the dummy DoubleVector used during the growth calculation
157 :     * \note The values of this vector are set to zero, and never used, unless the growth function depends on the feeding level of the stock (ie. growth is based on consumption of preys)
158 :     */
159 :     DoubleVector dummyfphi;
160 :     /**
161 :     * \brief This is the GrowthCalcBase used to calculate the growth information
162 :     */
163 :     GrowthCalcBase* growthcalc;
164 :     /**
165 :     * \brief This is the identifier of the function to be used to calculate the growth
166 :     */
167 :     int functionnumber;
168 :     /**
169 :     * \brief This is the flag used to denote whether the change is weight is to be calculated, or fixed to values specified in the input files
170 :     */
171 :     int fixedweights;
172 :     /**
173 :     * \brief This is the maximum number of length groups that an individual fish from the stock can grow on one timestep
174 :     */
175 :     int maxlengthgroupgrowth;
176 :     /**
177 :     * \brief This is the mean growth, as calculated for this length group by the GrowthCalc function
178 :     */
179 :     double growth;
180 :     /**
181 :     * \brief This is the value of alpha in the beta binomial distribution
182 :     */
183 :     double alpha;
184 :     /**
185 :     * \brief This is the value of beta in the beta binomial distribution
186 :     */
187 :     Formula beta;
188 :     /**
189 :     * \brief This is a DoubleVector used when calculating the beta binomial distribution
190 :     * \note This stores the value of n*(n-1)*....(n-x+1)/x!
191 :     */
192 :     DoubleVector part1;
193 :     /**
194 :     * \brief This is a DoubleVector used when calculating the beta binomial distribution
195 :     * \note This stores the value of gamma(n-x+beta)/gamma(beta)
196 :     */
197 :     DoubleVector part2;
198 :     /**
199 :     * \brief This is a double used when calculating the beta binomial distribution
200 :     * \note This stores the value of gamma(alpha+beta)/gamma(n+alpha+beta)
201 :     */
202 :     double part3;
203 :     /**
204 :     * \brief This is a DoubleVector used when calculating the beta binomial distribution
205 :     * \note This stores the value of gamma(x+alpha)/gamma(x)
206 :     */
207 :     DoubleVector part4;
208 :     };
209 :    
210 :     #endif

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge