diff --git a/.gitignore b/.gitignore index 41d29b1..2d5c3f3 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,6 @@ assembly.asmt build cmake-build-debug .idea -temp/ \ No newline at end of file +temp/ +/testapp/draggingBackhoe.log +/testapp/runPreDragBackhoe.asmt diff --git a/CMakeLists.txt b/CMakeLists.txt index 6059710..7b7825e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,9 @@ project(OndselSolver VERSION 1.0.1 DESCRIPTION "Assembly Constraints and Multibo set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) +option(ONDSELSOLVER_BUILD_TESTS "Set to ON to build the Google Test-based C++ test suite." OFF) +option(ONDSELSOLVER_BUILD_EXE "Set to ON to build the standalone OndselSolver executable." OFF) + include(GNUInstallDirs) if( UNIX ) @@ -17,9 +20,14 @@ ENDIF () add_compile_definitions(TEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/testapp") add_subdirectory(OndselSolver) -add_subdirectory(OndselSolverMain) -include(CTest) -enable_testing() -add_subdirectory(tests) -target_compile_definitions(test_run PUBLIC TEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/testapp") -set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OndselSolverMain PROPERTY VS_STARTUP_PROJECT OndselSolverMain) \ No newline at end of file +if(ONDSELSOLVER_BUILD_EXE) + add_subdirectory(OndselSolverMain) + set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OndselSolverMain PROPERTY VS_STARTUP_PROJECT OndselSolverMain) +endif() + +if(ONDSELSOLVER_BUILD_TESTS) + include(CTest) + enable_testing() + add_subdirectory(tests) + target_compile_definitions(test_run PUBLIC TEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/testapp") +endif() diff --git a/OndselSolver/ASMTAssembly.cpp b/OndselSolver/ASMTAssembly.cpp index 1517862..9daf755 100644 --- a/OndselSolver/ASMTAssembly.cpp +++ b/OndselSolver/ASMTAssembly.cpp @@ -61,6 +61,7 @@ #include "ASMTLimit.h" #include "ASMTRotationLimit.h" #include "ASMTTranslationLimit.h" +#include "ExternalSystem.h" #include using namespace MbD; @@ -68,6 +69,7 @@ using namespace MbD; MbD::ASMTAssembly::ASMTAssembly() : ASMTSpatialContainer() { + externalSystem = std::make_shared(); times = std::make_shared>(); } @@ -1305,6 +1307,11 @@ void MbD::ASMTAssembly::storeOnLevel(std::ofstream& os, size_t level) storeOnTimeSeries(os); } +size_t MbD::ASMTAssembly::numberOfFrames() +{ + return times->size(); +} + void MbD::ASMTAssembly::solve() { auto simulationParameters = CREATE::With(); @@ -1757,3 +1764,20 @@ void MbD::ASMTAssembly::setDebug(bool todebug) { debug = todebug; } + +void MbD::ASMTAssembly::updateForFrame(size_t index) +{ + ASMTSpatialContainer::updateForFrame(index); + for (auto& part : *parts) { + part->updateForFrame(index); + } + //for (auto& joint : *joints) { + // joint->updateForFrame(index); + //} + //for (auto& motion : *motions) { + // motion->updateForFrame(index); + //} + //for (auto& forceTorque : *forcesTorques) { + // forceTorque->updateForFrame(index); + //} +} diff --git a/OndselSolver/ASMTAssembly.h b/OndselSolver/ASMTAssembly.h index 4179565..e9cbc6e 100644 --- a/OndselSolver/ASMTAssembly.h +++ b/OndselSolver/ASMTAssembly.h @@ -27,6 +27,7 @@ namespace MbD { class ASMTLimit; class SystemSolver; class ASMTItemIJ; + class ExternalSystem; class ASMTAssembly : public ASMTSpatialContainer { @@ -91,6 +92,7 @@ namespace MbD { void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; void outputFile(const std::string& filename); void storeOnLevel(std::ofstream& os, size_t level) override; + size_t numberOfFrames(); /* This function performs a one shot solve of the assembly.*/ void solve(); @@ -133,6 +135,7 @@ namespace MbD { void storeOnTimeSeries(std::ofstream& os) override; void setFilename(const std::string& filename); void setDebug(bool todebug); + void updateForFrame(size_t index) override; std::string filename = ""; std::string notes = "(Text string: '' runs: (Core.RunArray runs: #() values: #()))"; @@ -151,6 +154,7 @@ namespace MbD { std::shared_ptr mbdUnits = std::make_shared(); std::shared_ptr mbdSystem; bool debug = false; + std::shared_ptr externalSystem; }; } diff --git a/OndselSolver/ASMTItem.cpp b/OndselSolver/ASMTItem.cpp index ffcb754..a18e7c9 100644 --- a/OndselSolver/ASMTItem.cpp +++ b/OndselSolver/ASMTItem.cpp @@ -191,6 +191,21 @@ void MbD::ASMTItem::createMbD(std::shared_ptr, std::shared_ptr) assert(false); } +void MbD::ASMTItem::updateForFrame(size_t index) +{ + assert(false); +} + +void MbD::ASMTItem::updateFromInitiallyAssembledState() +{ + assert(false); +} + +void MbD::ASMTItem::updateFromInputState() +{ + assert(false); +} + void MbD::ASMTItem::updateFromMbD() { assert(false); diff --git a/OndselSolver/ASMTItem.h b/OndselSolver/ASMTItem.h index b6551e5..41faf43 100644 --- a/OndselSolver/ASMTItem.h +++ b/OndselSolver/ASMTItem.h @@ -46,8 +46,11 @@ namespace MbD { void readDoublesInto(std::string str, std::string label, FRowDsptr& row); virtual void deleteMbD(); virtual void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits); - virtual void updateFromMbD(); - virtual void compareResults(AnalysisType type); + virtual void updateForFrame(size_t index); + virtual void updateFromInitiallyAssembledState(); + virtual void updateFromInputState(); + virtual void updateFromMbD(); + virtual void compareResults(AnalysisType type); virtual void outputResults(AnalysisType type); std::shared_ptr mbdUnits(); std::shared_ptr sptrConstant(double value); diff --git a/OndselSolver/ASMTSimulationParameters.cpp b/OndselSolver/ASMTSimulationParameters.cpp index 1815c76..3288583 100644 --- a/OndselSolver/ASMTSimulationParameters.cpp +++ b/OndselSolver/ASMTSimulationParameters.cpp @@ -78,6 +78,12 @@ void MbD::ASMTSimulationParameters::sethout(double h) void MbD::ASMTSimulationParameters::seterrorTol(double tol) { errorTol = tol; + errorTolPosKine = tol; + errorTolAccKine = tol; + corAbsTol = tol; + corRelTol = tol; + intAbsTol = tol; + intRelTol = tol; } void MbD::ASMTSimulationParameters::setmaxIter(size_t maxIter) diff --git a/OndselSolver/ASMTSpatialContainer.cpp b/OndselSolver/ASMTSpatialContainer.cpp index 75a1cbf..27dee14 100644 --- a/OndselSolver/ASMTSpatialContainer.cpp +++ b/OndselSolver/ASMTSpatialContainer.cpp @@ -360,6 +360,26 @@ ASMTSpatialContainer* MbD::ASMTSpatialContainer::partOrAssembly() return this; } +void MbD::ASMTSpatialContainer::updateForFrame(size_t index) +{ + position3D = getPosition3D(index); + rotationMatrix = getRotationMatrix(index); + velocity3D = getVelocity3D(index); + omega3D = getOmega3D(index); + acceleration3D = getAcceleration3D(index); + alpha3D = getAlpha3D(index); +} + +void MbD::ASMTSpatialContainer::updateFromInitiallyAssembledState() +{ + +} + +void MbD::ASMTSpatialContainer::updateFromInputState() +{ + +} + void MbD::ASMTSpatialContainer::updateFromMbD() { auto mbdUnts = mbdUnits(); @@ -372,6 +392,7 @@ void MbD::ASMTSpatialContainer::updateFromMbD() omega3D = omeOPO; auto aOcmO = mbdPart->qXddot()->times(mbdUnts->acceleration); auto alpOPO = mbdPart->alpOpO()->times(mbdUnts->alpha); + alpha3D = alpOPO; auto& rPcmP = principalMassMarker->position3D; auto& aAPp = principalMassMarker->rotationMatrix; auto aAOP = aAOp->timesTransposeFullMatrix(aAPp); @@ -384,7 +405,8 @@ void MbD::ASMTSpatialContainer::updateFromMbD() auto vOPO = vOcmO->minusFullColumn(omeOPO->cross(rPcmO)); velocity3D = vOPO; auto aOPO = aOcmO->minusFullColumn(alpOPO->cross(rPcmO))->minusFullColumn(omeOPO->cross(omeOPO->cross(rPcmO))); - xs->push_back(rOPO->at(0)); + acceleration3D = aOPO; + xs->push_back(rOPO->at(0)); ys->push_back(rOPO->at(1)); zs->push_back(rOPO->at(2)); auto bryantAngles = aAOP->bryantAngles(); @@ -764,3 +786,21 @@ FColDsptr MbD::ASMTSpatialContainer::getOmega3D(size_t i) vec3->atiput(2, omezs->at(i)); return vec3; } + +FColDsptr MbD::ASMTSpatialContainer::getAcceleration3D(size_t i) +{ + auto vec3 = std::make_shared>(3); + vec3->atiput(0, axs->at(i)); + vec3->atiput(1, ays->at(i)); + vec3->atiput(2, azs->at(i)); + return vec3; +} + +FColDsptr MbD::ASMTSpatialContainer::getAlpha3D(size_t i) +{ + auto vec3 = std::make_shared>(3); + vec3->atiput(0, alpxs->at(i)); + vec3->atiput(1, alpys->at(i)); + vec3->atiput(2, alpzs->at(i)); + return vec3; +} diff --git a/OndselSolver/ASMTSpatialContainer.h b/OndselSolver/ASMTSpatialContainer.h index b0452ad..01b7e64 100644 --- a/OndselSolver/ASMTSpatialContainer.h +++ b/OndselSolver/ASMTSpatialContainer.h @@ -72,7 +72,10 @@ namespace MbD { virtual FColDsptr vOcmO(); virtual FColDsptr omeOpO(); ASMTSpatialContainer* partOrAssembly() override; - void updateFromMbD() override; + void updateForFrame(size_t index) override; + void updateFromInitiallyAssembledState() override; + void updateFromInputState() override; + void updateFromMbD() override; void compareResults(AnalysisType type) override; void outputResults(AnalysisType type) override; void addRefPoint(std::shared_ptr refPoint); @@ -92,12 +95,16 @@ namespace MbD { void storeOnLevelRefCurves(std::ofstream& os, size_t level); void storeOnLevelRefSurfaces(std::ofstream& os, size_t level); void storeOnTimeSeries(std::ofstream& os) override; - FColDsptr getVelocity3D(size_t i); - FColDsptr getOmega3D(size_t i); + FColDsptr getVelocity3D(size_t i); + FColDsptr getOmega3D(size_t i); + FColDsptr getAcceleration3D(size_t i); + FColDsptr getAlpha3D(size_t i); FColDsptr velocity3D = std::make_shared>(3); - FColDsptr omega3D = std::make_shared>(3); - std::shared_ptr>> refPoints; + FColDsptr omega3D = std::make_shared>(3); + FColDsptr acceleration3D = std::make_shared>(3); + FColDsptr alpha3D = std::make_shared>(3); + std::shared_ptr>> refPoints; std::shared_ptr>> refCurves; std::shared_ptr>> refSurfaces; FRowDsptr vxs, vys, vzs, omexs, omeys, omezs; diff --git a/OndselSolver/ASMTTranslationalMotion.cpp b/OndselSolver/ASMTTranslationalMotion.cpp index 9555079..679712d 100644 --- a/OndselSolver/ASMTTranslationalMotion.cpp +++ b/OndselSolver/ASMTTranslationalMotion.cpp @@ -27,9 +27,15 @@ void MbD::ASMTTranslationalMotion::parseASMT(std::vector& lines) void MbD::ASMTTranslationalMotion::initMarkers() { - auto jt = root()->jointAt(motionJoint); - markerI = jt->markerI; - markerJ = jt->markerJ; + if (motionJoint == "") { + assert(markerI != ""); + assert(markerJ != ""); + } + else { + auto jt = root()->jointAt(motionJoint); + markerI = jt->markerI; + markerJ = jt->markerJ; + } } void MbD::ASMTTranslationalMotion::createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) @@ -60,6 +66,11 @@ void MbD::ASMTTranslationalMotion::readMotionJoint(std::vector& lin lines.erase(lines.begin()); } +void MbD::ASMTTranslationalMotion::setTranslationZ(std::string tranZ) +{ + translationZ = tranZ; +} + void MbD::ASMTTranslationalMotion::readTranslationZ(std::vector& lines) { assert(lines[0].find("TranslationZ") != std::string::npos); diff --git a/OndselSolver/ASMTTranslationalMotion.h b/OndselSolver/ASMTTranslationalMotion.h index 8c907d4..1898248 100644 --- a/OndselSolver/ASMTTranslationalMotion.h +++ b/OndselSolver/ASMTTranslationalMotion.h @@ -20,6 +20,7 @@ namespace MbD { void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; std::shared_ptr mbdClassNew() override; void readMotionJoint(std::vector& lines); + void setTranslationZ(std::string tranZ); void readTranslationZ(std::vector& lines); void storeOnLevel(std::ofstream& os, size_t level) override; void storeOnTimeSeries(std::ofstream& os) override; diff --git a/OndselSolver/CMakeLists.txt b/OndselSolver/CMakeLists.txt index b1a73da..9872fd1 100644 --- a/OndselSolver/CMakeLists.txt +++ b/OndselSolver/CMakeLists.txt @@ -297,7 +297,7 @@ set(ONDSELSOLVER_SRC System.cpp SystemNewtonRaphson.cpp SystemSolver.cpp - Time.cpp + SymTime.cpp TooManyTriesError.cpp TooSmallStepSizeError.cpp Translation.cpp diff --git a/OndselSolver/ExternalSystem.cpp b/OndselSolver/ExternalSystem.cpp index 690d8f3..693f1e7 100644 --- a/OndselSolver/ExternalSystem.cpp +++ b/OndselSolver/ExternalSystem.cpp @@ -9,6 +9,7 @@ #include "ExternalSystem.h" #include "CADSystem.h" #include "ASMTAssembly.h" +//#include #include "System.h" using namespace MbD; @@ -18,10 +19,14 @@ void MbD::ExternalSystem::preMbDrun(std::shared_ptr mbdSys) if (cadSystem) { cadSystem->preMbDrun(mbdSys); } - else if (asmtAssembly) { - asmtAssembly->preMbDrun(mbdSys); - } - else { + else if (asmtAssembly) { + asmtAssembly->preMbDrun(mbdSys); + //asmtAssembly->externalSystem->preMbDrun(mbdSys); + } + else if (freecadAssemblyObject) { + //freecadAssemblyObject->preMbDrun(); + } + else { assert(false); } } @@ -39,7 +44,10 @@ void MbD::ExternalSystem::updateFromMbD() else if (asmtAssembly) { asmtAssembly->updateFromMbD(); } - else { + else if (freecadAssemblyObject) { + //freecadAssemblyObject->updateFromMbD(); + } + else { assert(false); } } @@ -53,8 +61,12 @@ void MbD::ExternalSystem::outputFor(AnalysisType type) asmtAssembly->updateFromMbD(); asmtAssembly->compareResults(type); asmtAssembly->outputResults(type); - } - else { + //asmtAssembly->externalSystem->outputFor(type); + } + else if (freecadAssemblyObject) { + //freecadAssemblyObject->outputResults(type); + } + else { assert(false); } } diff --git a/OndselSolver/ExternalSystem.h b/OndselSolver/ExternalSystem.h index 39d4cad..610f501 100644 --- a/OndselSolver/ExternalSystem.h +++ b/OndselSolver/ExternalSystem.h @@ -16,10 +16,15 @@ //#include "ASMTAssembly.h" #include "Part.h" +namespace Assembly +{ + class AssemblyObject; +} + namespace MbD { class CADSystem; class ASMTAssembly; - class System; + class System; class ExternalSystem { @@ -37,7 +42,8 @@ namespace MbD { CADSystem* cadSystem; - ASMTAssembly* asmtAssembly; + ASMTAssembly* asmtAssembly; + Assembly::AssemblyObject* freecadAssemblyObject; }; } diff --git a/OndselSolver/GeneralSpline.cpp b/OndselSolver/GeneralSpline.cpp index 5040464..d618760 100644 --- a/OndselSolver/GeneralSpline.cpp +++ b/OndselSolver/GeneralSpline.cpp @@ -106,7 +106,7 @@ void MbD::GeneralSpline::computeDerivatives() else { //"Zero out higher derivatives at node n and node 1 to get the p end equations." unsigned int count = 0; - auto npass = 0; + unsigned int npass = 0; while (count < p) { matrix->atijput(np - count, np - npass, 1.0); count++; diff --git a/OndselSolver/Time.cpp b/OndselSolver/SymTime.cpp similarity index 100% rename from OndselSolver/Time.cpp rename to OndselSolver/SymTime.cpp diff --git a/individual_contributor_license_agrement.md b/individual_contributor_license_agrement.md new file mode 100644 index 0000000..eab9e6c --- /dev/null +++ b/individual_contributor_license_agrement.md @@ -0,0 +1,32 @@ +# Individual contributor license agreement + +You accept and agree to the following terms and conditions for Your present and future Contributions submitted to Ondsel Inc. Except for the license granted herein to Ondsel Inc and recipients of software distributed by Ondsel Inc, You reserve all right, title, and interest in and to Your Contributions. + +"1." **Definitions:** + + "You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with Ondsel Inc. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + "Contribution" shall mean any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to Ondsel Inc for inclusion in, or documentation of, any of the products owned or managed by Ondsel Inc (the "Work"). For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to Ondsel Inc or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, Ondsel Inc for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution." + +"2." **Grant of Copyright License:** + + Subject to the terms and conditions of this Agreement, You hereby grant to Ondsel Inc and to recipients of software distributed by Ondsel Inc a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works. + +"3." **Grant of Patent License:** + + Subject to the terms and conditions of this Agreement, You hereby grant to Ondsel Inc and to recipients of software distributed by Ondsel Inc a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed. + + You represent that you are legally entitled to grant the above license. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer, that your employer has waived such rights for your Contributions to Ondsel Inc, or that your employer has executed a separate Corporate CLA with Ondsel Inc. + +"4." **Contributions:** + + You represent that each of Your Contributions is Your original creation. You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions. + + Should You wish to submit work that is not Your original creation, You may submit it to Ondsel Inc separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as "Submitted on behalf of a third-party: (insert_name_here)". + + You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON- INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. + +You agree to notify Ondsel Inc of any facts or circumstances of which you become aware that would make these representations inaccurate in any respect. + +This text is licensed under the [Creative Commons Attribution 3.0 License](https://creativecommons.org/licenses/by/3.0/) and the original source is the Google Open Source Programs Office. +