p=3;
q=2;

m=p/q;
τArg:=Mod[Arg[#],2π]&

Clear[f,f2]

f[x_]:=
Piecewise[Flatten[Table[{{m (x-2π k/p),2k π/p≤x<(2k+1)π/p},{-m (x-2π k/p)+2π/q,(2k+1) π/p≤x<(2k+2)π/p}},{k,0,p}],{1,2}]]

f2[x_]:=
Piecewise[Flatten[Table[{{m (x-2π k/p) - π/(2q),2k π/p≤x<(2k+1)π/p},{-m (x-2π k/p)+2π/q- π/(2q),(2k+1) π/p≤x<(2k+2)π/p}},{k,0,p}],{1,2}]]

Plot[Table[f[x]+n 2 π/q,{n,0,q}],{x,0,2π},PlotRange->{{0,2π},{0,2π}}]
Plot[Table[f2[x]+n 2 π/q,{n,0,q+1}],{x,0,2π},PlotRange->{{0,2π},{0,2π}}]

f[x]

knot=ParametricPlot3D[Table[{Cos[ ((q θ)/p)+2π k/p],Sin[((q θ)/p)+2π k/p],θ},{k,0,p}],{θ,0,2π},PlotStyle->{Thick,Blue}]

Show[knot,Table[ParametricPlot3D[ComPolar[{r Exp[I (θ-π/(2p))], ((Abs[r Exp[I θ]])^4)f2[τArg[r Exp[I θ]]]+2π n/q}],{r, 0,1},{θ,0,2π},Mesh->None,PlotRange->All,Exclusions->{θ==0},PlotPoints->30],{n,0,q}]]