FEM: LinearizedStress: Core implementation
This commit is contained in:
parent
b7e4259676
commit
d92b8ff8b2
|
@ -1099,6 +1099,53 @@ void setupFilter(Gui::Command* cmd, std::string Name) {
|
|||
|
||||
};
|
||||
|
||||
std::string Plot() {
|
||||
|
||||
return "t=t_coords[len(t_coords)-1]\n\
|
||||
for i in range(len(t_coords)):\n\
|
||||
dum = t_coords[i]\n\
|
||||
t_coords[i] = dum - t_coords[len(t_coords)-1]*0.5\n\
|
||||
m = 0\n\
|
||||
for i in range(len(sValues)-1):\n\
|
||||
m = m +(t_coords[i+1] - t_coords[i])*(sValues[i+1]+sValues[i])\n\
|
||||
m = (1/t)*0.5*m\n\
|
||||
membrane = []\n\
|
||||
for i in range(len(sValues)):\n\
|
||||
membrane.append(m)\n\
|
||||
b = 0\n\
|
||||
for i in range(len(sValues)-1):\n\
|
||||
d = (t_coords[i+1] - t_coords[i])\n\
|
||||
b = b + d*(-3/t**2)*(sValues[i+1]*t_coords[i+1] + sValues[i]*t_coords[i])\n\
|
||||
b2 = -b\n\
|
||||
bending =[]\n\
|
||||
for i in range(len(t_coords)):\n\
|
||||
func = ((b2-b)/t)*t_coords[i]\n\
|
||||
bending.append(func)\n\
|
||||
peak = []\n\
|
||||
mb = []\n\
|
||||
for i in range(len(sValues)):\n\
|
||||
peak.append(sValues[i])\n\
|
||||
mb.append(bending[i] + membrane[0])\n\
|
||||
import FreeCAD\n\
|
||||
import numpy as np\n\
|
||||
from matplotlib import pyplot as plt\n\
|
||||
plt.figure(1)\n\
|
||||
plt.plot(t_coords, membrane, \"k--\")\n\
|
||||
plt.plot(t_coords, mb, \"b*-\")\n\
|
||||
plt.plot(t_coords, peak, \"r-x\")\n\
|
||||
plt.annotate(str(membrane[0]), xy=(t_coords[0], membrane[0]), xytext=(t_coords[0], membrane[0]))\n\
|
||||
plt.annotate(str(mb[0]), xy=(t_coords[0], mb[0]), xytext=(t_coords[0], mb[0]))\n\
|
||||
plt.annotate(str(peak[0]), xy=(t_coords[0], peak[0]), xytext=(t_coords[0], peak[0]))\n\
|
||||
plt.annotate(str(mb[len(t_coords)-1]), xy=(t_coords[len(t_coords)-1], mb[len(t_coords)-1]), xytext=(t_coords[len(t_coords)-1], mb[len(t_coords)-1]))\n\
|
||||
plt.annotate(str(peak[len(t_coords)-1]), xy=(t_coords[len(t_coords)-1], peak[len(t_coords)-1]), xytext=(t_coords[len(t_coords)-1], peak[len(t_coords)-1]))\n\
|
||||
plt.legend([\"Membrane\", \"Membrane and Bending\", \"Total\"], loc = \"best\")\n\
|
||||
plt.xlabel(\"Thickness [mm] \")\n\
|
||||
plt.ylabel(\"Stress [MPa]\")\n\
|
||||
plt.title(\"Linearized Stresses\")\n\
|
||||
plt.grid()\n\
|
||||
plt.show()\n";
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdFemPostCreateClipFilter);
|
||||
|
||||
CmdFemPostCreateClipFilter::CmdFemPostCreateClipFilter()
|
||||
|
@ -1163,6 +1210,28 @@ CmdFemPostCreateLinearizedStressesFilter::CmdFemPostCreateLinearizedStressesFilt
|
|||
|
||||
void CmdFemPostCreateLinearizedStressesFilter::activated(int)
|
||||
{
|
||||
|
||||
Gui::SelectionFilter DataAlongLineFilter("SELECT Fem::FemPostDataAlongLineFilter COUNT 1");
|
||||
|
||||
if (DataAlongLineFilter.match()) {
|
||||
Fem::FemPostDataAlongLineFilter* DataAlongLine = static_cast<Fem::FemPostDataAlongLineFilter*>(DataAlongLineFilter.Result[0][0].getObject());
|
||||
std::string FieldName = DataAlongLine->PlotData.getValue();
|
||||
if ((FieldName == "Max shear stress (Tresca)") || (FieldName == "Maximum Principal stress") || (FieldName == "Minimum Principal stress") || (FieldName == "Von Mises stress")) {
|
||||
doCommand(Gui::Command::Doc,"t_coords = App.ActiveDocument.DataAlongLine.XAxisData");
|
||||
doCommand(Gui::Command::Doc,"sValues = App.ActiveDocument.DataAlongLine.YAxisData");
|
||||
doCommand(Gui::Command::Doc, Plot().c_str());
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("CmdFemPostCreateLinearizedStressesFilter", "Wrong selection"),
|
||||
qApp->translate("CmdFemPostCreateLinearizedStressesFilter", "Select a Clip filter which clips a STRESS field along a line, please."));
|
||||
}
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("CmdFemPostCreateLinearizedStressesFilter", "Wrong selection"),
|
||||
qApp->translate("CmdFemPostCreateLinearizedStressesFilter", "Select a Clip filter which clips a STRESS field along a line, please."));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool CmdFemPostCreateLinearizedStressesFilter::isActive(void)
|
||||
|
@ -1170,7 +1239,6 @@ bool CmdFemPostCreateLinearizedStressesFilter::isActive(void)
|
|||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
|
||||
DEF_STD_CMD_A(CmdFemPostCreateScalarClipFilter);
|
||||
|
||||
CmdFemPostCreateScalarClipFilter::CmdFemPostCreateScalarClipFilter()
|
||||
|
|
Loading…
Reference in New Issue
Block a user