Ejemplo n.º 1
0
tmp<scalarField> faMatrix<scalar>::residual() const
{
    scalarField boundaryDiag(psi_.size(), 0.0);
    addBoundaryDiag(boundaryDiag, 0);

    // Make a copy of interfaces: no longer a reference
    // HJ, 20/Nov/2007
    lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces();

    tmp<scalarField> tres
    (
        lduMatrix::residual
        (
            psi_.internalField(),
            source_ - boundaryDiag*psi_.internalField(),
            boundaryCoeffs_,
            interfaces,
            0
        )
    );

    addBoundarySource(tres());

    return tres;
}
Foam::tmp<Foam::Field<Type> > Foam::fvMatrix<Type>::residual() const
{
    // Complete matrix assembly.  HJ, 17/Apr/2012
    fvMatrix& m = const_cast<fvMatrix&>(*this);
    m.completeAssembly();

    // Bug fix: Creating a tmp out of a const reference will change the field
    // HJ, 15/Apr/2011
    tmp<Field<Type> > tres(new Field<Type>(source_));
    Field<Type>& res = tres();

    addBoundarySource(res);

    // Make a copy of interfaces: no longer a reference
    // HJ, 20/Nov/2007
    lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces();

    // Loop over field components
    for (direction cmpt = 0; cmpt < Type::nComponents; cmpt++)
    {
        scalarField psiCmpt = psi_.internalField().component(cmpt);

        scalarField boundaryDiagCmpt(psi_.size(), 0);
        addBoundaryDiag(boundaryDiagCmpt, cmpt);

        FieldField<Field, scalar> bouCoeffsCmpt
        (
            boundaryCoeffs_.component(cmpt)
        );

        res.replace
        (
            cmpt,
            lduMatrix::residual
            (
                psiCmpt,
                res.component(cmpt) - boundaryDiagCmpt*psiCmpt,
                bouCoeffsCmpt,
                interfaces,
                cmpt
            )
        );
    }

    return tres;
}
Ejemplo n.º 3
0
int main() {
	int unidad = DETECT, modo,i,Vert,Horiz,Boton;
	MOUSE mouse;
	void uno(MOUSE &),dos(MOUSE &);
	void tres(MOUSE &),cuatro(MOUSE &),cinco(MOUSE &);
	void EscribirMenu(MOUSE &);

	mouse.Inicializar();

	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	if (graphresult() != 0) {
		cout << "Error al tratar de pasar al modo grafico\n";
		getch();
		return 1;
	}
	mouse.Mostrar();
		
		EscribirMenu(mouse);
		Boton = 0;
		while (Boton != DERECHO) {
			Boton = mouse.Estado(&Vert, &Horiz);
			if (Boton == IZQUIERDO) {
					if (Horiz >= 50 && Horiz <= 59) {
						uno(mouse);
						EscribirMenu(mouse);
					}
					else if (Horiz >= 60 && Horiz <= 69) {
						dos(mouse);
						EscribirMenu(mouse);
					}
					else if (Horiz >= 70 && Horiz <= 79) {
						tres(mouse);
						EscribirMenu(mouse);
					}
					else if (Horiz >= 80 && Horiz <= 89) {
						cuatro(mouse);
						EscribirMenu(mouse);
					}
					else if (Horiz >= 90 && Horiz <= 99) {
						cinco(mouse);
						EscribirMenu(mouse);
					}
				mouse.LibBotones();
			}
		}

	closegraph();
	return 0;
}
Ejemplo n.º 4
0
Foam::tmp<Foam::Field<Type>> Foam::fvMatrix<Type>::residual() const
{
    tmp<Field<Type>> tres(new Field<Type>(source_));
    Field<Type>& res = tres();

    addBoundarySource(res);

    // Loop over field components
    for (direction cmpt=0; cmpt<Type::nComponents; cmpt++)
    {
        scalarField psiCmpt(psi_.internalField().component(cmpt));

        scalarField boundaryDiagCmpt(psi_.size(), 0.0);
        addBoundaryDiag(boundaryDiagCmpt, cmpt);

        FieldField<Field, scalar> bouCoeffsCmpt
        (
            boundaryCoeffs_.component(cmpt)
        );

        res.replace
        (
            cmpt,
            lduMatrix::residual
            (
                psiCmpt,
                res.component(cmpt) - boundaryDiagCmpt*psiCmpt,
                bouCoeffsCmpt,
                psi_.boundaryField().scalarInterfaces(),
                cmpt
            )
        );
    }

    return tres;
}
Ejemplo n.º 5
0
Foam::tmp<Foam::scalarField> Foam::fvMatrix<Foam::scalar>::residual() const
{
    scalarField boundaryDiag(psi_.size(), 0.0);
    addBoundaryDiag(boundaryDiag, 0);

    tmp<scalarField> tres
    (
        lduMatrix::residual
        (
            psi_.primitiveField(),
            source_ - boundaryDiag*psi_.primitiveField(),
            boundaryCoeffs_,
            psi_.boundaryField().scalarInterfaces(),
            0
        )
    );

    addBoundarySource(tres.ref());

    return tres;
}
Ejemplo n.º 6
0
 tmode(const std::string& id, int width, int height)
     : id(id)
     , res(tres(width, height))
 {}
Ejemplo n.º 7
0
	loop2(TypBin, ptBin, nCorrTyp, nPtBins)
	{

		float pt1 = PtRes::PtBinLow(  ptBin);
		float pt2 = PtRes::PtBinHigh( ptBin);

		gStyle->SetOptStat(0);

		double nEntries = RelDiffPt[TypBin][ptBin]->Integral();
		RelDiffPt[TypBin][ptBin]->Scale(1./nEntries);

		RelDiffPt_Func[TypBin][ptBin]->SetParameter(1, 0.0);
		RelDiffPt_Func[TypBin][ptBin]->SetParameter(2, 0.1);
		RelDiffPt[TypBin][ptBin]->Fit( RelDiffPt_Func[TypBin][ptBin] );

		TCanvas canv ("canv",";lel;",1024,768);

		canv.SetLeftMargin  ( RelDiffPt_leftmargin   );
		canv.SetRightMargin ( RelDiffPt_rightmargin  );
		canv.SetTopMargin   ( RelDiffPt_topmargin    );
		canv.SetBottomMargin( RelDiffPt_bottommargin );

		RelDiffPt[TypBin][ptBin]->SetTitle("");
		//RelDiffPt[TypBin][ptBin]->GetXaxis()->CenterTitle(1);
		RelDiffPt[TypBin][ptBin]->GetXaxis()->SetTitleSize( RelDiffPt_xlabelsize );
		RelDiffPt[TypBin][ptBin]->GetXaxis()->SetTitle( "x = #frac{p_{T}^{reco}-p_{T}^{gen}}{p_{T}^{gen}}" );
		RelDiffPt[TypBin][ptBin]->GetYaxis()->SetTitleSize( RelDiffPt_ylabelsize );
		RelDiffPt[TypBin][ptBin]->GetYaxis()->SetTitle( "occurance" );
		RelDiffPt[TypBin][ptBin]->SetTitleOffset( RelDiffPt_xlabeloffset ,"X");
		RelDiffPt[TypBin][ptBin]->SetTitleOffset( RelDiffPt_ylabeloffset ,"Y");
		RelDiffPt[TypBin][ptBin]->GetYaxis()->CenterTitle(1);

		double amp   = abs(RelDiffPt_Func[TypBin][ptBin]->GetParameter(0));
		double x0    = abs(RelDiffPt_Func[TypBin][ptBin]->GetParameter(1));
		double sigma = abs(RelDiffPt_Func[TypBin][ptBin]->GetParameter(2));

		double amp_Err   = abs(RelDiffPt_Func[TypBin][ptBin]->GetParError(0));
		double x0_Err    = abs(RelDiffPt_Func[TypBin][ptBin]->GetParError(1));
		double sigma_Err = abs(RelDiffPt_Func[TypBin][ptBin]->GetParError(2));

		RelDiffPtSigma[TypBin][ptBin] = sigma; 
		RelDiffPtMean [TypBin][ptBin] = x0;

		(*PtResolutionParams[TypBin][ptBin])[0] = sigma;
		(*PtResolutionParams[TypBin][ptBin])[1] = x0;

		TLatex tres( RelDiffPt_tres_upperleftposx, RelDiffPt_tres_upperleftposy , Form("#splitline{#splitline{amp = %.3f #pm %.3f}{x_{0} = %.3f #pm %.3f}}{#sigma = %.3f #pm %.3f}", amp, amp_Err, x0, x0_Err, sigma, sigma_Err) ); 
		tres.SetTextSize( RelDiffPt_figuretextsize );
		tres.SetNDC(kTRUE);

		TLatex ttype( RelDiffPt_ttype_upperleftposx, RelDiffPt_ttype_upperleftposy , Form("#splitline{%s}{p_{T} = [%.2f - %.2f] GeV/c}", particletype(TypBin).c_str(), pt1, pt2 ) ); 
		ttype.SetTextSize( RelDiffPt_figuretextsize );
		ttype.SetNDC(kTRUE);


		RelDiffPt[TypBin][ptBin]->Draw("");
		tres.Draw();
		ttype.Draw();

		std::string dir   = Form("./figures/");
		std::string filePDF = Form("PtRelDiff_%d_pt_%.2f-%.2f.pdf", TypBin, pt1, pt2);
		std::string filePNG = Form("PtRelDiff_%d_pt_%.2f-%.2f.png", TypBin, pt1, pt2);

		std::string figurePNG = dir+filePNG;
		std::string figurePDF = dir+filePDF;

		canv.SaveAs( figurePNG.c_str() );
		canv.SaveAs( figurePDF.c_str() );

		canv.Clear();

	}
Ejemplo n.º 8
0
std::string Date::dateToString(Date date) {
	int i = 0;
	int ptr = 0;
	char tstr[20];
	// year
	int tyear = date.year_;
	tstr[0] = tyear / 1000 + '0';
	tyear = tyear % 1000;
	tstr[1] = tyear / 100 + '0';
	tyear = tyear % 100;
	tstr[2] = tyear / 10 + '0';
	tyear = tyear % 10;
	tstr[3] = tyear + '0';
	tstr[4] = '-';
	// month
	int tmonth = date.month_;
	if (tmonth / 10 < 1) {
		tstr[5] = '0';
		tstr[6] = tmonth + '0';
		tstr[7] = '-';
	} else {
		tstr[5] = tmonth / 10 + '0';
		tstr[6] = tmonth % 10 + '0';
		tstr[7] = '-';
	}
	// day
	int tday = date.day_;
	if (tday / 10 < 1) {
		tstr[8] = '0';
		tstr[9] = tday + '0';
		tstr[10] = '/';
	} else {
		tstr[8] = tday / 10 + '0';
		tstr[9] = tday % 10 + '0';
		tstr[10] = '/';
	}
	// hour
	int thour = date.hour_;
	if (thour / 10 < 1) {
		tstr[11] = '0';
		tstr[12] = thour + '0';
		tstr[13] = ':';
	} else {
		tstr[11] = thour / 10 + '0';
		tstr[12] = thour % 10 + '0';
		tstr[13] = ':';
	}
	// minute
	int tmin = date.minute_;
	if (tmin / 10 < 1) {
		tstr[14] = '0';
		tstr[15] = tmin + '0';
	} else {
		tstr[14] = tmin / 10 + '0';
		tstr[15] = tmin % 10 + '0';
	}
	// over
	tstr[16] = '\0';
	std::string tres(tstr);
	return tres;
}