CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   labelListList handling (http://www.cfd-online.com/Forums/openfoam/93739-labellistlist-handling.html)

Peter Müller October 25, 2011 08:31

labelListList handling
 
Hello together

Can anyone tell me how to find out the length of the lists in a labelListList?
Is there a function or do I have to iterate with a counter through the lists?

Thanks a lot

tomislav_maric October 26, 2011 03:00

Hi Peter,
means that the labelListList is just a List<> field with the List<label>,
so my guess is that you have to loop through to get the sizes. Check out
ListOps.H and ListListOps.H for generic algorithms defined on List<> and
List<List<> >.

Hope this helps,

Tomislav

olesen October 26, 2011 09:12

Quote:

Originally Posted by Peter Müller (Post 329353)
Hello together

Can anyone tell me how to find out the length of the lists in a labelListList?
Is there a function or do I have to iterate with a counter through the lists?

Take a look in ListListOps.H, the subSizes operation looks like what you want (haven't used it myself):

http://foam.sourceforge.net/docs/cpp...c0824cbecb892b

Peter Müller October 27, 2011 04:24

Hello together

Thanks a lot for your answers. I'm quite new in OpenFOAM and C++.
I have another question. When I try to create an exetuble with the wmake, I get the error

‘labeListList’ does not name a type

labelListList was used in my code like that:

const labeListList& FacesToPoint = cylField.pointFaces();

Where cylField is a vectorField which was created by a coordinate transform with cylindricalCS. What's the problem with my declaration?

An other problem is that i get an error while performing the coordinate transform:

error: no matching function for call to ‘Foam::cylindricalCS::globalToLocal(const Foam::Vector<double>&)’

Thanks

tomislav_maric October 27, 2011 04:34

Quote:

Originally Posted by Peter Müller (Post 329658)
Hello together

Thanks a lot for your answers. I'm quite new in OpenFOAM and C++.
I have another question. When I try to create an exetuble with the wmake, I get the error

‘labeListList’ does not name a type

labelListList was used in my code like that:

const labeListList& FacesToPoint = cylField.pointFaces();

Where cylField is a vectorField which was created by a coordinate transform with cylindricalCS. What's the problem with my declaration?

An other problem is that i get an error while performing the coordinate transform:

error: no matching function for call to ‘Foam::cylindricalCS::globalToLocal(const Foam::Vector<double>&)’

Thanks

Hi Peter,

those errors are compiler errors: there is no code in your program that implements (declares/defines) a labelListList. This type is a low-level container used by OpenFOAM. Have you created your .C and .H files manually for your application, or have you used:

Code:

foamNew source App appName
where "appName" is the name of your application, in your application directory?

Just in case you haven't used "foamNew" so far:

1) create the directory named as your application
2) change to this directory
3) execute the command above
4) edit Make/files and add "appName.C" in the first line
5) wmake

As for the cylindricalCS error:

error: no matching function for call to ‘Foam::cylindricalCS::globalToLocal(const Foam::Vector<double>&)’

Check out the cylindricalCS.H, in there you will find globalToLocal member functions:

there is a "bool" argument given to the functions as well that you need to define (bool translate).

If you are using a class, always go and find it using the Doxygen or in the source, and check out the declaration, this explains how it should be used...

Hope this helps..

Peter Müller October 27, 2011 07:25

Hi Maric

Thanks a lot for your quick reply. I created my application folder manually, but the files-and options files looks the same. The aim of this application is to create a mixingplane patch. At the moment I try to implement an algorithm who is able to detect the corner-points of the original mesh.

The class is named mpPolyPatch and inherits form PolyPatch. Since this is somehow similar to what coupledPolyPatch.C does, I took coupledPolyPatch as basic structure and tried to change it so that it fits to my requests.

Do I need another header-file to include/declare the class labelListList or do I have to specify some additional directories in the options-file of the MAKE-folder?

Thanks Peter

Bernhard October 27, 2011 08:00

If you really use this:
Code:

const labeListList& FacesToPoint = cylField.pointFaces();
Then it is only a typo, since you write labe instead of label.

tomislav_maric October 27, 2011 08:21

Quote:

Originally Posted by Bernhard (Post 329705)
If you really use this:
Code:

const labeListList& FacesToPoint = cylField.pointFaces();
Then it is only a typo, since you write labe instead of label.

:D of course.

Peter Müller October 27, 2011 08:32

Thanks so much. You wan't believe how long I tried to find the bug...
Today was a very efficient day :-)

tomislav_maric October 27, 2011 08:45

Quote:

Originally Posted by Peter Müller (Post 329715)
Thanks so much. You wan't believe how long I tried to find the bug...
Today was a very efficient day :-)

it's allways like this for me as well... I've spent the last 3 days trying to find a bug in the geometrical algorithm I'm working on, it turned out to be a rounding error..

This is my reaction when this happens:

:D Of course.

Peter Müller October 27, 2011 11:14

It seams that I was able to compile my application mpPolyPatch.C with "wmake libso". Can you tell me whether there is a possibility to check whether everthing wen't allright. For example check whether the new polyPatch, mpPolyPatch, is available in the library?

Thanks

tomislav_maric October 28, 2011 03:58

Quote:

Originally Posted by Peter Müller (Post 329754)
It seams that I was able to compile my application mpPolyPatch.C with "wmake libso". Can you tell me whether there is a possibility to check whether everthing wen't allright. For example check whether the new polyPatch, mpPolyPatch, is available in the library?

Thanks


If you have compiled it, it should be available. Check out the Make/files and see the line

Code:

LIB = $(FOAM_USER_LIBBIN)/libSomeName
If you want to use this library, then you need to include the header file myPolyPatch.H in the application that will use it. After that, you should edit the Make/options file and put this at the end of the list EXE_INC:

Code:

-I/path/to/myPolyPatch/directory/lnInclude
so that wmake knows where are the include files of the myPolyPatch (modify this so that it suits your situation of course, this is just an explanation). Also, in Make/options file, add

Code:

-llSomeName
where SomeName is the name of the library into which you have compiled myPolyPatch.


Note: in Make/options, every line in the directory/lib lists must end with "\" without the space (this doesn't work "\ "), except for the last one.

Peter Müller October 28, 2011 11:11

Hello Maric

Thank you so much for all your explanations. Until now the algorithm is able to properly detect the corner points of the boundary patch. What I would like to do now is reconstruct the edges surrounding the patch.

I have created a labelListList containing a list with points and the edges according to each point.

I did this with:

const labelListList& edgesToPoint = this->pointEdges()

I would now like to create a list of the points shared by one edge but I could not find a function like

const labelListList& edgesToPoint = this->edgePoints();

Do I have to loop through the pointEdges labelListList to find the points according to one edge?

Thanks a lot

Peter Müller October 31, 2011 06:10

Hello together

I would like to create something like an array where I can store integers inside. The reason why it is something is that I don't know the final length of the array and would therefore like to have something where I don't have to devine this.

I was thinking about a list but I'm not sure whether this would be the right choice and if yes i don't really know how I have to declare it correctly.

Can I write something like this?

List<int> myIntList;

Thanks a lot

olesen October 31, 2011 07:49

Quote:

Originally Posted by Peter Müller (Post 330125)
Hello together

I would like to create something like an array where I can store integers inside. The reason why it is something is that I don't know the final length of the array and would therefore like to have something where I don't have to devine this.

I was thinking about a list but I'm not sure whether this would be the right choice and if yes i don't really know how I have to declare it correctly.

Can I write something like this?

List<int> myIntList;

Thanks a lot

Looks fine. There is no major difference between a List<int> and a List<label> (since label is currently just a typedef for int), but I'd generally stick to using List<label> or labelList for consistency with the rest of OPENFOAM. Depending on your needs, a DynamicList might also be useful to consider if you are intending to a lot of resizing operations.

Peter Müller November 2, 2011 05:42

Hello

I'd like to use the Foam memberfunction polySplineEdge but it always tells me that polySplineEdge is not a memberfunction of Foam. If I take a look at the Doxygen "documentation" I find Foam::polySplineEdge.

I tried to use it like this:

pointField mySpline = Foam::polySplineEdge(.....)

Thanks

Peter Müller June 25, 2012 08:46

Hello together

Does anybody know how to create a labelList like it is possible with the integer arrays? Something like:

labelList myLabelList = {3, 1, 5, 7, 8}

Or even better, how to create a labelListList

labelListList myLabelListList = {3, 1, 5, 7, 8},
{2, 3},
{3,1,8},
{...................

I would like to test an utility and it would simplify the testing a lot if it would be possible to create labelListList somehow like this.

Thanks in advance

olesen June 25, 2012 08:54

Quote:

Originally Posted by Peter Müller (Post 368175)
Hello together

Does anybody know how to create a labelList like it is possible with the integer arrays? Something like:

labelList myLabelList = {3, 1, 5, 7, 8}

Or even better, how to create a labelListList

labelListList myLabelListList = {3, 1, 5, 7, 8},
{2, 3},
{3,1,8},
{...................

I would like to test an utility and it would simplify the testing a lot if it would be possible to create labelListList somehow like this.

Thanks in advance

A direct construction isn't so easy without lots of tricks.
Doesn't look really pretty, but I don't see why a stream constructor should not work:
Code:

    labelListList myLabListList(IStringStream(
"("
  "(3 1 5 7 8)"
  "(2 3)"
  "(3 1 8)
")"
)());


Peter Müller June 25, 2012 10:39

Thank you very much. This works fine for me.
Have a nice day.

Daniel73 May 20, 2014 05:49

Hi,
Does anybody know how to create a dynamic labelListList ?
Because when i write : "const labelListList & listlist; " i get the error because of non-initialization.
Do you have any suggestion to create empty labelListList?because i don't want to initialize it in declaration step...
Tnx


All times are GMT -4. The time now is 05:26.