LCOV - code coverage report
Current view: top level - ugbase/lib_disc/dof_manager - function_pattern.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 44 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 6 0

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2010-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              : #include "function_pattern.h"
      34              : #include "lib_grid/algorithms/subset_dim_util.h"
      35              : #include "lib_disc/common/groups_util.h"
      36              : #include "common/util/string_util.h"
      37              : 
      38              : #ifdef UG_PARALLEL
      39              :         #include "pcl/pcl.h"
      40              : #endif
      41              : 
      42              : namespace ug{
      43              : 
      44            0 : void FunctionPattern::set_subset_handler(ConstSmartPtr<ISubsetHandler> spSH){
      45            0 :         if(m_bLocked)
      46            0 :                 UG_THROW("FunctionPattern: already locked, but trying to set"
      47              :                                 " new subset handler.");
      48              : 
      49            0 :         m_spSH = spSH;
      50            0 :         clear();
      51            0 : }
      52              : 
      53            0 : void FunctionPattern::add(const std::vector<std::string>& vName, LFEID lfeID)
      54              : {
      55              : //      add all names
      56            0 :         for(size_t i = 0; i < vName.size(); ++i)
      57              :         {
      58              :         //      get string
      59              :                 const char* name = vName[i].c_str();
      60              : 
      61              :         //      if already locked, return false
      62            0 :                 if(m_bLocked)
      63            0 :                         UG_THROW("FunctionPattern: Already fixed. Cannot change.");
      64              : 
      65              :         //      check that space type has been passed
      66            0 :                 if(lfeID.type() == LFEID::NONE || lfeID.order() < LFEID::ADAPTIV)
      67            0 :                         UG_THROW("FunctionPattern: Specified Local Finite Element Space "
      68              :                                                         <<lfeID<< " is not a valid space. "
      69              :                                                         "[use e.g. (Lagrange, p), (DG, p), ...].");
      70              : 
      71              :         //      check dimension
      72            0 :                 if(DimensionOfSubsets(*m_spSH) != lfeID.dim())
      73            0 :                         UG_THROW("FunctionPattern: Adding "<<lfeID<<" to whole grid of"
      74              :                                  " dimension "<<DimensionOfSubsets(*m_spSH)<<".")
      75              : 
      76              :         //      create temporary subset group
      77            0 :                 SubsetGroup tmpSSGrp;
      78            0 :                 tmpSSGrp.set_subset_handler(m_spSH);
      79            0 :                 tmpSSGrp.add_all();
      80              : 
      81              :         //      add to function list, everywhere = true, copy SubsetGroup
      82            0 :                 m_vFunction.push_back(Function(name, lfeID, true, tmpSSGrp));
      83              :         }
      84            0 : }
      85              : 
      86            0 : void FunctionPattern::add(const std::vector<std::string>& vName, LFEID lfeID,
      87              :                           const SubsetGroup& ssGrp)
      88              : {
      89              : //      add all names
      90            0 :         for(size_t i = 0; i < vName.size(); ++i)
      91              :         {
      92              :         //      get string
      93              :                 const char* name = vName[i].c_str();
      94              : 
      95              :         //      if already locked, return false
      96            0 :                 if(m_bLocked)
      97            0 :                         UG_THROW("FunctionPattern: Already fixed. Cannot change.");
      98              : 
      99              :         //      check that space type has been passed
     100            0 :                 if(lfeID.type() == LFEID::NONE || lfeID.order() < LFEID::ADAPTIV)
     101            0 :                         UG_THROW("FunctionPattern: "
     102              :                                         " Specified Local Finite Element Space "<<lfeID<< " is not "
     103              :                                         " a valid space. [use e.g. (Lagrange, dim, p), (DG, dim, p), ...].");
     104              : 
     105              :         //      check that subset handler are equal
     106            0 :                 if(m_spSH.get() != ssGrp.subset_handler().get())
     107            0 :                         UG_THROW("FunctionPattern: "
     108              :                                         "SubsetHandler of SubsetGroup does "
     109              :                                         "not match SubsetHandler of FunctionPattern.");
     110              : 
     111              :         //      check dimension
     112            0 :                 if(ssGrp.get_highest_subset_dimension() != lfeID.dim())
     113            0 :                         UG_THROW("FunctionPattern: Adding "<<lfeID<<" to subsets with"
     114              :                                          " highest dimension "<<ssGrp.get_highest_subset_dimension()<<".")
     115              : 
     116              :         //      add to function list, everywhere = false, copy SubsetGroup as given
     117            0 :                 m_vFunction.push_back(Function(name, lfeID, false, ssGrp));
     118              :         }
     119            0 : }
     120              : 
     121            0 : void FunctionPattern::add(const std::vector<std::string>& vName, LFEID lfeID,
     122              :                           const std::vector<std::string>& vSubset)
     123              : {
     124            0 :         add(vName, lfeID, SubsetGroup(m_spSH, vSubset));
     125            0 : }
     126              : 
     127              : 
     128            0 : size_t FunctionPattern::fct_id_by_name(const char* name) const
     129              : {
     130            0 :         for(size_t i = 0; i < m_vFunction.size(); ++i)
     131              :         {
     132            0 :                 if(m_vFunction[i].name == name)
     133            0 :                         return i;
     134              :         }
     135              : 
     136            0 :         UG_THROW("Function name "<<name<<" not found in pattern.");
     137              : }
     138              : 
     139            0 : int FunctionPattern::subset_id_by_name(const char* name) const
     140              : {
     141            0 :         for(int i = 0; i < m_spSH->num_subsets(); ++i)
     142              :         {
     143            0 :                 if(m_spSH->subset_info(i).name == name)
     144            0 :                         return i;
     145              :         }
     146              : 
     147            0 :         UG_THROW("Subset name "<<name<<" not found in Subset Handler.");
     148              : }
     149              : 
     150              : } // end namespace ug
        

Generated by: LCOV version 2.0-1