|
[Sponsors] | |||||
|
|
|
#1 |
|
New Member
Rasmus Andersson
Join Date: Apr 2016
Posts: 3
Rep Power: 11 ![]() |
Hello!
I am developing an OpenFOAM model for electrolytes and in this context one module predicts diffusivities and is supposed to write its results to a dictionary for others to read. Writing to dictionaries seems straight-forward enough, but for some reason I can't get it to work. This is how I define the IODictionary to be written to: Code:
IOdictionary electrolyteProperties
(
IOobject
(
"electrolyteProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
Code:
dictionary& DDict = electrolyteProperties.subDict("D");
Code:
D
{
dimensions [ 0 2 -1 0 0 0 0];
values
(
1e-12
1e-12
1e-12
);
}
Code:
electrolyteProperties.set("values",DVals);
Code:
DVals: 3(4.34118e-12 4.56812e-12 3.49564e-12) Anyone have an idea of what may cause my problem? |
|
|
|
|
|
|
|
|
#2 |
|
New Member
Rasmus Andersson
Join Date: Apr 2016
Posts: 3
Rep Power: 11 ![]() |
Actually, printing the dictionary (using Info) gives exactly what I want, but it never ends up in the file. Do I need to call some write function of some sort? Just writing DDict.write() or electrolyteProperties.write() does not work, then the compiler complains that function call is ambiguous.
|
|
|
|
|
|
|
|
|
#3 |
|
Senior Member
|
Hi,
You can resolve write method ambiguity, for example, like this: Code:
IOdictionary electrolyteProperties
(
IOobject
(
"electrolyteProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
dictionary& DDict = electrolyteProperties.subDict("D");
scalarList DVals;
... fill DVals ...
DDict.set("values", DVals);
electrolyteProperties.regIOobject::write();
|
|
|
|
|
|
|
|
|
#4 |
|
New Member
Rasmus Andersson
Join Date: Apr 2016
Posts: 3
Rep Power: 11 ![]() |
Thanks a lot Alexey! That solved my problem.
/Rasmus |
|
|
|
|
|
|
|
|
#5 |
|
Senior Member
Klaus
Join Date: Mar 2009
Posts: 301
Rep Power: 23 ![]() |
Hello,
I run into compile errors with this code which I want to use to update some values in a dictionary: code: Code:
// IO test changing p-minIter value in fvSolutions file
// Declare dictionary
IOdictionary fvSolution(IOobject("fvSolution",runTime.system(),mesh,IOobject::NO_READ,IOobject::AUTO_WRITE));
// Declare subdictionary
dictionary mySubDictUpdate(fvSolution.subDict("p"));
// Update some values
mySubDictUpdate.set("minIter", 33 );
mySubDictUpdate.set("maxIter", 500 );
myPCG_solve.C:111:1: error: ‘IOdictionary’ was not declared in this scope IOdictionary fvSolution(IOobject("fvSolution",runTime.system(), mesh,IOobject::NO_READ,IOobject::AUTO_WRITE)); ^ myPCG_solve.C:114:1: error: ‘dictionary’ was not declared in this scope dictionary mySubDictUpdate(fvSolution.subDict("p")); myPCG_solve.C:117:1: error: ‘mySubDictUpdate’ was not declared in this scope mySubDictUpdate.set("minIter", 33 ); ^ myPCG_solve.C:122:1: error: ‘fvSolution’ was not declared in this scope fvSolution.Foam::IOobject::write(); ^ myPCG_solve.C:122:18: error: ‘Foam::IOobject’ has not been declared fvSolution.Foam::IOobject::write(); How can I declare the object and dictionaries "in this scope"? Klaus |
|
|
|
|
|
![]() |
| Tags |
| dictionaries, write data, write to file |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to Mix AIR and WATER | Elvis1991 | FLUENT | 12 | December 1, 2016 13:28 |
| Writing udf for Transient Heat conduction boundary value problem | abhi12019 | FLUENT | 3 | October 7, 2015 10:10 |
| writing subDict in a dictionary | ubaid | OpenFOAM Programming & Development | 3 | October 25, 2014 18:17 |
| [Other] Problem with the dictionary file | sfigato | OpenFOAM Meshing & Mesh Conversion | 5 | January 17, 2013 09:55 |
| Problem while writing pressure file "buoyantPressure" | ubaid | OpenFOAM | 0 | October 2, 2010 15:07 |