|
[Sponsors] |
February 27, 2008, 07:29 |
does scalarField accept to be
|
#1 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
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.
|
|
February 27, 2008, 07:35 |
No. You are unlikely to want t
|
#2 |
Senior Member
Gavin Tabor
Join Date: Mar 2009
Posts: 181
Rep Power: 17 |
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 |
|
February 28, 2008, 08:22 |
You are unlikely to want to do
|
#3 | |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
Quote:
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. |
||
February 28, 2008, 09:20 |
correction of the example:
|
#4 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
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. |
|
March 5, 2008, 09:58 |
C++ operation:
I need to do t
|
#5 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
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)>; } |
|
March 6, 2008, 04:38 |
autoPtr
|
#6 |
Senior Member
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26 |
autoPtr<volscalarfield> pMeanPtr;
.. // Set autoptr to valid field pMeanPtr.reset(new volScalarField(...)); .. // Test if set if (pMeanPtr.valid()) |
|
March 6, 2008, 07:20 |
Many thanks Mattijs for your h
|
#7 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
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. |
|
|
|
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 |