Foam::tmp<Foam::Field<Type> >
Foam::meshToPointField<Type, ApproxType, ExtendedStencil>::interpolate
(
    const GeometricField<Type, fvPatchField, volMesh>& vf
) const
{
    if (weights_.size() == 0)
    {
        FatalErrorIn
        (
            "meshToPointField<ApproxType, ExtendedStencil>::interpolate"
        )
            << " points to interpolate onto not set"
            << exit(FatalError);
    }

    // Collect internal and boundary values
    List<List<Type> > stencilFld;
    extendedCellToFaceStencil::collectData
    (
        cellStencil().map(), pointStencil_, vf, stencilFld
    );

    // Declare temporary field to return
    tmp<Field<Type> > tpf(new Field<Type>(pointStencil_.size(), pTraits<Type>::zero));
    Field<Type> & pf = tpf();
    
    forAll(pf, ip)
    {
        const List<Type>& stField = stencilFld[ip];
        const scalarList& stWeight = weights_[ip];

        forAll(stField, i)
        {
            pf[ip] += stWeight[i]*stField[i];
        }
    }
Example #2
0
void TestTools::testProfiles()
{
    TemporaryProfile tpp("parent", m_settings);
    Profile parentProfile = tpp.p;
    TemporaryProfile tpc("child", m_settings);
    Profile childProfile = tpc.p;
    parentProfile.removeBaseProfile();
    parentProfile.remove("testKey");
    QCOMPARE(parentProfile.value("testKey", "none").toString(), QLatin1String("none"));
    parentProfile.setValue("testKey", "testValue");
    QCOMPARE(parentProfile.value("testKey").toString(), QLatin1String("testValue"));

    childProfile.remove("testKey");
    childProfile.removeBaseProfile();
    QCOMPARE(childProfile.value("testKey", "none").toString(), QLatin1String("none"));
    childProfile.setBaseProfile("parent");
    QCOMPARE(childProfile.value("testKey").toString(), QLatin1String("testValue"));

    // Change base profile and check if the inherited value also changes.
    TemporaryProfile tpf("foo", m_settings);
    Profile fooProfile = tpf.p;
    fooProfile.setValue("testKey", "gnampf");
    childProfile.setBaseProfile("foo");
    QCOMPARE(childProfile.value("testKey", "none").toString(), QLatin1String("gnampf"));

    ErrorInfo errorInfo;
    childProfile.setBaseProfile("SmurfAlongWithMe");
    childProfile.value("blubb", QString(), &errorInfo);
    QVERIFY(errorInfo.hasError());

    errorInfo.clear();
    childProfile.setBaseProfile("parent");
    parentProfile.setBaseProfile("child");
    QVERIFY(!childProfile.value("blubb", QString(), &errorInfo).isValid());
    QVERIFY(errorInfo.hasError());

    QVERIFY(!childProfile.allKeys(Profile::KeySelectionNonRecursive).isEmpty());

    errorInfo.clear();
    QVERIFY(childProfile.allKeys(Profile::KeySelectionRecursive, &errorInfo).isEmpty());
    QVERIFY(errorInfo.hasError());
}
    void Texture::update() {
        glBindTexture(GL_TEXTURE_2D, _handle);

        _data.resize(_width * _height * getTypeSize(_type) * getElementCount(_format));
        std::generate(_data.begin(), _data.end(), randbyte);
        glTexImage2D(
            GL_TEXTURE_2D, 0, _internalFormat, _width, _height,
            _border, _format, _type, &_data[0]);

        tpf(GL_TEXTURE_MIN_FILTER, _minFilter);
        tpf(GL_TEXTURE_MAG_FILTER, _magFilter);
        tpf(GL_TEXTURE_MIN_LOD,    _minLOD);
        tpf(GL_TEXTURE_MAX_LOD,    _maxLOD);
        tpi(GL_TEXTURE_BASE_LEVEL, _baseLevel);
        tpi(GL_TEXTURE_MAX_LEVEL,  _maxLevel);
        tpf(GL_TEXTURE_WRAP_S,     _wrapS);
        tpf(GL_TEXTURE_WRAP_T,     _wrapT);
        tpf(GL_TEXTURE_WRAP_R,     _wrapR);
        tpfv(GL_TEXTURE_BORDER_COLOR, _borderColor.getData());
        tpf(GL_TEXTURE_PRIORITY,   _priority);

        glBindTexture(GL_TEXTURE_2D, 0);
    }
Example #4
0
int main(){

	if(config()) printf("system parameters config error!\n");

	/*
	delayMode=0;
	displayMode=1;	//determine information dispay mode
					//0 hide the content of the process loaded to system; 1 show all information 
	reportLevel=2; //0 report Warning and Error, 1 report Normal, Warning and Error, 2 report all
	updateSysfun=0;
	*/
	
	interpreter IM(101,30);
	editor e(103);
	assembler a(102);
	dispatcher os(105,10,30,40);
	storage  sys(106, sysPath[0]);
	storage  disk(107,sysPath[1]);


	//************************************************************************************************************
	//Dont modify this part!
	{	//initialize system
		FILE *fp;	//file pointer used to open code file for system function 
		int i;
		procptr pptr;
		pptr=new process[sysFunNumber];	//create process for system function
		process tp(0,100,10,40,0);	//process template, the code part is large but the data part is very small, with high priority
		
		for(i=0; i<sysFunNumber; i++){
			pptr[i].copy(tp);	//copy template process to each sysfun process
			pptr[i].ID=i;	//give each sysfun a new id(system function call number) 
			
		
			if(updateSysfun==1){	//reassemble sysfun
				sys.getFile(fp, sysFunTable[i],0); //open the function code file
				if(e.ASM(fp,a,sysFunTable[i])!=-1){
					Load(pptr,sysFunTable[i]);
					os.sysCall.put(i,&pptr[i]);	//load the system function to the sysCall list in scheduler
				}
				sys.releaseFile(fp);	//close file
			}
			else{
				Load(pptr,sysFunTable[i]);
				os.sysCall.put(i,&pptr[i]);	//load the system function to the sysCall list in scheduler
			}
	

		}
	}	//throuth this step, all the system function has been load into the system
	//************************************************************************************************************

	//************************************************************************************************************
	{	//load user code to system
		FILE *run;	//file ptr of list file
		FILE *pfr;	//pointer to the code file
		procptr pptr;	//used to create user process
		process tpf(0,100,40,50,1);	//process template, the data part is larger than sysfun, but priority is lower

		int id=50;	//least user proc ID
		char name[50]; //used to code file name
		disk.getFile(run,runList,0);
		fscanf(run,"%s",name);	//read code file name
		while(strcmp(name,"end") && strcmp(name, "END")){ //list file end with "end" or "END"
			disk.getFile(pfr,name,0);	//open code file
			pptr=new process;	//create user process
			pptr->copy(tpf);	//copy template process to each process
			pptr->ID=id++;	//give user process a new id
			printf("process ID:%d\n", pptr->ID);
	
			if(e.ASM(pfr,a,name) != -1){
				Load(pptr,name);
				os.loader(pptr);	//load process to scheduler
			}
			disk.releaseFile(pfr);	//close code file 
			fscanf(run,"%s",name); //read next code file name
		}
		disk.releaseFile(run);	//close list file
	}	//throuth this step, all the user process has been load into the system
	//*************************************************************************************************************

	
	os.swap2(IM);	//swap process to run and wait, when a user process finished, it will be put into finished queue 
	

	//*************************************************************************************************************
	{	//show the finished process data part
		procptr pptr;
		//pcbptr pblock;
		int r=0;
		//r=os.finished.deQueue(pptr); //get a process from finished queue
		r=os.finished.deQueue(pptr);
		
		
		printf("\ndisplay data?(y/n): ");
		char c;
		c=getche();
		putchar('\n');

		
		while(r!=-1){	//finished queue isnt empty
			printf("process ID:%d\n", pptr->ID);
			if(c=='y' || c=='Y'){
				int i;
				printf("memory ID:%d\n",pptr->MData.ID);
				for(i=0; i<pptr->MData.mSize; i++)
				printf("%-4d%d\n",i,pptr->MData.read(i)); //show M.mem[i]
			}
			printf("execute times:%d\n",pptr->exetime);
			r=os.finished.deQueue(pptr);	//get next process
		}
	}
	//*************************************************************************************************************

	//systemChecker.check(RES, sysLog);	//show system end state, normal state is show "queue::deQueue: queue is empty"

	printf("\nPress any key to exit.");
	getch();

	return 0;
}