|
[Sponsors] |
icoFoam set outflow Dirichlet conditions for p during runtime |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 13, 2015, 06:43 |
icoFoam set outflow Dirichlet conditions for p during runtime
|
#1 |
New Member
Join Date: Jan 2015
Posts: 4
Rep Power: 11 |
Hello everybody,
I am trying to set Dirichlet boundary conditions for the pressure which are unknown before runtime for the icoFoam solver at the outflow (and I am failing). These Dirichlet values come from another calculation which depends on the solutions of icoFoam, so there is no way to do this with tableFile or csvFile. My idea to achieve this is to create a modified version of the icoFoam Solver (called my_icoFoam). In this new solver I edited my_icoFoam.C : 1. I created a new fvPatch for the outlet: Code:
label outlet_patch_label = mesh.boundaryMesh().findPatchID("outlet"); const fvPatch& outlet_patch = mesh.boundary()[outlet_patch_label]; Code:
forAll(outlet_patch, face_i){ label curCellp = outlet_patch.faceCells()[face_i]; p[curCellp] = value; } I think the problem is that I declared the outflow boundary in the file case/0/p to: Code:
boundaryField { outlet { type fixedValue; value uniform 0; } } Any tips on what I am doing wrong or how chtMultiRegionSimpleFoam solves this probem are highly appreciated. |
|
January 16, 2015, 08:55 |
push
|
#2 |
New Member
Join Date: Jan 2015
Posts: 4
Rep Power: 11 |
Nobody with any ideas?
Im really in a dead end here, any ideas would be helpful. |
|
January 16, 2015, 17:19 |
|
#3 |
Senior Member
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 13 |
Maybe using groovyBC or swak4foam?
It will let you impose conditional conditions to your boundaryConditions, and you will be able to access runTime variables from it Maybe I can help you with it which is your condition for changing the BC? |
|
January 18, 2015, 16:22 |
|
#4 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings to all! And welcome to the forum Karman123!
Uhm... here's an idea: A person should not simply take a pain pill for a headache that was caused by a hammer hitting one's head. OK, joking aside, the problem here is that you might not be diagnosing properly the problem you have at hand. Because from your description, it seems to me that you should first run icoFoam for a few iterations with a "zeroGradient" or "inletOutlet" or "outlerInlet" at the outlet; and then change the boundary type in the last iteration to "fixedValue" and continue the simulation from there. No solver coding required. Then there is also the "mappedField" boundary type, which seems to do what you're looking for. Better yet, have a look at the code documentation: http://www.openfoam.org/docs/cpp/ - look at the bottom of the page there, where you can find the "Boundary Conditions" link. From there you can see the various outlet boundary conditions that OpenFOAM has got and possibly one of them already does what you want to do. Best regards, Bruno
__________________
|
|
January 19, 2015, 16:27 |
|
#5 | ||
New Member
Join Date: Jan 2015
Posts: 4
Rep Power: 11 |
Thank you very much for your replies.
Just to give some context, I am not using OpenFOAM professionally, but as a student (for the first time) on a project, which might explain the existance of a simple solution to my problem . The project is to couple a 1D solver I already wrote in C++ to a 3D inflow region (which I try to compute with icoFoam). So the pressure at the outlet boundary of the icoFoam-region is calculated by my own FV Code. Quote:
This part https://openfoamwiki.net/index.php/C..._other_patches seems to be interesting to me. If I create a new patch in my modified icoFoam solver which contains the solutions from my 1D solver I could access that new patch from the BC-file.. correct? Quote:
I cant find any explanations on "mappedField", only the code. I will look into that a little more. Thanks again and other suggestions are still welcome. |
|||
January 19, 2015, 17:03 |
|
#6 |
Senior Member
anonymous
Join Date: Aug 2014
Posts: 205
Rep Power: 13 |
You could just create a volVectorField with your 1D field, and access to it from groovyBC, no need of creating a new patch.
|
|
January 19, 2015, 17:46 |
|
#7 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Quick answer: Have a look at the tutorial folder "heatTransfer/buoyantSimpleFoam/externalCoupledCavity", since it somewhat looks like that it's what you're looking for. That tutorial essentially has a boundary condition coming from an outside application, where data is transferred via file.
|
|
February 12, 2015, 14:00 |
solution
|
#8 |
New Member
Join Date: Jan 2015
Posts: 4
Rep Power: 11 |
for anybody with a similar problem:
i used the solution "ssss" suggested. (I assumed coupling via file is slow) 1. install swak4foam 2. create a new solver (copy icoFoam and rename) 3. create a new volume scalar field in your createFields.H Code:
Info<< "Creating field for pressure coupling\n" << endl; volScalarField p_coupling ( IOobject ( "p_coupling", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("p_coupling", dimensionSet(0,2,-2,0,0,0,0), Foam::scalar(0)) ); Code:
double value=compute_value(...); dimensionedScalar value_dim ( "value_dim", dimensionSet(0,2,-2,0,0,0,0), scalar(value) ); p_coupling=value_dim; Code:
outlet { type groovyBC; valueExpression "p_coupling"; } thanks again ssss without you I might still be stuck |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Question about heat transfer coefficient setting for CFX | Anna Tian | CFX | 1 | June 16, 2013 07:28 |
OF 1.6 | Ubuntu 9.10 (64bit) | GLIBCXX_3.4.11 not found | piprus | OpenFOAM Installation | 22 | February 25, 2010 14:43 |
Set the inflow condition from the outflow | fanta1014 | CFX | 4 | January 26, 2010 22:22 |
OpenFOAM on MinGW crosscompiler hosted on Linux | allenzhao | OpenFOAM Installation | 127 | January 30, 2009 20:08 |
How to set environment variables | kanishka | OpenFOAM Installation | 1 | September 4, 2005 11:15 |