|
[Sponsors] |
why can not define a variable of "scalarFieldField tspecies(19)" |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 10, 2013, 09:25 |
why can not define a variable of "scalarFieldField tspecies(19)"
|
#1 | |
Member
赵庆良
Join Date: Aug 2013
Posts: 56
Rep Power: 12 |
Hi foamer.
I want to define "scalarFieldField tspecies(19)",code as following: Code:
#include "scalarFieldField.H" scalarFieldField tspecies(19); for (label i=0; i<Y.size(); i++) { tspecies[i](tableProperties.lookup(Y[i].name())); } Quote:
Thank in advance! |
||
December 10, 2013, 10:38 |
|
#2 |
Senior Member
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22 |
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); |
|
December 10, 2013, 12:09 |
|
#3 |
Member
赵庆良
Join Date: Aug 2013
Posts: 56
Rep Power: 12 |
Dear Lieven,
What you think is right! It really works for me!Thank you for you help!Good luck! |
|
December 10, 2013, 12:58 |
|
#4 | |||
Member
赵庆良
Join Date: Aug 2013
Posts: 56
Rep Power: 12 |
Quote:
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; } 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 ); So lookup (Y[i].name). If I use Code:
scalarField A(tableProperties.lookup("CH4")) Code:
scalarField A(tableProperties.lookup("Y[i].name()")) Quote:
Code:
scalarField A(tableProperties.lookup(Y[i].name())) Quote:
Last edited by zqlhzx; December 12, 2013 at 03:20. |
||||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF: trying to implement a Kinetic Equation source term | er.mkumar | Fluent UDF and Scheme Programming | 35 | March 22, 2019 10:20 |
Plot of user defined variable in CFD Post | dreamz | Main CFD Forum | 0 | December 8, 2013 22:00 |
define variable spring stiffness by writing a macro or command or.. | maralll | Main CFD Forum | 0 | November 6, 2013 20:01 |
Installing OF 1.6 on Mac OS X | gschaider | OpenFOAM Installation | 129 | June 19, 2010 09:23 |
UDF FOR UNSTEADY TIME STEP | mayur | FLUENT | 3 | August 9, 2006 10:19 |