zqlhzx |
December 10, 2013 12:58 |
Quote:
Originally Posted by Lieven
(Post 465737)
The way I understand it, is that scalarFieldField does not define a type like e.g. scalarList. So you can't create objects of this type since it simply does not exist. Instead, the source files (scalarFieldField.C and .H) define how objects of the type FieldField<Field, scalar> should handle a number of basic operations. So if you want to create an object which behaves as a scalarFieldField you should create it as
Code:
FieldField<Field, scalar> tspecies(19);
At least that's what I think ...
|
Dear Lieven,
I wirte the following codes in my solver and it can be compiled successfully.Could I ask you another question?
Code:
Info<< "Reading table properties\n" << endl;
IOdictionary tableProperties
(
IOobject
(
"tableProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
FieldField<Field,scalar> tspecies(19);
for (label i=0; i<Y.size(); i++)
{
scalarField A(tableProperties.lookup("Y[i].name()"));
tspecies[i]=A;
}
What I'd like to ask you is something about "(tableProperties.lookup("Y[i].name()")".In my tableProperties ,it is :
Code:
FoamFile
{
version 2.0;
format binary;
class dictionary;
location "constant";
object tableProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
CH4
(
0.0000 0.0120 0.0240 0.0360 0.0480 0.0060 0.0720 0.0840 0.0960 0.1080
0.1200 0.1320 0.1440 0.1560 0.1680 0.1800 0.1920 0.2040 0.2160 0.2280
0.2400 0.2520 0.2640 0.2760 0.2880 0.3000 0.3120 0.3240 0.3360 0.3480
0.3600 0.3720 0.3840 0.3960 0.4080 0.4200 0.4320 0.4440 0.4560 0.4680
0.4800 0.5000 0.5250 0.5500 0.5750 0.6000 0.6250 0.6500 0.6750 0.7000
0.7250 0.7500 0.7750 0.8000 0.8500 0.9000 0.9500 1.0001
);
O2
(
0.0000 0.0120 0.0240 0.0360 0.0480 0.0060 0.0720 0.0840 0.0960 0.1080
0.1200 0.1320 0.1440 0.1560 0.1680 0.1800 0.1920 0.2040 0.2160 0.2280
0.2400 0.2520 0.2640 0.2760 0.2880 0.3000 0.3120 0.3240 0.3360 0.3480
0.3600 0.3720 0.3840 0.3960 0.4080 0.4200 0.4320 0.4440 0.4560 0.4680
0.4800 0.5000 0.5250 0.5500 0.5750 0.6000 0.6250 0.6500 0.6750 0.7000
0.7250 0.7500 0.7750 0.8000 0.8500 0.9000 0.9500 1.0001
);
CO2
(
0.0000 0.0120 0.0240 0.0360 0.0480 0.0060 0.0720 0.0840 0.0960 0.1080
0.1200 0.1320 0.1440 0.1560 0.1680 0.1800 0.1920 0.2040 0.2160 0.2280
0.2400 0.2520 0.2640 0.2760 0.2880 0.3000 0.3120 0.3240 0.3360 0.3480
0.3600 0.3720 0.3840 0.3960 0.4080 0.4200 0.4320 0.4440 0.4560 0.4680
0.4800 0.5000 0.5250 0.5500 0.5750 0.6000 0.6250 0.6500 0.6750 0.7000
0.7250 0.7500 0.7750 0.8000 0.8500 0.9000 0.9500 1.0001
);
H2O
(
0.0000 0.0120 0.0240 0.0360 0.0480 0.0060 0.0720 0.0840 0.0960 0.1080
0.1200 0.1320 0.1440 0.1560 0.1680 0.1800 0.1920 0.2040 0.2160 0.2280
0.2400 0.2520 0.2640 0.2760 0.2880 0.3000 0.3120 0.3240 0.3360 0.3480
0.3600 0.3720 0.3840 0.3960 0.4080 0.4200 0.4320 0.4440 0.4560 0.4680
0.4800 0.5000 0.5250 0.5500 0.5750 0.6000 0.6250 0.6500 0.6750 0.7000
0.7250 0.7500 0.7750 0.8000 0.8500 0.9000 0.9500 1.0001
);
(In fact,the values in different species is different.I just show it as example).It should be that Y[0].name()=CH4,Y[1].name()=O2.Y[2].name()=CO2,Y[3].name()=H2O. I want to make "scalarFIeld A" is equal to the values for different species.
So lookup (Y[i].name).
If I use
Code:
scalarField A(tableProperties.lookup("CH4"))
it can work,and my case can run.However,if I use
Code:
scalarField A(tableProperties.lookup("Y[i].name()"))
then I run my case ,it give me error:
Quote:
keyword Y[i].name() is undefined in dictionary "/home/acer/OpenFOAM/acer-2.2.2/run/singlefirepoolx/constant/tableProperties"
|
Then I get rid of the "" like:
Code:
scalarField A(tableProperties.lookup(Y[i].name()))
it still gave me error:
Quote:
FOAM FATAL ERROR:
hanging pointer at index 0 (size 19), cannot dereference
From function PtrList::operator[]
in file /opt/openfoam222/src/OpenFOAM/lnInclude/PtrListI.H at line 150.
FOAM aborting
|
What do you think about my error?Could you give me some advises?Thank you !
|