Example #1
0
/*---------------------------------------------------
 * The main loop for the simulation
 * ------------------------------------------------*/
void jobbody()
{
	int j, ik, iv, nc, ns, iStep;
	double dtc;

	void RKtvd3(int ik, double dt);
	void gettherm(int nc, double **q, double **qs, double *p,
			      double *t, double *gam1, double *rgas1, double *cv1);
	void gettrans(int nc, double **qs, double *t, double *gam1,
				  double *cv1, double *mu, double *cond, double **diff);
	double getdt(int step);
	void saveData(int step);
	void saveDataT(double time);
	FILE *outId, *fp;

	outId = fopen("outInfo.dat", "a");
	fp = fopen("evoData.dat", "w");

	Ttot = config2.t0;
	nc = config1.Nc;

	gettherm(nc, U.q, U.qs, U.pre, U.tem, U.gam, U.rg, U.cv);
	gettrans(nc, U.qs, U.tem, U.gam, U.cv, U.mu, U.kt, U.di);

	config1.SamplesT = 1;

	for(iStep = config1.iStep0; iStep <= config1.nStep; iStep++)
	{
		/* 1. Preserve the last time step solution */
		for(j = 0; j<nc; j++)
		{
			for(iv = 0; iv<neqv; iv++)
				qo[j][iv] = U.q[j][iv];

			if(config1.gasModel != 0)
				for(ns = 0; ns<config1.nspec; ns++)
					qso[j][ns] = U.qs[j][ns];
	    }

		/* 2. Calculate time step */
		dtc = getdt(iStep);

		/* 3. Rung-kutta iteration */
		for(ik = 0; ik < timeOrder; ik++)
		{
			RKtvd3(ik, dtc);
			gettherm(nc, U.q, U.qs, U.pre, U.tem, U.gam, U.rg, U.cv);
			gettrans(nc, U.qs, U.tem, U.gam, U.cv, U.mu, U.kt, U.di);
		}

		/* 4. Output result */
		Ttot = Ttot + dtc*tref;
		//Ttot = Ttot + dtc;
		if(iStep % 50 == 0)
			printf("iStep: %d / total: %d\n", iStep, config1.nStep);
		if(iStep % config1.Samples == 0)
		{
			fprintf(outId, "istep = %d, flow_time = %e s. \n", iStep, Ttot);
			saveData(iStep);
		}


		if(iStep % config1.SamplesT == 0)
		{
			saveDataT(Ttot);
		}
	}
	printf("simulation complete! \n");
	fprintf(outId,"\n nStep = %d\n", config1.nStep);
	fprintf(outId," Actual flow time = %e \n", Ttot);
	fclose(outId);
	fclose(fp);
}
Example #2
0
static int
GII_fmouse_handler(gii_input *inp, gii_event *event)
{
	fmouse_priv   *priv = inp->priv;
	mapping_entry *entry;
	int ret = 0;
	int has = 0;
	int invalue=0;
	static int di_sent=0;
	gii_pmove_event pmrel,pmabs;
	
	/* Did we already send the device info record ? Do so, if we didn't. */
	if (di_sent==0) { 
		di_sent=1;
		send_devinfo(inp); 
	}
	
	DPRINT_MISC("filter-mouse: Filt check.\n");
	if (event->any.origin==inp->origin) 
		return 0;	/* avoid recursion ! */
	DPRINT_MISC("filter-mouse: Real check.\n");

	/* Track modifiers. This allows to use stuff like shift-clicking */
	if (event->any.type==evKeyPress  ||
	    event->any.type==evKeyRepeat ||
	    event->any.type==evKeyRelease) {
		priv->modifiers=event->key.modifiers;
	}

	/* Clear the eventual relative and absolute events that will 
	 * get sent after evaluating all rules. We should probably keep the
	 * absolute events between calls.
	 */
	_giiEventBlank((gii_event *)&pmrel, sizeof(gii_pmove_event));
	pmrel.type = evPtrRelative;
	pmrel.size = sizeof(gii_pmove_event);
	pmrel.origin = inp->origin;
	pmrel.target = GII_EV_TARGET_ALL;
	pmrel.x = pmrel.y = pmrel.z = pmrel.wheel = 0;

	_giiEventBlank((gii_event *)&pmabs, sizeof(gii_pmove_event));
	pmabs.type = evPtrAbsolute;
	pmabs.size = sizeof(gii_pmove_event);
	pmabs.origin = inp->origin;
	pmabs.target = GII_EV_TARGET_ALL;
	pmabs.x = pmabs.y = pmabs.z = pmabs.wheel = 0;

	/* Now go through the entries and convert as appropriate.
	 */
	for(entry = priv->entry;entry;entry = entry->next) {


		DPRINT_MISC("filter-mouse: Checking entry %p.\n",entry);
		if ((priv->modifiers&entry->modifier_mask)!=
		    entry->modifier_value) continue;	/* Modifiers are wrong. Forget it. */

		switch(entry->from) {
			case MAP_KEY: 
				if (event->any.type==evKeyPress||
				    event->any.type==evKeyRepeat) invalue=1;	/* Key press */
				else if (event->any.type==evKeyRelease) invalue=0;	/* Key release*/
				else continue;					/* Something else - forget it. */

				/* Continue, if the button/label/symbol doesn't match */
				if (entry->fromdata.key.button!=GIIK_NIL&&
				    entry->fromdata.key.button!=event->key.button) continue;
				if (entry->fromdata.key.label!=GIIK_NIL&&
				    entry->fromdata.key.label!=event->key.label) continue;
				if (entry->fromdata.key.symbol!=GIIK_NIL&&
				    entry->fromdata.key.symbol!=event->key.sym) continue;
				break;
			case MAP_REL:
				if (event->any.type==evPtrRelative) 
					invalue=getaxis(&event->pmove,entry->fromdata.axis);
				else continue;
				break;
			case MAP_ABS:
				if (event->any.type==evPtrAbsolute) 
					invalue=getaxis(&event->pmove,entry->fromdata.axis);
				else continue;
				break;
			case MAP_BUTTON:
				if (event->any.type==evPtrButtonPress &&
				    event->pbutton.button==entry->fromdata.button) invalue=1;
				else if (event->any.type==evPtrButtonRelease &&
				    event->pbutton.button==entry->fromdata.button) invalue=0;
				else continue;
				break;
			default:continue;	/* Something is wrong */
		}
		switch(entry->to) {
			case MAP_REL:
				setaxis(&pmrel, 
					entry->todata.trans.axis, 
					gettrans(&entry->todata.trans,
						(double)invalue));
				ret=1;has|=HASREL;
				break;
			case MAP_ABS:
				setaxis(&pmabs, 
					entry->todata.trans.axis, 
					gettrans(&entry->todata.trans, 
						(double)invalue));
				ret = 1;
				has |= HASABS;
				break;
			case MAP_BUTTON:
				fmouse_send_pbutton(inp, 
					invalue ? evPtrButtonPress :
						evPtrButtonRelease,
					entry->todata.button);
				ret = 1;
				break;
			default:
				continue; /* Something is WRONG here. */
		}
	}
	DPRINT_MISC("filter-mouse: Checking entry %p.\n",entry);

	if (has&HASABS) {
		_giiEvQueueAdd(inp, (gii_event *) &pmabs);
	}
	if (has&HASREL) {
		_giiEvQueueAdd(inp, (gii_event *) &pmrel);
	}
	
	if (ret) DPRINT_MISC("filter-mouse: Eating event.\n");

	return ret;
}