|
[Sponsors] |
August 18, 2023, 06:56 |
surfaceScalarField definition on-the-fly
|
#1 |
New Member
Sreehari Perumanath
Join Date: Jun 2022
Posts: 28
Rep Power: 4 |
Dear Foamers,
I have to define a surfaceScalarField in my code on-the-fly at each time-step for my system. In createFields.H, I do: Code:
surfaceScalarField stochHfx ( IOobject ( "stochHfx", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("stochHfx", dimPower, scalar(0)) ); Code:
forAll(stochHfx,facei) // loop over all internal faces { stochHfx[facei]=rnumq.scalarNormal(); //a random number } 2. Mostly, I use a cubic domain with cyclicBC in all directinos. So, I have to make the values of stochHfx on the left patch the same as that on the right patch. How can I do that? Any suggestion would be appreciated. I've been spending quite a long time on this, sadly. Thanks, S |
|
August 21, 2023, 07:33 |
|
#2 | |
Member
yijin Mao
Join Date: May 2010
Location: Columbia, MO
Posts: 64
Rep Power: 16 |
Quote:
1. use Random object, such as Random rndGen(215444), then use this object to generate random numbers. 2. to access boundary faces of field alphaf(lets say) Code:
//- loop all boundaryField of alphaf field //- apply user-defined operation on each face forAll(alphaf.boundaryField(), patchi) { fvsPatchScalarField& palphaf = alphaf.ref().boundaryFieldRef()[patchi]; forAll(palphaf, facei) { palphaf[facei] = rndGen.scalar01(); } } Code:
palphaf.patch().name() should return the name of the boundary. |
||
August 21, 2023, 17:23 |
|
#3 |
New Member
Sreehari Perumanath
Join Date: Jun 2022
Posts: 28
Rep Power: 4 |
Hi Alundilong,
Thanks a lot for the suggestion; very helpful. I think I got the idea. Cheers, S |
|
Tags |
boundary cells, cyclic bc, surfacescalarfield |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Upwind Gradient Not Recognizing surfaceScalarField | MajidHagh | OpenFOAM | 2 | October 30, 2019 12:58 |
Change boundary conditions on fly by string definition | Algis | OpenFOAM Programming & Development | 0 | December 15, 2015 12:03 |
Function returning uniform surfaceScalarField | lichmaster | OpenFOAM | 3 | June 25, 2012 04:46 |
Very basic problem with surfaceScalarField definition | feldy77 | OpenFOAM | 4 | December 8, 2011 14:13 |
OpenFOAM static build on Cray XT5 | asaijo | OpenFOAM Installation | 9 | April 6, 2011 13:21 |