static void update_bdry_wall(np_t *np, gl_t *gl, long lA, long lB, long lC, long theta, long thetasgn, bool ADIABATIC, bool BDRYDIRECFOUND, int ACCURACY){ spec_t wwall; double Twall,Pwall; long dim,spec; dim_t Vwall; bool ref_flag; if (ADIABATIC) { Twall=_f_symmetry(ACCURACY,_T(np[lB],gl),_T(np[lC],gl)); } else { Twall=_T(np[lA],gl); } /* clip Twall so that it remains within the user-specified bounds */ Twall=max(gl->model.fluid.Twmin,min(gl->model.fluid.Twmax,Twall)); for (dim=0; dim<nd; dim++){ Vwall[dim]=0.0e0; } for (spec=0; spec<ns; spec++){ wwall[spec]=_f_symmetry(ACCURACY,_w(np[lB],spec),_w(np[lC],spec)); } reformat_w(gl,wwall,"_bdry",&ref_flag); find_Pstar_bdry_wall(np, gl, lA, lB, lC, theta, thetasgn, BDRYDIRECFOUND, ACCURACY, &Pwall); find_U_2(np, lA,gl,wwall,Vwall,Pwall,Twall); }
//! Function called to init the container. Sets the sizes, and the memory storage order void _init() { _w = coord_type(); _w(0) = value_dimensions; for (uint64 i = 1; i < coord_dimensions; i++) { _w(i) = _w(i-1)*_sizes(i-1); } uint64 N = _sizes.prod(); if (_owner) _data = new value_data_type[N*value_dimensions](); }
void test1() { long double x = operator"" _v(1.2L); assert(x == 2.2L); std::string s = operator"" _w(u"one", 3); assert(s == "boo"); unsigned u = operator"" _w("Hello, World!"); assert(u == 13U); std::complex<double> i = operator"" _i(2.0); assert(i == std::complex<double>(0.0, 2.0)); }
void find_post_variable_value_fluid(np_t *np, long l, gl_t *gl, long varnum, double *varvalue){ spec_t w,nu; double eta,kappa; *varvalue=0.0; if (is_node_valid(np[l],TYPELEVEL_FLUID)){ if (varnum<ns) *varvalue=_w(np[l],varnum); if (varnum>=ns && varnum<ns+nd) *varvalue=_V(np[l],varnum-ns); //assert(is_node_resumed(np[l])); find_w(np[l],w); find_nuk_eta_kappa(w, _rho(np[l]), _T(np[l],gl), nu, &eta, &kappa); switch (varnum) { case nd+ns+0: *varvalue=_rho(np[l]); break; case nd+ns+1: *varvalue=_P(np[l],gl); break; case nd+ns+2: *varvalue=_Pstar(np[l],gl); break; case nd+ns+3: *varvalue=_T(np[l],gl); break; case nd+ns+4: *varvalue=_Tv(np[l]); break; case nd+ns+5: *varvalue=_a(np[l],gl); break; case nd+ns+6: *varvalue=_eta(np[l],gl); break; case nd+ns+7: *varvalue=_etastar(np,l,gl); break; case nd+ns+8: *varvalue=_kappastar(np,l,gl); break; case nd+ns+9: *varvalue=_k(np[l]); break; case nd+ns+10: *varvalue=_eps(np[l],gl); break; case nd+ns+11: *varvalue=_omega(np[l],gl); break; case nd+ns+12: *varvalue=_gamma(np[l],gl); break; } } }
double _Tstag(np_t np, gl_t *gl){ double hstag,Tstag; spec_t w; find_w(np,w); hstag=np.bs->U[fluxet]/_rho(np)-_k(np)-_w(np,specN2)*_ev(np)+_P(np,gl)/_rho(np); Tstag=_T_from_w_h(w, hstag); return(Tstag); }
static void update_bdry_freestream(np_t *np, gl_t *gl, long lA, long lB, long lC, long theta, long thetasgn, bool BDRYDIRECFOUND, int ACCURACY){ dim_t V; long spec; double T,P; spec_t w; bool OUTFLOW, FREESTREAM; find_V_P_T_bdry_freestream(np, gl, lA, lB, lC, theta, thetasgn, ACCURACY, V, &P, &T, &OUTFLOW, &FREESTREAM); if (OUTFLOW){ for (spec=0; spec<ns; spec++) w[spec]=_w(np[lB],spec); } else { for (spec=0; spec<ns; spec++) w[spec]=_w(np[lA],spec); } find_U_2(np, lA, gl, w, V, P, T); }
Camera::Camera(const Vector3f &pOr, const Vector3f &pAt, const float &distance, int l, int h) : _origine(pOr), _lu(l), _lv(h), _lw(distance) { Eigen::Vector3f tmp(pAt - pOr); _w = tmp.normalized(); if(_w == Vector3f(0,0,1) || _w == Vector3f(0,0,-1)) { _u = Vector3f(_w(2),0,0); _v = Vector3f(0,_w(2),0); } else { _u = - ( _w.cross(Vector3f(0,0,1)) ); _u.normalize(); _v = _w.cross(_u); _v.normalize(); } }
static void update_bdry_outflow(np_t *np, gl_t *gl, long lA, long lB, long lC, long theta, long thetasgn, bool BDRYDIRECFOUND, int ACCURACY){ double P,T; spec_t w; dim_t V; long spec,dim; bool ref_flag; assert_np(np[lA],is_node_resumed(np[lA])); P=_f_extrapol(ACCURACY,_P(np[lB],gl),_P(np[lC],gl)); T=_f_extrapol(ACCURACY,_T(np[lB],gl),_T(np[lC],gl)); for (spec=0; spec<ns; spec++){ w[spec]=_f_extrapol(ACCURACY,_w(np[lB],spec),_w(np[lC],spec)); } for (dim=0; dim<nd; dim++){ V[dim]=_f_extrapol(ACCURACY,_V(np[lB],dim),_V(np[lC],dim)); } reformat_w(gl,w,"_bdry",&ref_flag); find_U_2(np, lA, gl, w, V, P, T); }
static void update_bdry_inflow(np_t *np, gl_t *gl, long lA, long lB, long lC, long theta, long thetasgn, bool BDRYDIRECFOUND){ double P,T; spec_t w; dim_t V; long spec,dim; assert_np(np[lA],is_node_resumed(np[lA])); P=_P(np[lA],gl); T=_T(np[lA],gl); for (spec=0; spec<ns; spec++) w[spec]=_w(np[lA],spec); for (dim=0; dim<nd; dim++) V[dim]=_V(np[lA],dim); find_U_2(np, lA, gl, w, V, P, T); }
/** * This constructor does most of the work. * The overall strategy is to create a box of the * required size which is centered at the origin, with * the width along the x axis * the length along the y axis * the height along the z axis * Then create the transformation from real space * into this box, which is: * a translation from center to the origin, then * a rotation from the oriented box frame to this frame */ OrientedBoxMarker::OrientedBoxMarker(const std::string & name, InputParameters parameters) : Marker(name, parameters), /* * Create the box centered at the origin */ _xmax(0.5*getParam<Real>("width")), _ymax(0.5*getParam<Real>("length")), _zmax(0.5*getParam<Real>("height")), _bottom_left(-_xmax, -_ymax, -_zmax), _top_right(_xmax, _ymax, _zmax), _bounding_box(_bottom_left, _top_right), /* * Create the translation, which is just center */ _center(getParam<Point>("center")), _w(getParam<RealVectorValue>("width_direction")), _l(getParam<RealVectorValue>("length_direction")), _inside((MarkerValue)(int)parameters.get<MooseEnum>("inside")), _outside((MarkerValue)(int)parameters.get<MooseEnum>("outside")) { /* * now create the rotation matrix that rotates the oriented * box's width direction to "x", its length direction to "y" * and its height direction to "z" */ Real len; /* * Normalise the width and length directions in readiness for * insertion into the rotation matrix */ len = std::pow(_w*_w, 0.5); if (len == 0) mooseError("Length of width_direction vector is zero in OrientedBoxMarker"); _w /= len; len = std::pow(_l*_l, 0.5); if (len == 0) mooseError("Length of length_direction vector is zero in OrientedBoxMarker"); _l /= len; if (_w*_l > 1E-10) mooseError("width_direction and length_direction are not perpendicular in OrientedBoxMarker"); RealVectorValue h(_w(1)*_l(2)-_w(2)*_l(1), _w(2)*_l(0)-_w(0)*_l(2), _w(0)*_l(1)-_w(1)*_l(0)); // h=w cross l /* * The rotation matrix! */ _rot_matrix(0, 0) = _w(0); _rot_matrix(0, 1) = _w(1); _rot_matrix(0, 2) = _w(2); _rot_matrix(1, 0) = _l(0); _rot_matrix(1, 1) = _l(1); _rot_matrix(1, 2) = _l(2); _rot_matrix(2, 0) = h(0); _rot_matrix(2, 1) = h(1); _rot_matrix(2, 2) = h(2); }
void bus_test() { u4_t i, a, a2, d, d2, dr, dw, c, m, m2; volatile u4_t v; //#define TEST_BUS #ifdef TEST_BUS a = d = 0; while (1) { a++; if ((a&0x3fff)==0) d++; //v = GPIO_IN(0); //_r(0); _w(a&0x7f, a&0xff); //printf("0x%02x\n", bus_read(RREG_A16_SWITCHES)); #if 0 bus_write(0x70, 0xff); bus_write(0x71, 0xf0); //bus_read(0x70); //bus_write(0x71, 0xff); //bus_write(0x71, 0xf0); #endif #if 0 printf("delay delay delay delay "); //bus_write(0x00a0, 0x00); //bus_read(0x0000); //bus_read(0x0001); //bus_read(0x0002); //bus_read(0x0003); #endif #if 0 bus_write(0x00a0, 0x55); bus_write(0x0001, 0x01); bus_write(0x0002, 0x02); bus_write(0x0003, 0x03); bus_write(0x0003, 0x84); bus_read(0x0000); #endif } #if 0 // test for this in the bus_read() routine and select read method int direct_cmp = 1; u4_t t0, t1; a = 0x7d00; direct_cmp = 0; t0 = bus_read(0x00); direct_cmp = 1; t1 = bus_read(0x00); printf("test bus read @0x%02x 0x%08x 0x%08x\n", a, t0, t1); a = 0x7d01; direct_cmp = 0; t0 = bus_read(0x00); direct_cmp = 1; t1 = bus_read(0x00); printf("test bus read @0x%02x 0x%08x 0x%08x\n", a, t0, t1); a = 0x7d02; direct_cmp = 0; t0 = bus_read(0x00); direct_cmp = 1; t1 = bus_read(0x00); printf("test bus read @0x%02x 0x%08x 0x%08x\n", a, t0, t1); a = 0x7d03; direct_cmp = 0; t0 = bus_read(0x00); direct_cmp = 1; t1 = bus_read(0x00); printf("test bus read @0x%02x 0x%08x 0x%08x\n", a, t0, t1); //bus_write(0xa0, 0x03); xit(0); #endif #if 0 for (i=0; i<100000000; i++) { //printf("."); fflush(stdout); bus_write(0x00a0, 0x00); bus_read(0x00a0); #if 0 bus_write(0x00a0, 0x00); bus_write(0x00a1, 0x01); bus_write(0x00a2, 0x02); bus_write(0x00a3, 0x03); bus_write(0x00a3, 0x84); #endif } #endif //w(0x80, 0x55); //w(0x10, 0); //r(0x80); //r(0x80); //r(0x80); //r(0x80); //r(0x60); //w(0x10, 0x1); //w(0x10, 0x0); xit(0); #endif //#define TEST_HPIB #ifdef TEST_HPIB int i; for (i=0; i<100000000; i++) { bus_read(0x02); bus_write(0x02, 0x00); bus_write(0x02, 0xff); bus_write(0x02, 0x00); bus_write(0x02, 0xff); } xit(0); #endif //#define HI_PHK #ifdef HI_PHK { int i, j; u1_t k; #define H 0x20|0x02|0x40|0x10|0x04 #define I 0x20|0x10 #define P 0x20|0x10|0x01|0x02|0x40 #define O 0x01|0x02|0x04|0x08|0x10|0x20 #define U 0x02|0x04|0x08|0x10|0x20 #define L 0x08|0x10|0x20 #define E 0x01|0x08|0x10|0x20|0x40 #define N 0x01|0x02|0x04|0x10|0x20 #define G 0x01|0x04|0x08|0x10|0x20 #define DASH 0x40 #define PERIOD 0x80 bus_write(0x70, H); bus_write(0x71, I); bus_write(0x72, P); bus_write(0x73, O); bus_write(0x74, U); bus_write(0x75, L); bus_write(0x76, DASH); bus_write(0x77, H); bus_write(0x78, E); bus_write(0x79, N); bus_write(0x7a, N); bus_write(0x7b, I); bus_write(0x7c, N); bus_write(0x7d, G); bus_write(0x7e, PERIOD); bus_write(0x7f, PERIOD); xit(0); for (j = 0; j < 1000000; j++) { bus_write(0x7f, 1 << (j&0x7)); usleep(100000); } xit(0); } #endif //#define TEST_DISPLAY #ifdef TEST_DISPLAY printf("test display..\n"); { int i, j; i = 0; #if 0 do { printf("x"); fflush(stdout); bus_write(0x66, 0x01); bus_write(0x67, 0x00); usleep(1000000); printf("."); fflush(stdout); bus_write(0x66, 0x00); bus_write(0x67, 0x00); usleep(1000000); } while (1); #endif #if 0 do { delay(1000); bus_write(0x69, 0x08); delay(1000); bus_write(0x69, 0x00); } while (1); #endif #if 1 do { delay(100); #if 1 for (j = 0; j < 16; j++) { bus_write(0x70 + j, 1 << (i&0x7)); } #endif for (j = 0; j < 16; j++) { bus_write(0x60 + j, (i&1)? 0xf:0); } i++; } while (1); #endif xit(0); } #endif #define TEST_KEYS #ifdef TEST_KEYS printf("test keys..\n"); { int i, j, col; u1_t k; i = 0; col = 0; do { k = bus_read(RREG_KEY_SCAN); if (((k&0xf) != 0xf)) { //{ printf("%02x ", k); fflush(stdout); //printf("%02x-%02x ", bus_read(RREG_A16_SWITCHES), k); col += 3; if (col > 100) { printf("\n"); col = 0; } } delay(100); #if 1 for (j = 0; j < 16; j++) { bus_write(0x70 + j, 1 << (i&0x7)); } #endif #if 1 for (j = 0; j < 16; j++) { bus_write(0x60 + j, (i&1)? 0xf:0); } i++; #endif } while (1); xit(0); } #endif //#define TEST_RAM_CLK10 #ifdef TEST_RAM_CLK10 { int i; #if 0 w(0x80, 0x00); for (i = 0; i < 0x100; i++) { // w(0x80, (i & 1)? 0xff:0); r(0x80); r(0x80); r(0x80); r(0x80); sleep(1); } #else w(0x80, 0x00); for (i = 0; i < 0xfffffff; i++) { d = bus_read(0x80) & 0xff; if ((d&1) != 0) { printf("%x ", d); fflush(stdout); } } #endif xit(0); } #endif //#define TEST_ROM #ifdef TEST_ROM //for (a = 0x6000; a < 0x6004; a++) { r(0x6000); r(0x6001); r(0xfffe); r(0xffff); //w(0x6000, 0xff); xit(0); #endif //#define TEST_RAM #ifdef TEST_RAM a2 = 0x200; m = 0x00; for (a = 0x80; a < a2; a++) { bus_write(a, a & 0xff); } { u1_t dsave[0x200]; for (a = 0x80; a < a2; a++) { dsave[a] = bus_read(a); } for (a = 0x80; a < a2; a++) { c = a & 0xff; if ((dsave[a]|m) != (c|m)) { printf("@0x%x 0x%x != %x\n", a, c|m, dsave[a]|m); } } } //#define CHECK_BACKWARDS #ifdef CHECK_BACKWARDS for (a = a2-1; a >= 0x80; a--) { d = bus_read(a); c = a & 0xff; if ((d|m) != (c|m)) printf("@0x%x 0x%x != %x\n", a, c|m, d|m); } #endif #endif //#define TEST_RAM2 #ifdef TEST_RAM2 for (a = 0x80; a <= 0x1ff; a++) { bus_write(a, a); } for (a = 0x80; a < 0x1ff; a++) { d = bus_read(a); if (d != a) printf("@0x%x != %x\n", a, d); } #endif xit(0); }
int main(int argc, char * argv[]) { boost::thread_group worker_group; std::vector<boost::exception_ptr> index_errors; CmdLineOptions user_options; boost::shared_ptr<BoundedQueue<std::string>> FilesToIndex( new BoundedQueue<std::string>(MAX_QUEUE_FILES) ); try { /* get exceptions from threads launched or FileIndexer_exception */ get_CmdLineOptions(argc,argv,std::move(user_options)); /* Launch search thread */ boost::exception_ptr search_error; boost::thread searchWorker(searchPath, user_options, FilesToIndex, boost::ref(search_error)); /* Launch worker threads */ bool exception_thrown = false; int i; for (i = 0; ((i < user_options.N) && !exception_thrown); ++i) { boost::exception_ptr index_error; FileWorker _w(i, user_options.debug); try { worker_group.create_thread(boost::bind(&FileWorker::run, &_w, FilesToIndex, boost::ref(index_error))); } catch (boost::thread_resource_error const& e) { exception_thrown = true; std::cout << "Couldn't launch as many threads as requested: " << e.what() << std::endl; std::cout << "Continuing with " << i << " threads\n"; // don't push index_error continue; } catch (std::exception const& e) { std::cout << "Thread " << i << " thew exception: " << e.what() << std::endl; // need to tear down because we dont know what caused this cleanupWorkers(std::move(worker_group),std::move(index_errors)); return EXIT_ERROR; } index_errors.push_back(index_error); } /* Wait for workers to drain FilesToIndex */ searchWorker.join(); if( search_error ) boost::rethrow_exception(search_error); if (user_options.debug > 1) std::cout << "search worker has joined" << std::endl; cleanupWorkers(std::move(worker_group),std::move(index_errors)); if (user_options.debug > 1) std::cout << "index workers have all joined" << std::endl; /* print the resulting main index */ /* all done */ } /* --- main try block --- */ catch(const recursive_directory_iterator_error &e) { // std::cout << std::endl // << e.what() << std::endl; cleanupWorkers(std::move(worker_group),std::move(index_errors)); return EXIT_ERROR; } catch(std::exception const& e) { std::cout << std::endl << e.what() << std::endl; cleanupWorkers(std::move(worker_group),std::move(index_errors)); return EXIT_ERROR; } /* --- main catch block -- */ return EXIT_SUCCESS; } /* --- int main() --- */