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 1, Mon Feb 10 17:09:07 2014 UTC revision 2, Wed Apr 29 12:55:30 2015 UTC
# Line 22  Line 22 
22    fixedweights = 0;    fixedweights = 0;
23    functionnumber = 0;    functionnumber = 0;
24    LgrpDiv = new LengthGroupDivision(*GivenLgrpDiv);    LgrpDiv = new LengthGroupDivision(*GivenLgrpDiv);
25      vector_OK = 0;
26    if (LgrpDiv->Error())    if (LgrpDiv->Error())
27      handle.logMessage(LOGFAIL, "Error in grower - failed to create length group");      handle.logMessage(LOGFAIL, "Error in grower - failed to create length group");
28    CI = new ConversionIndex(OtherLgrpDiv, LgrpDiv, 1);    CI = new ConversionIndex(OtherLgrpDiv, LgrpDiv, 1);
# Line 99  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);
105      _calcLengthGrowth.AddRows(noareas, len, 0.0);
106      _calcWeightGrowth.AddRows(noareas, len, 0.0);
107    interpLengthGrowth.AddRows(noareas, otherlen, 0.0);    interpLengthGrowth.AddRows(noareas, otherlen, 0.0);
108    interpWeightGrowth.AddRows(noareas, otherlen, 0.0);    interpWeightGrowth.AddRows(noareas, otherlen, 0.0);
109    dummyfphi.resize(len, 0.0);    dummyfphi.resize(len, 0.0);
110      _lgrowth = new Matrix[noareas];
111      _wgrowth = new Matrix[noareas];
112    
113    for (i = 0; i < noareas; i++) {    for (i = 0; i < noareas; i++) {
114      lgrowth.resize(new DoubleMatrix(maxlengthgroupgrowth + 1, otherlen, 0.0));  //    lgrowth.resize(new DoubleMatrix(maxlengthgroupgrowth + 1, otherlen, 0.0));
115      wgrowth.resize(new DoubleMatrix(maxlengthgroupgrowth + 1, otherlen, 0.0));  //    wgrowth.resize(new DoubleMatrix(maxlengthgroupgrowth + 1, otherlen, 0.0));
116              _lgrowth[i] = *new Matrix(maxlengthgroupgrowth + 1, otherlen, 0.0);
117              _wgrowth[i] = *new Matrix(maxlengthgroupgrowth + 1, otherlen, 0.0);
118    }    }
119  }  }
120    
121  Grower::~Grower() {  Grower::~Grower() {
122    int i;    int i;
123    for (i = 0; i < lgrowth.Size(); i++) {    //TODO ojo
124      delete lgrowth[i];    int size = sizeof(_lgrowth)/sizeof(_lgrowth[0]);
125      delete wgrowth[i];    for (i = 0; i < size; i++) {
126        delete &_lgrowth[i];
127        delete &_wgrowth[i];
128    }    }
129    delete CI;    delete CI;
130    delete LgrpDiv;    delete LgrpDiv;
# Line 128  Line 138 
138    LgrpDiv->Print(outfile);    LgrpDiv->Print(outfile);
139    for (area = 0; area < areas.Size(); area++) {    for (area = 0; area < areas.Size(); area++) {
140      outfile << "\tLength increase on internal area " << areas[area] << ":\n\t";      outfile << "\tLength increase on internal area " << areas[area] << ":\n\t";
141      for (i = 0; i < calcLengthGrowth.Ncol(area); i++)      for (i = 0; i < _calcLengthGrowth.Ncol(); i++)
142        outfile << sep << calcLengthGrowth[area][i];        outfile << sep << _calcLengthGrowth[area][i];
143      outfile << "\n\tWeight increase on internal area " << areas[area] << ":\n\t";      outfile << "\n\tWeight increase on internal area " << areas[area] << ":\n\t";
144      for (i = 0; i < calcWeightGrowth.Ncol(area); i++)      for (i = 0; i < _calcWeightGrowth.Ncol(); i++)
145        outfile << sep << calcWeightGrowth[area][i];        outfile << sep << _calcWeightGrowth[area][i];
146      outfile << "\n\tDistributed length increase on internal area " << areas[area] << ":\n";      outfile << "\n\tDistributed length increase on internal area " << areas[area] << ":\n";
147      for (i = 0; i < lgrowth[area]->Nrow(); i++) {      for (i = 0; i < _lgrowth[area].Nrow(); i++) {
148        outfile << TAB;        outfile << TAB;
149        for (j = 0; j < lgrowth[area]->Ncol(i); j++)        for (j = 0; j < _lgrowth[area].Ncol(); j++)
150          outfile << sep << (*lgrowth[area])[i][j];          outfile << sep << _lgrowth[area][i][j];
151        outfile << endl;        outfile << endl;
152      }      }
153      outfile << "\tDistributed weight increase on internal area " << areas[area] << ":\n";      outfile << "\tDistributed weight increase on internal area " << areas[area] << ":\n";
154      for (i = 0; i < wgrowth[area]->Nrow(); i++) {      for (i = 0; i < _wgrowth[area].Nrow(); i++) {
155        outfile << TAB;        outfile << TAB;
156        for (j = 0; j < wgrowth[area]->Ncol(i); j++)        for (j = 0; j < _wgrowth[area].Ncol(); j++)
157          outfile << sep << (*wgrowth[area])[i][j];          outfile << sep << _wgrowth[area][i][j];
158        outfile << endl;        outfile << endl;
159      }      }
160    }    }
# Line 165  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);
178    growthcalc->calcGrowth(area, calcLengthGrowth[inarea], calcWeightGrowth[inarea],  //  growthcalc->calcGrowth(area, calcLengthGrowth[inarea], calcWeightGrowth[inarea],
179      numGrow[inarea], Area, TimeInfo, FPhi, MaxCon, LgrpDiv);  //    numGrow[inarea], Area, TimeInfo, FPhi, MaxCon, LgrpDiv);
180    
181    CI->interpolateLengths(interpLengthGrowth[inarea], calcLengthGrowth[inarea]);  //  cout << "size::" << _calcLengthGrowth.Ncol() << endl;
182      growthcalc->calcGrowth(area, _calcLengthGrowth[inarea], _calcWeightGrowth[inarea],
183          numGrow[inarea], Area, TimeInfo, FPhi, MaxCon, LgrpDiv, _calcLengthGrowth.Ncol());
184    //  ofstream outfile;
185    //            outfile.open("aaa", ios::out);
186    //            _calcLengthGrowth.Print(outfile);
187    //          int a;
188    //          cout << "2-----------------" << endl;
189    //          cin >> a;
190      //CI->interpolateLengths(interpLengthGrowth[inarea], calcLengthGrowth[inarea]);
191      CI->interpolateLengths(interpLengthGrowth[inarea], _calcLengthGrowth[inarea], _calcLengthGrowth.Ncol());
192    switch (functionnumber) {    switch (functionnumber) {
193      case 1:      case 1:
194      case 2:      case 2:
# Line 178  Line 198 
198      case 6:      case 6:
199      case 7:      case 7:
200      case 9:      case 9:
201        CI->interpolateLengths(interpWeightGrowth[inarea], calcWeightGrowth[inarea]);  //      CI->interpolateLengths(interpWeightGrowth[inarea], calcWeightGrowth[inarea]);
202            CI->interpolateLengths(interpWeightGrowth[inarea], _calcWeightGrowth[inarea], _calcWeightGrowth.Ncol());
203        break;        break;
204      case 8:      case 8:
205      case 10:      case 10:
# Line 188  Line 209 
209        handle.logMessage(LOGFAIL, "Error in grower - unrecognised growth function", functionnumber);        handle.logMessage(LOGFAIL, "Error in grower - unrecognised growth function", functionnumber);
210        break;        break;
211    }    }
212    //  ofstream outfile1;
213    //              outfile1.open("aaa", ios::out);
214    //              _calcLengthGrowth.Print(outfile1);
215    //            cout << "-----------------" << endl;
216    //            cin >> a;
217  }  }
218    
219  void Grower::Reset() {  void Grower::Reset() {
220    int i, j, area;    int i, j, area;
221    double factorialx, tmppart, tmpmax;    double factorialx, tmppart, tmpmax;
222    
223    calcLengthGrowth.setToZero();  //  calcLengthGrowth.setToZero();
224    calcWeightGrowth.setToZero();  //  calcWeightGrowth.setToZero();
225      _calcLengthGrowth.setToZero();
226      _calcWeightGrowth.setToZero();
227    interpLengthGrowth.setToZero();    interpLengthGrowth.setToZero();
228    for (area = 0; area < areas.Size(); area++) {    for (area = 0; area < areas.Size(); area++) {
229      (*lgrowth[area]).setToZero();      (_lgrowth[area]).setToZero();
230      for (i = 0; i < LgrpDiv->numLengthGroups(); i++)      for (i = 0; i < LgrpDiv->numLengthGroups(); i++)
231        numGrow[area][i].setToZero();        numGrow[area][i].setToZero();
232    }    }
# Line 214  Line 242 
242      case 9:      case 9:
243        interpWeightGrowth.setToZero();        interpWeightGrowth.setToZero();
244        for (area = 0; area < areas.Size(); area++)        for (area = 0; area < areas.Size(); area++)
245          (*wgrowth[area]).setToZero();          (_wgrowth[area]).setToZero();
246        break;        break;
247      case 8:      case 8:
248      case 10:      case 10:

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

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

Powered By FusionForge