100 |
numGrow.AddRows(noareas, len, nullpop); |
numGrow.AddRows(noareas, len, nullpop); |
101 |
|
|
102 |
//setting storage spaces for growth |
//setting storage spaces for growth |
103 |
// calcLengthGrowth.AddRows(noareas, len, 0.0); |
calcLengthGrowth.AddRows(noareas, len, 0.0); |
104 |
// calcWeightGrowth.AddRows(noareas, len, 0.0); |
calcWeightGrowth.AddRows(noareas, len, 0.0); |
|
_calcLengthGrowth.AddRows(noareas, len, 0.0); |
|
|
_calcWeightGrowth.AddRows(noareas, len, 0.0); |
|
105 |
interpLengthGrowth.AddRows(noareas, otherlen, 0.0); |
interpLengthGrowth.AddRows(noareas, otherlen, 0.0); |
106 |
interpWeightGrowth.AddRows(noareas, otherlen, 0.0); |
interpWeightGrowth.AddRows(noareas, otherlen, 0.0); |
107 |
dummyfphi.resize(len, 0.0); |
dummyfphi.resize(len, 0.0); |
108 |
_lgrowth = new Matrix[noareas]; |
lgrowth = new Matrix[noareas]; |
109 |
_wgrowth = new Matrix[noareas]; |
wgrowth = new Matrix[noareas]; |
110 |
|
|
111 |
for (i = 0; i < noareas; i++) { |
for (i = 0; i < noareas; i++) { |
112 |
// lgrowth.resize(new DoubleMatrix(maxlengthgroupgrowth + 1, otherlen, 0.0)); |
lgrowth[i] = *new Matrix(maxlengthgroupgrowth + 1, otherlen, 0.0); |
113 |
// wgrowth.resize(new DoubleMatrix(maxlengthgroupgrowth + 1, otherlen, 0.0)); |
wgrowth[i] = *new Matrix(maxlengthgroupgrowth + 1, otherlen, 0.0); |
|
_lgrowth[i] = *new Matrix(maxlengthgroupgrowth + 1, otherlen, 0.0); |
|
|
_wgrowth[i] = *new Matrix(maxlengthgroupgrowth + 1, otherlen, 0.0); |
|
114 |
} |
} |
115 |
} |
} |
116 |
|
|
117 |
Grower::~Grower() { |
Grower::~Grower() { |
118 |
int i; |
int i; |
119 |
//TODO ojo |
int size = sizeof(lgrowth)/sizeof(lgrowth[0]); |
|
int size = sizeof(_lgrowth)/sizeof(_lgrowth[0]); |
|
120 |
for (i = 0; i < size; i++) { |
for (i = 0; i < size; i++) { |
121 |
delete &_lgrowth[i]; |
delete &lgrowth[i]; |
122 |
delete &_wgrowth[i]; |
delete &wgrowth[i]; |
123 |
} |
} |
124 |
delete CI; |
delete CI; |
125 |
delete LgrpDiv; |
delete LgrpDiv; |
133 |
LgrpDiv->Print(outfile); |
LgrpDiv->Print(outfile); |
134 |
for (area = 0; area < areas.Size(); area++) { |
for (area = 0; area < areas.Size(); area++) { |
135 |
outfile << "\tLength increase on internal area " << areas[area] << ":\n\t"; |
outfile << "\tLength increase on internal area " << areas[area] << ":\n\t"; |
136 |
for (i = 0; i < _calcLengthGrowth.Ncol(); i++) |
for (i = 0; i < calcLengthGrowth.Ncol(); i++) |
137 |
outfile << sep << _calcLengthGrowth[area][i]; |
outfile << sep << calcLengthGrowth[area][i]; |
138 |
outfile << "\n\tWeight increase on internal area " << areas[area] << ":\n\t"; |
outfile << "\n\tWeight increase on internal area " << areas[area] << ":\n\t"; |
139 |
for (i = 0; i < _calcWeightGrowth.Ncol(); i++) |
for (i = 0; i < calcWeightGrowth.Ncol(); i++) |
140 |
outfile << sep << _calcWeightGrowth[area][i]; |
outfile << sep << calcWeightGrowth[area][i]; |
141 |
outfile << "\n\tDistributed length increase on internal area " << areas[area] << ":\n"; |
outfile << "\n\tDistributed length increase on internal area " << areas[area] << ":\n"; |
142 |
for (i = 0; i < _lgrowth[area].Nrow(); i++) { |
for (i = 0; i < lgrowth[area].Nrow(); i++) { |
143 |
outfile << TAB; |
outfile << TAB; |
144 |
for (j = 0; j < _lgrowth[area].Ncol(); j++) |
for (j = 0; j < lgrowth[area].Ncol(); j++) |
145 |
outfile << sep << _lgrowth[area][i][j]; |
outfile << sep << lgrowth[area][i][j]; |
146 |
outfile << endl; |
outfile << endl; |
147 |
} |
} |
148 |
outfile << "\tDistributed weight increase on internal area " << areas[area] << ":\n"; |
outfile << "\tDistributed weight increase on internal area " << areas[area] << ":\n"; |
149 |
for (i = 0; i < _wgrowth[area].Nrow(); i++) { |
for (i = 0; i < wgrowth[area].Nrow(); i++) { |
150 |
outfile << TAB; |
outfile << TAB; |
151 |
for (j = 0; j < _wgrowth[area].Ncol(); j++) |
for (j = 0; j < wgrowth[area].Ncol(); j++) |
152 |
outfile << sep << _wgrowth[area][i][j]; |
outfile << sep << wgrowth[area][i][j]; |
153 |
outfile << endl; |
outfile << endl; |
154 |
} |
} |
155 |
} |
} |
161 |
|
|
162 |
void Grower::calcGrowth(int area, |
void Grower::calcGrowth(int area, |
163 |
const AreaClass* const Area, const TimeClass* const TimeInfo) { |
const AreaClass* const Area, const TimeClass* const TimeInfo) { |
|
|
|
164 |
this->calcGrowth(area, Area, TimeInfo, dummyfphi, dummyfphi); |
this->calcGrowth(area, Area, TimeInfo, dummyfphi, dummyfphi); |
165 |
} |
} |
166 |
|
|
169 |
const DoubleVector& FPhi, const DoubleVector& MaxCon) { |
const DoubleVector& FPhi, const DoubleVector& MaxCon) { |
170 |
|
|
171 |
int inarea = this->areaNum(area); |
int inarea = this->areaNum(area); |
|
// growthcalc->calcGrowth(area, calcLengthGrowth[inarea], calcWeightGrowth[inarea], |
|
|
// numGrow[inarea], Area, TimeInfo, FPhi, MaxCon, LgrpDiv); |
|
172 |
|
|
173 |
// cout << "size::" << _calcLengthGrowth.Ncol() << endl; |
growthcalc->calcGrowth(area, calcLengthGrowth[inarea], calcWeightGrowth[inarea], |
174 |
growthcalc->calcGrowth(area, _calcLengthGrowth[inarea], _calcWeightGrowth[inarea], |
numGrow[inarea], Area, TimeInfo, FPhi, MaxCon, LgrpDiv, calcLengthGrowth.Ncol()); |
175 |
numGrow[inarea], Area, TimeInfo, FPhi, MaxCon, LgrpDiv, _calcLengthGrowth.Ncol()); |
|
176 |
// ofstream outfile; |
CI->interpolateLengths(interpLengthGrowth[inarea], calcLengthGrowth[inarea], calcLengthGrowth.Ncol()); |
|
// outfile.open("aaa", ios::out); |
|
|
// _calcLengthGrowth.Print(outfile); |
|
|
// int a; |
|
|
// cout << "2-----------------" << endl; |
|
|
// cin >> a; |
|
|
//CI->interpolateLengths(interpLengthGrowth[inarea], calcLengthGrowth[inarea]); |
|
|
CI->interpolateLengths(interpLengthGrowth[inarea], _calcLengthGrowth[inarea], _calcLengthGrowth.Ncol()); |
|
177 |
switch (functionnumber) { |
switch (functionnumber) { |
178 |
case 1: |
case 1: |
179 |
case 2: |
case 2: |
183 |
case 6: |
case 6: |
184 |
case 7: |
case 7: |
185 |
case 9: |
case 9: |
186 |
// CI->interpolateLengths(interpWeightGrowth[inarea], calcWeightGrowth[inarea]); |
CI->interpolateLengths(interpWeightGrowth[inarea], calcWeightGrowth[inarea], calcWeightGrowth.Ncol()); |
|
CI->interpolateLengths(interpWeightGrowth[inarea], _calcWeightGrowth[inarea], _calcWeightGrowth.Ncol()); |
|
187 |
break; |
break; |
188 |
case 8: |
case 8: |
189 |
case 10: |
case 10: |
193 |
handle.logMessage(LOGFAIL, "Error in grower - unrecognised growth function", functionnumber); |
handle.logMessage(LOGFAIL, "Error in grower - unrecognised growth function", functionnumber); |
194 |
break; |
break; |
195 |
} |
} |
|
// ofstream outfile1; |
|
|
// outfile1.open("aaa", ios::out); |
|
|
// _calcLengthGrowth.Print(outfile1); |
|
|
// cout << "-----------------" << endl; |
|
|
// cin >> a; |
|
196 |
} |
} |
197 |
|
|
198 |
void Grower::Reset() { |
void Grower::Reset() { |
199 |
int i, j, area; |
int i, j, area; |
200 |
double factorialx, tmppart, tmpmax; |
double factorialx, tmppart, tmpmax; |
201 |
|
|
202 |
// calcLengthGrowth.setToZero(); |
calcLengthGrowth.setToZero(); |
203 |
// calcWeightGrowth.setToZero(); |
calcWeightGrowth.setToZero(); |
|
_calcLengthGrowth.setToZero(); |
|
|
_calcWeightGrowth.setToZero(); |
|
204 |
interpLengthGrowth.setToZero(); |
interpLengthGrowth.setToZero(); |
205 |
for (area = 0; area < areas.Size(); area++) { |
for (area = 0; area < areas.Size(); area++) { |
206 |
(_lgrowth[area]).setToZero(); |
(lgrowth[area]).setToZero(); |
207 |
for (i = 0; i < LgrpDiv->numLengthGroups(); i++) |
for (i = 0; i < LgrpDiv->numLengthGroups(); i++) |
208 |
numGrow[area][i].setToZero(); |
numGrow[area][i].setToZero(); |
209 |
} |
} |
219 |
case 9: |
case 9: |
220 |
interpWeightGrowth.setToZero(); |
interpWeightGrowth.setToZero(); |
221 |
for (area = 0; area < areas.Size(); area++) |
for (area = 0; area < areas.Size(); area++) |
222 |
(_wgrowth[area]).setToZero(); |
(wgrowth[area]).setToZero(); |
223 |
break; |
break; |
224 |
case 8: |
case 8: |
225 |
case 10: |
case 10: |