00001 #include "transcrsec.h"
00002 #include "globalt.h"
00003
00004 transcrsec::transcrsec (void)
00005 {
00006
00007 ncst=0;
00008
00009 cstype = NULL;
00010
00011 numtype = NULL;
00012
00013 cs1d = NULL;
00014 cs2d = NULL;
00015 cs3d = NULL;
00016 }
00017 transcrsec::~transcrsec (void)
00018 {
00019 delete [] cstype;
00020 delete [] numtype;
00021 delete [] cs1d;
00022 delete [] cs2d;
00023 delete [] cs3d;
00024 }
00025
00026
00027
00028
00029
00030
00031
00032
00033 void transcrsec::read (XFILE *in)
00034 {
00035 long i;
00036
00037 xfscanf (in,"%k%ld","number_csect_types",&ncst);
00038 if (ncst<1){
00039 print_err("number of cross section types is less than 1",__FILE__,__LINE__,__func__);
00040 }
00041 if (Mesprt==1){
00042 fprintf (stdout,"\n number of cross section types %ld",ncst);
00043 }
00044
00045
00046 cstype = new crsectypet [ncst];
00047
00048 numtype = new long [ncst];
00049
00050 for (i=0;i<ncst;i++){
00051 xfscanf (in, "%k%m %k%ld", "crstype", &crsectypet_kwdset, &cstype[i], "num_inst", &numtype[i]);
00052 if (numtype[i]<1){
00053 print_err("number of instances of cross section is less than 1",__FILE__,__LINE__,__func__);
00054 }
00055
00056 readcrsectype(in, cstype[i], numtype[i]);
00057 }
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 void transcrsec::readcrsectype(XFILE *in, crsectypet ct, long numt)
00075 {
00076 long j,k;
00077
00078 switch (ct)
00079 {
00080 case nocrosssectiont:{
00081 break;
00082 }
00083 case crsec1dt:{
00084 if (Mesprt==1) fprintf (stdout,"\n number of 1D cross sections %ld",numt);
00085 cs1d = new crsection1d [numt];
00086 for (j=0;j<numt;j++){
00087 xfscanf (in,"%ld",&k);
00088 if ((k<1) || (k>numt))
00089 {
00090 print_err("index %ld of cross section parameter set is out of range <1,%ld>",
00091 __FILE__, __LINE__, __func__, k, numt);
00092 }
00093 cs1d[k-1].read (in);
00094 }
00095 break;
00096 }
00097 case crsec2dt:{
00098 if (Mesprt==1) fprintf (stdout,"\n number of 2D cross sections %ld",numt);
00099 cs2d = new crsection2d [numt];
00100 for (j=0;j<numt;j++){
00101 xfscanf (in,"%ld",&k);
00102 if ((k<1) || (k>numt))
00103 {
00104 print_err("index %ld of cross section parameter set is out of range <1,%ld>",
00105 __FILE__, __LINE__, __func__, k, numt);
00106 }
00107 cs2d[k-1].read (in);
00108 }
00109 break;
00110 }
00111 case crsec3dt:{
00112 if (Mesprt==1) fprintf (stdout,"\n number of 3D cross sections %ld",numt);
00113 cs3d = new crsection3d [numt];
00114 for (j=0;j<numt;j++){
00115 xfscanf (in,"%ld",&k);
00116 if ((k<1) || (k>numt))
00117 {
00118 print_err("index %ld of cross section parameter set is out of range <1,%ld>",
00119 __FILE__, __LINE__, __func__, k, numt);
00120 }
00121 cs3d[k-1].read (in);
00122 }
00123 break;
00124 }
00125 default:{
00126 print_err("unknown cross section type is required",__FILE__,__LINE__,__func__);
00127 }
00128 }
00129 }
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 void transcrsec::print (FILE *out)
00141 {
00142 long i,j;
00143
00144 fprintf(out,"\n\n## cross-sections:");
00145 fprintf (out,"\n%ld\n",ncst);
00146
00147 for (i=0;i<ncst;i++){
00148 fprintf (out,"\n%d %ld",(int)cstype[i],numtype[i]);
00149
00150 for (j=0;j<numtype[i];j++){
00151 fprintf (out,"\n%ld ",j+1);
00152 printcrschar(out, cstype[i], j);
00153 }
00154 }
00155 }
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 void transcrsec::printcrschar (FILE *out, crsectypet ct, long numinst)
00171 {
00172 switch (ct)
00173 {
00174 case nocrosssectiont:{
00175 break;
00176 }
00177 case crsec1dt:{
00178 cs1d[numinst].print (out);
00179 break;
00180 }
00181 case crsec2dt:{
00182 cs2d[numinst].print (out);
00183 break;
00184 }
00185 case crsec3dt:{
00186 cs3d[numinst].print (out);
00187 break;
00188 }
00189 default:{
00190 print_err("unknown cross section type is required",__FILE__,__LINE__,__func__);
00191 }
00192 }
00193 }
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205 void transcrsec::give_thickn (ivector &nod,vector &t)
00206 {
00207 long i,n;
00208 n=nod.n;
00209 for (i=0;i<n;i++){
00210 switch (Tt->nodes[nod[i]].crst){
00211 case nocrosssectiont:{
00212 break;
00213 }
00214 case crsec2dt:{
00215 t[i]=cs2d[Tt->nodes[nod[i]].idcs].t;
00216 break;
00217 }
00218 default:{
00219 print_err("unknown cross section type is required",__FILE__,__LINE__,__func__);
00220 }
00221 }
00222 }
00223 }
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233 void transcrsec::give_thicke (long eid,double &t)
00234 {
00235 switch (Tt->elements[eid].crst){
00236 case nocrosssectiont:{
00237 break;
00238 }
00239 case crsec2dt:{
00240 t=cs2d[Tt->elements[eid].idcs].t;
00241 break;
00242 }
00243 default:{
00244 print_err("unknown cross section type is required",__FILE__,__LINE__,__func__);
00245 }
00246 }
00247 }
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258 void transcrsec::give_thickness (long eid,ivector &nodes,vector &th)
00259 {
00260 long i,nne;
00261 double t;
00262
00263 if (Tt->elements[eid].crst==0){
00264 give_thickn (nodes,th);
00265 }
00266 else{
00267 give_thicke (eid,t);
00268 nne = Tt->give_nne (eid);
00269 for (i=0;i<nne;i++){
00270 th[i]=t;
00271 }
00272 }
00273 }
00274
00275
00276
00277
00278
00279
00280 void transcrsec::give_areae (long eid,double &a)
00281 {
00282 switch (Tt->elements[eid].crst){
00283 case nocrosssectiont:{
00284 break;
00285 }
00286 case crsec1dt:{
00287 a=cs1d[Tt->elements[eid].idcs].a;
00288 break;
00289 }
00290 default:{
00291 print_err("unknown cross section type is required",__FILE__,__LINE__,__func__);
00292 }
00293 }
00294 }
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305 void transcrsec::give_arean (ivector &nod,vector &a)
00306 {
00307 long i,n;
00308 n=nod.n;
00309 for (i=0;i<n;i++){
00310 switch (Tt->nodes[nod[i]].crst){
00311 case nocrosssectiont:{
00312 break;
00313 }
00314 case crsec1dt:{
00315 a[i]=cs1d[Tt->nodes[nod[i]].idcs].a;
00316 break;
00317 }
00318 default:{
00319 print_err("unknown cross section type is required",__FILE__,__LINE__,__func__);
00320 }
00321 }
00322 }
00323 }
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335 void transcrsec::give_area (long eid,ivector &nodes,vector &a)
00336 {
00337 long i,nne;
00338 double aa;
00339
00340 if (Tt->elements[eid].crst==0){
00341 give_arean (nodes,a);
00342 }
00343 else{
00344 give_areae (eid,aa);
00345
00346 nne = Tt->give_nne (eid);
00347 for (i=0;i<nne;i++){
00348 a[i]=aa;
00349 }
00350 }
00351 }
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361 void transcrsec::give_densityn (ivector &nod,vector &rho)
00362 {
00363 long i,n;
00364 n=nod.n;
00365 for (i=0;i<n;i++){
00366 switch (Tt->nodes[nod[i]].crst){
00367 case nocrosssectiont:{
00368 break;
00369 }
00370 case crsec1dt:{
00371 rho[i]=cs1d[Tt->nodes[nod[i]].idcs].rho;
00372 break;
00373 }
00374 case crsec2dt:{
00375 rho[i]=cs2d[Tt->nodes[nod[i]].idcs].rho;
00376 break;
00377 }
00378 case crsec3dt:{
00379 rho[i]=cs3d[Tt->nodes[nod[i]].idcs].rho;
00380 break;
00381 }
00382 default:{
00383 print_err("unknown cross section type is required",__FILE__,__LINE__,__func__);
00384 }
00385 }
00386 }
00387 }
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397 void transcrsec::give_densitye (long eid,double &rho)
00398 {
00399 switch (Tt->elements[eid].crst){
00400 case nocrosssectiont:{
00401 break;
00402 }
00403 case crsec1dt:{
00404 rho=cs1d[Tt->elements[eid].idcs].rho;
00405 break;
00406 }
00407 case crsec2dt:{
00408 rho=cs2d[Tt->elements[eid].idcs].rho;
00409 break;
00410 }
00411 case crsec3dt:{
00412 rho=cs3d[Tt->elements[eid].idcs].rho;
00413 break;
00414 }
00415 default:{
00416 print_err("unknown cross section type is required",__FILE__,__LINE__,__func__);
00417 }
00418 }
00419 }
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430 void transcrsec::give_density (long eid,ivector &nodes,vector &dens)
00431 {
00432 long i,nne;
00433 double d;
00434
00435 if (Tt->elements[eid].crst==0){
00436 give_densityn (nodes,dens);
00437 }
00438 else{
00439 give_densitye (eid,d);
00440 nne = Tt->give_nne (eid);
00441 for (i=0;i<nne;i++){
00442 dens[i]=d;
00443 }
00444 }
00445 }