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] Diff of /trunk/gadget/grower.cc
[mareframe] / trunk / gadget / grower.cc Repository:
ViewVC logotype

Diff of /trunk/gadget/grower.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2, Wed Apr 29 12:55:30 2015 UTC revision 5, Sun May 10 12:04:01 2015 UTC
# Line 100  Line 100 
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    for (i = 0; i < noareas; i++) {    for (i = 0; i < noareas; i++) {
111  //    lgrowth.resize(new DoubleMatrix(maxlengthgroupgrowth + 1, otherlen, 0.0));            lgrowth[i].Initialize(maxlengthgroupgrowth + 1, otherlen, 0.0);
112  //    wgrowth.resize(new DoubleMatrix(maxlengthgroupgrowth + 1, otherlen, 0.0));            wgrowth[i].Initialize(maxlengthgroupgrowth + 1, otherlen, 0.0);
113            _lgrowth[i] = *new Matrix(maxlengthgroupgrowth + 1, otherlen, 0.0);  //        lgrowth[i] = new Matrix(maxlengthgroupgrowth + 1, otherlen, 0.0);
114            _wgrowth[i] = *new Matrix(maxlengthgroupgrowth + 1, otherlen, 0.0);  //        wgrowth[i] = new Matrix(maxlengthgroupgrowth + 1, otherlen, 0.0);
115    }    }
116  }  }
117    
118  Grower::~Grower() {  Grower::~Grower() {
119    int i;    int i;
120    //TODO ojo    //int size = sizeof(lgrowth)/sizeof(lgrowth[0]);
121    int size = sizeof(_lgrowth)/sizeof(_lgrowth[0]);    int size = areas.Size();
122    for (i = 0; i < size; i++) {  //  for (i = 0; i < size; i++) {
123      delete &_lgrowth[i];  //    delete (*lgrowth)[i];
124      delete &_wgrowth[i];  //    delete (*wgrowth)[i];
125    }  //  }
126      delete[] lgrowth;
127      delete[] wgrowth;
128    delete CI;    delete CI;
129    delete LgrpDiv;    delete LgrpDiv;
130    delete growthcalc;    delete growthcalc;
131      if (vector_OK != 0)
132              delete[] meanlength_vectorPow;
133  }  }
134    
135  void Grower::Print(ofstream& outfile) const {  void Grower::Print(ofstream& outfile) const {
# Line 138  Line 139 
139    LgrpDiv->Print(outfile);    LgrpDiv->Print(outfile);
140    for (area = 0; area < areas.Size(); area++) {    for (area = 0; area < areas.Size(); area++) {
141      outfile << "\tLength increase on internal area " << areas[area] << ":\n\t";      outfile << "\tLength increase on internal area " << areas[area] << ":\n\t";
142      for (i = 0; i < _calcLengthGrowth.Ncol(); i++)      for (i = 0; i < calcLengthGrowth.Ncol(); i++)
143        outfile << sep << _calcLengthGrowth[area][i];        outfile << sep << calcLengthGrowth[area][i];
144      outfile << "\n\tWeight increase on internal area " << areas[area] << ":\n\t";      outfile << "\n\tWeight increase on internal area " << areas[area] << ":\n\t";
145      for (i = 0; i < _calcWeightGrowth.Ncol(); i++)      for (i = 0; i < calcWeightGrowth.Ncol(); i++)
146        outfile << sep << _calcWeightGrowth[area][i];        outfile << sep << calcWeightGrowth[area][i];
147      outfile << "\n\tDistributed length increase on internal area " << areas[area] << ":\n";      outfile << "\n\tDistributed length increase on internal area " << areas[area] << ":\n";
148      for (i = 0; i < _lgrowth[area].Nrow(); i++) {      for (i = 0; i < lgrowth[area].Nrow(); i++) {
149        outfile << TAB;        outfile << TAB;
150        for (j = 0; j < _lgrowth[area].Ncol(); j++)        for (j = 0; j < lgrowth[area].Ncol(); j++)
151          outfile << sep << _lgrowth[area][i][j];          outfile << sep << lgrowth[area][i][j];
152        outfile << endl;        outfile << endl;
153      }      }
154      outfile << "\tDistributed weight increase on internal area " << areas[area] << ":\n";      outfile << "\tDistributed weight increase on internal area " << areas[area] << ":\n";
155      for (i = 0; i < _wgrowth[area].Nrow(); i++) {      for (i = 0; i < wgrowth[area].Nrow(); i++) {
156        outfile << TAB;        outfile << TAB;
157        for (j = 0; j < _wgrowth[area].Ncol(); j++)        for (j = 0; j < wgrowth[area].Ncol(); j++)
158          outfile << sep << _wgrowth[area][i][j];          outfile << sep << wgrowth[area][i][j];
159        outfile << endl;        outfile << endl;
160      }      }
161    }    }
# Line 166  Line 167 
167    
168  void Grower::calcGrowth(int area,  void Grower::calcGrowth(int area,
169    const AreaClass* const Area, const TimeClass* const TimeInfo) {    const AreaClass* const Area, const TimeClass* const TimeInfo) {
   
170    this->calcGrowth(area, Area, TimeInfo, dummyfphi, dummyfphi);    this->calcGrowth(area, Area, TimeInfo, dummyfphi, dummyfphi);
171  }  }
172    
# Line 175  Line 175 
175    const DoubleVector& FPhi, const DoubleVector& MaxCon) {    const DoubleVector& FPhi, const DoubleVector& MaxCon) {
176    
177    int inarea = this->areaNum(area);    int inarea = this->areaNum(area);
 //  growthcalc->calcGrowth(area, calcLengthGrowth[inarea], calcWeightGrowth[inarea],  
 //    numGrow[inarea], Area, TimeInfo, FPhi, MaxCon, LgrpDiv);  
178    
179  //  cout << "size::" << _calcLengthGrowth.Ncol() << endl;    growthcalc->calcGrowth(area, calcLengthGrowth[inarea], calcWeightGrowth[inarea],
180    growthcalc->calcGrowth(area, _calcLengthGrowth[inarea], _calcWeightGrowth[inarea],        numGrow[inarea], Area, TimeInfo, FPhi, MaxCon, LgrpDiv, calcLengthGrowth.Ncol());
181        numGrow[inarea], Area, TimeInfo, FPhi, MaxCon, LgrpDiv, _calcLengthGrowth.Ncol());  
182  //  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());  
183    switch (functionnumber) {    switch (functionnumber) {
184      case 1:      case 1:
185      case 2:      case 2:
# Line 198  Line 189 
189      case 6:      case 6:
190      case 7:      case 7:
191      case 9:      case 9:
192  //      CI->interpolateLengths(interpWeightGrowth[inarea], calcWeightGrowth[inarea]);          CI->interpolateLengths(interpWeightGrowth[inarea], calcWeightGrowth[inarea], calcWeightGrowth.Ncol());
         CI->interpolateLengths(interpWeightGrowth[inarea], _calcWeightGrowth[inarea], _calcWeightGrowth.Ncol());  
193        break;        break;
194      case 8:      case 8:
195      case 10:      case 10:
# Line 209  Line 199 
199        handle.logMessage(LOGFAIL, "Error in grower - unrecognised growth function", functionnumber);        handle.logMessage(LOGFAIL, "Error in grower - unrecognised growth function", functionnumber);
200        break;        break;
201    }    }
 //  ofstream outfile1;  
 //              outfile1.open("aaa", ios::out);  
 //              _calcLengthGrowth.Print(outfile1);  
 //            cout << "-----------------" << endl;  
 //            cin >> a;  
202  }  }
203    
204  void Grower::Reset() {  void Grower::Reset() {
205    int i, j, area;    int i, j, area;
206    double factorialx, tmppart, tmpmax;    double factorialx, tmppart, tmpmax;
207    
208  //  calcLengthGrowth.setToZero();    calcLengthGrowth.setToZero();
209  //  calcWeightGrowth.setToZero();    calcWeightGrowth.setToZero();
   _calcLengthGrowth.setToZero();  
   _calcWeightGrowth.setToZero();  
210    interpLengthGrowth.setToZero();    interpLengthGrowth.setToZero();
211    for (area = 0; area < areas.Size(); area++) {    for (area = 0; area < areas.Size(); area++) {
212      (_lgrowth[area]).setToZero();      (lgrowth[area]).setToZero();
213      for (i = 0; i < LgrpDiv->numLengthGroups(); i++)      for (i = 0; i < LgrpDiv->numLengthGroups(); i++)
214        numGrow[area][i].setToZero();        numGrow[area][i].setToZero();
215    }    }
216      if (vector_OK != 0)
217      {
218              delete[] meanlength_vectorPow;
219              vector_OK = 0;
220      }
221    
222    switch (functionnumber) {    switch (functionnumber) {
223      case 1:      case 1:
# Line 242  Line 230 
230      case 9:      case 9:
231        interpWeightGrowth.setToZero();        interpWeightGrowth.setToZero();
232        for (area = 0; area < areas.Size(); area++)        for (area = 0; area < areas.Size(); area++)
233          (_wgrowth[area]).setToZero();          (wgrowth[area]).setToZero();
234        break;        break;
235      case 8:      case 8:
236      case 10:      case 10:

Legend:
Removed from v.2  
changed lines
  Added in v.5

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

Powered By FusionForge