LCOV - code coverage report
Current view: top level - ugbase/lib_disc/spatial_disc - ass_tuner_impl.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 42 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 48 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2013-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Authors: Raphael Prohl, 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_DISC__SPATIAL_DISC__ASS_TUNER_IMPL__
      34              : #define __H__UG__LIB_DISC__SPATIAL_DISC__ASS_TUNER_IMPL__
      35              : 
      36              : #include "ass_tuner.h"
      37              : 
      38              : namespace ug{
      39              : 
      40              : template <typename TAlgebra>
      41            0 : void AssemblingTuner<TAlgebra>::resize(ConstSmartPtr<DoFDistribution> dd,
      42              :                                   vector_type& vec) const
      43              : {
      44            0 :         if (single_index_assembling_enabled()){ vec.resize(1);}
      45              :         else{
      46              :                 const size_t numIndex = dd->num_indices();
      47              :                 vec.resize(numIndex);
      48              :         }
      49              : 
      50            0 :         if (m_bClearOnResize)
      51              :                 vec.set(0.0);
      52            0 : }
      53              : 
      54              : template <typename TAlgebra>
      55            0 : void AssemblingTuner<TAlgebra>::resize(ConstSmartPtr<DoFDistribution> dd,
      56              :                                                                   matrix_type& mat) const
      57              : {
      58            0 :         if (single_index_assembling_enabled())
      59              :         {
      60            0 :                 if (m_bClearOnResize) mat.resize_and_clear(1, 1);
      61            0 :                 else mat.resize_and_keep_values(1,1);
      62              :         }
      63              :         else
      64              :         {
      65              :                 const size_t numIndex = dd->num_indices();
      66            0 :                 if (m_bClearOnResize)
      67              :                 {
      68            0 :                         if (m_bMatrixStructureIsConst)
      69              :                         {
      70            0 :                                 UG_COND_THROW(mat.num_rows() != dd->num_indices() || mat.num_cols() != dd->num_indices(),
      71              :                                         "The assembling tuner is set to use a constant matrix structure, "
      72              :                                         "but the number of indices in the new matrix is different from that in the old one.");
      73            0 :                                 mat.clear_retain_structure();
      74              :                         }
      75              :                         else
      76            0 :                                 mat.resize_and_clear(numIndex, numIndex);
      77              :                 }
      78              :                 else
      79            0 :                         mat.resize_and_keep_values(numIndex, numIndex);
      80              :         }
      81            0 : }
      82              : 
      83              : template <typename TAlgebra>
      84              : template <typename TElem>
      85              : bool AssemblingTuner<TAlgebra>::element_used(TElem* elem) const
      86              : {
      87            0 :         if(m_pBoolMarker)
      88            0 :                 if(!m_pBoolMarker->is_marked(elem)) return false;
      89              : 
      90              :         return true;
      91              : }
      92              : 
      93              : 
      94              : template <typename TAlgebra>
      95              : template <typename TElem>
      96            0 : void AssemblingTuner<TAlgebra>::collect_selected_elements(std::vector<TElem*>& vElem,
      97              :                                                      ConstSmartPtr<DoFDistribution> dd, int si) const
      98              : {
      99            0 :         if (!m_pSelector)
     100            0 :                 UG_THROW("Selector-iterator not set!")
     101              : 
     102              :         Selector* sel = m_pSelector;
     103            0 :         const ISubsetHandler& sh = *dd->subset_handler();
     104              : 
     105              :         for(typename Selector::traits<TElem>::iterator iter = sel->begin<TElem>();
     106            0 :                 iter != sel->end<TElem>(); ++iter)
     107              :         {
     108            0 :                 if(sh.get_subset_index(*iter) == si)
     109            0 :                         vElem.push_back(*iter);
     110              :         }
     111            0 : }
     112              : 
     113              : template <typename TAlgebra>
     114            0 : void AssemblingTuner<TAlgebra>::set_dirichlet_row(matrix_type& mat, const DoFIndex& ind) const
     115              : {
     116              :         //      check if assembling has been carried out with respect to one index only.
     117              :         //      For that case assembling-matrices have been resized to a block-matrix at one DoF only.
     118            0 :         if(single_index_assembling_enabled())
     119              :         {
     120            0 :                 if (mat.num_rows() != 1 || mat.num_cols() != 1)
     121            0 :                         UG_THROW("#rows and #cols need to be 1 for setting dirichlet rows"
     122              :                                         " in an index-wise manner.")
     123              : 
     124            0 :                 const size_t index = ind[0];
     125            0 :                 if (index == m_SingleAssIndex)
     126            0 :                         SetDirichletRow(mat, 0, ind[1]);
     127              :         }
     128              :         else{
     129              :                 SetDirichletRow(mat, ind);
     130              :         }
     131            0 : }
     132              : 
     133              : template <typename TAlgebra>
     134            0 : void AssemblingTuner<TAlgebra>::set_dirichlet_val(vector_type& vec, const DoFIndex& ind, const double val) const
     135              : {
     136              :         //      check if assembling has been carried out with respect to one index only.
     137              :         //      For that case assembling-vectors have been resized to a block-vector at one DoF only.
     138            0 :         if(single_index_assembling_enabled())
     139              :         {
     140            0 :                 if(vec.size() != 1)
     141            0 :                         UG_THROW("vector-size needs to be 1 for setting dirichlet values"
     142              :                                         " in an index-wise manner.");
     143              : 
     144            0 :                 const size_t index = ind[0];
     145            0 :                 if(index == m_SingleAssIndex)
     146            0 :                         BlockRef(vec[0], ind[1]) = val;
     147              :         }
     148              :         else{
     149            0 :                 DoFRef(vec, ind) = val;
     150              :         }
     151            0 : }
     152              : 
     153              : 
     154              : } // end namespace ug
     155              : 
     156              : #endif /* __H__UG__LIB_DISC__SPATIAL_DISC__ASS_TUNER_IMPL__ */
        

Generated by: LCOV version 2.0-1