how to create a volScalarField of mesh.V() ???
Hey
I use a volScalarField with the volume of cells. It works with the cell center but not with cell volume. - Why the following line works volVectorField centres = Sj.mesh().C(); - Why the following line dosn't work volScalarField volume= Sj.mesh().V(); Sj is a volVectorField defined as follow: volVectorField Sj ( IOobject ( "Sj", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ),mesh, dimensionSet(1,-1,-3,0,0,-1,0) ); thanks Sebastian |
Did you ever get to fix this? I have the exact same problem.
|
I think that mesh.V() is a scalarField, not a volscalarField ..........
|
Looking at the doxygen documentation on the openfoam.com website, you can see that:
Quote:
Did you try using: Quote:
Francois. |
This is due that a volScalarField does store values on the boundary, what does not make a lot of sense for cell volumes.
So just the internalField of a volScalarField does have cell volumes So I personally would not try to cast this into a volScalarField! What will you do on the boundaries? If you initialize the volScalarField with zero than there will be zero at the boundaries too. What happens if you divide at a point by these values? I would just work on the internalField volScalarField myWhatEverField =mag(U); scalarField volumes = mesh.V(); volScalarField result(IOobject(...),mesh, 0); result.internalField() = myWahateverField.internalField/volumes; Do whatever you need to do on the boundaries Best Kathrin |
Quote:
Hi, I need mesh.V() for my code which is calculating mDot for phaseChangeTwoPhaseMixtures in a multi phase flow. There is the following error: ‘mesh’ was not declared in this scope If I changee it to : ‘mesh’ was not declared in this scope The error is : ‘const class Foam::incompressibleThreePhaseMixture’ has no member named ‘mesh’ I will aprrciateof any help. Cheers, Elham |
did you try U_.mesh().V()
|
Quote:
It didn't work. |
stuck in creating the volScalarField
Hello All
I am trying to create a variable delta which is cuberoot of volume. I am using it in a coupled level set VOF method, inside the code I will be using the variable for some multiplication with volume fraction and level set scalar. Here is the code I am using in createFields, volScalarField deltaX ( IOobject ( "deltaX", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensionedScalar("deltaX",dimless, 0.0) ); deltaX.internalField()=cbrt(mesh.V()); volScalarField gamma(deltaX*0.75); volScalarField epsilon(deltaX*1.5); volScalarField deltaTau(deltaX*0.1); And it is giving the following error in the bold line ./createFields.H:228:27: error: passing ‘const Internal {aka const Foam::DimensionedField<double, Foam::volMesh>}’ as ‘this’ argument of ‘void Foam::DimensionedField<Type, GeoMesh>::operator=(const Foam::tmp<Foam::DimensionedField<Type, GeoMesh> >&) [with Type = double; GeoMesh = Foam::volMesh]’ discards qualifiers [-fpermissive] deltaX.internalField()=cbrt(mesh.V()); Any help will be deeply appreciated. |
Did you try:
deltaX.primitiveFieldRef()=cbrt(mesh.V()); |
Thanks Michael,
It is working fine. But I have one more small doubt what is the difference between deltaX.primitiveFieldRef() and deltaX.Ref() ? |
Hey kk415,
it looks like your deltaX is having the wrong type of units (I don't know if dimless is what you want, shouldn't it be in [m]?). The reason why you were having the error is due to the fact that in OF (at least in my OF versions) the function internalField returns a const reference to a geometricFields private data which is storing the internal field, thus disallowing any kind of changes to that member. internalFieldRef is the non constant counterpart which allows you to modify the field directly. Regarding your last question, the function ref() returns a reference to the dimensioned internal field. So basically, by using this function, you may have to ensure that the dimensions of your field deltaX matches cbrt(mesh.V()) . It is basically safer. With internalFieldRef, you can write directly to that field without checking units. For more information, check the extended code guide (https://www.openfoam.com/documentati...ce.html#l00041) which is undoubtedly the best resource to better understand OF. Cheers RP |
Quote:
Code:
voScalarField cellSize |
All times are GMT -4. The time now is 23:45. |