#=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~=~
#                                      numgeo - GiD interface
#                       Copyright (C) 2023-today Jan Machacek, Rahul Dogra
#=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~=~
#
# History
# - 26.11.2023, J. Machacek - Initial version
# - 03.03.2025, R. Dogra - Added truss elements
# - 07.03.2025, R. Dogra - Added beam elements
# - 12.08.2025, R. Dogra - Added u8p8-stab-ax elements
# - 29.09.2025, R. Dogra - Added Three-phase u-p stab elements
# - 01.01.2026, R. Dogra - Added errors for the element types
# - 04.01.2026, R. Dogra - Added Flow-only (p) elements 
#
#=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~=~

proc numgeo::return_eltype {dim formulation integration shape numnodes} {

#
# 2D (plane-strain)
#

  if {$dim == "2D (plane-strain)"} {

  #
  # Triangular elements
  #
    if {$shape == "Triangular"} {
  
    #
    # 3-node triangular elements
    #
      if {$numnodes == "3"} {
        if {$formulation == "Single-phase solid"} {
          return "u3-solid"
        } elseif {$formulation == "Single-phase porous"} {
          return "u3"
        } elseif {$formulation == "Two-phase u-p - stabilised"} {
          return "u3p3-sat-stab"
        } elseif {$formulation == "Two-phase u-p"} {
          error [= "Two-phase linear triangular u-p elements (3 nodes) were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
        } elseif {$formulation == "Three-phase u-p - stabilised"} {
          return "u3p3-stab"
        } elseif {$formulation == "Three-phase u-p"} {
          error [= "Three-phase linear triangular u-p elements (3 nodes) were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
        } elseif {$formulation == "Three-phase u-p-p"} {
          error [= "Three-phase linear triangular u-p-p elements (3 nodes) were selected. However, this element type is not implemented in numgeo. You may either chose a simplified formulation or switch to higher-order elements."]
        } elseif {$formulation == "Flow-only"} {
          return [= "p3"]
        } elseif {$formulation == "...select..."} {
          error [= "Element type is not correctly selected"]
        }
              
        #
        # 6-node triangular elements
        #
      } elseif {$numnodes == "6"} {
        if {$formulation == "Single-phase solid"} {
          return "u6-solid"
        } elseif {$formulation == "Single-phase porous"} {
          return "u6"
        } elseif {$formulation == "Two-phase u-p"} {
          return "u6p3-sat"
        } elseif {$formulation == "Two-phase u-p - stabilised"} {
          error [= "Two-phase quadratic triangular u-p elements (6 nodes) with Fluid Pressure Laplacian (FPL) were selected. However, this element type is not implemented in numgeo."]
        } elseif {$formulation == "Two-phase u-p-U"} {
          return "u6p3u6-sat"
        } elseif {$formulation == "Three-phase u-p"} {
          return "u6p3"
        } elseif {$formulation == "Three-phase u-p - stabilised"} {
          return "u6p6-stab"
        } elseif {$formulation == "Three-phase u-p-p"} {
          return "u6pp3"
        } elseif {$formulation == "...select..."} {
          error [= "Element type is not correctly selected"]
        } elseif {$formulation == "Flow-only"} {
          return [= "p6"]
        } else {
          error [= "Unknown element formulation: $formulation"] 
        }
      }
    }
	
    #
    # Quadrilateral elements
    #
    if {$shape == "Quadrilateral"} {
    # Reduced integration with hourglass control
      if {$integration == "full"} {
        set red ""
      } else {
        set red "-red"
      }
      #
      # 4-node quadrilateral elements
      #
      if {$numnodes == "4"} {
        if {$formulation == "Single-phase solid"} {
          return "u4-solid$red"
        } elseif {$formulation == "Single-phase porous"} {
          return "u4$red"
        } elseif {$formulation == "Two-phase u-U"} {
          return "u4u4$red"
        } elseif {$formulation == "Two-phase u-p - stabilised"} {
          return "u4p4-sat-stab-red"
        } elseif {$formulation == "Two-phase u-p"} {
          error [= "Two-phase linear quadrilateral elements (4 nodes) without Fluid Pressure Laplacian (FPL) stabilisation were selected. However, this element type is not implemented in numgeo."]
        } elseif {$formulation == "Three-phase u-p - stabilised"} {
          return "u4p4-stab-red"
        } elseif {$formulation == "Three-phase u-p"} {
          error [= "Three-phase linear quadrilateral elements (4 nodes) without Fluid Pressure Laplacian (FPL) stabilisation were selected. However, this element type is not implemented in numgeo."]
        } elseif {$formulation == "Three-phase u-p-p"} {
          return "u4p4-stab-red"
        } elseif {$formulation == "Flow-only"} {
          return [= "p4"]
        } elseif {$formulation == "...select..."} {
          error [= "Element type is not correctly selected"]
        } 
        #
        # 8-node quadrilateral elements
        #
      } elseif {$numnodes == "8"} {
        if {$formulation == "Single-phase solid"} {
          return "u8-solid$red"
        } elseif {$formulation == "Single-phase porous"} {
          return "u8$red"
        } elseif {$formulation == "Two-phase u-p element - stabilised"} {
          error [= "Two-phase quadratic quadrilateral elements (8 nodes) with Fluid Pressure Laplacian (FPL) stabilisation were selected. However, this element type is not implemented in numgeo."]
        } elseif {$formulation == "Two-phase u-p"} {
          return "u8p4-sat$red"
        } elseif {$formulation == "Two-phase u-p-U"} {
          return "u8p4u8-sat$red"
        } elseif {$formulation == "Two-phase u-U"} {
          return "u8u8$red"
        } elseif {$formulation == "Three-phase u-p - stabilised"} {
          return "u8p8-stab"
        } elseif {$formulation == "Three-phase u-p"} {
          return "u8p4$red"
        } elseif {$formulation == "Three-phase u-p-p"} {
          return "u8pp4$red"
        } elseif {$formulation == "Flow-only"} {
          return [= "p8"]
        } elseif {$formulation == "...select..."} {
          error [= "Element type is not correctly selected"]
        } 
      }
    }
    
    #
    # 2D axissymmetric elements
    #
  } elseif {$dim == "2D: Axissymmetric"} {
    # Additional case for 2D axissymmetric
    if {$shape == "Triangular"} {
      if {$numnodes == "6"} {
        if {$formulation == "Single-phase solid"} {
          if {$integration == "full"} {
            return "u6-solid-ax"
          } elseif {$integration == "reduced"} {
            return "u6-solid-ax"
          }
        } elseif {$formulation == "Single-phase porous"} {
          if {$integration == "full"} {
            return "u6-ax"
          } elseif {$integration == "reduced"} {
            return "u6-ax"
          }
        } elseif {$formulation == "Two-phase u-p"} {
          if {$integration == "full"} {
            return "u6p3-sat-ax"
          } elseif {$integration == "reduced"} {
            return "u6p3-sat-ax"
          }
        } elseif {$formulation == "Two-phase u-U"} {
          if {$integration == "full"} {
            error [= "Two-phase u-U quadratic triangular elements ('6 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          } elseif {$integration == "reduced"} {
            error [= "Two-phase u-U quadratic triangular elements ('6 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          }
        } elseif {$formulation == "Two-phase u-p-U"} {
          if {$integration == "full"} {
            return "u6p3u6-sat-ax"
          } elseif {$integration == "reduced"} {
            return "u6p3u6-sat-ax"
          }
        } elseif {$formulation == "Three-phase u-p"} {
          if {$integration == "full"} {
            return "u6p3-ax"
          } elseif {$integration == "reduced"} {
            return "u6p3-ax"
          }
        } elseif {$formulation == "...select..."} {
          error [= "Element type is not correctly selected"]
        } 
      } elseif {$numnodes == "3"} {
        if {$formulation == "Single-phase solid"} {
          if {$integration == "full"} {
            return "u3-solid-ax"
          } elseif {$integration == "reduced"} {
            return "u3-solid-ax"
          }
        } elseif {$formulation == "Single-phase porous"} {
          if {$integration == "full"} {
            error [= "Single-phase porous linear triangular elements ('3 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          } elseif {$integration == "reduced"} {
            error [= "Single-phase porous linear triangular elements ('3 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          }
        } elseif {$formulation == "Two-phase u-p"} {
          if {$integration == "full"} {
            return "u3p3-sat-mini-ax"
          } elseif {$integration == "reduced"} {
            return "u3p3-sat-mini-ax"
          }
        } elseif {$formulation == "Two-phase u-p - stabilised"} {
          if {$integration == "full"} {
            return "u3p3-sat-stab-ax"
          } elseif {$integration == "reduced"} {
            return "u3p3-sat-stab-ax"
          }
        } elseif {$formulation == "Two-phase u-U"} {
          if {$integration == "full"} {
            error [= "Two-phase u-U linear triangular elements ('3 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          } elseif {$integration == "reduced"} {
            error [= "Two-phase u-U linear triangular elements ('3 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          }
        } elseif {$formulation == "Two-phase u-p-U"} {
          if {$integration == "full"} {
            error [= "Two-phase u-p-U linear triangular elements ('3 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          } elseif {$integration == "reduced"} {
            error [= "Two-phase u-p-U linear triangular elements ('3 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          }
        } elseif {$formulation == "Three-phase u-p - stabilised"} {
          if {$integration == "full"} {
            return "u3p3-stab-ax"
          } elseif {$integration == "reduced"} {
            return "u3p3-stab-ax"
          }
        } elseif {$formulation == "Three-phase u-p"} {
          if {$integration == "full"} {
            error [= "Three phase u-p linear triangular elements ('3 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          } elseif {$integration == "reduced"} {
            error [= "Three phase u-p linear triangular elements ('3 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          }
        } elseif {$formulation == "Three-phase u-p-p"} {
          if {$integration == "full"} {
            error [= "Three phase u-p-p linear triangular elements ('3 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          } elseif {$integration == "reduced"} {
            error [= "Three phase u-p-p linear triangular elements ('3 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          }
        } elseif {$formulation == "Flow-only"} {
          error [= "Element type is not correctly selected"]
        } elseif {$formulation == "...select..."} {
          error [= "Element type is not correctly selected"]
        } 
      }
    } elseif {$shape == "Quadrilateral"} {
      if {$numnodes == "4"} {
        if {$formulation == "Single-phase solid"} {
          if {$integration == "full"} {
            return "u4-solid-ax"
          } elseif {$integration == "reduced"} {
            return "u4-solid-ax-red"
          }
        } elseif {$formulation == "Single-phase porous"} {
          if {$integration == "full"} {
            return "u4-ax"
          } elseif {$integration == "reduced"} {
            return "u4-ax-red"
          }
        } elseif {$formulation == "Two-phase u-U"} {
          if {$integration == "full"} {
            return "u4u4-ax"
          } elseif {$integration == "reduced"} {
              return "u4u4-ax-red"
          }
        } elseif {$formulation == "Two-phase u-p"} {
          if {$integration == "full"} {
            return "u4p4-sat-ax"
          } elseif {$integration == "reduced"} {
            return "u4p4-sat-ax"
          }
        } elseif {$formulation == "Two-phase u-p - stabilised"} {
          if {$integration == "full"} {
            return "u4p4-sat-mini-ax"
          } elseif {$integration == "reduced"} {
            return "u4p4-sat-stab-ax-red"
          }
        } elseif {$formulation == "Two-phase u-p-U"} {
          if {$integration == "full"} {
            error [= "Two-phase u-p-U linear quadrilateral elements ('4 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          } elseif {$integration == "reduced"} {
            error [= "Two-phase u-p-U linear quadrilateral elements ('4 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          }
        } elseif {$formulation == "Three-phase u-p"} {
          if {$integration == "full"} {
            error [= "Three phase u-p linear quadrilateral elements ('4 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          } elseif {$integration == "reduced"} {
            error [= "Three phase u-p linear quadrilateral elements ('4 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          }
        } elseif {$formulation == "Three-phase u-p - stabilised"} {
          if {$integration == "full"} {
            return "u4p4-stab-ax-red"
          } elseif {$integration == "reduced"} {
            return "u4p4-stab-ax-red"
          }
        } elseif {$formulation == "Three-phase u-p-p"} {
          if {$integration == "full"} {
            error [= "Three phase u-p-p linear quadrilateral elements ('4 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          } elseif {$integration == "reduced"} {
            error [= "Three phase u-p-p linear quadrilateral elements ('4 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          }
        } elseif {$formulation == "Flow-only"} {
          error [= "Element type is not correctly selected"]
        } elseif {$formulation == "...select..."} {
          error [= "Element type is not correctly selected"]
        } 
      } elseif {$numnodes == "8"} {
        if {$formulation == "Single-phase solid"} {
          if {$integration == "full"} {
            return "u8-solid-ax"
          } elseif {$integration == "reduced"} {
            return "u8-solid-ax-red"
          }
        } elseif {$formulation == "Single-phase porous"} {
          if {$integration == "full"} {
            return "u8-ax"
          } elseif {$integration == "reduced"} {
            return "u8-ax-red"
          }
        } elseif {$formulation == "Two-phase u-p"} {
          if {$integration == "full"} {
            return "u8p4-sat-ax"
          } elseif {$integration == "reduced"} {
            return "u8p4-sat-ax-red"
          }
        } elseif {$formulation == "Two-phase u-p-U"} {
          if {$integration == "full"} {
            return "u8p4u8-sat-ax"
          } elseif {$integration == "reduced"} {
            return "u8p4u8-sat-ax-red"
          }
        } elseif {$formulation == "Two-phase u-U"} {
          if {$integration == "full"} {
            return "u8u8-ax"
          } elseif {$integration == "reduced"} {
            return "u8u8-ax-red"
          }
        } elseif {$formulation == "Two-phase u-p - stabilised"} {
            error [= "Two-phase u-p - stabilised quadratic quadrilateral elements ('8 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
        } elseif {$formulation == "Three-phase u-p"} {
          if {$integration == "full"} {
            return "u8p8-ax"
          } elseif {$integration == "reduced"} {
            return "u8p8-ax"
          }
        } elseif {$formulation == "Three-phase u-p - stabilised"} {
          if {$integration == "full"} {
            return "u8p8-stab-ax"
          } elseif {$integration == "reduced"} {
            return "u8p8-stab-ax-red"
          }
        } elseif {$formulation == "Three-phase u-p-p"} {
          if {$integration == "full"} {
            return "u8p8-ax"
          } elseif {$integration == "reduced"} {
            return "u8p8-ax"
          }
        } elseif {$formulation == "Flow-only"} {
          error [= "Element type is not correctly selected"]
        } elseif {$formulation == "...select..."} {
          error [= "Element type is not correctly selected"]
        } 
      }
    }
    #
    # 3D elements
    #
  } elseif {$dim == "3D"} {
    #
    # Hexahedra elements
    #
    if {$shape == "Hexahedra"} {
      #
      # linear hexahedra
      #
      if {$numnodes == "8"} {
        if {$formulation == "Single-phase solid"} {
          if {$integration == "full"} {
            return "u8-solid-3D"
          } elseif {$integration == "reduced"} {
            return "u8-solid-3D-red"
          }
        } elseif {$formulation == "Single-phase porous"} {
          if {$integration == "full"} {
            return "u8-3D"
          } elseif {$integration == "reduced"} {
            return "u8-3D"
          }
        } elseif {$formulation == "Two-phase u-p"} {
          if {$integration == "full"} {
            error [= "Two-phase u-p linear hexaheadral elements ('8 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          } elseif {$integration == "reduced"} {
            error [= "Two-phase u-p linear hexaheadral elements ('8 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          }
        } elseif {$formulation == "Two-phase u-U"} {
          if {$integration == "full"} {
            return "u8u8-3D"
          } elseif {$integration == "reduced"} {
            return "u8u8-3D-red"
          }
        } elseif {$formulation == "Two-phase u-p - stabilised"} {
          if {$integration == "full"} {
            return "u8p8-sat-3D-stab-red"
          } elseif {$integration == "reduced"} {
            return "u8p8-sat-3D-stab-red"
          }
        } elseif {$formulation == "Two-phase u-p-U"} {
          if {$integration == "full"} {
            error [= "Two-phase u-p linear hexaheadral elements ('8 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          } elseif {$integration == "reduced"} {
            error [= "Two-phase u-p linear hexaheadral elements ('8 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          }
        } elseif {$formulation == "Three-phase u-p"} {
          if {$integration == "full"} {
            error [= "Three-phase element type is not implemented yet! Will be fixed in upcoming updates"]
          } elseif {$integration == "reduced"} {
            error [= "Three-phase element type is not implemented yet! Will be fixed in upcoming updates"]
          }
        } elseif {$formulation == "Three-phase u-p - stabilised"} {
          if {$integration == "full"} {
            return "u8p8-3D-stab"
          } elseif {$integration == "reduced"} {
            return "u8p8-3D-stab-red"
          }
        } elseif {$formulation == "Three-phase u-p-p"} {
          if {$integration == "full"} {
            error [= "Three-phase element type is not implemented yet! Will be fixed in upcoming updates"]
          } elseif {$integration == "reduced"} {
            error [= "Three-phase element type is not implemented yet! Will be fixed in upcoming updates"]
          }
        } elseif {$formulation == "Flow-only"} {
          error [= "Element type is not correctly selected"]
        } elseif {$formulation == "...select..."} {
          error [= "Element type is not correctly selected"]
        } 
      #
      # quadratic hexahedra
      #
      } elseif {$numnodes == "20"} {
        if {$formulation == "Single-phase solid"} {
          if {$integration == "full"} {
            return "u20-solid"
          } elseif {$integration == "reduced"} {
            return "u20-solid-red"
          }
        } elseif {$formulation == "Single-phase porous"} {
          if {$integration == "full"} {
            return "u20"
          } elseif {$integration == "reduced"} {
            return "u20-red"
          }
        } elseif {$formulation == "Two-phase u-U"} {
          if {$integration == "full"} {
            return "u20u20"
          } elseif {$integration == "reduced"} {
            return "u20u20"
          }
        } elseif {$formulation == "Two-phase u-p"} {
          if {$integration == "full"} {
            return "u20p8-sat"
          } elseif {$integration == "reduced"} {
            return "u20p8-sat-red"
          }
        } elseif {$formulation == "Two-phase u-p - stabilised"} {
          if {$integration == "full"} {
            error [= "Two-phase u-p - stabilised quadratic hexaheadral elements ('20 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          } elseif {$integration == "reduced"} {
            error [= "Two-phase u-p - stabilised quadratic hexaheadral elements ('20 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          }
        } elseif {$formulation == "Two-phase u-p-U"} {
          if {$integration == "full"} {
            return "u20p8u20-sat"
          } elseif {$integration == "reduced"} {
            return "u20p8u20-sat-red"
          }
        } elseif {$formulation == "Three-phase u-p"} {
          if {$integration == "full"} {
            error [= "Three-phase element type is not implemented yet! Will be fixed in upcoming updates"]
          } elseif {$integration == "reduced"} {
            error [= "Three-phase element type is not implemented yet! Will be fixed in upcoming updates"]
          }
        } elseif {$formulation == "Three-phase u-p - stabilised"} {
          if {$integration == "full"} {
            return "u20p20-stab"
          } elseif {$integration == "reduced"} {
            return "u20p20-stab-red"
          }
        } elseif {$formulation == "Three-phase u-p-p"} {
          if {$integration == "full"} {
            error [= "Three-phase element type is not implemented yet! Will be fixed in upcoming updates"]
          } elseif {$integration == "reduced"} {
            error [= "Three-phase element type is not implemented yet! Will be fixed in upcoming updates"]
          }
        } elseif {$formulation == "Flow-only"} {
          error [= "Element type is not correctly selected"]
        } elseif {$formulation == "...select..."} {
          error [= "Element type is not correctly selected"]
        } 
        #
        # bi-quadratic Hexahedra
        #
      } elseif {$numnodes == "27"} {
        if {$formulation == "Single-phase solid"} {
          if {$integration == "full"} {
            return "u27-solid"
          } elseif {$integration == "reduced"} {
            return "u27-solid-red"
          }
        } elseif {$formulation == "Single-phase porous"} {
          if {$integration == "full"} {
            return "u27"
          } elseif {$integration == "reduced"} {
            return "u27"
          }
        } elseif {$formulation == "Two-phase u-U"} {
          if {$integration == "full"} {
            error [= "Two-phase u-U biquadratic hexaheadral elements ('27 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          } elseif {$integration == "reduced"} {
            error [= "Two-phase u-U biquadratic hexaheadral elements ('27 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          }
        } elseif {$formulation == "Two-phase u-p"} {
          if {$integration == "full"} {
            return "u27p8-sat"
          } elseif {$integration == "reduced"} {
            return "u27p8-sat"
          }
        } elseif {$formulation == "Two-phase u-p - stabilised"} {
          if {$integration == "full"} {
            error [= "Two-phase u-p - stabilised biquadratic hexaheadral elements ('27 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          } elseif {$integration == "reduced"} {
            error [= "Two-phase u-p - stabilised biquadratic hexaheadral elements ('27 NODES') were selected. However, this element type is not implemented in numgeo. You may either chose a different formulation or switch to higher-order elements."]
          }
        } elseif {$formulation == "Two-phase u-p-U"} {
          if {$integration == "full"} {
            return "u27p8u27-sat"
          } elseif {$integration == "reduced"} {
            return "u27p8u27-sat"
          }
        } elseif {$formulation == "Three-phase u-p"} {
          if {$integration == "full"} {
            error [= "Three-phase element type is not implemented yet! Will be fixed in upcoming updates"]
          } elseif {$integration == "reduced"} {
            error [= "Three-phase element type is not implemented yet! Will be fixed in upcoming updates"]
          }
        } elseif {$formulation == "Three-phase u-p - stabilised"} {
          if {$integration == "full"} {
            error [= "Three-phase element type is not implemented yet! Will be fixed in upcoming updates"]
          } elseif {$integration == "reduced"} {
            error [= "Three-phase element type is not implemented yet! Will be fixed in upcoming updates"]
          }
        } elseif {$formulation == "Three-phase u-p-p"} {
          if {$integration == "full"} {
            error [= "Three-phase element type is not implemented yet! Will be fixed in upcoming updates"]
          } elseif {$integration == "reduced"} {
            error [= "Three-phase element type is not implemented yet! Will be fixed in upcoming updates"]
          }
        } elseif {$formulation == "Flow-only"} {
          error [= "Element type is not correctly selected"]
        } elseif {$formulation == "...select..."} {
          error [= "Element type is not correctly selected"]
        } 
      } 
      #
      # Tetrahedra elements
      #
    } elseif {$shape == "Tetrahedra"} {
      #
      # linear tetrahedra
      #
      if {$numnodes == "4"} {
        if {$formulation == "Single-phase solid"} {
          return "u4-solid-3D"
        }  elseif {$formulation == "Single-phase porous"} {
          error [= "Single-phase porous linear tetrahedra elements ('4 NODES') were selected. However, this element type is not implemented in numgeo."]
        }  elseif {$formulation == "Two-phase u-p"} {
          return "u4p4-sat-3D-mini"
        }  elseif {$formulation == "Two-phase u-U"} {
          error [= "Two-phase u-U linear tetrahedra elements ('4 NODES') were selected. However, this element type is not implemented in numgeo."]
        }  elseif {$formulation == "Two-phase u-p - stabilised"} {
          error [= "Two-phase u-p stabilised linear tetrahedra elements ('4 NODES') were selected. However, this element type is not implemented in numgeo."]
        }  elseif {$formulation == "Two-phase u-p-U"} {
          error [= "Two-phase u-p-U linear tetrahedra elements ('4 NODES') were selected. However, this element type is not implemented in numgeo."]
        }  elseif {$formulation == "Three-phase u-p"} {
          error [= "Three-phase u-p linear tetrahedra elements ('4 NODES') were selected. However, this element type is not implemented in numgeo."]
        } elseif {$formulation == "Three-phase u-p - stabilised"} {
          error [= "Three-phase u-p stabilised linear tetrahedra elements ('4 NODES') were selected. However, this element type is not implemented in numgeo."]
        } elseif {$formulation == "Three-phase u-p-p"} {
          error [= "Three-phase u-p-p linear tetrahedra elements ('4 NODES') were selected. However, this element type is not implemented in numgeo."]
        } elseif {$formulation == "Flow-only"} {
          error [= "Element type is not correctly selected"]
        } elseif {$formulation == "...select..."} {
          error [= "Element type is not correctly selected"]
        } 
        #
        # quadratic tetrahedra
        #
      } elseif {$numnodes == "10"} {
        if {$formulation == "Single-phase solid"} {
          return "u10-solid-3d"
        } elseif {$formulation == "Single-phase porous"} {
          error [= "Single-phase porous quadratic tetrahedra elements ('4 NODES') were selected. However, this element type is not implemented in numgeo."]
        } elseif {$formulation == "Two-phase u-U"} {
          error [= "Two-phase u-U quadratic tetrahedra elements ('4 NODES') were selected. However, this element type is not implemented in numgeo."]
        } elseif {$formulation == "Two-phase u-p"} {
          return "u10p4-sat"
        } elseif {$formulation == "Two-phase u-p - stabilised"} {
          error [= "Two-phase u-p stabilised quadratic tetrahedra elements ('4 NODES') were selected. However, this element type is not implemented in numgeo."]
        } elseif {$formulation == "Two-phase u-p-U"} {
          error [= "Two-phase u-p-U quadratic tetrahedra elements ('4 NODES') were selected. However, this element type is not implemented in numgeo."]
        } elseif {$formulation == "Three-phase u-p"} {
          error [= "Three-phase u-p quadratic tetrahedra elements ('4 NODES') were selected. However, this element type is not implemented in numgeo."]
        } elseif {$formulation == "Three-phase u-p - stabilised"} {
          return "u10p10-stab"
        } elseif {$formulation == "Three-phase u-p-p"} {
          error [= "Three-phase u-p-p quadratic tetrahedra elements ('4 NODES') were selected. However, this element type is not implemented in numgeo."]
        } elseif {$formulation == "Flow-only"} {
          error [= "Element type is not correctly selected"]
        } elseif {$formulation == "...select..."} {
          error [= "Element type is not correctly selected"]
        } 
      }
    }
  }
}

proc numgeo::return_eltype2 {dim formulation shape numnodes} {
  #
  # 2D (plane-strain)
  #
  if {$dim == "2D (plane-strain)"} {
    # formulation
	if {$formulation == "Truss"} {
	  # Linear elements
      if {$shape == "Linear"} {
        # 2-node linear elements
        if {$numnodes == "2"} {
          return "u2-truss"
          # 3-noded linear elements
        } elseif {$numnodes == "3"} {
          return "u3-truss"
        } 
      }
    } elseif {$formulation == "Beam"} {
    # Linear elements
      if {$shape == "Linear"} {
        # 2-node linear elements
        if {$numnodes == "2"} {
          return "u2-beam"
          # 3-noded linear elements
        } elseif {$numnodes == "3"} {
          return "u3-beam"
        } 
      }
    } elseif {$formulation == "...select..."} {
      error [= "Element type is not correctly selected"]
    }    
  } elseif {$dim == "2D: Axissymmetric"} {
    # formulation
  if {$formulation == "Truss"} {
    # Linear elements
      if {$shape == "Linear"} {
        # 2-node linear elements
        if {$numnodes == "2"} {
          error [= "2D: Axissymmetric truss element type is selected (2 NODES). However, this element type is not implemented in numgeo."]
          # 3-noded linear elements
        } elseif {$numnodes == "3"} {
          error [= "2D: Axissymmetric truss element type is selected (3 NODES). However, this element type is not implemented in numgeo."]
        } 
      }
    } elseif {$formulation == "Beam"} {
	  # Linear elements
      if {$shape == "Linear"} {
        # 2-node linear elements
        if {$numnodes == "2"} {
          error [= "2D: Axissymmetric beam element type is selected (2 NODES). However, this element type is not implemented in numgeo."]
          # 3-noded linear elements
        } elseif {$numnodes == "3"} {
          error [= "2D: Axissymmetric beam element type is selected (3 NODES). However, this element type is not implemented in numgeo."]
        } 
      }
    } elseif {$formulation == "...select..."} {
      error [= "Element type is not correctly selected"]
    }    
  } elseif {$dim == "3D"} {
    # formulation
  if {$formulation == "Truss"} {
    # Linear elements
      if {$shape == "Linear"} {
        # 2-node linear elements
        if {$numnodes == "2"} {
          error [= "3D truss element type is selected (2 NODES). However, this element type is not implemented in numgeo."]
          # 3-noded linear elements
        } elseif {$numnodes == "3"} {
          error [= "3D truss element type is selected (3 NODES). However, this element type is not implemented in numgeo."]
        } 
      }
    } elseif {$formulation == "Beam"} {
    # Linear elements
      if {$shape == "Linear"} {
        # 2-node linear elements
        if {$numnodes == "2"} {
          return "u2-beam-3D"
          # 3-noded linear elements
        } elseif {$numnodes == "3"} {
          return "u3-beam-3D"
        } 
      }
    } elseif {$formulation == "...select..."} {
      error [= "Element type is not correctly selected"]
    }    
  }
    error [= "Please check: you did not select the element type correctly (no matching element found). Make sure Dimension / Shape / Nodes / Formulation / Integration are selected."]
}