Is PetscScalar the correct type for us?
Hi,
I wanted to do some test runs with HyTeG on the LRZ Linux cluster. For this I wanted to build with HYTEG_BUILD_WITH_PETSC=yes. It turns out that this fails. I get the following errors
[ 0%] Building CXX object src/hyteg/CMakeFiles/hyteg.dir/edgedofspace/EdgeDoFProjectNormalOperator.cpp.o
/dss/dsshome1/lxc07/uk502aj/HyTeG/HyTeG/src/hyteg/FunctionMemory.hpp(48): error: static assertion failed with "Wrong ValueType template"
static_assert( std::is_arithmetic< ValueType >::value, "Wrong ValueType template" );
^
detected during:
instantiation of class "hyteg::FunctionMemory<ValueType> [with ValueType=PetscScalar]" at line 587 of "/dss/dsshome1/lxc07/uk502aj/HyTeG/HyTeG/src/hyteg/edgedofspace/EdgeDoFMacroEdge.hpp"
instantiation of "void hyteg::edgedof::macroedge::createVectorFromFunction(const walberla::uint_t={size_t={unsigned long}} &, hyteg::Edge &, const hyteg::PrimitiveDataID<hyteg::FunctionMemory<ValueType>, hyteg::Edge> &, const hyteg::PrimitiveDataID<hyteg::FunctionMemory<int>, hyteg::Edge> &, const std::shared_ptr<hyteg::VectorProxy> &) [with ValueType=PetscScalar]" at line 51 of "/dss/dsshome1/lxc07/uk502aj/HyTeG/HyTeG/src/hyteg/edgedofspace/EdgeDoFPetsc.hpp"
/dss/dsshome1/lxc07/uk502aj/HyTeG/HyTeG/src/hyteg/edgedofspace/EdgeDoFMacroEdge.hpp(593): error: no suitable conversion function from "PetscScalar" to "walberla::real_t={double}" exists
vec->setValue( numerator[idx], src[idx] );
A closer inspection shows that the reason seems to be that the PETSc installation on the cluster makes PetscScalar
a complex value. Output of
#include <type_traits>
#include <iostream>
#include <petscsys.h>
int main( void ) {
PetscScalar x = 4.0;
std::cout << "Value of x is " << x << std::endl;
std::cout << "std::is_arithmetic< PetscScalar > gives " << std::is_arithmetic< PetscScalar >::value << std::endl;
}
is
Value of x is (4,0)
std::is_arithmetic< PetscScalar > gives 0
This behaviour seems to be okay from the PETSc side as the documentation leaves open whether it will be a real- or complex-valued scalar.
Maybe PetscReal
is the datatype we actually want to use?
Cheers
Marcus