LCOV - code coverage report
Current view: top level - ugbase/lib_disc/local_finite_element - local_finite_element_provider_impl.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 50 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 35 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              : #ifndef __H__UG__LIB_DISC__LOCAL_FINITE_ELEMENT__LOCAL_FINITE_ELEMENT_PROVIDER_IMPL__
      34              : #define __H__UG__LIB_DISC__LOCAL_FINITE_ELEMENT__LOCAL_FINITE_ELEMENT_PROVIDER_IMPL__
      35              : 
      36              : #include "common/common.h"
      37              : #include "local_finite_element_provider.h"
      38              : 
      39              : namespace ug{
      40              : 
      41              : ///////////////////////////////////////////
      42              : // LocalFiniteElementProvider
      43              : ///////////////////////////////////////////
      44              : 
      45              : template <int dim, typename TShape, typename TGrad>
      46              : std::map<LFEID, LocalFiniteElementProvider::LocalShapeFunctionSets<dim, TShape, TGrad> >&
      47            0 : LocalFiniteElementProvider::lsfs_map()
      48              : {
      49              :         typedef std::map<LFEID, LocalShapeFunctionSets<dim, TShape, TGrad> > Map;
      50            0 :         static Map map;
      51            0 :         return map;
      52              : };
      53              : 
      54              : template <int dim>
      55              : std::map<LFEID, LocalFiniteElementProvider::DimLocalDoFSets<dim> >&
      56            0 : LocalFiniteElementProvider::lds_map()
      57              : {
      58              :         typedef std::map<LFEID, DimLocalDoFSets<dim> > Map;
      59            0 :         static Map map;
      60            0 :         return map;
      61              : }
      62              : 
      63              : template <int dim, typename TShape, typename TGrad>
      64            0 : void LocalFiniteElementProvider::
      65              : register_set(const LFEID& id,
      66              :              ConstSmartPtr<LocalShapeFunctionSet<dim, TShape, TGrad> > set)
      67              : {
      68              : //      get type of map
      69              :         typedef std::map<LFEID, LocalShapeFunctionSets<dim, TShape, TGrad> > Map;
      70            0 :         Map& map = inst().lsfs_map<dim, TShape, TGrad>();
      71            0 :         LocalShapeFunctionSets<dim, TShape, TGrad>& vLSFS = map[id];
      72            0 :         const ReferenceObjectID roid = set->roid();
      73              : 
      74            0 :         if(vLSFS[roid].valid()){
      75            0 :                 UG_THROW("LocalFiniteElementProvider::register_set(): "
      76              :                                 "Reference type already registered for trial space: "<<id<<" and "
      77              :                                 " Reference element type "<<roid<<".");
      78              :         } else {
      79            0 :                 vLSFS[roid] = set;
      80              :         }
      81              : 
      82            0 :         if(m_mContSpace.find(id) == m_mContSpace.end()){
      83            0 :                 m_mContSpace.insert(std::map<LFEID, bool>::value_type(id, set->continuous()));
      84              :         }else{
      85            0 :                 if(m_mContSpace[id] != set->continuous())
      86            0 :                         UG_THROW("LocalFiniteElementProvider::register_set(): "
      87              :                                         "Reference type says continuous:"<<set->continuous()<<", but "
      88              :                                         " other Reference element says "<<m_mContSpace[id]<<".");
      89              :         }
      90              : 
      91              : //      register also as DimLocalDoFSet
      92            0 :         register_set(id, set.template cast_dynamic<DimLocalDoFSet<dim> >());
      93            0 : }
      94              : 
      95              : template <int dim>
      96            0 : void LocalFiniteElementProvider::
      97              : register_set(const LFEID& id,
      98              :              ConstSmartPtr<DimLocalDoFSet<dim> > set)
      99              : {
     100              : //      get type of map
     101              :         typedef std::map<LFEID, DimLocalDoFSets<dim> > Map;
     102            0 :         Map& map = inst().lds_map<dim>();
     103            0 :         DimLocalDoFSets<dim>& vLDS = map[id];
     104              : 
     105            0 :         const ReferenceObjectID roid = set->roid();
     106              : 
     107            0 :         if(vLDS[roid].valid()){
     108            0 :                 UG_THROW("LocalFiniteElementProvider::register_set(): "
     109              :                                  "Reference type already registered for trial space: "<<id<<" and "
     110              :                                  " Reference element type "<<roid<<".");
     111              :         } else {
     112            0 :                 vLDS[roid] = set;
     113              :         }
     114              : 
     115              : //      register also as LocalDoFSet
     116            0 :         register_set(id, set.template cast_dynamic<LocalDoFSet>());
     117            0 : }
     118              : 
     119              : 
     120              : template <int dim, typename TShape, typename TGrad>
     121              : ConstSmartPtr<LocalShapeFunctionSet<dim, TShape, TGrad> >
     122            0 : LocalFiniteElementProvider::
     123              : getptr(ReferenceObjectID roid, const LFEID& id, bool bCreate)
     124              : {
     125              : //      init provider and get map
     126              :         typedef std::map<LFEID, LocalShapeFunctionSets<dim, TShape, TGrad> > Map;
     127            0 :         Map& map = inst().lsfs_map<dim, TShape, TGrad>();
     128              : 
     129              : //      search for identifier
     130              :         typename Map::const_iterator iter = map.find(id);
     131            0 :         if(iter == map.end() || (iter->second)[roid].invalid())
     132              :         {
     133              :         //      try to create the set
     134            0 :                 if(bCreate){
     135            0 :                         create_set(roid, id);
     136            0 :                         return getptr<dim, TShape, TGrad>(roid, id, false);
     137              :                 }
     138            0 :                 return SPNULL;
     139              :         }
     140              : 
     141              : //      return shape function set
     142              :         return (iter->second)[roid];
     143              : }
     144              : 
     145              : template <int dim, typename TShape, typename TGrad>
     146              : const LocalShapeFunctionSet<dim, TShape, TGrad>&
     147            0 : LocalFiniteElementProvider::
     148              : get(ReferenceObjectID roid, const LFEID& id, bool bCreate)
     149              : {
     150            0 :         ConstSmartPtr<LocalShapeFunctionSet<dim, TShape, TGrad> > ptr =
     151              :                         getptr<dim,TShape,TGrad>(roid, id, bCreate);
     152              : 
     153            0 :         if(ptr.valid()) return *ptr;
     154              :         else
     155            0 :                 UG_THROW("LocalFiniteElementProvider: Local Shape Function Set not "
     156              :                                  "found for "<<roid<<" (world dim: "<<dim<<") and type = "<<id<<
     157              :                                  ". (This is usually due to: a) The function set is not implemented at "
     158              :                                  " all, or b) The finite element space is discontinuous but the "
     159              :                                  "evaluation is requested on a subelement, i.e. a grid object "
     160              :                                  "with dimension less than the dimension where the finite element"
     161              :                                  " space is defined.)");
     162              : }
     163              : 
     164              : template <int dim>
     165              : ConstSmartPtr<DimLocalDoFSet<dim> >
     166            0 : LocalFiniteElementProvider::
     167              : get_dof_ptr(ReferenceObjectID roid, const LFEID& id, bool bCreate)
     168              : {
     169              : //      init provider and get map
     170              :         typedef std::map<LFEID, DimLocalDoFSets<dim> > Map;
     171            0 :         Map& map = inst().lds_map<dim>();
     172              : 
     173              : //      search for identifier
     174              :         typename Map::const_iterator iter = map.find(id);
     175            0 :         if(iter == map.end() || (iter->second)[roid].invalid())
     176              :         {
     177              :         //      try to create the set
     178            0 :                 if(bCreate){
     179            0 :                         create_dof_set(roid, id);
     180            0 :                         return get_dof_ptr<dim>(roid, id, false);
     181              :                 }
     182            0 :                 return SPNULL;
     183              :         }
     184              : 
     185              : //      return shape function set
     186              :         return (iter->second)[roid];
     187              : }
     188              : 
     189              : template <int dim>
     190              : const DimLocalDoFSet<dim>&
     191            0 : LocalFiniteElementProvider::
     192              : get_dofs(ReferenceObjectID roid, const LFEID& id, bool bCreate)
     193              : {
     194            0 :         ConstSmartPtr<DimLocalDoFSet<dim> > ptr =
     195              :                         get_dof_ptr<dim>(roid, id, bCreate);
     196              : 
     197            0 :         if(ptr.valid()) return *ptr;
     198              :         else
     199            0 :                 UG_THROW("LocalFiniteElementProvider: Local DoF Set not "
     200              :                                  "found for "<<roid<<" (world dim: "<<dim<<") and type = "<<id);
     201              : }
     202              : 
     203              : }
     204              : #endif /* __H__UG__LIB_DISC__LOCAL_FINITE_ELEMENT__LOCAL_FINITE_ELEMENT_PROVIDER_IMPL__ */
        

Generated by: LCOV version 2.0-1