(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



Clear[X1,X2,Basis]
Basis[{X1_,X2_}]= Flatten[
Table[
X1^i X2^j (1-X1-X2)^(5-i-j),
{i,0,5},
{j,0,5-i}]
]
DBasis[{X1_,X2_}]=D[Basis[{X1,X2}],{{X1,X2}}];
DDBasis[{X1_,X2_}]=D[DBasis[{X1,X2}],{{X1,X2}}];


Pts={{0,0},{0,1},{1,0}};
MidPts={{1/2,0},{1/2,1/2},{0,1/2}};
Ns =  {{0,-1},{1/Sqrt[2],1/Sqrt[2]},{-1,0}};
A=Join[
Map[ Basis, Pts],
Map[DBasis,Pts][[All,All,1]],
Map[DBasis,Pts][[All,All,2]],
Map[DDBasis,Pts][[All,All,1,1]],
Map[DDBasis,Pts][[All,All,2,2]],
Map[DDBasis,Pts][[All,All,1,2]],
MapThread[DBasis[#1].#2&,{MidPts, Ns}]
];
Det[A]


ShapeFunctions[{X1_,X2_}]=FullSimplify[Transpose[Inverse[A]].Basis[{X1,X2}]];
TableForm[ShapeFunctions[{X1,X2}],TableHeadings->{Automatic}]


ShapeFunction[{X1_,X2_},"V"]=ShapeFunctions[{X1,X2}][[1]];
ShapeFunction[{X1_,X2_},"G"]=ShapeFunctions[{X1,X2}][[{4,7}]];
ShapeFunction[{X1_,X2_},"H"]=ShapeFunctions[{X1,X2}][[{10,13,16}]];
ShapeFunction[{X1_,X2_},"M"]=ShapeFunctions[{X1,X2}][[19]];
Plot3D[
ShapeFunction[{X1,X2},"V"],
{X1,0,1},
{X2,0,1},
RegionFunction->Function[{X1,X2,Z}, X1+X2<1],
AxesLabel->{"X1","X2","Z"}
]
Plot3D[
ShapeFunction[{X1,X2},"G"],
{X1,0,1},
{X2,0,1},
RegionFunction->Function[{X1,X2,Z}, X1+X2<1],
AxesLabel->{"X1","X2","Z"}]
Plot3D[
ShapeFunction[{X1,X2},"H"],
{X1,0,1},
{X2,0,1},
RegionFunction->Function[{X1,X2,Z}, X1+X2<1],
AxesLabel->{"X1","X2","Z"}
]
Plot3D[
ShapeFunction[{X1,X2},"M"],
{X1,0,1},
{X2,0,1},
RegionFunction->Function[{X1,X2,Z}, X1+X2<1],
AxesLabel->{"X1","X2","Z"}
]



