LCOV - code coverage report
Current view: top level - ugbase/lib_disc/local_finite_element - local_finite_element_id.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 38 0
Test Date: 2025-09-21 23:31:46 Functions: 0.0 % 3 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              : #include "local_finite_element_id.h"
      34              : #include <string>
      35              : #include <algorithm> // std::transform
      36              : #include <cctype> // std::tolower
      37              : #include "common/error.h"
      38              : 
      39              : namespace ug{
      40              : 
      41              : /// writes the Identifier to the output stream
      42            0 : std::ostream& operator<<(std::ostream& out,       const LFEID& v)
      43              : {
      44            0 :         std::stringstream ss;
      45            0 :         if(v.m_order >= 0) ss << v.m_order;
      46            0 :         else if(v.m_order == LFEID::ADAPTIV) ss << "adaptive";
      47            0 :         else ss << "invalid";
      48              : 
      49            0 :         switch(v.m_type)
      50              :         {
      51            0 :                 case LFEID::LAGRANGE: out << "(Lagrange, " << v.m_dim << ", " << ss.str() << ")"; break;
      52            0 :                 case LFEID::CROUZEIX_RAVIART: out << "(Crouzeix-Raviart, " << v.m_dim << ", " << ss.str() << ")"; break;
      53            0 :                 case LFEID::PIECEWISE_CONSTANT: out << "(Piecewise constant, " << v.m_dim << ", " << ss.str() << ")"; break;
      54            0 :                 case LFEID::DG: out << "(DG, " << v.m_dim << ", " << ss.str() << ")"; break;
      55            0 :                 case LFEID::MINI: out << "(MINI, " << v.m_dim << ", " << ss.str() << ")"; break;
      56            0 :                 case LFEID::NEDELEC: out << "(Nedelec, " << v.m_dim << ", " << ss.str() << ")"; break;
      57            0 :                 case LFEID::USER_DEFINED: out << "(User defined, " << v.m_dim << ", " << ss.str() << ")"; break;
      58            0 :                 default: out << "(unknown, " << v.m_dim << ", " << ss.str() << ")";
      59              :         }
      60            0 :         return out;
      61            0 : }
      62              : 
      63              : ///     returns the LFEID for a combination of Space and order
      64            0 : LFEID ConvertStringToLFEID(const char* type, int dim, int order)
      65              : {
      66              : //      convert to string
      67            0 :         std::string typeStr(type);
      68              :         std::transform(typeStr.begin(), typeStr.end(), typeStr.begin(), ::tolower);
      69              : 
      70              : //      compare
      71              :         LFEID::SpaceType eType = LFEID::NONE;
      72            0 :                  if(typeStr == "lagrange") eType = LFEID::LAGRANGE;
      73            0 :         else if(typeStr == "crouzeix-raviart") eType = LFEID::CROUZEIX_RAVIART;
      74            0 :         else if(typeStr == "piecewise-constant") eType = LFEID::PIECEWISE_CONSTANT;
      75            0 :         else if(typeStr == "mini") eType = LFEID::MINI;
      76            0 :         else if(typeStr == "dg") eType = LFEID::DG;
      77            0 :         else if(typeStr == "nedelec") eType = LFEID::NEDELEC;
      78            0 :         else UG_THROW("Cannot find local finite element space: "<<type<<", "<<order);
      79              : 
      80            0 :         return LFEID(eType, dim, order);
      81              : }
      82              : 
      83              : 
      84              : ///     returns the LFEID for a combination of Space and order
      85            0 : LFEID ConvertStringToLFEID(const char* type, int dim)
      86              : {
      87              :         int order;
      88              : //      convert to string
      89            0 :         std::string typeStr(type);
      90              :         std::transform(typeStr.begin(), typeStr.end(), typeStr.begin(), ::tolower);
      91              : 
      92              : //      compare
      93              :         LFEID::SpaceType eType = LFEID::NONE;
      94            0 :         if(typeStr == "lagrange"){
      95              :                 eType = LFEID::LAGRANGE;
      96              :                 order = 1;
      97              :         }
      98            0 :         else if(typeStr == "crouzeix-raviart"){
      99              :                 eType = LFEID::CROUZEIX_RAVIART;
     100              :                 order = 1;
     101              :         }
     102            0 :         else if(typeStr == "piecewise-constant"){
     103              :                 eType = LFEID::PIECEWISE_CONSTANT;
     104              :                 order = 0;
     105              :         }
     106            0 :         else if(typeStr == "dg"){
     107              :                 // eType = LFEID::DG;
     108            0 :                 UG_THROW("Unspecified order for DG approximation space.\n");
     109              :         }
     110            0 :         else if(typeStr == "mini"){
     111              :                 //eType = LFEID::MINI;
     112              :                 // order = 1;
     113            0 :                 UG_THROW("Unspecified order for MINI approximation space.\n");
     114              :         }
     115            0 :         else if(typeStr == "nedelec"){
     116              :                 eType = LFEID::NEDELEC;
     117              :                 order = 1;
     118              :         }
     119            0 :         else UG_THROW("Cannot find local finite element space: "<<type);
     120              : 
     121            0 :         return LFEID(eType, dim, order);
     122              : }
     123              : 
     124              : /// @}
     125              : 
     126              : } // end namespace ug
        

Generated by: LCOV version 2.0-1