Merge branch 'master' into bugfix/job-setup

This commit is contained in:
mlampert
2021-03-16 19:58:52 -07:00
committed by GitHub
2 changed files with 58 additions and 43 deletions

View File

@@ -273,7 +273,7 @@ class _TaskPanel:
return
self.card_path = self.parameterWidget.cb_materials.itemData(index) # returns whole path
FreeCAD.Console.PrintMessage(
"choose_material in FEM material task panel:\n"
"Material card choosen:\n"
" {}\n".format(self.card_path)
)
self.material = self.materials[self.card_path]
@@ -389,7 +389,7 @@ class _TaskPanel:
# FreeCAD units definition is at file end of src/Base/Unit.cpp
if not self.material:
FreeCAD.Console.PrintMessage("For some reason all material data is empty!\n")
self.material["Name"] = "Empty"
self.material["Name"] = "NoName"
if "Density" in self.material:
if "Density" not in str(Units.Unit(self.material["Density"])):
FreeCAD.Console.PrintMessage(
@@ -400,7 +400,7 @@ class _TaskPanel:
self.material["Density"] = "0 kg/m^3"
else:
FreeCAD.Console.PrintMessage(
"Density not found in material data of: {}\n"
"Density not found in {}\n"
.format(self.material["Name"])
)
self.material["Density"] = "0 kg/m^3"
@@ -417,7 +417,7 @@ class _TaskPanel:
self.material["YoungsModulus"] = "0 MPa"
else:
FreeCAD.Console.PrintMessage(
"YoungsModulus not found in material data of: {}\n"
"YoungsModulus not found in {}\n"
.format(self.material["Name"])
)
self.material["YoungsModulus"] = "0 MPa"
@@ -433,7 +433,7 @@ class _TaskPanel:
self.material["PoissonRatio"] = "0"
else:
FreeCAD.Console.PrintMessage(
"PoissonRatio not found in material data of: {}\n"
"PoissonRatio not found in {}\n"
.format(self.material["Name"])
)
self.material["PoissonRatio"] = "0"
@@ -450,7 +450,7 @@ class _TaskPanel:
self.material["KinematicViscosity"] = "0 m^2/s"
else:
FreeCAD.Console.PrintMessage(
"KinematicViscosity not found in material data of: {}\n"
"KinematicViscosity not found in {}\n"
.format(self.material["Name"])
)
self.material["KinematicViscosity"] = "0 m^2/s"
@@ -466,7 +466,7 @@ class _TaskPanel:
self.material["VolumetricThermalExpansionCoefficient"] = "0 m^3/m^3/K"
else:
FreeCAD.Console.PrintMessage(
"VolumetricThermalExpansionCoefficient not found in material data of: {}\n"
"VolumetricThermalExpansionCoefficient not found in {}\n"
.format(self.material["Name"])
)
self.material["VolumetricThermalExpansionCoefficient"] = "0 m^3/m^3/K"
@@ -481,7 +481,7 @@ class _TaskPanel:
self.material["ThermalConductivity"] = "0 W/m/K"
else:
FreeCAD.Console.PrintMessage(
"ThermalConductivity not found in material data of: {}\n"
"ThermalConductivity not found in {}\n"
.format(self.material["Name"])
)
self.material["ThermalConductivity"] = "0 W/m/K"
@@ -496,7 +496,7 @@ class _TaskPanel:
self.material["ThermalExpansionCoefficient"] = "0 um/m/K"
else:
FreeCAD.Console.PrintMessage(
"ThermalExpansionCoefficient not found in material data of: {}\n"
"ThermalExpansionCoefficient not found in {}\n"
.format(self.material["Name"])
)
self.material["ThermalExpansionCoefficient"] = "0 um/m/K"
@@ -510,20 +510,21 @@ class _TaskPanel:
self.material["SpecificHeat"] = "0 J/kg/K"
else:
FreeCAD.Console.PrintMessage(
"SpecificHeat not found in material data of: {}\n"
"SpecificHeat not found in {}\n"
.format(self.material["Name"])
)
self.material["SpecificHeat"] = "0 J/kg/K"
FreeCAD.Console.PrintMessage("\n")
def update_material_property(self, input_field, matProperty, qUnit, variation=0.001):
def update_material_property(self, inputfield_text, matProperty, qUnit, variation=0.001):
# print(inputfield_text)
# this update property works for all Gui::InputField widgets
if qUnit != "":
value = Units.Quantity(input_field.text()).getValueAs(qUnit)
value = Units.Quantity(inputfield_text).getValueAs(qUnit)
old_value = Units.Quantity(self.material[matProperty]).getValueAs(qUnit)
else:
# for example PoissonRatio
value = float(input_field.text())
value = float(inputfield_text)
old_value = float(self.material[matProperty])
if value:
if not (1 - variation < float(old_value) / value < 1 + variation):
@@ -540,40 +541,36 @@ class _TaskPanel:
self.set_transient_material()
else:
pass # some check or default value set can be done here
# print(inputfield_text)
# mechanical input fields
def ym_changed(self):
# FreeCADs standard unit for stress is kPa for UnitsSchemeInternal, but MPa can be used
input_field = self.parameterWidget.input_fd_young_modulus
variation = 0.001
self.update_material_property(
input_field,
self.parameterWidget.input_fd_young_modulus.text(),
"YoungsModulus",
"kPa",
variation
)
def density_changed(self):
print(
"String read from density input field: {}"
.format(self.parameterWidget.input_fd_density.text())
)
# FreeCADs standard unit for density is kg/mm^3 for UnitsSchemeInternal
input_field = self.parameterWidget.input_fd_density
variation = 0.001
self.update_material_property(
input_field,
self.parameterWidget.input_fd_density.text(),
"Density",
"kg/m^3",
variation
)
def pr_changed(self):
value = self.parameterWidget.spinBox_poisson_ratio.value()
input_field = self.parameterWidget.spinBox_poisson_ratio
if value:
variation = 0.001
self.update_material_property(
input_field,
self.parameterWidget.spinBox_poisson_ratio.text(),
"PoissonRatio",
"",
variation
)
elif value == 0:
# PoissonRatio was set to 0.0 what is possible
@@ -587,50 +584,39 @@ class _TaskPanel:
# thermal input fields
def tc_changed(self):
input_field = self.parameterWidget.input_fd_thermal_conductivity
variation = 0.001
self.update_material_property(
input_field,
self.parameterWidget.input_fd_thermal_conductivity.text(),
"ThermalConductivity",
"W/m/K",
variation
)
def tec_changed(self):
input_field = self.parameterWidget.input_fd_expansion_coefficient
variation = 0.001
self.update_material_property(
input_field,
self.parameterWidget.input_fd_expansion_coefficient.text(),
"ThermalExpansionCoefficient",
"um/m/K",
variation
)
def sh_changed(self):
input_field = self.parameterWidget.input_fd_specific_heat
variation = 0.001
self.update_material_property(
input_field,
self.parameterWidget.input_fd_specific_heat.text(),
"SpecificHeat",
"J/kg/K",
variation
)
# fluidic input fields
def vtec_changed(self):
input_field = self.parameterWidget.input_fd_vol_expansion_coefficient
self.update_material_property(
input_field,
self.parameterWidget.input_fd_vol_expansion_coefficient.text(),
"VolumetricThermalExpansionCoefficient",
"m^3/m^3/K"
"m^3/m^3/K",
)
def kinematic_viscosity_changed(self):
input_field = self.parameterWidget.input_fd_kinematic_viscosity
self.update_material_property(
input_field,
self.parameterWidget.input_fd_kinematic_viscosity.text(),
"KinematicViscosity",
"m^2/s"
"m^2/s",
)
def set_mat_params_in_input_fields(self, matmap):

View File

@@ -89,6 +89,7 @@
# include <NCollection_List.hxx>
# include <BRepFill_Filling.hxx>
#endif
# include <BRepFill_Generator.hxx>
#include <cstdio>
#include <fstream>
@@ -455,6 +456,10 @@ public:
"Create a ruled surface out of two edges or wires. If wires are used then"
"these must have the same number of edges."
);
add_varargs_method("makeShellFromWires",&Module::makeShellFromWires,
"makeShellFromWires(Wires) -- Make a shell from wires.\n"
"The wires must have the same number of edges."
);
add_varargs_method("makeTube",&Module::makeTube,
"makeTube(edge,radius,[continuity,max degree,max segments]) -- Create a tube.\n"
"continuity is a string which must be 'C0','C1','C2','C3','CN','G1' or 'G1',"
@@ -1630,6 +1635,30 @@ private:
throw Py::Exception(PartExceptionOCCError, "creation of ruled surface failed");
}
}
Py::Object makeShellFromWires(const Py::Tuple& args)
{
PyObject *pylist;
if (!PyArg_ParseTuple(args.ptr(), "O", &pylist))
throw Py::Exception();
try {
BRepFill_Generator fill;
Py::Sequence list(pylist);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
Py::TopoShape shape(*it);
const TopoDS_Shape& s = shape.extensionObject()->getTopoShapePtr()->getShape();
if (!s.IsNull() && s.ShapeType() == TopAbs_WIRE) {
fill.AddWire(TopoDS::Wire(s));
}
}
fill.Perform();
return Py::asObject(new TopoShapeShellPy(new TopoShape(fill.Shell())));
}
catch (Standard_Failure&) {
throw Py::Exception(PartExceptionOCCError, "creation of shell failed");
}
}
Py::Object makeTube(const Py::Tuple& args)
{
PyObject *pshape;