分区网格的一小段代码


  • 管理员

    codedSource
    {
        type            vectorCodedSource;
        selectionMode   cellZone;
        cellZone        BANANA;
    
        fields          (U);
        name            codedSource;
    	
        codeAddSup
        #{  
        	        const label cellZoneID = mesh().cellZones().findZoneID("BANANA"); // find ID for the cellZone "BANANA"
    		const cellZone& zone = mesh().cellZones()[cellZoneID];
    		const cellZoneMesh& zoneMesh = zone.zoneMesh();
    		const labelList& cellsZone = zoneMesh[cellZoneID]; //list of all cellZone cell ID's  
                    
                    const scalarField& V = mesh_.V(); // Cell volume
                     
                    Foam::Field<Foam::Vector<double> >& USource = eqn.source(); // get source from fvMatrix
    		//scalarField & Udiag = eqn.diag(); // get diagonal of fvMatrix
                    
                    const scalarField& rho = mesh().lookupObject<scalarField>("rho"); // get density field
                  
                    const vector g (0,-9.81,0)      // gravitational vector
    
    
                    forAll(cellsZone,i)
    			{
            		const label celli = cellsZone[i];
    			
    			USource[celli] -= rho[celli]*g/V[celli];
    			}
        #};
        
        codeCorrect
        #{
        Pout<< "**codeCorrect**" << endl;
        
        #};
        codeSetValue
        #{
        Pout<< "**codeSetValue**" << endl;
        #};  
        code
        #{
                $codeInclude
                $codeCorrect
                $codeAddSup
                $codeSetValue
        #};
    


  • Hi,东岳大佬,请教下openfoam里可以实现分区网格计算,比如两个分区,并设置interface boundary condition来coupling这两个区域吗?如果可以,麻烦给点思路,谢谢。
    我暂时想到的只有fluid-solid interaction,即FSI toolbox in Foam-extend,改写solid domain为fluid-fluid interaction,来实现,不过有些繁琐了。

    BR,
    Shiyu


Log in to reply
 


CFD中文网 | 东岳流体学术 | 东岳流体商业 | 吉ICP备20003622号-1