CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Impose Pressure to cellSet

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 18, 2016, 10:45
Default Impose Pressure to cellSet
  #1
Senior Member
 
Join Date: Jan 2014
Posts: 179
Rep Power: 12
hxaxtma is on a distinguished road
Hi guys,

I am trying to impose a pressure value to a selected cellSet.
This is what I have done so far after cellSet creation shown by a Snippet!:
Code:
        Info << "Loop through cellSet: " << runTime.timeName() << endl;
        const labelList& cells = sensorCells.toc();
        forAll(cells,I)
        {
            Info << cells[I] << endl;
            p[cells[I]]=10;
            Info << "Add pressure " <<  endl;
        }
Code is compiling, but no pressure jump appears. Where is the problem?

Solver compiles, but no pressure

Last edited by hxaxtma; January 18, 2016 at 10:46. Reason: And 2nd question, how can I access the x,y,z component values of the cells in the for loop?
hxaxtma is offline   Reply With Quote

Old   January 18, 2016, 10:53
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

1. Concerning your implementation: when do you update values?

2. There is Foam::fv::explicitSetValue fvOption. You can find usage suggestions in $FOAM_SRC/fvOptions/constraints/general/explicitSetValue/ExplicitSetValue.H.

3. Cell centers are kept in fvMesh::C() vector field (http://foam.sourceforge.net/docs/cpp...144592e78ccdba).
alexeym is offline   Reply With Quote

Old   January 18, 2016, 12:20
Default
  #3
Senior Member
 
Join Date: Jan 2014
Posts: 179
Rep Power: 12
hxaxtma is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Hi,

1. Concerning your implementation: when do you update values?

2. There is Foam::fv::explicitSetValue fvOption. You can find usage suggestions in $FOAM_SRC/fvOptions/constraints/general/explicitSetValue/ExplicitSetValue.H.

3. Cell centers are kept in fvMesh::C() vector field (http://foam.sourceforge.net/docs/cpp...144592e78ccdba).
Thanks for your advice:

1. Added in the main loop for every timestep (cellSet changes every timestep)

2.Hm, I am a bit confused about the ExplicitSetValue.H/C code? Which part exactly would help me out here?
hxaxtma is offline   Reply With Quote

Old   January 18, 2016, 13:54
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

1. Could you post your "main loop"?

2. One, which explicitly sets value of a given field. Though, since you have said that cellSet changes every time step, fvOption framework is not really an option.
alexeym is offline   Reply With Quote

Old   January 19, 2016, 05:41
Default
  #5
Senior Member
 
Join Date: Jan 2014
Posts: 179
Rep Power: 12
hxaxtma is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Hi,

1. Could you post your "main loop"?

2. One, which explicitly sets value of a given field. Though, since you have said that cellSet changes every time step, fvOption framework is not really an option.
Hi Alex,

here is my mainloop, I commented the fluid solving out:

Code:
\*---------------------------------------------------------------------------*/

#include "fvCFD.H"
#include "sensorArray.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:

int main(int argc, char *argv[])
{
    #include "setRootCase.H"

    #include "createTime.H"
    #include "createMesh.H"
    #include "createFields.H"
    #include "initContinuityErrs.H"


    // Pre-process the cell set for the first time-step. 
    selectSensor(sensorCells, mesh);
    sensorCells.write(); 
   
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    Info<< "\nStarting time loop\n" << endl;


    while(runTime.loop())
    {
        /*
        //icoFoam START
         #include "readPISOControls.H"
        #include "CourantNo.H"

        fvVectorMatrix UEqn
        (
            fvm::ddt(U)
          + fvm::div(phi, U)
          - fvm::laplacian(nu, U)
        );

        solve(UEqn == -fvc::grad(p));

        // --- PISO loop
        for (int corr=0; corr<nCorr; corr++)
        {
            volScalarField rAU(1.0/UEqn.A());
            volVectorField HbyA("HbyA", U);
            HbyA = rAU*UEqn.H();
            surfaceScalarField phiHbyA
            (
                "phiHbyA",
                (fvc::interpolate(HbyA) & mesh.Sf())
              + fvc::interpolate(rAU)*fvc::ddtCorr(U, phi)
            );
            adjustPhi(phiHbyA, U, p);
            for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
            {
                fvScalarMatrix pEqn
                (
                    fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
                );

                pEqn.setReference(pRefCell, pRefValue);
                pEqn.solve();

                if (nonOrth == nNonOrthCorr)
                {
                    phi = phiHbyA - pEqn.flux();
                }
            }

            #include "continuityErrs.H"
            U = HbyA - rAU*fvc::grad(p);
            U.correctBoundaryConditions();              
            //End PISO Loop
        //END icoFOAM 

        }
        */
        
        //Info << "Time: " << runTime.timeName() << endl;
        //Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s";
        //Info << "ClockTime = " << runTime.elapsedClockTime() << " s";

        Info << "Create Sensor Cell Set Time: " << runTime.timeName() << endl;
        selectSensor(sensorCells, mesh);  
         
        Info << "Calculate Volume Force: " << runTime.timeName() << endl;        

        vector u_bf;                       // Velocity BaseFlow
            
        Info << "Loop through cellSet: " << runTime.timeName() << endl;
        const labelList& sensorCell = sensorCells.toc();    

        
        forAll(sensorCell,i)
        {
            //Info << cells[I] << endl;
            u_bf=U[sensorCell[i]]; // Get Baseflow Velocity over CellSet
            
            //const volVectorField& C_sensor = mesh.C().sensorCell[i];
            //volScalarField Cx_sensor = C_sensor.component(0);        
            //volScalarField Cy_sensor = C_sensor.component(1);    
            //volScalarField Cz_sensor = C_sensor.component(2);    



            Info << "Get Velocity of Baseflow of SensorSet " << sensorCells[i] << ": "<< u_bf << endl;
            //p[cells[I]]+=10;
            Info << "Add pressure " << endl;
               
        }
        

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    Info<< "\nEnd\n" << endl;
    return 0;
    }
    
}
In #include "sensorArray.H" I just set my cellSet Zone by geometrical contraints.

Next I want to loop over the cellSet and impose a volume force in dependence of y.Position of the cells.

Thanks for help
hxaxtma is offline   Reply With Quote

Old   January 19, 2016, 11:27
Default
  #6
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Maybe I am missing something but...

1. I do not see call to runTime.write().
2. Code changing pressure is commented out.
alexeym is offline   Reply With Quote

Old   January 19, 2016, 11:29
Default
  #7
Senior Member
 
Join Date: Jan 2014
Posts: 179
Rep Power: 12
hxaxtma is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Maybe I am missing something but...

1. I do not see call to runTime.write().
2. Code changing pressure is commented out.
Hehe, yes it is commented out, cause this is not working.
and I just forgot to post runtime.write() in the Code Snippet above.

Anyway, this should only represent the main "idea".
hxaxtma is offline   Reply With Quote

Old   January 19, 2016, 11:34
Default
  #8
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Well... your "idea" is "in principle" correct. BUT you do not execute "idea", you execute your "code", and the error is in your REAL "code". Good luck with "idea".
alexeym is offline   Reply With Quote

Old   January 20, 2016, 03:37
Default
  #9
Senior Member
 
Join Date: Jan 2014
Posts: 179
Rep Power: 12
hxaxtma is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Well... your "idea" is "in principle" correct. BUT you do not execute "idea", you execute your "code", and the error is in your REAL "code". Good luck with "idea".
Hi Alex,
I am sorry if I insulted you in a way. I did not want to. I just wanted to point out that I am only missing the function to write field values in the selected cells of the cellSet and the commented line //p[..]+=10 is not working here for me properly.
hxaxtma is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wind tunnel Boundary Conditions in Fluent metmet FLUENT 6 October 30, 2019 12:23
Periodic flow using Cyclic - comparison with Fluent nusivares OpenFOAM Running, Solving & CFD 30 December 12, 2017 05:35
Outlet pressure aja1345 FLUENT 5 August 18, 2015 11:02
Calculation of the Governing Equations Mihail CFX 7 September 7, 2014 06:27
Pulsatile pressure inlet with pressure outlet a.lynchy FLUENT 3 March 23, 2012 13:45


All times are GMT -4. The time now is 19:54.