|
[Sponsors] |
June 2, 2009, 10:41 |
|
#21 |
Member
Julien Schaguene
Join Date: Apr 2009
Location: France
Posts: 55
Rep Power: 17 |
Hi,
Looking for a way to implement non uniform BC, I found part of the answer here, thanks! Now, I'm looking for something more specific: I want to implement an inletOutlet condition. With the help provided here, I managed to modify the value argument of my BC. Now I want to modify also the inletValue argument, but I don't know how to write it. Does anyone can help me? Thank you for your help! Julien |
|
June 3, 2009, 03:21 |
|
#22 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
Hi Julien
There is already implemented an inletOutlet boundary condition. See the User-/Programming-guides. For the use of these look into "/tutorials/interFoam/damBreak/0". Best regards, Niels |
|
June 3, 2009, 04:16 |
|
#23 |
Member
Julien Schaguene
Join Date: Apr 2009
Location: France
Posts: 55
Rep Power: 17 |
Thank you for answering Niels,
but sorry, I wanted to say non uniform inletOutlet boundary condition. I already used inletOutlet conditions, but only with uniform values at inletValue. I would like to know the syntax to modify the inletValue argument instead of the value one. Best Regards Julien |
|
June 3, 2009, 04:34 |
|
#24 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
So what you need is to be able to read a list of values in stead of on single value?
If that is the case, I would look into A_("A", coeffDict_, N_) where A_ in this case is a scalarField, "A" the name of the valuelist in the dictionary seen by coeffDict_ and N_ is the number of elements. The above is used in a constructor. See also the last constructor in the Doxygen-files: http://foam.sourceforge.net/doc/Doxy...b6d65dfbddd227 Good luck, Niels P.S. I would start with the single-value inletOutlet and modify it where needed. |
|
July 27, 2009, 13:00 |
|
#25 |
Member
Julien Schaguene
Join Date: Apr 2009
Location: France
Posts: 55
Rep Power: 17 |
Hi,
I come back to this topic because I'm using what was explained in the first page, and I want to go further for an industrial use (so I have to create applications that would make my work faster after...) I want to change the type of boundaryfield with an application, so I'm looking for syntax to do it. For the moment, after the line fvPatchScalarField& targetPatch = gamma.boundaryField()[inletPatchID]; when I write targetPatch.type(); I get type generic; and targetPatch is type fixedValue; value uniform 0; and I don't find the way to change type fixedValue. I want to change from fixedValue to inletOutlet for example, and then implement the arguments of my type (here inletValue and Value). I looked around the declarations of fvPatchField, boundaryField... but I'm a beginner in C++ and didn't find what I wanted. Can anyone help me please? Best regards, Julien |
|
January 11, 2010, 11:08 |
|
#26 | ||
Senior Member
Join Date: Dec 2009
Posts: 112
Rep Power: 17 |
Quote:
Quote:
I hope you did not go crazy on the prob :-P , waiting for the answer over one year...but here we go... I had the exact same problem and I think i came up with an answer. Since I could not find anything regarding an answer to "our" prob here a post: the creatfields.h file needs to contain an entry for every variable you want to use (otherwise he complains obout unknown things) so you need to do: Info << "Reading field VARIABLE\n" << endl; vol-insertTYPE-Field VARIABLE ( IOobject ( "VARIABLE", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); regards |
|||
January 11, 2010, 14:30 |
|
#27 |
Senior Member
Join Date: Dec 2009
Posts: 112
Rep Power: 17 |
Hey There,
I have been trying to create my own nonuniform profile for different variables. I ran into a prob (suprise, surprise...). I used the executable that is made once you type "wmake" to change the first boundary patch successfully. then I was going to add a second patch, which did not work out. I tried different things and figured that I can only assign the first patch defined in Blockmesh (right ??). i came up with this theory since I have this code: .... volVectorField::GeometricBoundaryField& Upatches = U.boundaryField(); volScalarField::GeometricBoundaryField& kpatches = k.boundaryField(); volScalarField::GeometricBoundaryField& epsilonpatches = epsilon.boundaryField(); forAll(Upatches, patchI) { if ( (typeid(Upatches[patchI]) == typeid(fixedValueFvPatchVectorField)) && (mesh.boundaryMesh()[patchI].name() == "inlet-air" || "sidewall" || "inlet-gas" || "sackgesicht!" ) ) { fixedValueFvPatchVectorField& Upatch = refCast<fixedValueFvPatchVectorField>(Upatches[patchI]); fixedValueFvPatchScalarField& kpatch = refCast<fixedValueFvPatchScalarField>(kpatches[patchI]); fixedValueFvPatchScalarField& epsilonpatch = refCast<fixedValueFvPatchScalarField>(epsilonpatch es[patchI]); const vectorField& faceCentres = mesh.Cf().boundaryField()[patchI]; forAll(faceCentres, facei) { { Upatch[facei] = vector (0,0,56789); kpatch[facei] = 666; epsilonpatch[facei] = 666; } } }; Info<< "Writing nonsence\n" << endl; U.write(); k.write(); epsilon.write(); Info<< "End\n" << endl; return 0; } } and he writes only new entrys for the first patch defined by blockmesh. I changed patch-orders in Blockmesh. When I changed first and second patch he assigned values to the new first patch. When I tried having the patch originally assigned third on first place, i ended up with error messages-> . so what the bleeep is going on and how can I assigne non-uniform values to several patches at once?? ----------- One veery noobish question: I was forced to copy the executable, which is created by typing wmake, to the case-folder and execute it using ./filename.. Since rehash seems not to work on suse 11. How can I rehash easy, so that I can use it like the other tools (such as setHotRoom, or paraFoam) just by typing its name?? ----------- thx®ards |
|
January 11, 2010, 15:01 |
|
#28 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Code:
(mesh.boundaryMesh()[patchI].name() == "inlet-air" || mesh.boundaryMesh()[patchI].name() == "sidewall" || mesh.boundaryMesh()[patchI].name() == "inlet-gas" || mesh.boundaryMesh()[patchI].name() == "sackgesicht!" ) ) Bernhard |
||
January 12, 2010, 06:46 |
|
#29 |
Senior Member
Join Date: Dec 2009
Posts: 112
Rep Power: 17 |
Hi Bernhard,
thanks for your answer! But I am afraid it has to be something else... when I do: volVectorField::GeometricBoundaryField& Upatches = U.boundaryField(); volScalarField::GeometricBoundaryField& kpatches = k.boundaryField(); volScalarField::GeometricBoundaryField& epsilonpatches = epsilon.boundaryField(); forAll(Upatches, patchI) { if ( (typeid(Upatches[patchI]) == typeid(fixedValueFvPatchVectorField)) && (mesh.boundaryMesh()[patchI].name() == "inlet-air" ) ) { fixedValueFvPatchVectorField& Upatch = refCast<fixedValueFvPatchVectorField>(Upatches[patchI]); fixedValueFvPatchScalarField& kpatch = refCast<fixedValueFvPatchScalarField>(kpatches[patchI]); fixedValueFvPatchScalarField& epsilonpatch = refCast<fixedValueFvPatchScalarField>(epsilonpatch es[patchI]); const vectorField& faceCentres = mesh.Cf().boundaryField()[patchI]; forAll(faceCentres, facei) { { Upatch[facei] = vector (0,0,777); kpatch[facei] = 666; epsilonpatch[facei] = 666; } } }; Info<< "Writing nonsence\n" << endl; U.write(); k.write(); epsilon.write(); Info<< "End\n" << endl; return 0; } It only writes new values when I change the patch-entry in blockmesh to first position, otherwise it seems not to be doing anything ... any further Ideas? regards! p.s. can anyone also give me a hint how to quickly rehash on suse 11. ? |
|
January 13, 2010, 13:47 |
nonuniform internal Field
|
#30 |
Senior Member
Join Date: Dec 2009
Posts: 112
Rep Power: 17 |
Hi All,
if I want to have a nonuniform InternalField and I would like to have a similar code like postet above for the inlet...what do I have to change? Can anyone give me a hint? I have been trying stuff like this, but it does not work... fvPatchField::internalField& Upatches = U.internalField(); GeometricField::internalField& Upatches = U.internalField(); I have also been trying to find a hint how to do it in the doxygen-"documentation"...but without success...has anyone a hint how to takle the problem, when I have a file setting the boundary (like postet before) and I want to rewrite it to set a nonuniform INternalfield ?? Thx&Regards ! |
|
January 13, 2010, 15:10 |
|
#31 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Bernhard |
||
January 14, 2010, 10:08 |
|
#32 |
Senior Member
Join Date: Dec 2009
Posts: 112
Rep Power: 17 |
Hi Bernhard,
thx for your answer.. It is kind of inspiring, but I am lacking the knowledge to do anything with this inspiration... For example: I have the lines: const vectorField& faceCentres = mesh.Cf().boundaryField()[patchI]; and scalar test = cellCentres.y() /R; For the boundary-profile. I suppose the first line assigns the position-information to the variable "face centers". The secont line uses part of this info. Since i want to fit it to my cause (the internal-field) i have been trying things like this: const vectorField& position = mesh.Cf().internalField()[cellI]; scalar test = position.y() /R; which obviously causes the compiler (and i guess also you) to do: ! I could not find a axample in files (like funkysetfields, setfields...) which i was able to transfer. So I started looking in the doxygen-files..I think they are hiding the answer somewhere... So my question: ----------How do I start looking for the answer (in this case of bottom to top engineering) ?? I have been trying to find the syntax in the classes that regard my prob.. For example in : src » finiteVolume » fields » fvPatchFields » fvPatchField But the source code contains no information about finding a position in the field. Or I have been staring at: Foam::globalMeshData I can see with which variables the classes exchange data...but i cant find a solution for my prob(or any service of the class i can call and which classes i have to include for him to work).. I know that this is quite a "large" question, but I think the only way to really "learn" how to deal with Openfoam is to understand how I get information about the structure (otherwise i keep on guessing ). regards&thx ( again) ! |
|
January 14, 2010, 16:24 |
|
#33 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Yes. Have a look at Table 2.1 in the Programmer's guide for the meaning of Cf(). What you'll also find is the method C() for cell centers which you'll propably need for non-uniform internal fields
|
|
January 15, 2010, 07:59 |
|
#34 | |
Senior Member
Join Date: Dec 2009
Posts: 112
Rep Power: 17 |
Quote:
thx a lot, was quite usefull.. have a nice weekend! regards |
||
January 15, 2010, 08:02 |
nonuniform internalField, Volumeprofile, profile, Volume
|
#35 |
Senior Member
Join Date: Dec 2009
Posts: 112
Rep Power: 17 |
Hi Folks,
since I was not able to find something like this and I just finished it (and it is working ) here a post for the archive: (This file is writing a non uniform internal-field for k, epsilon, velocity) #include "fvCFD.H" #include "OSspecific.H" #include "fixedValueFvPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" # include "createFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // volVectorField::InternalField& Upatches = U.internalField(); volScalarField::InternalField& kpatches = k.internalField(); volScalarField::InternalField& epspatches = epsilon.internalField(); forAll(Upatches, cellI) { scalar R = 0.0026; //for 3d geometries only!? /*scalar rR = sqr(faceCentres[facei].y *faceCentres[facei].y() + faceCentres[facei].x() *faceCentres[facei].x() )/R; */ scalar test = mesh.Cf().internalField()[cellI].y() /R; if ( (test > 0) && (test < 1.00) ) { scalar MEAN_vel1 = 53; scalar FACT1 = 0.03; scalar VEL1 = MEAN_vel1 * (1.1758 + 0.27651 * test - 4.034 * pow(test,2) + 21.211*pow(test,3) - 50.888 * pow(test,4) + 57.595 * pow(test,5) - 25.343 * pow(test,6)); scalar k_1 = (3*VEL1*VEL1*FACT1*FACT1)/2; scalar sucker_1 = VEL1*VEL1*VEL1; scalar eps_1 = ( (Foam::sqrt(sucker_1>0 ? sucker_1 : -sucker_1) ) / (0.1 * 2* 0.0026)); Upatches[cellI] = vector (0,0,VEL1); kpatches[cellI] =k_1 ; epspatches[cellI]= eps_1; } if ( (test > 1.00) && (test < 5) ) { scalar MEAN_vel2 = 9.2; scalar FACT2 = -0.60736 + 1.2393 * test - 0.82277 * pow(test,2) + 0.2596 * pow(test,3) - 0.042878 * pow(test,4) + 0.0035864 *pow(test,5) - 0.00012003 * pow(test,6); scalar VEL2 = MEAN_vel2 * ( -8.5665 + 19.253 * test - 16.531 *pow(test,2) + 7.6006* pow(test,3) - 2.0045 * pow(test,4) + 0.30352 * pow(test,5) - 0.024522 * pow(test,6) + 0.00081898 * pow(test,7) ) ; scalar k_2 = (3*FACT2*FACT2*VEL2*VEL2)/2); scalar eps_2 = ( (Foam::sqrt(VEL2*VEL2*VEL2) ) / (0.1 * 2* 0.0026)); Upatches[cellI] = vector (0,0,VEL2); kpatches[cellI] = k_2; epspatches[cellI]= eps_2; } if ( (test > 5) && (test < 6.5) ) { scalar MEAN_vel3 = 9.2; scalar FACT3 = -2.2207 + 1.4684 * test - 0.3617 * pow(test,2) + 0.039378 * pow(test,3) - 0.0016 * pow(test,4); scalar VEL3 = MEAN_vel3 * 1 ; scalar k_3 = (3*( pow(FACT3, 2) * pow(VEL3,2) )/2; scalar eps_3 = ((Foam::sqrt(pow(VEL3,3))) / (0.1 * 2* R)); Upatches[cellI] = vector (0,0, VEL3); kpatches[cellI] = k_3; epspatches[cellI]= eps_3; } if ( (test > 6.5) ) { scalar MEAN_vel4 = 9.2; scalar FACT4 = 0.001; scalar VEL4 = MEAN_vel4 * 1 ; scalar k_4 = (3 * (pow(FACT4, 2) * pow(VEL4,2))/2; scalar eps_4 = ((Foam::sqrt(pow(VEL4,3))) / (0.1 * 2* R)); Upatches[cellI] = vector (0,0, VEL4); kpatches[cellI] = k_4; epspatches[cellI]= eps_4; } } Info<< "Writing stuff\n" << endl; U.write(); k.write(); epsilon.write(); Info<< "End\n" << endl; return 0; } regards! Last edited by heavy_user; January 18, 2010 at 14:22. |
|
January 18, 2010, 14:41 |
nonuniform profile with library
|
#36 |
Senior Member
Join Date: Dec 2009
Posts: 112
Rep Power: 17 |
Hi There,
i have managed to make an executable (by using wmake) that patches the folder "0" with the desired non-uniform Values (see postings before if interested) ... So I tried to do the same using the library I can create out of my BC-files by using "wmake libso".. So I do: "wmake libso" and he says : "'libNULL.so' is up to date." I added the library entry to controldict ( like shown here: http://openfoamwiki.net/index.php/Si...ry_/_Tutorials ) libs ("setProfiles_oneInlet.so");I also added an entry to the k or U or epsilon file in 0 : Like for using groovyBC... inlet { type setProfiles_oneInlet; value uniform 0.000138; } when i start the calculation he says: gradientInternalCoeffs cannot be called for a genericFvPatchField (actual type setProfiles_oneInlet) on patch inlet of field k in file "/home/itvns/OpenFOAM/OpenFOAM-1.6/!!_OWN/sandia_nonpremixed_turb_jetflame/V5_profiles_byLIB/0/k" You are probably trying to solve for a field with a generic boundary condition. From function genericFvPatchField<Type>::gradientInternalCoeffs( ) const in file fields/fvPatchFields/basic/generic/genericFvPatchField.C at line 782. so what did I miss, how do I use the boundary-conditionst this way (or is it not possible??) thx in advance! regards! |
|
January 20, 2010, 08:24 |
|
#37 |
Senior Member
Join Date: Dec 2009
Posts: 112
Rep Power: 17 |
Hi All,
i thougth I managed to create a profile for the BC and the internal-field..unfortunatelly I failed for reasons I dont understand. The Profiles (for U, epsilon, k, CH4 and O2) should be independent of Z-direction, BUT they are NOT ! I attached pictures of CH4 over y (for different heights (Z)). And also a graph for the z-velocity over y (for different heights (Z)). Those were made for time 0 after patching the profile. CH4 is the easyest example of the profile i am trying to use. It should be 1 for 0<y<0.0026& 0<z<2 and 0 elsewhere. (I am also assigning values to U,eps, k, CH4, O2, thats why i dont use setFields) So 2 PRROBS : 1. why is the distribution depending on z, eventhough it should not be? 2. The patched file "0/CH4" has the values 0 and 1 ONLY (i checked on that ), the values I get out of "sample-utility" and the picture from paraFoam show values unequal to 0 or 1 ...similar things happen to U_z(see picture "vel_distribution..") ??? So why is the distribution depending on z and why does he alter my (peak) values ??? thx in advance®ards!! More Info: I have an INLET along the y-axes(CH4 entering for y< 0.0026, O2 for y>0.0026), x-Direction is"empty" since i am doing 2d..Direction of flow is along z-axis. The Complete code for patching the BC and internal field is attached, parts of it can be seen further down... (here i deleted eveything not necessary for CH4, to keep it simple) Code:
volVectorField::InternalField& Upatches2 = U.internalField(); volScalarField::InternalField& kpatches2 = k.internalField(); volScalarField::InternalField& epspatches2 = epsilon.internalField(); volScalarField::InternalField& CH4patches2 = CH4.internalField(); volScalarField::InternalField& O2patches2 = O2.internalField(); forAll(Upatches2, cellI) { scalar R = 0.0026; scalar test = mesh.Cf().internalField()[cellI].y() /R; if ( (test > 0) && (test < 1.00) ) { CH4patches2[cellI] = 1; O2patches2[cellI] = 0; } if ( (test > 1.00) && (test < 5) ) { CH4patches2[cellI] = 0; O2patches2[cellI] = 1; } if ( (test > 5) && (test < 6.5) ) { CH4patches2[cellI] = 0; O2patches2[cellI] = 1; } if ( (test > 6.5) ) { CH4patches2[cellI]= 0; O2patches2[cellI] = 1; } } Info<< "Writing stuff\n" << endl; U.write(); k.write(); epsilon.write(); CH4.write(); O2.write(); Info<< "End\n" << endl; return 0; } } Code:
interpolationScheme cellPoint; setFormat raw; sets ( /* z=0 { name test123; type uniform; axis y; start (0 0.00001 0); end (0 0.15 0); nPoints 100; } z=0.1 { name test123; type uniform; axis y; start (0 0 0.1); end (0 0.15 0.1); nPoints 100; } z=0.2 { name test123; type uniform; axis y; start (0 0.00001 0.2); end (0 0.15 0.2); nPoints 100; } z=0.5 { name test123; type uniform; axis y; start (0 0.00001 0.5); end (0 0.15 0.5); nPoints 100; } /* z=1 { name test123; type uniform; axis y; start (0 0.00001 1); end (0 0.15 1); nPoints 100; } z=1.5 { name test123; type uniform; axis y; start (0 0.00001 1.5); end (0 0.15 1.5); nPoints 100; } */ ); surfaces (); fields ( CH4 ); Last edited by heavy_user; January 22, 2010 at 12:01. |
|
January 22, 2010, 12:01 |
|
#38 |
Senior Member
Join Date: Dec 2009
Posts: 112
Rep Power: 17 |
HI Folks,
i updated the last post to make the prob clearer.. regards& a nice weekend!! |
|
January 27, 2010, 10:54 |
|
#39 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Code:
scalar test = mesh.C()[cellI].y() /R; |
||
January 29, 2010, 05:50 |
|
#40 |
Senior Member
Join Date: Dec 2009
Posts: 112
Rep Power: 17 |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Specifying nonuniform initial condition | msyaml | OpenFOAM Running, Solving & CFD | 65 | April 25, 2016 05:23 |
Nonuniform initial condition using cellSetDict | rinao | OpenFOAM Running, Solving & CFD | 6 | January 9, 2013 01:42 |
Nonuniform boundary syntax | juho | OpenFOAM Running, Solving & CFD | 1 | December 11, 2008 17:13 |
Set nonuniform boundary values | nikwin | OpenFOAM Running, Solving & CFD | 1 | November 30, 2008 08:12 |
Nonuniform gradient boundary condition | ankgupta8um | OpenFOAM Running, Solving & CFD | 1 | March 14, 2006 02:34 |