00001 #include "intpointst.h"
00002 #include "globalt.h"
00003 #include <string.h>
00004
00005 intpointst::intpointst ()
00006 {
00007
00008 ncompgrad=0;
00009
00010 ncompother=0;
00011
00012 ncompeqother=0;
00013
00014
00015 tm = (mattypet) 0;
00016
00017 idm=0;
00018
00019
00020
00021
00022
00023 av=NULL;
00024
00025 pv=NULL;
00026
00027 grad=NULL;
00028
00029 fluxes=NULL;
00030
00031 other = NULL;
00032
00033 eqother = NULL;
00034 }
00035
00036 intpointst::~intpointst (void)
00037 {
00038 long i;
00039 delete [] av;
00040 delete [] pv;
00041 for (i=0; i<Tp->ntm; i++)
00042 {
00043
00044
00045 if (grad != NULL)
00046 delete [] grad[i];
00047 if (fluxes != NULL)
00048 delete [] fluxes[i];
00049 }
00050 delete [] grad;
00051 delete [] fluxes;
00052
00053
00054 delete [] other;
00055 delete [] eqother;
00056 }
00057
00058
00059
00060
00061
00062
00063 void intpointst::read (FILE *in)
00064 {
00065 fscanf (in,"%d %ld",(int*)&tm,&idm);
00066 idm--;
00067 }
00068
00069
00070
00071
00072
00073
00074
00075
00076 void intpointst::alloc (long ipp)
00077 {
00078 long i,ntm;
00079
00080
00081 ntm = Tp->ntm;
00082
00083 ncompgrad = Tp->gdim;
00084
00085 ncompother = Tm->givencompother();
00086
00087 ncompeqother = Tm->givencompeqother(ipp,0);
00088
00089 if (ncompother > 0){
00090 other = new double [ncompother];
00091 }
00092
00093 if (ncompeqother > 0){
00094 eqother = new double [ncompeqother];
00095 }
00096
00097
00098
00099
00100
00101 av = new double [ntm];
00102
00103 pv = new double [ntm];
00104
00105 grad = new double* [ntm];
00106
00107 fluxes = new double* [ntm];
00108
00109 for (i=0;i<ntm;i++){
00110
00111 grad[i] = new double [ncompgrad];
00112 fluxes[i] = new double [ncompgrad];
00113 }
00114
00115 clean ();
00116 }
00117
00118
00119
00120
00121
00122
00123
00124 void intpointst::clean ()
00125 {
00126 long i,j,ntm;
00127
00128
00129 ntm = Tp->ntm;
00130
00131 for (i=0;i<ntm;i++){
00132 av[i]=0.0;
00133 pv[i]=0.0;
00134 for (j=0;j<ncompgrad;j++){
00135
00136 grad[i][j]=0.0;
00137 fluxes[i][j]=0.0;
00138 }
00139 }
00140
00141 for (i=0;i<ncompother;i++){
00142 other[i]=0.0;
00143 }
00144
00145 for (i=0;i<ncompeqother;i++){
00146 eqother[i]=0.0;
00147 }
00148 }
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 void intpointst::storegrad (long lcid, double *gradv)
00162 {
00163 long i;
00164 for (i=0; i<ncompgrad; i++)
00165 grad[lcid][i]=gradv[i];
00166 }
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 void intpointst::copy(intpointst &ip, long ntm)
00181 {
00182 long i, j;
00183
00184 ip.tm = tm;
00185
00186
00187 ip.idm = idm;
00188
00189
00190 ip.ncompgrad = ncompgrad;
00191
00192
00193 ip.ncompother = ncompother;
00194
00195
00196 ip.ncompeqother = ncompeqother;
00197
00198
00199 infl = new long*[ntm];
00200 for(i=0; i<ntm; i++)
00201 {
00202 infl[i] = new long[ntm];
00203 for(j=0; j<ntm; j++)
00204 ip.infl[i][j] = infl[i][j];
00205 }
00206
00207
00208 ip.av = new double[ntm];
00209 for (i=0; i<ntm; i++)
00210 ip.av[i] = av[i];
00211
00212
00213 ip.pv = new double[ntm];
00214 for (i=0; i<ntm; i++)
00215 ip.pv[i] = pv[i];
00216
00217
00218 ip.grad = new double*[ntm];
00219 for (i=0; i<ntm; i++)
00220 {
00221 ip.grad[i] = new double[ncompgrad];
00222 for(j=0; j<ncompgrad; j++)
00223 ip.grad[i][j] = grad[i][j];
00224 }
00225
00226
00227 ip.fluxes = new double*[ntm];
00228 for (i=0; i<ntm; i++)
00229 {
00230 ip.fluxes[i] = new double[ncompgrad];
00231 for(j=0; j<ncompgrad; j++)
00232 ip.fluxes[i][j] = fluxes[i][j];
00233 }
00234
00235
00236 ip.other = new double[ncompother];
00237 for(i=0; i<ncompother; i++)
00238 ip.other[i] = other[i];
00239
00240
00241 ip.eqother = new double[ncompeqother];
00242 for(i=0; i<ncompeqother; i++)
00243 ip.eqother[i] = eqother[i];
00244 }
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257 void intpointst::save_data_txt (FILE *aux,sel &selother)
00258 {
00259 long i,j,ntm,gdim;
00260 int prec = (int)Tp->hdbcont.prec;
00261
00262
00263 ntm = Tp->ntm;
00264
00265 gdim = Tp->gdim;
00266
00267 for (i=0;i<ntm;i++){
00268 fprintf (aux,"%e\n",av[i]);
00269 }
00270 for (i=0;i<ntm;i++){
00271 fprintf (aux,"%e\n",pv[i]);
00272 }
00273 for (i=0;i<ntm;i++){
00274 for (j=0;j<gdim;j++){
00275 fprintf (aux,"%e\n",grad[i][j]);
00276 }
00277 }
00278 for (i=0;i<ntm;i++){
00279 for (j=0;j<gdim;j++){
00280 fprintf (aux,"%e\n",fluxes[i][j]);
00281 }
00282 }
00283
00284 for (i=0;i<ncompeqother;i++)
00285 {
00286 if (selother.presence_id(i))
00287 fprintf (aux,"%.*le\n",prec,eqother[i]);
00288 }
00289 }
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303 void intpointst::restore_data_txt (FILE *aux,long ncompo, sel &selother, long *selid)
00304 {
00305 long i,j,ntm,gdim,ik,is;
00306 double tmp;
00307
00308
00309 ntm = Tp->ntm;
00310
00311 gdim = Tp->gdim;
00312
00313 for (i=0;i<ntm;i++){
00314 fscanf (aux,"%le\n",&av[i]);
00315 }
00316 for (i=0;i<ntm;i++){
00317 fscanf (aux,"%le\n",&pv[i]);
00318 }
00319 for (i=0;i<ntm;i++){
00320 for (j=0;j<gdim;j++){
00321 fscanf (aux,"%le\n",&grad[i][j]);
00322 }
00323 }
00324 for (i=0;i<ntm;i++){
00325 for (j=0;j<gdim;j++){
00326 fscanf (aux,"%le\n",&fluxes[i][j]);
00327 }
00328 }
00329
00330 for (i=0;i<ncompo;i++)
00331 {
00332 fscanf (aux,"%le",&tmp);
00333 if (selother.presence_id(i,ik))
00334 {
00335 is = selid[ik]+i-selother.id1[ik];
00336 if (is >= ncompeqother)
00337 print_err("invalid index for eqother restoring is required", __FILE__, __LINE__, __func__);
00338 else
00339 eqother[is] = tmp;
00340 }
00341 }
00342 }
00343
00344
00345
00346
00347
00348
00349 void intpointst::actual_previous_change ()
00350 {
00351 long i,ntm;
00352
00353
00354 ntm = Tp->ntm;
00355
00356 for (i=0;i<ntm;i++){
00357 pv[i]=av[i];
00358 }
00359 }
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372 void intpointst::save_data_bin (FILE *aux,sel &selother)
00373 {
00374 long i;
00375
00376
00377
00378 for (i=0;i<ncompeqother;i++)
00379 {
00380 if (selother.presence_id(i))
00381 fwrite (eqother+i, sizeof(*eqother), 1, aux);
00382 }
00383 }
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397 void intpointst::restore_data_bin (FILE *aux,long ncompo, sel &selother, long *selid)
00398 {
00399 long i, ik, is;
00400 double tmp;
00401
00402
00403
00404 for (i=0;i<ncompo;i++)
00405 {
00406 fread (&tmp, sizeof(tmp), 1, aux);
00407 if (selother.presence_id(i,ik))
00408 {
00409 is = selid[ik]+i-selother.id1[ik];
00410 if (is >= ncompeqother)
00411 print_err("invalid index for eqother restoring is required", __FILE__, __LINE__, __func__);
00412 else
00413 eqother[is] = tmp;
00414 }
00415 }
00416 }