|
[Sponsors] |
April 27, 2012, 15:31 |
dictionary scalarField formatting
|
#1 |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
I'm playing around with some functionality in 1.6-ext and am using a class that requires a scalarField be supplied in a dictionary. Its for a list of times at which to activate a specific boundary condition. How should this entry be formatted? I can't seem to find any tutorials/examples that use this kind of setup.
|
|
April 27, 2012, 18:34 |
|
#2 |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,097
Rep Power: 34 |
Hi,
If you Info a scalarField to the terminal then you can see the format. It looks like this (where lookupName is just whatever name you want to give it): Code:
lookupName 5 ( 0 0.005 0.01 0.015 0.02); |
|
April 27, 2012, 18:50 |
|
#3 |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
Thanks Phil!
I think that almost does it. How should I format it so that it gets read by code like this: Code:
scalarField(entries[i].dict().lookup("times")) I currently have Code:
times 2 (2.0 3.0); Code:
--> FOAM FATAL IO ERROR: Attempt to return dictionary entry as a primitive |
|
April 27, 2012, 18:54 |
|
#4 |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,097
Rep Power: 34 |
Hi,
This is how I read a scalarField from a dictionary: Code:
IOdictionary myData ( IOobject ( "myDict", runTime.constant(), runTime.db(), IOobject::MUST_READ, IOobject::NO_WRITE ) ); const scalarField myTime = myDict.lookup("time"); |
|
April 27, 2012, 19:04 |
|
#5 |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
That definitely makes more sense to me, but I don't want to go re-writing someone else's class. I've never seen a scalarField read like that, so I'm at a loss here. I'll try enabling some debug switches and see what comes out.
Thanks anyways! |
|
April 27, 2012, 21:07 |
|
#6 |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
No luck with the debug flags or debug mode. The code I'm looking at is the attachDetach.C. It still exists in OF21x ($FOAM_SRC/dynamicMesh/attachDetach/attachDetach.C), I'm trying it out there and giving it in the same error. Its just syntax, but I can't find anywhere else that uses something similar.
Is it possible that scalarField can't actually be read like this, and no one noticed? |
|
April 30, 2012, 11:24 |
|
#7 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
I don't see anything wrong with attachDetach. The only scalarField lookup is for triggerTimes_ in the constructor initialization list, and the syntax is:
Code:
triggerTimes_(dict.lookup("triggerTimes")),
__________________
~~~ Follow me on twitter @DavidGaden |
|
April 30, 2012, 14:26 |
|
#8 |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
Hi David!
Sorry the confusion, what I meant was is that the problem is with MY syntax in the dictionary to define the triggertimes. The comments made by Philip are correct in that a scalarfield as defined in his first message should be read just fine, but I haven't been able to get it working. The syntax I have for my attach/detach face is as follows: Code:
flap1 { faceZoneName flap1; //the internal faces faceZone name masterPatch top; //the name of the master boundary patch slavePatch bottom; //the name of the slave boundary patch triggerTimes 2 (2.0 3.0); //the times to trigger the condition (in this case, at 2.0 and 3.0 seconds) } |
|
April 30, 2012, 15:14 |
|
#9 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
I don't know anything about dynamic mesh, but looking at attachDetach.C, the dictionary constructor expects everything to be in the dictionary root. So you need to use "subDict" in your constructor call.
Assume the dictionary you show above is myDict. Your attachDetach constructor call should be something like: Code:
attachDetach myAttachDetachObject ( attachDetachName, myDict.subDict("flap1"), 0, // "index"? I don't know what index is... mesh );
__________________
~~~ Follow me on twitter @DavidGaden |
|
April 30, 2012, 19:24 |
|
#10 |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
Thanks! I found the error: in the attachDetachFvMesh from 1.6-ext, the modifiers are inside a PtrList<entries>, so the syntax in the dictionary should be:
Code:
modifiers ( flap1 {...} flap2 {...} //etc. ); |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Creating a symmTensorField from a scalarField | maninthemail | OpenFOAM | 13 | April 22, 2023 07:43 |
writing subDict in a dictionary | ubaid | OpenFOAM Programming & Development | 3 | October 25, 2014 18:17 |
boundary condition scalarField in parallel | nlc | OpenFOAM | 4 | November 5, 2010 20:26 |
Problem with rhoSimpleFoam | matteo_gautero | OpenFOAM Running, Solving & CFD | 0 | February 28, 2008 07:51 |
FoamX error aachenBomb case | Ervin Adorean (Adorean) | OpenFOAM Pre-Processing | 13 | March 7, 2005 04:50 |