Merge branch 'master' into bugfix/path-length
This commit is contained in:
@@ -130,13 +130,13 @@
|
||||
using namespace App;
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
using namespace boost::program_options;
|
||||
|
||||
|
||||
// scriptings (scripts are built-in but can be overridden by command line option)
|
||||
#include <App/InitScript.h>
|
||||
#include <App/TestScript.h>
|
||||
#include <App/CMakeScript.h>
|
||||
using namespace boost::program_options;
|
||||
|
||||
|
||||
// scriptings (scripts are built-in but can be overridden by command line option)
|
||||
#include <App/InitScript.h>
|
||||
#include <App/TestScript.h>
|
||||
#include <App/CMakeScript.h>
|
||||
|
||||
#ifdef _MSC_VER // New handler for Microsoft Visual C++ compiler
|
||||
# pragma warning( disable : 4535 )
|
||||
@@ -1082,6 +1082,16 @@ void Application::addImportType(const char* Type, const char* ModuleName)
|
||||
}
|
||||
}
|
||||
|
||||
void Application::changeImportModule(const char* Type, const char* OldModuleName, const char* NewModuleName)
|
||||
{
|
||||
for (auto& it : _mImportTypes) {
|
||||
if (it.filter == Type && it.module == OldModuleName) {
|
||||
it.module = NewModuleName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> Application::getImportModules(const char* Type) const
|
||||
{
|
||||
std::vector<std::string> modules;
|
||||
@@ -1195,6 +1205,16 @@ void Application::addExportType(const char* Type, const char* ModuleName)
|
||||
}
|
||||
}
|
||||
|
||||
void Application::changeExportModule(const char* Type, const char* OldModuleName, const char* NewModuleName)
|
||||
{
|
||||
for (auto& it : _mExportTypes) {
|
||||
if (it.filter == Type && it.module == OldModuleName) {
|
||||
it.module = NewModuleName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> Application::getExportModules(const char* Type) const
|
||||
{
|
||||
std::vector<std::string> modules;
|
||||
@@ -2256,7 +2276,7 @@ void Application::LoadParameters(void)
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
// fix weird error while linking boost (all versions of VC)
|
||||
// VS2010: https://forum.freecadweb.org/viewtopic.php?f=4&t=1886&p=12553&hilit=boost%3A%3Afilesystem%3A%3Aget#p12553
|
||||
// VS2010: https://forum.freecadweb.org/viewtopic.php?f=4&t=1886&p=12553&hilit=boost%3A%3Afilesystem%3A%3Aget#p12553
|
||||
namespace boost { namespace program_options { std::string arg="arg"; } }
|
||||
#if (defined (BOOST_VERSION) && (BOOST_VERSION >= 104100))
|
||||
namespace boost { namespace program_options {
|
||||
@@ -2946,7 +2966,7 @@ std::string Application::FindHomePath(const char* sCall)
|
||||
binPath += L"bin";
|
||||
SetDllDirectoryW(binPath.c_str());
|
||||
|
||||
// https://stackoverflow.com/questions/5625884/conversion-of-stdwstring-to-qstring-throws-linker-error
|
||||
// https://stackoverflow.com/questions/5625884/conversion-of-stdwstring-to-qstring-throws-linker-error
|
||||
#ifdef _MSC_VER
|
||||
QString str = QString::fromUtf16(reinterpret_cast<const ushort *>(homePath.c_str()));
|
||||
#else
|
||||
|
||||
@@ -300,6 +300,8 @@ public:
|
||||
//@{
|
||||
/// Register an import filetype and a module name
|
||||
void addImportType(const char* Type, const char* ModuleName);
|
||||
/// Change the module name of a registered filetype
|
||||
void changeImportModule(const char* Type, const char* OldModuleName, const char* NewModuleName);
|
||||
/// Return a list of modules that support the given filetype.
|
||||
std::vector<std::string> getImportModules(const char* Type) const;
|
||||
/// Return a list of all modules.
|
||||
@@ -316,6 +318,8 @@ public:
|
||||
//@{
|
||||
/// Register an export filetype and a module name
|
||||
void addExportType(const char* Type, const char* ModuleName);
|
||||
/// Change the module name of a registered filetype
|
||||
void changeExportModule(const char* Type, const char* OldModuleName, const char* NewModuleName);
|
||||
/// Return a list of modules that support the given filetype.
|
||||
std::vector<std::string> getExportModules(const char* Type) const;
|
||||
/// Return a list of all modules.
|
||||
@@ -458,8 +462,10 @@ private:
|
||||
static PyObject* sSetConfig (PyObject *self,PyObject *args);
|
||||
static PyObject* sDumpConfig (PyObject *self,PyObject *args);
|
||||
static PyObject* sAddImportType (PyObject *self,PyObject *args);
|
||||
static PyObject* sChangeImportModule(PyObject *self,PyObject *args);
|
||||
static PyObject* sGetImportType (PyObject *self,PyObject *args);
|
||||
static PyObject* sAddExportType (PyObject *self,PyObject *args);
|
||||
static PyObject* sChangeExportModule(PyObject *self,PyObject *args);
|
||||
static PyObject* sGetExportType (PyObject *self,PyObject *args);
|
||||
static PyObject* sGetResourceDir (PyObject *self,PyObject *args);
|
||||
static PyObject* sGetUserAppDataDir (PyObject *self,PyObject *args);
|
||||
|
||||
@@ -72,6 +72,8 @@ PyMethodDef Application::Methods[] = {
|
||||
"Dump the configuration to the output."},
|
||||
{"addImportType", (PyCFunction) Application::sAddImportType, METH_VARARGS,
|
||||
"Register filetype for import"},
|
||||
{"changeImportModule", (PyCFunction) Application::sChangeImportModule, METH_VARARGS,
|
||||
"Change the import module name of a registered filetype"},
|
||||
{"getImportType", (PyCFunction) Application::sGetImportType, METH_VARARGS,
|
||||
"Get the name of the module that can import the filetype"},
|
||||
{"EndingAdd", (PyCFunction) Application::sAddImportType, METH_VARARGS, // deprecated
|
||||
@@ -80,6 +82,8 @@ PyMethodDef Application::Methods[] = {
|
||||
"deprecated -- use getImportType"},
|
||||
{"addExportType", (PyCFunction) Application::sAddExportType, METH_VARARGS,
|
||||
"Register filetype for export"},
|
||||
{"changeExportModule", (PyCFunction) Application::sChangeExportModule, METH_VARARGS,
|
||||
"Change the export module name of a registered filetype"},
|
||||
{"getExportType", (PyCFunction) Application::sGetExportType, METH_VARARGS,
|
||||
"Get the name of the module that can export the filetype"},
|
||||
{"getResourceDir", (PyCFunction) Application::sGetResourceDir, METH_VARARGS,
|
||||
@@ -526,6 +530,18 @@ PyObject* Application::sAddImportType(PyObject * /*self*/, PyObject *args)
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* Application::sChangeImportModule(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
char *key,*oldMod,*newMod;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sss", &key,&oldMod,&newMod))
|
||||
return nullptr;
|
||||
|
||||
GetApplication().changeImportModule(key,oldMod,newMod);
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* Application::sGetImportType(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
char* psKey=0;
|
||||
@@ -578,6 +594,18 @@ PyObject* Application::sAddExportType(PyObject * /*self*/, PyObject *args)
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* Application::sChangeExportModule(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
char *key,*oldMod,*newMod;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sss", &key,&oldMod,&newMod))
|
||||
return nullptr;
|
||||
|
||||
GetApplication().changeExportModule(key,oldMod,newMod);
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* Application::sGetExportType(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
char* psKey=0;
|
||||
|
||||
@@ -247,6 +247,12 @@ except ImportError:
|
||||
FreeCAD.Console.PrintError("\n\nSeems the python standard libs are not installed, bailing out!\n\n")
|
||||
raise
|
||||
|
||||
# Backward compatibility to Py2
|
||||
import sys
|
||||
if sys.version_info.major < 3:
|
||||
import time
|
||||
time.process_time = time.clock
|
||||
|
||||
class FCADLogger(object):
|
||||
'''Convenient class for tagged logging.
|
||||
|
||||
|
||||
@@ -71,493 +71,173 @@ class TestCcxTools(unittest.TestCase):
|
||||
def test_1_static_analysis(
|
||||
self
|
||||
):
|
||||
fcc_print("\n--------------- Start of FEM ccxtools static analysis test ---------------")
|
||||
|
||||
# set up the static analysis example
|
||||
# set up
|
||||
from femexamples import boxanalysis as box
|
||||
box.setup_static(self.active_doc, "ccxtools")
|
||||
|
||||
analysis = self.active_doc.Analysis
|
||||
solver_object = self.active_doc.CalculiXccxTools
|
||||
fcc_print("Analysis {}".format(type(analysis)))
|
||||
fcc_print("Analysis {}".format(analysis.TypeId))
|
||||
|
||||
static_analysis_dir = testtools.get_unit_test_tmp_dir(
|
||||
test_name = "ccxtools static analysis test"
|
||||
base_name = "cube_static"
|
||||
res_obj_name = "CCX_Results"
|
||||
analysis_dir = testtools.get_unit_test_tmp_dir(
|
||||
self.temp_dir,
|
||||
"FEM_ccx_static"
|
||||
)
|
||||
fea = ccxtools.FemToolsCcx(analysis, solver_object, test_mode=True)
|
||||
fea.update_objects()
|
||||
fcc_print("fea Analysis {}".format(type(fea.analysis)))
|
||||
fcc_print("fea Analysis {}".format(fea.analysis.TypeId))
|
||||
|
||||
fcc_print("Setting up working directory {}".format(static_analysis_dir))
|
||||
fea.setup_working_dir(static_analysis_dir)
|
||||
self.assertTrue(
|
||||
True if fea.working_dir == static_analysis_dir else False,
|
||||
"Setting working directory {} failed".format(static_analysis_dir)
|
||||
# test input file writing
|
||||
fea = self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
test_end=True,
|
||||
)
|
||||
|
||||
fcc_print("Checking FEM inp file prerequisites for static analysis...")
|
||||
error = fea.check_prerequisites()
|
||||
self.assertFalse(
|
||||
error,
|
||||
"ccxtools check_prerequisites returned error message: {}".format(error)
|
||||
# test result reading
|
||||
self.result_reading_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
fea=fea,
|
||||
res_obj_name=res_obj_name,
|
||||
)
|
||||
|
||||
static_base_name = "cube_static"
|
||||
inpfile_given = join(self.test_file_dir, (static_base_name + ".inp"))
|
||||
inpfile_totest = join(static_analysis_dir, (self.mesh_name + ".inp"))
|
||||
fcc_print("Checking FEM inp file write...")
|
||||
fcc_print("Writing {} for static analysis".format(inpfile_totest))
|
||||
error = fea.write_inp_file()
|
||||
self.assertFalse(
|
||||
error,
|
||||
"Writing failed"
|
||||
)
|
||||
|
||||
fcc_print("Comparing {} to {}".format(inpfile_given, inpfile_totest))
|
||||
ret = testtools.compare_inp_files(inpfile_given, inpfile_totest)
|
||||
self.assertFalse(
|
||||
ret,
|
||||
"ccxtools write_inp_file test failed.\n{}".format(ret)
|
||||
)
|
||||
|
||||
fcc_print(
|
||||
"Setting up working directory to {} in order to read simulated calculations"
|
||||
.format(self.test_file_dir)
|
||||
)
|
||||
fea.setup_working_dir(self.test_file_dir)
|
||||
fcc_print(fea.working_dir)
|
||||
fcc_print(self.test_file_dir)
|
||||
self.assertTrue(
|
||||
True if fea.working_dir == self.test_file_dir else False,
|
||||
"Setting working directory {} failed".format(self.test_file_dir)
|
||||
)
|
||||
|
||||
fcc_print("Setting base name to read test {}.frd file...".format("cube_static"))
|
||||
fea.set_base_name(static_base_name)
|
||||
self.assertTrue(
|
||||
True if fea.base_name == static_base_name else False,
|
||||
"Setting base name to {} failed".format(static_base_name)
|
||||
)
|
||||
|
||||
fcc_print("Setting inp file name to read test {}.frd file...".format("cube_static"))
|
||||
fea.set_inp_file_name()
|
||||
self.assertTrue(
|
||||
True if fea.inp_file_name == inpfile_given else False,
|
||||
"Setting inp file name to {} failed".format(inpfile_given)
|
||||
)
|
||||
|
||||
fcc_print("Checking FEM frd file read from static analysis...")
|
||||
fea.load_results()
|
||||
self.assertTrue(
|
||||
fea.results_present,
|
||||
"Cannot read results from {}.frd frd file".format(fea.base_name)
|
||||
)
|
||||
|
||||
fcc_print("Reading stats from result object for static analysis...")
|
||||
static_expected_values = join(self.test_file_dir, "cube_static_expected_values")
|
||||
ret = testtools.compare_stats(
|
||||
fea,
|
||||
static_expected_values,
|
||||
"CCX_Results"
|
||||
)
|
||||
self.assertFalse(
|
||||
ret,
|
||||
"Invalid results read from .frd file"
|
||||
)
|
||||
|
||||
static_save_fc_file = static_analysis_dir + static_base_name + ".FCStd"
|
||||
fcc_print("Save FreeCAD file for static analysis to {}...".format(static_save_fc_file))
|
||||
self.active_doc.saveAs(static_save_fc_file)
|
||||
|
||||
fcc_print("--------------- End of FEM ccxtools static analysis test -------------------")
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_2_static_multiple_material(
|
||||
self
|
||||
):
|
||||
fcc_print("\n--------------- Start of FEM ccxtools multiple material test -------------")
|
||||
|
||||
# set up the simple multimat example
|
||||
# set up
|
||||
from femexamples import material_multiple_twoboxes
|
||||
material_multiple_twoboxes.setup(self.active_doc, "ccxtools")
|
||||
|
||||
analysis = self.active_doc.Analysis
|
||||
solver_object = self.active_doc.CalculiXccxTools
|
||||
|
||||
static_multiplemat_dir = testtools.get_unit_test_tmp_dir(
|
||||
test_name = "multiple material test"
|
||||
base_name = "multimat"
|
||||
analysis_dir = testtools.get_unit_test_tmp_dir(
|
||||
self.temp_dir,
|
||||
"FEM_ccx_multimat/"
|
||||
)
|
||||
fea = ccxtools.FemToolsCcx(analysis, solver_object, test_mode=True)
|
||||
fea.update_objects()
|
||||
fea.setup_working_dir(static_multiplemat_dir)
|
||||
|
||||
fcc_print("Checking FEM inp file prerequisites for ccxtools multimat analysis...")
|
||||
error = fea.check_prerequisites()
|
||||
self.assertFalse(
|
||||
error,
|
||||
"ccxtools check_prerequisites returned error message: {}".format(error)
|
||||
"FEM_ccx_multimat"
|
||||
)
|
||||
|
||||
static_base_name = "multimat"
|
||||
inpfile_given = join(self.test_file_dir, (static_base_name + ".inp"))
|
||||
inpfile_totest = join(static_multiplemat_dir, (self.mesh_name + ".inp"))
|
||||
fcc_print("Checking FEM inp file write...")
|
||||
fcc_print("Writing {} for static multiple material".format(inpfile_totest))
|
||||
error = fea.write_inp_file()
|
||||
self.assertFalse(
|
||||
error,
|
||||
"Writing failed"
|
||||
# test input file writing
|
||||
self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
)
|
||||
|
||||
fcc_print("Comparing {} to {}".format(inpfile_given, inpfile_totest))
|
||||
ret = testtools.compare_inp_files(inpfile_given, inpfile_totest)
|
||||
self.assertFalse(
|
||||
ret,
|
||||
"ccxtools write_inp_file test failed.\n{}".format(ret)
|
||||
)
|
||||
|
||||
static_save_fc_file = static_multiplemat_dir + static_base_name + ".FCStd"
|
||||
fcc_print("Save FreeCAD file for static analysis to {}...".format(static_save_fc_file))
|
||||
self.active_doc.saveAs(static_save_fc_file)
|
||||
|
||||
fcc_print("--------------- End of FEM ccxtools multiple material test -----------------")
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_3_freq_analysis(
|
||||
self
|
||||
):
|
||||
fcc_print("\n--------------- Start of FEM ccxtools frequency analysis test ------------")
|
||||
|
||||
# set up the static analysis example
|
||||
# set up
|
||||
from femexamples import boxanalysis as box
|
||||
box.setup_frequency(self.active_doc, "ccxtools")
|
||||
|
||||
analysis = self.active_doc.Analysis
|
||||
solver_object = self.active_doc.CalculiXccxTools
|
||||
|
||||
frequency_analysis_dir = testtools.get_unit_test_tmp_dir(
|
||||
test_name = "frequency analysis test"
|
||||
base_name = "cube_frequency"
|
||||
res_obj_name = "CCX_Mode1_Results"
|
||||
analysis_dir = testtools.get_unit_test_tmp_dir(
|
||||
self.temp_dir,
|
||||
"FEM_ccx_frequency"
|
||||
)
|
||||
fea = ccxtools.FemToolsCcx(analysis, solver_object, test_mode=True)
|
||||
fea.update_objects()
|
||||
|
||||
fcc_print("Setting up working directory {}".format(frequency_analysis_dir))
|
||||
fea.setup_working_dir(frequency_analysis_dir)
|
||||
self.assertTrue(
|
||||
True if fea.working_dir == frequency_analysis_dir else False,
|
||||
"Setting working directory {} failed".format(frequency_analysis_dir)
|
||||
# test input file writing
|
||||
fea = self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
test_end=True,
|
||||
)
|
||||
|
||||
fcc_print("Checking FEM inp file prerequisites for frequency analysis...")
|
||||
error = fea.check_prerequisites()
|
||||
self.assertFalse(
|
||||
error,
|
||||
"ccxtools check_prerequisites returned error message: {}".format(error)
|
||||
# test result reading
|
||||
self.result_reading_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
fea=fea,
|
||||
res_obj_name=res_obj_name,
|
||||
)
|
||||
|
||||
frequency_base_name = "cube_frequency"
|
||||
inpfile_given = join(self.test_file_dir, (frequency_base_name + ".inp"))
|
||||
inpfile_totest = join(frequency_analysis_dir, (self.mesh_name + ".inp"))
|
||||
fcc_print("Checking FEM inp file write...")
|
||||
fcc_print("Writing {} for frequency analysis".format(inpfile_totest))
|
||||
error = fea.write_inp_file()
|
||||
self.assertFalse(
|
||||
error,
|
||||
"Writing failed"
|
||||
)
|
||||
|
||||
fcc_print("Comparing {} to {}".format(inpfile_given, inpfile_totest))
|
||||
ret = testtools.compare_inp_files(inpfile_given, inpfile_totest)
|
||||
self.assertFalse(
|
||||
ret,
|
||||
"ccxtools write_inp_file test failed.\n{}".format(ret)
|
||||
)
|
||||
|
||||
fcc_print(
|
||||
"Setting up working directory to {} in order to read simulated calculations".
|
||||
format(self.test_file_dir)
|
||||
)
|
||||
fea.setup_working_dir(self.test_file_dir)
|
||||
self.assertTrue(
|
||||
True if fea.working_dir == self.test_file_dir else False,
|
||||
"Setting working directory {} failed".format(self.test_file_dir)
|
||||
)
|
||||
|
||||
fcc_print("Setting base name to read test {}.frd file...".format(frequency_base_name))
|
||||
fea.set_base_name(frequency_base_name)
|
||||
self.assertTrue(
|
||||
True if fea.base_name == frequency_base_name else False,
|
||||
"Setting base name to {} failed".format(frequency_base_name)
|
||||
)
|
||||
|
||||
fcc_print("Setting inp file name to read test {}.frd file...".format("cube_frequency"))
|
||||
fea.set_inp_file_name()
|
||||
self.assertTrue(
|
||||
True if fea.inp_file_name == inpfile_given else False,
|
||||
"Setting inp file name to {} failed".format(inpfile_given)
|
||||
)
|
||||
|
||||
fcc_print("Checking FEM frd file read from frequency analysis...")
|
||||
fea.load_results()
|
||||
self.assertTrue(
|
||||
fea.results_present,
|
||||
"Cannot read results from {}.frd frd file".format(fea.base_name)
|
||||
)
|
||||
|
||||
fcc_print("Reading stats from result object for frequency analysis...")
|
||||
frequency_expected_values = join(self.test_file_dir, "cube_frequency_expected_values")
|
||||
ret = testtools.compare_stats(
|
||||
fea,
|
||||
frequency_expected_values,
|
||||
"CCX_Mode1_Results"
|
||||
)
|
||||
self.assertFalse(
|
||||
ret,
|
||||
"Invalid results read from .frd file"
|
||||
)
|
||||
|
||||
frequency_save_fc_file = frequency_analysis_dir + frequency_base_name + ".FCStd"
|
||||
fcc_print(
|
||||
"Save FreeCAD file for frequency analysis to {}..."
|
||||
.format(frequency_save_fc_file)
|
||||
)
|
||||
self.active_doc.saveAs(frequency_save_fc_file)
|
||||
|
||||
fcc_print("--------------- End of FEM ccxtools frequency analysis test ----------------")
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_4_thermomech_analysis(
|
||||
self
|
||||
):
|
||||
|
||||
fcc_print("\n--------------- Start of FEM ccxtools thermomechanical analysis test -----")
|
||||
|
||||
# set up the thermomech example
|
||||
# set up
|
||||
from femexamples.thermomech_spine import setup as thermomech
|
||||
thermomech(self.active_doc, "ccxtools")
|
||||
|
||||
analysis = self.active_doc.Analysis
|
||||
|
||||
thermomech_analysis_dir = testtools.get_unit_test_tmp_dir(
|
||||
test_name = "thermomechanical analysis test"
|
||||
base_name = "spine_thermomech"
|
||||
res_obj_name = "CCX_Results"
|
||||
analysis_dir = testtools.get_unit_test_tmp_dir(
|
||||
self.temp_dir,
|
||||
"FEM_ccx_thermomech"
|
||||
)
|
||||
fea = ccxtools.FemToolsCcx(analysis, test_mode=True)
|
||||
fea.update_objects()
|
||||
|
||||
fcc_print("Setting up working directory {}".format(thermomech_analysis_dir))
|
||||
fea.setup_working_dir(thermomech_analysis_dir)
|
||||
self.assertTrue(
|
||||
True if fea.working_dir == thermomech_analysis_dir else False,
|
||||
"Setting working directory {} failed".format(thermomech_analysis_dir)
|
||||
# test input file writing
|
||||
fea = self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
test_end=True,
|
||||
)
|
||||
|
||||
fcc_print("Checking FEM inp file prerequisites for thermo-mechanical analysis...")
|
||||
error = fea.check_prerequisites()
|
||||
self.assertFalse(
|
||||
error,
|
||||
"ccxtools check_prerequisites returned error message: {}".format(error)
|
||||
# test result reading
|
||||
self.result_reading_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
fea=fea,
|
||||
res_obj_name=res_obj_name,
|
||||
)
|
||||
|
||||
thermomech_base_name = "spine_thermomech"
|
||||
inpfile_given = join(self.test_file_dir, (thermomech_base_name + ".inp"))
|
||||
inpfile_totest = join(thermomech_analysis_dir, (self.mesh_name + ".inp"))
|
||||
fcc_print("Checking FEM inp file write...")
|
||||
fcc_print("Writing {} for thermomech analysis".format(inpfile_totest))
|
||||
error = fea.write_inp_file()
|
||||
self.assertFalse(
|
||||
error,
|
||||
"Writing failed"
|
||||
)
|
||||
|
||||
fcc_print("Comparing {} to {}".format(inpfile_given, inpfile_totest))
|
||||
ret = testtools.compare_inp_files(inpfile_given, inpfile_totest)
|
||||
self.assertFalse(
|
||||
ret,
|
||||
"ccxtools write_inp_file test failed.\n{}".format(ret)
|
||||
)
|
||||
|
||||
fcc_print(
|
||||
"Setting up working directory to {} in order to read simulated calculations"
|
||||
.format(self.test_file_dir)
|
||||
)
|
||||
fea.setup_working_dir(self.test_file_dir)
|
||||
self.assertTrue(
|
||||
True if fea.working_dir == self.test_file_dir else False,
|
||||
"Setting working directory {} failed".format(self.test_file_dir)
|
||||
)
|
||||
|
||||
fcc_print("Setting base name to read test {}.frd file...".format("spine_thermomech"))
|
||||
fea.set_base_name(thermomech_base_name)
|
||||
self.assertTrue(
|
||||
True if fea.base_name == thermomech_base_name else False,
|
||||
"Setting base name to {} failed".format(thermomech_base_name)
|
||||
)
|
||||
|
||||
fcc_print("Setting inp file name to read test {}.frd file...".format("spine_thermomech"))
|
||||
fea.set_inp_file_name()
|
||||
self.assertTrue(
|
||||
True if fea.inp_file_name == inpfile_given else False,
|
||||
"Setting inp file name to {} failed".format(inpfile_given)
|
||||
)
|
||||
|
||||
fcc_print("Checking FEM frd file read from thermomech analysis...")
|
||||
fea.load_results()
|
||||
self.assertTrue(
|
||||
fea.results_present,
|
||||
"Cannot read results from {}.frd frd file".format(fea.base_name)
|
||||
)
|
||||
|
||||
fcc_print("Reading stats from result object for thermomech analysis...")
|
||||
thermomech_expected_values = join(
|
||||
self.test_file_dir,
|
||||
"spine_thermomech_expected_values"
|
||||
)
|
||||
ret = testtools.compare_stats(
|
||||
fea,
|
||||
thermomech_expected_values,
|
||||
"CCX_Results"
|
||||
)
|
||||
self.assertFalse(
|
||||
ret,
|
||||
"Invalid results read from .frd file"
|
||||
)
|
||||
|
||||
thermomech_save_fc_file = thermomech_analysis_dir + thermomech_base_name + ".FCStd"
|
||||
fcc_print(
|
||||
"Save FreeCAD file for thermomech analysis to {}..."
|
||||
.format(thermomech_save_fc_file)
|
||||
)
|
||||
self.active_doc.saveAs(thermomech_save_fc_file)
|
||||
|
||||
fcc_print("--------------- End of FEM ccxtools thermomechanical analysis test ---------")
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_5_Flow1D_thermomech_analysis(
|
||||
self
|
||||
):
|
||||
fcc_print("\n--------------- Start of FEM ccxtools Flow1D analysis test ---------------")
|
||||
|
||||
# set up the thermomech flow1d example
|
||||
# set up
|
||||
from femexamples.thermomech_flow1d import setup as flow1d
|
||||
flow1d(self.active_doc, "ccxtools")
|
||||
analysis = self.active_doc.Analysis
|
||||
|
||||
Flow1D_thermomech_analysis_dir = testtools.get_unit_test_tmp_dir(
|
||||
test_name = "Flow1D analysis test"
|
||||
base_name = "Flow1D_thermomech"
|
||||
res_obj_name = "CCX_Time1_0_Results"
|
||||
analysis_dir = testtools.get_unit_test_tmp_dir(
|
||||
self.temp_dir,
|
||||
"FEM_ccx_Flow1D_thermomech"
|
||||
)
|
||||
fea = ccxtools.FemToolsCcx(analysis, test_mode=True)
|
||||
fea.update_objects()
|
||||
|
||||
fcc_print("Setting up working directory {}".format(Flow1D_thermomech_analysis_dir))
|
||||
fea.setup_working_dir(Flow1D_thermomech_analysis_dir)
|
||||
self.assertTrue(
|
||||
True if fea.working_dir == Flow1D_thermomech_analysis_dir else False,
|
||||
"Setting working directory {} failed".format(Flow1D_thermomech_analysis_dir)
|
||||
# test input file writing
|
||||
fea = self.input_file_writing_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
test_end=True,
|
||||
)
|
||||
|
||||
fcc_print("Checking FEM inp file prerequisites for thermo-mechanical analysis...")
|
||||
error = fea.check_prerequisites()
|
||||
self.assertFalse(
|
||||
error,
|
||||
"ccxtools check_prerequisites returned error message: {}".format(error)
|
||||
# test result reading
|
||||
self.result_reading_test(
|
||||
test_name=test_name,
|
||||
base_name=base_name,
|
||||
analysis_dir=analysis_dir,
|
||||
fea=fea,
|
||||
res_obj_name=res_obj_name,
|
||||
)
|
||||
|
||||
Flow1D_thermomech_base_name = "Flow1D_thermomech"
|
||||
inpfile_given = join(self.test_file_dir, (Flow1D_thermomech_base_name + ".inp"))
|
||||
inpfile_totest = join(Flow1D_thermomech_analysis_dir, (self.mesh_name + ".inp"))
|
||||
fcc_print("Checking FEM inp file write...")
|
||||
fcc_print("Writing {} for thermomech analysis".format(inpfile_totest))
|
||||
error = fea.write_inp_file()
|
||||
self.assertFalse(
|
||||
error,
|
||||
"Writing failed"
|
||||
)
|
||||
|
||||
fcc_print("Comparing {} to {}".format(inpfile_given, inpfile_totest))
|
||||
ret = testtools.compare_inp_files(inpfile_given, inpfile_totest)
|
||||
self.assertFalse(
|
||||
ret,
|
||||
"ccxtools write_inp_file test failed.\n{}".format(ret)
|
||||
)
|
||||
|
||||
fcc_print(
|
||||
"Setting up working directory to {} in order to read simulated calculations"
|
||||
.format(self.test_file_dir)
|
||||
)
|
||||
fea.setup_working_dir(self.test_file_dir)
|
||||
self.assertTrue(
|
||||
True if fea.working_dir == self.test_file_dir else False,
|
||||
"Setting working directory {} failed".format(self.test_file_dir)
|
||||
)
|
||||
|
||||
fcc_print("Setting base name to read test {}.frd file...".format("Flow1D_thermomech"))
|
||||
fea.set_base_name(Flow1D_thermomech_base_name)
|
||||
self.assertTrue(
|
||||
True if fea.base_name == Flow1D_thermomech_base_name else False,
|
||||
"Setting base name to {} failed".format(Flow1D_thermomech_base_name)
|
||||
)
|
||||
|
||||
fcc_print("Setting inp file name to read test {}.frd file...".format("Flow1D_thermomech"))
|
||||
fea.set_inp_file_name()
|
||||
self.assertTrue(
|
||||
True if fea.inp_file_name == inpfile_given else False,
|
||||
"Setting inp file name to {} failed".format(inpfile_given)
|
||||
)
|
||||
|
||||
fcc_print("Checking FEM frd file read from Flow1D thermomech analysis...")
|
||||
fea.load_results()
|
||||
self.assertTrue(
|
||||
fea.results_present,
|
||||
"Cannot read results from {}.frd frd file".format(fea.base_name)
|
||||
)
|
||||
|
||||
fcc_print("Reading stats from result object for Flow1D thermomech analysis...")
|
||||
Flow1D_thermomech_expected_values = join(
|
||||
self.test_file_dir,
|
||||
"Flow1D_thermomech_expected_values"
|
||||
)
|
||||
ret = testtools.compare_stats(
|
||||
fea,
|
||||
Flow1D_thermomech_expected_values,
|
||||
"CCX_Time1_0_Results"
|
||||
)
|
||||
self.assertFalse(
|
||||
ret,
|
||||
"Invalid results read from .frd file"
|
||||
)
|
||||
|
||||
Flow1D_thermomech_save_fc_file = join(
|
||||
Flow1D_thermomech_analysis_dir,
|
||||
(Flow1D_thermomech_base_name + ".FCStd")
|
||||
)
|
||||
fcc_print(
|
||||
"Save FreeCAD file for thermomech analysis to {}..."
|
||||
.format(Flow1D_thermomech_save_fc_file)
|
||||
)
|
||||
self.active_doc.saveAs(Flow1D_thermomech_save_fc_file)
|
||||
|
||||
fcc_print("--------------- End of FEM ccxtools Flow1D analysis test -------------------")
|
||||
|
||||
# ********************************************************************************************
|
||||
def test_6_contact_shell_shell(
|
||||
self
|
||||
):
|
||||
# set up the example
|
||||
# set up
|
||||
from femexamples import contact_shell_shell as shellcontact
|
||||
shellcontact.setup(self.active_doc, "ccxtools")
|
||||
analysis_dir = testtools.get_unit_test_tmp_dir(
|
||||
self.temp_dir,
|
||||
"FEM_ccx_contact_shell_shell",
|
||||
)
|
||||
|
||||
# test input file writing
|
||||
self.input_file_writing_test(
|
||||
test_name="contact shell shell analysis test",
|
||||
base_name="contact_shell_shell",
|
||||
test_dir="FEM_ccx_contact_shell_shell",
|
||||
analysis_dir=analysis_dir,
|
||||
)
|
||||
|
||||
# ********************************************************************************************
|
||||
@@ -565,7 +245,8 @@ class TestCcxTools(unittest.TestCase):
|
||||
self,
|
||||
test_name,
|
||||
base_name,
|
||||
test_dir
|
||||
analysis_dir,
|
||||
test_end=False,
|
||||
):
|
||||
fcc_print(
|
||||
"\n--------------- "
|
||||
@@ -576,10 +257,6 @@ class TestCcxTools(unittest.TestCase):
|
||||
|
||||
analysis = self.active_doc.Analysis
|
||||
solver_object = self.active_doc.CalculiXccxTools
|
||||
analysis_dir = testtools.get_unit_test_tmp_dir(
|
||||
self.temp_dir,
|
||||
test_dir,
|
||||
)
|
||||
fea = ccxtools.FemToolsCcx(analysis, solver_object, test_mode=True)
|
||||
fea.update_objects()
|
||||
|
||||
@@ -614,12 +291,16 @@ class TestCcxTools(unittest.TestCase):
|
||||
"ccxtools write_inp_file test failed.\n{}".format(ret)
|
||||
)
|
||||
|
||||
static_save_fc_file = analysis_dir + base_name + ".FCStd"
|
||||
if test_end is True:
|
||||
# do not save and print End of tests
|
||||
return fea
|
||||
|
||||
save_fc_file = analysis_dir + base_name + ".FCStd"
|
||||
fcc_print(
|
||||
"Save FreeCAD file for {} to {}..."
|
||||
.format(test_name, static_save_fc_file)
|
||||
.format(test_name, save_fc_file)
|
||||
)
|
||||
self.active_doc.saveAs(static_save_fc_file)
|
||||
self.active_doc.saveAs(save_fc_file)
|
||||
|
||||
fcc_print(
|
||||
"\n--------------- "
|
||||
@@ -628,6 +309,81 @@ class TestCcxTools(unittest.TestCase):
|
||||
.format(test_name)
|
||||
)
|
||||
|
||||
# ********************************************************************************************
|
||||
def result_reading_test(
|
||||
self,
|
||||
test_name,
|
||||
base_name,
|
||||
analysis_dir,
|
||||
fea,
|
||||
res_obj_name,
|
||||
):
|
||||
inpfile_given = join(self.test_file_dir, (base_name + ".inp"))
|
||||
|
||||
fcc_print(
|
||||
"Setting up working directory to {} in order to read simulated calculations"
|
||||
.format(self.test_file_dir)
|
||||
)
|
||||
fea.setup_working_dir(self.test_file_dir)
|
||||
self.assertTrue(
|
||||
True if fea.working_dir == self.test_file_dir else False,
|
||||
"Setting working directory {} failed".format(self.test_file_dir)
|
||||
)
|
||||
|
||||
fcc_print(
|
||||
"Setting base name to read test {}.frd file..."
|
||||
.format(base_name)
|
||||
)
|
||||
fea.set_base_name(base_name)
|
||||
self.assertTrue(
|
||||
True if fea.base_name == base_name else False,
|
||||
"Setting base name to {} failed".format(base_name)
|
||||
)
|
||||
|
||||
fcc_print(
|
||||
"Setting inp file name to read test {}.frd file..."
|
||||
.format(base_name)
|
||||
)
|
||||
fea.set_inp_file_name()
|
||||
self.assertTrue(
|
||||
True if fea.inp_file_name == inpfile_given else False,
|
||||
"Setting inp file name to {} failed".format(inpfile_given)
|
||||
)
|
||||
|
||||
fcc_print("Checking FEM frd file read from {}...".format(test_name))
|
||||
fea.load_results()
|
||||
self.assertTrue(
|
||||
fea.results_present,
|
||||
"Cannot read results from {}.frd frd file".format(fea.base_name)
|
||||
)
|
||||
|
||||
fcc_print("Reading stats from result object for {}...".format(test_name))
|
||||
expected_values = join(
|
||||
self.test_file_dir,
|
||||
base_name + "_expected_values"
|
||||
)
|
||||
ret = testtools.compare_stats(
|
||||
fea,
|
||||
expected_values,
|
||||
res_obj_name
|
||||
)
|
||||
self.assertFalse(
|
||||
ret,
|
||||
"Invalid results read from .frd file"
|
||||
)
|
||||
|
||||
save_fc_file = join(
|
||||
analysis_dir,
|
||||
(base_name + ".FCStd")
|
||||
)
|
||||
fcc_print(
|
||||
"Save FreeCAD file for {} to {}..."
|
||||
.format(test_name, save_fc_file)
|
||||
)
|
||||
self.active_doc.saveAs(save_fc_file)
|
||||
|
||||
fcc_print("--------------- End of {} -------------------".format(test_name))
|
||||
|
||||
# ********************************************************************************************
|
||||
def tearDown(
|
||||
self
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
#***************************************************************************/
|
||||
|
||||
|
||||
# Registered in Part's Init.py file
|
||||
FreeCAD.changeImportModule("STEP with colors (*.step *.stp)","Import","ImportGui")
|
||||
FreeCAD.changeExportModule("STEP with colors (*.step *.stp)","Import","ImportGui")
|
||||
|
||||
"""
|
||||
class ImportWorkbench ( Workbench ):
|
||||
"Import workbench object"
|
||||
|
||||
@@ -32,7 +32,7 @@ FreeCAD.addImportType("BREP format (*.brep *.brp)","Part")
|
||||
FreeCAD.addExportType("BREP format (*.brep *.brp)","Part")
|
||||
FreeCAD.addImportType("IGES format (*.iges *.igs)","Part")
|
||||
FreeCAD.addExportType("IGES format (*.iges *.igs)","Part")
|
||||
FreeCAD.addImportType("STEP with colors (*.step *.stp)","ImportGui")
|
||||
FreeCAD.addExportType("STEP with colors (*.step *.stp)","ImportGui")
|
||||
FreeCAD.addImportType("STEP with colors (*.step *.stp)","Import")
|
||||
FreeCAD.addExportType("STEP with colors (*.step *.stp)","Import")
|
||||
|
||||
FreeCAD.__unit_test__ += [ "TestPartApp" ]
|
||||
|
||||
@@ -87,14 +87,14 @@ void DrawWeldSymbol::onSettingDocument()
|
||||
return;
|
||||
}
|
||||
|
||||
std::string tileName1 = doc->getUniqueObjectName("DrawTileWeld");
|
||||
std::string tileName1 = doc->getUniqueObjectName("TileWeld");
|
||||
auto tile1Obj( doc->addObject( "TechDraw::DrawTileWeld", tileName1.c_str() ) );
|
||||
DrawTileWeld* tile1 = dynamic_cast<DrawTileWeld*>(tile1Obj);
|
||||
if (tile1 != nullptr) {
|
||||
tile1->TileParent.setValue(this);
|
||||
}
|
||||
|
||||
std::string tileName2 = doc->getUniqueObjectName("DrawTileWeld");
|
||||
std::string tileName2 = doc->getUniqueObjectName("TileWeld");
|
||||
auto tile2Obj( doc->addObject( "TechDraw::DrawTileWeld", tileName2.c_str() ) );
|
||||
DrawTileWeld* tile2 = dynamic_cast<DrawTileWeld*>(tile2Obj);
|
||||
if (tile2 != nullptr) {
|
||||
|
||||
@@ -116,7 +116,7 @@ TechDraw::DrawViewSymbol* TaskActiveView::createActiveView(void)
|
||||
{
|
||||
// Base::Console().Message("TAV::createActiveView()\n");
|
||||
|
||||
std::string symbolName = m_pageFeat->getDocument()->getUniqueObjectName("DrawActiveView");
|
||||
std::string symbolName = m_pageFeat->getDocument()->getUniqueObjectName("ActiveView");
|
||||
std::string symbolType = "TechDraw::DrawViewSymbol";
|
||||
|
||||
std::string pageName = m_pageFeat->getNameInDocument();
|
||||
|
||||
@@ -261,7 +261,7 @@ void TaskLeaderLine::setUiEdit()
|
||||
void TaskLeaderLine::createLeaderFeature(std::vector<Base::Vector3d> converted)
|
||||
{
|
||||
// Base::Console().Message("TTL::createLeaderFeature()\n");
|
||||
m_leaderName = m_basePage->getDocument()->getUniqueObjectName("DrawLeaderLine");
|
||||
m_leaderName = m_basePage->getDocument()->getUniqueObjectName("LeaderLine");
|
||||
m_leaderType = "TechDraw::DrawLeaderLine";
|
||||
|
||||
std::string PageName = m_basePage->getNameInDocument();
|
||||
|
||||
@@ -281,7 +281,7 @@ void TaskRichAnno::onEditorExit(void)
|
||||
void TaskRichAnno::createAnnoFeature()
|
||||
{
|
||||
// Base::Console().Message("TRA::createAnnoFeature()");
|
||||
std::string annoName = m_basePage->getDocument()->getUniqueObjectName("DrawRichAnno");
|
||||
std::string annoName = m_basePage->getDocument()->getUniqueObjectName("RichTextAnnotation");
|
||||
std::string annoType = "TechDraw::DrawRichAnno";
|
||||
|
||||
std::string PageName = m_basePage->getNameInDocument();
|
||||
|
||||
@@ -351,7 +351,7 @@ TechDraw::DrawViewSection* TaskSectionView::createSectionView(void)
|
||||
Gui::Command::openCommand("Create SectionView");
|
||||
TechDraw::DrawViewSection* newSection = nullptr;
|
||||
if (m_section == nullptr) {
|
||||
sectionName = m_base->getDocument()->getUniqueObjectName("DrawViewSection");
|
||||
sectionName = m_base->getDocument()->getUniqueObjectName("SectionView");
|
||||
std::string sectionType = "TechDraw::DrawViewSection";
|
||||
|
||||
TechDraw::DrawPage* page = m_base->findParentPage();
|
||||
|
||||
@@ -434,7 +434,7 @@ TechDraw::DrawWeldSymbol* TaskWeldingSymbol::createWeldingSymbol(void)
|
||||
{
|
||||
// Base::Console().Message("TWS::createWeldingSymbol()\n");
|
||||
|
||||
std::string symbolName = m_leadFeat->getDocument()->getUniqueObjectName("DrawWeldSymbol");
|
||||
std::string symbolName = m_leadFeat->getDocument()->getUniqueObjectName("WeldSymbol");
|
||||
std::string symbolType = "TechDraw::DrawWeldSymbol";
|
||||
|
||||
TechDraw::DrawPage* page = m_leadFeat->findParentPage();
|
||||
|
||||
Reference in New Issue
Block a user