Example #1
0
void BaseUnitTest() 
{
	bool baseOk = false;
	
    SetConsoleTitle("Unit-Test: base.c/ base.h");
	
	printf("\n\t\t\tTEST BEGINN");
	
	baseOk = BaseInit("G:\\Coding\\buildcfg\\unittest\\base");
	
	if(!baseOk){
		printf("\aDatei konnte nicht geoeffnnet werden\n\n");
		return;
	}
	
	printf("Test der Zeichen-Funktonen:\n\n");
	printf("\t Erstes Zeichen, mit Cur(): %c, Pos: %ld [ \'a\' erwartet, Pos: 0 (\'a\') ]\n", Cur(), ftell( base->datei ) );
	printf("\t Zweites Zeichen mit Next(): %c, Pos: %ld[ \'z\' erwartet, Pos: 0 (\'a\') ]\n", Next(), ftell( base->datei ) );
	printf("\t Zweites Zeichen mit Fwd(): %c, Pos: %ld [\'z\' erwartet, Pos: 0 (\'z\') ]\n", Fwd(), ftell( base->datei) );
	printf("\t Erstes Zeichen mit Last(): %c, Pos: %ld [\'a\' erwartet, Pos: 1 (\'z\') ]\n", Last(), ftell( base->datei) );
	printf("\t Erstes Zeichen mit Rwd(): %c, Pos: %ld [\'a\' erwartet, Pos: 1 (\'a\') ]\n", Rwd(), ftell( base->datei ) );
	printf("\t Erstes Zeichen mit Cur(): %c, Pos: %ld [\'a\' erwartet, Pos: 0 (\'a\') ]\n", Cur(), ftell( base->datei ) );

	printf(" Skip(): ");
	printf("\n\tIn Zeile 2 wechseln.\n\n");
	
	while( Cur() != '\n'){
		Fwd();
	}
	Fwd();
	printf("\n\tSchleife beendet!");
	Skip();
	printf("\n\n\t naechtes Zeichen: %c, Zeile  (F erwartet, in Zeile 13 oder so)\n\n", Cur());
	
	printf(" GetLineCount():\n\n");
	printf("\n\n\t\t200 Zeichen weiter...\n\n");
	
	for(int i = 0; i < 200; i++) Fwd();
	printf("\t\tDatei-Position vorher: %ld\n\n", ftell( base->datei ));
	printf("\t\tDas sollte Zeile: %d sein.\n\n", GetLineCount());
	printf("\t\tUnd das die Position nachher: %ld", ftell( base->datei ));
	printf("\nBaseClose():\n\n");
	BaseClose();
	
	if( base ){
		printf("\t\nBaseClose fehlgeschlagen!\n");
		return;
	}else{
		printf("\t\nBaseClose erfolgreich!\n");
	}
	
	printf("\n\n\t\t\tTEST ABGESCHLOSSEN\n\n");
}
Example #2
0
    void EigenValuesAdvection::v_NumericalFlux(Array<OneD, Array<OneD, NekDouble> > &physfield, Array<OneD, Array<OneD, NekDouble> > &numflux)
    {
        int i;
		
        int nTraceNumPoints = GetTraceNpoints();
        int nvel = m_spacedim; //m_velocity.num_elements();
		
        Array<OneD, NekDouble > Fwd(nTraceNumPoints);
        Array<OneD, NekDouble > Bwd(nTraceNumPoints);
        Array<OneD, NekDouble > Vn (nTraceNumPoints,0.0);		
        
        //Get Edge Velocity - Could be stored if time independent
        for(i = 0; i < nvel; ++i)
        {
            m_fields[0]->ExtractTracePhys(m_velocity[i], Fwd);
            Vmath::Vvtvp(nTraceNumPoints,m_traceNormals[i],1,Fwd,1,Vn,1,Vn,1);
        }
        
        for(i = 0; i < numflux.num_elements(); ++i)
        {
            m_fields[i]->GetFwdBwdTracePhys(physfield[i],Fwd,Bwd);
            m_fields[i]->GetTrace()->Upwind(Vn,Fwd,Bwd,numflux[i]);
            // calculate m_fields[i]*Vn
            Vmath::Vmul(nTraceNumPoints,numflux[i],1,Vn,1,numflux[i],1);
        }
    }
Example #3
0
File: main.cpp Project: CCJY/coliru
int main()
{
    g(NULL);           // Fine
    g(0);              // Fine
 
    Fwd(g, nullptr);   // Fine
//  Fwd(g, NULL);  // ERROR: No function g(int)
}
Example #4
0
int test_nullptr1()
{
	g(NULL);           // Fine
	g(0);              // Fine

	Fwd(g, nullptr);   // Fine
	// Fwd(g, NULL);  // ERROR: No function g(int) // error C2664: “void (int *)”: 无法将参数 1 从“int”转换为“int *”

	int length1 = sizeof(NULL); // x64, length1 = 4
	int length2 = sizeof(nullptr); // x64, length2 = 8

	return 0;
}
Example #5
0
int Skip()
{
	printf("\nSkip()\n");
	while( (!feof(base->datei)) && (Cur() != EOF) ){
		switch( Cur() ){
		
		//Nicht-druckbare Zeichen
		printf("Skip: Loop: Nichts Druckbares!\n");
		case '\t':
		case '\a': 
		case '\b':
		case '\f':
		case '\v':
		case '\r':
		case '\n':
		case ' ':
			Fwd();
			break;
			
		case '/':	//Kommentar (//)
			printf("Skip Loop: Kommentar!\n");
			if( Next() == '/')	//Kommentar oder doch nur ein einzelner Backslash?
				while( (!feof(base->datei) && (Cur() != EOF)) && (Cur() != '\n') ) Fwd(); //Zur Nächsten Zeile gehen.
			else
				return 0;
			break;
		
		case EOF:
			printf("Skip Loop: EOF");
			return 1;
		
		default:
			printf("Skip() beendet, gefundenes Zeichen %c\n", Cur());
			return 0; 
		}
	}
	printf("Skip beendet, EOF!");
	return 1; 
}
Example #6
0
    /**
     *  Calculates the third term of the weak form (1): numerical flux
     *  at boundary \f$ \left[ \mathbf{\psi}^{\delta} \cdot \{
     *  \mathbf{F}^u - \mathbf{F}(\mathbf{U}^{\delta}) \}
     *  \right]_{x_e^l}^{x_eû} \f$
     */
    void PulseWavePropagation::v_NumericalFlux(Array<OneD, Array<OneD, NekDouble> > &physfield, 
                                               Array<OneD, Array<OneD, NekDouble> > &numflux)
    {		
        int i;
        int nTracePts = GetTraceTotPoints();
        
        Array<OneD, Array<OneD, NekDouble> > Fwd(m_nVariables);
        Array<OneD, Array<OneD, NekDouble> > Bwd(m_nVariables);
        
        for (i = 0; i < m_nVariables; ++i)
        {
            Fwd[i] = Array<OneD, NekDouble>(nTracePts);
            Bwd[i] = Array<OneD, NekDouble>(nTracePts);
        }
	
        // Get the physical values at the trace
        for (i = 0; i < m_nVariables; ++i)
        {
            m_vessels[m_currentDomain*m_nVariables+ i]->
                GetFwdBwdTracePhys(physfield[i],Fwd[i],Bwd[i]);
        }
        
        // Solve the upwinding Riemann problem within one arterial
        // segment by calling the upwinding Riemann solver implemented
        // in this file
        NekDouble Aflux, uflux;
        for (i = 0; i < nTracePts; ++i)
        {
            switch(m_upwindTypePulse)
            {
            case eUpwindPulse:
                {
                    RiemannSolverUpwind(Fwd[0][i],Fwd[1][i],Bwd[0][i],Bwd[1][i],
                                        Aflux, uflux, m_A_0_trace[m_currentDomain][i],
                                        m_beta_trace[m_currentDomain][i],
                                        m_trace_fwd_normal[m_currentDomain][i]);
                }
                break;
            default:
                {
                    ASSERTL0(false,"populate switch statement for upwind flux");
                }
                break;
            }
            numflux[0][i] = Aflux;
            numflux[1][i] = uflux;
        }
    }
Example #7
0
    /**
     * Calcualate numerical fluxes
     */
    void IncNavierStokes::v_NumericalFlux(Array<OneD, Array<OneD, NekDouble> > &physfield, 
                                          Array<OneD, Array<OneD, NekDouble> > &numflux)
    {
        /// Counter variable
        int i;

        /// Number of trace points
        int nTracePts   = GetTraceNpoints();
        
        /// Number of spatial dimensions
        int nDimensions = m_spacedim;

        /// Forward state array
        Array<OneD, NekDouble> Fwd(2*nTracePts);
        
        /// Backward state array
        Array<OneD, NekDouble> Bwd = Fwd + nTracePts;
        
        /// Normal velocity array
        Array<OneD, NekDouble> Vn (nTracePts, 0.0);
        
        // Extract velocity field along the trace space and multiply by trace normals
        for(i = 0; i < nDimensions; ++i)
        {
            m_fields[0]->ExtractTracePhys(m_fields[m_velocity[i]]->GetPhys(), Fwd);
            Vmath::Vvtvp(nTracePts, m_traceNormals[i], 1, Fwd, 1, Vn, 1, Vn, 1);
        }

        /// Compute the numerical fluxes at the trace points
        for(i = 0; i < numflux.num_elements(); ++i)
        {
            /// Extract forwards/backwards trace spaces
            m_fields[i]->GetFwdBwdTracePhys(physfield[i], Fwd, Bwd);

            /// Upwind between elements
            m_fields[i]->GetTrace()->Upwind(Vn, Fwd, Bwd, numflux[i]);

            /// Calculate the numerical fluxes multipling Fwd or Bwd
            /// by the normal advection velocity
            Vmath::Vmul(nTracePts, numflux[i], 1, Vn, 1, numflux[i], 1);
        }
    }
Example #8
0
int GetLineCount()
{
	int ret = 0;
	long int curP = ftell( base->datei );

	
	// Alle \n vom Dateinfang bis zur aktuellen Position zählen.
	
	rewind( base->datei ); 
	
	for( int i = 0; i < curP; i++){
		if( Cur() == '\n')
			ret++;
		
		Fwd();
	}
	
	//Dateizeiger wieder zur usrprünglichen positin
	fseek( base->datei, curP, SEEK_SET );
	return ret;
}
Example #9
0
/**
 * @brief Wall boundary conditions for the APE equations.
 */
void APE::WallBC(int bcRegion, int cnt,
                 Array<OneD, Array<OneD, NekDouble> > &physarray)
{
    int nTracePts = GetTraceTotPoints();
    int nVariables = physarray.num_elements();

    const Array<OneD, const int> &traceBndMap = m_fields[0]->GetTraceBndMap();

    // Get physical values of the forward trace
    Array<OneD, Array<OneD, NekDouble> > Fwd(nVariables);
    for (int i = 0; i < nVariables; ++i)
    {
        Fwd[i] = Array<OneD, NekDouble>(nTracePts);
        m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
    }

    // Adjust the physical values of the trace to take
    // user defined boundaries into account
    int id1, id2, nBCEdgePts;
    int eMax = m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();

    for (int e = 0; e < eMax; ++e)
    {
        nBCEdgePts = m_fields[0]->GetBndCondExpansions()[bcRegion]->
                GetExp(e)->GetTotPoints();
        id1 = m_fields[0]->GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e);
        id2 = m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[cnt+e]);

        // For 2D/3D, define: v* = v - 2(v.n)n
        Array<OneD, NekDouble> tmp(nBCEdgePts, 0.0);

        // Calculate (v.n)
        for (int i = 0; i < m_spacedim; ++i)
        {
            Vmath::Vvtvp(nBCEdgePts,
                         &Fwd[1+i][id2], 1,
                         &m_traceNormals[i][id2], 1,
                         &tmp[0], 1,
                         &tmp[0], 1);
        }

        // Calculate 2.0(v.n)
        Vmath::Smul(nBCEdgePts, -2.0, &tmp[0], 1, &tmp[0], 1);

        // Calculate v* = v - 2.0(v.n)n
        for (int i = 0; i < m_spacedim; ++i)
        {
            Vmath::Vvtvp(nBCEdgePts,
                         &tmp[0], 1,
                         &m_traceNormals[i][id2], 1,
                         &Fwd[1+i][id2], 1,
                         &Fwd[1+i][id2], 1);
        }

        // Copy boundary adjusted values into the boundary expansion
        for (int i = 0; i < nVariables; ++i)
        {
            Vmath::Vcopy(nBCEdgePts,
                         &Fwd[i][id2], 1,
                         &(m_fields[i]->GetBndCondExpansions()[bcRegion]->UpdatePhys())[id1], 1);
        }
    }
}
Example #10
0
 void DiffusionLDG::v_NumFluxforVector(
     const Array<OneD, MultiRegions::ExpListSharedPtr>        &fields,
     const Array<OneD, Array<OneD, NekDouble> >               &ufield,
           Array<OneD, Array<OneD, Array<OneD, NekDouble> > > &qfield,
           Array<OneD, Array<OneD, NekDouble> >               &qflux)
 {
     int i, j;
     int nTracePts  = fields[0]->GetTrace()->GetTotPoints();
     int nvariables = fields.num_elements();
     int nDim       = qfield.num_elements();
     
     NekDouble C11 = 0.0;
     Array<OneD, NekDouble > Fwd(nTracePts);
     Array<OneD, NekDouble > Bwd(nTracePts);
     Array<OneD, NekDouble > Vn (nTracePts, 0.0);
     
     Array<OneD, NekDouble > qFwd     (nTracePts);
     Array<OneD, NekDouble > qBwd     (nTracePts);
     Array<OneD, NekDouble > qfluxtemp(nTracePts, 0.0);
     
     Array<OneD, NekDouble > uterm(nTracePts);
     
     /*
     // Setting up the normals
     m_traceNormals = Array<OneD, Array<OneD, NekDouble> >(nDim);
     for(i = 0; i < nDim; ++i)
     {
         m_traceNormals[i] = Array<OneD, NekDouble> (nTracePts);
     }
     fields[0]->GetTrace()->GetNormals(m_traceNormals);
     */
     
     // Get the normal velocity Vn
     for(i = 0; i < nDim; ++i)
     {
         Vmath::Svtvp(nTracePts, 1.0, m_traceNormals[i], 1, 
                      Vn, 1, Vn, 1);
     }
     
     // Evaulate upwind flux:
     // qflux = \hat{q} \cdot u = q \cdot n - C_(11)*(u^+ - u^-)
     for (i = 0; i < nvariables; ++i)
     {
         qflux[i] = Array<OneD, NekDouble> (nTracePts, 0.0);
         for (j = 0; j < nDim; ++j)
         {
             //  Compute Fwd and Bwd value of ufield of jth direction
             fields[i]->GetFwdBwdTracePhys(qfield[j][i], qFwd, qBwd);
             
             // if Vn >= 0, flux = uFwd, i.e.,
             // edge::eForward, if V*n>=0 <=> V*n_F>=0, pick 
             // qflux = qBwd = q+
             // edge::eBackward, if V*n>=0 <=> V*n_B<0, pick 
             // qflux = qBwd = q-
             
             // else if Vn < 0, flux = uBwd, i.e.,
             // edge::eForward, if V*n<0 <=> V*n_F<0, pick 
             // qflux = qFwd = q-
             // edge::eBackward, if V*n<0 <=> V*n_B>=0, pick 
             // qflux = qFwd = q+
             
             fields[i]->GetTrace()->Upwind(/*m_traceNormals[j]*/Vn, 
                                           qBwd, qFwd, 
                                           qfluxtemp);
             
             Vmath::Vmul(nTracePts, 
                         m_traceNormals[j], 1, 
                         qfluxtemp, 1, 
                         qfluxtemp, 1);
             
             // Generate Stability term = - C11 ( u- - u+ )
             fields[i]->GetFwdBwdTracePhys(ufield[i], Fwd, Bwd);
             
             Vmath::Vsub(nTracePts, 
                         Fwd, 1, Bwd, 1, 
                         uterm, 1);
             
             Vmath::Smul(nTracePts, 
                         -1.0 * C11, uterm, 1, 
                         uterm, 1);
             
             // Flux = {Fwd, Bwd} * (nx, ny, nz) + uterm * (nx, ny)
             Vmath::Vadd(nTracePts, 
                         uterm, 1, 
                         qfluxtemp, 1, 
                         qfluxtemp, 1);
             
             // Imposing weak boundary condition with flux
             if (fields[0]->GetBndCondExpansions().num_elements())
             {
                 v_WeakPenaltyforVector(fields, i, j, 
                                        qfield[j][i], 
                                        qfluxtemp, C11);
             }
             
             // q_hat \cdot n = (q_xi \cdot n_xi) or (q_eta \cdot n_eta)
             // n_xi = n_x * tan_xi_x + n_y * tan_xi_y + n_z * tan_xi_z
             // n_xi = n_x * tan_eta_x + n_y * tan_eta_y + n_z*tan_eta_z
             Vmath::Vadd(nTracePts, 
                         qfluxtemp, 1, 
                         qflux[i], 1, 
                         qflux[i], 1);
         }
     }
 }