Commit 7a313d93 authored by Stefan Pfeifer's avatar Stefan Pfeifer

Restructure project tree, add resource folder and icons

parent 3c9fa3b8
......@@ -26,4 +26,10 @@ General
* Restructure. Put code in cpp files, include less stuff in headers to reduce compile times.
* Decide between using std::array and Eigen::Array, then replace one with the other.
\ No newline at end of file
* Decide between using std::array and Eigen::Array, then replace one with the other.
Platforms, compilers
====================
* tests fail on Windows 7 with MinGW 5.3.0 32bit.
\ No newline at end of file
include(dependencies.pri)
TARGET = bow-design-simulator
TEMPLATE = app
QT += core \
gui \
widgets \
charts \
printsupport \
SOURCES += ../src/main.cpp \
../src/fem/elements/Element.cpp \
../src/gui/MainWindow.cpp \
../src/numerics/StepFunction.cpp \
../src/fem/System.cpp \
../src/numerics/Domain.cpp \
../src/numerics/CubicSpline.cpp \
../src/numerics/LinearSpline.cpp
HEADERS += \
../src/fem/elements/BarElement.hpp \
../src/fem/elements/MassElement.hpp \
../src/fem/elements/BeamElement.hpp \
../src/fem/elements/Element.hpp \
../src/gui/MainWindow.hpp \
../src/numerics/TDMatrix.hpp \
../src/numerics/StepFunction.hpp \
../src/gui/BowEditor.hpp \
../src/fem/Node.hpp \
../src/fem/System.hpp \
../src/fem/View.hpp \
../src/numerics/NumParam.hpp \
../src/numerics/Domain.hpp \
../src/numerics/Units.hpp \
../src/gui/NumberView.hpp \
../src/numerics/DataSeries.hpp \
../src/gui/SeriesEditor.hpp \
../src/model/InputData.hpp \
../src/model/DiscreteLimb.hpp \
../src/model/BowModel.hpp \
../src/model/OutputData.hpp \
../src/numerics/SecantMethod.hpp \
../src/fem/elements/ContactElement1D.hpp \
../src/numerics/CubicSpline.hpp \
../src/numerics/LinearSpline.hpp \
../src/gui/Document.hpp
INCLUDEPATH += /mnt/Daten/Libraries/Eigen-3.2.9 \
/mnt/Daten/Libraries/Catch-1.5.6 \
/mnt/Daten/Libraries/Boost-1.61.0 \
/mnt/Daten/Libraries/Cereal-1.2.0/include \
include(dependencies.pri)
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
../tests/bar_trusses.cpp \
../tests/tangent_stiffness.cpp \
../tests/harmonic_oscillator.cpp \
../tests/main.cpp \
../tests/large_deformation_beams.cpp \
../src/fem/System.cpp \
../src/fem/elements/Element.cpp
HEADERS += \
../src/fem/Node.hpp \
../src/fem/View.hpp \
../src/fem/System.hpp \
../src/fem/elements/BarElement.hpp \
../src/fem/elements/MassElement.hpp \
../src/fem/elements/Element.hpp \
../src/fem/elements/BeamElement.hpp
include(dependencies.pri)
TARGET = bow-design-simulator
TEMPLATE = app
QT += core \
gui \
widgets \
charts \
printsupport \
SOURCES += ../source/main.cpp \
../source/fem/elements/Element.cpp \
../source/gui/MainWindow.cpp \
../source/numerics/StepFunction.cpp \
../source/fem/System.cpp \
../source/numerics/Domain.cpp \
../source/numerics/CubicSpline.cpp \
../source/numerics/LinearSpline.cpp
HEADERS += \
../source/fem/elements/BarElement.hpp \
../source/fem/elements/MassElement.hpp \
../source/fem/elements/BeamElement.hpp \
../source/fem/elements/Element.hpp \
../source/gui/MainWindow.hpp \
../source/numerics/TDMatrix.hpp \
../source/numerics/StepFunction.hpp \
../source/gui/BowEditor.hpp \
../source/fem/Node.hpp \
../source/fem/System.hpp \
../source/fem/View.hpp \
../source/numerics/NumParam.hpp \
../source/numerics/Domain.hpp \
../source/numerics/Units.hpp \
../source/gui/NumberView.hpp \
../source/numerics/DataSeries.hpp \
../source/gui/SeriesEditor.hpp \
../source/model/InputData.hpp \
../source/model/DiscreteLimb.hpp \
../source/model/BowModel.hpp \
../source/model/OutputData.hpp \
../source/numerics/SecantMethod.hpp \
../source/fem/elements/ContactElement1D.hpp \
../source/numerics/CubicSpline.hpp \
../source/numerics/LinearSpline.hpp \
../source/gui/Document.hpp
RESOURCES += ../resources/resources.qrc
INCLUDEPATH += C:/Daten/Libraries/Eigen-3.2.9 \
C:/Daten/Libraries/Catch-1.5.6 \
C:/Daten/Libraries/Boost-1.61.0 \
C:/Daten/Libraries/Cereal-1.2.0/include \
include(dependencies.pri)
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
../source/tests/bar_trusses.cpp \
../source/tests/tangent_stiffness.cpp \
../source/tests/harmonic_oscillator.cpp \
../source/tests/main.cpp \
../source/tests/large_deformation_beams.cpp \
../source/fem/System.cpp \
../source/fem/elements/Element.cpp
HEADERS += \
../source/fem/Node.hpp \
../source/fem/View.hpp \
../source/fem/System.hpp \
../source/fem/elements/BarElement.hpp \
../source/fem/elements/MassElement.hpp \
../source/fem/elements/Element.hpp \
../source/fem/elements/BeamElement.hpp
<RCC>
<qresource prefix="/">
<file>icon.png</file>
<file>oxygen/application-exit.png</file>
<file>oxygen/arrow-right.png</file>
<file>oxygen/arrow-right-double.png</file>
<file>oxygen/document-new.png</file>
<file>oxygen/document-open.png</file>
<file>oxygen/document-save.png</file>
<file>oxygen/document-save-as.png</file>
<file>oxygen/system-help.png</file>
</qresource>
</RCC>
......@@ -11,35 +11,36 @@ public:
MainWindow(): editor(new BowEditor(document))
{
// Actions
QAction *action_new = new QAction(QIcon::fromTheme("document-new"), "&New", this);
QAction *action_new = new QAction(QIcon::fromTheme(":/oxygen/document-new"), "&New", this);
//QAction *action_new = new QAction(QIcon(":/document-new"), "&New", this);
action_new->setShortcuts(QKeySequence::New);
connect(action_new, &QAction::triggered, this, &MainWindow::newFile);
QAction *action_open = new QAction(QIcon::fromTheme("document-open"), "&Open...", this);
QAction *action_open = new QAction(QIcon::fromTheme(":/oxygen/document-open"), "&Open...", this);
action_open->setShortcuts(QKeySequence::Open);
connect(action_open, &QAction::triggered, this, &MainWindow::open);
QAction *action_save = new QAction(QIcon::fromTheme("document-save"), "&Save", this);
QAction *action_save = new QAction(QIcon::fromTheme(":/oxygen/document-save"), "&Save", this);
action_save->setShortcuts(QKeySequence::Save);
connect(action_save, &QAction::triggered, this, &MainWindow::save);
QAction *action_save_as = new QAction(QIcon::fromTheme("document-save-as"), "Save &As...", this);
QAction *action_save_as = new QAction(QIcon::fromTheme(":/oxygen/document-save-as"), "Save &As...", this);
action_save_as->setShortcuts(QKeySequence::SaveAs);
connect(action_save_as, &QAction::triggered, this, &MainWindow::saveAs);
QAction *action_exit = new QAction(QIcon::fromTheme("application-exit"), "&Quit", this);
QAction *action_exit = new QAction(QIcon::fromTheme(":/oxygen/application-exit"), "&Quit", this);
action_exit->setShortcuts(QKeySequence::Quit);
connect(action_exit, &QAction::triggered, this, &QWidget::close);
QAction *action_run_statics = new QAction("Statics...", this);
QAction *action_run_statics = new QAction(QIcon::fromTheme(":/oxygen/arrow-right"), "Statics...", this);
//action_run_statics->setShortcuts(QKeySequence::Quit);
// connect ...
QAction *action_run_dynamics = new QAction("Dynamics...", this);
QAction *action_run_dynamics = new QAction(QIcon::fromTheme(":/oxygen/arrow-right-double"), "Dynamics...", this);
//action_run_dynmics->setShortcuts(QKeySequence::Quit);
// connect ...
QAction *action_about = new QAction(QIcon::fromTheme("dialog-information"), "&About...", this);
QAction *action_about = new QAction(QIcon::fromTheme(":/oxygen/system-help"), "&About...", this);
connect(action_about, &QAction::triggered, this, &MainWindow::about);
// File menu
......@@ -58,6 +59,11 @@ public:
toolbar_file->addAction(action_save);
toolbar_file->addAction(action_save_as);
// Simulation toolbar
QToolBar *toolbar_simulation = this->addToolBar("Simulation");
toolbar_simulation->addAction(action_run_statics);
toolbar_simulation->addAction(action_run_dynamics);
// Simulation menu
QMenu *menu_run = this->menuBar()->addMenu("&Simulate");
menu_run->addAction(action_run_statics);
......@@ -67,6 +73,7 @@ public:
QMenu *menu_help = this->menuBar()->addMenu("&Help");
menu_help->addAction(action_about);
this->setWindowIcon(QIcon(":/icon"));
this->setCentralWidget(editor);
setCurrentFile(QString());
}
......@@ -74,8 +81,6 @@ public:
private slots:
void closeEvent(QCloseEvent *event) override
{
//this->setFocus(); // Make all views lose their focus so they propagate their changes to the document
if(optionalSave())
{
event->accept();
......
#pragma once
#include "TDMatrix.hpp"
#include "DataSeries.hpp"
#include <cereal/cereal.hpp>
class CubicSpline
{
public:
CubicSpline(DataSeries data);
double operator()(double arg) const;
double arg_min() const;
double arg_max() const;
DataSeries sample(size_t n_points) const;
private:
size_t interval_index(double arg) const;
std::vector<double> t;
std::vector<double> x;
std::vector<double> a;
std::vector<double> b;
std::vector<double> c;
};
#pragma once
#include "TDMatrix.hpp"
#include "DataSeries.hpp"
#include <cereal/cereal.hpp>
class CubicSpline
{
public:
CubicSpline(DataSeries data);
double operator()(double arg) const;
double arg_min() const;
double arg_max() const;
DataSeries sample(size_t n_points) const;
private:
size_t interval_index(double arg) const;
std::vector<double> t;
std::vector<double> x;
std::vector<double> a;
std::vector<double> b;
std::vector<double> c;
};
#pragma once
#include "TDMatrix.hpp"
#include "DataSeries.hpp"
#include <cereal/cereal.hpp> // Todo: Necessary hereß
class LinearSpline
{
public:
LinearSpline(DataSeries data);
double operator()(double arg) const;
double arg_min() const;
double arg_max() const;
DataSeries sample(size_t n_points) const;
private:
size_t interval_index(double arg) const; // Todo: Common implementation for all interpolation classes
DataSeries data;
};
#pragma once
#include "TDMatrix.hpp"
#include "DataSeries.hpp"
#include <cereal/cereal.hpp> // Todo: Necessary hereß
class LinearSpline
{
public:
LinearSpline(DataSeries data);
double operator()(double arg) const;
double arg_min() const;
double arg_max() const;
DataSeries sample(size_t n_points) const;
private:
size_t interval_index(double arg) const; // Todo: Common implementation for all interpolation classes
DataSeries data;
};
#pragma once
#include <vector>
#include <cassert>
#include <stdexcept>
template<typename T>
class TDMatrix
{
public:
TDMatrix(std::size_t n);
std::size_t size() const;
T get(std::size_t i, std::size_t j) const;
void set(std::size_t i, std::size_t j, T val);
void solve(std::vector<T>& rhs);
private:
std::vector<T> a; // Lower secondary diagonal
std::vector<T> b; // Diagonal
std::vector<T> c; // Upper secondary diagonal
};
template<typename T>
TDMatrix<T>::TDMatrix(std::size_t n): a(n-1), b(n), c(n-1)
{
}
template<typename T>
std::size_t TDMatrix<T>::size() const
{
return b.size();
}
template<typename T>
T TDMatrix<T>::get(std::size_t i, std::size_t j) const
{
assert(i < size() && j < size());
switch(i-j)
{
case 1:
return a[j];
case 0:
return b[j];
case -1:
return c[i];
default:
return 0;
}
}
template<typename T>
void TDMatrix<T>::set(std::size_t i, std::size_t j, T val)
{
assert(i < size() && j < size());
switch(i-j)
{
case 1:
a[j] = val;
break;
case 0:
b[j] = val;
break;
case -1:
c[i] = val;
break;
default:
throw std::runtime_error("This entry cannot be set");
}
}
template<typename T>
void TDMatrix<T>::solve(std::vector<T>& rhs)
{
assert(rhs.size() == size());
std::size_t n = size() - 1;
c[0] /= b[0];
rhs[0] /= b[0];
for(std::size_t i = 1; i < n; ++i)
{
T m = b[i] - a[i-1]*c[i-1];
c[i] = c[i]/m;
rhs[i] = (rhs[i] - a[i-1]*rhs[i-1])/m;
}
rhs[n] = (rhs[n] - a[n-1]*rhs[n-1])/(b[n] - a[n-1]*c[n-1]);
for(std::size_t i = n; i > 0; --i)
{
rhs[i-1] -= c[i-1]*rhs[i];
}
}
#pragma once
#include <vector>
#include <cassert>
#include <stdexcept>
template<typename T>
class TDMatrix
{
public:
TDMatrix(std::size_t n);
std::size_t size() const;
T get(std::size_t i, std::size_t j) const;
void set(std::size_t i, std::size_t j, T val);
void solve(std::vector<T>& rhs);
private:
std::vector<T> a; // Lower secondary diagonal
std::vector<T> b; // Diagonal
std::vector<T> c; // Upper secondary diagonal
};
template<typename T>
TDMatrix<T>::TDMatrix(std::size_t n): a(n-1), b(n), c(n-1)
{
}
template<typename T>
std::size_t TDMatrix<T>::size() const
{
return b.size();
}
template<typename T>
T TDMatrix<T>::get(std::size_t i, std::size_t j) const
{
assert(i < size() && j < size());
switch(i-j)
{
case 1:
return a[j];
case 0:
return b[j];
case -1:
return c[i];
default:
return 0;
}
}
template<typename T>
void TDMatrix<T>::set(std::size_t i, std::size_t j, T val)
{
assert(i < size() && j < size());
switch(i-j)
{
case 1:
a[j] = val;
break;
case 0:
b[j] = val;
break;
case -1:
c[i] = val;
break;
default:
throw std::runtime_error("This entry cannot be set");
}
}
template<typename T>
void TDMatrix<T>::solve(std::vector<T>& rhs)
{
assert(rhs.size() == size());
std::size_t n = size() - 1;
c[0] /= b[0];
rhs[0] /= b[0];
for(std::size_t i = 1; i < n; ++i)
{
T m = b[i] - a[i-1]*c[i-1];
c[i] = c[i]/m;
rhs[i] = (rhs[i] - a[i-1]*rhs[i-1])/m;
}
rhs[n] = (rhs[n] - a[n-1]*rhs[n-1])/(b[n] - a[n-1]*c[n-1]);
for(std::size_t i = n; i > 0; --i)
{
rhs[i-1] -= c[i-1]*rhs[i];
}
}
#include "../src/fem/System.hpp"
#include "../src/fem/elements/BarElement.hpp"
#include "../fem/System.hpp"
#include "../fem/elements/BarElement.hpp"
#include <catch.hpp>
#include <iostream>
......
#include "../src/fem/System.hpp"
#include "../src/fem/elements/BarElement.hpp"
#include "../src/fem/elements/MassElement.hpp"
#include "../fem/System.hpp"
#include "../fem/elements/BarElement.hpp"
#include "../fem/elements/MassElement.hpp"
#include <catch.hpp>
#include <iostream>
......
#include "../src/fem/System.hpp"
#include "../src/fem/elements/BeamElement.hpp"
#include "../fem/System.hpp"
#include "../fem/elements/BeamElement.hpp"
#include <catch.hpp>
#include <vector>
......
#include "../src/fem/System.hpp"
#include "../src/fem/elements/BarElement.hpp"
#include "../src/fem/elements/BeamElement.hpp"
#include "../fem/System.hpp"
#include "../fem/elements/BarElement.hpp"
#include "../fem/elements/BeamElement.hpp"
#include <catch.hpp>
#include <iostream>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment