hpfem / hermes-legacy

hp-FEM library
http://hpfem.org/
68 stars 47 forks source link

Unify treatment of real and complex vectors in hermes_common #15

Closed solin closed 14 years ago

solin commented 14 years ago

We should avoid having separate methods such as get_c_array() and get_c_array_cplc(), get() and get_cplx() etc. This makes the code complicated.

certik commented 14 years ago

How would that be done?

solin commented 14 years ago

The vector knows whether it is real or complex, so why should the user control this by calling either get_c_array() or get_c_array_cplx() ? Imho the user should just call get_c_array() that would return a pointer to scalar.

certik commented 14 years ago

Because then you would have to compile hermes_common twice, once for real and once for complex numbers. Which I think is a step back, as I think we want to combine real and complex numbers in one project.

Maybe I am missing some other option how this would be done. I tried to do this for example:

double *get_c_array();
cplx *get_c_array();

but C++ doesn't allow such code -- it can only overload the methods if they have different arguments, not return values.

solin commented 14 years ago

So why not make it

void get_c_array(double *c_array);
void get_c_array(cplx *c_array);
certik commented 14 years ago

Nice idea, that should work. Well, probably something like this:

void get_c_array(double * &c_array);
void get_c_array(cplx * &c_array);
solin commented 14 years ago

This is a good question. In order to avoid segfaults, I would almost prefer to copy the vectors into user-supplied allocated structures rather than exposing the pointers.

certik commented 14 years ago

Well, we will use RPC anyways, and then you don't need to worry about this.

l-korous commented 14 years ago

Hi, this has been done I think, is that right?

solin commented 14 years ago

Yes, I am closing this. However, we have another issue in front ot us, which is to allow multiphysics problems where part is real and part complex. The resulting stiffness matrix must be real. I created an issue for this recently.