text: /*
  ============================================================================================
     This class contains data about a given FE function space, and methods for computing
     transformations of the local basis functions.
  
     This code references the header files:
  
     matrix_vector_defn.h
     matrix_vector_ops.h
     geometric_computations.h
     basis_function_computations.h
  
  
     NOTE: portions of this code are automatically generated!
  
     Copyright (c) 01-15-2018,  Shawn W. Walker
  ============================================================================================
  */
  
  /*------------ BEGIN: Auto Generate ------------*/
  // define the name of the FE basis function (should be the same as the filename of this file)
  #define SpecificFUNC        Data_Type_V_Space_phi_restricted_to_Sigma
  #define SpecificFUNC_str   "Data_Type_V_Space_phi_restricted_to_Sigma"
  
  // set the type of function space
  #define SPACE_type  "CG - lagrange_deg2_dim1"
  // set the name of function space
  #define SPACE_name  "V_Space"
  
  // set the Subdomain topological dimension
  #define SUB_TD  1
  // set the Domain of Integration (DoI) topological dimension
  #define DOI_TD  1
  // set the geometric dimension
  #define GD  3
  // set the number of cartesian tuple components (m*n) = 3 * 1
  #define NC  3
  // NOTE: the (i,j) tuple component is accessed by the linear index k = i + (j-1)*m
  // set the number of quad points
  #define NQ  1
  // set the number of basis functions
  #define NB  3
  /*------------   END: Auto Generate ------------*/
  
  /* C++ (Specific) FE Function class definition */
  class SpecificFUNC: public ABSTRACT_FEM_Function_Class // derive from base class
  {
  public:
      int*     Elem_DoF[NB];    // element DoF list
  
      // data structure containing information on the function evaluations.
      // Note: this data is evaluated at several quadrature points!
      // actually, the "quadrature" point is an interpolation point in the reference element
      SCALAR  Func_f_Value[NB][NQ];
  
      // constructor
      SpecificFUNC ();
      ~SpecificFUNC (); // destructor
      void Setup_Function_Space(const mxArray*);
      void Get_Local_to_Global_DoFmap(const int&, int*) const;
                     // need the "const" to ENSURE that nothing in this object will change!
      void Transform_Basis_Functions();
      const CLASS_geom_Sigma_embedded_in_Gamma_restricted_to_Sigma*  Mesh;
  
  private:
      void Map_Basis_p1();
  };
  
  /*------------ BEGIN: Auto Generate ------------*/
  /***************************************************************************************/
  /* constructor */
  SpecificFUNC::SpecificFUNC () :
  ABSTRACT_FEM_Function_Class () // call the base class constructor
  {
      Name       = (char*) SpecificFUNC_str;
      Type       = (char*) SPACE_type;
      Space_Name = (char*) SPACE_name;
      Sub_TopDim = SUB_TD;
      DoI_TopDim = DOI_TD;
      GeoDim     = GD;
      Num_Basis  = NB;
      Num_Comp   = NC;
      Num_QP     = NQ;
      Mesh       = NULL;
  
      // init DoF information to NULL
      for (int basis_i = 0; (basis_i < Num_Basis); basis_i++)
          Elem_DoF[basis_i] = NULL;
  
      // init everything to zero
      for (int qp_i = 0; (qp_i < Num_QP); qp_i++)
      for (int basis_i = 0; (basis_i < Num_Basis); basis_i++)
          Func_f_Value[basis_i][qp_i].Set_To_Zero();
  }
  /***************************************************************************************/
  /*------------   END: Auto Generate ------------*/
  
  
  /***************************************************************************************/
  /* DE-structor */
  SpecificFUNC::~SpecificFUNC ()
  {
  }
  /***************************************************************************************/
  
  
  /***************************************************************************************/
  /* put incoming function data from MATLAB into a nice struct  */
  void SpecificFUNC::Setup_Function_Space(const mxArray* Elem)          // inputs
  {
      Init_Function_Space(Elem);
  
      // split up the columns of the element data
      Elem_DoF[0] = (int *) mxGetPr(Elem);
      for (int basis_i = 1; (basis_i < Num_Basis); basis_i++)
          Elem_DoF[basis_i] = Elem_DoF[basis_i-1] + Num_Elem;
  }
  /***************************************************************************************/
  
  
  /***************************************************************************************/
  /* get the local DoFs on the given element.
     Note: elem_index is in the   C-style (i.e. 0 <= elem_index <= Num_Elem - 1),
           Indices is in the MATLAB-style (i.e. 1 <= Indices[:] <= max(Elem_DoF)). */
  void SpecificFUNC::Get_Local_to_Global_DoFmap(const int& elem_index, int* Indices) const  // inputs
  {
      /* error check: */
      if (elem_index < 0)
          {
          mexPrintf("ERROR: Given element index #%d is not positive. It must be > 0!\n",elem_index+1);
          mexPrintf("ERROR: There is an issue with the Finite Element Space = %s!\n",Space_Name);
          mexErrMsgTxt("ERROR: Make sure your inputs are valid!");
          }
      else if (elem_index >= Num_Elem)
          {
          mexPrintf("ERROR: Given element index #%d exceeds the number of elements in the finite element (FE) space.\n",elem_index+1);
  		mexPrintf("It must be <= %d!  OR  Your FE space DoFmap is not defined correctly!\n",Num_Elem);
  		mexPrintf("   For example, the number of rows in DoFmap should *equal*\n");
  		mexPrintf("       the number of mesh elements in the (sub)-domain.\n");
          mexPrintf("ERROR: There is an issue with the Finite Element Space = %s!\n",Space_Name);
          mexErrMsgTxt("ERROR: Make sure your inputs are valid!");
          }
  
      // get local to global index map for the current element
      for (int basis_i = 0; (basis_i < Num_Basis); basis_i++)
          {
          int DoF_index = Elem_DoF[basis_i][elem_index] - 1; // shifted for C - style indexing
          Indices[basis_i] = DoF_index;
          }
  }
  /***************************************************************************************/
  
  /*------------ BEGIN: Auto Generate ------------*/
  /***************************************************************************************/
  /* compute the correct local transformation */
  void SpecificFUNC::Transform_Basis_Functions()
  {
      Map_Basis_p1();
  }
  /***************************************************************************************/
  /*------------   END: Auto Generate ------------*/
  
  
  /*------------ BEGIN: Auto Generate ------------*/
  /***************************************************************************************/
  /* map basis functions from the standard reference element
         to an actual element in the Domain.     */
  void SpecificFUNC::Map_Basis_p1()
  {
  
  /*------------ BEGIN: Auto Generate ------------*/
  // Local Element defined on Subdomain: CG, lagrange_deg2_dim1
  // the Subdomain             has topological dimension = 1
  // the Domain of Integration has topological dimension = 1
  // geometric dimension = 3
  
      // get "Val" of basis functions
      SCALAR phi_Val[NB];
  
      // convenience variables
      const double& x_hat = local_coord[0];
      const double& y_hat = local_coord[1];
      const double& z_hat = local_coord[2];
  
      phi_Val[0].Set_Equal_To(x_hat*-3.0+(x_hat*x_hat)*2.0+1.0);
      phi_Val[1].Set_Equal_To(x_hat*(x_hat*2.0-1.0));
      phi_Val[2].Set_Equal_To(x_hat*(x_hat-1.0)*-4.0);
  
  /*------------   END: Auto Generate ------------*/
  
  /*------------ BEGIN: Auto Generate ------------*/
      /*** compute basis function quantities ***/
      // copy function evaluations over (indexing is in the C style)
      // evaluate for each basis function
      for (int basis_i = 0; (basis_i < Num_Basis); basis_i++)
          {
          Func_f_Value[basis_i][0].a = phi_Val[basis_i].a;
          }
  /*------------   END: Auto Generate ------------*/
  }
  /***************************************************************************************/
  /*------------   END: Auto Generate ------------*/
  
  // remove those macros!
  #undef SpecificFUNC
  #undef SpecificFUNC_str
  
  #undef SPACE_type
  #undef SPACE_name
  #undef SUB_TD
  #undef DOI_TD
  #undef GD
  #undef NC
  #undef NB
  #undef NQ
  
  /***/
  