(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 11.3' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       158,          7]
NotebookDataLength[     26434,        743]
NotebookOptionsPosition[     22024,        674]
NotebookOutlinePosition[     22388,        690]
CellTagsIndexPosition[     22345,        687]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{

Cell[CellGroupData[{
Cell["Parametric curve", "Title",ExpressionUUID->"79a46f05-a3a7-4626-bea4-856a395496dc"],

Cell[CellGroupData[{

Cell["Theory", "Section",ExpressionUUID->"b163ea11-98d6-453a-a69e-a02bcb2f1b4b"],

Cell[CellGroupData[{

Cell["Definition", "Subsection",ExpressionUUID->"ab1b5d88-55db-4455-a06e-94a035e67c77"],

Cell[TextData[{
 "We have a curve defined by \n",
 Cell[BoxData[
  FormBox[GridBox[{
     {
      RowBox[{GridBox[{
         {
          RowBox[{
           RowBox[{"r", "(", "t", ")"}], "=",
           RowBox[{
            RowBox[{"{",
             RowBox[{
              RowBox[{"x", "(", "t", ")"}], ",",
              RowBox[{"y", "(", "t", ")"}], ",",
              RowBox[{"z", "(", "t", ")"}]}], "}"}], "\[Transpose]"}]}]}
        },
        GridBoxAlignment->{"Columns" -> {{"Center"}}}], ","}]}
    },
    GridBoxItemSize->{"Columns" -> {{
         Scaled[0.96]}}}], TraditionalForm]],ExpressionUUID->
  "6a41d068-3307-4304-8b1f-38203b3b3ca1"],
 "\nwith ",
 Cell[BoxData[
  FormBox[
   RowBox[{"t", "\[Element]",
    RowBox[{"[",
     RowBox[{
      SubscriptBox["t", "a"], ",",
      SubscriptBox["t", "b"]}], "]"}]}], TraditionalForm]],ExpressionUUID->
  "11037534-09fc-413b-9f41-52ab75a9c387"],
 ". The goal is to discretize the curve with equally spaced finite elements, \
therefore the arc length along the beam needs to be integrated."
}], "Text",ExpressionUUID->"171d2317-6c08-4c9b-a14d-4723b4f8ee51"]
}, Open  ]],

Cell[CellGroupData[{

Cell["Arc length", "Subsection",ExpressionUUID->"20387f21-9551-4ef1-9074-c40ce371626d"],

Cell[TextData[{
 "The arc length from ",
 Cell[BoxData[
  FormBox[
   SubscriptBox["t", "a"], TraditionalForm]],ExpressionUUID->
  "0758c790-4741-4197-87a4-76d0b4f26e93"],
 " to ",
 Cell[BoxData[
  FormBox["t", TraditionalForm]],ExpressionUUID->
  "1c4f7092-0f9a-4955-91d0-629344ead5db"],
 " is calculated by \n",
 Cell[BoxData[
  FormBox[GridBox[{
     {
      RowBox[{GridBox[{
         {
          RowBox[{"S", "="}]}
        },
        GridBoxAlignment->{"Columns" -> {{"Center"}}}],
       RowBox[{"\[Integral]",
        RowBox[{"\[DifferentialD]", "s"}]}]}]}
    },
    GridBoxItemSize->{"Columns" -> {{
         Scaled[0.96]}}}], TraditionalForm]],ExpressionUUID->
  "8249aa1c-ef39-4f13-a474-c9e90ddc373a"],
 "\nwith\n",
 Cell[BoxData[
  FormBox[GridBox[{
     {
      RowBox[{
       RowBox[{"\[DifferentialD]", "s"}], "=",
       RowBox[{
        RowBox[{
         RowBox[{"\[LeftDoubleBracketingBar]",
          RowBox[{"r", "'"}], "\[RightDoubleBracketingBar]"}],
         RowBox[{"\[DifferentialD]", "t"}]}], "=",
        RowBox[{
         SqrtBox[
          RowBox[{
           SuperscriptBox[
            RowBox[{"x", "'"}], "2"], "+",
           SuperscriptBox[
            RowBox[{"y", "'"}], "2"], "+",
           SuperscriptBox[
            RowBox[{"z", "'"}], "2"]}]],
         RowBox[{"\[DifferentialD]", "t"}]}]}]}]}
    },
    GridBoxItemSize->{"Columns" -> {{
         Scaled[0.96]}}}], TraditionalForm]],ExpressionUUID->
  "8aa6d33b-aba6-4969-a2cc-c62619dd3ef6"],
 "\nthe arc length is\n",
 Cell[BoxData[
  FormBox[GridBox[{
     {
      RowBox[{GridBox[{
         {
          RowBox[{
           RowBox[{"S", "(", "t", ")"}], "="}]}
        },
        GridBoxAlignment->{"Columns" -> {{"Center"}}}],
       RowBox[{
        SubsuperscriptBox["\[Integral]",
         SubscriptBox["t", "a"], "t"],
        RowBox[{
         SqrtBox[
          RowBox[{
           RowBox[{
            RowBox[{"x", "'"}],
            SuperscriptBox[
             RowBox[{"(", "\[Tau]", ")"}], "2"]}], "+",
           RowBox[{
            RowBox[{"y", "'"}],
            SuperscriptBox[
             RowBox[{"(", "\[Tau]", ")"}], "2"]}], "+",
           RowBox[{
            RowBox[{"z", "'"}],
            SuperscriptBox[
             RowBox[{"(", "\[Tau]", ")"}], "2"]}]}]],
         RowBox[{
          RowBox[{"\[DifferentialD]", "\[Tau]"}], "."}]}]}]}]}
    },
    GridBoxItemSize->{"Columns" -> {{
         Scaled[0.96]}}}], TraditionalForm]],ExpressionUUID->
  "e432aa2e-6b4e-4f1e-ad9d-4ae2172c6d02"],
 "\nThe length of the whole curve is ",
 Cell[BoxData[
  FormBox[
   RowBox[{"L", "=",
    RowBox[{"S", "(",
     SubscriptBox["t", "b"], ")"}]}], TraditionalForm]],ExpressionUUID->
  "edf96f78-92d3-457a-96a4-9c9fb23cd788"],
 ". When the length is known the arc length for a finite element node ",
 Cell[BoxData[
  FormBox[
   RowBox[{
    SubscriptBox["S", "n"], "=",
    RowBox[{"S", "(",
     SubscriptBox["t", "n"], ")"}]}], TraditionalForm]],ExpressionUUID->
  "8db23eab-422f-47ea-8406-227f2467158e"],
 " can be calculated (nodes do not have to be equally spaced). The next step \
is to get the parameter ",
 Cell[BoxData[
  FormBox[
   SubscriptBox["t", "n"], TraditionalForm]],ExpressionUUID->
  "78e0a289-0cc4-4c49-8ba2-f7891868e836"],
 ". The best way to do this is via Newtons-method by finding a root for the \
residual \n",
 Cell[BoxData[
  FormBox[GridBox[{
     {GridBox[{
        {
         RowBox[{
          RowBox[{
           RowBox[{"S", "(", "t", ")"}], "-",
           SubscriptBox["S", "n"]}], "=",
          RowBox[{"R", "."}]}]}
       },
       GridBoxAlignment->{"Columns" -> {{"Center"}}}]}
    },
    GridBoxItemSize->{"Columns" -> {{
         Scaled[0.96]}}}], TraditionalForm]],ExpressionUUID->
  "d2df8bf0-be5d-4a87-9444-1c2c7ecef89c"],
 "\nLinearization:\n",
 Cell[BoxData[
  FormBox[GridBox[{
     {GridBox[{
        {
         RowBox[{
          FractionBox[
           RowBox[{"\[PartialD]", "R"}],
           RowBox[{"\[PartialD]", "t"}]], "=",
          RowBox[{
           FractionBox[
            RowBox[{"\[PartialD]", "S"}],
            RowBox[{"\[PartialD]", "t"}]], "=",
           SqrtBox[
            RowBox[{
             SuperscriptBox[
              RowBox[{"x", "'"}], "2"], "+",
             SuperscriptBox[
              RowBox[{"y", "'"}], "2"], "+",
             SuperscriptBox[
              RowBox[{"z", "'"}], "2"]}]]}]}]}
       },
       GridBoxAlignment->{"Columns" -> {{"Center"}}}]}
    },
    GridBoxItemSize->{"Columns" -> {{
         Scaled[0.96]}}}], TraditionalForm]],ExpressionUUID->
  "d29c3516-9af7-4961-b4ee-f73faf39b9fd"]
}], "Text",ExpressionUUID->"12ff3d6e-fc3f-45d5-8f25-c49c6385bd14"]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["Example", "Section",ExpressionUUID->"fa901e4d-4f51-425b-b38d-2402ec1883ee"],

Cell[BoxData[
 RowBox[{
  RowBox[{"referenceFileDirectory", "=",
   RowBox[{"FileNameJoin", "[",
    RowBox[{"{",
     RowBox[{
      RowBox[{"ParentDirectory", "[",
       RowBox[{"NotebookDirectory", "[", "]"}], "]"}], ",",
      "\[IndentingNewLine]", "\"\<tests\>\"", ",",
      "\"\<reference-files\>\""}], "}"}], "]"}]}], ";"}]], "Input",
 CellLabel->"In[48]:=",ExpressionUUID->"32555063-f343-4d69-83c7-3617b322660a"],

Cell[CellGroupData[{

Cell["Helix", "Subsection",ExpressionUUID->"b6fd7fd8-b1af-4ee0-8fe6-7edf2793f347"],

Cell[BoxData[
 RowBox[{
  RowBox[{"$Assumptions", "=",
   RowBox[{"{",
    RowBox[{
     RowBox[{"{",
      RowBox[{"t", ",", "tint"}], "}"}], "\[Element]", "Reals"}], "}"}]}],
  ";"}]], "Input",
 CellLabel->"In[90]:=",ExpressionUUID->"2306497f-7144-49ff-9fff-7fe800379eb8"],

Cell["One turn of a helix with scaled coordinate along curve.", "Text",ExpressionUUID->"76edc4ff-0d7c-4326-acbb-7acdd70f7753"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"intervall", "=",
   RowBox[{"{",
    RowBox[{"0", ",",
     RowBox[{"2", "\[Pi]"}]}], "}"}]}], ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"intervallLength", "=",
   RowBox[{
    RowBox[{
    "intervall", "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}], "-",

    RowBox[{
    "intervall", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}]}]}],
  ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"fac", "=", "2"}], ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{
   RowBox[{"transformation", "[", "t_", "]"}], ":=",
   RowBox[{
    RowBox[{"Exp", "[",
     RowBox[{"fac", " ",
      RowBox[{"t", "/", "intervallLength"}]}], "]"}],
    RowBox[{"t", "/",
     RowBox[{"Exp", "[", "fac", "]"}]}]}]}], ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"r", "=",
   RowBox[{"{", "\[IndentingNewLine]",
    RowBox[{
     RowBox[{"2",
      RowBox[{"Cos", "[",
       RowBox[{"transformation", "[", "t", "]"}], "]"}]}], ",",
     "\[IndentingNewLine]",
     RowBox[{"2",
      RowBox[{"Sin", "[",
       RowBox[{"transformation", "[", "t", "]"}], "]"}]}], ",",
     "\[IndentingNewLine]",
     RowBox[{"4",
      RowBox[{
       RowBox[{"transformation", "[", "t", "]"}], "/",
       "intervallLength"}]}]}], "\[IndentingNewLine]", "}"}]}],
  ";"}]}], "Input",
 CellLabel->"In[91]:=",ExpressionUUID->"ac1f361d-f0d5-4f66-8445-f93ca479fe41"],

Cell["Get the inverse transformation.", "Text",ExpressionUUID->"a398365a-d516-404e-a321-ad5f66afc445"],

Cell[BoxData[
 RowBox[{"invTransformation", "=",
  RowBox[{"t", "/.",
   RowBox[{
    RowBox[{"Solve", "[",
     RowBox[{
      RowBox[{
       RowBox[{"transformation", "[", "t", "]"}], "\[Equal]", "s"}], ",",
      "t"}], "]"}], "\[LeftDoubleBracket]", "1",
    "\[RightDoubleBracket]"}]}]}]], "Input",
 CellLabel->"In[96]:=",ExpressionUUID->"a9dd87a4-1ddd-417e-b021-2bcf7fc7244e"],

Cell["\<\
Plot the transformation and its inverse of the parameter coordinate.\
\>", "Text",ExpressionUUID->"cbe6e905-5aa1-4042-aa28-584cc6c2293a"],

Cell[BoxData[
 RowBox[{"{", "\[IndentingNewLine]",
  RowBox[{
   RowBox[{"Plot", "[",
    RowBox[{
     RowBox[{"transformation", "[", "t", "]"}], ",",
     RowBox[{"{",
      RowBox[{"t", ",",
       RowBox[{
       "intervall", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}],
       ",",
       RowBox[{
       "intervall", "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}]}],
      "}"}]}], "]"}], ",", "\[IndentingNewLine]",
   RowBox[{"Plot", "[",
    RowBox[{"invTransformation", ",",
     RowBox[{"{",
      RowBox[{"s", ",",
       RowBox[{
       "intervall", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}],
       ",",
       RowBox[{
       "intervall", "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}]}],
      "}"}]}], "]"}]}], "\[IndentingNewLine]", "}"}]], "Input",
 CellLabel->"In[97]:=",ExpressionUUID->"ccb91c5a-a515-41b9-a968-9009947a882a"],

Cell["Number of elements.", "Text",ExpressionUUID->"17483e09-353d-4c80-b48c-0b3b33969c6f"],

Cell[BoxData[
 RowBox[{
  RowBox[{"nel", "=", "10"}], ";"}]], "Input",
 CellLabel->"In[98]:=",ExpressionUUID->"bbf791dc-278e-4ea6-ad9f-0e3af20ffd92"],

Cell[TextData[{
 "Draw the curve in 3D, with equally spaces points in ",
 Cell[BoxData[
  FormBox["t", TraditionalForm]],ExpressionUUID->
  "d1d09c6f-7360-4018-a9fe-84268a4e9114"],
 ". It is clear that the arc length between the points is not equal."
}], "Text",ExpressionUUID->"7529a3fd-0322-45dd-98a1-eb3383bfe518"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"pltCurve", "=",
   RowBox[{"ParametricPlot3D", "[",
    RowBox[{"r", ",",
     RowBox[{"{",
      RowBox[{"t", ",",
       RowBox[{
       "intervall", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}],
       ",",
       RowBox[{
       "intervall", "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}]}],
      "}"}], ",",
     RowBox[{"AxesLabel", "\[Rule]",
      RowBox[{"{",
       RowBox[{"\"\<x\>\"", ",", "\"\<y\>\"", ",", "\"\<z\>\""}], "}"}]}],
     ",",
     RowBox[{"PlotStyle", "\[Rule]", "Blue"}]}], "]"}]}],
  ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"pltPoints", "=",
   RowBox[{"ListPointPlot3D", "[", "\[IndentingNewLine]",
    RowBox[{
     RowBox[{"Table", "[",
      RowBox[{
       RowBox[{"N", "[", "r", "]"}], ",",
       RowBox[{"{",
        RowBox[{"t", ",",
         RowBox[{
         "intervall", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}],
         ",",
         RowBox[{
         "intervall", "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}],
         ",", "0.5"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]",
     RowBox[{"PlotStyle", "\[Rule]", "Orange"}]}], "\[IndentingNewLine]",
    "]"}]}], ";"}], "\[IndentingNewLine]",
 RowBox[{"Show", "[",
  RowBox[{"pltCurve", ",", "pltPoints", ",",
   RowBox[{"PlotRange", "\[Rule]", "All"}], ",",
   RowBox[{"AspectRatio", "\[Rule]", "Automatic"}]}], "]"}]}], "Input",
 CellLabel->
  "In[115]:=",ExpressionUUID->"f382cc1d-966b-49d2-8192-a8af9520b3f8"],

Cell["Calculate the arc length along the beam curve.", "Text",ExpressionUUID->"4ea3d8ab-a7ee-47e7-ad92-487dce00c89d"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"ds", "=",
   RowBox[{"Simplify", "[",
    RowBox[{"Norm", "[",
     RowBox[{
      SubscriptBox["\[PartialD]", "t"], "r"}], "]"}], "]"}]}],
  ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"S", "=",
   RowBox[{
    RowBox[{"Evaluate", "[",
     RowBox[{"(",
      RowBox[{"Integrate", "[",
       RowBox[{"ds", ",",
        RowBox[{"{",
         RowBox[{"t", ",",
          RowBox[{
          "intervall", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}],
           ",", "tint"}], "}"}], ",",
        RowBox[{"Assumptions", "\[Rule]",
         RowBox[{"tint", ">",
          RowBox[{
          "intervall", "\[LeftDoubleBracket]", "2",
           "\[RightDoubleBracket]"}]}]}]}], "]"}], ")"}], "]"}], "/.",
    RowBox[{"tint", "\[Rule]", "t"}]}]}], ";"}]}], "Input",
 CellLabel->
  "In[102]:=",ExpressionUUID->"f7456b6f-fed7-4b68-b33d-8d1235f50f4a"],

Cell["Total length of the curve.", "Text",ExpressionUUID->"d7c1bf38-9679-4d93-863f-1539762eb64c"],

Cell[BoxData[
 RowBox[{"L", "=",
  RowBox[{"S", "/.",
   RowBox[{"t", "->",
    RowBox[{
    "intervall", "\[LeftDoubleBracket]", "2",
     "\[RightDoubleBracket]"}]}]}]}]], "Input",
 CellLabel->
  "In[104]:=",ExpressionUUID->"91ae4741-a8fd-454f-9fd1-f4ffdb86512d"],

Cell["Divide the curve in equally spaced elements.", "Text",ExpressionUUID->"26759f0e-b0bc-4959-9c81-5875ad5e3378"],

Cell[BoxData[
 RowBox[{
  RowBox[{"Lel", "=",
   RowBox[{"L", "/", "nel"}]}], ";"}]], "Input",
 CellLabel->
  "In[105]:=",ExpressionUUID->"430ee304-8bb3-49da-a5f0-bf9a05f600b6"],

Cell["Calculate the parameter for the nodes.", "Text",ExpressionUUID->"1ec28448-cc57-40f7-8300-193b177e7fb9"],

Cell[BoxData[
 RowBox[{
  RowBox[{"tNodes", "=",
   RowBox[{"Table", "[", "\[IndentingNewLine]",
    RowBox[{
     RowBox[{"t", "/.", "\[IndentingNewLine]",
      RowBox[{"FindRoot", "[",
       RowBox[{
        RowBox[{"S", "-",
         RowBox[{"i", " ",
          RowBox[{"L", "/", "nel"}]}]}], ",",
        RowBox[{"{",
         RowBox[{"t", ",",
          RowBox[{"i",
           RowBox[{
            RowBox[{"(",
             RowBox[{
              RowBox[{
              "intervall", "\[LeftDoubleBracket]", "2",
               "\[RightDoubleBracket]"}], "-",
              RowBox[{
              "intervall", "\[LeftDoubleBracket]", "1",
               "\[RightDoubleBracket]"}]}], ")"}], "/", "nel"}]}]}], "}"}]}],
       "]"}]}], "\[IndentingNewLine]", ",",
     RowBox[{"{",
      RowBox[{"i", ",", "0", ",", "nel"}], "}"}]}], "]"}]}], ";"}]], "Input",
 CellLabel->
  "In[106]:=",ExpressionUUID->"a9b2b839-d6e4-4850-948e-b89036e084c3"],

Cell["Plot the nodes (now equally spaced)", "Text",ExpressionUUID->"f07fd95f-60df-401b-90fb-366b129e713e"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"nodes", "=",
   RowBox[{"Table", "[",
    RowBox[{
     RowBox[{"N", "[", "r", "]"}], ",",
     RowBox[{"{",
      RowBox[{"t", ",", "tNodes"}], "}"}]}], "]"}]}],
  ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"pltNodes", "=",
   RowBox[{"ListPointPlot3D", "[", "\[IndentingNewLine]",
    RowBox[{"nodes", ",", "\[IndentingNewLine]",
     RowBox[{"PlotStyle", "\[Rule]", "Red"}]}], "\[IndentingNewLine]",
    "]"}]}], ";"}], "\[IndentingNewLine]",
 RowBox[{"Show", "[",
  RowBox[{"pltCurve", ",", "pltNodes", ",", "pltPoints", ",",
   RowBox[{"PlotRange", "\[Rule]", "All"}], ",",
   RowBox[{"AspectRatio", "\[Rule]", "Automatic"}]}], "]"}]}], "Input",
 CellLabel->
  "In[118]:=",ExpressionUUID->"0e5ab382-da74-4dab-8883-14783664fb59"],

Cell["Output the coordinates to compare with beamme", "Text",ExpressionUUID->"1b007c3e-b86a-4a11-b2a3-59854e2a4470"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"csvFile", "=",
   RowBox[{"FileNameJoin", "[",
    RowBox[{"{",
     RowBox[{
     "referenceFileDirectory", ",",
      "\"\<test_curve_3d_helix_mathematica.csv\>\""}], "}"}], "]"}]}],
  ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"Export", "[",
   RowBox[{"csvFile", ",", "nodes"}], "]"}], ";"}]}], "Input",
 CellLabel->
  "In[110]:=",ExpressionUUID->"3c38fe49-045a-49c9-8063-bedf6df089fa"]
}, Open  ]],

Cell[CellGroupData[{

Cell["Sinus", "Subsection",ExpressionUUID->"eb2055f1-140d-4202-83aa-92e92968ce39"],

Cell[BoxData[
 RowBox[{
  RowBox[{"$Assumptions", "=",
   RowBox[{"{",
    RowBox[{
     RowBox[{
      RowBox[{"{",
       RowBox[{"t", ",", "tint"}], "}"}], "\[Element]", "Reals"}], ",",
     RowBox[{"0", "\[LessEqual]", "t", "\[LessEqual]",
      RowBox[{"2", "\[Pi]"}]}], ",",
     RowBox[{"0", "\[LessEqual]", "tint", "\[LessEqual]",
      RowBox[{"2", "\[Pi]"}]}]}], "}"}]}], ";"}]], "Input",
 CellLabel->"In[71]:=",ExpressionUUID->"757b8d12-c1dc-4379-b53c-4e190ca81963"],

Cell["Define the function", "Text",ExpressionUUID->"72d5b471-6187-4ba5-be92-6d8ca4801ede"],

Cell[BoxData[{
 RowBox[{"r", "=",
  RowBox[{"{",
   RowBox[{"t", ",",
    RowBox[{"Sin", "[", "t", "]"}]}], "}"}]}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"r3D", "=",
   RowBox[{"Flatten", "[",
    RowBox[{"{",
     RowBox[{
      RowBox[{"{",
       RowBox[{"t", ",",
        RowBox[{"Sin", "[", "t", "]"}]}], "}"}], ",", "0"}], "}"}], "]"}]}],
  ";"}], "\[IndentingNewLine]",
 RowBox[{"ds", "=",
  RowBox[{"Simplify", "[",
   RowBox[{"Norm", "[",
    RowBox[{
     SubscriptBox["\[PartialD]", "t"], "r"}], "]"}],
   "]"}]}], "\[IndentingNewLine]",
 RowBox[{"S", "=",
  RowBox[{
   RowBox[{"(",
    RowBox[{"Integrate", "[",
     RowBox[{"ds", ",",
      RowBox[{"{",
       RowBox[{"t", ",", "0", ",", "tint"}], "}"}]}], "]"}], ")"}], "/.",
   RowBox[{"tint", "\[Rule]", "t"}]}]}]}], "Input",
 CellLabel->"In[72]:=",ExpressionUUID->"864fb784-c9b4-4eba-b31a-188be4066c7a"],

Cell["Get the nodal points", "Text",ExpressionUUID->"50a03bb0-639f-4234-857d-e8af81c79e60"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"nel", "=", "16"}], ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"L", "=",
   RowBox[{"N", "[",
    RowBox[{"S", "/.",
     RowBox[{"t", "\[Rule]",
      RowBox[{"2", "\[Pi]"}]}]}], "]"}]}], ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"Lel", "=",
   RowBox[{"L", "/", "nel"}]}], ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"tNodes", "=",
   RowBox[{"Table", "[", "\[IndentingNewLine]",
    RowBox[{
     RowBox[{"t", "/.",
      RowBox[{"FindRoot", "[",
       RowBox[{
        RowBox[{"S", "-",
         RowBox[{"i", " ", "Lel"}]}], ",",
        RowBox[{"{",
         RowBox[{"t", ",", "i"}], "}"}]}], "]"}]}], ",",
     "\[IndentingNewLine]",
     RowBox[{"{",
      RowBox[{"i", ",", "0", ",", "nel"}], "}"}]}], "\[IndentingNewLine]",
    "]"}]}], ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"nodes", "=",
   RowBox[{"Table", "[",
    RowBox[{
     RowBox[{"N", "[", "r3D", "]"}], ",",
     RowBox[{"{",
      RowBox[{"t", ",", "tNodes"}], "}"}]}], "]"}]}],
  ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"pltNodes", "=",
   RowBox[{"ListPlot", "[", "\[IndentingNewLine]",
    RowBox[{
     RowBox[{"nodes", "\[LeftDoubleBracket]",
      RowBox[{"All", ",",
       RowBox[{"{",
        RowBox[{"1", ",", "2"}], "}"}]}], "\[RightDoubleBracket]"}], ",",
     "\[IndentingNewLine]",
     RowBox[{"PlotStyle", "\[Rule]", "Red"}]}], "\[IndentingNewLine]",
    "]"}]}], ";"}]}], "Input",
 CellLabel->"In[76]:=",ExpressionUUID->"fa08b071-5194-4155-9a59-2647bfb34cdb"],

Cell["Plot the function with parametric points", "Text",ExpressionUUID->"d88596ee-5054-4577-bd5e-813d0c47b5d5"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"pltCurve", "=",
   RowBox[{"ParametricPlot", "[",
    RowBox[{"r", ",",
     RowBox[{"{",
      RowBox[{"t", ",", "0", ",",
       RowBox[{"2", "\[Pi]"}]}], "}"}]}], "]"}]}],
  ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"pltPoints", "=",
   RowBox[{"ListPlot", "[",
    RowBox[{"Table", "[",
     RowBox[{
      RowBox[{"N", "[", "r", "]"}], ",",
      RowBox[{"{",
       RowBox[{"t", ",", "0", ",",
        RowBox[{"2", "\[Pi]"}], ",",
        RowBox[{"2",
         RowBox[{"\[Pi]", "/", "nel"}]}]}], "}"}]}], "]"}], "]"}]}],
  ";"}], "\[IndentingNewLine]",
 RowBox[{"Show", "[",
  RowBox[{"pltCurve", ",", "pltPoints", ",", "pltNodes"}], "]"}]}], "Input",
 CellLabel->"In[82]:=",ExpressionUUID->"54d2d687-b73e-44e7-982a-b561f58587c0"],

Cell["Output the coordinates to compare with beamme", "Text",ExpressionUUID->"a5e0a165-187e-454b-a308-d5c39a0d250e"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"csvFile", "=",
   RowBox[{"FileNameJoin", "[",
    RowBox[{"{",
     RowBox[{
     "referenceFileDirectory", ",",
      "\"\<test_curve_2d_sin_mathematica.csv\>\""}], "}"}], "]"}]}],
  ";"}], "\[IndentingNewLine]",
 RowBox[{
  RowBox[{"Export", "[",
   RowBox[{"csvFile", ",", "nodes"}], "]"}], ";"}]}], "Input",
 CellLabel->"In[85]:=",ExpressionUUID->"32f0de4d-05bb-454d-b1bd-087e1afa8f19"]
}, Open  ]]
}, Open  ]]
}, Open  ]]
},
WindowSize->{928, 1028},
WindowMargins->{{0, Automatic}, {Automatic, 28}},
Magnification:>1.5 Inherited,
FrontEndVersion->"11.3 for Linux x86 (64-bit) (March 6, 2018)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[580, 22, 88, 0, 147, "Title",ExpressionUUID->"79a46f05-a3a7-4626-bea4-856a395496dc"],
Cell[CellGroupData[{
Cell[693, 26, 80, 0, 101, "Section",ExpressionUUID->"b163ea11-98d6-453a-a69e-a02bcb2f1b4b"],
Cell[CellGroupData[{
Cell[798, 30, 87, 0, 81, "Subsection",ExpressionUUID->"ab1b5d88-55db-4455-a06e-94a035e67c77"],
Cell[888, 32, 1124, 32, 156, "Text",ExpressionUUID->"171d2317-6c08-4c9b-a14d-4723b4f8ee51"]
}, Open  ]],
Cell[CellGroupData[{
Cell[2049, 69, 87, 0, 81, "Subsection",ExpressionUUID->"20387f21-9551-4ef1-9074-c40ce371626d"],
Cell[2139, 71, 4702, 149, 480, "Text",ExpressionUUID->"12ff3d6e-fc3f-45d5-8f25-c49c6385bd14"]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[6890, 226, 81, 0, 101, "Section",ExpressionUUID->"fa901e4d-4f51-425b-b38d-2402ec1883ee"],
Cell[6974, 228, 429, 10, 82, "Input",ExpressionUUID->"32555063-f343-4d69-83c7-3617b322660a"],
Cell[CellGroupData[{
Cell[7428, 242, 82, 0, 81, "Subsection",ExpressionUUID->"b6fd7fd8-b1af-4ee0-8fe6-7edf2793f347"],
Cell[7513, 244, 278, 8, 47, "Input",ExpressionUUID->"2306497f-7144-49ff-9fff-7fe800379eb8"],
Cell[7794, 254, 126, 0, 54, "Text",ExpressionUUID->"76edc4ff-0d7c-4326-acbb-7acdd70f7753"],
Cell[7923, 256, 1422, 43, 320, "Input",ExpressionUUID->"ac1f361d-f0d5-4f66-8445-f93ca479fe41"],
Cell[9348, 301, 102, 0, 54, "Text",ExpressionUUID->"a398365a-d516-404e-a321-ad5f66afc445"],
Cell[9453, 303, 388, 10, 47, "Input",ExpressionUUID->"a9dd87a4-1ddd-417e-b021-2bcf7fc7244e"],
Cell[9844, 315, 147, 2, 54, "Text",ExpressionUUID->"cbe6e905-5aa1-4042-aa28-584cc6c2293a"],
Cell[9994, 319, 902, 24, 150, "Input",ExpressionUUID->"ccb91c5a-a515-41b9-a968-9009947a882a"],
Cell[10899, 345, 90, 0, 54, "Text",ExpressionUUID->"17483e09-353d-4c80-b48c-0b3b33969c6f"],
Cell[10992, 347, 149, 3, 47, "Input",ExpressionUUID->"bbf791dc-278e-4ea6-ad9f-0e3af20ffd92"],
Cell[11144, 352, 317, 6, 90, "Text",ExpressionUUID->"7529a3fd-0322-45dd-98a1-eb3383bfe518"],
Cell[11464, 360, 1528, 41, 252, "Input",ExpressionUUID->"f382cc1d-966b-49d2-8192-a8af9520b3f8"],
Cell[12995, 403, 117, 0, 54, "Text",ExpressionUUID->"4ea3d8ab-a7ee-47e7-ad92-487dce00c89d"],
Cell[13115, 405, 912, 27, 150, "Input",ExpressionUUID->"f7456b6f-fed7-4b68-b33d-8d1235f50f4a"],
Cell[14030, 434, 97, 0, 54, "Text",ExpressionUUID->"d7c1bf38-9679-4d93-863f-1539762eb64c"],
Cell[14130, 436, 269, 8, 47, "Input",ExpressionUUID->"91ae4741-a8fd-454f-9fd1-f4ffdb86512d"],
Cell[14402, 446, 115, 0, 54, "Text",ExpressionUUID->"26759f0e-b0bc-4959-9c81-5875ad5e3378"],
Cell[14520, 448, 178, 5, 47, "Input",ExpressionUUID->"430ee304-8bb3-49da-a5f0-bf9a05f600b6"],
Cell[14701, 455, 109, 0, 54, "Text",ExpressionUUID->"1ec28448-cc57-40f7-8300-193b177e7fb9"],
Cell[14813, 457, 963, 27, 150, "Input",ExpressionUUID->"a9b2b839-d6e4-4850-948e-b89036e084c3"],
Cell[15779, 486, 106, 0, 54, "Text",ExpressionUUID->"f07fd95f-60df-401b-90fb-366b129e713e"],
Cell[15888, 488, 790, 20, 218, "Input",ExpressionUUID->"0e5ab382-da74-4dab-8883-14783664fb59"],
Cell[16681, 510, 116, 0, 54, "Text",ExpressionUUID->"1b007c3e-b86a-4a11-b2a3-59854e2a4470"],
Cell[16800, 512, 447, 13, 150, "Input",ExpressionUUID->"3c38fe49-045a-49c9-8063-bedf6df089fa"]
}, Open  ]],
Cell[CellGroupData[{
Cell[17284, 530, 82, 0, 81, "Subsection",ExpressionUUID->"eb2055f1-140d-4202-83aa-92e92968ce39"],
Cell[17369, 532, 484, 12, 47, "Input",ExpressionUUID->"757b8d12-c1dc-4379-b53c-4e190ca81963"],
Cell[17856, 546, 90, 0, 54, "Text",ExpressionUUID->"72d5b471-6187-4ba5-be92-6d8ca4801ede"],
Cell[17949, 548, 900, 28, 150, "Input",ExpressionUUID->"864fb784-c9b4-4eba-b31a-188be4066c7a"],
Cell[18852, 578, 91, 0, 54, "Text",ExpressionUUID->"50a03bb0-639f-4234-857d-e8af81c79e60"],
Cell[18946, 580, 1560, 46, 422, "Input",ExpressionUUID->"fa08b071-5194-4155-9a59-2647bfb34cdb"],
Cell[20509, 628, 111, 0, 54, "Text",ExpressionUUID->"d88596ee-5054-4577-bd5e-813d0c47b5d5"],
Cell[20623, 630, 798, 23, 116, "Input",ExpressionUUID->"54d2d687-b73e-44e7-982a-b561f58587c0"],
Cell[21424, 655, 116, 0, 54, "Text",ExpressionUUID->"a5e0a165-187e-454b-a308-d5c39a0d250e"],
Cell[21543, 657, 441, 12, 116, "Input",ExpressionUUID->"32f0de4d-05bb-454d-b1bd-087e1afa8f19"]
}, Open  ]]
}, Open  ]]
}, Open  ]]
}
]
*)
