void UpdateSolution::link_fields() { if( is_null( m_solution ) ) { m_solution = Handle<Field>( follow_link( solver().field_manager() .get_child( sdm::Tags::solution() ) ) ); options().configure_option( sdm::Tags::solution(), m_solution->uri() ); } if( is_null( m_update_coeff ) ) { m_update_coeff = Handle<Field>( follow_link( solver().field_manager() .get_child( sdm::Tags::update_coeff() ) ) ); options().configure_option( sdm::Tags::update_coeff(), m_update_coeff->uri() ); } if( is_null( m_residual ) ) { m_residual = Handle<Field>( follow_link( solver().field_manager() .get_child( sdm::Tags::residual() ) ) ); options().configure_option( sdm::Tags::residual(), m_residual->uri() ); } if( is_null( m_jacobian_determinant ) ) { m_jacobian_determinant = follow_link(solver().field_manager() .get_child( sdm::Tags::jacob_det() ))->handle<Field>(); options().configure_option( sdm::Tags::jacob_det(), m_jacobian_determinant->uri() ); } }
void ComputeUpdateCoefficient::link_fields() { if( is_null( m_update_coeff ) ) { m_update_coeff = Handle<Field>( follow_link( solver().field_manager().get_child( sdm::Tags::update_coeff() ) ) ); options().set( sdm::Tags::update_coeff(), m_update_coeff ); } if( is_null( m_wave_speed ) ) { m_wave_speed = Handle<Field>( follow_link( solver().field_manager().get_child( sdm::Tags::wave_speed() ) ) ); options().set( sdm::Tags::wave_speed(), m_wave_speed ); } }
void BoundaryTerm::link_fields() { if( is_null( m_solution ) ) m_solution = follow_link( solver().handle<RDM::RDSolver>()->fields() .get_child( RDM::Tags::solution() ))->handle<Field>(); if( is_null( m_wave_speed ) ) m_wave_speed = follow_link( solver().handle<RDM::RDSolver>()->fields() .get_child( RDM::Tags::wave_speed() ))->handle<Field>(); if( is_null( m_residual ) ) m_residual = follow_link( solver().handle<RDM::RDSolver>()->fields() .get_child( RDM::Tags::residual() ))->handle<Field>(); }
static gint popup_button_press_event(GtkWidget *widget, GdkEventButton *event) { RESULT *rp; GtkTextIter iter; guint offset; gint buffer_x, buffer_y; LOG(LOG_DEBUG, "IN : popup_button_press_event()"); if(event->type == GDK_BUTTON_PRESS){ if (event->button == 1){ gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget), GTK_TEXT_WINDOW_TEXT, (gint)(event->x), (gint)(event->y), &buffer_x, &buffer_y); gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &iter, buffer_x, buffer_y); offset = gtk_text_iter_get_offset(&iter); if(follow_link(offset) == TRUE){ LOG(LOG_DEBUG, "OUT : popup_button_press_event() = TRUE"); return(TRUE); } else { if(bpushpin_down == FALSE){ gtk_widget_destroy(popup); popup = NULL; } } } else if ((event->button == 2) || (event->button == 3)){ if(!current_in_result) return(TRUE); if (event->button == 2) { if(g_list_previous(current_in_result) == NULL){ return(TRUE); } current_in_result = g_list_previous(current_in_result); } else { if(g_list_next(current_in_result) == NULL){ return(TRUE); } current_in_result = g_list_next(current_in_result); } if(current_in_result == NULL) return(TRUE); rp = (RESULT *)(current_in_result->data); if(current_in_result){ show_popup(rp); } } } LOG(LOG_DEBUG, "OUT : popup_button_press_event()"); return(TRUE); }
/* * This routine interprets a pathname in the context of the * currnet directory and the root directory, and returns * the inode of the containing directory, and a pointer to * the filename of the file (pointing into the pathname) * and the length of the filename. */ static errcode_t dir_namei(cmfs_filesys *fs, uint64_t root, uint64_t dir, const char *pathname, int pathlen, int link_count, char *buf, const char **name, int *namelen, uint64_t *res_inode) { char c; const char *thisname; int len; uint64_t inode; errcode_t ret; if ((c = *pathname) == '/') { dir = root; pathname++; pathlen--; } while (1) { thisname = pathname; for (len = 0; --pathlen >= 0; len++) { c = *(pathname++); if (c == '/') break; } if (pathlen < 0) break; ret = cmfs_lookup(fs, dir, thisname, len, buf, &inode); if (ret) return ret; ret = follow_link(fs, root, dir, inode, link_count, buf, &dir); if (ret) return ret; } *name = thisname; *namelen = len; *res_inode = dir; return 0; }
gint button_press_event(GtkWidget *widget, GdkEventButton *event) { GtkTextIter iter; guint offset; gint buffer_x, buffer_y; GdkRectangle location; gboolean too_far=FALSE; LOG(LOG_DEBUG, "IN : button_press_event()"); if((event->type == GDK_BUTTON_PRESS) && (event->button == 1)){ // If you don't convert position as buffer origin, // position will be invalid when scrolling gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget), GTK_TEXT_WINDOW_TEXT, (gint)(event->x), (gint)(event->y), &buffer_x, &buffer_y); gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &iter, buffer_x, buffer_y); offset = gtk_text_iter_get_offset(&iter); gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget), &iter, &location); if((buffer_x >= location.x + font_width) || (buffer_x <= location.x - font_width)) too_far = TRUE; else too_far = FALSE; if(scan_link(offset) && !too_far){ if(follow_link(offset) == TRUE) return(TRUE); } } else if((event->type == GDK_BUTTON_PRESS) && ((event->button == 2) || (event->button == 3))){ gtk_item_factory_popup(GTK_ITEM_FACTORY(text_item_factory), event->x_root, event->y_root, event->button, event->time); LOG(LOG_DEBUG, "OUT : button_press_event() = TRUE"); return(TRUE); } //gdk_window_get_pointer(widget->window, &x, &y, &mask); LOG(LOG_DEBUG, "OUT : button_press_event() = FALSE"); return(FALSE); }
void RK::execute() { RDSolver& mysolver = *solver().handle< RDSolver >(); // get the current rk k step and order const Uint rkorder = mysolver.properties().value<Uint>("rkorder"); const Uint step = mysolver.iterative_solver().properties().value<Uint>("iteration"); if (is_null(m_solution)) m_solution = follow_link( mysolver.fields().get_child( RDM::Tags::solution() ) )->handle<Field>(); if (is_null(m_residual)) m_residual = follow_link( mysolver.fields().get_child( RDM::Tags::residual() ) )->handle<Field>(); if (is_null(m_dual_area)) m_dual_area = follow_link( mysolver.fields().get_child( RDM::Tags::dual_area() ) )->handle<Field>(); // get the correct solution to update depending on which rk k step we are Handle< Field > csolution_k; if ( step == rkorder ) csolution_k = m_solution; else { csolution_k = follow_link(mysolver.fields().get_child( std::string(RDM::Tags::solution()) + "-" + to_str(step) + "dt" ))->handle<Field>(); } cf3_assert( is_not_null(csolution_k) ); Field& solution_k = *csolution_k; Field& dual_area = *m_dual_area; Field& residual = *m_residual; /// @todo should be used later to calculate automatically the \Delta t //const Real CFL = options().option("cfl").value<Real>(); /// @todo maybe better to directly store dual_area inverse // implementation of the RungeKutta update step const Uint nbdofs = solution_k.size(); const Uint nbvars = solution_k.row_size(); for ( Uint i=0; i< nbdofs; ++i ) for ( Uint j=0; j< nbvars; ++j ) solution_k[i][j] += - residual[i][j] / dual_area[i][0]; }
void IterativeSolver::execute() { RDM::RDSolver& mysolver = *solver().handle< RDM::RDSolver >(); /// @todo this configuration sould be in constructor but does not work there configure_option_recursively( "iterator", handle<Component>() ); // access components (out of loop) ActionDirector& boundary_conditions = *access_component( "cpath:../BoundaryConditions" )->handle<ActionDirector>(); ActionDirector& domain_discretization = *access_component( "cpath:../DomainDiscretization" )->handle<ActionDirector>(); Action& synchronize = *mysolver.actions().get_child("Synchronize")->handle<Action>(); Handle<Component> cnorm = post_actions().get_child("ComputeNorm"); cnorm->options().set("table", follow_link(mysolver.fields().get_child( RDM::Tags::residual() ))->uri() ); Component& cprint = *post_actions().get_child("IterationSummary"); cprint.options().set("norm", cnorm ); // iteration loop Uint iter = 1; // iterations start from 1 ( max iter zero will do nothing ) properties().property("iteration") = iter; while( ! stop_condition() ) // non-linear loop { // (1) the pre actions - cleanup residual, pre-process something, etc pre_actions().execute(); // (2) domain discretization domain_discretization.execute(); // (3) apply boundary conditions boundary_conditions.execute(); // (4) update update().execute(); // (5) update synchronize.execute(); // (6) the post actions - compute norm, post-process something, etc post_actions().execute(); // raise signal that iteration is done raise_iteration_done(); // increment iteration properties().property("iteration") = ++iter; // update the iteration number } }
void FaceTerm::link_fields() { if( is_null( m_solution ) ) { m_solution = follow_link( solver().handle<RDM::RDSolver>()->fields().get_child( RDM::Tags::solution() ))->handle<Field>(); configure_option_recursively( RDM::Tags::solution(), m_solution ); } if( is_null( m_residual ) ) { m_residual = follow_link( solver().handle<RDM::RDSolver>()->fields().get_child( RDM::Tags::residual() ))->handle<Field>(); configure_option_recursively( RDM::Tags::residual(), m_residual ); } if( is_null( m_wave_speed ) ) { m_wave_speed = follow_link( solver().handle<RDM::RDSolver>()->fields().get_child( RDM::Tags::wave_speed() ))->handle<Field>(); configure_option_recursively( RDM::Tags::wave_speed(), m_wave_speed ); } }
void FwdEuler::execute() { RDSolver& mysolver = *solver().handle< RDSolver >(); if (is_null(m_solution)) m_solution = follow_link(mysolver.fields().get_child( RDM::Tags::solution() ))->handle<Field>(); if (is_null(m_wave_speed)) m_wave_speed = follow_link(mysolver.fields().get_child( RDM::Tags::wave_speed() ))->handle<Field>(); if (is_null(m_residual)) m_residual = follow_link(mysolver.fields().get_child( RDM::Tags::residual() ))->handle<Field>(); Field& solution = *m_solution; Field& wave_speed = *m_wave_speed; Field& residual = *m_residual; CFinfo << "PPPPPPPPPPPPPP3: " << solution.uri().path() << CFendl; CFinfo << "PPPPPPPPPPPPPP4: " << residual.uri().path() << CFendl; CFinfo << "PPPPPPPPPPPPPP5: " << wave_speed.uri().path() << CFendl; const Real CFL = options().option("cfl").value<Real>(); const Uint nbdofs = solution.size(); const Uint nbvars = solution.row_size(); for ( Uint i=0; i< nbdofs; ++i ) { if ( is_zero(wave_speed[i][0]) ) { for ( Uint j=0; j< nbvars; ++j ) if( is_not_zero(residual[i][j]) ) CFwarn << "residual not null but wave_speed null at node [" << i << "] variable [" << j << "]" << CFendl; continue; } const Real update = CFL / wave_speed[i][0] ; for ( Uint j=0; j< nbvars; ++j ) solution[i][j] += - update * residual[i][j]; } }
void Node2FaceCellConnectivity::add_used (FaceCellConnectivity& used_comp) { bool found = false; std::vector<Handle< FaceCellConnectivity > > used_components = used(); boost_foreach( Handle< FaceCellConnectivity > comp, used_components ) { if (comp->handle<Component>() == follow_link(used_comp)) { found = true; break; } } if (found == false) m_used_components->create_component<Link>("used_component["+to_str(used_components.size())+"]")->link_to(used_comp); }
static int load_file_follow_symlink(const char *name) { int r; char link[PATH_MAX+1], *path; r = readlink(name, link, PATH_MAX); if (r > 0) { link[r] = 0; /* needs to be null terminated */ path = alloca(strlen(name) + strlen(link) + 1); strcpy(path, name); if (follow_link(path, link)) return -1; log_print(LOG_DEBUG, "followed link to: %s\n", path); load_file(path); } return 0; }
errcode_t ext2fs_follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd, ext2_ino_t inode, ext2_ino_t *res_inode) { char *buf; errcode_t retval; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); retval = ext2fs_get_mem(fs->blocksize, &buf); if (retval) return retval; retval = follow_link(fs, root, cwd, inode, 0, buf, res_inode); ext2fs_free_mem(&buf); return retval; }
static void handle_file(FileView *view, FileHandleExec exec, FileHandleLink follow) { char full_path[PATH_MAX]; int executable; int runnable; const dir_entry_t *const curr = &view->dir_entry[view->list_pos]; get_full_path_of(curr, sizeof(full_path), full_path); if(is_dir(full_path) || is_unc_root(view->curr_dir)) { if(!curr->selected && (curr->type != FT_LINK || follow == FHL_NO_FOLLOW)) { open_dir(view); return; } } runnable = is_runnable(view, full_path, curr->type, follow == FHL_FOLLOW); executable = is_executable(full_path, curr, exec == FHE_NO_RUN, runnable); if(stats_file_choose_action_set() && (executable || runnable)) { /* The call below does not return. */ vifm_choose_files(view, 0, NULL); } if(executable && !is_dir_entry(full_path, curr->type)) { execute_file(full_path, exec == FHE_ELEVATE_AND_RUN); } else if(runnable) { run_selection(view, exec == FHE_NO_RUN); } else if(curr->type == FT_LINK) { follow_link(view, follow == FHL_FOLLOW); } }
solver::Action& InitialConditions::create_initial_condition(const std::string& name, const std::vector<URI>& regions) { Handle<solver::Action> ic = create_component< sdm::Init >(name); Handle<Field> solution = follow_link(solver().field_manager().get_child(sdm::Tags::solution()))->handle<Field>(); ic->options().configure_option( sdm::Tags::solver() , m_solver); ic->options().configure_option( sdm::Tags::mesh(), m_mesh); ic->options().configure_option( "solution_field", solution); if( regions.empty() ) // if user did not specify, then use the one from the solver { ic->options().configure_option("regions" , solver().options().option("regions").value< std::vector<common::URI> >() ); } else { ic->options().configure_option("regions" , regions); } ic->options().configure_option( sdm::Tags::physical_model() , m_physical_model); return *ic; }
void PrepareMesh::execute() { // configuration of all solver components. // This component and its children should be part of it. solver().configure_option_recursively(sdm::Tags::solution_order(),solver().options().option(sdm::Tags::solution_order()).value<Uint>()); solver().configure_option_recursively(sdm::Tags::mesh(),mesh().handle<Component>()); solver().configure_option_recursively(sdm::Tags::regions(),solver().options().option(sdm::Tags::regions()).value< std::vector<URI> >()); solver().configure_option_recursively(sdm::Tags::physical_model(),physical_model().handle<Component>()); solver().configure_option_recursively(sdm::Tags::solver(),solver().handle<Component>()); configure_option_recursively(sdm::Tags::solution_order(),solver().options().option(sdm::Tags::solution_order()).value<Uint>()); configure_option_recursively(sdm::Tags::mesh(),mesh().handle<Component>()); configure_option_recursively(sdm::Tags::regions(),solver().options().option(sdm::Tags::regions()).value< std::vector<URI> >()); configure_option_recursively(sdm::Tags::physical_model(),physical_model().handle<Component>()); configure_option_recursively(sdm::Tags::solver(),solver().handle<Component>()); // execution of prepare mesh ActionDirector::execute(); std::vector<URI> fields; fields.push_back( follow_link( solver().field_manager().get_child(sdm::Tags::solution()) )->uri() ); solver().handle<SDSolver>()->time_stepping().post_actions().get_child("Periodic")->configure_option_recursively("fields",fields); solver().handle<SDSolver>()->time_stepping().post_actions().get_child("Periodic")->configure_option_recursively("file",URI("sdm_output_${time}.msh")); }
static errcode_t open_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t base, const char *pathname, size_t pathlen, int follow, int link_count, char *buf, ext2_ino_t *res_inode) { const char *base_name; int namelen; ext2_ino_t dir, inode; errcode_t retval; #ifdef NAMEI_DEBUG printf("open_namei: root=%lu, dir=%lu, path=%*s, lc=%d\n", root, base, pathlen, pathname, link_count); #endif retval = dir_namei(fs, root, base, pathname, pathlen, link_count, buf, &base_name, &namelen, &dir); if (retval) return retval; if (!namelen) { *res_inode=dir; return 0; } retval = ext2fs_lookup (fs, dir, base_name, namelen, buf, &inode); if (retval) return retval; if (follow) { retval = follow_link(fs, root, dir, inode, link_count, buf, &inode); if (retval) return retval; } #ifdef NAMEI_DEBUG printf("open_namei: (link_count=%d) returns %lu\n", link_count, inode); #endif *res_inode = inode; return 0; }
Handle< const Component > follow_link(const Component& link_or_comp) { return follow_link(link_or_comp.handle()); }
static errcode_t open_namei(cmfs_filesys *fs, uint64_t root, uint64_t base, const char *pathname, size_t pathlen, int follow, int link_count, char *buf, uint64_t *res_inode) { const char *basename; int namelen; uint64_t dir, inode; errcode_t ret; #ifdef NAMIE_DEBUG printf("%s:%d root=%lu, dir=%lu, path=%*s, lc=%d\n", __func__, __LINE__, root, base, pathlen, pathname, link_count); #endif ret = dir_namei(fs, root, base, pathname, pathlen, link_count, buf, &basename, &namelen, &dir); if (ret) return ret; /* special case: '/usr/' etc */ if (!namelen) { *res_inode = dir; return 0; } ret = cmfs_lookup(fs, dir, basename, namelen, buf, &inode); if (ret) return ret; if (follow) { ret = follow_link(fs, root, dir, inode, link_count, buf, &inode); if (ret) return ret; } #ifdef NAMEI_DEBUG printf("%s:%d (link_count=%d) returns %lu\n", link_count, inode); #endif *res_inode = inode; return 0; }
int main(int argc, char *argv[]) { int i; char line[1024], *uri; /* copy defaults */ init_config(); uri = &config.start_uri[0]; /* parse command line */ for (i = 1; i < argc; i++) { if (argv[i][0] == '-') switch(argv[i][1]) { case 'H': usage(); break; case 'v': banner(stderr); exit(EXIT_FAILURE); default: usage(); } else { uri = argv[i]; } } /* parse uri */ banner(stdout); if (! parse_uri(uri)) { banner(stderr); fprintf(stderr, "invalid gopher URI: %s", argv[i]); exit(EXIT_FAILURE); } /* main loop */ view_directory(parsed_host, parsed_port, parsed_selector, 0); for (;;) { printf("\033[%sm%s:%s%s\033[0m ", config.color_prompt, current_host, current_port, current_selector); fflush(stdout); /* to display the prompt */ if (! read_line(0, line, sizeof(line))) { puts("QUIT"); return EXIT_SUCCESS; } i = strlen(line); switch (line[0]) { case '?': puts( "? - help\n" "* - reload directory\n" "< - go back in history\n" ".LINK - download the given link\n" "h - show history\n" "hLINK - jump to the specified history item\n" "gURI - jump to the given gopher URI\n" "b - show bookmarks\n" "bLINK - jump to the specified bookmark item\n" "C^d - quit"); break; case '<': pop_history(); break; case '*': view_directory(current_host, current_port, current_selector, 0); break; case '.': download_link(make_key(line[1], line[2])); break; case 'h': if (i == 1 || i == 3) view_history(make_key(line[1], line[2])); else follow_link(make_key(line[0], line[1])); break; case 'g': if (i != 2) { if (parse_uri(&line[1])) view_directory(parsed_host, parsed_port, parsed_selector, 1); else puts("invalid gopher URI"); } else follow_link(make_key(line[0], line[1])); break; case 'b': if (i == 1 || i == 3) view_bookmarks(make_key(line[1], line[2])); else follow_link(make_key(line[0], line[1])); break; default: follow_link(make_key(line[0], line[1])); break; } } return EXIT_SUCCESS; /* never get's here but stops cc complaining */ }
Handle< const Component > follow_link(const Component& link_or_comp) { std::cout << "checking link on " << link_or_comp.uri() << std::endl; return follow_link(link_or_comp.handle<Component>()); }
Handle< Component > follow_link(Component& link_or_comp) { return follow_link(link_or_comp.handle<Component>()); }