int CoffLoader::LoadSections(FILE *fp) { NumOfSections = CoffFileHeader->NumberOfSections; SectionData = new char * [NumOfSections]; if ( !SectionData ) return 0; // Bobbin007: for debug dlls this check always fails //////check VMA size!!!!! //unsigned long vma_size = 0; //for (int SctnCnt = 0; SctnCnt < NumOfSections; SctnCnt++) //{ // SectionHeader_t *ScnHdr = (SectionHeader_t *)(SectionHeader + SctnCnt); // vma_size = max(vma_size, ScnHdr->VirtualAddress + ScnHdr->SizeOfRawData); // vma_size = max(vma_size, ScnHdr->VirtualAddress + ScnHdr->VirtualSize); //} //if (WindowsHeader->SizeOfImage < vma_size) // return 0; //something wrong with file for (int SctnCnt = 0; SctnCnt < NumOfSections; SctnCnt++) { SectionHeader_t *ScnHdr = (SectionHeader_t *)(SectionHeader + SctnCnt); SectionData[SctnCnt] = ((char*)hModule + ScnHdr->VirtualAddress); fseek(fp, ScnHdr->PtrToRawData, SEEK_SET); if (!fread(SectionData[SctnCnt], 1, ScnHdr->SizeOfRawData, fp)) return 0; #ifdef DUMPING_DATA //debug blocks char szBuf[128]; char namebuf[9]; for (int i = 0; i < 8; i++) namebuf[i] = ScnHdr->Name[i]; namebuf[8] = '\0'; sprintf(szBuf, "Load code Sections %s Memory %p,Length %x\n", namebuf, SectionData[SctnCnt], max(ScnHdr->VirtualSize, ScnHdr->SizeOfRawData)); OutputDebugString(szBuf); #endif if ( ScnHdr->SizeOfRawData < ScnHdr->VirtualSize ) //initialize BSS data in the end of section { memset((char*)((long)(SectionData[SctnCnt]) + ScnHdr->SizeOfRawData), 0, ScnHdr->VirtualSize - ScnHdr->SizeOfRawData); } if (ScnHdr->Characteristics & IMAGE_SCN_CNT_BSS) //initialize whole .BSS section, pure .BSS is obsolete { memset(SectionData[SctnCnt], 0, ScnHdr->VirtualSize); } #ifdef DUMPING_DATA PrintSection(SectionHeader + SctnCnt, SectionData[SctnCnt]); #endif } return 1; }
// Create global archive file void ArchiveData::CreateGlobalFile(void) { FILE *fp; char fline[1000]; GlobalQuantity *nextGlobal; // skip if none, but error if tried to define global quantities if(globalTime<0.) { globalTime=-1.; if(firstGlobal!=NULL) throw CommonException("<GlobalArchive> was used but never activated with a <GlobalArchiveTime> command.","ArchiveData::CreateGlobalFile"); return; } // get relative path name to the file globalFile=new char[strlen(outputDir)+strlen(archiveRoot)+8]; sprintf(globalFile,"%s%s.global",outputDir,archiveRoot); // create and open the file if((fp=fopen(globalFile,"w"))==NULL) goto abort; // write color strcpy(fline,"#setColor"); nextGlobal=firstGlobal; while(nextGlobal!=NULL) nextGlobal=nextGlobal->AppendColor(fline); strcat(fline,"\n"); if(fwrite(fline,strlen(fline),1,fp)!=1) goto abort; // write name strcpy(fline,"#setName"); nextGlobal=firstGlobal; while(nextGlobal!=NULL) nextGlobal=nextGlobal->AppendName(fline); strcat(fline,"\n"); if(fwrite(fline,strlen(fline),1,fp)!=1) goto abort; // close the file if(fclose(fp)!=0) goto abort; // section in output file PrintSection("ARCHIVED GLOBAL RESULTS"); cout << "Global data file: " << archiveRoot << ".global" << endl; cout << endl; return; abort: FileError("Global archive file creation failed",globalFile,"ArchiveData::CreateGlobalFile"); }
// Create global file, get archive size, and print to output file archiving table void ArchiveData::BeginArchives(bool isThreeD) { // set flag if 3D calculations threeD=isThreeD; // global archiving CreateGlobalFile(); // Archive file list headind CalcArchiveSize(); SetArchiveHeader(); PrintSection("ARCHIVED ANALYSIS RESULTS"); cout << "Root file name: " << archiveRoot << "." << endl << "Archive format: " << mpmOrder << endl << "Crack archive format: " << crackOrder << endl << endl << " Step Time (msec) Filename" << endl << "----------------------------------------------" << endl; }
void NairnFEA::ReactionResults(void) { NodalDispBC *nextBC=firstDispBC; if(outFlags[REACT_OUT]=='N') return; char fline[200]; sprintf(fline,"REACTIVITIES AT FIXED NODES (in %s)",UnitsController::Label(FEAFORCE_UNITS)); PrintSection(fline); cout << " Node F" << xax << " F" << yax << " F" << zax << endl; cout << "------------------------------------------------------------------" << endl; // each one while(nextBC!=NULL) { nextBC->PrintReaction(); nextBC=(NodalDispBC *)nextBC->GetNextObject(); } cout << endl; }
void NairnFEA::AvgNodalStresses(void) { int numshw,ii,i; if(outFlags[AVGSTRESS_OUT]=='N') return; // heading char fline[200]; sprintf(fline,"AVERAGE NODAL STRESSES (in %s)",UnitsController::Label(PRESSURE_UNITS)); PrintSection(fline); cout << " Node sig(" << xax << ") sig(" << yax << ") sig(" << zax << ") sig(" << xax << yax << ")" << endl; cout << "--------------------------------------------------------------------------" << endl; // print all or selected nodes numshw = (outFlags[AVGSTRESS_OUT]=='Y') ? nnodes : selectedNodes.size(); for(ii=1; ii<=numshw;ii++) { i = (outFlags[AVGSTRESS_OUT]=='Y') ? ii : selectedNodes[ii-1]; nd[i]->PrintAvgStress(); } cout << endl; }
void NairnFEA::DisplacementResults(void) { int i,ind=0,maxi,ii; char fline[200]; if(outFlags[DISPLACEMENT_OUT]=='N') return; // heading sprintf(fline,"NODAL DISPLACEMENTS (in %s)",UnitsController::Label(CULENGTH_UNITS)); PrintSection(fline); if(np==AXI_SYM) cout << " Node u w v" << endl; else cout << " Node u v w" << endl; cout << "------------------------------------------------------" << endl; // each nodal displacement maxi = outFlags[DISPLACEMENT_OUT]=='Y' ? nnodes : selectedNodes.size(); for(ii=1;ii<=maxi;ii++) { // find node and dof if(outFlags[DISPLACEMENT_OUT]=='Y') i=ii; else i=selectedNodes[ii-1]; ind=nfree*i; // 2D output if(nfree==2) sprintf(fline,"%5d %15.7e %15.7e",i,rm[ind-1],rm[ind]); // 3D output else if(nfree==3) sprintf(fline,"%5d %15.7e %15.7e %15.7e",i,rm[ind-2],rm[ind-1],rm[ind]); cout << fline << endl; } cout << endl; }
void NairnFEA::EnergyResults(void) { double temp; int incolm,i,ind; char fline[200]; if(outFlags[ENERGY_OUT]=='N') return; // heading sprintf(fline,"STRAIN ENERGIES IN ELEMENTS (in %s)",UnitsController::Label(FEAWORK_UNITS)); PrintSection(fline); cout << " Elem Strain Energy Elem Strain Energy" << endl; cout << "------------------------------------------------------------------" << endl; temp=0.; if(IsEven(nelems)) incolm=nelems/2; else incolm=(nelems+1)/2; double escale = UnitsController::Scaling(1.e-3); for(i=1;i<=incolm;i++) { ind=i+incolm; if(ind<=nelems) { sprintf(fline,"%5d %15.7e %5d %15.7e", i,escale*theElements[i-1]->strainEnergy,ind,escale*theElements[ind-1]->strainEnergy); temp+=theElements[ind-1]->strainEnergy; } else sprintf(fline,"%5d %15.7e",i,escale*theElements[i-1]->strainEnergy); temp+=theElements[i-1]->strainEnergy; cout << fline << endl; } cout << "------------------------------------------------------------------" << endl; sprintf(fline,"Total %15.7e",escale*temp); cout << fline << endl << endl; }
void NairnFEA::FEAAnalysis() { char nline[200]; int result; int i; NodalDispBC *nextBC; double times[5]; #pragma mark --- TASK 0: INITIALIZE // start timer times[0]=CPUTime(); // get problem size and other initialization nsize=nnodes*nfree + numConstraints; nband=GetBandWidth(); if(np==AXI_SYM) { xax='r'; yax='z'; zax='t'; } // Stiffness matrix info PrintSection("TOTAL STIFFNESS MATRIX"); sprintf(nline,"Initial number of equations:%6d Initial bandwidth:%6d",nsize,nband); cout << nline << endl << endl; #pragma mark --- TASK 1: ALLOCATE R VECTOR // Allocate reaction vector and load with nodal loads and edge loads rm=(double *)malloc(sizeof(double)*(nsize+1)); if(rm==NULL) throw CommonException("Memory error allocating reaction vector (rm)","NairnFEA::FEAAnalysis"); for(i=1;i<=nsize;i++) rm[i]=0.; // add nodal loads to rm[] vector NodalLoad *nextLoad=firstLoadBC; while(nextLoad!=NULL) nextLoad=nextLoad->Reaction(rm,np,nfree); // add stresses on element edges to rm[] vector ForcesOnEdges(); #pragma mark --- TASK 2: GET STIFFNESS MATRIX // allocate and fill global stiffness matrix, st[][], and reaction vector, rm[] times[1]=CPUTime(); BuildStiffnessMatrix(); #pragma mark --- TASK 3: DISPLACEMENT BCs // Impose displacement boundary conditions and rotate // nodes for skew boundary conditions nextBC=firstDispBC; while(nextBC!=NULL) nextBC=nextBC->FixOrRotate(st,rm,nsize,nband,nfree); #pragma mark --- TASK 4: INVERT STIFFNESS MATRIX // Solve linear system for nodal displacements times[2]=CPUTime(); double *work=(double *)malloc(sizeof(double)*(nsize+1)); if(work==NULL) throw CommonException("Memory error allocating work vector for linear solver", "NairnFEA::FEAAnalysis"); result=gelbnd(st,nsize,nband,rm,work,0); if(result==1) { throw CommonException("Linear solver error: matrix is singular. Check boundary conditions.\n (Hint: turn on resequencing to check for mesh connectivity problem)", "NairnFEA::FEAAnalysis"); } else if(result==-1) { cout << "Linear solver warning: solution process was close to singular. Results might be invalid." << endl; } free(work); free(st); free(stiffnessMemory); #pragma mark --- TASK 5a: UNSKEW ROTATED NODES nextBC=firstDispBC; while(nextBC!=NULL) nextBC=nextBC->Unrotate(rm,nfree); #pragma mark --- TASK 6: OUTPUT RESULTS // time to here for performance evaluation double execTime=ElapsedTime(); // elpased time in secs times[3]=CPUTime(); // Print Displacements DisplacementResults(); // Calculate forces, stresses, and energy // print element forces and stresses ForceStressEnergyResults(); // Average nodal stresses AvgNodalStresses(); // reactivities at fixed nodes ReactionResults(); // strain energies EnergyResults(); // execution times times[4]=CPUTime(); PrintSection("EXECUTION TIMES AND MEMORY"); cout << "1. Allocate Memory: " << (times[1]-times[0]) << " secs" << endl; cout << "2. Build Stiffness Matrix: " << (times[2]-times[1]) << " secs" << endl; cout << "3. Solve Linear System: " << (times[3]-times[2]) << " secs" << endl; cout << "4. Write Results: " << (times[4]-times[3]) << " secs" << endl; cout << "5. Total Execution CPU Time: " << times[3] << " secs" << endl; cout << "6. Total Execution Elapsed Time: " << execTime << " secs" << endl; cout << "7. Scaling: " << times[3]/execTime << endl; //--------------------------------------------------- // Trailer cout << "\n***** NAIRNFEA RUN COMPLETED\n"; }
void NairnFEA::ForceStressEnergyResults(void) { int i,j,iel,ind,kftemp=0,kstemp=0,numnds; int nodeNum; char gline[16],fline[200]; if(outFlags[FORCE_OUT]!='N' || outFlags[ELEMSTRESS_OUT]!='N') { sprintf(fline,"NODAL FORCES (in %s) AND STRESSES (in %s) IN EACH ELEMENT", UnitsController::Label(FEAFORCE_UNITS),UnitsController::Label(PRESSURE_UNITS)); PrintSection(fline); } /* The nodal stresses will store nodal point objects fs.stress.sig[], fs.force, fs.numElems Strain energy in element object strainEnergy */ for(i=1;i<=nnodes;i++) nd[i]->InitForceField(); // Loop over elements, calculating forces and averaging stresses for(iel=0;iel<nelems;iel++) { theElements[iel]->ForceStress(rm,np,nfree); numnds=theElements[iel]->NumberNodes(); // Print forces at nodes sprintf(gline,"%5d",iel+1); if(theElements[iel]->WantElement(outFlags[FORCE_OUT],selectedNodes)) { kftemp=1; cout << "--------------------------------------------------------------------------" << endl; cout << "Element Node F" << xax << " F" << yax << " F" << zax << endl; cout << "--------------------------------------------------------------------------" << endl; } else kftemp=0; // print and sum forces for(j=1;j<=numnds;j++) { ind=nfree*(j-1)+1; nodeNum=theElements[iel]->nodes[j-1]; // print force if(kftemp==1) { sprintf(fline,"%5s %5d %15.7e %15.7e",gline, nodeNum,-se[ind][7],-se[ind+1][7]); cout << fline << endl; strcpy(gline," "); } // Sum forces at nodes nd[nodeNum]->fs->force.x+=se[ind][7]; nd[nodeNum]->fs->force.y+=se[ind+1][7]; } // Print stresses at nodes in elements if(theElements[iel]->WantElement(outFlags[ELEMSTRESS_OUT],selectedNodes)) { kstemp=1; if(kftemp==1) { cout << " --------------------------------------------------------" << endl; cout << " sig" << xax << " sig" << yax << " sig" << xax << yax << endl; cout << " --------------------------------------------------------" << endl; } else { cout << "--------------------------------------------------------------------------" << endl; cout << "Element Node sig" << xax << " sig" << yax << " sig" << xax << yax << endl; cout << "--------------------------------------------------------------------------" << endl; } } else kstemp=0; for(j=1;j<=numnds;j++) { nodeNum=theElements[iel]->nodes[j-1]; if(kstemp==1) { sprintf(fline,"%5s %5d %15.7e %15.7e %15.7e", gline,nodeNum,se[j][1],se[j][2],se[j][3]); cout << fline << endl; strcpy(gline," "); } // Transfer stresses to global array - if bulk element if(theElements[iel]->BulkElement()) { nd[nodeNum]->fs->stress.xx+=se[j][1]; nd[nodeNum]->fs->stress.yy+=se[j][2]; nd[nodeNum]->fs->stress.xy+=se[j][3]; nd[nodeNum]->fs->numElems++; } } // Print rest of stresses and add stresses into global array if(np==PLANE_STRAIN || np==AXI_SYM) { if(kstemp==1) { cout << " --------------------------------------------------------" << endl; cout << " sig" << zax << " sig" << xax << zax << " sig" << yax << zax << endl; cout << " --------------------------------------------------------" << endl; } for(j=1;j<=numnds;j++) { nodeNum=theElements[iel]->nodes[j-1]; if(kstemp==1) { sprintf(fline,"%5s %5d %15.7e %15.7e %15.7e", gline,nodeNum,se[j][4],(double)0.0,(double)0.0); cout << fline << endl; } // Tranfer stresses to global array if(theElements[iel]->BulkElement()) nd[nodeNum]->fs->stress.zz+=se[j][4]; } } } // blank line if(outFlags[FORCE_OUT]!='N' || outFlags[ELEMSTRESS_OUT]!='N') cout << endl; }
// start results file before proceeding to analysis // throws CommonException() void CommonAnalysis::StartResultsOutput(void) { //-------------------------------------------------- // Analysis Title PrintAnalysisTitle(); cout << "Written by: Nairn Research Group, Oregon State University\n" << "Date: " << __DATE__ << "\n" << "Source: " << svninfo << "\n" << "Units: "; UnitsController::OutputUnits(); cout << "\n" #ifdef _OPENMP << "Processors: " << numProcs << "\n" #endif << endl; //-------------------------------------------------- // Description PrintSection("ANALYSIS DESCRIPTION"); cout << GetDescription() << endl; /* development flags * * Current Flags in Use in MPM Code * none * */ int i; bool hasFlags=FALSE; for(i=0; i<NUMBER_DEVELOPMENT_FLAGS; i++) { if(dflag[i]!=0) { cout << "Development Flag #" << i << " = " << dflag[i] << endl; cout << "... WARNING: unrecognized developer flag specified" << endl; hasFlags=TRUE; } } if(hasFlags) cout << endl; //-------------------------------------------------- // Analysis Type PrintAnalysisType(); // start section (Background Grid) #ifdef MPM_CODE PrintSection("NODES AND ELEMENTS (Background Grid)"); #else PrintSection("NODES AND ELEMENTS"); #endif //--------------------------------------------------- // Nodes char hline[200]; if(nnodes==0 || nelems<0) throw CommonException("No nodes or elements were defined in the input file.","CommonAnalysis::StartResultsOutput"); sprintf(hline,"Nodes: %d Elements: %d\n",nnodes,nelems); cout << hline; sprintf(hline,"DOF per node: %d ",nfree); cout << hline; // analysis type switch(np) { case PLANE_STRAIN: cout << "2D Plane Strain Analysis\n"; break; case PLANE_STRESS: cout << "2D Plane Stress Analysis\n"; break; case AXI_SYM: cout << "Axisymmetric Analysis\n"; break; case PLANE_STRAIN_MPM: cout << "2D Plane Strain MPM" << MPMAugmentation() << " Analysis\n"; break; case PLANE_STRESS_MPM: cout << "2D Plane Stress MPM" << MPMAugmentation() << " Analysis\n"; break; case THREED_MPM: cout << "3D MPM" << MPMAugmentation() << " Analysis\n"; break; case AXISYMMETRIC_MPM: cout << "Axisymmetric MPM" << MPMAugmentation() << " Analysis\n"; break; default: throw CommonException("No FEA or MPM analysis type was provided.","CommonAnalysis::StartResultsOutput"); } #ifdef MPM_CODE cout << "Incremental F Terms: " << MaterialBase::incrementalDefGradTerms << endl; #endif cout << endl; //--------------------------------------------------- // Nodes sprintf(hline,"NODAL POINT COORDINATES (in %s)",UnitsController::Label(CULENGTH_UNITS)); PrintSection(hline); archiver->ArchiveNodalPoints(np); //--------------------------------------------------- // Elements PrintSection("ELEMENT DEFINITIONS"); archiver->ArchiveElements(np); //--------------------------------------------------- // Defined Materials const char *err; #ifdef MPM_CODE sprintf(hline,"DEFINED MATERIALS\n (Note: moduli and stresses in %s, thermal exp. coeffs in ppm/K)\n ( density in %s)", UnitsController::Label(PRESSURE_UNITS),UnitsController::Label(DENSITY_UNITS)); #else sprintf(hline,"DEFINED MATERIALS\n (Note: moduli in %s, thermal exp. coeffs in ppm/K)", UnitsController::Label(PRESSURE_UNITS)); #endif PrintSection(hline); if(theMaterials==NULL) throw CommonException("No materials were defined.","CommonAnalysis::StartResultsOutput"); for(i=0; i<nmat; i++) { err=theMaterials[i]->VerifyAndLoadProperties(np); theMaterials[i]->PrintMaterial(i+1); cout << endl; if(err!=NULL) { cout << "Invalid material properties\n " << err << endl; throw CommonException("See material error above.","CommonAnalysis::StartResultsOutput"); } } // finish with analysis specific items MyStartResultsOutput(); //--------------------------------------------------- // initialize timers #ifdef _OPENMP startTime = omp_get_wtime(); #else time(&startTime); #endif startCPU=clock(); }
int main(int argc, char *argv[]) { char *data_filename, *deref_filename; double train_pct, prune_pct, test_pct; double train_accuracy, test_accuracy; DTNODE *tree; uchar *test_members, *train_members, *prune_members; int multiple_input_files; char *train_filename, *prune_filename, *test_filename; int num_test, num_train, num_prune, num_features, num_data; int depth, count, prev_count; int num_negatives, num_false_negatives; int num_positives, num_false_positives; void **data; struct timeval tv; unsigned int random_seed; SSVINFO ssvinfo; ssvinfo.batch = 0; progname = (char *) rindex(argv[0], '/'); argv[0] = progname = (progname != NULL) ? (progname + 1) : argv[0]; multiple_input_files = 0; if (argc>2){ if (!strcmp(argv[1],"-tpt") && (argc==5)){ train_filename = argv[2]; prune_filename = argv[3]; test_filename = argv[4]; data = ReadTPT(train_filename, prune_filename, test_filename, &train_members, &prune_members, &test_members, &num_train, &num_prune, &num_test, &num_data, &num_features, &ssvinfo); multiple_input_files = 1; } else if (!strcmp(argv[1],"-tp") && (argc==4)){ train_filename = argv[2]; prune_filename = argv[3]; data = ReadTwo(train_filename, prune_filename, &train_members, &prune_members, &num_train, &num_prune, &num_data, &num_features, &ssvinfo); num_test = 0; test_members = CREATE_BITARRAY(num_data); ZERO_BITARRAY(test_members,num_data); multiple_input_files = 1; } else if (!strcmp(argv[1],"-tt")&& (argc==4)){ train_filename = argv[2]; test_filename = argv[3]; data = ReadTwo(train_filename, test_filename, &train_members, &test_members, &num_train, &num_test, &num_data, &num_features, &ssvinfo); num_prune = 0; prune_members = CREATE_BITARRAY(num_data); ZERO_BITARRAY(prune_members,num_data); multiple_input_files = 1; } } if (!multiple_input_files){ if (argc != 5 && argc != 7) { fprintf(stderr, USAGE, progname); exit(1); } switch (argc) { case 5: if (gettimeofday(&tv, NULL) == -1) SYS_ERROR1("gettimeofday(%s)", ""); random_seed = (unsigned int) tv.tv_usec; train_pct = atof(argv[1]); prune_pct = atof(argv[2]); test_pct = atof(argv[3]); data_filename = argv[4]; break; case 7: if ((argv[1][1] == 's') || (argv[1][1] == 'S')) { random_seed = atoi(argv[2]); } else if ((argv[1][1] == 'b') || (argv[1][1] == 'B')) { if (gettimeofday(&tv, NULL) == -1) SYS_ERROR1("gettimeofday(%s)", ""); random_seed = (unsigned int) tv.tv_usec; ssvinfo.batch = atoi(argv[2]); } else { fprintf(stderr, USAGE, progname); exit(1); } train_pct = atof(argv[3]); prune_pct = atof(argv[4]); test_pct = atof(argv[5]); data_filename = argv[6]; break; default: fprintf(stderr, USAGE, progname); exit(1); } if ((random_seed < 0) || (train_pct <= 0.0) || (train_pct > 1.0) || (prune_pct < 0.0) || (prune_pct > 1.0) || (test_pct < 0.0) || (test_pct > 1.0) || (train_pct + prune_pct + test_pct > 1.00000001)) { fprintf(stderr, USAGE, progname); exit(1); } /* Memory-map the examples file. */ data = ReadSSVFile(data_filename, &num_data, &num_features, &ssvinfo); /* Initialize random number generator. */ srandom(random_seed); if (ssvinfo.batch>0) { BatchMain(data, num_data, num_features, train_pct, prune_pct, test_pct, &ssvinfo); exit(0); } /* Partition examples in train, test and prune sets. */ PartitionExamples(data, &num_data, num_features, &train_members, &num_train, &test_members, &num_test, &prune_members, &num_prune, train_pct, prune_pct, test_pct, &ssvinfo); /* Print the program arguments */ PrintSection("Program arguments"); printf("Random seed: %u\n", random_seed); printf("Training: %.0f%% (%d examples)\n", train_pct * 100.0, num_train); printf("Pruning: %.0f%% (%d examples)\n", prune_pct * 100.0, num_prune); printf("Testing: %.0f%% (%d examples)\n", test_pct * 100.0, num_test); printf("Data filename: %s\n", data_filename); } if (num_train == 0) { fprintf(stderr, "%s: no examples to train on!\n", progname); exit(1); } /* Create a decision tree and print it */ PrintSection("Growing decision tree"); tree = CreateDecisionTree(data, num_data, num_features, prune_pct, test_pct, train_members, num_train, &ssvinfo); PrintSection("Printing decision tree"); PrintDecisionTreeStructure(tree, &ssvinfo); PrintSection("Computing decision tree statistics"); PrintStats(tree, data, num_data, train_members, num_train, test_members, num_test, &ssvinfo); /* Post-prune the decision tree. */ if (num_prune > 0) { PrintSection("Pruning decision tree"); prev_count = CountNodes(tree); PruneDecisionTree(tree, tree, data, num_data, prune_members, num_prune, &ssvinfo); count = CountNodes(tree); /* If the node count decreased, something must have been pruned */ if (count < prev_count) { printf("\nPruning reduced the tree size from %d to %d nodes\n",prev_count,count); PrintSection("Printing PRUNED decision tree"); PrintDecisionTreeStructure(tree, &ssvinfo); } else { printf("\nPruning did not remove any nodes\n"); } /* Print the statistics again, for comparison */ PrintSection("Computing decision tree statistics after pruning"); PrintStats(tree, data, num_data, train_members, num_train, test_members, num_test, &ssvinfo); } free(train_members); free(test_members); free(prune_members); exit(0); }
// finish start of FEA results file void NairnFEA::MyStartResultsOutput(void) { char hline[200]; int i; //--------------------------------------------------- // Temperature PrintSection("THERMAL LOAD"); if(temperatureExpr!=NULL) { if(!CreateFunction(temperatureExpr)) throw CommonException("The temperature expression is not a valid function","NairnFEA::MyStartResultsOutput"); for(i=1;i<=nnodes;i++) { nd[i]->gTemperature = FunctionValue(1,nd[i]->x,nd[i]->y,0.,0.,0.,0.)-stressFreeTemperature; } DeleteFunction(); } else { // unknown, but may have been set in explicit node commands temperatureExpr=new char[2]; strcpy(temperatureExpr,"?"); } sprintf(hline,"T0: %.2lf C\nT: %s C",stressFreeTemperature,temperatureExpr); cout << hline << endl; if(stressFreeTemperature!=0) { sprintf(hline,"T-T0: %s - %.2lf C",temperatureExpr,stressFreeTemperature); cout << hline << endl; } cout << endl; //--------------------------------------------------- // Fixed Displacements if(firstDispBC!=NULL) { PrintSection("NODAL POINTS WITH FIXED DISPLACEMENTS"); cout << " Node DOF Displacement (mm) Axis Angle\n" << "----------------------------------------------------\n"; NodalDispBC *nextBC=firstDispBC; while(nextBC!=NULL) nextBC=nextBC->PrintBC(cout); cout << endl; } //--------------------------------------------------- // Loaded Nodes if(firstLoadBC!=NULL) { PrintSection("NODAL POINTS WITH APPLIED LOADS"); cout << " Node DOF Load (N)\n" << "------------------------------\n"; NodalLoad *nextLoad=firstLoadBC; while(nextLoad!=NULL) nextLoad=nextLoad->PrintLoad(); cout << endl; } //--------------------------------------------------- // Stress element faces if(firstEdgeBC!=NULL) { PrintSection("FACES WITH APPLIED STRESS (MPa)"); cout << " Elem Fc Type Nodal Stress Nodal Stress Nodal Stress\n" << "----------------------------------------------------------------------\n"; EdgeBC *nextEdge=firstEdgeBC; while(nextEdge!=NULL) nextEdge=nextEdge->PrintEdgeLoad(); cout << endl; } //--------------------------------------------------- // Periodic directions if(periodic.dof) { PrintSection("PERIODIC DIRECTIONS"); // x periodic, but y not (not allowed for axisymmetric) if(fmobj->periodic.dof==1) { sprintf(hline,"x direction from %g to %g mm",periodic.xmin,periodic.xmax); cout << hline << endl; if(periodic.fixDu) { sprintf(hline," Displacement jump fixed at %g mm for exx = %g",periodic.du,periodic.du/(periodic.xmax-periodic.xmin)); cout << hline << endl; } if(periodic.fixDudy) { sprintf(hline," Displacement jump slope fixed at %g",periodic.dudy); cout << hline << endl; } } // y periodic, but x not (only option for axisymmetrix - z periodic, but r not) else if(fmobj->periodic.dof==2) { char pax = fmobj->IsAxisymmetric() ? 'z' : 'y' ; sprintf(hline,"%c direction from %g to %g mm",pax,periodic.ymin,periodic.ymax); cout << hline << endl; if(periodic.fixDv) { sprintf(hline," Displacement jump fixed at %g mm for e%c%c = %g",periodic.dv,pax,pax,periodic.dv/(periodic.ymax-periodic.ymin)); cout << hline << endl; } if(periodic.fixDvdx) { sprintf(hline," Displacement jump slope fixed at %g",periodic.dvdx); cout << hline << endl; } } // x and y both periodic (not allowed for axisymmetric) else { sprintf(hline,"x direction from %g to %g mm",periodic.xmin,periodic.xmax); cout << hline << endl; if(periodic.fixDu) { sprintf(hline," Displacement jump fixed at %g mm for exx = %g",periodic.du,periodic.du/(periodic.xmax-periodic.xmin)); cout << hline << endl; } if(periodic.fixDvdx) { sprintf(hline," Displacement jump dv fixed at %g",periodic.dvdx); cout << hline << endl; } sprintf(hline,"y direction from %g to %g mm",periodic.ymin,periodic.ymax); cout << hline << endl; if(periodic.fixDv) { sprintf(hline," Displacement jump fixed at %g mm for eyy = %g",periodic.dv,periodic.dv/(periodic.ymax-periodic.ymin)); cout << hline << endl; } if(periodic.fixDudy) { sprintf(hline," Displacement jump du fixed at %g",periodic.dudy); cout << hline << endl; // if both Dudy and Dvdx then global shear is specified if(periodic.fixDvdx) { double b=periodic.dvdx/(periodic.xmax-periodic.xmin); double d=periodic.dudy/(periodic.ymax-periodic.ymin); sprintf(hline," for gxy = %g and rotation = %g",b+d,(d-b)/2); cout << hline << endl; } } } cout << endl; } }