[petsc-users] TSSetIFunction
Jed Brown
jedbrown at mcs.anl.gov
Wed Mar 20 19:57:08 CDT 2013
"Jin, Shuangshuang" <Shuangshuang.Jin at pnnl.gov> writes:
> Another question is I know ex19.c is using real numbers only, if I run it alone, I should use arch-real to compile it successfully.
> However, because my code has to do complex numbers computation somewhere else, I built the PETSc with an ARCH-complex. Now when I integrate ex19.c into my code, I get the following compilation error:
>
> [d3m956 at olympus ss00]$ make
> mpicxx -I/pic/projects/ds/petsc-dev/include -I/pic/projects/ds/petsc-dev/arch-complex/include -I/share/apps/openmpi/1.5.4/gcc/4.1.2/include -g -c -o simulation.o simulation.C
> simulation.C: In static member function ‘static PetscErrorCode Simulation::IFunction(_p_TS*, PetscReal, _p_Vec*, _p_Vec*, _p_Vec*, void*)’:
> simulation.C:25: error: no match for ‘operator/’ in ‘std::operator* [with _Tp = double](((const std::complex<double>&)((const std::complex<double>*)(& std::operator* [with _Tp = double](((const std::complex<double>&)((const std::complex<double>*)(x + 16u))), ((const std::complex<double>&)((const std::complex<double>*)(x + 16u))))))), ((const std::complex<double>&)((const std::complex<double>*)(x + 16u)))) / 3’
> make: *** [simulation.o] Error 1
>
> I guess it is because of the complex number and real number mismatch. But I’m not sure if it’s the case.
> simulation.C:25 corresponds to line “f[1] = (x[1]*x[1]*x[1]/3 - x[1])-x[0];” in the code:
std::complex did not overload division. You can change '3' above to '3.'
to make C++ use a suitable overloaded type. This lack of promotion is
the nature of std::complex. C99 complex is friendlier in this regard,
having no trouble with this code.
More information about the petsc-users
mailing list