int is_valid(t_tetrim *tetrim, int data[6][6]) { int c; int x; int link; c = -1; x = -1; link = 0; while (++c < 16) { if (data[c % 4 + 1][c / 4 + 1] == '#') { if (data[c % 4 + 1][c / 4 + 2] == '#') link++; if (data[c % 4 + 2][c / 4 + 1] == '#') link++; if (x == -1) x = c / 4; data[c % 4 + 1][c / 4 + 1] = '.'; data[c % 4 + 1][c / 4 + 1 - x] = '#'; } } move_data(tetrim, data); if (link < 3) return (-1); return (0); }
void setup_geoflow(ElementsHashTable* El_Table, NodeHashTable* NodeTable, int myid, int nump, MatProps* matprops_ptr, TimeProps *timeprops_ptr) { int i; int no_of_buckets = El_Table->get_no_of_buckets(); vector<HashEntryLine> &bucket=El_Table->bucket; tivector<Element> &elenode_=El_Table->elenode_; /* zero out the fluxes for all of the nodes */ //@NodesSingleLoop for(i = 0; i < NodeTable->elenode_.size(); i++) { if(NodeTable->status_[i]>=0) NodeTable->elenode_[i].zero_flux(); } /* put the coord for the center node in the element */ //@ElementsBucketDoubleLoop for(int ibuck = 0; ibuck < no_of_buckets; ibuck++) { for(int ielm = 0; ielm < bucket[ibuck].ndx.size(); ielm++) { Element *Curr_El = &(elenode_[bucket[ibuck].ndx[ielm]]); int refined = Curr_El->refined_flag(); if(Curr_El->adapted_flag() > 0) //if this is a refined element don't involve!!! { Curr_El->find_positive_x_side(NodeTable); Curr_El->calculate_dx(NodeTable); Curr_El->calc_topo_data(matprops_ptr); Curr_El->calc_gravity_vector(matprops_ptr); } } } /* transfer ghost elements to proper processors */ move_data(nump, myid, El_Table, NodeTable, timeprops_ptr); /* calculate d_gravity array for each element */ //@ElementsBucketDoubleLoop for(int ibuck = 0; ibuck < no_of_buckets; ibuck++) { for(int ielm = 0; ielm < bucket[ibuck].ndx.size(); ielm++) { Element *Curr_El = &(elenode_[bucket[ibuck].ndx[ielm]]); int refined = Curr_El->refined_flag(); if(Curr_El->adapted_flag() > 0) //if this is a refined element don't involve!!! { Curr_El->calc_d_gravity(El_Table); } } } return; }
size_t pthq_read(PTHQ *pth, void *buf, size_t bufsize) { pth_st *cur = pth; void *tmp; pthread_mutex_lock(&cur->rmute); /* 队列空则阻塞之*/ while (cur->dap[cur->rdp] == NULL && cur->status == Q_OPENED) { pthread_cond_wait(&cur->rcond, &cur->rmute); } if (is_closed_unlock(cur)) return EOF; tmp = cur->dap[cur->rdp]; cur->dap[cur->rdp] = NULL; fprintf(stdout, "%s", (char *)tmp + sizeof(size_t)); if (++cur->rdp == cur->buf_size) cur->rdp = 0; pthread_cond_broadcast(&cur->wcond); pthread_mutex_unlock(&cur->rmute); return move_data(buf, bufsize, tmp); }
void unrefine(HashTable* El_Table, HashTable* NodeTable, double target, int myid, int nump, TimeProps* timeprops_ptr, MatProps* matprops_ptr, int rescomp) { //printf("myid=%d entering unrefine\n",myid); int time_step = timeprops_ptr->iter; int i, j, k; Element* Curr_El; ElemPtrList<Element> NewFatherList, OtherProcUpdate; //-------------------go through all the elements of the subdomain------------------------ HashEntryPtr* buck = El_Table->getbucketptr(); for (i = 0; i < El_Table->get_no_of_buckets(); i++) if (*(buck + i)) { HashEntryPtr currentPtr = *(buck + i); while (currentPtr) { Curr_El = (Element*) currentPtr->value; currentPtr = currentPtr->next; if (rescomp) { if (Curr_El->get_adapted_flag() > 0) Curr_El->put_adapted_flag(NOTRECADAPTED); } else { if (Curr_El->get_adapted_flag() == NEWFATHER) Curr_El->put_adapted_flag(NOTRECADAPTED); } } } // start unrefinement for (i = 0; i < El_Table->get_no_of_buckets(); i++) if (*(buck + i)) { HashEntryPtr currentPtr = *(buck + i); while (currentPtr) { Curr_El = (Element*) currentPtr->value; // need to get currentPtr->next now since currentPtr might get deleted! currentPtr = currentPtr->next; if (Curr_El->get_adapted_flag() == NOTRECADAPTED) { //if this is a refined element don't involve!!! // if this if the original element, don't unrefine. only son 0 checks for unrefinement! if ((Curr_El->get_gen() > MIN_GENERATION) && (Curr_El->get_which_son() == 0)) { //check to see if currentPtr might get deleted and if it might, find next ptr that won't if (currentPtr != NULL) { int newnext = 0; while (newnext == 0 && currentPtr != NULL) { Element* nextelm = (Element*) currentPtr->value; if (nextelm->get_which_son() == 0) newnext = 1; else currentPtr = currentPtr->next; } } Curr_El->find_brothers<Element>(El_Table, NodeTable, target, myid, matprops_ptr, &NewFatherList, &OtherProcUpdate); } } } } int iproc; time_t tic, toc; /* for(iproc=0;iproc<nump-1;iproc++) if(myid>iproc); MPI_Barrier(MPI_COMM_WORLD); printf("myid=%d unref before unref_neigh_update\n",myid); fflush(stdout); tic=time(NULL); toc=tic+2; do{ tic=time(NULL); }while(tic<toc); for(iproc=1;iproc<nump;iproc++) if(myid<iproc); MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD); */ //assert(!IfMissingElem(El_Table, myid, time_step, 0)); unrefine_neigh_update(El_Table, NodeTable, myid, (void*) &NewFatherList); //assert(!IfMissingElem(El_Table, myid, time_step, 1)); unrefine_interp_neigh_update(El_Table, NodeTable, nump, myid, (void*) &OtherProcUpdate); /* for(iproc=0;iproc<nump-1;iproc++) if(myid>iproc); MPI_Barrier(MPI_COMM_WORLD); printf("myid=%d unref before delete\n",myid); fflush(stdout); tic=time(NULL); toc=tic+2; do{ tic=time(NULL); }while(tic<toc); for(iproc=1;iproc<nump;iproc++) if(myid<iproc); MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD); */ for (k = 0; k < NewFatherList.get_num_elem(); k++) delete_oldsons(El_Table, NodeTable, myid, NewFatherList.get(k)); /* MPI_Barrier(MPI_COMM_WORLD); for(iproc=0;iproc<nump-1;iproc++) if(myid>iproc); MPI_Barrier(MPI_COMM_WORLD); printf("myid=%d unref after delete\n",myid); fflush(stdout); tic=time(NULL); toc=tic+2; do{ tic=time(NULL); }while(tic<toc); for(iproc=1;iproc<nump;iproc++) if(myid<iproc); MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD); */ //assert(!IfMissingElem(El_Table, myid, time_step, 2)); /* printf("myid=%d after deleting\n",myid); MPI_Barrier(MPI_COMM_WORLD); printf("myid=%d leaving unrefine\n",myid); */ /* char debugfilename[64]; sprintf(debugfilename,"unref%02d%08d.debug",myid,time_step); FILE *fpdebug=fopen(debugfilename,"w"); fprintf(fpdebug,"%d elements unrefined on process %d ====================================!!!!!!!!!!!\n", unrefined*4, myid); fclose(fpdebug); */ move_data(nump, myid, El_Table, NodeTable, timeprops_ptr); for (i = 0; i < El_Table->get_no_of_buckets(); i++) { HashEntryPtr currentPtr = *(buck + i); while (currentPtr) { Curr_El = (Element*) currentPtr->value; currentPtr = currentPtr->next; if (Curr_El->get_adapted_flag() > TOBEDELETED) Curr_El->calc_wet_dry_orient(El_Table); } } //printf("myid=%d exiting unrefine\n",myid); return; }
static void append_nullary_function(Context* ctx, const char* name, WasmType result_type, int16_t num_local_i32, int16_t num_local_i64, int16_t num_local_f32, int16_t num_local_f64) { /* We assume that the data for the function in ctx->buf. Add this as a new function to ctx->temp_buf. */ const size_t header_size = FUNC_HEADER_SIZE(0); const size_t data_size = ctx->buf.size; const size_t name_size = strlen(name) + 1; const size_t total_added_size = header_size + data_size + name_size; const size_t new_size = ctx->temp_buf.size + total_added_size; const size_t old_size = ctx->temp_buf.size; if (g_verbose) printf("; after %s\n", name); ensure_output_buffer_capacity(&ctx->temp_buf, new_size); ctx->temp_buf.size = new_size; /* We need to add a new function header, data and name to the name table: OLD: NEW: module header module header global headers global headers function headers function headers NEW function header segment headers segment headers function data function data NEW function data segment data segment data name table name table NEW name */ const uint16_t num_globals = read_u16_at(&ctx->temp_buf, 2); const uint16_t num_functions = read_u16_at(&ctx->temp_buf, 4); const uint16_t num_segments = read_u16_at(&ctx->temp_buf, 6); /* fixup the number of functions */ out_u16_at(&ctx->temp_buf, 4, read_u16_at(&ctx->temp_buf, 4) + 1, "FIXUP num functions"); /* fixup the global offsets */ int i; uint32_t offset = GLOBAL_HEADERS_OFFSET; for (i = 0; i < num_globals; ++i) { add_u32_at(&ctx->temp_buf, offset + GLOBAL_HEADER_NAME_OFFSET, header_size + data_size, "FIXUP global name offset"); offset += GLOBAL_HEADER_SIZE; } /* fixup the function offsets */ for (i = 0; i < num_functions; ++i) { const uint8_t num_args = read_u8_at(&ctx->temp_buf, offset); add_u32_at(&ctx->temp_buf, offset + FUNC_HEADER_NAME_OFFSET(num_args), header_size + data_size, "FIXUP func name offset"); add_u32_at(&ctx->temp_buf, offset + FUNC_HEADER_CODE_START_OFFSET(num_args), header_size, "FIXUP func code start offset"); add_u32_at(&ctx->temp_buf, offset + FUNC_HEADER_CODE_END_OFFSET(num_args), header_size, "FIXUP func code end offset"); offset += FUNC_HEADER_SIZE(num_args); } uint32_t old_func_header_end = offset; /* fixup the segment offsets */ for (i = 0; i < num_segments; ++i) { add_u32_at(&ctx->temp_buf, offset + SEGMENT_HEADER_DATA_OFFSET, header_size + data_size, "FIXUP segment data offset"); offset += SEGMENT_HEADER_SIZE; } /* if there are no functions, then the end of the function data is the end of the headers */ uint32_t old_func_data_end = offset; if (num_functions) { /* we don't have to keep track of the number of args of the last function because it will be subtracted out, so we just use 0 */ uint32_t last_func_code_end_offset = old_func_header_end - FUNC_HEADER_SIZE(0) + FUNC_HEADER_CODE_END_OFFSET(0); old_func_data_end = read_u32_at(&ctx->temp_buf, last_func_code_end_offset) - header_size; } /* move everything after the function data down, but leave room for the new function name */ move_data(&ctx->temp_buf, old_func_data_end + header_size + data_size, old_func_data_end, old_size - old_func_data_end); /* write the new name */ const uint32_t new_name_offset = new_size - name_size; out_data(&ctx->temp_buf, new_name_offset, name, name_size, "func name"); /* write the new function data */ const uint32_t new_data_offset = old_func_data_end + header_size; out_data(&ctx->temp_buf, new_data_offset, ctx->buf.start, ctx->buf.size, "func func data"); /* move everything between the end of the function headers and the end of the function data down */ move_data(&ctx->temp_buf, old_func_header_end + header_size, old_func_header_end, old_func_data_end - old_func_header_end); /* write the new header */ const uint32_t new_header_offset = old_func_header_end; if (g_verbose) { printf("; clear [%07x,%07x)\n", new_header_offset, new_header_offset + FUNC_HEADER_SIZE(0)); } memset(ctx->temp_buf.start + new_header_offset, 0, FUNC_HEADER_SIZE(0)); out_u8_at(&ctx->temp_buf, new_header_offset + FUNC_HEADER_RESULT_TYPE_OFFSET, wasm_type_to_v8_type(result_type), "func result type"); out_u32_at(&ctx->temp_buf, new_header_offset + FUNC_HEADER_NAME_OFFSET(0), new_name_offset, "func name offset"); out_u32_at(&ctx->temp_buf, new_header_offset + FUNC_HEADER_CODE_START_OFFSET(0), new_data_offset, "func code start offset"); out_u32_at(&ctx->temp_buf, new_header_offset + FUNC_HEADER_CODE_END_OFFSET(0), new_data_offset + data_size, "func code end offset"); out_u16_at(&ctx->temp_buf, new_header_offset + FUNC_HEADER_NUM_LOCAL_I32_OFFSET(0), num_local_i32, "func num local i32"); out_u16_at(&ctx->temp_buf, new_header_offset + FUNC_HEADER_NUM_LOCAL_I64_OFFSET(0), num_local_i64, "func num local i64"); out_u16_at(&ctx->temp_buf, new_header_offset + FUNC_HEADER_NUM_LOCAL_F32_OFFSET(0), num_local_f32, "func num local f32"); out_u16_at(&ctx->temp_buf, new_header_offset + FUNC_HEADER_NUM_LOCAL_F64_OFFSET(0), num_local_f64, "func num local f64"); out_u8_at(&ctx->temp_buf, new_header_offset + FUNC_HEADER_EXPORTED_OFFSET(0), 1, "func export"); }
int main(int argc, char *argv[]) { int i;//-- counters HashTable* BT_Node_Ptr; HashTable* BT_Elem_Ptr; //-- MPI int myid, master, numprocs; int namelen; char processor_name[MPI_MAX_PROCESSOR_NAME]; MPI_Status status; MPI_Init(&argc,&argv); //PetscInitializeNoArguments(); PetscInitialize(&argc,&argv,PETSC_NULL,PETSC_NULL); MPI_Comm_size(MPI_COMM_WORLD, &numprocs); MPI_Comm_rank(MPI_COMM_WORLD, &myid); MPI_Get_processor_name(processor_name, &namelen); char debugfilename[256]; sprintf(debugfilename,"hpfem%04d.debug",myid); double start, end; start = MPI_Wtime(); /* create new MPI datastructures for class objects */ MPI_New_Datatype(); char filename[50]; sprintf(filename,"debug.main.%04d",myid); /* read original data from serial preprocessing code and then initialize element stiffness routines info */ int material_count=0, output_flag; double epsilon = 1., intfrictang = 1, *bedfrictang = NULL, gamma = 1; double frict_tiny = 0.1, mu = 1.0e-03, rho = 1600, rhof = 1000, porosity = 1; char **matnames=NULL; int xdmerr; StatProps statprops; MatProps matprops(material_count, matnames, intfrictang, bedfrictang, porosity, mu, rho, rhof, epsilon, gamma, frict_tiny, 1.0, 1.0, 1.0); TimeProps timeprops; timeprops.starttime=time(NULL); MapNames mapnames; PileProps pileprops; FluxProps fluxprops; OutLine outline; DISCHARGE discharge; int adaptflag; double end_time = 10000.0; /* * viz_flag is used to determine which viz output to use * nonzero 1st bit of viz_flag means output tecplotxxxx.plt * nonzero 2nd bit of viz_flag means output mshplotxxxx.plt * nonzero 4th bit of viz_flag means output xdmfxxxxx.xmf * nonzero 5th bit of viz_flag means output grass_sites files order_flag == 1 means use first order method order_flag == 2 means use second order method */ int viz_flag = 0, order_flag, savefileflag=1; //savefileflag will be flipped so first savefile will end in 0 int Init_Node_Num, Init_Elem_Num, srctype; double v_star; // v/v_slump double nz_star; /* temporary... used for negligible velocity as stopping criteria paper... plan to include in v_star implicitly later */ Read_data(myid, &matprops, &pileprops, &statprops, &timeprops, &fluxprops, &adaptflag, &viz_flag, &order_flag, &mapnames, &discharge, &outline, &srctype ); if(!loadrun(myid, numprocs, &BT_Node_Ptr, &BT_Elem_Ptr, &matprops, &timeprops, &mapnames, &adaptflag, &order_flag, &statprops, &discharge, &outline)) { Read_grid(myid, numprocs, &BT_Node_Ptr, &BT_Elem_Ptr, &matprops, &outline); setup_geoflow(BT_Elem_Ptr, BT_Node_Ptr, myid, numprocs, &matprops,&timeprops); move_data(numprocs, myid, BT_Elem_Ptr, BT_Node_Ptr,&timeprops); AssertMeshErrorFree(BT_Elem_Ptr,BT_Node_Ptr,numprocs,myid,-1.0); //initialize pile height and if appropriate perform initial adaptation init_piles(BT_Elem_Ptr, BT_Node_Ptr, myid, numprocs, adaptflag, &matprops, &timeprops, &mapnames, &pileprops, &fluxprops, &statprops); } if (myid==0) { for(int imat=1; imat<=matprops.material_count; imat++) printf("bed friction angle for \"%s\" is %g\n",matprops.matnames[imat], matprops.bedfrict[imat]*180.0/PI); printf("internal friction angle is %g, epsilon is %g \n method order = %i\n", matprops.intfrict*180.0/PI, matprops.epsilon, order_flag ); printf("REFINE_LEVEL=%d\n",REFINE_LEVEL); } //printdate(BT_Elem_Ptr, BT_Node_Ptr,&matprops, &fluxprops,&timeprops); MPI_Barrier(MPI_COMM_WORLD); calc_stats(BT_Elem_Ptr, BT_Node_Ptr, myid, &matprops, &timeprops, &statprops, &discharge, 0.0); output_discharge(&matprops, &timeprops, &discharge, myid); move_data(numprocs, myid, BT_Elem_Ptr, BT_Node_Ptr,&timeprops); // int jiter; // for( jiter=0; jiter <3; jiter++){ // LaplacianData Laplacian (BT_Elem_Ptr, BT_Node_Ptr ,1 ,.001); // implicit_solver(&Laplacian); // } // HashEntryPtr *buck = BT_Elem_Ptr->getbucketptr(); // for(jiter=0; jiter<BT_Elem_Ptr->get_no_of_buckets(); jiter++){ // if(*(buck+jiter)) // { // HashEntryPtr currentPtr = *(buck+jiter); // while(currentPtr) // { // Element* Curr_El=(Element*)(currentPtr->value); // if(Curr_El->get_adapted_flag()>0)//||(timeprops_ptr->iter%5==2))) // { //if this is a refined element don't involve!!! // double phi = *(Curr_El->get_state_vars()+4); // if(phi>1) phi=1; // if(phi<0) phi=0; // Curr_El->update_phase2(phi); // Curr_El->update_phase1(phi); // } // currentPtr=currentPtr->next; // } // } // } //============================================================================================================= // int num_buck=BT_Elem_Ptr->get_no_of_buckets(); // HashEntryPtr* buck = BT_Elem_Ptr->getbucketptr(); // int num_nonzero_elem=0, *all_num_nonzero_elem; // for(i=0; i<num_buck; i++) // if(*(buck+i)){ // HashEntryPtr currentPtr = *(buck+i); // while(currentPtr){ // Element* Curr_El=(Element*)(currentPtr->value); // if((Curr_El->get_adapted_flag()>0)&& // (myid==Curr_El->get_myprocess())) // if(*(Curr_El->pass_key())==3842346279 && *(Curr_El->pass_key()+1)==2368179492) // { // int xp=Curr_El->get_positive_x_side(); // int yp=(xp+1)%4, xm=(xp+2)%4, ym=(xp+3)%4; // Node* nym = (Node*) BT_Node_Ptr->lookup(Curr_El->getNode()+(ym+4)*2); // assert(nym->flux[1]); // } // currentPtr=currentPtr->next; // } // } //===================================================================================================== if(myid==0) output_summary(&timeprops, &statprops, savefileflag); if(viz_flag&1) tecplotter(BT_Elem_Ptr, BT_Node_Ptr, &matprops, &timeprops, &mapnames, statprops.vstar ); if(viz_flag&2) meshplotter(BT_Elem_Ptr, BT_Node_Ptr, &matprops, &timeprops, &mapnames, statprops.vstar); //printdate(BT_Elem_Ptr, BT_Node_Ptr,&matprops, &fluxprops,&timeprops); #ifdef HAVE_HDF5 if(viz_flag&8) xdmerr=write_xdmf(BT_Elem_Ptr,BT_Node_Ptr,&timeprops,&matprops,&mapnames,XDMF_NEW); #endif if(viz_flag&16){ if(myid==0) grass_sites_header_output(&timeprops); grass_sites_proc_output(BT_Elem_Ptr, BT_Node_Ptr, myid, &matprops, &timeprops);} /* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccc cccccccccccccccccccccccccccccccccccccccccccccccccccccccccc Time Stepping Loop cccccccccccccccccccccccccccccccccccccccccccccccccccccccccc cccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */ long element_counter=0; // for performance count elements/timestep/proc int ifstop=0; double max_momentum=100; //nondimensional /* ifend(0.5*statprops.vmean) is a hack, the original intent (when we were intending to use vstar as a stopping criteria) whas to have the calculation when vstar dropped back down below 1, instead we're using the ifend() function to stop the simulation when the volume averaged velocity falls back down below 2 meters... this hack is only for the colima hazard map runs, otherwise pass ifend() a constant valued */ while(!(timeprops.ifend(0)) && !ifstop)//(timeprops.ifend(0.5*statprops.vmean)) && !ifstop) { /* * mesh adaption routines */ double TARGET = .05; //double UNREFINE_TARGET = .005; double UNREFINE_TARGET = .01; int h_count = 0; if (timeprops.iter < 50) matprops.frict_tiny=0.1; else matprops.frict_tiny=0.000000001; //check for changes in topography and update if necessary //may want to put an "if(timeprops.iter %20==0)" (20 is arbitrary) here if(timeprops.iter==200){ update_topo(BT_Elem_Ptr, BT_Node_Ptr, myid, numprocs, &matprops, &timeprops,&mapnames); } if((adaptflag!=0)&&(timeprops.iter%5==4)) { AssertMeshErrorFree(BT_Elem_Ptr,BT_Node_Ptr,numprocs,myid,-2.0); H_adapt(BT_Elem_Ptr, BT_Node_Ptr, h_count, TARGET, &matprops, &fluxprops, &timeprops, 5); move_data(numprocs, myid, BT_Elem_Ptr, BT_Node_Ptr,&timeprops); unrefine(BT_Elem_Ptr, BT_Node_Ptr, UNREFINE_TARGET, myid, numprocs, &timeprops, &matprops); MPI_Barrier(MPI_COMM_WORLD);//for debug move_data(numprocs, myid, BT_Elem_Ptr, BT_Node_Ptr,&timeprops); //this move_data() here for debug... to make AssertMeshErrorFree() Work if((numprocs>1)&&(timeprops.iter%10==9)) { repartition2(BT_Elem_Ptr, BT_Node_Ptr, &timeprops); move_data(numprocs, myid, BT_Elem_Ptr, BT_Node_Ptr,&timeprops); //this move_data() here for debug... to make AssertMeshErrorFree() Work } move_data(numprocs, myid, BT_Elem_Ptr, BT_Node_Ptr,&timeprops); } step(BT_Elem_Ptr, BT_Node_Ptr, myid, numprocs, &matprops, &timeprops, &pileprops, &fluxprops, &statprops, &order_flag, &outline, &discharge,adaptflag); /* * output results to file */ if(timeprops.ifoutput()) { // if (timeprops.iter%30==1){//(timeprops.iter<1000 && timeprops.iter%60==58) //output_flag=1; //else if ( timeprops.iter%200==198) //output_flag=1; // if(output_flag) // { move_data(numprocs, myid, BT_Elem_Ptr, BT_Node_Ptr,&timeprops); output_discharge(&matprops, &timeprops, &discharge, myid); //output_flag=0; if(myid==0){ output_summary(&timeprops, &statprops, savefileflag); } if(viz_flag&1) tecplotter(BT_Elem_Ptr, BT_Node_Ptr, &matprops, &timeprops, &mapnames,statprops.vstar); if(viz_flag&2) meshplotter(BT_Elem_Ptr, BT_Node_Ptr, &matprops, &timeprops, &mapnames,statprops.vstar); #ifdef HAVE_HDF5 if(viz_flag&8) xdmerr=write_xdmf(BT_Elem_Ptr,BT_Node_Ptr,&timeprops,&matprops,&mapnames,XDMF_OLD); #endif if(viz_flag&16){ if(myid==0) grass_sites_header_output(&timeprops); grass_sites_proc_output(BT_Elem_Ptr, BT_Node_Ptr, myid, &matprops, &timeprops); } } #ifdef PERFTEST int countedvalue=timeprops.iter%2+1; int e_buckets=BT_Elem_Ptr->get_no_of_buckets(); HashEntry* entryp; for(i=0; i<e_buckets; i++) { entryp = *(BT_Elem_Ptr->getbucketptr() + i); while(entryp) { Element * EmTemp = (Element*)entryp->value; assert(EmTemp); assert(EmTemp->get_counted()!=countedvalue); if((EmTemp->get_adapted_flag()>=NOTRECADAPTED)&& (EmTemp->get_adapted_flag()<=BUFFER) ) { //if this element doesn't belong on this processor don't involve element_counter++; EmTemp->put_counted(countedvalue); } entryp = entryp->next; } } MPI_Barrier(MPI_COMM_WORLD); #endif } MPI_Barrier(MPI_COMM_WORLD); move_data(numprocs, myid, BT_Elem_Ptr, BT_Node_Ptr,&timeprops); MPI_Barrier(MPI_COMM_WORLD); output_discharge(&matprops, &timeprops, &discharge, myid); MPI_Barrier(MPI_COMM_WORLD); if(myid==0) output_summary(&timeprops, &statprops, savefileflag); //printf("hpfem.C 1: xcen=%g\n",statprops.xcen); if(viz_flag&1) tecplotter(BT_Elem_Ptr, BT_Node_Ptr, &matprops, &timeprops, &mapnames, statprops.vstar); //printf("hpfem.C 2: xcen=%g\n",statprops.xcen); MPI_Barrier(MPI_COMM_WORLD); if(viz_flag&2) meshplotter(BT_Elem_Ptr, BT_Node_Ptr, &matprops, &timeprops, &mapnames, statprops.vstar); MPI_Barrier(MPI_COMM_WORLD); #ifdef HAVE_HDF5 if(viz_flag&8) xdmerr=write_xdmf(BT_Elem_Ptr,BT_Node_Ptr,&timeprops,&matprops,&mapnames,XDMF_CLOSE); MPI_Barrier(MPI_COMM_WORLD); #endif if(viz_flag&16){ if(myid==0) grass_sites_header_output(&timeprops); grass_sites_proc_output(BT_Elem_Ptr, BT_Node_Ptr, myid, &matprops, &timeprops);} MPI_Barrier(MPI_COMM_WORLD); // write out ending warning, maybe flow hasn't finished moving sim_end_warning(BT_Elem_Ptr, &matprops, &timeprops, statprops.vstar); MPI_Barrier(MPI_COMM_WORLD); //write out the final pile statistics (and run time) if(myid==0) out_final_stats(&timeprops, &statprops); MPI_Barrier(MPI_COMM_WORLD); //write out stochastic simulation statistics //if(statprops.lhs.runid>=0) if(myid==0) output_stoch_stats(&matprops, &statprops); MPI_Barrier(MPI_COMM_WORLD); //saverun(&BT_Node_Ptr, myid, numprocs, &BT_Elem_Ptr, &matprops, &timeprops, &mapnames, // adaptflag, order_flag, &statprops, &discharge, &outline, &savefileflag); Was not possible because the saverun function doesn't write the information for laplacian, moreover element constructor requires some modifications MPI_Barrier(MPI_COMM_WORLD); //output maximum flow depth a.k.a. flow outline OutLine outline2; double dxy[2]; dxy[0]=outline.dx; dxy[1]=outline.dy; outline2.init2(dxy,outline.xminmax,outline.yminmax); int NxNyout=outline.Nx*outline.Ny; MPI_Reduce(*(outline.pileheight),*(outline2.pileheight),NxNyout, MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD); if(myid==0) outline2.output(&matprops,&statprops); #ifdef PERFTEST long m = element_counter, ii; MPI_Allreduce ( &element_counter, &ii, 1, MPI_LONG, MPI_SUM, MPI_COMM_WORLD ); end=MPI_Wtime(); char perffilename[256]; sprintf(perffilename,"perform%04d.%04d",numprocs,myid); FILE *fpperf=fopen(perffilename,"w"); fprintf(fpperf,"%d Finished -- used %ld elements of %ld total in %e seconds, %e\n",myid,m,ii,end-start, ii/(end-start)); fclose(fpperf); #endif PetscFinalize(); MPI_Finalize(); return(0); }
void step(HashTable* El_Table, HashTable* NodeTable, int myid, int nump, MatProps* matprops_ptr, TimeProps* timeprops_ptr, PileProps *pileprops_ptr, FluxProps *fluxprops, StatProps* statprops_ptr, int* order_flag, OutLine* outline_ptr, DISCHARGE* discharge, int adaptflag) { /* * PREDICTOR-CORRECTED based on Davis' Simplified Godunov Method */ /* pass off proc data here (really only need state_vars for off-proc neighbors) */ move_data(nump, myid, El_Table, NodeTable, timeprops_ptr); slopes(El_Table, NodeTable, matprops_ptr, 0); // get coefficients, eigenvalues, hmax and calculate the time step double dt = get_coef_and_eigen(El_Table, NodeTable, matprops_ptr, fluxprops, timeprops_ptr, 0); // here we store the required data (solution and functional sensitivity) for the 0 time step timeprops_ptr->incrtime(&dt); //also reduces dt if necessary // assign influxes and then if any new sources are activating in // current time step refine and re-mark cells adapt_fluxsrc_region(El_Table, NodeTable, matprops_ptr, pileprops_ptr, fluxprops, timeprops_ptr, dt, myid, adaptflag); int i; HashEntryPtr* buck = El_Table->getbucketptr(); HashEntryPtr currentPtr; Element* Curr_El; double dt2 = .5 * dt; // dt2 is set as dt/2 ! /* * predictor step */ int j, k, counter; double tiny = GEOFLOW_TINY; double flux_src_coef = 0; #ifdef SECOND_ORDER //-------------------go through all the elements of the subdomain and //-------------------calculate the state variables at time .5*delta_t /* mdj 2007-04 */ int IF_STOPPED; double curr_time,influx[3],*d_uvec; //VxVy[2]; double VxVy[2]; Node* nd; #pragma omp parallel for \ private(currentPtr,Curr_El,IF_STOPPED,influx,j,k,curr_time,flux_src_coef,VxVy) for(i=0; i<El_Table->get_no_of_buckets(); i++) if(*(buck+i)) { currentPtr = *(buck+i); while(currentPtr) { Curr_El=(Element*)(currentPtr->value); influx[3]; influx[0]=*(Curr_El->get_influx()+0); influx[1]=*(Curr_El->get_influx()+1); influx[2]=*(Curr_El->get_influx()+2); if(!(influx[0]>=0.0)) { printf("negative influx=%g\n",influx[0]); assert(0); } if(Curr_El->get_adapted_flag()>0) { d_uvec = Curr_El->get_d_state_vars(); nd = (Node*) NodeTable->lookup(Curr_El->pass_key()); // -- calc contribution of flux source flux_src_coef=0; curr_time=(timeprops_ptr->time)*(timeprops_ptr->TIME_SCALE); //VxVy[2]; if(*(Curr_El->get_state_vars()+0)>GEOFLOW_TINY) { VxVy[0]=*(Curr_El->get_state_vars()+1)/ *(Curr_El->get_state_vars()+0); VxVy[1]=*(Curr_El->get_state_vars()+2)/ *(Curr_El->get_state_vars()+0); } else VxVy[0]=VxVy[1]=0.0; #ifdef STOPCRIT_CHANGE_SOURCE IF_STOPPED=Curr_El->get_stoppedflags(); #else IF_STOPPED=!(!(Curr_El->get_stoppedflags())); #endif predict_(Curr_El->get_state_vars(), d_uvec, (d_uvec+NUM_STATE_VARS), Curr_El->get_prev_state_vars(), &tiny, Curr_El->get_kactxy(), &dt2, Curr_El->get_gravity(), Curr_El->get_curvature(), &(matprops_ptr->bedfrict[Curr_El->get_material()]), &(matprops_ptr->intfrict), Curr_El->get_d_gravity(), &(matprops_ptr->frict_tiny), order_flag, VxVy, &IF_STOPPED,influx); /* apply bc's */ #ifdef APPLY_BC for(j=0;j<4;j++) if(*(Curr_El->get_neigh_proc()+j) == INIT) // this is a boundary! for(k=0;k<NUM_STATE_VARS;k++) *(Curr_El->get_state_vars()+k) = 0; #endif } currentPtr=currentPtr->next; } } /* finished predictor step */ /* really only need to share dudx, state_vars, and kactxy */ move_data(nump, myid, El_Table, NodeTable,timeprops_ptr); /* calculate the slopes for the new (half-time step) state variables */ slopes(El_Table, NodeTable, matprops_ptr); #endif //SECOND_ORDER /* really only need to share dudx, state_vars, and kactxy */ move_data(nump, myid, El_Table, NodeTable, timeprops_ptr); /* calculate kact/pass */ double dt_not_used = get_coef_and_eigen(El_Table, NodeTable, matprops_ptr, fluxprops, timeprops_ptr, 1); /* * calculate edge states */ double outflow = 0.0; //shouldn't need the =0.0 assignment but just being cautious. //printf("step: before calc_edge_states\n"); fflush(stdout); calc_edge_states<Element>(El_Table, NodeTable, matprops_ptr, timeprops_ptr, myid, order_flag, &outflow); outflow *= dt; /* * corrector step and b.c.s */ //for comparison of magnitudes of forces in slumping piles double forceint = 0.0, elemforceint; double forcebed = 0.0, elemforcebed; double eroded = 0.0, elemeroded; double deposited = 0.0, elemdeposited; double realvolume = 0.0; buck = El_Table->getbucketptr(); // mdj 2007-04 this loop has pretty much defeated me - there is // a dependency in the Element class that causes incorrect // results // for (i = 0; i < El_Table->get_no_of_buckets(); i++) if (*(buck + i)) { HashEntryPtr currentPtr = *(buck + i); while (currentPtr) { Element* Curr_El = (Element*) (currentPtr->value); if (Curr_El->get_adapted_flag() > 0) { //if this is a refined element don't involve!!! double *dxy = Curr_El->get_dx(); // if calculations are first-order, predict is never called // ... so we need to update prev_states // void *Curr_El_out = (void *) Curr_El; //I believe it's because we need correct function be a friend function of node class, but we do not want to add element header to node.h if (*order_flag == 1) Curr_El->update_prev_state_vars(); //if (*(Curr_El->pass_key())==2151461179 && *(Curr_El->pass_key()+1)==330382099 /*&& timeprops->iter == 9 */) // cout<<"step is cheking the element"<<endl; correct(NodeTable, El_Table, dt, matprops_ptr, fluxprops, timeprops_ptr, Curr_El, &elemforceint, &elemforcebed, &elemeroded, &elemdeposited); forceint += fabs(elemforceint); forcebed += fabs(elemforcebed); realvolume += dxy[0] * dxy[1] * *(Curr_El->get_state_vars()); eroded += elemeroded; deposited += elemdeposited; double *coord = Curr_El->get_coord(); //update the record of maximum pileheight in the area covered by this element double hheight = *(Curr_El->get_state_vars()); // int ind = Curr_El->get_sol_rec_ind(); // jacobian = solHyst->at(ind); #ifdef MAX_DEPTH_MAP double pfheight[6]; outline_ptr->update(coord[0] - 0.5 * dxy[0], coord[0] + 0.5 * dxy[0], coord[1] - 0.5 * dxy[1], coord[1] + 0.5 * dxy[1], hheight, pfheight); #endif //#ifdef APPLY_BC // for (j = 0; j < 4; j++) // if (*(Curr_El->get_neigh_proc() + j) == INIT) // this is a boundary! // for (k = 0; k < NUM_STATE_VARS; k++) // *(Curr_El->get_state_vars() + k) = 0; //#endif } currentPtr = currentPtr->next; } } //update the orientation of the "dryline" (divides partially wetted cells //into wet and dry parts solely based on which neighbors currently have //pileheight greater than GEOFLOW_TINY for (i = 0; i < El_Table->get_no_of_buckets(); i++) { HashEntryPtr currentPtr = *(buck + i); while (currentPtr) { Element* Curr_El = (Element*) (currentPtr->value); currentPtr = currentPtr->next; if (Curr_El->get_adapted_flag() > 0) //if this is a refined element don't involve!!! Curr_El->calc_wet_dry_orient(El_Table); } } /* finished corrector step */ calc_stats(El_Table, NodeTable, myid, matprops_ptr, timeprops_ptr, statprops_ptr, discharge, dt); // double tempin[6], tempout[6]; // tempin[0] = outflow; //volume that flew out the boundaries this iteration // tempin[1] = eroded; //volume that was eroded this iteration // tempin[2] = deposited; //volume that is currently deposited // tempin[3] = realvolume; //"actual" volume within boundaries // tempin[4] = forceint; //internal friction force // tempin[5] = forcebed; //bed friction force // // MPI_Reduce(tempin, tempout, 6, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); // // statprops_ptr->outflowvol += tempout[0] * (matprops_ptr->HEIGHT_SCALE) // * (matprops_ptr->LENGTH_SCALE) * (matprops_ptr->LENGTH_SCALE); // statprops_ptr->erodedvol += tempout[1] * (matprops_ptr->HEIGHT_SCALE) // * (matprops_ptr->LENGTH_SCALE) * (matprops_ptr->LENGTH_SCALE); // statprops_ptr->depositedvol = tempout[2] * (matprops_ptr->HEIGHT_SCALE) // * (matprops_ptr->LENGTH_SCALE) * (matprops_ptr->LENGTH_SCALE); // statprops_ptr->realvolume = tempout[3] * (matprops_ptr->HEIGHT_SCALE) // * (matprops_ptr->LENGTH_SCALE) * (matprops_ptr->LENGTH_SCALE); // // statprops_ptr->forceint = tempout[4] / tempout[3] * matprops_ptr->GRAVITY_SCALE; // statprops_ptr->forcebed = tempout[5] / tempout[3] * matprops_ptr->GRAVITY_SCALE; //calc_volume(El_Table, myid, matprops_ptr, timeprops_ptr, dt, v_star, nz_star); return; }
/* Matrix-vector product subroutine for the 2D Laplacian. */ PetscErrorCode MatLaplacian2D_Mult(Mat A, Vec x, Vec y) { PetscInt elem, i, rank, *indices, *num_elem_proc, xsize; PetscScalar *x_ptr, *y_ptr; PetscErrorCode ierr; HashEntryPtr currentPtr; Element *Curr_El; ContData *myctx; VecScatter *vscat; Vec x_local, y_local; // PetscFunctionBegin; ierr = MatShellGetContext(A, (void**) &myctx); CHKERRQ(ierr); //ierr = VecGetSize(x,&xsize); // cout<<"size x is before "<<xsize<<endl; //ierr = VecGetSize(y,&xsize); // cout<<"size y is before"<<xsize<<endl; num_elem_proc = myctx->Num_elem_proc; rank = myctx->rank; vscat = &(myctx->Scatter); ierr = VecCreateSeq(PETSC_COMM_SELF, num_elem_proc[rank], &x_local); CHKERRQ(ierr); ierr = VecScatterBegin(*vscat, x, x_local, INSERT_VALUES, SCATTER_REVERSE); CHKERRQ(ierr); ierr = VecScatterEnd(*vscat, x, x_local, INSERT_VALUES, SCATTER_REVERSE); CHKERRQ(ierr); ierr = VecCreateSeq(PETSC_COMM_SELF, num_elem_proc[rank], &y_local); CHKERRQ(ierr); ierr = VecGetArray(x_local, &x_ptr); CHKERRQ(ierr); elem = 0; HashEntryPtr *buck = myctx->El_Table->getbucketptr(); for (i = 0; i < myctx->El_Table->get_no_of_buckets(); i++) if (*(buck + i)) { HashEntryPtr currentPtr = *(buck + i); while (currentPtr) { Element* Curr_El = (Element*) (currentPtr->value); if (Curr_El->get_adapted_flag() > 0) { *(Curr_El->get_state_vars()) = x_ptr[elem]; elem++; } currentPtr = currentPtr->next; } } ierr = VecRestoreArray(x_local, &x_ptr); CHKERRQ(ierr); move_data(myctx->size, myctx->rank, myctx->El_Table, myctx->Node_Table, myctx->Timeptr); //here we need comminucation between processors to transfer the information of the gohst elements and MPI_BARRIER elem = 0; for (i = 0; i < myctx->El_Table->get_no_of_buckets(); i++) if (*(buck + i)) { HashEntryPtr currentPtr = *(buck + i); while (currentPtr) { Element* Curr_El = (Element*) (currentPtr->value); if (Curr_El->get_adapted_flag() > 0) { Curr_El->calc_lap_phi(myctx->El_Table, myctx->Node_Table); } currentPtr = currentPtr->next; } } MPI_Barrier(PETSC_COMM_WORLD); ierr = VecGetArray(y_local, &y_ptr); CHKERRQ(ierr); for (i = 0; i < myctx->El_Table->get_no_of_buckets(); i++) if (*(buck + i)) { HashEntryPtr currentPtr = *(buck + i); while (currentPtr) { Element* Curr_El = (Element*) (currentPtr->value); if (Curr_El->get_adapted_flag() > 0) { y_ptr[elem] = *(Curr_El->get_state_vars()) - (myctx->LapCoef) * (myctx->delta_t) * (*(Curr_El->get_lap_phi()) + *(Curr_El->get_lap_phi() + 1)); // if ( *(Curr_El->get_state_vars())>0) // printf("phi=%f, lap_phi_x=%f, lap_phi_y=%f, y=%f \n ", // *(Curr_El->get_state_vars()), *(Curr_El->get_lap_phi()),*(Curr_El->get_lap_phi()+1), yy[elem]); elem++; } currentPtr = currentPtr->next; } } ierr = VecRestoreArray(y_local, &y_ptr); CHKERRQ(ierr); //ierr = VecGetSize(x,&xsize); //cout<<"size x is after"<<xsize<<endl; //ierr = VecGetSize(y,&xsize); //cout<<"size y is after "<<xsize<<endl; ierr = VecScatterBegin(*vscat, y_local, y, INSERT_VALUES, SCATTER_FORWARD); CHKERRQ(ierr); ierr = VecScatterEnd(*vscat, y_local, y, INSERT_VALUES, SCATTER_FORWARD); CHKERRQ(ierr); ierr = VecDestroy(&y_local); CHKERRQ(ierr); ierr = VecDestroy(&x_local); CHKERRQ(ierr); //PetscFree(xx); //PetscFree(yy); //PetscFree(indices); //exit(1); PetscFunctionReturn(0); }
void setup_geoflow(HashTable* El_Table, HashTable* NodeTable, int myid, int nump,MatProps* matprops_ptr,TimeProps *timeprops_ptr) { int i; int num_buckets = El_Table->get_no_of_buckets(); int num_node_buckets = NodeTable->get_no_of_buckets(); /* zero out the fluxes for all of the nodes */ HashEntryPtr* buck = NodeTable->getbucketptr(); for(i=0; i<num_node_buckets; i++) if(*(buck+i)) { HashEntryPtr currentPtr = *(buck+i); while(currentPtr) { Node* Curr_Node=(Node*)(currentPtr->value); Curr_Node->zero_flux(); currentPtr=currentPtr->next; } } /* put the coord for the center node in the element */ buck = El_Table->getbucketptr(); for(i=0; i<num_buckets; i++) if(*(buck+i)) { HashEntryPtr currentPtr = *(buck+i); while(currentPtr) { Element* Curr_El=(Element*)(currentPtr->value); int refined = Curr_El->get_refined_flag(); if(Curr_El->get_adapted_flag()>0)//if this is a refined element don't involve!!! { Curr_El->find_positive_x_side(NodeTable); Curr_El->calculate_dx(NodeTable); Curr_El->calc_topo_data(matprops_ptr); Curr_El->calc_gravity_vector(matprops_ptr); } currentPtr=currentPtr->next; } } /* transfer ghost elements to proper processors */ move_data(nump, myid, El_Table, NodeTable,timeprops_ptr); /* calculate d_gravity array for each element */ buck = El_Table->getbucketptr(); for(i=0; i<num_buckets; i++) if(*(buck+i)) { HashEntryPtr currentPtr = *(buck+i); while(currentPtr) { Element* Curr_El=(Element*)(currentPtr->value); int refined = Curr_El->get_refined_flag(); if(Curr_El->get_adapted_flag()>0)//if this is a refined element don't involve!!! { Curr_El->calc_d_gravity(El_Table); } currentPtr=currentPtr->next; } } return; }
static void i810_accel_putc(struct vc_data *conp, struct display *p, int c, int yy, int xx) { struct blit_data data; int width, height, depth, d_addr, d_pitch, s_pitch; void (*move_data)(void *dst, void *src, int dpitch, int spitch, int size); char *s_addr; if (i810_accel->lockup || not_safe()) return; depth = (p->var.bits_per_pixel + 7) >> 3; switch (depth) { case 1: data.fg = (int) attr_fgcol(p,c); data.bg = (int) attr_bgcol(p,c); data.blit_bpp = BPP8; break; case 2: data.bg = (int) ((u16 *)p->dispsw_data)[attr_bgcol(p, c)]; data.fg = (int) ((u16 *)p->dispsw_data)[attr_fgcol(p, c)]; data.blit_bpp = BPP16; break; case 3: data.fg = ((int *) p->dispsw_data)[attr_fgcol(p, c)]; data.bg = ((int *) p->dispsw_data)[attr_bgcol(p, c)]; data.blit_bpp = BPP24; } height = fontheight(p); width = (fontwidth(p) + 7) & ~7; switch (width) { case 8: move_data = i810fb_moveb; break; case 16: move_data = i810fb_movew; break; case 32: move_data = i810fb_movel; break; default: move_data = i810fb_move; break; } s_pitch = width >> 3; d_pitch = ((s_pitch) + 1) & ~1; data.dwidth = width * depth; data.dheight = height; data.dpitch = p->next_line; data.rop = PAT_COPY_ROP; data.dsize = (d_pitch * height) >> 2; data.d_addr = (i810_accel->fb_offset << 12) + (yy * height * p->next_line) + (xx * width * depth); data.s_addr[0] = d_addr = i810_accel->text_buffer; s_addr = p->fontdata + ((c & p->charmask) * s_pitch * height); move_data((void *) d_addr, s_addr, d_pitch, s_pitch, height); mono_src_copy_imm_blit(&data); }
void step(HashTable* El_Table, HashTable* NodeTable, int myid, int nump, MatProps* matprops_ptr, TimeProps* timeprops_ptr, PileProps *pileprops_ptr, FluxProps *fluxprops, StatProps* statprops_ptr, int* order_flag, OutLine* outline_ptr, DISCHARGE* discharge, int adaptflag) { /* * PREDICTOR-CORRECTED based on Davis' Simplified Godunov Method */ /* pass off proc data here (really only need state_vars for off-proc neighbors) */ move_data(nump, myid, El_Table, NodeTable,timeprops_ptr); slopes(El_Table, NodeTable, matprops_ptr); // get coefficients, eigenvalues, hmax and calculate the time step double dt = get_coef_and_eigen(El_Table, NodeTable, matprops_ptr, fluxprops, timeprops_ptr,0); timeprops_ptr->incrtime(&dt); //also reduces dt if necessary // assign influxes and then if any new sources are activating in // current time step refine and re-mark cells adapt_fluxsrc_region(El_Table,NodeTable,matprops_ptr,pileprops_ptr,fluxprops, timeprops_ptr,dt,myid,adaptflag); int i; HashEntryPtr* buck = El_Table->getbucketptr(); HashEntryPtr currentPtr; Element* Curr_El; double dt2 = .5*dt; // dt2 is set as dt/2 ! // printf("dt for explicit is ...%f \n", dt); /* * predictor step */ int j,k, counter; double tiny = GEOFLOW_TINY,phi; double flux_src_coef=0; // printf("the number of elements are ...........%d\n", num_nonzero_elem(El_Table)); #ifdef SECOND_ORDER //-------------------go through all the elements of the subdomain and //-------------------calculate the state variables at time .5*delta_t /* mdj 2007-04 */ int IF_STOPPED; double curr_time,influx[3],*d_uvec,*lap_phi; //VxVy[2]; double VxVy[2]; Node* nd; #pragma omp parallel for \ private(currentPtr,Curr_El,IF_STOPPED,influx,j,k,curr_time,flux_src_coef,VxVy) for(i=0; i<El_Table->get_no_of_buckets(); i++) if(*(buck+i)) { currentPtr = *(buck+i); while(currentPtr){ Curr_El=(Element*)(currentPtr->value); influx[3]; influx[0]=*(Curr_El->get_influx()+0); influx[1]=*(Curr_El->get_influx()+1); influx[2]=*(Curr_El->get_influx()+2); if(!(influx[0]>=0.0)){ printf("negative influx=%g\n",influx[0]); assert(0); } if(Curr_El->get_adapted_flag()>0){ lap_phi=Curr_El->get_lap_phi(); d_uvec = Curr_El->get_d_state_vars(); nd = (Node*) NodeTable->lookup(Curr_El->pass_key()); // -- calc contribution of flux source flux_src_coef=0; curr_time=(timeprops_ptr->time)*(timeprops_ptr->TIME_SCALE); //VxVy[2]; if(*(Curr_El->get_state_vars())<0/*GEOFLOW_TINY*/) { VxVy[0]=*(Curr_El->get_state_vars()+2)/ *(Curr_El->get_state_vars()+1); VxVy[1]=*(Curr_El->get_state_vars()+3)/ *(Curr_El->get_state_vars()+1); } else VxVy[0]=VxVy[1]=0.0; #ifdef STOPCRIT_CHANGE_SOURCE IF_STOPPED=Curr_El->get_stoppedflags(); #else IF_STOPPED=!(!(Curr_El->get_stoppedflags())); #endif predict_(Curr_El->get_state_vars(), d_uvec, (d_uvec+NUM_STATE_VARS),lap_phi, Curr_El->get_prev_state_vars(), &tiny, Curr_El->get_kactxy(), &dt2, Curr_El->get_gravity(), Curr_El->get_curvature(), &(matprops_ptr->bedfrict[Curr_El->get_material()]), &(matprops_ptr->intfrict), Curr_El->get_d_gravity(), &(matprops_ptr->frict_tiny), order_flag, VxVy, &IF_STOPPED,influx); /* apply bc's */ #ifdef APPLY_BC for(j=0;j<4;j++) if(*(Curr_El->get_neigh_proc()+j) == INIT) // this is a boundary! for(k=1;k<NUM_STATE_VARS;k++) *(Curr_El->get_state_vars()+k) = 0; #endif } currentPtr=currentPtr->next; } } /* finished predictor step */ /* really only need to share dudx, state_vars, and kactxy */ move_data(nump, myid, El_Table, NodeTable,timeprops_ptr); /* calculate the slopes for the new (half-time step) state variables */ slopes(El_Table, NodeTable, matprops_ptr); #endif //SECOND_ORDER /* really only need to share dudx, state_vars, and kactxy */ move_data(nump, myid, El_Table, NodeTable,timeprops_ptr); /* calculate kact/pass */ double dt_not_used = get_coef_and_eigen(El_Table, NodeTable, matprops_ptr, fluxprops, timeprops_ptr, 1); /* * calculate edge states */ double outflow=0.0; //shouldn't need the =0.0 assignment but just being cautious. //printf("step: before calc_edge_states\n"); fflush(stdout); calc_edge_states(El_Table,NodeTable,matprops_ptr,timeprops_ptr,myid,order_flag,&outflow); //printf("the outflow in step after calc_edge ..............%f\n",outflow); outflow*=dt; //printf("the dt in step ...............%f\n",dt); //printf("the outflow in step ...............%f\n",outflow); MapNames mapnames; char *b,*c,*d; char a[5]="abs";// ,b[5],c[5],d[5]; b=c=d=a; int ce=0; mapnames.assign(a, b, c,d, ce); if (/*timeprops_ptr->iter%50==4||*/timeprops_ptr->iter==1){ int tt=timeprops_ptr->iter; //for(int ii=0;ii<1000;ii++){ initialization( NodeTable, El_Table, dt, matprops_ptr,fluxprops, timeprops_ptr); meshplotter(El_Table, NodeTable,matprops_ptr,timeprops_ptr,&mapnames,ce); //timeprops_ptr->iter++; //} //timeprops_ptr->iter=tt; } /* * corrector step and b.c.s */ //for comparison of magnitudes of forces in slumping piles double forceint=0.0, elemforceint; double forcebed=0.0, elemforcebed; double eroded=0.0, elemeroded; double deposited=0.0, elemdeposited; double realvolume=0.0; for(i=0; i<El_Table->get_no_of_buckets(); i++) if(*(buck+i)) { HashEntryPtr currentPtr = *(buck+i); while(currentPtr) { Element* Curr_El=(Element*)(currentPtr->value); if(Curr_El->get_adapted_flag()>0) { //if this is a refined element don't involve!!! double *dxy=Curr_El->get_dx(); // if calculations are first-order, predict is never called // ... so we need to update prev_states // double phi=*(Curr_El->get_state_vars())+*(Curr_El->get_state_vars()+4); if ( *order_flag == 1 ) Curr_El->update_prev_state_vars(); void *Curr_El_out= (void *) Curr_El; correct(NodeTable, El_Table, dt, matprops_ptr, fluxprops, timeprops_ptr, Curr_El_out, &elemforceint,&elemforcebed, &elemeroded,&elemdeposited); for(int kk=0;kk<6;kk++) if (isnan(*(Curr_El->get_state_vars()+kk))) printf("Hello this is the NAN"); forceint+=fabs(elemforceint); forcebed+=fabs(elemforcebed); realvolume+=dxy[0]*dxy[1]**(Curr_El->get_state_vars()+1); eroded+=elemeroded; deposited+=elemdeposited; double *coord=Curr_El->get_coord(); //update the record of maximum pileheight in the area covered by this element double hheight=*(Curr_El->get_state_vars()+1); if(hheight>0 && hheight<0); #ifdef MAX_DEPTH_MAP double pfheight[6]; outline_ptr->update(coord[0]-0.5*dxy[0],coord[0]+0.5*dxy[0], coord[1]-0.5*dxy[1],coord[1]+0.5*dxy[1], hheight,pfheight); #endif #ifdef APPLY_BC for(j=0;j<4;j++) if(*(Curr_El->get_neigh_proc()+j) == INIT) // this is a boundary! for(k=1;k<NUM_STATE_VARS;k++) *(Curr_El->get_state_vars()+k) = 0; #endif } currentPtr=currentPtr->next; } } // for(i=0; i<El_Table->get_no_of_buckets(); i++) { // if(*(buck+i)) // { // HashEntryPtr currentPtr = *(buck+i); // while(currentPtr) // { // Element* Curr_El=(Element*)(currentPtr->value); // if(Curr_El->get_adapted_flag()>0 // )//&& ((timeprops_ptr->iter%5==4)))//||(timeprops_ptr->iter%5==2))) // { //if this is a refined element don't involve!!! // //if (*(Curr_El->get_state_vars()+1)>1e-3) // //{ // phi = *(Curr_El->get_state_vars()); // if(phi>1) phi=1; // if(phi<0) phi=0; //} //else //phi=0; // *(Curr_El->get_state_vars())=phi; // Curr_El->update_phase1(phi); // } // currentPtr=currentPtr->next; // } // } // } //update the orientation of the "dryline" (divides partially wetted cells //into wet and dry parts solely based on which neighbors currently have //pileheight greater than GEOFLOW_TINY //for(i=0; i<El_Table->get_no_of_buckets(); i++) // { // HashEntryPtr currentPtr = *(buck+i); // while(currentPtr) // { // Element* Curr_El=(Element*)(currentPtr->value); // currentPtr=currentPtr->next; // if(Curr_El->get_adapted_flag()>0) //if this is a refined element don't involve!!! // Curr_El->calc_wet_dry_orient(El_Table); // } // } /* finished corrector step */ calc_stats(El_Table, NodeTable, myid, matprops_ptr, timeprops_ptr, statprops_ptr, discharge, dt); double tempin[6], tempout[6]; tempin[0]=outflow; //volume that flew out the boundaries this iteration tempin[1]=eroded; //volume that was eroded this iteration tempin[2]=deposited; //volume that is currently deposited tempin[3]=realvolume; //"actual" volume within boundaries tempin[4]=forceint; //internal friction force tempin[5]=forcebed; //bed friction force MPI_Reduce(tempin,tempout,6,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD); statprops_ptr->outflowvol+=tempout[0]*(matprops_ptr->HEIGHT_SCALE)* (matprops_ptr->LENGTH_SCALE)*(matprops_ptr->LENGTH_SCALE); statprops_ptr->erodedvol+=tempout[1]*(matprops_ptr->HEIGHT_SCALE)* (matprops_ptr->LENGTH_SCALE)*(matprops_ptr->LENGTH_SCALE); statprops_ptr->depositedvol=tempout[2]*(matprops_ptr->HEIGHT_SCALE)* (matprops_ptr->LENGTH_SCALE)*(matprops_ptr->LENGTH_SCALE); statprops_ptr->realvolume=tempout[3]*(matprops_ptr->HEIGHT_SCALE)* (matprops_ptr->LENGTH_SCALE)*(matprops_ptr->LENGTH_SCALE); statprops_ptr->forceint=tempout[4]/tempout[3]*matprops_ptr->GRAVITY_SCALE; statprops_ptr->forcebed=tempout[5]/tempout[3]*matprops_ptr->GRAVITY_SCALE; return; }
int pw_move_data(FILE *out, FILE *in, int len) { return move_data(out, in, len); }
int decrunch_oxm(FILE *f, FILE *fo) { int i, j, pos; int hlen, npat, len, plen; int nins, nsmp; uint32 ilen; uint8 buf[1024]; struct xm_instrument xi[256]; char *pcm[256]; int newlen = 0; fseek(f, 60, SEEK_SET); hlen = read32l(f); fseek(f, 6, SEEK_CUR); npat = read16l(f); nins = read16l(f); fseek(f, 60 + hlen, SEEK_SET); for (i = 0; i < npat; i++) { len = read32l(f); fseek(f, 3, SEEK_CUR); plen = read16l(f); fseek(f, len - 9 + plen, SEEK_CUR); } pos = ftell(f); fseek(f, 0, SEEK_SET); move_data(fo, f, pos); /* module header + patterns */ for (i = 0; i < nins; i++) { ilen = read32l(f); if (ilen > 1024) return -1; fseek(f, -4, SEEK_CUR); fread(buf, ilen, 1, f); /* instrument header */ buf[26] = 0; fwrite(buf, ilen, 1, fo); nsmp = readmem16l(buf + 27); if (nsmp == 0) continue; /* Read sample headers */ for (j = 0; j < nsmp; j++) { xi[j].len = read32l(f); fread(xi[j].buf, 1, 36, f); } /* Read samples */ for (j = 0; j < nsmp; j++) { if (xi[j].len > 0) { int res = 8; if (xi[j].buf[10] & 0x10) res = 16; pcm[j] = oggdec(f, xi[j].len, res, &newlen); xi[j].len = newlen; if (pcm[j] == NULL) return -1; } } /* Write sample headers */ for (j = 0; j < nsmp; j++) { write32l(fo, xi[j].len); fwrite(xi[j].buf, 1, 36, fo); } /* Write samples */ for (j = 0; j < nsmp; j++) { if (xi[j].len > 0) { fwrite(pcm[j], 1, xi[j].len, fo); free(pcm[j]); } } } return 0; }
void init_piles(HashTable* HT_Elem_Ptr, HashTable* HT_Node_Ptr, int myid, int numprocs, int adaptflag, MatProps* matprops, TimeProps* timeprops_ptr, MapNames* mapnames, PileProps* pileprops, FluxProps *fluxprops, StatProps* statprops) { unsigned nodes[9][KEYLENGTH], *node_key; int num_buckets=HT_Elem_Ptr->get_no_of_buckets(); if(!adaptflag) H_adapt_to_level(HT_Elem_Ptr,HT_Node_Ptr,matprops,pileprops, fluxprops,timeprops_ptr,REFINE_LEVEL); #if defined PARABALOID || defined CYLINDER if(adaptflag) initial_H_adapt(HT_Elem_Ptr, HT_Node_Ptr, 0, matprops, pileprops,fluxprops,timeprops_ptr,4); #else for(int ibucket=0; ibucket<num_buckets; ibucket++) { HashEntry *entryp = *(HT_Elem_Ptr->getbucketptr() + ibucket); //check every element in bucket while(entryp){ Element *EmTemp = (Element*)entryp->value; assert(EmTemp); if(EmTemp->get_adapted_flag()>0) { //put in the pile height right here... double* ndcoord = EmTemp->get_coord(); double pile_height=0.0; double radius_sq; EmTemp->put_height(pileheight); } entryp = entryp->next; } } #endif //end "#if defined PARABALOID || defined CYLINDER" move_data(numprocs, myid, HT_Elem_Ptr, HT_Node_Ptr,timeprops_ptr); slopes(HT_Elem_Ptr, HT_Node_Ptr, matprops); /* initial calculation of actual volume on the map */ double realvolume=0.0, depositedvol=0.0, forcebed=0.0, meanslope=0.0; double epsilon[2]={matprops->epsilon, matprops->epsilon}; HashEntryPtr* buck = HT_Elem_Ptr->getbucketptr(); for(int ibucket=0; ibucket<HT_Elem_Ptr->get_no_of_buckets(); ibucket++) if(*(buck+ibucket)) { HashEntryPtr currentPtr = *(buck+ibucket); while(currentPtr) { Element* Curr_El=(Element*)(currentPtr->value); assert(Curr_El); if(Curr_El->get_adapted_flag()>0) { //if this is a refined element don't involve!!! double *dxy=Curr_El->get_dx(); double dvol=dxy[0]*dxy[1]**(Curr_El->get_state_vars()+1); realvolume+=dvol; Curr_El->put_kactxy(epsilon); Curr_El->calc_stop_crit(matprops); if (Curr_El->get_stoppedflags()==2) depositedvol += dvol; double resolution=0, xslope=0, yslope=0; Get_max_resolution(&resolution); Get_slope(resolution, *((Curr_El->get_coord()))*matprops->LENGTH_SCALE, *((Curr_El->get_coord())+1)*matprops->LENGTH_SCALE, &xslope,&yslope); double slope=sqrt(xslope*xslope+yslope*yslope); forcebed+=dvol*9.8/sqrt(1.0+slope*slope)* tan(matprops->bedfrict[Curr_El->get_material()]); Curr_El->level_set(HT_Elem_Ptr); } currentPtr=currentPtr->next; } } //========================================================================================================================= for(int ibucket=0; ibucket<HT_Elem_Ptr->get_no_of_buckets(); ibucket++) if(*(buck+ibucket)) { HashEntryPtr currentPtr = *(buck+ibucket); while(currentPtr) { Element* Curr_El=(Element*)(currentPtr->value); assert(Curr_El); if(Curr_El->get_adapted_flag()>0) { if(*( Curr_El->get_state_vars()+5)==3) *(Curr_El->get_state_vars())=0.0;//to make zero phi on the boundary } currentPtr=currentPtr->next; } } double tempin[3], tempout[3]; tempin[0]=realvolume; tempin[1]=forcebed; tempin[2]=depositedvol; MPI_Reduce(tempin,tempout,3,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD); statprops->realvolume=tempout[0]*(matprops->HEIGHT_SCALE) *(matprops->LENGTH_SCALE)*(matprops->LENGTH_SCALE); statprops->outflowvol=0.0; statprops->erodedvol=0.0; statprops->depositedvol=tempout[2]*(matprops->HEIGHT_SCALE) *(matprops->LENGTH_SCALE)*(matprops->LENGTH_SCALE); statprops->forceint=0.0; statprops->forcebed=tempout[1]/tempout[0]; return; }
void cxxTitanSimulation::init_piles() { MatProps* matprops_ptr = get_matprops(); FluxProps* fluxprops_ptr = get_fluxprops(); TimeProps* timeprops_ptr = get_timeprops(); StatProps* statprops_ptr = get_statprops(); ElementsHashTable* HT_Elem_Ptr=get_HT_Elem(); NodeHashTable* HT_Node_Ptr=get_HT_Node(); PileProps* pileprops_ptr=get_pileprops(); unsigned nodes[9][KEYLENGTH], *node_key; int no_of_buckets = HT_Elem_Ptr->get_no_of_buckets(); vector<HashEntryLine> &bucket=HT_Elem_Ptr->bucket; tivector<Element> &elenode_=HT_Elem_Ptr->elenode_; PileProps::PileType pile_type= pileprops_ptr->get_default_piletype(); int i; bool allPilesAreElliptical=true; for(i=0;i<pileprops_ptr->numpiles;i++) { if(!(pileprops_ptr->pile_type[i] == PileProps::PARABALOID || pileprops_ptr->pile_type[i] == PileProps::CYLINDER)) allPilesAreElliptical=false; } if(pileprops_ptr->numpiles>0)pile_type= pileprops_ptr->pile_type[0]; if(!adapt) H_adapt_to_level(HT_Elem_Ptr, HT_Node_Ptr, matprops_ptr, pileprops_ptr, fluxprops_ptr, timeprops_ptr, REFINE_LEVEL); if(allPilesAreElliptical) { if(adapt) initial_H_adapt(HT_Elem_Ptr, HT_Node_Ptr, 0, matprops_ptr, pileprops_ptr, fluxprops_ptr, timeprops_ptr, 4); } else { printf("It seems this type of piles have hardcoded coordinates\n"); assert(0); //@ElementsBucketDoubleLoop for(int ibuck = 0; ibuck < no_of_buckets; ibuck++) { for(int ielm = 0; ielm < bucket[ibuck].ndx.size(); ielm++) { Element *EmTemp = &(elenode_[bucket[ibuck].ndx[ielm]]); if(EmTemp->adapted_flag() > 0) { //put in the pile height right here... double pile_height = 0.0; double radius_sq; switch (pile_type) { case PileProps::PLANE: radius_sq = pow(EmTemp->coord(0) - 76., 2) + pow(EmTemp->coord(1) - 80., 2); if(radius_sq < 35.) pile_height = 10 * (1. - radius_sq / 35.); break; case PileProps::CASITA: radius_sq = pow(EmTemp->coord(0) - 504600., 2) + pow(EmTemp->coord(1) - 1402320., 2); if(radius_sq < 30000.) pile_height = 15 * (1. - radius_sq / 30000.); break; case PileProps::POPO: //popo topo radius_sq = pow(EmTemp->coord(0) - 537758. / matprops_ptr->scale.length, 2) + pow(EmTemp->coord(1) - 2100910. / matprops_ptr->scale.length, 2); if(radius_sq < (10000. / matprops_ptr->scale.length)) pile_height = 1. - radius_sq / (10000. / matprops_ptr->scale.length); break; case PileProps::ID1: // iverson and denlinger experiments I -- as pictured if(EmTemp->coord(0) < 53.345 && EmTemp->coord(0) > 45.265 && EmTemp->coord(1) > -10. && EmTemp->coord(1) < 300.) { if(EmTemp->coord(0) < 51.148) pile_height = 3.5912 * (1.0 - (51.148 - EmTemp->coord(0)) / 5.8832); else pile_height = 3.59 * (53.345 - EmTemp->coord(0)) / 2.1967; if(pile_height < 0) pile_height = 0; } break; case PileProps::ID2: //iverson and denlinger experiments II -- 90 angle with plane if(EmTemp->coord(0) < 53.345 / matprops_ptr->scale.length && EmTemp->coord(0) > 46.45 / matprops_ptr->scale.length) pile_height = 4.207255 * (1.0 - (53.345 / matprops_ptr->scale.length - EmTemp->coord(0)) / 6.895 * matprops_ptr->scale.length); break; default: printf("Danger no recognized pile type defined in init_piles.C\n"); assert(0); } EmTemp->put_height(pile_height); } } } } //end "#if defined PARABALOID || defined CYLINDER" move_data(numprocs, myid, HT_Elem_Ptr, HT_Node_Ptr, timeprops_ptr); //update temporary arrays of elements/nodes pointers HT_Node_Ptr->flushNodeTable(); HT_Elem_Ptr->flushElemTable(); HT_Elem_Ptr->updateLocalElements(); HT_Elem_Ptr->updateNeighboursIndexes(); slopes(HT_Elem_Ptr, HT_Node_Ptr, matprops_ptr); /* initial calculation of actual volume on the map */ double realvolume = 0.0, depositedvol = 0.0, forcebed = 0.0, meanslope = 0.0; double epsilon[DIMENSION]; for(i=0;i<DIMENSION;i++) epsilon[i]=matprops_ptr->scale.epsilon; //@ElementsBucketDoubleLoop for(int ibuck = 0; ibuck < no_of_buckets; ibuck++) { for(int ielm = 0; ielm < bucket[ibuck].ndx.size(); ielm++) { Element* Curr_El = &(elenode_[bucket[ibuck].ndx[ielm]]); if(Curr_El->adapted_flag() > 0) { //if this is a refined element don't involve!!! double dvol = Curr_El->dx(0) * Curr_El->dx(1) * Curr_El->state_vars(0); realvolume += dvol; Curr_El->set_kactxy(epsilon); Curr_El->calc_stop_crit(matprops_ptr,integrator); if(Curr_El->stoppedflags() == 2) depositedvol += dvol; double resolution = 0, xslope = 0, yslope = 0; Get_max_resolution(&resolution); Get_slope(resolution, Curr_El->coord(0) * matprops_ptr->scale.length, Curr_El->coord(1) * matprops_ptr->scale.length, xslope, yslope); double slope = sqrt(xslope * xslope + yslope * yslope); forcebed += dvol * 9.8 / sqrt(1.0 + slope * slope) * tan(matprops_ptr->bedfrict[Curr_El->material()]); } } } double tempin[3], tempout[3]; tempin[0] = realvolume; tempin[1] = forcebed; tempin[2] = depositedvol; #ifdef USE_MPI MPI_Reduce(tempin, tempout, 3, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); #else //USE_MPI for(int i9=0;i9<3;++i9)tempout[i9]=tempin[i9]; #endif //USE_MPI statprops_ptr->realvolume = tempout[0] * (matprops_ptr->scale.height) * (matprops_ptr->scale.length) * (matprops_ptr->scale.length); statprops_ptr->outflowvol = 0.0; statprops_ptr->erodedvol = 0.0; statprops_ptr->depositedvol = tempout[2] * (matprops_ptr->scale.height) * (matprops_ptr->scale.length) * (matprops_ptr->scale.length); statprops_ptr->forceint = 0.0; statprops_ptr->forcebed = tempout[1] / tempout[0]; return; }
int main(int argc, char *argv[]) { int i, j, k;//-- counters HashTable* BT_Node_Ptr; HashTable* BT_Elem_Ptr; //-- MPI int myid, numprocs; MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD, &numprocs); MPI_Comm_rank(MPI_COMM_WORLD, &myid); #ifdef DEBUG if (myid==0){ int w; printf("type in a number: \n"); (void) scanf ("%d", &w); } // MPI_Barrier(MPI_COMM_WORLD); #endif /* create new MPI datastructures for class objects */ MPI_New_Datatype(); /* read original data from serial preprocessing code and then initialize element stiffness routines info */ double epsilon = 1., intfrictang = 1, bedfrictang = 1, gamma = 1; double frict_tiny = 0.1, mu = .0001, rho = 2200, porosity = 1; MatProps matprops(intfrictang, bedfrictang, porosity, mu, rho, epsilon, gamma, frict_tiny, (double) 1, (double) 1, (double) 1); int max_time_steps = 3000, numoutput = 1, adaptflag; double end_time = 10000.0; /* * viz_flag is used to determine which viz output to use * viz_flag%2 == 0 means output tecplotxxxx.plt * viz_flag%3 == 0 means output mshplotxxxx.plt * viz_flag%5 == 0 means output pady's stuff (viz_filenames.out and viz_outputxxx.plt) * viz_flag%7 == 0 means output hdf stuff (not implemented yet) */ int viz_flag = 0; int order_flag = 0; //order flag for time stepping scheme -- not used as of 6/19/03 Read_data(&BT_Node_Ptr, myid, &BT_Elem_Ptr, &matprops, &max_time_steps, &end_time, &numoutput, &adaptflag, &viz_flag, &order_flag); printf("bed friction angle is %e and internal friction angle is %e, epsilon is %e\n", (double) (matprops.bedfrict*180./PI), (double) (matprops.intfrict*180./PI), (double) (matprops.epsilon)); printf("METHOD ORDER %d \n",ORDER); double dummyt=-100.; double maxFluxIntegral=0; //overall maximum of the integral of the //flux on the element boundary int h_c=0; // H_adapt(BT_Elem_Ptr, BT_Node_Ptr, h_c, dummyt, &matprops); //H_adapt(BT_Elem_Ptr, BT_Node_Ptr, h_c, dummyt, &matprops); if(viz_flag%3==0) meshplotter(BT_Elem_Ptr, BT_Node_Ptr, 0,&matprops); /* cccccccccccccccccccccccccccccccccccccccccccccccccccccccccc cccccccccccccccccccccccccccccccccccccccccccccccccccccccccc Time Stepping Loop cccccccccccccccccccccccccccccccccccccccccccccccccccccccccc cccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */ int time_step = 0; double time = 0; while(time_step <= max_time_steps && time < end_time) { //if(myid ==0) // printf("doing time_step = %d and time is %e\n",time_step, // time*sqrt(matprops.LENGTH_SCALE/matprops.GRAVITY_SCALE)); /* * mesh adaption routines */ double TARGET = 0.005; double UNREFINE_TARGET=GEOFLOW_TINY; int h_count = 0; if (time_step < 0) matprops.frict_tiny=0.1; else if (time_step >= 0) matprops.frict_tiny=0.000001; if(adaptflag != 0) { if(time_step%4 == 0 ) { H_adapt(BT_Elem_Ptr, BT_Node_Ptr, h_count, TARGET, &matprops, &maxFluxIntegral); } else if(time_step%4 == 2 ) { unrefine(BT_Elem_Ptr, BT_Node_Ptr, UNREFINE_TARGET, myid, numprocs, time_step, &matprops); } //P_adapt(BT_Elem_Ptr, BT_Node_Ptr, TARGET); //CN if(viz_flag%3==0) //CN meshplotter(BT_Elem_Ptr, BT_Node_Ptr, time_step+1,&matprops); /* * mesh repartitioning routines */ if(time_step % 10 == 1 && numprocs > 1) { delete_ghost_elms(BT_Elem_Ptr, myid); repartition(BT_Elem_Ptr, BT_Node_Ptr, time_step); // move_data(numprocs, myid, BT_Elem_Ptr, BT_Node_Ptr); } } step(BT_Elem_Ptr, BT_Node_Ptr, myid, numprocs, end_time, &time, &matprops, time_step, &maxFluxIntegral,numoutput); // printf(" maxFluxIntegral %e in hpfem.C \n ",maxFluxIntegral); // exit(0); calc_volume(BT_Elem_Ptr, BT_Node_Ptr, myid, numprocs, &matprops); /* * output results to file */ if(time_step % numoutput == 0) { move_data(numprocs, myid, BT_Elem_Ptr, BT_Node_Ptr); if(viz_flag%3==0) meshplotter(BT_Elem_Ptr, BT_Node_Ptr, time_step+1,&matprops); } time_step++; } move_data(numprocs, myid, BT_Elem_Ptr, BT_Node_Ptr); if(viz_flag%3==0) meshplotter(BT_Elem_Ptr, BT_Node_Ptr, time_step+1,&matprops); printf("%d Finished -- Final simulation time %e\n",myid,time); MPI_Finalize(); return(0); }
static void i810_accel_putcs(struct vc_data *conp, struct display *p, const unsigned short *s, int count, int yy, int xx) { struct blit_data text; int depth, c, d_addr, s_pitch, d_pitch, f_width, cell; char *s_addr; void (*move_data)(void *dst, void *src, int dpitch, int spitch, int size); if (i810_accel->lockup || not_safe()) return; c = scr_readw(s); depth = (p->var.bits_per_pixel + 7) >> 3; switch (depth) { case 1: text.fg = (int) attr_fgcol(p,c); text.bg = (int) attr_bgcol(p,c); text.blit_bpp = BPP8; break; case 2: text.bg = (int) ((u16 *)p->dispsw_data)[attr_bgcol(p, c)]; text.fg = (int) ((u16 *)p->dispsw_data)[attr_fgcol(p, c)]; text.blit_bpp = BPP16; break; case 3: text.fg = ((int *) p->dispsw_data)[attr_fgcol(p, c)]; text.bg = ((int *) p->dispsw_data)[attr_bgcol(p, c)]; text.blit_bpp = BPP24; } f_width = (fontwidth(p) + 7) & ~7; switch (f_width) { case 8: move_data = i810fb_moveb; break; case 16: move_data = i810fb_movew; break; case 32: move_data = i810fb_movel; break; default: move_data = i810fb_move; break; } s_pitch = f_width >> 3; d_pitch = ((s_pitch * count) + 1) & ~1; text.dwidth = f_width * depth * count; text.dheight = fontheight(p); text.dpitch = p->next_line; text.dsize = ((d_pitch * text.dheight) + 7) & ~7; text.dsize >>= 2; text.rop = PAT_COPY_ROP; text.d_addr = (i810_accel->fb_offset << 12) + (yy * text.dheight * p->next_line) + (xx * f_width * depth); text.s_addr[0] = d_addr = i810_accel->text_buffer; cell = s_pitch * text.dheight; if (s_pitch == 1 && count > 3) { int i, d_addr0; char *s1, *s2, *s3, *s4; while (count > 3) { s1 = p->fontdata + (scr_readw(s++) & p->charmask) * cell; s2 = p->fontdata + (scr_readw(s++) & p->charmask) * cell; s3 = p->fontdata + (scr_readw(s++) & p->charmask) * cell; s4 = p->fontdata + (scr_readw(s++) & p->charmask) * cell; d_addr0 = d_addr; for (i = text.dheight; i--; ) { *(unsigned long *) d_addr0 = (unsigned long) ((*s1++ & 0xff) | (*s2++ & 0xff) << 8 | (*s3++ & 0xff) << 16 | (*s4++ & 0xff) << 24 ); d_addr0 += d_pitch; } d_addr += 4; count -= 4; } } while (count--) { c = scr_readw(s++) & p->charmask; s_addr = p->fontdata + (c * cell); move_data((void *) d_addr, s_addr, d_pitch, s_pitch, text.dheight); d_addr += s_pitch; } mono_src_copy_imm_blit(&text); }