Skip to content
Snippets Groups Projects
Select Git revision
  • 36ccac01c945b192d2b2ebf0d03d43c6eab50a06
  • master default
  • cgnsUnstructured
  • partitioning
  • poppler
  • HighOrderBLCurving
  • gmsh_3_0_4
  • gmsh_3_0_3
  • gmsh_3_0_2
  • gmsh_3_0_1
  • gmsh_3_0_0
  • gmsh_2_16_0
  • gmsh_2_15_0
  • gmsh_2_14_1
  • gmsh_2_14_0
  • gmsh_2_13_2
  • gmsh_2_13_1
  • gmsh_2_12_0
  • gmsh_2_11_0
  • gmsh_2_10_1
  • gmsh_2_10_0
  • gmsh_2_9_3
  • gmsh_2_9_2
  • gmsh_2_9_1
  • gmsh_2_9_0
  • gmsh_2_8_6
26 results

BasisFactory.cpp

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    BasisFactory.cpp 1.99 KiB
    // Gmsh - Copyright (C) 1997-2012 C. Geuzaine, J.-B-> Remacle
    //
    // See the LICENSE.txt file for license information. Please report all
    // bugs and problems to the public mailing list <gmsh@geuz.org>.
    
    #include "GmshDefines.h"
    #include "GmshMessage.h"
    #include "polynomialBasis.h"
    #include "pyramidalBasis.h"
    #include "pointsGenerators.h"
    #include "BasisFactory.h"
    
    std::map<int, nodalBasis*> BasisFactory::fs;
    std::map<int, JacobianBasis*> BasisFactory::js;
    std::map<int, bezierBasis*> BasisFactory::bs;
    
    const nodalBasis* BasisFactory::getNodalBasis(int elementType)
    {
      // If the Basis has already been built, return it.
      std::map<int, nodalBasis*>::const_iterator it = fs.find(elementType);
      if (it != fs.end()) {
        return it->second;
      }
      // Get the parent type to see which kind of basis
      // we want to create
      int parentType = MElement::ParentTypeFromTag(elementType);
      nodalBasis* F = NULL;
    
      switch(parentType) {
        case(TYPE_PNT):
        case(TYPE_LIN):
        case(TYPE_TRI):
        case(TYPE_QUA):
        case(TYPE_PRI):
        case(TYPE_TET):
        case(TYPE_HEX):
          F = new polynomialBasis(elementType);
          break;
        case(TYPE_PYR):
          F = new pyramidalBasis(elementType);
          break;
        default:
          Msg::Error("Unknown type of element.");
          return NULL;
      }
    
      // FIXME: check if already exists to deallocate if necessary
      fs.insert(std::make_pair(elementType, F));
    
      return fs[elementType];
    }
    
    const bezierBasis* BasisFactory::getBezierBasis(int elementType)
    {
      std::map<int, bezierBasis*>::const_iterator it = bs.find(elementType);
      if (it != bs.end())
        return it->second;
    
      bezierBasis* B = new bezierBasis(elementType);
      if (B) bs.insert(std::make_pair(elementType, B));
      return B;
    }
    
    const JacobianBasis* BasisFactory::getJacobianBasis(int elementType)
    {
      std::map<int, JacobianBasis*>::const_iterator it = js.find(elementType);
      if (it != js.end())
        return it->second;
    
      JacobianBasis* J = new JacobianBasis(elementType);
      if (J) js.insert(std::make_pair(elementType, J));
      return J;
    }