CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

dictionary scalarField formatting

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   April 27, 2012, 14:31
Default dictionary scalarField formatting
  #1
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 725
Rep Power: 18
mturcios777 will become famous soon enough
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.
mturcios777 is offline   Reply With Quote

Old   April 27, 2012, 17:34
Default
  #2
Senior Member
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin,Ireland
Posts: 565
Rep Power: 19
bigphil will become famous soon enoughbigphil will become famous soon enough
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);
Philip
bigphil is offline   Reply With Quote

Old   April 27, 2012, 17:50
Default
  #3
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 725
Rep Power: 18
mturcios777 will become famous soon enough
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);
and get the following error:

Code:
--> FOAM FATAL IO ERROR:
    Attempt to return dictionary entry as a primitive
mturcios777 is offline   Reply With Quote

Old   April 27, 2012, 17:54
Default
  #4
Senior Member
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin,Ireland
Posts: 565
Rep Power: 19
bigphil will become famous soon enoughbigphil will become famous soon enough
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");
Philip
bigphil is offline   Reply With Quote

Old   April 27, 2012, 18:04
Default
  #5
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 725
Rep Power: 18
mturcios777 will become famous soon enough
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!
mturcios777 is offline   Reply With Quote

Old   April 27, 2012, 20:07
Default
  #6
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 725
Rep Power: 18
mturcios777 will become famous soon enough
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?
mturcios777 is offline   Reply With Quote

Old   April 30, 2012, 10:24
Default
  #7
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 397
Rep Power: 12
marupio is on a distinguished road
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")),
That's correct as far as I know.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   April 30, 2012, 13:26
Default
  #8
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 725
Rep Power: 18
mturcios777 will become famous soon enough
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)
}
Does anyone have a case that uses the attach/detach condition with a properly formatted dictionary?
mturcios777 is offline   Reply With Quote

Old   April 30, 2012, 14:14
Default
  #9
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 397
Rep Power: 12
marupio is on a distinguished road
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
    );
If you omit .subDict, you will get the error you mention above.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   April 30, 2012, 18:24
Default
  #10
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 725
Rep Power: 18
mturcios777 will become famous soon enough
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.
);
Has anyone used attachDetach in 2.1.x, particularly with compressible flow?
mturcios777 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
writing subDict in a dictionary ubaid OpenFOAM Programming & Development 3 October 25, 2014 17:17
Creating a symmTensorField from a scalarField maninthemail OpenFOAM 2 September 30, 2011 04:13
boundary condition scalarField in parallel ubald 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


All times are GMT -4. The time now is 00:19.