CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

how to create a volScalarField of mesh.V() ???

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree13Likes
  • 1 Post By sebware
  • 1 Post By Fransje
  • 7 Post By kathrin_kissling
  • 3 Post By mAlletto
  • 1 Post By raumpolizei

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 8, 2010, 12:36
Default how to create a volScalarField of mesh.V() ???
  #1
New Member
 
Sebastian
Join Date: Feb 2010
Posts: 9
Rep Power: 16
sebware is on a distinguished road
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
granzer likes this.
sebware is offline   Reply With Quote

Old   June 13, 2011, 13:59
Default
  #2
Member
 
Fran
Join Date: Sep 2009
Location: Buenos Aires
Posts: 37
Rep Power: 16
lfbarcelo is on a distinguished road
Did you ever get to fix this? I have the exact same problem.
lfbarcelo is offline   Reply With Quote

Old   June 13, 2011, 18:20
Default
  #3
Senior Member
 
Pablo
Join Date: Mar 2009
Posts: 102
Rep Power: 17
pablodecastillo is on a distinguished road
I think that mesh.V() is a scalarField, not a volscalarField ..........
pablodecastillo is offline   Reply With Quote

Old   July 2, 2011, 08:48
Default
  #4
Senior Member
 
Francois
Join Date: Jun 2010
Posts: 107
Rep Power: 20
Fransje will become famous soon enough
Looking at the doxygen documentation on the openfoam.com website, you can see that:

Quote:
const DimensionedField< scalar, volMesh > & V () const - Return cell volumes.
Meaning that V() will return a DimensionedField.

Did you try using:
Quote:
volScalarField volume= Sj.mesh().V().field();
Kind regards,

Francois.
nimasam likes this.
Fransje is offline   Reply With Quote

Old   July 6, 2011, 11:17
Default
  #5
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
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
kathrin_kissling is offline   Reply With Quote

Old   July 23, 2018, 00:36
Default
  #6
Senior Member
 
Elham
Join Date: Oct 2009
Posts: 184
Rep Power: 16
Elham is on a distinguished road
Quote:
Originally Posted by kathrin_kissling View Post
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

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
Elham is offline   Reply With Quote

Old   July 29, 2018, 07:33
Default
  #7
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
did you try U_.mesh().V()
mAlletto is offline   Reply With Quote

Old   November 12, 2018, 04:00
Default
  #8
Senior Member
 
Elham
Join Date: Oct 2009
Posts: 184
Rep Power: 16
Elham is on a distinguished road
Quote:
Originally Posted by mAlletto View Post
did you try U_.mesh().V()

It didn't work.
Elham is offline   Reply With Quote

Old   June 12, 2019, 04:17
Unhappy stuck in creating the volScalarField
  #9
Senior Member
 
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10
kk415 is on a distinguished road
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:imensionedField<double, Foam::volMesh>}’ as ‘this’ argument of ‘void Foam:imensionedField<Type, GeoMesh>:perator=(const Foam::tmp<Foam:imensionedField<Type, GeoMesh> >&) [with Type = double; GeoMesh = Foam::volMesh]’ discards qualifiers [-fpermissive]
deltaX.internalField()=cbrt(mesh.V());





Any help will be deeply appreciated.
kk415 is offline   Reply With Quote

Old   June 12, 2019, 05:33
Default
  #10
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
Did you try:

deltaX.primitiveFieldRef()=cbrt(mesh.V());
kk415, vivek05 and Zhanyuan Wang like this.
mAlletto is offline   Reply With Quote

Old   June 14, 2019, 01:52
Default
  #11
Senior Member
 
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10
kk415 is on a distinguished road
Thanks Michael,


It is working fine. But I have one more small doubt what is the difference between deltaX.primitiveFieldRef() and deltaX.Ref() ?
kk415 is offline   Reply With Quote

Old   June 14, 2019, 04:19
Default
  #12
Member
 
Join Date: Dec 2018
Location: Darmstadt, Germany
Posts: 87
Rep Power: 7
raumpolizei is on a distinguished road
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
kk415 likes this.
raumpolizei is offline   Reply With Quote

Old   June 25, 2019, 04:34
Default
  #13
Senior Member
 
Ruiyan Chen
Join Date: Jul 2016
Location: Hangzhou, China
Posts: 162
Rep Power: 9
cryabroad is on a distinguished road
Quote:
Originally Posted by sebware View Post
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
This is what I have been using.

Code:
voScalarField cellSize
(
    IOobject
    (
        "cellSize",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    mesh,
    dimensionedScalar("zero", dimVolume, 0.0)
);
cellSize.ref() = mesh.V();
I think I actually got this piece of code by searching the forum. As others pointed out, mesh.V() doesn't store values corresponding to the boundaries, so whatever volScalarField you created to retrieve the cell volumes, you can only use the internal part.
cryabroad is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create initiate a volScalarField p without reading from disk NO_READ does not seem to work dbxmcf OpenFOAM Running, Solving & CFD 14 March 25, 2022 07:08
Meshing a Sphere Ajay FLUENT 10 September 3, 2016 15:18
Actuator disk model audrich FLUENT 0 September 21, 2009 08:06
Where's the singularity/mesh flaw? audrich FLUENT 3 August 4, 2009 02:07
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55


All times are GMT -4. The time now is 16:51.