|
[Sponsors] |
March 11, 2013, 22:42 |
Help with this line of code :
|
#1 |
Senior Member
ATM
Join Date: May 2009
Location: United States
Posts: 104
Rep Power: 17 |
Hi all.
I dont quite understand what these lines of code mean in the file nuSgsUSpaldingWallFunctionFvPatchScalarField.C , which is the Spalding Wall Function for LES. I use OpenFOAM 2.1.1 U has been defined as Code:
const fvPatchVectorField& U = lesModel.U().boundaryField()[patchi]; Code:
const scalarField magUp(mag(U.patchInternalField() - U)); I am confused as to why this is being done. Any help will be appreciated. Also, I CANNOT find the nuSgsUSpaldingWallFunction folder in the Github for OpenFOAM 2.1.x https://github.com/OpenFOAM/OpenFOAM-2.1.x whereas its there in OpenFOAM-2.1.1 / src / turbulenceModels / incompressible / LES / derivedFvPatchFields / wallFunctions / nuSgsWallFunctions / nuSgsUSpaldingWallFunction /nuSgsUSpaldingWallFunctionFvPatchScalarField.C in my install directory of OpenFOAM 2.1.1 in my machine!!! Why is this? Thank you all for your time. Regards A.T.M |
|
March 12, 2013, 01:12 |
|
#2 |
Senior Member
Yogesh Bapat
Join Date: Oct 2010
Posts: 102
Rep Power: 16 |
U.patchInternalField() will only give U field in neighboring cells to the patch and not complete internal field.
Regards, -Yogesh |
|
March 12, 2013, 08:58 |
|
#3 | |
Senior Member
ATM
Join Date: May 2009
Location: United States
Posts: 104
Rep Power: 17 |
Quote:
Thank you. Just to make sure I understand right, lesModel.U().boundaryField()[patchi] has the patchID mentioned here, whereas the U.patchInternalField() doesnt have anything like that. Which patch does it refer to by default? Also, the "boundaryField" refers to the cells which are adjacent to the boundary, and the "internalField" refers to the cells adjacent to the boundaryField cells? is this correct? Regards, ATM |
||
March 12, 2013, 11:27 |
|
#4 |
Senior Member
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0 |
Greetings!
Just some more info for you. The line Code:
const fvPatchVectorField& U = lesModel.U().boundaryField()[patchi]; Code:
const scalarField magUp(mag(U.patchInternalField() - U)); |
|
March 12, 2013, 11:49 |
|
#5 |
Senior Member
ATM
Join Date: May 2009
Location: United States
Posts: 104
Rep Power: 17 |
Dan,
Thank you very much! That was helpful. On a similar note, can I just call pressure (press) in the code as Code:
const volScalarField& press = db().lookupObject<volScalarField>("p") Code:
const fvPatchScalarField& P = press().boundaryField()[patchi]; Sorry if this seems very rudimentary....I am not very comfortable with the way OF is coded. Thanks again. |
|
March 12, 2013, 11:59 |
|
#6 | |
Senior Member
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0 |
The compiler should tell you if it is a redefinition of the variable names or if it is a reserved word....since its job is to keep track of that. These variables have local scope so you can name them what you have suggested unless they are defined in another part of the code you are altering.
Quote:
Last edited by chegdan; March 12, 2013 at 12:45. |
||
March 15, 2013, 01:59 |
|
#7 |
Senior Member
ATM
Join Date: May 2009
Location: United States
Posts: 104
Rep Power: 17 |
Dan,
Thats right....Thank you . I am pretty sure that the variable names I am using here are unique in the code and not used anywhere else. I just want to include the local term at the near wall cells in my code (which is a new wall function - I am coding it by seeing the nuSgsUSpaldingWallFunctionFvPatchScalarField.C , and reusing the code I want from it) So, I do : Code:
const volScalarField& pr = db().lookupObject<volScalarField>("p")[patchi]; // (Line 130) Read "Pressure" from the database structure const volScalarField& bpr = pr().boundaryField()[patchi]; // Defining new variable to the boundary field values of 'p' read from the previous line const volVectorField Gbpr = Foam::fvc::grad(bpr); // (Line 138) Defining new variable for gradient of the pressure boundary field 'bpr' const scalarField GradP = Gbpr.component(0); // Defining new variable for X-component of the gradient Compiling would give me this error: Code:
NewWallFunctionFvPatchScalarField.C: In member function ‘virtual void Foam::incompressible::LESModels::NewWallFunctionFvPatchScalarField::evaluate(Foam::UPstream::commsTypes)’: NewWallFunctionFvPatchScalarField.C:130: error: invalid initialization of reference of type ‘const Foam::volScalarField&’ from expression of type ‘const double’ NewWallFunctionFvPatchScalarField.C:138: error: no match for call to ‘(const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>) ()’ the nuSgsUSpaldingWallFunctionFvPatchScalarField.C does a similar operation with "U" field, which was defined in LESModel.C. I'm wondering how I can fix my code to do the operation I want - I assume it should be somewhat simple for a C++ programmer, but I couldn't figure out myself. Regards, atm Last edited by atmcfd; March 18, 2013 at 23:02. Reason: edit |
|
March 17, 2013, 17:00 |
|
#8 |
Senior Member
ATM
Join Date: May 2009
Location: United States
Posts: 104
Rep Power: 17 |
Some additional info:
The above code compiles fine if i do not make the pr().boundaryField call , remove [patchi] from Line 130, and use the 'pr' field as itself. Looks like If I just find out the function to use to create a boundaryField from a complete volScalarField, I will be done. Thanks, atm Last edited by atmcfd; March 18, 2013 at 23:03. |
|
March 20, 2013, 22:41 |
|
#9 |
Senior Member
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0 |
If you want access to your boundary field from your volScalarField, look at your first post on how you originally accessed the boundary field
Code:
const fvPatchVectorField& U = lesModel.U().boundaryField()[patchi]; |
|
March 24, 2013, 23:33 |
|
#10 |
Senior Member
ATM
Join Date: May 2009
Location: United States
Posts: 104
Rep Power: 17 |
Dan,
Thanks for responding. I will look into it more..... Regards Atm |
|
April 11, 2013, 19:50 |
|
#11 |
New Member
Giancarlo
Join Date: Apr 2013
Location: Milan
Posts: 21
Rep Power: 13 |
Hi guys,
I have a similar problem. I have a patch named "fluid_to solid" in my mesh. In order to copy the values of a field in correspondence to this specific patch I have written the following code: Code:
forAll( TFluid[j].boundaryField(), patchi) { label patchID = fluidRegions[j].boundaryMesh().findPatchID("fluid_to_solid"); forAll( TFluid[j].boundaryField()[patchID], facei) { Tf[facei+1] = TFluid[j].boundaryField()[patchID][facei]; } } Can anyone help me? Best Giancarlo |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenFOAM 1.7.1 installation problem on OpenSUSE 11.3 | flakid | OpenFOAM Installation | 16 | December 28, 2010 09:48 |
OpenFOAM15 installables are incomplete problem with paraFoam | tryingof | OpenFOAM Bugs | 17 | December 7, 2008 05:41 |
OpenFOAM with IBM AIX | matthias | OpenFOAM Installation | 20 | March 25, 2008 03:36 |
Design Integration with CFD? | John C. Chien | Main CFD Forum | 19 | May 17, 2001 16:56 |
What is the Better Way to Do CFD? | John C. Chien | Main CFD Forum | 54 | April 23, 2001 09:10 |