bool slider::touch(int x, int y, touch_action action) { system * sys = get_system(); math::vec2 pos = global_position(); if((pos.x < x && x < pos.x + get_size().x && (pos.y < y && y < pos.y + get_size().y))) { if(action == touch_action::DOWN) { sys->capture(this); return true; } } if(sys->capture_test(this)) { if(action == touch_action::UP) { sys->capture_release(); } else if(action == touch_action::MOVE) { const float value = (math::clamp(x, pos.x, pos.x + get_size().x) - pos.x) / get_size().x; model_->set_value(value); } return true; } return false; }
string getInfo() { ostringstream info; info << "ArrayFire v" << AF_VERSION << AF_VERSION_MINOR << " (CPU, " << get_system() << ", build " << REVISION << ")" << std::endl; return info.str(); }
string getDeviceInfo() { const CPUInfo cinfo = DeviceManager::getInstance().getCPUInfo(); ostringstream info; info << "ArrayFire v" << AF_VERSION << " (CPU, " << get_system() << ", build " << AF_REVISION << ")" << endl; string model = cinfo.model(); size_t memMB = getDeviceMemorySize(getActiveDeviceId()) / 1048576; info << string("[0] ") << cinfo.vendor() << ": " << ltrim(model); if (memMB) info << ", " << memMB << " MB, "; else info << ", Unknown MB, "; info << "Max threads(" << cinfo.threads() << ") "; #ifndef NDEBUG info << AF_COMPILER_STR; #endif info << endl; return info.str(); }
cl_ulong physics::fermionmatrix::D_KS_eo::get_flops() const { const hardware::System& system = get_system(); auto devices = system.get_devices(); auto fermion_code = devices[0]->getFermionStaggeredCode(); return fermion_code->get_flop_size("D_KS_eo"); }
/* * configure_system: * - first load and parse configuration file * - load system configuration with config file data * - then load option variables if present (override configuration variables on file) */ void configure_system(const psOSCdSystem *temp) { psOSCdSystem *sys = get_system(); sys->configuration_filename = temp->configuration_filename; load_configuration_from_file(sys); override_with_command_line_options(sys, temp); }
cl_ulong physics::fermionmatrix::MdagM_eo::get_flops() const { const hardware::System& system = get_system(); auto devices = system.get_devices(); auto spinor_code = devices[0]->getSpinorStaggeredCode(); auto fermion_code = devices[0]->getFermionStaggeredCode(); cl_ulong res; res = 2 * fermion_code->get_flop_size("D_KS_eo"); res += spinor_code->get_flop_size("saxpby_cplx_staggered_eoprec"); return res; }
cowlist get_list () { char * list = get_system ("cowsay -l"); size_t i = 0; int len = 0; int slen = 0; char ** ret; char * buf; cowlist res; ret = (char **) malloc (50 * sizeof (char *)); buf = (char *) malloc (512 * sizeof (char)); while (list[++i] != '\n'); while (++i < strlen (list)) { if (list[i] == '\n' || list[i] == ' ') { if ((len + 1) % 50) ret = (char **) realloc (ret, (len + 50 + 1) * sizeof (char *)); buf[slen++] = '\0'; buf = (char *) realloc (buf, slen * sizeof (char)); ret[len++] = buf; buf = (char *) malloc (512 * sizeof (char)); slen = 0; } else { if ((slen + 1) % 50) buf = (char *) realloc (buf, (slen + 512 + 1) * sizeof (char *)); buf[slen++] = list[i]; } } if ((len + 1) % 50) ret = (char **) realloc (ret, (len + 50 + 1) * sizeof (char *)); buf[slen] = '\0'; buf = (char *) realloc (buf, strlen (buf) * sizeof (char)); ret[len++] = buf; res.cowfile = ret; res.size = len; return res; }
void show_list () { char * list = get_system ("cowsay -l"); size_t i = 0; while (list[++i] != '\n'); while (++i < strlen (list)) putchar (list[i]); puts (""); exit (0); }
void slider::draw_tracker(const math::vec2 & pos, float value) { EPS_STATE_PROGRAM(program_slider_tracker_.get_product()); program_slider_tracker_.uniform_value(utils::to_int(program_enum::u_transform), get_system()->transform()); program_slider_tracker_.uniform_value(utils::to_int(program_enum::u_color), color_tracker_); float offset = get_size().y * 0.8f; math::vec2 tracker(pos.x + (get_size().x - offset) * value, pos.y + (get_size().y - offset) * 0.5f); GLfloat vertices[] = { (tracker.x), (tracker.y), 0.0f, 1.0f, (tracker.x + offset), (tracker.y), 1.0f, 1.0f, (tracker.x + offset), (tracker.y + offset), 1.0f, 0.0f, (tracker.x), (tracker.y + offset), 0.0f, 0.0f }; square_.construct(vertices); square_.render(program_slider_tracker_, utils::to_int(program_enum::a_vertex_xy), utils::to_int(program_enum::a_vertex_uv)); }
void slider::draw_slider_end(const math::vec2 & pos, float value) { EPS_STATE_PROGRAM(program_slider_.get_product()); program_slider_.uniform_value(utils::to_int(program_enum::u_transform), get_system()->transform()); program_slider_.uniform_value(utils::to_int(program_enum::u_color), color_slider_); float offset_y = get_size().y * 0.45f; float offset_x = get_size().x * value; GLfloat vertices[] = { (pos.x + offset_x), (pos.y + offset_y), 0.0f, 1.0f, (pos.x + get_size().x), (pos.y + offset_y), 1.0f, 1.0f, (pos.x + get_size().x), (pos.y + get_size().y - offset_y), 1.0f, 0.0f, (pos.x + offset_x), (pos.y + get_size().y - offset_y), 0.0f, 0.0f }; square_.construct(vertices); square_.render(program_slider_, utils::to_int(program_enum::a_vertex_xy), utils::to_int(program_enum::a_vertex_uv)); }
gint get_next_group(FILE *fp, struct model_pak *model, gint *have_basis) { gchar *line, *keyword; gint ret; GSList *keywords = NULL, *list; line = file_read_line(fp); if (!line) return(FALSE); /* TODO not a valid keyword so for the moment skip but could store */ if (g_ascii_strncasecmp(line, " $", 2) != 0) return(TRUE); if (g_ascii_strncasecmp(line, " $data", 6) == 0) { ret = get_data(fp, model, *have_basis); } else if (g_ascii_strncasecmp(line, " $basis", 7) == 0) { *have_basis = TRUE; keywords = get_gamess_keywords(fp, line+7, &ret); for (list=keywords ; list ; list=g_slist_next(list)) { keyword = (gchar *) list->data; ret = get_basis(keyword, model); } } else if (g_ascii_strncasecmp(line, " $contrl", 8) == 0) { keywords = get_gamess_keywords(fp, line+8, &ret); for (list=keywords; list ; list=g_slist_next(list)) { keyword = (gchar *) list->data; ret = get_control(keyword, model); } } else if (g_ascii_strncasecmp(line, " $system", 8) == 0) { keywords = get_gamess_keywords(fp, line+8, &ret); for (list=keywords; list ; list=g_slist_next(list)) { keyword = (gchar *) list->data; ret = get_system(keyword, model); } } else if (g_ascii_strncasecmp(line, " $statpt", 8) == 0) { keywords = get_gamess_keywords(fp, line+8, &ret); for (list=keywords; list ; list=g_slist_next(list)) { keyword = (gchar *) list->data; ret = get_statpt(keyword, model); } } else if (g_ascii_strncasecmp(line, " $dft", 5) == 0) { model->gamess.dft = TRUE; /* TODO - process functional */ } else { /* TODO - Unknown keyword, just pass through */ } free_slist(keywords); g_free(line); return(TRUE); }
void DGFEMContext::neighbor_side_fe_reinit () { // Call this *after* side_fe_reinit // Initialize all the neighbor side FE objects based on inverse mapping // the quadrature points on the current side std::vector<Point> qface_side_points; std::vector<Point> qface_neighbor_points; std::map<FEType, FEAbstract *>::iterator local_fe_end = _neighbor_side_fe.end(); for (std::map<FEType, FEAbstract *>::iterator i = _neighbor_side_fe.begin(); i != local_fe_end; ++i) { FEType neighbor_side_fe_type = i->first; FEAbstract* side_fe = _side_fe[neighbor_side_fe_type]; qface_side_points = side_fe->get_xyz(); FEInterface::inverse_map (dim, neighbor_side_fe_type, &get_neighbor(), qface_side_points, qface_neighbor_points); i->second->reinit(&get_neighbor(), &qface_neighbor_points); } // Set boolean flag to indicate that the DG terms are active on this element _dg_terms_active = true; // Also, initialize data required for DG assembly on the current side, // analogously to FEMContext::pre_fe_reinit // Initialize the per-element data for elem. get_system().get_dof_map().dof_indices (&get_neighbor(), _neighbor_dof_indices); const unsigned int n_dofs = dof_indices.size(); const unsigned int n_neighbor_dofs = libmesh_cast_int<unsigned int> (_neighbor_dof_indices.size()); // These resize calls also zero out the residual and jacobian _neighbor_residual.resize(n_neighbor_dofs); _elem_elem_jacobian.resize(n_dofs, n_dofs); _elem_neighbor_jacobian.resize(n_dofs, n_neighbor_dofs); _neighbor_elem_jacobian.resize(n_neighbor_dofs, n_dofs); _neighbor_neighbor_jacobian.resize(n_neighbor_dofs, n_neighbor_dofs); // Initialize the per-variable data for elem. { unsigned int sub_dofs = 0; for (unsigned int i=0; i != get_system().n_vars(); ++i) { get_system().get_dof_map().dof_indices (&get_neighbor(), _neighbor_dof_indices_var[i], i); const unsigned int n_dofs_var = libmesh_cast_int<unsigned int> (_neighbor_dof_indices_var[i].size()); _neighbor_subresiduals[i]->reposition (sub_dofs, n_dofs_var); for (unsigned int j=0; j != i; ++j) { const unsigned int n_dofs_var_j = libmesh_cast_int<unsigned int> (dof_indices_var[j].size()); _elem_elem_subjacobians[i][j]->reposition (sub_dofs, _neighbor_subresiduals[j]->i_off(), n_dofs_var, n_dofs_var_j); _elem_elem_subjacobians[j][i]->reposition (_neighbor_subresiduals[j]->i_off(), sub_dofs, n_dofs_var_j, n_dofs_var); _elem_neighbor_subjacobians[i][j]->reposition (sub_dofs, _neighbor_subresiduals[j]->i_off(), n_dofs_var, n_dofs_var_j); _elem_neighbor_subjacobians[j][i]->reposition (_neighbor_subresiduals[j]->i_off(), sub_dofs, n_dofs_var_j, n_dofs_var); _neighbor_elem_subjacobians[i][j]->reposition (sub_dofs, _neighbor_subresiduals[j]->i_off(), n_dofs_var, n_dofs_var_j); _neighbor_elem_subjacobians[j][i]->reposition (_neighbor_subresiduals[j]->i_off(), sub_dofs, n_dofs_var_j, n_dofs_var); _neighbor_neighbor_subjacobians[i][j]->reposition (sub_dofs, _neighbor_subresiduals[j]->i_off(), n_dofs_var, n_dofs_var_j); _neighbor_neighbor_subjacobians[j][i]->reposition (_neighbor_subresiduals[j]->i_off(), sub_dofs, n_dofs_var_j, n_dofs_var); } _elem_elem_subjacobians[i][i]->reposition (sub_dofs, sub_dofs, n_dofs_var, n_dofs_var); _elem_neighbor_subjacobians[i][i]->reposition (sub_dofs, sub_dofs, n_dofs_var, n_dofs_var); _neighbor_elem_subjacobians[i][i]->reposition (sub_dofs, sub_dofs, n_dofs_var, n_dofs_var); _neighbor_neighbor_subjacobians[i][i]->reposition (sub_dofs, sub_dofs, n_dofs_var, n_dofs_var); sub_dofs += n_dofs_var; } libmesh_assert_equal_to (sub_dofs, n_dofs); } }
void SourceDisk::get_lightrays_(trace::Result &result, const Element &target) const { const Surface *starget = dynamic_cast<const Surface*>(&target); if (!starget) return; double rlen = result.get_params().get_lost_ray_length(); const trace::Distribution &d = result.get_params().get_distribution(*starget); // i is point on target surface auto de = [&]( const math::Vector3 &i ) { //math::Vector3 r_ = starget->get_transform_to(*this).transform(i); // pattern point on target surface if (i[0] < _limit1[0] || i[0] > _limit2[0] || i[1] < _limit1[1] || i[1] > _limit2[1]) { return; } math::Vector3 direction; math::Vector3 position; switch (mode) { case (SourceAtFiniteDistance): //position = math::vector3_0; //direction = r_.normalized(); break; case (SourceAtInfinity): // std::cout << direction << " " << i << std::endl; // exit(-1); // for (double xi = -_size.x()/2.0; xi < _size.x()/2.0; xi+=_size.x()/10) { // for (double yi = -_size.y()/2.0; yi < _size.y()/2.0; yi+=_size.y()/10) { for (auto&l : this->_spectrum) { trace::Ray &r = result.new_ray(); math::Vector3 z(0,0,10000); math::Vector3 v(0,0,1); // r.direction() = math::Vector3(0, 0, 1).normalize(); r.direction() = math::Vector3(0, 0, 1).normalize(); //_direction;//_direction.normalized();//_direction.normalized(); r.origin() = i - r.direction() * 1.0; //(r_ - _direction.normalized() * 100.0); r.set_creator(this); r.set_intensity(l.get_intensity()); // FIXME depends on distance from source and pattern density r.set_wavelen(l.get_wavelen()); r.set_material(_mat.valid() ? _mat.ptr() : &get_system()->get_environment_proxy()); // } // } } break; } }; starget->get_pattern(de, d, result.get_params().get_unobstructed()); }