← Back to team overview

dolfin team mailing list archive

Re: problem with Rectangle::coordinates()

 

For me it works too. The only problem I realized is that in current dolfin version enum has been replaced by string, so the construction of the mesh should be rather:
Rectangle rectangle(0.0, 0.0, 1, 2, 3, 7, "right");

Always remember to include error messages. Without them we can only guest, what's your problem.

cheers
BArtek




Patrick Riesen wrote:
Hi phil,

i copied your code fragment and compile/run it without problems:
this is the output:

0
0
0.333333
0
0.666667
0
1
0
0
0.285714
0.333333
0.285714
0.666667
0.285714
1
0.285714
0
0.571429
0.333333
0.571429
0.666667
0.571429
1
0.571429
0
0.857143
0.333333
0.857143
0.666667
0.857143
1
0.857143
0
1.14286
0.333333
1.14286
0.666667
1.14286
1
1.14286
0
1.42857
0.333333
1.42857
0.666667
1.42857
1
1.42857
0
1.71429
0.333333
1.71429
0.666667
1.71429
1
1.71429
0
2
0.333333
2
0.666667
2
1
2

there's maybe some error in your Makefile/SConstruct file or your dolfin installation? i attached the SConstruct file. the ordering seems like you say [x0, y0, x1, y1 etc.] but i hope you can figure it out by this or get the code to run on you own machine.

cheers,
patrick


phil marinier wrote:
I am trying to use the coordinates() function in c++. When I tested it out using python to see how it worked, I got back what seemed like a 2d numpy array, athough it could have been a one dimensional array of arrays. When I tried to use it in C++ I assumed that I needed to do this:

double **coordinates;
coordinates = rectangle.coordinates();

which gave me an error because the coordinates() function returns a double* not a double** I wrote a little program to test the output of the coordinates() function:

#include <dolfin.h>
#include <iostream>

using namespace dolfin;

int main()
{
    Rectangle rectangle(0.0, 0.0, 1, 2, 3, 7, Rectangle::right);
    double *coordinates;
    coordinates = rectangle.coordinates();
    for (int j = 0; j < 64; j++)
        std::cout << coordinates[j] << std::endl;
}

which didn't even compile and I can't make sense of the pages of error msgs I got. I tried commenting out the for loop and there was no change. My question is twofold. First, how do I use this function in C++ and get it to compile, and second, what does the output look like? I assumed the resulting 1d array would be [x0, y0, x1, y1, .... , xn, yn]. Is that in fact the case?

Thank you for your help

Phil



------------------------------------------------------------------------

_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev


------------------------------------------------------------------------

_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev



References