|
[Sponsors] |
manipulating boundaryField of a volScalarField in OpenFOAM |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 30, 2013, 11:28 |
manipulating boundaryField of a volScalarField in OpenFOAM
|
#1 |
New Member
Join Date: May 2013
Posts: 6
Rep Power: 13 |
Dear all,
I need to manipulate a volScalarField using some complex expressions that include other volScalarFields and scalars. I have already a library (C++ class library) that operates on scalars and in order to take advantage of this I (note that I need to perform element by element multiplications), I employed a for loop for the internal field: Code:
for (label i=0; i<D.internalField()[i]; ++i) { D.internalField()[i]*= libraryObject.libraryFunction ( T.internalField()[i], P.internalField()[i], someScalar ); } Code:
scalar scalarT; scalar scalarP; for (label i=0; i<D.boundaryField()[i]; ++i) { scalarT=T.boundaryField()[i]; scalarP=P.boundaryField()[i]; D.boundaryField()[i]*= libraryObject.libraryFunction ( scalarT, scalarP, someScalar ); } Is there a way to "cast" boundaryField()[i] to a scalar? Is there any other way to manipulate the boundary field using the libraryFunction? I know that boundary condition models employ the == operator to reset them, but I can not figure out how this could work in the boundaryField of a volScalarField variable. I would be grateful for any recommendations/suggestions. |
|
January 15, 2014, 16:47 |
|
#2 |
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18 |
Howdy!
When referencing the index of an D.internalField[i] <-like that, the i is refering to a cell index. A boundaryField() is different in that it returns not a patch but a list of patches. For example, to access face j on patch i you would have to write D.boundaryField()[i][j] You're most likey meaning to do something like this: Code:
forAll(D.boundaryField(), patchI) { scalarField& tPatch=T.boundaryField()[patchI]; scalarField& pPatch=P.boundaryField()[patchI]; scalarField& DPatch=D.boundaryField()[patchI]; forAll(DPatch,faceI) { DPatch[faceI]*= libraryObject.libraryFunction ( tPatch[faceI], pPatch[faceI], someScalar ); } } Good luck! Kyle |
|
January 19, 2014, 03:23 |
|
#3 |
New Member
Join Date: May 2013
Posts: 6
Rep Power: 13 |
Thank you Kyle! that was the problem.
|
|
September 21, 2018, 05:00 |
|
#4 | |
Senior Member
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12 |
Hi foamers
I defined a volSymmTensorField and now want to change the values of that in a special boundary: Code:
volSymmTensorField TauT_RT = tauT; // changing the values of internal field forAll (TauT_RT , i) { TauT_RT[i].xy() =40.5; } // changing the values of boundary field forAll (TauT_RT.boundaryField()[patchI] , i) { TauT_RT.boundaryField()[patchI][i].component(symmTensor::XY) = 40 * i; } Quote:
|
||
February 5, 2020, 23:26 |
|
#5 | |
Senior Member
|
Quote:
|
||
Tags |
boundaryfield, fvpatchfield |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ESI-OpenCFD Releases OpenFOAM v2.2.0 | opencfd | OpenFOAM Announcements from ESI-OpenCFD | 13 | March 30, 2013 17:52 |
[Gmsh] gmsh 2.6.0 conversion to OpenFoam 160 | rosswin | OpenFOAM Meshing & Mesh Conversion | 0 | March 5, 2013 08:34 |
Summer School on Numerical Modelling and OpenFOAM | hjasak | OpenFOAM | 5 | October 12, 2008 14:14 |
64bitrhel5 OF installation instructions | mirko | OpenFOAM Installation | 2 | August 12, 2008 19:07 |
OpenFOAM Training and Workshop | Hrvoje Jasak | Main CFD Forum | 0 | October 7, 2005 08:14 |