Merge pull request #5 from Ondsel-Development/working-for-linux

adding linux support via cmake files and other changes
This commit is contained in:
aiksiongkoh
2023-09-28 13:58:49 -06:00
committed by GitHub
31 changed files with 371 additions and 53 deletions

5
.gitignore vendored
View File

@@ -33,4 +33,7 @@
.vs
x64/
*.bak
*.bak
cmake-build-debug
.idea

7
CMakeLists.txt Normal file
View File

@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.26)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# add_library(some_target main.cpp)
add_executable(ondsel-solver MbDCode/MbDCode.cpp)
add_subdirectory(MbDCode)

View File

@@ -30,9 +30,12 @@
using namespace MbD;
void MbD::ASMTAssembly::runFile(const char* chars)
void MbD::ASMTAssembly::runFile(const char* fileName)
{
std::ifstream stream(chars);
std::ifstream stream(fileName);
if(stream.fail()) {
throw std::invalid_argument("File not found.");
}
std::string line;
std::vector<std::string> lines;
while (std::getline(stream, line)) {

View File

@@ -33,7 +33,7 @@ namespace MbD {
{
//
public:
static void runFile(const char* chars);
static void runFile(const char* fileName);
ASMTAssembly* root() override;
void parseASMT(std::vector<std::string>& lines) override;
void readNotes(std::vector<std::string>& lines);

View File

@@ -6,7 +6,7 @@
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <corecrt_math_defines.h>
#include "corecrt_math_defines.h"
#include "AngleZIecJec.h"
#include "Numeric.h"

View File

@@ -29,7 +29,7 @@ namespace MbD {
Array(std::vector<T> vec) : std::vector<T>(vec) {}
Array(int count) : std::vector<T>(count) {}
Array(int count, const T& value) : std::vector<T>(count, value) {}
Array(typename typename std::vector<T>::iterator begin, typename typename std::vector<T>::iterator end) : std::vector<T>(begin, end) {}
Array(typename std::vector<T>::iterator begin, typename std::vector<T>::iterator end) : std::vector<T>(begin, end) {}
Array(std::initializer_list<T> list) : std::vector<T>{ list } {}
virtual void initialize();
void copyFrom(std::shared_ptr<Array<T>> x);
@@ -180,4 +180,4 @@ namespace MbD {
{
this->at(i) *= factor;
}
}
}

268
MbDCode/CMakeLists.txt Normal file
View File

@@ -0,0 +1,268 @@
target_sources(ondsel-solver PUBLIC
Abs.cpp
AbsConstraint.cpp
AccICKineNewtonRaphson.cpp
AccICNewtonRaphson.cpp
AccKineNewtonRaphson.cpp
AccNewtonRaphson.cpp
AngleJoint.cpp
AngleZIecJec.cpp
AngleZIeqcJec.cpp
AngleZIeqcJeqc.cpp
AnyGeneralSpline.cpp
AnyPosICNewtonRaphson.cpp
ArcTan.cpp
ArcTan2.cpp
Array.cpp
ASMTAnimationParameters.cpp
ASMTAssembly.cpp
ASMTConstantGravity.cpp
ASMTConstraintSet.cpp
ASMTCylindricalJoint.cpp
ASMTExtrusion.cpp
ASMTFixedJoint.cpp
ASMTForceTorque.cpp
ASMTGeneralMotion.cpp
ASMTItem.cpp
ASMTItemIJ.cpp
ASMTJoint.cpp
ASMTKinematicIJ.cpp
ASMTMarker.cpp
ASMTMotion.cpp
ASMTPart.cpp
ASMTPointInPlaneJoint.cpp
ASMTPrincipalMassMarker.cpp
ASMTRefCurve.cpp
ASMTRefItem.cpp
ASMTRefPoint.cpp
ASMTRefSurface.cpp
ASMTRevoluteJoint.cpp
ASMTRotationalMotion.cpp
ASMTSimulationParameters.cpp
ASMTSpatialContainer.cpp
ASMTSpatialItem.cpp
ASMTSphericalJoint.cpp
ASMTTime.cpp
ASMTTranslationalMotion.cpp
ASMTTranslationalJoint.cpp
ASMTUniversalJoint.cpp
AtPointConstraintIJ.cpp
AtPointConstraintIqcJc.cpp
AtPointConstraintIqcJqc.cpp
AtPointConstraintIqctJqc.cpp
AtPointJoint.cpp
BasicIntegrator.cpp
BasicQuasiIntegrator.cpp
BasicUserFunction.cpp
CADSystem.cpp
CartesianFrame.cpp
CompoundJoint.cpp
Constant.cpp
ConstantGravity.cpp
ConstantVelocityJoint.cpp
Constraint.cpp
ConstraintIJ.cpp
ConstVelConstraintIJ.cpp
ConstVelConstraintIqcJc.cpp
ConstVelConstraintIqcJqc.cpp
Cosine.cpp
CREATE.cpp
CylindricalJoint.cpp
CylSphJoint.cpp
DifferentiatedGeneralSpline.cpp
EndFrameqct2.cpp
EulerAngles.cpp
EulerAnglesDDot.cpp
EulerAnglesDot.cpp
Exponential.cpp
ExternalSystem.cpp
FunctionFromData.cpp
FunctionXcParameter.cpp
FunctionXY.cpp
GeneralSpline.cpp
Ln.cpp
Log10.cpp
LogN.cpp
Negative.cpp
PosVelAccData.cpp
DiagonalMatrix.cpp
DifferenceOperator.cpp
DirectionCosineConstraintIJ.cpp
DirectionCosineConstraintIqcJc.cpp
DirectionCosineConstraintIqcJqc.cpp
DirectionCosineConstraintIqctJqc.cpp
DirectionCosineIecJec.cpp
DirectionCosineIeqcJec.cpp
DirectionCosineIeqcJeqc.cpp
DirectionCosineIeqctJeqc.cpp
DiscontinuityError.cpp
DispCompIecJecIe.cpp
DispCompIecJecKec.cpp
DispCompIecJecKeqc.cpp
DispCompIecJecO.cpp
DispCompIeqcJecIe.cpp
DispCompIeqcJecKeqc.cpp
DispCompIeqcJecO.cpp
DispCompIeqcJeqcIe.cpp
DispCompIeqcJeqcKeqc.cpp
DispCompIeqcJeqcKeqct.cpp
DispCompIeqcJeqcO.cpp
DispCompIeqctJeqcIe.cpp
DispCompIeqctJeqcKeqct.cpp
DispCompIeqctJeqcO.cpp
DistanceConstraintIJ.cpp
DistanceConstraintIqcJc.cpp
DistanceConstraintIqcJqc.cpp
DistanceConstraintIqctJqc.cpp
DistancexyConstraintIJ.cpp
DistancexyConstraintIqcJc.cpp
DistancexyConstraintIqcJqc.cpp
DistIecJec.cpp
DistIeqcJec.cpp
DistIeqcJeqc.cpp
DistIeqctJeqc.cpp
DistxyIecJec.cpp
DistxyIeqcJec.cpp
DistxyIeqcJeqc.cpp
DistxyIeqctJeqc.cpp
EndFramec.cpp
EndFrameqc.cpp
EndFrameqct.cpp
EulerAngleszxz.cpp
EulerAngleszxzDDot.cpp
EulerAngleszxzDot.cpp
EulerArray.cpp
EulerConstraint.cpp
EulerParameters.cpp
EulerParametersDDot.cpp
EulerParametersDot.cpp
ExpressionX.cpp
FixedJoint.cpp
ForceTorqueData.cpp
ForceTorqueItem.cpp
FullColumn.cpp
FullMatrix.cpp
FullMotion.cpp
FullRow.cpp
Function.cpp
FunctionWithManyArgs.cpp
FunctionX.cpp
GearConstraintIJ.cpp
GearConstraintIqcJc.cpp
GearConstraintIqcJqc.cpp
GearJoint.cpp
GEFullMat.cpp
GEFullMatFullPv.cpp
GEFullMatParPv.cpp
GESpMat.cpp
GESpMatFullPv.cpp
GESpMatFullPvPosIC.cpp
GESpMatParPv.cpp
GESpMatParPvMarko.cpp
GESpMatParPvMarkoFast.cpp
GESpMatParPvPrecise.cpp
ICKineIntegrator.cpp
IndependentVariable.cpp
InLineJoint.cpp
InPlaneJoint.cpp
Integrator.cpp
IntegratorInterface.cpp
Item.cpp
Joint.cpp
KineIntegrator.cpp
KinematicIeJe.cpp
LDUFullMatParPv.cpp
LDUSpMat.cpp
LDUSpMatParPv.cpp
LDUSpMatParPvMarko.cpp
LDUSpMatParPvPrecise.cpp
LinearMultiStepMethod.cpp
LineInPlaneJoint.cpp
MarkerFrame.cpp
Math.cpp
MatrixDecomposition.cpp
MatrixGaussElimination.cpp
MatrixLDU.cpp
MatrixSolver.cpp
MaximumIterationError.cpp
NewtonRaphson.cpp
NewtonRaphsonError.cpp
NoRotationJoint.cpp
NotKinematicError.cpp
Numeric.cpp
OrbitAnglezIecJec.cpp
OrbitAnglezIeqcJec.cpp
OrbitAnglezIeqcJeqc.cpp
Orientation.cpp
ParallelAxesJoint.cpp
Part.cpp
PartFrame.cpp
PerpendicularJoint.cpp
PlanarJoint.cpp
PointInLineJoint.cpp
PointInPlaneJoint.cpp
PosICKineNewtonRaphson.cpp
PosICNewtonRaphson.cpp
PosKineNewtonRaphson.cpp
PosNewtonRaphson.cpp
Power.cpp
PrescribedMotion.cpp
Product.cpp
QuasiIntegrator.cpp
RackPinConstraintIJ.cpp
RackPinConstraintIqcJc.cpp
RackPinConstraintIqcJqc.cpp
RackPinJoint.cpp
Reciprocal.cpp
RedundantConstraint.cpp
RevCylJoint.cpp
RevoluteJoint.cpp
RowTypeMatrix.cpp
ScalarNewtonRaphson.cpp
ScrewConstraintIJ.cpp
ScrewConstraintIqcJc.cpp
ScrewConstraintIqcJqc.cpp
ScrewJoint.cpp
SimulationStoppingError.cpp
Sine.cpp
SingularMatrixError.cpp
Solver.cpp
SparseColumn.cpp
SparseMatrix.cpp
SparseRow.cpp
SparseVector.cpp
SphericalJoint.cpp
SphSphJoint.cpp
StableBackwardDifference.cpp
LDUFullMat.cpp
StateData.cpp
Sum.cpp
Symbolic.cpp
SymbolicParser.cpp
SyntaxError.cpp
System.cpp
SystemNewtonRaphson.cpp
SystemSolver.cpp
Time.cpp
TooManyTriesError.cpp
TooSmallStepSizeError.cpp
Translation.cpp
TranslationalJoint.cpp
TranslationConstraintIJ.cpp
TranslationConstraintIqcJc.cpp
TranslationConstraintIqcJqc.cpp
TranslationConstraintIqctJqc.cpp
Units.cpp
UniversalJoint.cpp
UserFunction.cpp
Variable.cpp
FullVector.cpp
VectorNewtonRaphson.cpp
VelICKineSolver.cpp
VelICSolver.cpp
VelKineSolver.cpp
VelSolver.cpp
ZRotation.cpp
ZTranslation.cpp
ASMTAssembly.cpp
)

View File

@@ -71,15 +71,15 @@ namespace MbD {
static std::shared_ptr<Constraint> ConstraintWith(std::shared_ptr<EndFramec> frmi, std::shared_ptr<EndFramec> frmj, int axis) {
std::shared_ptr<Constraint> inst;
std::string str = typeid(T(frmi, frmj, axis)).name();
if (str == "class MbD::AtPointConstraintIJ") {
if (str.find("AtPointConstraintIJ") != std::string::npos) {
if (std::dynamic_pointer_cast<EndFrameqct>(frmi)) {
inst = std::make_shared<AtPointConstraintIqctJqc>(frmi, frmj, axis);
}
else {
inst = std::make_shared<AtPointConstraintIqcJqc>(frmi, frmj, axis);
}
}
else if(str == "class MbD::TranslationConstraintIJ") {
} // "class MbD::Tran
else if(str.find("TranslationConstraintIJ") != std::string::npos) {
if (std::dynamic_pointer_cast<EndFrameqct>(frmi)) {
inst = std::make_shared<TranslationConstraintIqctJqc>(frmi, frmj, axis);
}
@@ -98,7 +98,7 @@ namespace MbD {
static std::shared_ptr<Constraint> ConstraintWith(std::shared_ptr<EndFramec> frmi, std::shared_ptr<EndFramec> frmj, int axisi, int axisj) {
std::shared_ptr<Constraint> inst;
std::string str = typeid(T(frmi, frmj, axisi, axisj)).name();
if (str == "class MbD::DirectionCosineConstraintIJ") {
if (str.find("DirectionCosineConstraintIJ") != std::string::npos) {
if (std::dynamic_pointer_cast<EndFrameqct>(frmi)) {
inst = std::make_shared<DirectionCosineConstraintIqctJqc>(frmi, frmj, axisi, axisj);
}

View File

@@ -8,7 +8,7 @@
#pragma once
#include <corecrt_math_defines.h>
#include "corecrt_math_defines.h"
#include <memory>
#include "RowTypeMatrix.h"
@@ -296,6 +296,13 @@ namespace MbD {
row2->atiput(2, 0.0);
return rotMat;
}
template<>
inline void FullMatrix<double>::zeroSelf()
{
for (int i = 0; i < this->size(); i++) {
this->at(i)->zeroSelf();
}
}
template<>
inline void FullMatrix<double>::identity() {
this->zeroSelf();
@@ -452,13 +459,6 @@ namespace MbD {
assert(false);
return 0.0;
}
template<>
inline void FullMatrix<double>::zeroSelf()
{
for (int i = 0; i < this->size(); i++) {
this->at(i)->zeroSelf();
}
}
template<typename T>
inline void FullMatrix<T>::zeroSelf()
{

View File

@@ -35,7 +35,7 @@ namespace MbD {
FullRow(std::vector<T> vec) : FullVector<T>(vec) {}
FullRow(int count) : FullVector<T>(count) {}
FullRow(int count, const T& value) : FullVector<T>(count, value) {}
FullRow(typename std::vector<T>::iterator begin, typename std::vector<T>::iterator end) : FullVector<T>(begin, end) {}
FullRow(typename std::vector<T>::const_iterator begin, typename std::vector<T>::const_iterator end) : FullVector<T>(begin, end) {}
FullRow(std::initializer_list<T> list) : FullVector<T>{ list } {}
FRowsptr<T> times(T a);
FRowsptr<T> negated();

View File

@@ -9,6 +9,7 @@
#pragma once
#include <ostream>
#include <limits>
#include "Array.h"

View File

@@ -108,6 +108,12 @@ void GESpMatFullPv::backSubstituteIntoDU()
double sum, duij, duii;
//answerX = rightHandSideB->copyEmpty();
assert(m == n);
// TODO: temp
// assert(n > 0);
// auto localLen = colOrder->numberOfElements();
// assert(n < localLen);
answerX = std::make_shared<FullColumn<double>>(m);
auto jn = colOrder->at(n);
answerX->at(jn) = rightHandSideB->at(m) / matrixA->at(m)->at(jn);

View File

@@ -9,7 +9,7 @@
#pragma once
#include "ConstraintIJ.h"
#include "OrbitAngleZIecJec.h"
#include "OrbitAnglezIecJec.h"
namespace MbD {
class GearConstraintIJ : public ConstraintIJ

View File

@@ -9,7 +9,7 @@
#include "GearConstraintIqcJc.h"
#include "EndFrameqc.h"
#include "CREATE.h"
#include "OrbitAngleZIeqcJec.h"
#include "OrbitAnglezIeqcJec.h"
using namespace MbD;

View File

@@ -8,7 +8,7 @@
#include "GearConstraintIqcJqc.h"
#include "EndFrameqc.h"
#include "OrbitAngleZIeqcJeqc.h"
#include "OrbitAnglezIeqcJeqc.h"
#include "CREATE.h"
using namespace MbD;

View File

@@ -6,9 +6,9 @@
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <windows.h>
//#include <windows.h>
#include <assert.h>
#include <debugapi.h>
//#include <debugapi.h>
#include <sstream>
#include "Item.h"

View File

@@ -26,20 +26,20 @@ void runSpMat();
int main()
{
//ASMTAssembly::runFile("piston.asmt");
//ASMTAssembly::runFile("00backhoe.asmt");
//ASMTAssembly::runFile("circular.asmt");
ASMTAssembly::runFile("piston.asmt");
ASMTAssembly::runFile("00backhoe.asmt");
ASMTAssembly::runFile("circular.asmt");
//ASMTAssembly::runFile("cirpendu.asmt"); //Under constrained. Testing ICKine.
//ASMTAssembly::runFile("engine1.asmt");
//ASMTAssembly::runFile("fourbar.asmt");
//ASMTAssembly::runFile("fourbot.asmt");
//ASMTAssembly::runFile("wobpump.asmt");
ASMTAssembly::runFile("engine1.asmt");
ASMTAssembly::runFile("fourbar.asmt");
ASMTAssembly::runFile("fourbot.asmt");
ASMTAssembly::runFile("wobpump.asmt");
auto cadSystem = std::make_shared<CADSystem>();
cadSystem->runOndselDoublePendulum();
////cadSystem->runOndselPiston();
//cadSystem->runPiston();
//runSpMat();
cadSystem->runOndselPiston();
cadSystem->runPiston();
runSpMat();
}
void runSpMat() {
@@ -58,4 +58,4 @@ void runSpMat() {
auto matSolver = CREATE<GESpMatParPvPrecise>::With();
auto answer = matSolver->solvewithsaveOriginal(spMat, fullCol, true);
auto aAx = spMat->timesFullColumn(answer);
}
}

View File

@@ -7,7 +7,7 @@
***************************************************************************/
#include <cmath>
#include <corecrt_math_defines.h>
#include "corecrt_math_defines.h"
#include <stdexcept>
#include "Numeric.h"

View File

@@ -6,9 +6,9 @@
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <corecrt_math_defines.h>
#include "corecrt_math_defines.h"
#include "OrbitAngleZIecJec.h"
#include "OrbitAnglezIecJec.h"
#include "Numeric.h"
using namespace MbD;

View File

@@ -6,7 +6,7 @@
* See LICENSE file for details about copyright. *
***************************************************************************/
#include "OrbitAngleZIeqcJec.h"
#include "OrbitAnglezIeqcJec.h"
#include "CREATE.h"
#include "DispCompIeqcJecIe.h"

View File

@@ -8,7 +8,7 @@
#pragma once
#include "OrbitAngleZIecJec.h"
#include "OrbitAnglezIecJec.h"
namespace MbD {
class OrbitAngleZIeqcJec : public OrbitAngleZIecJec

View File

@@ -6,7 +6,7 @@
* See LICENSE file for details about copyright. *
***************************************************************************/
#include "OrbitAngleZIeqcJeqc.h"
#include "OrbitAnglezIeqcJeqc.h"
#include "CREATE.h"
#include "DispCompIeqcJeqcIe.h"

View File

@@ -8,7 +8,7 @@
#pragma once
#include "OrbitAngleZIeqcJec.h"
#include "OrbitAnglezIeqcJec.h"
namespace MbD {
class OrbitAngleZIeqcJeqc : public OrbitAngleZIeqcJec

View File

@@ -103,13 +103,13 @@ void PosICNewtonRaphson::handleSingularMatrix()
}
else {
std::string str = typeid(*matrixSolver).name();
if (str == "class GESpMatParPvMarkoFast") {
if (str.find("GESpMatParPvMarkoFast") != std::string::npos) {
matrixSolver = CREATE<GESpMatParPvPrecise>::With();
this->solveEquations();
}
else {
str = typeid(*matrixSolver).name();
if (str == "class GESpMatParPvPrecise") {
if (str.find("GESpMatParPvPrecise") != std::string::npos) {
this->lookForRedundantConstraints();
matrixSolver = this->matrixSolverClassNew();
}

View File

@@ -6,7 +6,7 @@
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <corecrt_math_defines.h>
#include "corecrt_math_defines.h"
#include "ScrewConstraintIJ.h"

View File

@@ -6,7 +6,7 @@
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <corecrt_math_defines.h>
#include "corecrt_math_defines.h"
#include "ScrewConstraintIqcJc.h"
#include "EndFrameqc.h"

View File

@@ -6,7 +6,7 @@
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <corecrt_math_defines.h>
#include "corecrt_math_defines.h"
#include "ScrewConstraintIqcJqc.h"
#include "EndFrameqc.h"

View File

@@ -6,7 +6,7 @@
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <corecrt_math_defines.h>
#include "corecrt_math_defines.h"
#include <sstream>
#include <iomanip>

View File

@@ -52,13 +52,13 @@ void SystemNewtonRaphson::basicSolveEquations()
void SystemNewtonRaphson::handleSingularMatrix()
{
std::string str = typeid(*matrixSolver).name();
if (str == "class GESpMatParPvMarkoFast") {
if (str.find("GESpMatParPvMarkoFast") != std::string::npos) {
matrixSolver = CREATE<GESpMatParPvPrecise>::With();
this->solveEquations();
}
else {
str = typeid(*matrixSolver).name();
if (str == "class GESpMatParPvPrecise") {
if (str.find("GESpMatParPvPrecise") != std::string::npos) {
str = "MbD: Singular Matrix Error. ";
system->logString(str);
matrixSolver = this->matrixSolverClassNew();

View File

@@ -25,13 +25,13 @@ void VelSolver::basicSolveEquations()
void VelSolver::handleSingularMatrix()
{
std::string str = typeid(*matrixSolver).name();
if (str == "class GESpMatParPvMarkoFast") {
if (str.find("GESpMatParPvMarkoFast") != std::string::npos) {
matrixSolver = CREATE<GESpMatParPvPrecise>::With();
this->solveEquations();
}
else {
str = typeid(*matrixSolver).name();
if (str == "class GESpMatParPvPrecise") {
if (str.find("GESpMatParPvPrecise") != std::string::npos) {
this->logSingularMatrixMessage();
matrixSolver = this->matrixSolverClassNew();
}

View File

@@ -0,0 +1,30 @@
//
// corecrt_math_defines.h
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Definitions of useful mathematical constants
//
#pragma once
#ifndef _MATH_DEFINES_DEFINED
#define _MATH_DEFINES_DEFINED
// Definitions of useful mathematical constants
//
// Define _USE_MATH_DEFINES before including <math.h> to expose these macro
// definitions for common math constants. These are placed under an #ifdef
// since these commonly-defined names are not part of the C or C++ standards
// #define M_E 2.71828182845904523536 // e
// #define M_LOG2E 1.44269504088896340736 // log2(e)
// #define M_LOG10E 0.434294481903251827651 // log10(e)
// #define M_LN2 0.693147180559945309417 // ln(2)
// #define M_LN10 2.30258509299404568402 // ln(10)
#define M_PI 3.14159265358979323846 // pi
// #define M_PI_2 1.57079632679489661923 // pi/2
// #define M_PI_4 0.785398163397448309616 // pi/4
// #define M_1_PI 0.318309886183790671538 // 1/pi
// #define M_2_PI 0.636619772367581343076 // 2/pi
#define M_2_SQRTPI 1.12837916709551257390 // 2/sqrt(pi)
#define M_SQRT2 1.41421356237309504880 // sqrt(2)
// #define M_SQRT1_2 0.707106781186547524401 // 1/sqrt(2)
#endif