|
[Sponsors] |
January 18, 2016, 11:45 |
Impose Pressure to cellSet
|
#1 |
Senior Member
Join Date: Jan 2014
Posts: 179
Rep Power: 12 |
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; } Solver compiles, but no pressure Last edited by hxaxtma; January 18, 2016 at 11:46. Reason: And 2nd question, how can I access the x,y,z component values of the cells in the for loop? |
|
January 18, 2016, 11:53 |
|
#2 |
Senior Member
|
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). |
|
January 18, 2016, 13:20 |
|
#3 | |
Senior Member
Join Date: Jan 2014
Posts: 179
Rep Power: 12 |
Quote:
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? |
||
January 18, 2016, 14:54 |
|
#4 |
Senior Member
|
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. |
|
January 19, 2016, 06:41 |
|
#5 | |
Senior Member
Join Date: Jan 2014
Posts: 179
Rep Power: 12 |
Quote:
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; } } Next I want to loop over the cellSet and impose a volume force in dependence of y.Position of the cells. Thanks for help |
||
January 19, 2016, 12:27 |
|
#6 |
Senior Member
|
Maybe I am missing something but...
1. I do not see call to runTime.write(). 2. Code changing pressure is commented out. |
|
January 19, 2016, 12:29 |
|
#7 | |
Senior Member
Join Date: Jan 2014
Posts: 179
Rep Power: 12 |
Quote:
and I just forgot to post runtime.write() in the Code Snippet above. Anyway, this should only represent the main "idea". |
||
January 19, 2016, 12:34 |
|
#8 |
Senior Member
|
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".
|
|
January 20, 2016, 04:37 |
|
#9 | |
Senior Member
Join Date: Jan 2014
Posts: 179
Rep Power: 12 |
Quote:
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. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wind tunnel Boundary Conditions in Fluent | metmet | FLUENT | 6 | October 30, 2019 13:23 |
Periodic flow using Cyclic - comparison with Fluent | nusivares | OpenFOAM Running, Solving & CFD | 30 | December 12, 2017 06:35 |
Outlet pressure | aja1345 | FLUENT | 5 | August 18, 2015 12:02 |
Calculation of the Governing Equations | Mihail | CFX | 7 | September 7, 2014 07:27 |
Pulsatile pressure inlet with pressure outlet | a.lynchy | FLUENT | 3 | March 23, 2012 14:45 |