← Back to team overview

dolfin team mailing list archive

Re: problem with Rectangle::coordinates()

 

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

import os, commands

# Get compiler from pkg-config
compiler = commands.getoutput('pkg-config --variable=compiler dolfin')

# Create a SCons Environment based on the main os environment
env = Environment(ENV=os.environ, CXX=compiler)

# Get compiler flags from pkg-config
env.ParseConfig('pkg-config --cflags --libs dolfin')

# Program name
env.Program('test', 'main.cpp')

Follow ups

References