Skip to content

Commit

Permalink
Cmake gtest (#79)
Browse files Browse the repository at this point in the history
* Check rackpin and gear for zero radii

* rebase zero-radii-check (#69)

* contributing

* Update push-freecad.yml

updated actions/checkout to v4

* dragging log for debugging

* fix calcdxNorm crash

* setDebug and remove MBDyn*

* Update cmakelists.txt

* fix includes for gcc-14

gcc-14 is more disciplined about not including <algorithm> transitively.

* fix runDragStep

* backhoe files (#65)

* Mark unused variables to silence compiler warnings. (#64)

* Backhoe issues (#67)

* backhoe issues

* runDragStep edit

* backhoe issues

* runDragStep edit

* Reduce large drag step progressively until convergence.

* Switch to using built-in M_PI, even on MSVC (#68)

---------

Co-authored-by: Brad Collette <[email protected]>
Co-authored-by: mosfet80 <[email protected]>
Co-authored-by: PaddleStroke <[email protected]>
Co-authored-by: Jed Brown <[email protected]>
Co-authored-by: sliptonic <[email protected]>
Co-authored-by: Chris Hennes <[email protected]>

* in progress

* Gtest added

* With changes from Assembly

* WinMerge main and this branch

* Add flag for GTest

* Flag to suppress OndselSolverMain

* rebase zero-radii-check (#69)

* contributing

* Update push-freecad.yml

updated actions/checkout to v4

* dragging log for debugging

* fix calcdxNorm crash

* setDebug and remove MBDyn*

* Update cmakelists.txt

* fix includes for gcc-14

gcc-14 is more disciplined about not including <algorithm> transitively.

* fix runDragStep

* backhoe files (#65)

* Mark unused variables to silence compiler warnings. (#64)

* Backhoe issues (#67)

* backhoe issues

* runDragStep edit

* backhoe issues

* runDragStep edit

* Reduce large drag step progressively until convergence.

* Switch to using built-in M_PI, even on MSVC (#68)

---------

Co-authored-by: Brad Collette <[email protected]>
Co-authored-by: mosfet80 <[email protected]>
Co-authored-by: PaddleStroke <[email protected]>
Co-authored-by: Jed Brown <[email protected]>
Co-authored-by: sliptonic <[email protected]>
Co-authored-by: Chris Hennes <[email protected]>

* in progress

* Gtest added

* With changes from Assembly

* Add flag for GTest

* Flag to suppress OndselSolverMain

---------

Co-authored-by: Brad Collette <[email protected]>
Co-authored-by: mosfet80 <[email protected]>
Co-authored-by: PaddleStroke <[email protected]>
Co-authored-by: Jed Brown <[email protected]>
Co-authored-by: sliptonic <[email protected]>
Co-authored-by: Chris Hennes <[email protected]>
  • Loading branch information
7 people authored Aug 30, 2024
1 parent 20845a3 commit 6bf651c
Show file tree
Hide file tree
Showing 17 changed files with 200 additions and 29 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ assembly.asmt
build
cmake-build-debug
.idea
temp/
temp/
/testapp/draggingBackhoe.log
/testapp/runPreDragBackhoe.asmt
20 changes: 14 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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)
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()
24 changes: 24 additions & 0 deletions OndselSolver/ASMTAssembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@
#include "ASMTLimit.h"
#include "ASMTRotationLimit.h"
#include "ASMTTranslationLimit.h"
#include "ExternalSystem.h"
#include <filesystem>

using namespace MbD;

MbD::ASMTAssembly::ASMTAssembly()
: ASMTSpatialContainer()
{
externalSystem = std::make_shared<ExternalSystem>();
times = std::make_shared<FullRow<double>>();
}

Expand Down Expand Up @@ -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<ASMTSimulationParameters>::With();
Expand Down Expand Up @@ -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);
//}
}
4 changes: 4 additions & 0 deletions OndselSolver/ASMTAssembly.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace MbD {
class ASMTLimit;
class SystemSolver;
class ASMTItemIJ;
class ExternalSystem;

class ASMTAssembly : public ASMTSpatialContainer
{
Expand Down Expand Up @@ -91,6 +92,7 @@ namespace MbD {
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> 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();
Expand Down Expand Up @@ -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: #()))";
Expand All @@ -151,6 +154,7 @@ namespace MbD {
std::shared_ptr<Units> mbdUnits = std::make_shared<Units>();
std::shared_ptr<System> mbdSystem;
bool debug = false;
std::shared_ptr<ExternalSystem> externalSystem;

};
}
Expand Down
15 changes: 15 additions & 0 deletions OndselSolver/ASMTItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,21 @@ void MbD::ASMTItem::createMbD(std::shared_ptr<System>, std::shared_ptr<Units>)
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);
Expand Down
7 changes: 5 additions & 2 deletions OndselSolver/ASMTItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<System> mbdSys, std::shared_ptr<Units> 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<Units> mbdUnits();
std::shared_ptr<Constant> sptrConstant(double value);
Expand Down
6 changes: 6 additions & 0 deletions OndselSolver/ASMTSimulationParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
42 changes: 41 additions & 1 deletion OndselSolver/ASMTSpatialContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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<FullColumn<double>>(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<FullColumn<double>>(3);
vec3->atiput(0, alpxs->at(i));
vec3->atiput(1, alpys->at(i));
vec3->atiput(2, alpzs->at(i));
return vec3;
}
17 changes: 12 additions & 5 deletions OndselSolver/ASMTSpatialContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ASMTRefPoint> refPoint);
Expand All @@ -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<FullColumn<double>>(3);
FColDsptr omega3D = std::make_shared<FullColumn<double>>(3);
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefPoint>>> refPoints;
FColDsptr omega3D = std::make_shared<FullColumn<double>>(3);
FColDsptr acceleration3D = std::make_shared<FullColumn<double>>(3);
FColDsptr alpha3D = std::make_shared<FullColumn<double>>(3);
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefPoint>>> refPoints;
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefCurve>>> refCurves;
std::shared_ptr<std::vector<std::shared_ptr<ASMTRefSurface>>> refSurfaces;
FRowDsptr vxs, vys, vzs, omexs, omeys, omezs;
Expand Down
17 changes: 14 additions & 3 deletions OndselSolver/ASMTTranslationalMotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ void MbD::ASMTTranslationalMotion::parseASMT(std::vector<std::string>& 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<System> mbdSys, std::shared_ptr<Units> mbdUnits)
Expand Down Expand Up @@ -60,6 +66,11 @@ void MbD::ASMTTranslationalMotion::readMotionJoint(std::vector<std::string>& lin
lines.erase(lines.begin());
}

void MbD::ASMTTranslationalMotion::setTranslationZ(std::string tranZ)
{
translationZ = tranZ;
}

void MbD::ASMTTranslationalMotion::readTranslationZ(std::vector<std::string>& lines)
{
assert(lines[0].find("TranslationZ") != std::string::npos);
Expand Down
1 change: 1 addition & 0 deletions OndselSolver/ASMTTranslationalMotion.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace MbD {
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
std::shared_ptr<ItemIJ> mbdClassNew() override;
void readMotionJoint(std::vector<std::string>& lines);
void setTranslationZ(std::string tranZ);
void readTranslationZ(std::vector<std::string>& lines);
void storeOnLevel(std::ofstream& os, size_t level) override;
void storeOnTimeSeries(std::ofstream& os) override;
Expand Down
2 changes: 1 addition & 1 deletion OndselSolver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ set(ONDSELSOLVER_SRC
System.cpp
SystemNewtonRaphson.cpp
SystemSolver.cpp
Time.cpp
SymTime.cpp
TooManyTriesError.cpp
TooSmallStepSizeError.cpp
Translation.cpp
Expand Down
26 changes: 19 additions & 7 deletions OndselSolver/ExternalSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "ExternalSystem.h"
#include "CADSystem.h"
#include "ASMTAssembly.h"
//#include <Mod/Assembly/App/AssemblyObject.h>
#include "System.h"

using namespace MbD;
Expand All @@ -18,10 +19,14 @@ void MbD::ExternalSystem::preMbDrun(std::shared_ptr<System> 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);
}
}
Expand All @@ -39,7 +44,10 @@ void MbD::ExternalSystem::updateFromMbD()
else if (asmtAssembly) {
asmtAssembly->updateFromMbD();
}
else {
else if (freecadAssemblyObject) {
//freecadAssemblyObject->updateFromMbD();
}
else {
assert(false);
}
}
Expand All @@ -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);
}
}
Expand Down
10 changes: 8 additions & 2 deletions OndselSolver/ExternalSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -37,7 +42,8 @@ namespace MbD {


CADSystem* cadSystem;
ASMTAssembly* asmtAssembly;
ASMTAssembly* asmtAssembly;
Assembly::AssemblyObject* freecadAssemblyObject;

};
}
Expand Down
Loading

0 comments on commit 6bf651c

Please sign in to comment.