コード例 #1
0
ファイル: FlowPrinter.cpp プロジェクト: cnplab/blockmon
        /*
         * the main method
         * receives a Flow message and prints out its associated information
         * If the message belongs to another class, an exception is thrown.
         */
        virtual void _receive_msg(std::shared_ptr<const Msg>&& m, int /* index */)
        {
            if ( m->type() == MSG_ID(Flow) )
            {
                auto flow = static_cast<const Flow *>(m.get());
                std::stringstream ss;
                const FlowKey& fk = flow->key();
                int duration = flow->end_time() - flow->start_time();
                ss<<"packets="<<flow->packets() << ",";
                ss<<"bytes="<<flow->bytes() << ",";
                ss<<"start="<<flow->start_time() << ",";
                ss<<"end="<<flow->end_time() << ",";
                ss<<"duration.us="<<duration<< ",";
                ss<<"source.ip4="<<ip_to_string(fk.src_ip4)<< ",";
                ss<<"source.port="<<fk.src_port<< ",";
                ss<<"destination.ip4="<<ip_to_string(fk.dst_ip4)<< ",";
                ss<<"destination.port="<<fk.dst_port;
                /*
                ss<<"Flow of  "<< flow->packets() << " packets and "<<flow->bytes()<<" bytes begin at "<<flow->start_time()<<" end at "<<flow->end_time()<< "duration (ms.) "<<duration <<std::endl;
                ss<<"SRC IP "<<ip_to_string(fk.src_ip4)<<" SRC port "<<fk.src_port<<std::endl;
                ss<<"DST IP "<<ip_to_string(fk.dst_ip4)<<" DST port "<<fk.dst_port<<std::endl;
                //ss<<"protocol "<<fk.proto<<std::endl;
                */
                blocklog(ss.str(),log_info);


            }
                else
            {
                throw std::runtime_error("Flowprinter: wrong message type");
            }
        }
コード例 #2
0
ファイル: benchmark.c プロジェクト: drb/firedns
int main() {
	int i;
	double libc, fire;
	struct firedns_state state, *s = &state;
	firedns_init(s);
	firedns_add_servers_from_resolv_conf(s);

	printf("Testing %d firedns_resolveip4list(\"%s\"):\n",TESTS,TEST_HOST);
	start_time();
	for (i = 0; i < TESTS; i++)
		firedns_resolveip4list(s, TEST_HOST);
	fire = end_time();

	printf("Testing %d gethostbyname(\"%s\"):\n",TESTS,TEST_HOST);
	start_time();
	for (i = 0; i < TESTS; i++)
		gethostbyname(TEST_HOST);
	libc = end_time();

	if (libc > fire)
		printf("Speedup: %d%%\n",(int) (((libc - fire) / libc) * 100.0));
	else
		printf("Slowdown: %d%%\n",(int) (((fire - libc) / libc) * 100.0));

	return 0;
}
コード例 #3
0
ファイル: gravity.c プロジェクト: sleitner/cart
void prolongate( int level ) {
	int i,j;
	const int prolongation_vars[1] = { VAR_POTENTIAL };
	int icell;
	int num_level_cells;
	int *level_cells;

	cart_assert( level >= min_level+1 );

	start_time( WORK_TIMER );

	select_level( level-1, CELL_TYPE_LOCAL | CELL_TYPE_REFINED, &num_level_cells, &level_cells );
#pragma omp parallel for default(none), private(i,icell,j), shared(num_level_cells,level_cells,cell_vars,cell_child_oct)
	for ( i = 0; i < num_level_cells; i++ ) {
		icell = level_cells[i];

		for ( j = 0; j < num_children; j++ ) {
			cell_potential( cell_child(icell,j) ) = cell_interpolate( icell, j, VAR_POTENTIAL );
		}
	}
	cart_free( level_cells );

	end_time( WORK_TIMER );

	/* update buffers */
	start_time( PROLONGATE_UPDATE_TIMER );
	update_buffer_level( level, prolongation_vars, 1 );
	end_time( PROLONGATE_UPDATE_TIMER );
}
コード例 #4
0
ファイル: gravity_step.c プロジェクト: sleitner/cart
void compute_accelerations_particles( int level ) {
	int i, j;
	double a2half;
	const int accel_vars[nDim] = { VAR_ACCEL, VAR_ACCEL+1, VAR_ACCEL+2 };
	int neighbors[num_neighbors];
	int L1, R1;
	double phi_l, phi_r;
	int icell;
	int num_level_cells;
	int *level_cells;

	start_time( GRAVITY_TIMER );
	start_time( PARTICLE_ACCEL_TIMER );
	start_time( WORK_TIMER );

#ifdef COSMOLOGY
	a2half = -0.5*abox[level]*abox[level]*cell_size_inverse[level];
#else
	a2half = -0.5 * cell_size_inverse[level];
#endif

	select_level( level, CELL_TYPE_LOCAL, &num_level_cells, &level_cells );
#pragma omp parallel for default(none), private(icell,j,neighbors,L1,R1,phi_l,phi_r), shared(num_level_cells,level_cells,level,cell_vars,a2half)
	for ( i = 0; i < num_level_cells; i++ ) {
		icell = level_cells[i];

		cell_all_neighbors( icell, neighbors );
		for ( j = 0; j < nDim; j++ ) {
			L1 = neighbors[2*j];
			R1 = neighbors[2*j+1];

			if ( cell_level(L1) < level ) {
				phi_l = 0.8*cell_potential(L1) + 0.2*cell_potential(icell);
			} else {
				phi_l = cell_potential(L1);
			}

			if ( cell_level(R1) < level ) {
				phi_r = 0.8*cell_potential(R1)+0.2*cell_potential(icell);
			} else {
				phi_r = cell_potential(R1);
			}

			cell_accel( icell, j ) = (float)(a2half * ( phi_r - phi_l ) );
		}
	}
	cart_free( level_cells );

	end_time( WORK_TIMER );

	/* update accelerations */
	start_time( PARTICLE_ACCEL_UPDATE_TIMER );
	update_buffer_level( level, accel_vars, nDim );
	end_time( PARTICLE_ACCEL_UPDATE_TIMER );

	end_time( PARTICLE_ACCEL_TIMER );
	end_time( GRAVITY_TIMER );
}
コード例 #5
0
ファイル: discrete.cpp プロジェクト: regmi/hermes2d
void DiscreteProblem::create_matrix()
{
  // remove any previous matrix
  free_matrix_indices();
  free_matrix_values();

  // calculate the total number of DOFs
  ndofs = 0;
  for (int i = 0; i < neq; i++)
    ndofs += spaces[i]->get_num_dofs();
  if (!quiet) verbose("Ndofs: %d", ndofs);
  if (!ndofs) return;

  // get row and column indices of nonzero matrix elements
  Page** pages = new Page*[ndofs];
  memset(pages, 0, sizeof(Page*) * ndofs);
  if (!quiet) { verbose("Calculating matrix sparse structure..."); begin_time(); }
  precalculate_sparse_structure(pages);

  // initialize the arrays Ap and Ai
  Ap = (int*) malloc(sizeof(int) * (ndofs+1));
  int aisize = get_num_indices(pages, ndofs);
  Ai = (int*) malloc(sizeof(int) * aisize);
  if (Ai == NULL) error("Out of memory. Could not allocate the array Ai.");

  // sort the indices and remove duplicities, insert into Ai
  int i, pos = 0, num;
  for (i = 0; i < ndofs; i++)
  {
    Ap[i] = pos;
    pos += sort_and_store_indices(pages[i], Ai + pos, Ai + aisize);
  }
  Ap[i] = pos;
  if (!quiet) verbose("  Nonzeros: %d\n  Total matrix size: %0.1lf MB\n  (time: %g sec)",
                         pos, (double) get_matrix_size() / (1024*1024), end_time());
  delete [] pages;

  // shrink Ai to the actual size
  int* oldAi = Ai;
  Ai = (int*) realloc(Ai, sizeof(int) * pos);
  if (oldAi != Ai) warn("Realloc moved Ai when shrinking."); // this should not happen

  // UMFPACK: perform symbolic analysis of the matrix
  if (!quiet) { verbose("Performing UMFPACK symbolic analysis..."); begin_time(); }
  int status = umfpack_symbolic(ndofs, ndofs, Ap, Ai, NULL, &Symbolic, NULL, NULL);
  if (status != UMFPACK_OK) umfpack_status(status);
  if (!quiet) verbose("  (time: %g sec)", end_time());

  equi = (double*) malloc(sizeof(double) * ndofs);
  if (equi == NULL) error("Out of memory. Error allocating the equilibration vector.");
  for (int i = 0; i < ndofs; i++)
    equi[i] = 1.0;
  is_equi = false;
}
コード例 #6
0
ファイル: rt_otvet.c プロジェクト: sleitner/cart
void rtOtvetSingleSourceEddingtonTensor(int level)
{
  int i, j, l, index, cell;
  int num_level_cells, *level_cells;
  double eps1, eps2, dr2, pos[nDim];

  start_time(WORK_TIMER);

  eps1 = 0.01*cell_size[rtSingleSourceLevel]*cell_size[rtSingleSourceLevel];
  eps2 = 9*cell_size[rtSingleSourceLevel]*cell_size[rtSingleSourceLevel];

  select_level(level,CELL_TYPE_LOCAL,&num_level_cells,&level_cells);

#pragma omp parallel for default(none), private(index,cell,pos,dr2,i,j,l), shared(level,num_level_cells,level_cells,rtSingleSourceValue,rtSingleSourcePos,eps1,eps2,cell_vars)
  for(index=0; index<num_level_cells; index++)
    {
      cell = level_cells[index];
      cell_center_position(cell,pos);

      dr2 = eps1;
      for(i=0; i<nDim; i++)
	{
	  pos[i] -= rtSingleSourcePos[i];
	  if(pos[i] >  0.5*num_grid) pos[i] -= num_grid;
	  if(pos[i] < -0.5*num_grid) pos[i] += num_grid;
	  dr2 += pos[i]*pos[i];
	}

      cell_var(cell,RT_VAR_OT_FIELD) = rtSingleSourceValue/(4*M_PI*dr2);
      
      dr2 += nDim*eps2;
      for(l=j=0; j<nDim; j++)
	{
	  for(i=0; i<j; i++)
	    {
	      cell_var(cell,rt_et_offset+l++) = pos[i]*pos[j]/dr2;
	    }
	  cell_var(cell,rt_et_offset+l++) = (eps2+pos[j]*pos[j])/dr2;
	}
    }

  cart_free(level_cells);

  end_time(WORK_TIMER);

  start_time(RT_SINGLE_SOURCE_UPDATE_TIMER);
  update_buffer_level(level,rtOtvetETVars,rtNumOtvetETVars);
  end_time(RT_SINGLE_SOURCE_UPDATE_TIMER);
}
コード例 #7
0
ファイル: drivespeed.c プロジェクト: DEEDS-TUD/PAIN
int readFile(int use, int dsize)
{
    int p;

    if (largeFile) start_time();

    handle = open(testFile, O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
    if (handle == -1)
    {
        sprintf(resultchars, " Cannot open %s for reading\n", testFile);
        return 0;
    }

    for (p=0; p<use; p++)
    {
        if (read(handle, dataIn, dsize) == -1)
        {
            sprintf(resultchars," Error reading file %s block %d\n", testFile, p+1);
            return 0;
        }

    }
    close(handle);
    if (largeFile) end_time();
    return 1;
}
コード例 #8
0
ファイル: Note.cpp プロジェクト: 63n/ardour
Note<Time>::Note(const Note<Time>& copy)
	: _on_event(copy._on_event, true)
	, _off_event(copy._off_event, true)
{
	set_id (copy.id());

	assert(_on_event.buffer());
	assert(_off_event.buffer());
	/*
	  assert(copy._on_event.size == 3);
	  _on_event.buffer = _on_event_buffer;
	  memcpy(_on_event_buffer, copy._on_event_buffer, 3);

	  assert(copy._off_event.size == 3);
	  _off_event.buffer = _off_event_buffer;
	  memcpy(_off_event_buffer, copy._off_event_buffer, 3);
	*/

	assert(time() == copy.time());
	assert(end_time() == copy.end_time());
	assert(length() == copy.length());
	assert(note() == copy.note());
	assert(velocity() == copy.velocity());
	assert(_on_event.channel() == _off_event.channel());
	assert(channel() == copy.channel());
}
コード例 #9
0
ファイル: rt.c プロジェクト: sleitner/cart
void rtInitRun()
{
#ifdef RT_TEST
  frt_real Yp = 1.0e-10;
#else
  frt_real Yp = constants->Yp;
#endif
  frt_real Tmin = gas_temperature_floor;
  frt_real D2GminH2 = rt_dust_to_gas_floor*(constants->Dsun/constants->Zsun);
  frt_real CluFacH2 = rt_clumping_factor;
  frt_real CohLenH2 = rt_coherence_length;
  frt_real fGal = rt_uv_emissivity_stars;
  frt_real fQSO = rt_uv_emissivity_quasars;
  frt_intg IPOP = rt_stellar_pop;
  frt_intg IREC = 0;
  frt_intg IOUNIT = 81;

  start_time(WORK_TIMER);

  frtCall(initrun2)(&Yp,&Tmin,&D2GminH2,&CluFacH2,&CohLenH2,&fGal,&fQSO,&IPOP,&IREC,&IOUNIT);

  end_time(WORK_TIMER);

#ifdef RT_TRANSFER
  rtInitRunTransfer();
#endif
}
コード例 #10
0
ファイル: drivespeed.c プロジェクト: DEEDS-TUD/PAIN
int writeFile(int use, int dsize)
{
    int  p;

    if (largeFile) start_time();

    if (useCache)
    {
        handle = open(testFile, O_WRONLY | O_CREAT | O_TRUNC,
                      S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
    }
    else
    {
        handle = open(testFile, O_WRONLY | O_CREAT | O_TRUNC | O_DIRECT | O_SYNC,
                      S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH | S_IWOTH); // O_DIRECT | O_SYNC
    }
    if (handle == -1)
    {
        sprintf(resultchars, " Cannot open %s for writing\n", testFile);
        return 0;
    }

    for (p=0; p<use; p++)
    {
        if (write(handle, dataOut, dsize) != dsize )
        {
            sprintf(resultchars," Error writing file %s block %d\n", testFile, p+1);
            return 0;
        }
    }
    close(handle);

    if (largeFile) end_time();
    return 1;
}
コード例 #11
0
ファイル: main.cpp プロジェクト: martinlanzendorfer/hermes2d
int main(int argc, char* argv[])
{
  // Load the mesh
  Mesh mesh;
  H2DReader mloader;
  mloader.load("domain.mesh", &mesh);
  for (int i=0; i < INIT_REF_NUM; i++) mesh.refine_all_elements();

  // Initialize the shapeset and the cache
  H1Shapeset shapeset;
  PrecalcShapeset pss(&shapeset);

  // Create finite element space
  H1Space space(&mesh, &shapeset);
  space.set_bc_types(bc_types);
  space.set_bc_values(bc_values);
  space.set_uniform_order(P_INIT);

  // Enumerate basis functions
  space.assign_dofs();

  // Initialize the weak formulation
  WeakForm wf(1);
  wf.add_biform(0, 0, bilinear_form, bilinear_form_ord, SYM);
  wf.add_liform(0, linear_form, linear_form_ord);
  wf.add_liform_surf(0, linear_form_surf, linear_form_surf_ord, 2);

  // Visualize solution and mesh
  ScalarView sview("Coarse solution", 0, 100, 798, 700);
  OrderView  oview("Polynomial orders", 800, 100, 798, 700);

  // Matrix solver
  UmfpackSolver solver;

  // Time measurement
  double cpu = 0;
  begin_time();

  // Solve the problem
  Solution sln;
  LinSystem ls(&wf, &solver);
  ls.set_spaces(1, &space);
  ls.set_pss(1, &pss);
  ls.assemble();
  ls.solve(1, &sln);

  // Time measurement
  cpu += end_time();

  // View the solution and mesh
  sview.show(&sln);
  oview.show(&space);

  // Print timing information
  verbose("Total running time: %g sec", cpu);

  // wait for all views to be closed
  View::wait("Waiting for all views to be closed.");
  return 0;
}
コード例 #12
0
ファイル: ga.c プロジェクト: Nazgolze/image-approximator
void init_ga(int num_circles)
{
	char *end_time_str;
	struct timespec tp1, tp2;
	int idx;
	if(_is_initialized)
		return;

	printfl(IA_INFO,
	    "initializing for genetic algorithm, this may take some time....");
	_is_initialized = true;
	circle_pool = calloc(GEN_SIZE, sizeof(struct ia_circles *));
	start_time(&tp1);

	for(idx = 0; idx < GEN_SIZE; idx++) {
		circle_pool[idx] = calloc(1, sizeof(struct ia_circles));
		init_circles(circle_pool[idx], num_circles);
	}

	for(idx = 0; idx < GEN_SIZE; idx++) {
		//for(jdx = 0; jdx < 2; jdx++) {
		//	_seed_mutate(&circle_pool[idx]);
		//}
		refresh_circles(circle_pool[idx]);
		sort_circles(circle_pool[idx]);
	}

	end_time_str = end_time(&tp1, &tp2, "time");
	printfi("%s\nsee, that didn't take too long, did it?\n", end_time_str);
	free(end_time_str);
}
コード例 #13
0
ファイル: rt.c プロジェクト: sleitner/cart
void rtInitStep(double dt)
{
  frt_real uDen = units->number_density;
  frt_real uLen = units->length;
  frt_real uTime = units->time;
  frt_real dtCode = dt;

#ifdef COSMOLOGY
  frt_real aExp = abox[min_level];
  frt_real daExp = abox_from_tcode(tl[min_level]+dt) - abox[min_level];
  frt_real HExp = Hubble(aExp)/units->time;
#else
  frt_real aExp = 1.0;
  frt_real daExp = 0.0;
  frt_real HExp = 0.0;
#endif

  start_time(WORK_TIMER);

  frtCall(stepbegin)(&uDen,&uLen,&uTime,&aExp,&HExp,&daExp,&dtCode);

  end_time(WORK_TIMER);

#ifdef RT_TRANSFER
  rtInitStepTransfer();
#endif

  rtUpdateTables();

#ifdef RT_DEBUG
  switch(rt_debug.Mode)
    {
    case 1:
      {
	int i, cell;
	cell = cell_find_position(rt_debug.Pos);
	cart_debug("In cell-level debug for cell %d/%d",cell,cell_level(cell));
	cart_debug("RT_HVAR_OFFSET: %d",RT_HVAR_OFFSET);
#ifdef RT_VAR_SOURCE
	cart_debug("RT_VAR_SOURCE: %d",RT_VAR_SOURCE);
#endif
	cart_debug("rt_grav_vars_offset: %d",rt_grav_vars_offset);
#ifdef RT_TRANSFER
	cart_debug("rt_num_vars: %d",rt_num_vars);
#if (RT_TRANSFER_METHOD == RT_METHOD_OTVET)
	cart_debug("RT_VAR_OT_FIELD: %d",RT_VAR_OT_FIELD);
	cart_debug("rt_et_offset: %d",rt_et_offset);
	cart_debug("rt_field_offset: %d",rt_field_offset);
#endif
#endif
	for(i=0; i<num_vars; i++)
	  {
	    cart_debug("Var[%d] = %g",i,cell_var(cell,i));
	  }
	break;
      }
    }
#endif /* RT_DEBUG */
}
コード例 #14
0
ファイル: control.cpp プロジェクト: Mr-Phoebe/QT-learning
void Control::initTime()
{
    QSqlQuery query;
    QDateTime start_date_time;
    query.exec("select min(DATE),min(TIME) from DATAS");
    if(query.next()){
        int min_date = query.value(0).toInt();
        int min_time = query.value(1).toInt();
        int year = min_date / 10000;
        int month = min_date % 10000 / 100;
        int day = min_date % 100;
        int h = min_time / 10000;
        QTime start_time(h,0);
        QDate start_date(2000 +year,month,day);
        start_date_time = QDateTime(start_date,start_time);
    }

    query.exec("select max(DATE),max(TIME) from DATAS");
    QDateTime end_date_time;
    if(query.next()){
        int max_date = query.value(0).toInt();
        int max_time = query.value(1).toInt();
        int year = max_date / 10000;
        int month = max_date % 10000 / 100;
        int day = max_date % 100;
        int h = max_time / 10000;
        QTime end_time(h,0);
        QDate end_date(2000 +year,month,day);
        end_date_time = QDateTime(end_date,end_time);
    }
    ui->startDateTimeEdit->setDisplayFormat("yyyy-M-d HH");
    ui->endDateTimeEdit->setDisplayFormat("yyyy-M-d HH");
    ui->startDateTimeEdit->setMinimumDateTime(start_date_time);
    ui->startDateTimeEdit->setMaximumDateTime(end_date_time);
    ui->endDateTimeEdit->setMinimumDateTime(start_date_time);
    ui->endDateTimeEdit->setMaximumDateTime(end_date_time);

    ui->startDateTimeEdit_2->setDisplayFormat("yyyy-M-d HH");
    ui->endDateTimeEdit_2->setDisplayFormat("yyyy-M-d HH");
    ui->startDateTimeEdit_2->setMinimumDateTime(start_date_time);
    ui->startDateTimeEdit_2->setMaximumDateTime(end_date_time);
    ui->endDateTimeEdit_2->setMinimumDateTime(start_date_time);
    ui->endDateTimeEdit_2->setMaximumDateTime(end_date_time);

    ui->startDateTimeEdit_3->setDisplayFormat("yyyy-M-d HH");
    ui->endDateTimeEdit_3->setDisplayFormat("yyyy-M-d HH");
    ui->startDateTimeEdit_3->setMinimumDateTime(start_date_time);
    ui->startDateTimeEdit_3->setMaximumDateTime(end_date_time);
    ui->endDateTimeEdit_3->setMinimumDateTime(start_date_time);
    ui->endDateTimeEdit_3->setMaximumDateTime(end_date_time);

    ui->startDateTimeEdit_4->setDisplayFormat("yyyy-M-d HH");
    ui->endDateTimeEdit_4->setDisplayFormat("yyyy-M-d HH");
    ui->startDateTimeEdit_4->setMinimumDateTime(start_date_time);
    ui->startDateTimeEdit_4->setMaximumDateTime(end_date_time);
    ui->endDateTimeEdit_4->setMinimumDateTime(start_date_time);
    ui->endDateTimeEdit_4->setMaximumDateTime(end_date_time);
}
コード例 #15
0
ファイル: rt.c プロジェクト: sleitner/cart
void rtAfterAssignDensity2(int level, int num_level_cells, int *level_cells)
{
  start_time(RT_AFTER_DENSITY_TIMER);

#ifdef RT_TRANSFER
  rtAfterAssignDensityTransfer(level,num_level_cells,level_cells);
#endif

  end_time(RT_AFTER_DENSITY_TIMER);
}
コード例 #16
0
ファイル: rt_step.c プロジェクト: sleitner/cart
void rtLevelUpdate(int level)
{
  start_time(RT_LEVEL_UPDATE_TIMER);

#ifdef RT_TRANSFER
  rtLevelUpdateTransfer(level);
#endif

  end_time(RT_LEVEL_UPDATE_TIMER);
}
コード例 #17
0
ファイル: main.cpp プロジェクト: Zhonghua/hermes2d
/** Nonadaptive solver.*/
void solveNonadaptive(Mesh &mesh, NonlinSystem &nls,
                      Solution &Cp, Solution &Ci, Solution &phip, Solution &phii) {
    begin_time();

    //VectorView vview("electric field [V/m]", 0, 0, 600, 600);
    ScalarView Cview("Concentration [mol/m3]", 0, 0, 800, 800);
    ScalarView phiview("Voltage [V]", 650, 0, 600, 600);

#ifdef CONT_OUTPUT
    phiview.show(&phii);
    Cview.show(&Ci);
    Cview.wait_for_keypress();
#endif
    Solution Csln, phisln;
    for (int n = 1; n <= NSTEP; n++) {

#ifdef VERBOSE
        info("\n---- Time step %d ----", n);
#endif

        int it = 1;
        double res_l2_norm;

        do {

#ifdef VERBOSE
            info("\n -------- Time step %d, Newton iter %d --------\n", n, it);
#endif
            it++;
            nls.assemble();
            nls.solve(2, &Csln, &phisln);
            res_l2_norm = nls.get_residuum_l2_norm();

#ifdef VERBOSE
            info("Residuum L2 norm: %g\n", res_l2_norm);
#endif

            Ci.copy(&Csln);
            phii.copy(&phisln);

        } while (res_l2_norm > NEWTON_TOL);
#ifdef CONT_OUTPUT
        phiview.show(&phii);
        Cview.show(&Ci);
#endif
        phip.copy(&phii);
        Cp.copy(&Ci);
    }
    verbose("\nTotal run time: %g sec", end_time());
    Cview.show(&Ci);
    phiview.show(&phii);
    //MeshView mview("small.mesh", 100, 30, 800, 800);
    //mview.show(&mesh);
    View::wait();
}
コード例 #18
0
ファイル: gravity_step.c プロジェクト: sleitner/cart
void copy_potential( int level ) {
	int i;
	int icell;
	int num_level_cells;
	int *level_cells;

	start_time( GRAVITY_TIMER );
	start_time( WORK_TIMER );

	select_level( level, CELL_TYPE_ANY, &num_level_cells, &level_cells );
#pragma omp parallel for default(none), private(i,icell), shared(num_level_cells,level_cells,cell_vars)
	for ( i = 0; i < num_level_cells; i++ ) {
		icell = level_cells[i];
		cell_potential_hydro(icell) = cell_potential(icell);
	}
	cart_free( level_cells );

	end_time( WORK_TIMER );
	end_time( GRAVITY_TIMER );
}
コード例 #19
0
ファイル: rt.c プロジェクト: sleitner/cart
/* This function can be called more than once per top level step */ 
void rtUpdateTables()
{
#ifdef RT_TRANSFER
  int i;
  frt_real rfAvg[rt_num_fields];

  for(i=0; i<rt_num_fields; i++) rfAvg[i] = rtAvgRF[i].Value;

#else
  frt_real *rfAvg = NULL;
#endif

  start_time(RT_TABLES_TIMER);
  start_time(WORK_TIMER);

  /* Fill in the tables */
  frtCall(updatetables)(rfAvg);

  end_time(WORK_TIMER);
  end_time(RT_TABLES_TIMER);
}
コード例 #20
0
ファイル: rt.c プロジェクト: sleitner/cart
void rtGlobalUpdate(int top_level, MPI_Comm level_com)
{
  start_time(RT_GLOBAL_UPDATE_TIMER);

#ifdef RT_TRANSFER
  rtGlobalUpdateTransfer(top_level,level_com);
#endif
  
  //rtUpdateTables(top_level,level_com);

  end_time(RT_GLOBAL_UPDATE_TIMER);
}
コード例 #21
0
ファイル: rt.c プロジェクト: sleitner/cart
void rtAfterAssignDensity1(int level)
{
  int num_level_cells;
  int *level_cells;

  start_time(RT_AFTER_DENSITY_TIMER);

#ifdef RT_TRANSFER
  /* assumes buffer gas density is up to date */
  start_time( WORK_TIMER );
  select_level(level,CELL_TYPE_ANY,&num_level_cells,&level_cells);
  end_time( WORK_TIMER );

  rtAfterAssignDensityTransfer(level,num_level_cells,level_cells);

  start_time( WORK_TIMER );
  cart_free(level_cells);
  end_time( WORK_TIMER );
#endif

  end_time(RT_AFTER_DENSITY_TIMER);
}
コード例 #22
0
ファイル: gravity_step.c プロジェクト: sleitner/cart
void interpolate_potential( int level ) {
	int i;
	int icell;
	int num_level_cells;
	int *level_cells;
	double dtdt2;

	start_time( GRAVITY_TIMER );
	start_time( WORK_TIMER );

	/*
	//  NG: dtl_old may not be set in the first time-step, but then
	//  cell_potential = cell_potential_hydro
	*/
	if(dtl_old[level] > 0.1*dtl[level])
	  {
	    dtdt2 = 0.5 * dtl[level]/dtl_old[level];
	  }
	else
	  {
	    dtdt2 = 0;
	  }

	select_level( level, CELL_TYPE_ANY, &num_level_cells, &level_cells );
#pragma omp parallel for default(none), private(i,icell), shared(num_level_cells,level_cells,cell_vars,dtdt2)
	for ( i = 0; i < num_level_cells; i++ ) {
		icell = level_cells[i];

		cell_potential_hydro(icell) = cell_potential(icell) +
			( cell_potential(icell) - cell_potential_hydro(icell) ) * dtdt2;
	}
	cart_free( level_cells );

	end_time( WORK_TIMER );
	end_time( GRAVITY_TIMER );
}
コード例 #23
0
ファイル: gravity.c プロジェクト: sleitner/cart
void solve_poisson( int level, int flag ) {
	const int potential_vars[1] = { VAR_POTENTIAL };

	cart_assert( level >= min_level && level <= max_level );

	start_time( GRAVITY_TIMER );

	if ( level == min_level ) {
		root_grid_fft_exec(VAR_TOTAL_MASS,1,potential_vars,root_grid_fft_gravity_worker);
	} else {
		relax( level, flag );
	}

	end_time( GRAVITY_TIMER );
}
コード例 #24
0
ファイル: Note.cpp プロジェクト: 63n/ardour
const Note<Time>&
Note<Time>::operator=(const Note<Time>& other)
{
	_on_event = other._on_event;
	_off_event = other._off_event;

	assert(time() == other.time());
	assert(end_time() == other.end_time());
	assert(length() == other.length());
	assert(note() == other.note());
	assert(velocity() == other.velocity());
	assert(_on_event.channel() == _off_event.channel());
	assert(channel() == other.channel());

	return *this;
}
コード例 #25
0
void star_particle_feedback(int level, int time_multiplier) {
	int i;
	int ipart;
	int iter_cell;
	int num_level_cells;
	int *level_cells;
	double t_next;

	start_time( WORK_TIMER );

	setup_star_formation_feedback(level);
	t_next = tl[level] + time_multiplier*dtl[level];

	select_level( level, CELL_TYPE_LOCAL | CELL_TYPE_LEAF, &num_level_cells, &level_cells );
#ifndef COMPILER_GCC
		/* Get compiler segfault under GCC */
#ifdef STAR_PARTICLE_TYPES
#pragma omp parallel for default(none), private(iter_cell,ipart), shared(num_level_cells,level_cells,cell_particle_list,particle_level,level,particle_t,t_next,particle_id,particle_species_indices,num_particle_species,particle_list_next, sf_feedback_particle,star_particle_type), schedule(dynamic) 
#else
#pragma omp parallel for default(none), private(iter_cell,ipart), shared(num_level_cells,level_cells,cell_particle_list,particle_level,level,particle_t,t_next,particle_id,particle_species_indices,num_particle_species,particle_list_next, sf_feedback_particle), schedule(dynamic)
#endif
#endif
	for ( i = 0; i < num_level_cells; i++ ) {
		iter_cell = level_cells[i];

		ipart = cell_particle_list[iter_cell];
		while ( ipart != NULL_PARTICLE ) {
			if ( particle_is_star(ipart) && particle_t[ipart] < t_next - 0.5*dtl[max_level] 
#ifdef STAR_PARTICLE_TYPES
			     && (   star_particle_type[ipart] == STAR_TYPE_NORMAL 
                                 || star_particle_type[ipart] == STAR_TYPE_STARII 
                                 || star_particle_type[ipart] == STAR_TYPE_FAST_GROWTH) 
#endif /* STAR_PARTICLE_TYPES */
			) {
				sf_feedback_particle->hydro_feedback(level,iter_cell,ipart,t_next);
			}

			ipart = particle_list_next[ipart];
		}
	}

	cart_free(level_cells);

	end_time( WORK_TIMER );
}
コード例 #26
0
ファイル: smmempnproc.cpp プロジェクト: Joincheng/lithtech
// ------------------------------------------------------------------------
// 
// ------------------------------------------------------------------------
void SmInitMetaModelFromPN( ILTAStream *strm , MetaModel &metaModel, 
						    CParseNode *pnroot, 
							CLTATranslStatus & status  )
{
	// give pnode processors a target
	s_animsetcmd.m_MetaModel   = & metaModel ;
	s_hierarchycmd.m_MetaModel = & metaModel ;
	s_shapecmd.m_MetaModel     = & metaModel ;
	// set up symbol table
	CExecPN::s_ProcFnTable["animset"] = & s_animsetcmd  ;
	CExecPN::s_ProcFnTable["hierarchy"] = & s_hierarchycmd  ;
	CExecPN::s_ProcFnTable["shape"] = & s_shapecmd ;
	
	// apply cmds to tree.
	start_time();
	__BuildParseTree( strm,  pnroot );
	end_time();
}
コード例 #27
0
ファイル: State.cpp プロジェクト: sim642/FLL-timetable
void State::create_rows()
{
	for (auto &block : blocks)
	{
		if (block.parent_name)
		{
			auto it = std::find_if(blocks.begin(), blocks.end(), [&block](const Block &other)
			{
				return other.name == *block.parent_name;
			});
			if (it == blocks.end())
				throw std::runtime_error("State::create_rows: no parent found");
			block.start_time = it->end_time();
		}

		block.create_rows(teams.size());
	}
}
コード例 #28
0
ファイル: rt_transfer.c プロジェクト: sleitner/cart
void rtAfterAssignDensityTransfer(int level, int num_level_cells, int *level_cells)
{
#ifdef RT_VAR_SOURCE
  int i;

#ifdef PARTICLES

  /*
  // If we have a source field that was set inside density(...), 
  // turn the mass per cell into density.
  */
  start_time( WORK_TIMER );

#pragma omp parallel for default(none), private(i), shared(level,num_level_cells,level_cells,cell_vars)
  for(i=0; i<num_level_cells; i++)
    {
      cell_rt_source(level_cells[i]) *= cell_volume_inverse[level];
    }

  end_time( WORK_TIMER );

#else  /* PARTICLES */

#ifdef RT_SINGLE_SOURCE
  /*
  // Set the source field from a single source
  */
  rtTransferAssignSingleSourceDensity(level);
#else  /* RT_SINGLE_SOURCE */

#error "Invalid set of switches: either PARTICLES or RT_SINGLE_SOURCE must be defined."

#endif /* RT_SINGLE_SOURCE */

#endif /* PARTICLES */

#if (RT_TRANSFER_METHOD == RT_METHOD_OTVET)
  /* Need only local cells */
  rtAfterAssignDensityTransferOtvet(level,num_cells_per_level[level],level_cells);
#endif

#endif /* RT_VAR_SOURCE */
}
コード例 #29
0
ファイル: Hes_Emu.cpp プロジェクト: Accusedbold/zdoom
int Hes_Emu::cpu_done()
{
	check( time() >= end_time() ||
			(!(r.status & i_flag_mask) && time() >= irq_time()) );
	
	if ( !(r.status & i_flag_mask) )
	{
		hes_time_t present = time();
		
		if ( irq.timer <= present && !(irq.disables & timer_mask) )
		{
			timer.fired = true;
			irq.timer = future_hes_time;
			irq_changed(); // overkill, but not worth writing custom code
			#if GME_FRAME_HOOK_DEFINED
			{
				unsigned const threshold = period_60hz / 30;
				unsigned long elapsed = present - last_frame_hook;
				if ( elapsed - period_60hz + threshold / 2 < threshold )
				{
					last_frame_hook = present;
					GME_FRAME_HOOK( this );
				}
			}
			#endif
			return 0x0A;
		}
		
		if ( irq.vdp <= present && !(irq.disables & vdp_mask) )
		{
			// work around for bugs with music not acknowledging VDP
			//run_until( present );
			//irq.vdp = future_hes_time;
			//irq_changed();
			#if GME_FRAME_HOOK_DEFINED
				last_frame_hook = present;
				GME_FRAME_HOOK( this );
			#endif
			return 0x08;
		}
	}
	return 0;
}
コード例 #30
-1
void HeaderManipulation::publishMsg(const topic_tools::ShapeShifter &msg, const ros::Time &msg_in_time)
{
    ROS_DEBUG("HeaderManipulation publishMsg Thread started with timestamp %f", msg_in_time.toSec());
    ros::Time end_time(ros::Time::now());
    ros::Time last_time;
    config_mutex_.lock();
    ros::Time time_to_pub(msg_in_time + msg_delay_);
    config_mutex_.unlock();
    do
    {
        last_time = end_time;
        ROS_DEBUG("waiting to publish msg from %f at %f", msg_in_time.toSec(), time_to_pub.toSec());
        if (end_time > time_to_pub)
        {
            boost::mutex::scoped_lock pub_lock(pub_mutex_);
            ROS_DEBUG("publishing msg which should be held back till: %f", time_to_pub.toSec());
            generic_pub_.publish(msg);
            return;
        }
        boost::mutex::scoped_lock config_lock(config_mutex_);
        publish_retry_rate_.sleep();
        time_to_pub = msg_in_time + msg_delay_;
        end_time = ros::Time::now();
    } while (last_time <= end_time);
    ROS_WARN("Detected jump back in time. Dropping msg. last: %f, end %f",
             last_time.toSec(), end_time.toSec());
    return;
}