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

C OpenFOAM data structures

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 27, 2008, 07:29
Default does scalarField accept to be
  #1
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
does scalarField accept to be build dynamically without specifying the size in the constructor. This is like saying a=[]; a(end+1)=3; in matlab.
maka is offline   Reply With Quote

Old   February 27, 2008, 07:35
Default No. You are unlikely to want t
  #2
Senior Member
 
Gavin Tabor
Join Date: Mar 2009
Posts: 181
Rep Power: 17
grtabor is on a distinguished road
No. You are unlikely to want to do this - the size of your scalarField _is_ the size of your mesh. If you need to create the object before constructing it you need to make a pointer and then reference it to the object when you do construct it. If you need a list of scalars which can grow, use ptrList.

Gavin
grtabor is offline   Reply With Quote

Old   February 28, 2008, 08:22
Default You are unlikely to want to do
  #3
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
Quote:
You are unlikely to want to do this - the size of your scalarField _is_ the size of your mesh.
.

I thought that this is the case in volScalarField. I used to think that scalarField is just punch of numbers that may correspond to the mesh or not, for example, they may represent a spatial average over homogeneous directions. Thanks for the tip regarding prtList, it is very useful.

I found the following solution:

scalarField sf(3,0.0);
sf.newElmt(4); Y[4] = 100;

Now, assume I have a scalar field y as:

scalarField y = patches()[patchI].Cf().component(vector::Y);

I looked for a member function to check if its value is constant but I did not find any. Any body aware of such a function.

Best regards,
Maka.
maka is offline   Reply With Quote

Old   February 28, 2008, 09:20
Default correction of the example:
  #4
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
correction of the example:

// this adds and element of value 100 to the end of scalar field sf.
scalarField sf(3,0.0);
sf.setSize(sf.size() + 1, 100);

/Maka.
maka is offline   Reply With Quote

Old   March 5, 2008, 09:58
Default C++ operation: I need to do t
  #5
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
C++ operation:
I need to do the following operation (the scope of pMean variable is important) but it does not work. I tried with and without tmp. Would you please explain how to do it.

IOobject pMeanHeader
(
"pMean",
runTime.times()[i].name(),
mesh,
//IOobject::MUST_READ
IOobject::READ_IF_PRESENT
);

volScalarField pMean;

if (pMeanHeader.headerOk())
{
pMean = tmp<volscalarfield(pmeanheader,mesh)>;

}
maka is offline   Reply With Quote

Old   March 6, 2008, 04:38
Default autoPtr pMeanP
  #6
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
autoPtr<volscalarfield> pMeanPtr;
..
// Set autoptr to valid field
pMeanPtr.reset(new volScalarField(...));
..
// Test if set
if (pMeanPtr.valid())
mattijs is offline   Reply With Quote

Old   March 6, 2008, 07:20
Default Many thanks Mattijs for your h
  #7
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
maka is on a distinguished road
Many thanks Mattijs for your help. It works. For the beginners like myself one can dereference the autoPtr by:

volScalarField& pMean(*pMeanPtr.ptr());

Best regards,
Maka.
maka 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
Convert exisiting data to openfoam braennstroem OpenFOAM Pre-Processing 25 August 7, 2019 15:11
Star V4.00 data structures Jaishree Siemens 1 June 15, 2007 16:49
How to generate OpenFOAM grid from DEM data rcpoudel OpenFOAM Pre-Processing 1 May 22, 2006 13:41
Data Structures - 2D FVM Euler Eqn Solver Scott Main CFD Forum 3 March 31, 2006 06:09
Data Structures for unstructured grid generation Dinesh Godavarty Main CFD Forum 0 December 5, 2000 10:49


All times are GMT -4. The time now is 18:53.