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

openfoam define a zero value volscalarfield

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 4, 2016, 09:00
Default openfoam define a zero value volscalarfield
  #1
New Member
 
Luis Lencina
Join Date: May 2010
Posts: 12
Rep Power: 16
LUIS1717 is on a distinguished road
Hi everyone,

I'm trying to program a solver and its need a volscalarfield that initially must be zero everywhere in the mesh and I don't want to read it from any initial condition or to write it down. Anyone know how to do it?

thanks in advance Luis
LUIS1717 is offline   Reply With Quote

Old   February 4, 2016, 11:26
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Just an example:

Code:
$ sol
$ grep -r volScalarField *
...lots of output...
stressAnalysis/solidDisplacementFoam/readThermalProperties.H
...
$ less stressAnalysis/solidDisplacementFoam/readThermalProperties.H
Go to line 16.

Another:

Code:
$ src
$ cd turbulenceModels/incompressible/turbulenceModel/laminar
$ less laminar.C
Go to line 90 (this one maybe a little bit too complicated, since involves certain things in addition to field creation).
alexeym is offline   Reply With Quote

Old   February 4, 2016, 11:57
Default
  #3
New Member
 
Luis Lencina
Join Date: May 2010
Posts: 12
Rep Power: 16
LUIS1717 is on a distinguished road
Thanks alexeym,

I was wondering if there were some way to avoid to create the IOobject, or at least dont have to write it down.
LUIS1717 is offline   Reply With Quote

Old   February 4, 2016, 11:58
Smile
  #4
Senior Member
 
Hesam
Join Date: Feb 2015
Posts: 139
Rep Power: 11
rapierrz is on a distinguished road
Hi Luis,

For example for vol scalar field alpha

volScalarField Temp
(
IOobject
(
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
dimensionedScalar("Temp",dimensionSet(0,0,0,0,0,0, 0),0)
);
rapierrz is offline   Reply With Quote

Old   February 4, 2016, 12:22
Default
  #5
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
@LUIS1717

If you take a look at GeometricField class documentation (http://foam.sourceforge.net/docs/cpp/a00912.html, volScalarField is just a typedef GeometricField<scalar, fvPatchField, volMesh>), it can be created either as a copy of another GeometricField, or on the base of IOobject.

So in brief, no, you can not avoid IOobject constructor.

Surely if you really-really-really hate IOobject constructor, you can create wrapper taking field name, dimensions, and mesh as parameters and returning autoPtr.
alexeym is offline   Reply With Quote

Old   April 16, 2016, 16:16
Default
  #6
Senior Member
 
Join Date: Mar 2009
Location: My oyster
Posts: 124
Rep Power: 17
ziad is on a distinguished road
Quote:
Originally Posted by LUIS1717 View Post
Hi everyone,

I'm trying to program a solver and its need a volscalarfield that initially must be zero everywhere in the mesh and I don't want to read it from any initial condition or to write it down. Anyone know how to do it?

thanks in advance Luis
Here's a REALLY ugly hack, but it's simple, it works and you won't need IOobject.

Code:
volScalarField toto ("use any combination of variables with correct dimensions");
toto *= scalar(0);
ziad is offline   Reply With Quote

Reply

Tags
openfoam, volscalarfield, zero value


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
Hydrogen storage by metal hydride longbk FLUENT 12 August 1, 2023 21:13
HELP----Surface Reaction UDF Ashi Fluent UDF and Scheme Programming 1 May 19, 2020 22:13
[OpenFOAM.org] A Mac OS X of23x Development Environment Using Docker rt08 OpenFOAM Installation 1 February 28, 2016 20:00
OpenFOAM Training: Programming CFD Course 12-13 and 19-20 April 2016 cfd.direct OpenFOAM Announcements from Other Sources 0 January 14, 2016 11:19
Different define of psi uesd in pEqn.H zqlhzx OpenFOAM Running, Solving & CFD 0 December 24, 2013 09:45


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