/*--------------------------------*- 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;                                                      
}                                                                               
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 

sourceTerm                                                                            
{                                                                               
    type            scalarCodedSource;                                                           
    selectionMode   all;                                                          
    fields          (T);                                                         
                                                                                
    // Name of the coded source                                                   
    name            sourceTerm_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                                           
        scalarField& TSource= eqn.source();                                                    
                                                                             
        // Loops over each cell in the domain                                      
        forAll(TSource, 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 = x*x; 
            const scalar tmp1 = y*y; 
            const scalar tmp2 = tmp0 + tmp1; 
            const scalar tmp3 = Foam::cos(tmp2); 
            const scalar solution_T = 0.59999999999999998*tmp0*tmp3 + 0.59999999999999998*tmp1*tmp3 + 0.59999999999999998*Foam::sin(tmp2); 
                                                                            
            TSource[cellI] -= V[cellI]*(solution_T);                                                                            
        };                                                                         
    #};                                                                         
}