CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

face functionality for a DynamicList

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

Like Tree1Likes
  • 1 Post By deepsterblue

Reply
 
LinkBack Thread Tools Display Modes
Old   November 30, 2011, 07:33
Default face functionality for a DynamicList
  #1
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 259
Blog Entries: 5
Rep Power: 11
tomislav_maric is on a distinguished road
Hi everyone,

I'm using the DynamicList for storing an extensively variable number of points and corresponding faces. If I want to use the face functionality that relies on the pointField, such as the face::normal or face::mag, the options I have considered so far are the following (please be kind and note that these are fast written small descriptive code snippets):

1) Templating the face class into tFace, and typedefing the template for the pointField:

template< class Points >
class tFace
{
private:
// blah
public:
// blah blah, blabidi blah

normal( const Points & );

mag (const Points & );
}

and then to save myself:

typedef genericFace<pointField> face;

I'm sure this wouldn't break things, because the functionality of the face is preserved (I'm not making the face a different container, I'm just changing the Access functions part of the interface). Still, it's a bad habit to change the core library... so I'm skeptical.

2) I've tried slicing via references to avoid copying the data, but it doesn't work, the classes are distinct (diverging from List<T> into DynamicList and separately into Field<Type>).

3) I've tried brute force: the reinterpret_cast which just killed me because of the T* __restricted__ v_ in the UList (segmentation fault signal)

4) I've tried the xferMoveTo and friends, but: copying is the thing that I'm trying to avoid, this operation will be performed 100 of thousands of times in a single time step, xferMoveTo actually removes the data from the DynamicList and "puts it" into the pointField.

5) I'm thinking about switching the container to pointField, but I'm really skeptical because a lot of the algorithms rely on the DynamicList.

6) There is an option to do a local implementation of the algorithms, but I'm playing with the idea of re-using the code of the face class, otherwise if I do a local implementation, I may just use List<label> or write a small concrete type for my face... like... "dynamicFace" (inheriting from face wouldn't help here).

Any thoughts on this?

Tomislav
tomislav_maric is offline   Reply With Quote

Old   November 30, 2011, 13:13
Default
  #2
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 386
Rep Power: 15
deepsterblue will become famous soon enough
Isn't there a DynamicField class that you could use? It's identical to the Field class, but allows resizing.
tomislav_maric likes this.
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Old   November 30, 2011, 19:04
Default
  #3
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 259
Blog Entries: 5
Rep Power: 11
tomislav_maric is on a distinguished road
Quote:
Originally Posted by deepsterblue View Post
Isn't there a DynamicField class that you could use? It's identical to the Field class, but allows resizing.
Thanks Sandeep!

This works just fine:

Code:
    DynamicField<point> dPoints;

    dPoints.append(point(0,0,0));
    dPoints.append(point(0,0,0));
    dPoints.append(point(0,0,0));
    dPoints.append(point(0,0,0));

    face f(4);

    forAll(f, I)
    {
        f[I] = I;
    }

    f.mag(dPoints);
I'll check the class out some more tomorrow when I get some sleep... it seems (from the public part of the interface) similar to DynamicList... but because it's inherited from the Field I can feed it to the face. Coolio. Thanks again!
tomislav_maric is offline   Reply With Quote

Reply

Tags
code re-use, dynamiclist, face, template

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
Import netgen mesh to OpenFOAM hsieh Open Source Meshers: Gmsh, Netgen, CGNS, ... 32 September 13, 2011 05:50
BlockMeshmergePatchPairs hjasak OpenFOAM Native Meshers: blockMesh 11 August 15, 2008 07:36
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55
Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Native Meshers: blockMesh 10 April 2, 2007 14:00
Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 2 July 15, 2005 04:15


All times are GMT -4. The time now is 06:52.