|
[Sponsors] |
Updating Boundary Conditions per time step/iteration in OF v4/v5 |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 17, 2018, 01:25 |
Updating Boundary Conditions per time step/iteration in OF v4/v5
|
#1 |
New Member
Join Date: Jan 2018
Posts: 4
Rep Power: 8 |
Hi, guys:
I just start Openfoam. I am trying to update the boundary conditions per time step or iteration. I have read through the previous threads and follow them. But it didn't make out. while (piso.correct()) { ......... } forAll (p.boundaryField()[patchID], i) { p.boundaryField()[patchID][i] == 1.0; } wmake gives the error: warning: value computed is not used [-Wunused-value] p.boundaryField()[patchID][facej] == 1.0; I have tried both OF v4 and v5. The previous threads use v1-3. I modify icoFoam as a template. I insert the above test code below the piso loop. Thanks Alex |
|
January 17, 2018, 02:28 |
|
#2 |
New Member
Join Date: Jan 2018
Posts: 4
Rep Power: 8 |
It seems I could not access and modify the boundary values in the solver like some other threads mentioned:
change "p" to "mesh" reports error ‘class Foam::fvMesh’ has no member named ‘boundaryField’ operator "=" reports error forAll(mesh.boundary(), patchID) { forAll (mesh.boundary()[patchID],facei) { alfa.boundaryField()[patchID][facei] = 2.0; } } |
|
September 26, 2018, 12:30 |
|
#3 |
Member
Pavan
Join Date: Jan 2016
Posts: 53
Rep Power: 10 |
Were you able to figure it out? I am facing the same problem
|
|
September 26, 2018, 12:41 |
|
#4 | |
Member
Pavan
Join Date: Jan 2016
Posts: 53
Rep Power: 10 |
Quote:
variable.correctBoundaryConditions(); after p.boundaryField()[patchID][i] == 1.0; and see if it works |
||
September 27, 2018, 06:54 |
|
#5 |
Senior Member
Join Date: Sep 2013
Posts: 353
Rep Power: 21 |
I do not understand what you are trying to achieve. boundary conditions can do that without changes. One example:
Code:
myBoundary { type fixedValue; value uniform 1.0; } Code:
myBoundary { type uniformFixedValue; uniformValue constant 1.0; } Code:
myBoundary { type uniformFixedValue; uniformValue table ( (0 1.0) (5 2.0) ); } |
|
September 27, 2018, 09:46 |
|
#6 |
Member
Pavan
Join Date: Jan 2016
Posts: 53
Rep Power: 10 |
Bloerb
In my case, the inlet velocity is parabolic in space and pulsating in time. Thus, for the velocity boundary condition I am using: INLET { type timeVaryingMappedFixedValue; mapMethod nearest; offset (0 0 0); setAverage off; perturb 0 ; fieldTableName no; } The velocity distribution (at selected time steps) is saved in the folder constant/boundaryData/INLET/. However, I also need to ensure that, in each time step, the pressure at the inlet matches a certain value. I understand we cannot simultaneously define pressure and velocity boundary condition at the inlet. Therefore, in each time step, I am trying to adjust the outlet pressure (by multiplying the fixedValue with an adjustment factor) till I achieve the required pressure at the inlet. I want the solver (pimpleFoam) to keep iterating (within the time step) and updating the outlet pressure until the target inlet pressure is achieved. So far, I have not succeeded in this. Any help will be highly appreciated. FYI: I am doing this creating a new boundary condition. I do not mind doing this from within the solver as well. |
|
September 30, 2018, 10:55 |
|
#7 |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18 |
Hi,
I remember, I did something similar before. You need to implement a new BC which impose a parabolic BC (it is kind of 101 tutorial for OF programming). Then U_max in your case should be Function1 type which the user can select it as a table or Sine wave (for pulsing flow) in time. In old OF versions, it was called DataEntry (or something like that). OF course ``timeVaryingMappedFixedValue`` is one solution but for me it is not needed if you know the profile analytically. If you are solving incompressible flow, I cannot see the point of adjusting or iterating to active a certain pressure value. Only pressure gradient matters, not the absolute value. Your code probably doestn't work on OF-4 > because you need to use ``boundaryFieldRef()`` which returns a reference not a constant reference. Check this thread [LINK] Best wishes, Hassan |
|
September 30, 2018, 22:10 |
|
#8 | |||
Member
Pavan
Join Date: Jan 2016
Posts: 53
Rep Power: 10 |
Hassan
Thank you very much. I am still pretty much stuck at the same place. Please see below: Quote:
I think I got the velocity boundary condition at the inlet workig as per my requirement. Quote:
True, but I am trying to simulate the blood flow in arteries and I need to make sure both pressure and velocity at the inlet are attaining a stupulated value. These values have been recorded during experiments. So witinin each time loop I need to satisfy velocity and pressure at the inlet. As I mentioned earlier, I have defined the velocity BC at inlet and I am trying the achieve the required inlet pressure by dynamically changing the oulet pressure. I am trying to tweak pimpleFoam slover to suit my requirement. But, even after assiging the new pressures at the begining of each "pimple loop", the area averaged pressure at the inlet is not changing (after each pimple loop). The area averaged pressure (at inlet) is only chaanging upon the completion of time loop. Can you suggest a way where I can upadate the oulet pressures after each pimple loop so that the subsequent pimple loop runs with updated outlet pressures. Here is my code while (pimple.loop()) { #include "ResistanceHeader.H" #include "UEqn.H" // --- Pressure corrector loop while (pimple.correct()) { #include "pEqn.H" } if (pimple.turbCorr()) { laminarTransport.correct(); turbulence->correct(); } p.correctBoundaryConditions() } runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; The ResistanceHeader.H file contains the following code const label& OUT1patchId = mesh.boundaryMesh().findPatchID("OUT1"); / /Calculating area of the outlet scalar OUT1Area = gSum(mesh.boundary()[OUT1patchId].magSf()); // Calculating radius of the outlet in cm, that is why rad_1 is getting multiplied by 100 scalar OUT1rad_1 = Foam::sqrt(OUT1Area/(constant::mathematical:i))*100; scalar OUT1PVR_1 = 1; scalar OUT1PVR_2 = 1; scalar OUT1PVR_3 = 1; if (OUT1Count== 1) { OUT1PVR_1 = (Rnew)*((-1.589e5)*Foam:ow(OUT1rad_1, 7.0) + (1.361e6)*Foam:ow(OUT1rad_1, 6.0) + (-4.778e6)*Foam:ow(OUT1rad_1, 5.0) + (8.864e6)*Foam:ow(OUT1rad_1, 4.0) + (-9.328e6)*Foam:ow(OUT1rad_1, 3.0) + (5.548e6)*Foam:ow(OUT1rad_1, 2.0) + (-1.737e6)*Foam:ow(OUT1rad_1, 1.0) + (2.318e5)); OUT1PVR_3 = OUT1PVR_1; } if (OUT1Count>1) { OUT1PVR_2 = OUT1PVR_1; OUT1PVR_3 = Rnew * OUT1PVR_2; OUT1PVR_1 = OUT1PVR_3; } scalar OUT1Pressure = ((OUT1PVR * gSum(phi.boundaryField()[OUT1patchId])) + PCWP)/blood_density; p.boundaryFieldRef()[OUT1patchId] = OUT1Pressure; The last line in the above code is supposed to update the boundary field but for some reason I do not see it upadating the values after each pimple loop Quote:
Please let me know how to fix these problems. Particularly, how to force pimplefoam to update the boundary condition after each pimple loop. |
||||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
bash script for pseudo-parallel usage of reconstructPar | kwardle | OpenFOAM Post-Processing | 42 | May 8, 2024 00:17 |
AMI speed performance | danny123 | OpenFOAM | 21 | October 24, 2020 05:13 |
My radial inflow turbine | Abo Anas | CFX | 27 | May 11, 2018 02:44 |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 07:20 |
dynamic Mesh is faster than MRF???? | sharonyue | OpenFOAM Running, Solving & CFD | 14 | August 26, 2013 08:47 |