|
[Sponsors] |
August 2, 2012, 23:43 |
change values of a surfaceSalarField at boundary
|
#1 |
New Member
kob
Join Date: Nov 2011
Posts: 28
Rep Power: 14 |
Hello everyone
I want to change values of a surfaceSalarField sphi at boundary 'surface'.To other regions,the values keep default.So I write a piece of code : Code:
sphi=sigma*(interpolate(U) &mesh.Sf())-fvc::snGrad(ha); label patchI=mesh.boundaryMesh().findPatchID("surface"); forAll(sphi,patchI) { sphi[patchI]=sigma*(interpolate(U) &mesh.Sf()); } But this is wrong.So can you tell me how to modify the above code? regards! bryant Last edited by bryant_k; August 3, 2012 at 02:58. |
|
August 3, 2012, 09:22 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Hi Bryant, I got your message.
Look at the file "applications/utilities/postProcessing/wall/yPlusLES/yPlusLES.C" for answers Also look at "applications/utilities/postProcessing/wall/yPlusRAS/yPlusRAS.C" to see a more basic method of calculating yPlus. Best regards, Bruno
__________________
|
|
August 3, 2012, 10:51 |
|
#3 |
New Member
kob
Join Date: Nov 2011
Posts: 28
Rep Power: 14 |
Hi Bruno
I have looked at the files which you suggested.I am confused with the code inside. I am not familiar with the LES or RAS. Maybe I have not make my points clearly.Firstly the quantity 'sphi' is a surfaceScalarFiled.And then there are two different expressions for it. Code:
sphi=sigma*(interpolate(U) &mesh.Sf())//this expression is just for the boundary 'surface' sphi=sigma*(interpolate(U) &mesh.Sf())-fvc::snGrad(ha);//this expression is for other regions Regards! bryant |
|
August 3, 2012, 14:03 |
|
#4 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
If you abstract yourself from whatever LES and RAS are, you would see the details in bold and italic:
Code:
const fvPatchList& patches = mesh.boundary(); const volScalarField nuLam(sgsModel->nu()); forAll(patches, patchi) { const fvPatch& currPatch = patches[patchi]; if (isA<wallFvPatch>(currPatch)) { yPlus.boundaryField()[patchi] = d[patchi] *sqrt ( nuEff.boundaryField()[patchi] *mag(U.boundaryField()[patchi].snGrad()) ) /nuLam.boundaryField()[patchi]; const scalarField& Yp = yPlus.boundaryField()[patchi]; Info<< "Patch " << patchi << " named " << currPatch.name() << " y+ : min: " << gMin(Yp) << " max: " << gMax(Yp) << " average: " << gAverage(Yp) << nl << endl; } } This should translate to your case to be something like: Code:
sphi=sigma*(interpolate(U) &mesh.Sf())-fvc::snGrad(ha); label patchI=mesh.boundaryMesh().findPatchID("surface"); forAll(sphi,patchI) { sphi.boundaryField()[patchI] = sigma*(U.boundaryField()[patchi] & mesh.Sf()); } OK, the closest I could find so far was "applications/solvers/multiphase/compressibleTwoPhaseEulerFoam/turbulenceModel/wallViscosity.H"... I found it among the results from using this command: Code:
find . -name "*.[CH]" | xargs grep -sl surfaceScalarField | sed 's=/[a-zA-Z0-9]*\..*==' | uniq | xargs grep -e "forAll(.*patc" -rsl
Mmm... this is complicated... Anyone else wants to help?
__________________
|
|
August 3, 2012, 14:16 |
|
#5 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
OK, I kept digging a bit deeper... in this file "applications/solvers/electromagnetics/magneticFoam/createFields.H", you'll find these pieces of code:
Code:
surfaceScalarField murf ( //... ); surfaceScalarField Mrf ( //... ); const labelList& faces = mesh.faceZones()[magnetZonei]; const scalar muri = magnets[i].mur(); const scalar Mri = magnets[i].Mr().value(); const vector& orientationi = magnets[i].orientation(); const surfaceVectorField& Sf = mesh.Sf(); forAll(faces, i) { label facei = faces[i]; murf[facei] = muri; Mrf[facei] = Mri*(orientationi & Sf[facei]); }
__________________
|
|
August 5, 2012, 03:09 |
|
#6 |
New Member
kob
Join Date: Nov 2011
Posts: 28
Rep Power: 14 |
Hi Bruno
Thank you for your help. I have modified my code according the reference file. Code:
sphi=sigma*(interpolate(U) &mesh.Sf())-fvc::snGrad(ha); forAll(sphi,i) { label zonei = mesh.faceZones().findZoneID("surface"); const labelList& faces = mesh.faceZones()[zoneonei]; forAll(faces, i) { label facei = faces[i]; sphi[facei] = sigma.value()*(U.boundaryField()[facei]& mesh.Sf[facei]); } } I have a doubt at this line: Code:
sphi[facei] = sigma.value()*(U.boundaryField()[facei]& mesh.Sf[facei]); Code:
sphi[facei] = sigma*(U.boundaryField()[facei]& mesh.Sf[facei]); Do you have any idea about this? regards! bryant |
|
August 5, 2012, 08:08 |
|
#7 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Hi Bryant,
Something's very wrong here: Code:
forAll(sphi,i) { //... forAll(faces, i) And why is "zonei" being found inside the outer loop and not outside? Best regards, Bruno
__________________
|
|
Tags |
change values |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
The FOAM Documentation Project - SHUT-DOWN | holger_marschall | OpenFOAM | 242 | March 7, 2013 12:30 |
How to make code run in parallel? | cwang5 | OpenFOAM Programming & Development | 1 | May 30, 2011 04:47 |
Open Source Vs Commercial Software | MechE | OpenFOAM | 28 | May 16, 2011 11:02 |
Design Integration with CFD? | John C. Chien | Main CFD Forum | 19 | May 17, 2001 15:56 |
public CFD Code development | Heinz Wilkening | Main CFD Forum | 38 | March 5, 1999 11:44 |