void NV10EXAComposite(PixmapPtr pix_dst, int srcX, int srcY, int maskX, int maskY, int dstX, int dstY, int width, int height) { ScrnInfoPtr pScrn = xf86Screens[pix_dst->drawable.pScreen->myNum]; NVPtr pNv = NVPTR(pScrn); struct nouveau_channel *chan = pNv->chan; struct nouveau_grobj *celsius = pNv->Nv3D; PicturePtr mask = pNv->pmpict, src = pNv->pspict; PictVector dstq[4] = QUAD(dstX, dstY, width, height), maskq[4] = QUAD(maskX, maskY, width, height), srcq[4] = QUAD(srcX, srcY, width, height); MAP(transform_vertex, src->transform, srcq); if (mask) MAP(transform_vertex, mask->transform, maskq); WAIT_RING (chan, 64); BEGIN_RING(chan, celsius, NV10TCL_VERTEX_BEGIN_END, 1); OUT_RING (chan, NV10TCL_VERTEX_BEGIN_END_QUADS); MAP(emit_vertex, pNv, dstq, srcq, mask ? maskq : NULL); BEGIN_RING(chan, celsius, NV10TCL_VERTEX_BEGIN_END, 1); OUT_RING (chan, NV10TCL_VERTEX_BEGIN_END_STOP); }
void ParentProcess(void) { int a, b, c, d; int abcd, a4b4c4d4; int count = 0; char buf[BUF_SIZE]; sprintf(buf, "Parent is about to compute the Armstrong numbers\n"); write(1, buf, strlen(buf)); for (a = 0; a <= 9; a++) for (b = 0; b <= 9; b++) for (c = 0; c <= 9; c++) for (d = 0; d <= 9; d++) { abcd = a*1000 + b*100 + c*10 + d; a4b4c4d4 = QUAD(a) + QUAD(b) + QUAD(c) + QUAD(d); if (abcd == a4b4c4d4) { sprintf(buf, "From parent: " "the %d Armstrong number is %d\n", ++count, abcd); write(1, buf, strlen(buf)); } } sprintf(buf, "From parent: there are %d Armstrong numbers\n", count); write(1, buf, strlen(buf)); }
Float Hyperboloid::Area() const { return phiMax / 6.f * (2 * QUAD(p1.x) - 2 * p1.x * p1.x * p1.x * p2.x + 2 * QUAD(p2.x) + 2 * (p1.y * p1.y + p1.y * p2.y + p2.y * p2.y) * (SQR(p1.y - p2.y) + SQR(p1.z - p2.z)) + p2.x * p2.x * (5 * p1.y * p1.y + 2 * p1.y * p2.y - 4 * p2.y * p2.y + 2 * SQR(p1.z - p2.z)) + p1.x * p1.x * (-4 * p1.y * p1.y + 2 * p1.y * p2.y + 5 * p2.y * p2.y + 2 * SQR(p1.z - p2.z)) - 2 * p1.x * p2.x * (p2.x * p2.x - p1.y * p1.y + 5 * p1.y * p2.y - p2.y * p2.y - p1.z * p1.z + 2 * p1.z * p2.z - p2.z * p2.z)); }
double get_integral(double a, double b, int l, int m, int fun){ double get_int,t,t_min,t_max,dt,tmp,sum,e,de; int i, n; n=10000; if (1 == 1) { /*low precision*/ de = (b - a)/(double)n; sum = 0.5*(function(l,m,a,fun)+function(l,m,b,fun)); for (i=1; i <= (n-1); i++) { e = a + de*(double)i; sum = sum + function(l,m,e,fun); } get_int = sum*de; //printf(" \n get_int = %14.10e", get_int); } else { //higher precision t_min = 0.; t_max = sqrt(b - a); dt = (t_max - t_min)/(double)n; tmp = t_max*function(l,m,b,fun); sum = 0.5*tmp; for (i=1; i <= (n-1); i++) { t = t_min + dt*(double)i; e = a + QUAD(t); sum = sum +t*function(l,m,e,fun); } get_int = sum*dt; } return get_int; }
void OutMacroParameters::OutPressure(void) { char file_name[50]; sprintf(file_name, "data/output/gas %i/pressure%i.txt", gas_index, number_of_file); file_pressure = fopen(file_name, "w"); //file_temperature = fopen("temperature.txt", "w"); double n; double u_x, u_y, u_z; double pressure; double local_max_pressure = 0.0f; double local_min_pressure = 1000.0f; int sym_size_x, sym_size_y; int sym_x, sym_y; switch( Grid_->FLAG_USE_SYMMETRY ) { case NO_SYMMETRY: sym_size_x = Grid_->size_x-1; sym_size_y = Grid_->size_y-1; break; case QUARTER_SYMMETRY: sym_size_x = Grid_->size_x/2.0f; sym_size_y = Grid_->size_y/2.0f; break; } for(int y=0; y<Grid_->size_y; y++) { for(int x=0; x<Grid_->size_x; x++) { if( !Cells[x][y] || Cells[x][y]->type == 9 ) { fprintf(file_pressure, "%i %i %f\n", x, y, 0.0f); } else { sym_x = x; sym_y = y; if( Grid_->FLAG_USE_SYMMETRY == QUARTER_SYMMETRY ) { if( x > (sym_size_x-1) ) { sym_x = Grid_->size_x-1-x; } if( y > (sym_size_y-1) ) { sym_y = Grid_->size_y-1-y; } } n = 0.0f; u_x = 0.0f; u_y = 0.0f; u_z = 0.0f; pressure = 0.0f; for(int i=0; i<MainInfo_->speed_quantity; i++) { for(int j=0; j<MainInfo_->speed_quantity; j++) { for(int k=0; k<MainInfo_->speed_quantity; k++) { if( Cells[sym_x][sym_y]->GetP(i,j,k) > MainInfo_->p_cut && MainInfo_->FLAG_use_cut_sphere ) { // do nothing } else { n += Cells[sym_x][sym_y]->real_SPEED_CUBE[i][j][k]; u_x += Cells[sym_x][sym_y]->real_SPEED_CUBE[i][j][k]* Cells[sym_x][sym_y]->GetP(i)/Cells[sym_x][sym_y]->GetMolMass(); u_y += Cells[sym_x][sym_y]->real_SPEED_CUBE[i][j][k]* Cells[sym_x][sym_y]->GetP(j)/Cells[sym_x][sym_y]->GetMolMass(); u_z += Cells[sym_x][sym_y]->real_SPEED_CUBE[i][j][k]* Cells[sym_x][sym_y]->GetP(k)/Cells[sym_x][sym_y]->GetMolMass(); } } } } u_x /= n; u_y /= n; u_z /= n; for(int i=0; i<MainInfo_->speed_quantity; i++) { for(int j=0; j<MainInfo_->speed_quantity; j++) { for(int k=0; k<MainInfo_->speed_quantity; k++) { if( Cells[sym_x][sym_y]->GetP(i,j,k) > MainInfo_->p_cut && MainInfo_->FLAG_use_cut_sphere ) { // do nothing } else { pressure += Cells[sym_x][sym_y]->GetMolMass() * ( QUAD(Cells[sym_x][sym_y]->GetP(i)/Cells[sym_x][sym_y]->GetMolMass()-u_x)+ QUAD(Cells[sym_x][sym_y]->GetP(j)/Cells[sym_x][sym_y]->GetMolMass()-u_y)+ QUAD(Cells[sym_x][sym_y]->GetP(k)/Cells[sym_x][sym_y]->GetMolMass()-u_z) )* Cells[sym_x][sym_y]->real_SPEED_CUBE[i][j][k]; } } } } pressure; // ����������� pressure /= 3; fprintf(file_pressure, "%i %i %f\n", x, y, pressure); if(pressure > local_max_pressure) local_max_pressure = pressure; if(pressure < local_min_pressure) local_min_pressure = pressure; } } } if(local_max_pressure > max_pressure) max_pressure = local_max_pressure; if(local_min_pressure < min_pressure) min_pressure = local_min_pressure; fclose(file_pressure); return; }
void OutMacroParameters::StreamOut(void) { char file_name[50]; sprintf(file_name, "data/output/gas %i/stream_of_heap%i.txt", gas_index, number_of_file); file_stream_of_heap = fopen(file_name, "w"); //file_stream_of_heap = fopen("stream_of_heap.txt", "w"); double u_x; double u_y; double q_x; double q_y; double mod_gas_velocity; for(int y=0; y<Grid_->size_y; y++) { for(int x=0; x<Grid_->size_x; x++) { if( !Cells[x][y] || Cells[x][y]->type == 9 ) { fprintf(file_stream_of_heap, "%i %i %f %f\n", x, y, 100.0f, 100.0f); } else { u_x = 0.0f; u_y = 0.0f; for(int i=0; i<MainInfo_->speed_quantity; i++) { for(int j=0; j<MainInfo_->speed_quantity; j++) { for(int k=0; k<MainInfo_->speed_quantity; k++) { if( Cells[x][y]->GetP(i,j,k) > MainInfo_->p_cut && MainInfo_->FLAG_use_cut_sphere ) { // do nothing } else { u_x += Cells[x][y]->real_SPEED_CUBE[i][j][k]* Cells[x][y]->GetP(i)/Cells[x][y]->GetMolMass()*CUBE(MainInfo_->delta_p/Cells[x][y]->GetMolMass()); u_y += Cells[x][y]->real_SPEED_CUBE[i][j][k]* Cells[x][y]->GetP(j)/Cells[x][y]->GetMolMass()*CUBE(MainInfo_->delta_p/Cells[x][y]->GetMolMass()); } } } } q_x = 0.0f; q_y = 0.0f; for(int i=0; i<MainInfo_->speed_quantity; i++) { for(int j=0; j<MainInfo_->speed_quantity; j++) { for(int k=0; k<MainInfo_->speed_quantity; k++) { if( Cells[x][y]->GetP(i,j,k) > MainInfo_->p_cut && MainInfo_->FLAG_use_cut_sphere ) { // do nothing } else { q_x += Cells[x][y]->GetP(i)/Cells[x][y]->GetMolMass()*QUAD(Cells[x][y]->GetP(i)/Cells[x][y]->GetMolMass()-u_x)* Cells[x][y]->real_SPEED_CUBE[i][j][k]*MainInfo_->delta_p/Cells[x][y]->GetMolMass(); q_y += Cells[x][y]->GetP(j)/Cells[x][y]->GetMolMass()*QUAD(Cells[x][y]->GetP(j)/Cells[x][y]->GetMolMass()-u_y)* Cells[x][y]->real_SPEED_CUBE[i][j][k]*MainInfo_->delta_p/Cells[x][y]->GetMolMass(); } } } } //q_x *= Cells[x][y]->GetMolMass() / 2.0f; //q_y *= Cells[x][y]->GetMolMass() / 2.0f; mod_gas_velocity = sqrt( q_x*q_x + q_y*q_y ); if( mod_gas_velocity > max_mod_gas_velocity ) max_mod_gas_velocity = mod_gas_velocity; if( mod_gas_velocity < min_mod_gas_velocity ) min_mod_gas_velocity = mod_gas_velocity; fprintf(file_stream_of_heap, "%i %i %f %f\n", x, y, q_x, q_y); } } } fclose(file_stream_of_heap); return; }
static const MyVertex vertexData[] = { { {-1, -1, -1}, {HALF_NEG_1, HALF_NEG_1, HALF_NEG_1, HALF_POS_1}, 0xFFFFFF }, { {-1, -1, 1}, {HALF_NEG_1, HALF_NEG_1, HALF_POS_1, HALF_POS_1}, 0xFFFF00 }, { {-1, 1, -1}, {HALF_NEG_1, HALF_POS_1, HALF_NEG_1, HALF_POS_1}, 0xFF00FF }, { {-1, 1, 1}, {HALF_NEG_1, HALF_POS_1, HALF_POS_1, HALF_POS_1}, 0xFF0000 }, { { 1, -1, -1}, {HALF_POS_1, HALF_NEG_1, HALF_NEG_1, HALF_POS_1}, 0x00FFFF }, { { 1, -1, 1}, {HALF_POS_1, HALF_NEG_1, HALF_POS_1, HALF_POS_1}, 0x00FF00 }, { { 1, 1, -1}, {HALF_POS_1, HALF_POS_1, HALF_NEG_1, HALF_POS_1}, 0x0000FF }, { { 1, 1, 1}, {HALF_POS_1, HALF_POS_1, HALF_POS_1, HALF_POS_1}, 0x000000 }, }; #define QUAD(a,b,c,d) a, b, d, d, c, a static const uint16 indexData[] = { QUAD(0,1,2,3), // -X QUAD(4,5,6,7), // +X QUAD(0,1,4,5), // -Y QUAD(2,3,6,7), // +Y QUAD(0,2,4,6), // -Z QUAD(1,3,5,7), // +Z }; #undef QUAD const uint32 numTriangles = sizeof indexData / sizeof indexData[0] / 3; uint32 vertexSid, indexSid; Matrix perspectiveMat; FPSCounterState gFPS;
bool EdgeCondition::SetEdgeArea( EDGE_AREA* area, int num ) { double u_x = 0; double u_y = 0; double consumption = 0; int x, y; double C = 0.0f; double k; //if( num == 1 || num == 3 ) // k = 6.0f / CUBE( area->size ) * edgecondition_areas[num]->start_consumption; //else k = 6.0f / CUBE( area->size ) * edgecondition_areas[num]->consumption; double p_slash; // �������� ���������� ������������� for( int l=0; l<area->size; l++ ) { x = area->coord.x; y = area->coord.y; switch ( area->orientation ) { case EDGE_AREA::HORISONTAL: x += l; break; case EDGE_AREA::VERTICAL: y += l; break; } if( !Cells[x][y] || Cells[x][y]->type == 9 ) { printf("Error of consuption area\n"); return false; } else { C = 0.0f; // count C p_slash = -k*l*(l-area->size-1)*Cells[x][y]->GetMolMass(); // ��� ����� (�����) p_slash /= Cells[x][y]->n; for(int i=0; i<MainInfo_->speed_quantity; i++) { for(int j=0; j<MainInfo_->speed_quantity; j++) { for(int k=0; k<MainInfo_->speed_quantity; k++) { C += exp((-1.0f)* ( QUAD( Cells[x][y]->GetP(i) - p_slash ) + QUAD( Cells[x][y]->GetP(j) ) + QUAD( Cells[x][y]->GetP(k) ) ) / (2.0f*Cells[x][y]->GetMolMass()*Cells[x][y]->T_start)); } } } /* n0 = 1.0 */ C = 1.0f / C; u_x = 0; u_y = 0; for(int i=0; i<MainInfo_->speed_quantity; i++) { for(int j=0; j<MainInfo_->speed_quantity; j++) { for(int k=0; k<MainInfo_->speed_quantity; k++) { if( ( Cells[x][y]->GetP(i,j,k) > MainInfo_->p_cut ) && MainInfo_->FLAG_use_cut_sphere ) { // do nothing } else { Cells[x][y]->real_SPEED_CUBE[i][j][k] = Cells[x][y]->n * C * exp((-1.0f)* ( QUAD( Cells[x][y]->GetP(i) - p_slash ) + QUAD( Cells[x][y]->GetP(j) ) + QUAD( Cells[x][y]->GetP(k) ) ) / (2.0f*Cells[x][y]->GetMolMass()*Cells[x][y]->T_start)); u_x += Cells[x][y]->real_SPEED_CUBE[i][j][k]* Cells[x][y]->GetP(i)/Cells[x][y]->GetMolMass(); u_y += Cells[x][y]->real_SPEED_CUBE[i][j][k]* Cells[x][y]->GetP(j)/Cells[x][y]->GetMolMass(); } } } } switch ( area->orientation ) { case EDGE_AREA::HORISONTAL: consumption += u_y; break; case EDGE_AREA::VERTICAL: consumption += u_x; break; } } } //// �������� //printf("\rcons_check = %f cons = %f delta = %f", // edgecondition_areas[num]->consumption, consumption, // edgecondition_areas[num]->consumption - consumption ); return true; }