LCOV - code coverage report
Current view: top level - ugbase/lib_algebra - cpu_algebra_types.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2025-09-21 23:31:46 Functions: - 0 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2011-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Andreas Vogel
       4              :  * 
       5              :  * This file is part of UG4.
       6              :  * 
       7              :  * UG4 is free software: you can redistribute it and/or modify it under the
       8              :  * terms of the GNU Lesser General Public License version 3 (as published by the
       9              :  * Free Software Foundation) with the following additional attribution
      10              :  * requirements (according to LGPL/GPL v3 §7):
      11              :  * 
      12              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      13              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      14              :  * 
      15              :  * (2) The following notice must be displayed at a prominent place in the
      16              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (3) The following bibliography is recommended for citation and must be
      19              :  * preserved in all covered files:
      20              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      21              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      22              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      23              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      24              :  *   flexible software system for simulating pde based models on high performance
      25              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      26              :  * 
      27              :  * This program is distributed in the hope that it will be useful,
      28              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      29              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      30              :  * GNU Lesser General Public License for more details.
      31              :  */
      32              : 
      33              : #ifndef __H__UG__LIB_ALGEBRA__CPU_ALGEBRA_TYPES__
      34              : #define __H__UG__LIB_ALGEBRA__CPU_ALGEBRA_TYPES__
      35              : 
      36              : #include "algebra_type.h"
      37              : 
      38              : // vector and sparse_matrix
      39              : #include "cpu_algebra/vector.h"
      40              : #include "cpu_algebra/sparsematrix.h"
      41              : 
      42              : #ifdef UG_GPU
      43              : //#include "gpu_algebra/gpuvector.h"
      44              : //#include "gpu_algebra/gpusparsematrix.h"
      45              : #endif
      46              : 
      47              : // parallel support
      48              : #ifdef UG_PARALLEL
      49              :         #include "parallelization/parallel_vector.h"
      50              :         #include "parallelization/parallel_matrix.h"
      51              : #endif
      52              : 
      53              : #include "small_algebra/small_algebra.h"
      54              : namespace ug{
      55              : 
      56              : ////////////////////////////////////////////////////////////////////////////////
      57              : //   CPU Algebra
      58              : ////////////////////////////////////////////////////////////////////////////////
      59              : 
      60              : /*  Define different algebra types.
      61              :  *  An Algebra should export the following typedef:
      62              :  *  - matrix_type
      63              :  *  - vector_type
      64              :  */
      65              : 
      66              : ////////////////////////////////////////////////////////////////////////////////
      67              : //   CPU Algebra (Block 1x1 Algebra)
      68              : ////////////////////////////////////////////////////////////////////////////////
      69              : 
      70              : /**
      71              :  * \defgroup cpu_algebra CPU Algebra
      72              :  * \ingroup lib_algebra
      73              :  * \{
      74              :  */
      75              : 
      76              : struct CPUAlgebra
      77              : {
      78              : #ifdef UG_PARALLEL
      79              :                 typedef ParallelMatrix<SparseMatrix<double> > matrix_type;
      80              :                 typedef ParallelVector<Vector<double> > vector_type;
      81              : #else
      82              :                 typedef SparseMatrix<double> matrix_type;
      83              :                 typedef Vector<double> vector_type;
      84              : #endif
      85              : 
      86              :         static const int blockSize = 1;
      87              :         static AlgebraType get_type()
      88              :         {
      89          128 :                 return AlgebraType(AlgebraType::CPU, 1);
      90              :         }
      91              : };
      92              : 
      93              : // end group cpu_algebra
      94              : /// \}
      95              : 
      96              : /**
      97              :  * \defgroup crs_algebra CRS Algebra
      98              :  * \ingroup lib_algebra
      99              :  * \{
     100              :  */
     101              : /*#ifdef UG_GPU
     102              : struct GPUAlgebra
     103              : {
     104              : #ifdef UG_PARALLEL
     105              :                 typedef ParallelMatrix<GPUSparseMatrix<double> > matrix_type;
     106              :                 typedef ParallelVector<GPUVector<double> > vector_type;
     107              : #else
     108              :                 typedef GPUSparseMatrix<double> matrix_type;
     109              :                 typedef GPUVector<double> vector_type;
     110              : #endif
     111              : 
     112              :         static const int blockSize = 1;
     113              :         static AlgebraType get_type()
     114              :         {
     115              :                 return AlgebraType(AlgebraType::GPU, 1);
     116              :         }
     117              : };
     118              : #endif
     119              : // end group crs_algebra
     120              : /// \}
     121              : */
     122              : ////////////////////////////////////////////////////////////////////////////////
     123              : //   CPU Fixed Block Algebra
     124              : ////////////////////////////////////////////////////////////////////////////////
     125              : /// \addtogroup cpu_algebra
     126              : template<int TBlockSize>
     127              : struct CPUBlockAlgebra
     128              : {
     129              : #ifdef UG_PARALLEL
     130              :         typedef ParallelMatrix<SparseMatrix<DenseMatrix<FixedArray2<double, TBlockSize, TBlockSize> > > > matrix_type;
     131              :         typedef ParallelVector<Vector<DenseVector<FixedArray1<double, TBlockSize> > > > vector_type;
     132              : #else
     133              :         typedef  SparseMatrix<DenseMatrix<FixedArray2<double, TBlockSize, TBlockSize> > > matrix_type;
     134              :         typedef Vector<DenseVector<FixedArray1<double, TBlockSize> > > vector_type;
     135              : #endif
     136              : 
     137              :         static const int blockSize = TBlockSize;
     138              :         static AlgebraType get_type()
     139              :         {
     140          256 :                 return AlgebraType(AlgebraType::CPU, TBlockSize);
     141              :         }
     142              : };
     143              : 
     144              : ////////////////////////////////////////////////////////////////////////////////
     145              : //   CPU Variable Block Algebra
     146              : ////////////////////////////////////////////////////////////////////////////////
     147              : 
     148              : /// \addtogroup cpu_algebra
     149              : struct CPUVariableBlockAlgebra
     150              : {
     151              : #ifdef UG_PARALLEL
     152              :         typedef ParallelMatrix<SparseMatrix<DenseMatrix<VariableArray2<double> > > > matrix_type;
     153              :         typedef ParallelVector<Vector<DenseVector<VariableArray1<double> > > > vector_type;
     154              : #else
     155              :         typedef  SparseMatrix<DenseMatrix<VariableArray2<double> > > matrix_type;
     156              :         typedef Vector<DenseVector<VariableArray1<double> > > vector_type;
     157              : #endif
     158              : 
     159              :         static const int blockSize = AlgebraType::VariableBlockSize;
     160              :         static AlgebraType get_type()
     161              :         {
     162              :                 return AlgebraType(AlgebraType::CPU, AlgebraType::VariableBlockSize);
     163              :         }
     164              : };
     165              : 
     166              : }
     167              : #endif /* __H__UG__LIB_ALGEBRA__CPU_ALGEBRA_TYPES__ */
        

Generated by: LCOV version 2.0-1