/*--------------------------------*- C++ -*----------------------------------*\ 
| =========                 |                                                |  
| \      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           | 
|  \    /   O peration     | Version:  v2012                                 | 
|   \  /    A nd           | Website:  www.openfoam.com                      | 
|    \/     M anipulation  |                                                 | 
\*---------------------------------------------------------------------------*/ 
FoamFile                                                                        
{                                                                               
    version     2.0;                                                            
    format      ascii;                                                          
    class       dictionary;                                                     
    object      fvOptions;                                                      
}                                                                               
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 

momentumSource                                                                            
{                                                                               
    type            vectorCodedSource;                                                           
    selectionMode   all;                                                          
    fields          (U);                                                         
                                                                                
    // Name of the coded source                                                   
    name            momentumSource_2;                                                           
                                                                                
    codeInclude                                                                   
    #{                                                                            
        // Info: Include necessary libraries for calculation                        
    #};                                                                           
                                                                                
    codeCorrect                                                                   
    #{                                                                            
        // Info: Apply corrections after the equation has been solved               
    #};                                                                           
                                                                                
    codeConstrain                                                                 
    #{                                                                            
        // Info: Constrain values before the equation is solved                     
    #};                                                                           

    codeAddSup                                                                   
    #{                                                                          
        // Gets the cell volumes of the mesh                                       
        const scalarField& V = mesh_.V();                                          
                                                                               
        // Gets the vector containing cell center position of the mesh             
        const volVectorField& C = mesh().C();                                      
                                                                               
        // Gets the equation source term                                           
        vectorField& USource= eqn.source();                                                    
                                                                             
        // Loops over each cell in the domain                                      
        forAll(USource, cellI)                                                         
        {                                                                         
            // Gets the x component of the current cell 
            const scalar x = C[cellI].x(); 

            //Gets the y component of the current cell 
            const scalar y = C[cellI].y(); 
                                                                             
            const scalar tmp0 = Foam::pow(M_PI, 2); 
            const scalar tmp1 = 2*M_PI; 
            const scalar tmp2 = tmp1*y; 
            const scalar tmp3 = 2.5*Foam::sqrt(0.64000000000000001*tmp0 + 1); 
            const scalar tmp4 = 2.5 - tmp3; 
            const scalar tmp5 = tmp4*x; 
            const scalar tmp6 = Foam::exp(tmp5); 
            const scalar tmp7 = tmp6*Foam::cos(tmp2); 
            const scalar tmp8 = 5.0 - 2*tmp3; 
            const scalar tmp9 = Foam::sin(tmp2); 
            const scalar tmp10 = tmp4*tmp4; 
            const scalar tmp11 = tmp10*tmp7; 
            const scalar tmp12 = 0.050000000000000003 - 0.02*tmp3; 
            const scalar tmp13 = tmp4*tmp7; 
            const scalar tmp14 = tmp7 - 1; 
            const scalar tmp15 = M_1_PI; 
            const scalar tmp16 = (1.0/2.0)*tmp15; 
            const scalar solution_U_1 = -0.040000000000000001*tmp0*tmp7 - 0.01*tmp11 + tmp12*tmp13 + tmp13*tmp14 + tmp4*Foam::exp(2*tmp5)*(tmp9*tmp9) - 0.5*tmp8*Foam::exp(tmp8*x); 
            const scalar solution_U_2 = tmp6*tmp9*(tmp1*tmp12 - tmp10*tmp14*tmp16 + tmp11*tmp16 - 0.0050000000000000001*tmp15*tmp4*tmp4*tmp4 - 0.02*M_PI*tmp4); 
            const scalar solution_U_3 = 0; 
                                                                            

            const vector solution (solution_U_1, solution_U_2, solution_U_3); 
            USource[cellI] -= V[cellI]*solution; 
                                                                            
        };                                                                         
    #};                                                                         
}                                                                             