class_docstr: Implementation of reduced HCT triangular element with explicit shape
  functions.
  
  Computes z, dz, d2z and the element stiffness matrix for bending energy:
  E(f) = integral( (d2z/dx2 + d2z/dy2)**2 dA)
  
  *** Reference for the shape functions: ***
  [1] Basis functions for general Hsieh-Clough-Tocher _triangles, complete or
      reduced.
      Michel Bernadou, Kamal Hassan
      International Journal for Numerical Methods in Engineering.
      17(5):784 - 789.  2.01
  
  *** Element description: ***
  9 dofs: z and dz given at 3 apex
  C1 (conform)
class_docstr_tok: ["Implementation","of","reduced","HCT","triangular","element","with","explicit","shape","functions",".","Computes","z",",","dz",",","d2z","and","the","element","stiffness","matrix","for","bending","energy",":","E","(","f",")","=","integral","(","(","d2z\/dx2","+","d2z\/dy2",")","*","*","2","dA",")","*","*","*","Reference","for","the","shape","functions",":","*","*","*","[","1","]","Basis","functions","for","general","Hsieh-Clough-Tocher","_triangles",",","complete","or","reduced",".","Michel","Bernadou",",","Kamal","Hassan","International","Journal","for","Numerical","Methods","in","Engineering",".","17","(","5",")",":784","-","789",".","2.01","*","*","*","Element","description",":","*","*","*","9","dofs",":","z","and","dz","given","at","3","apex","C1","(","conform",")"]
docstr: Build K and F for the following elliptic formulation:
  minimization of curvature energy with value of function at node
  imposed and derivatives 'free'.
  
  Build the global Kff matrix in cco format.
  Build the full Ff vec Ff = - Kfc x Uc.
  
  Parameters
  ----------
  *J* is a (N x 2 x 2) array of jacobian matrices (jacobian matrix at
  triangle first apex)
  *ecc* is a (N x 3 x 1) array (array of column-matrices) of triangle
  eccentricities
  *triangles* is a (N x 3) array of nodes indexes.
  *Uc* is (N x 3) array of imposed displacements at nodes
  
  Returns
  -------
  (Kff_rows, Kff_cols, Kff_vals) Kff matrix in coo format - Duplicate
  (row, col) entries must be summed.
  Ff: force vector - dim npts * 3
docstr_tok: ["Build","K","and","F","for","the","following","elliptic","formulation",":","minimization","of","curvature","energy","with","value","of","function","at","node","imposed","and","derivatives","'free","'",".","Build","the","global","Kff","matrix","in","cco","format",".","Build","the","full","Ff","vec","Ff","=","-","Kfc","x","Uc",".","Parameters","--","--","--","--","--","*","J","*","is","a","(","N","x","2","x","2",")","array","of","jacobian","matrices","(","jacobian","matrix","at","triangle","first","apex",")","*","ecc","*","is","a","(","N","x","3","x","1",")","array","(","array","of","column-matrices",")","of","triangle","eccentricities","*","triangles","*","is","a","(","N","x","3",")","array","of","nodes","indexes",".","*","Uc","*","is","(","N","x","3",")","array","of","imposed","displacements","at","nodes","Returns","--","--","--","-","(","Kff_rows",",","Kff_cols",",","Kff_vals",")","Kff","matrix","in","coo","format","-","Duplicate","(","row",",","col",")","entries","must","be","summed",".","Ff",":","force","vector","-","dim","npts","*","3"]
code: def get_Kff_and_Ff(self, J, ecc, triangles, Uc):
      """
      Build K and F for the following elliptic formulation:
      minimization of curvature energy with value of function at node
      imposed and derivatives 'free'.
  
      Build the global Kff matrix in cco format.
      Build the full Ff vec Ff = - Kfc x Uc.
  
      Parameters
      ----------
      *J* is a (N x 2 x 2) array of jacobian matrices (jacobian matrix at
      triangle first apex)
      *ecc* is a (N x 3 x 1) array (array of column-matrices) of triangle
      eccentricities
      *triangles* is a (N x 3) array of nodes indexes.
      *Uc* is (N x 3) array of imposed displacements at nodes
  
      Returns
      -------
      (Kff_rows, Kff_cols, Kff_vals) Kff matrix in coo format - Duplicate
      (row, col) entries must be summed.
      Ff: force vector - dim npts * 3
      """
      ntri = np.size(ecc, 0)
      vec_range = np.arange(ntri, dtype=np.int32)
      c_indices = np.full(
          ntri, -1, dtype=np.int32
      )  # for unused dofs, -1
      f_dof = [1, 2, 4, 5, 7, 8]
      c_dof = [0, 3, 6]
  
      # vals, rows and cols indices in global dof numbering
      f_dof_indices = _to_matrix_vectorized(
          [
              [
                  c_indices,
                  triangles[:, 0] * 2,
                  triangles[:, 0] * 2 + 1,
                  c_indices,
                  triangles[:, 1] * 2,
                  triangles[:, 1] * 2 + 1,
                  c_indices,
                  triangles[:, 2] * 2,
                  triangles[:, 2] * 2 + 1,
              ]
          ]
      )
  
      expand_indices = np.ones([ntri, 9, 1], dtype=np.int32)
      f_row_indices = _transpose_vectorized(
          expand_indices @ f_dof_indices
      )
      f_col_indices = expand_indices @ f_dof_indices
      K_elem = self.get_bending_matrices(J, ecc)
  
      # Extracting sub-matrices
      # Explanation & notations:
      # * Subscript f denotes 'free' degrees of freedom (i.e. dz/dx, dz/dx)
      # * Subscript c denotes 'condensated' (imposed) degrees of freedom
      #    (i.e. z at all nodes)
      # * F = [Ff, Fc] is the force vector
      # * U = [Uf, Uc] is the imposed dof vector
      #        [ Kff Kfc ]
      # * K =  [         ]  is the laplacian stiffness matrix
      #        [ Kcf Kff ]
      # * As F = K x U one gets straightforwardly: Ff = - Kfc x Uc
  
      # Computing Kff stiffness matrix in sparse coo format
      Kff_vals = np.ravel(K_elem[np.ix_(vec_range, f_dof, f_dof)])
      Kff_rows = np.ravel(
          f_row_indices[np.ix_(vec_range, f_dof, f_dof)]
      )
      Kff_cols = np.ravel(
          f_col_indices[np.ix_(vec_range, f_dof, f_dof)]
      )
  
      # Computing Ff force vector in sparse coo format
      Kfc_elem = K_elem[np.ix_(vec_range, f_dof, c_dof)]
      Uc_elem = np.expand_dims(Uc, axis=2)
      Ff_elem = -(Kfc_elem @ Uc_elem)[:, :, 0]
      Ff_indices = f_dof_indices[np.ix_(vec_range, [0], f_dof)][:, 0, :]
  
      # Extracting Ff force vector in dense format
      # We have to sum duplicate indices -  using bincount
      Ff = np.bincount(np.ravel(Ff_indices), weights=np.ravel(Ff_elem))
      return Kff_rows, Kff_cols, Kff_vals, Ff
  
imports: import numpy
  from matplotlib import _api
  from matplotlib.tri import Triangulation
  from matplotlib.tri._trifinder import TriFinder
  from matplotlib.tri._tritools import TriAnalyzer
label_desc: Use image node_id 7 for calling the _ReducedHCT_Element obj's underlying member method code with example usage: obj.get_Kff_and_Ff(J, ecc, triangles, Uc) and returns: Kff_rows,  Kff_cols,  Kff_vals,  Ff