//================================================================================================= void Terrain::Rebuild(bool smooth) { assert(state == 2); VTerrain* v; V(mesh->LockVertexBuffer(0, (void**)&v)); #define TRI(xx,zz) v[n++].pos.y = h[x+xx+(z+zz)*hszer] uint n = 0; for(uint z = 0; z < n_tiles; ++z) { for(uint x = 0; x < n_tiles; ++x) { TRI(0, 0); TRI(0, 1); TRI(1, 0); CalculateNormal(v[n - 3], v[n - 2], v[n - 1]); TRI(0, 1); TRI(1, 1); TRI(1, 0); CalculateNormal(v[n - 3], v[n - 2], v[n - 1]); } } #undef TRI if(smooth) SmoothNormals(v); V(mesh->UnlockVertexBuffer()); }
//================================================================================================= void Terrain::RebuildUv() { assert(state == 2); VTerrain* v; V(mesh->LockVertexBuffer(0, (void**)&v)); #define TRI(uu,vv) v[n++].tex = Vec2(float(uu)/uv_mod, float(vv)/uv_mod) uint n = 0; for(uint z = 0; z < n_tiles; ++z) { for(uint x = 0; x < n_tiles; ++x) { int u1 = (x%uv_mod); int u2 = ((x + 1) % uv_mod); if(u2 == 0) u2 = uv_mod; int v1 = (z%uv_mod); int v2 = ((z + 1) % uv_mod); if(v2 == 0) v2 = uv_mod; TRI(u1, v1); TRI(u1, v2); TRI(u2, v1); TRI(u1, v2); TRI(u2, v2); TRI(u2, v1); } } #undef TRI V(mesh->UnlockVertexBuffer()); }
//================================================================================================= void Terrain::Build(bool smooth) { assert(state == 1); HRESULT hr = D3DXCreateMeshFVF(n_tris, n_verts, D3DXMESH_MANAGED | D3DXMESH_32BIT, VTerrain::fvf, device, &mesh); if(FAILED(hr)) throw Format("Failed to create new terrain mesh (%d)!", hr); VTerrain* v; //word* idx; uint* idx; uint n = 0; //uint index = 0; V(mesh->LockVertexBuffer(0, (void**)&v)); V(mesh->LockIndexBuffer(0, (void**)&idx)); #define TRI(xx,zz,uu,vv) v[n++] = VTerrain((x+xx)*tile_size, h[x+xx+(z+zz)*hszer], (z+zz)*tile_size, float(uu)/uv_mod, float(vv)/uv_mod,\ ((float)(x+xx)) / n_tiles, ((float)(z+zz)) / n_tiles) for(uint z = 0; z < n_tiles; ++z) { for(uint x = 0; x < n_tiles; ++x) { int u1 = (x%uv_mod); int u2 = ((x + 1) % uv_mod); if(u2 == 0) u2 = uv_mod; int v1 = (z%uv_mod); int v2 = ((z + 1) % uv_mod); if(v2 == 0) v2 = uv_mod; TRI(0, 0, u1, v1); TRI(0, 1, u1, v2); TRI(1, 0, u2, v1); CalculateNormal(v[n - 3], v[n - 2], v[n - 1]); TRI(0, 1, u1, v2); TRI(1, 1, u2, v2); TRI(1, 0, u2, v1); CalculateNormal(v[n - 3], v[n - 2], v[n - 1]); } } #undef TRI for(uint z = 0; z < n_parts; ++z) { for(uint x = 0; x < n_parts; ++x) { const uint z_start = z*tiles_per_part, z_end = z_start + tiles_per_part, x_start = x*tiles_per_part, x_end = x_start + tiles_per_part; for(uint zz = z_start; zz < z_end; ++zz) { for(uint xx = x_start; xx < x_end; ++xx) { for(uint j = 0; j < 6; ++j) { *idx = (xx + zz*n_tiles) * 6 + j; ++idx; } } } } } V(mesh->UnlockIndexBuffer()); state = 2; if(smooth) SmoothNormals(v); V(mesh->UnlockVertexBuffer()); }
void Assemble_bubble(int tot_dof, int subdof, int Bb, int bb, double u[], int* ix, HashTable* El_Table, HashTable* NodeTable, int myid) /* first a dof chain is created for each element of the subdomain the contribution of each element is added to the sub_stiffness matrix*/ { int i,j,k; /*char filename[14] = "ChanOutxx.dat"; filename[7] = 48 + myid/10; filename[8] = 48 + myid%10; ofstream eout; eout.open(filename, ios::out); */ // printf("in assemble_bubble %d\n", myid); MPI_Barrier(MPI_COMM_WORLD); //-------------------go through all the elements of the subdomain------------------------ //-------------------and create an element to subdomain mapping-------------------------- 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) { Element* Curr_El=(Element*)(currentPtr->value); if(!(Curr_El->get_refined_flag()))//if this is a refined element don't involve!!! { int ndof = Curr_El->get_no_of_dof(); double* el_stiff = new double[ndof*ndof]; double* el_load = new double[ndof]; int* ix_el = new int[ndof]; //elm to subdof mapping int ix_counter = 0; for(j=0; j<8; j++) { Node* NodePtr=(Node*) (NodeTable->lookup(Curr_El->getNode()+KEYLENGTH*j)); if((NodePtr->getinfo()==CORNER)||(NodePtr->getinfo()==SIDE)||(NodePtr->getinfo()==BUBBLE)) { for(k=*(NodePtr->getdof()); k<*((NodePtr->getdof())+1)+1; k++) { ix_el[ix_counter] = k; ix_counter++; } } else if(NodePtr->getinfo()==S_C_CON && j<4) { Element* fatter=(Element*)El_Table->lookup(Curr_El->getfather()); Node* TargetNode=(Node*)(NodeTable->lookup(fatter->getNode()+j*KEYLENGTH));//see notebook //looking up the appropriate corner node of the father //both of them have to have 1*EQUATIONS associated for(int k=*(TargetNode->getdof()); k<*((TargetNode->getdof())+1)+1; k++) { ix_el[ix_counter] = k; ix_counter++; } } else if(NodePtr->getinfo()==S_C_CON && j>3)//if it is an S_C_CON but it is a big element { for(int k=*(NodePtr->getdof()); k<*((NodePtr->getdof())+1)+1; k++) { ix_el[ix_counter] = k; ix_counter++; } } else if(NodePtr->getinfo()==S_S_CON)//the side nodes of the constrained element is added to the constarined node { Node* TargetNode=(Node*)(NodeTable->lookup(Curr_El->getNode()+(j-4)*KEYLENGTH));//see note if(TargetNode->getinfo()!=S_C_CON) if(j!=7) TargetNode=(Node*)(NodeTable->lookup(Curr_El->getNode()+(j-3)*KEYLENGTH)); else TargetNode=(Node*)(NodeTable->lookup(Curr_El->getNode())); for(int k=*(TargetNode->getdof()); k<*((TargetNode->getdof())+1)+1; k++) { ix_el[ix_counter] = k; ix_counter++; } } } Node* NodePtr=(Node*) (NodeTable->lookup(Curr_El->pass_key())); for(int k=*(NodePtr->getdof()); k<*((NodePtr->getdof())+1)+1; k++) { ix_el[ix_counter] = k; ix_counter++; } //element to subdomain stiffness matrix mapping done //----assemble the sub_domain stiffness------- int count1=0; int count2=0; //--get the element stiffness and rhs Curr_El->get_stiffness(NodeTable, El_Table, el_stiff, el_load, Curr_El); int int_dof = (Curr_El->get_order()) - 1; int_dof = int_dof*int_dof*2; //# of bubble functions if(int_dof < 0) int_dof = 0; for(k=0;k<ndof-int_dof;k++) for(j=ndof-int_dof;j<ndof;j++) *(el_load+j) -= *(el_stiff+k*ndof+j) * *(u+ix[ix_el[k]]); double* int_el_stiff = new double[int_dof*int_dof]; for(j=0;j<int_dof;j++) for(k=0;k<int_dof;k++) *(int_el_stiff+j*int_dof+k) = *(el_stiff+(j+ndof-int_dof)*ndof+k+ndof-int_dof); if(int_dof > 0) { #ifdef SUNOS tri_(int_el_stiff,&int_dof, &int_dof); #endif #ifdef IBMSP tri(int_el_stiff,&int_dof, &int_dof); #endif #ifdef CRAY TRI(int_el_stiff,&int_dof, &int_dof); #endif } delete []el_stiff; double* u_bubble = new double[int_dof]; if(int_dof > 0) { #ifdef SUNOS //printf("rhsub ndof %d int_dof %d i %d proc %d \n",ndof, int_dof, i, myid); //cout<<*(currentPtr->key)<<" "<<*(currentPtr->key+1)<<endl<<flush; rhsub_(int_el_stiff, (el_load+ndof-int_dof),&int_dof, &int_dof, u_bubble); // printf("done rhsub %d \n",myid); #endif #ifdef IBMSP rhsub(int_el_stiff, (el_load+ndof-int_dof),&int_dof, &int_dof, u_bubble); #endif #ifdef CRAY RHSUB(int_el_stiff, (el_load+ndof-int_dof),&int_dof, &int_dof, u_bubble); #endif } for(j=0;j<int_dof;j++) //insert u_bubble into global solution { u[ix[ix_el[ndof-int_dof+j]]] = *(u_bubble+j); } delete []u_bubble; delete []el_load; delete []ix_el; } currentPtr=currentPtr->next; } } // printf("done with assemble_bubble\n"); }
void IndexTable::Calculate (int sides) { IndexBuffer *buf = &buffers[sides]; buf->Init (sizeof(index_t)*MAX_INDICES); index_t *begin = (index_t*)buf->LockData (), *i = begin; int ystart = 0, xstart = 0; int yend = QUAD_W, xend = QUAD_W; if (sides & left_bit) xstart++; if (sides & right_bit) xend--; if (sides & up_bit) ystart++; if (sides & down_bit) yend--; if (sides & up_bit) { for (int x=xstart;x<QUAD_W;x++) { if (x&1) { TRI(x-1, x+1, VERTC+x); if (x<xend) TRI(x+1, VERTC+x+1, VERTC+x); } else { TRI(x, VERTC+x+1, VERTC+x); } } } for (int y=ystart;y<QUAD_W;y++) { if (sides & left_bit) { if (y&1) { TRI(VRT(0,y-1),VRT(1,y),VRT(0,y+1)); if (y<yend) TRI(VRT(1,y),VRT(1,y+1),VRT(0,y+1)); } else { TRI(VRT(0,y),VRT(1,y),VRT(1,y+1)); } } if (y>=ystart && y<yend) { for (int x=xstart;x<xend;x++) { TRI(y*VERTC+x, y*VERTC+x+1, (y+1)*VERTC+x+1); TRI(y*VERTC+x, (y+1)*VERTC+x+1, (y+1)*VERTC+x); } } if (sides & right_bit) { int x=QUAD_W-1; if (y&1) { TRI(VRT(x+1,y-1),VRT(x+1,y+1),VRT(x,y)); if(y<yend) TRI(VRT(x,y),VRT(x+1,y+1),VRT(x,y+1)); } else { TRI(VRT(x,y),VRT(x+1,y),VRT(x,y+1)); } } } if (sides & down_bit) { int y=QUAD_W-1; for (int x=xstart;x<QUAD_W;x++) { if (x&1) { TRI(VRT(x,y),VRT(x+1,y+1),VRT(x-1,y+1)); if (x<xend) TRI(VRT(x,y),VRT(x+1,y),VRT(x+1,y+1)); } else { TRI(VRT(x,y),VRT(x+1,y),VRT(x,y+1)); } } } size[sides]=i-begin; assert (size[sides]<=MAX_INDICES); buf->UnlockData (); }
DYA(OP_GCD, "GCD") MON(OP_TRUNC, "IP") DYA(OP_LCM, "LCM") NILIC(OP_LOAD, "LOAD") DYA(OP_MOD41, "MOD") NILIC(OP_NEXTPRIME, "NEXTP") NILIC(OP_XisPRIME, "PRIME?") DYA(OP_MOD, "RMDR") NILIC(OP_SAVE, "SAVE") NILIC(OP_STKSIZE, "SSIZE?") NILIC(OP_VERSION, "VERS") MON(OP_DOWK, "WDAY") NILIC(OP_WHO, "WHO") DYA(OP_XROOT, "\234\003y") DYA(OP_DTDIF, "\203DAYS") TRI(OP_PERMRR, "MRR") MON(OP_PERCNT, "%") DYA(OP_PARAL, "||") MON(OP_CUBERT, "[^3][sqrt]") NILIC(OP_2FRAC, "DECOMP") #ifdef ENABLE_REGISTER_BROWSER NILIC(OP_SHOWREGS, "CATREG") #endif }; static s_opcode stats_catalogue[] = { DYA(OP_PERM, "PERM") DYA(OP_COMB, "COMB") NILIC(OP_statSErr, "SERR") NILIC(OP_RCLSIGMA, "SUM") NILIC(OP_statWMEAN, "\001w")