From: young Date: Thu, 17 Oct 2013 09:15:19 +0000 (+0000) Subject: A trivial initialisation tests for SLEPc complex. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4aaeb0ca8096d002a6d9783b649469ae90c21c9f;p=dealii-svn.git A trivial initialisation tests for SLEPc complex. git-svn-id: https://svn.dealii.org/branches/branch_petscscalar_complex@31276 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/slepc_scalar_complex/00.cc b/tests/slepc_scalar_complex/00.cc new file mode 100644 index 0000000000..3a076f1bb6 --- /dev/null +++ b/tests/slepc_scalar_complex/00.cc @@ -0,0 +1,101 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// just check initialising SLEPc can be done and that it initialises +// PETSc in the way we expect, ie. *a* PETSc object exist. This is an +// approximate copy of slepc/00.cc.. + +#include "../tests.h" +#include +#include +#include +#include +#include + +#ifdef PETSC_USE_COMPLEX + +std::ofstream logfile ("00/output"); + +int main (int argc, char **argv) +{ + deallog.attach (logfile); + deallog.depth_console (1); + + try + { + logfile << "Initializing SLEPc (PETSc): " + << std::flush; + + SlepcInitialize (&argc, &argv, 0, 0); + { + logfile << "ok" + << std::endl; + + // Do something simple with PETSc + logfile << "Using PetscScalar:" + << std::endl; + + const PetscScalar pi_1i = numbers::PI + 1.*PETSC_i; + const PetscScalar two = 2.; + + logfile << " pi+1i: " << pi_1i + << std::endl + << " two: " << two + << std::endl + << " two times pi+1i: " << two *pi_1i + << std::endl; + + + logfile << "Finalizing SLEPc (PETSc): " + << std::flush; + + } + SlepcFinalize (); + + logfile << "ok" + << std::endl << std::endl; + } + + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} + +#endif diff --git a/tests/slepc_scalar_complex/00/cmp/generic b/tests/slepc_scalar_complex/00/cmp/generic new file mode 100644 index 0000000000..10a07daa27 --- /dev/null +++ b/tests/slepc_scalar_complex/00/cmp/generic @@ -0,0 +1,8 @@ + +Initializing SLEPc (PETSc): ok +Using PetscScalar: + pi+1i: (3.14159,1.00000) + two: (2.00000,0.00000) + two times pi+1i: (6.28319,2.00000) +Finalizing SLEPc (PETSc): ok +