Do you know any library for Finite Element Method, that i can use for realtime application ?
I think about getFEM++, but I don't test it yet.
I want to use FEM to simulate behaviour of elasto-plastic body in realtime. My further plan is to merge it with Bullet.
You should try to specify the kind of problems you are trying to solve in order to select the best library for you.
How many dimensions for your problem?
Do you plan on doing collision detection?
How many vertices will compose your objects?
Do you plan on using parallelism to achieve real-time computations?
Do you plan on doing spectral analysis for a dynamical system or just study local deformations with a quasistatic system?
etc.
Concerning the available libraries, I have mostly used homemade ones, but here are some that you might be able to use:
[GetFEM++] : C++ library, documentation and tutorials available. It seems you already know this one.
[LifeV] : I know some people who use this for fluid dynamics, but it works for structure dynamics too. It is developed by several major research institutions.
[OFELI] : another C++ library but it may lack tutorials.
Moreover, are you sure that what you need is not already present in the Bullet library? Soft body dynamics is already a part of Bullet... (Video here)
Related
For my next project I would like to try UML modeling. There are several reason - mainly documentation + to break ground for development to avoid re-coding everything over and over again.
I've tried it several times in the past, but I had a feeling like without a deep knowledge of the background libraries my work will depend on, It's not a trivial task, as at the very beginning I don't know, what kind of member variables and functions I would need.
Usually I was coding to get familiar with the libraries and API my app was interface and I get into a state, where the work was almost done or let's say it was from 50% ready, where it made no sense to me to start modeling something.
Am I true you really need to understand well the background or there are ways/techniques how to overcome this?
Another point is, do you built up the model from bottom to top or from top to bottom or it depends on the use case?
Thank you for any recommendations how to proceed.
If I understand well, your main challenge is to get an understanding of the libraries and API that you are using.
If you intend to create an UML diagram for reverse-engineering the library and understand it, you might loose your time: You'd be able to make a meaningful model only once you've understood how the pieces fit together. And for this discovery and knowledge acquisition, you already use the most effective approach:
Usually I was coding to get familiar with the libraries and API my app was interfaced.
Now, if the library or the API is delivered with an UML model, it's another story: an existing design model (not all the details of the implementation, but the core elements of the design, and interaction scenario that are difficult to grasp from the code) could help you to grasp faster how the library works, which will help you to go faster through the exploratory phase.
It's also a different story when you are reverese-engineering an undocumented app: there you don't have a tutorial, and it's difficult to write code to use the existing elements in a meaninful way. There it could make sense to document the system post-mortem. But again, do not lose yourself in a detailed implementation model with all the details: focus on the core elements, whose understanding will really matter for your maintenance fellows.
The three main purposes of making UML class models when developing an app are:
Describing the entity types of the app's problem domain for analyzing and better understanding the requirements for the app in a conceptual (domain) model.
Designing the schema of the app's underlying database (this is typically an RDB schema defined with a bunch of CREATE TABLE statements).
Designing the model classes of the data model of your app, which will be coded, e.g., as Java Entity classes or C# classes with EF annotations.
For 1 and 2, you may take a look at my book An introduction to information modeling and databases, while for 3 you may check out a book on model-based development, e.g. for Java Backend Apps or JavaScript Frontend Apps.
If your goal is to model the dependencies of your app, this may indeed be another purpose. However, as argued by #Christope, reverse-engineering a library is itself a big project that may easily consume more time than you have for developing your app.
Introduction
I want to request a lot of advice on a new programming project I am going to start on my own. I am going to be very precise in what I would like to accomplish and in what my basic requirements are. Therefore this is going to be a long question. Please bear with me.
I am going to split the question into five sections:
Real-world problem
Simulation problem
Requirements and preferences
Additional information
List of advice requests
1. Real-world problem
Skyscrapers and large bridges suffer from dynamic wind loading. This means, when designed incorrectly they can collapse due to wind-induced vibrations (this actually happened in 1940: http://www.youtube.com/watch?v=3mclp9QmCGs). To design such structures correctly, efficient number-crunching software is required for analysis and simulation.
2. Simulation problem
There exists a multitude of software capable of either simulating fluid flows or structural mechanics. Many have already been developed for over 30 years and are proven and mature technologies. Writing a multi-physical program capable of simulating both fluid flows and structural mechanics simultaneously from scratch, is therefore unwise. First of all, you would need years of development before reaching maturity and it is very hard to enter a world which has depended on specific software for over 30 years. But more important...why recreate when you can reuse? Instead of pursuing a monolithic approach, I prefer a partitioned approach where I can reuse existing simulation software.
In the partitioned approach I will use software X to simulate flows and I will use software Y to simulate structures. Then I will write my own coupling algorithm which establishes communication between X and Y and uses them to simulate the multi-physical problem (e.g. wind-induced vibrations of skyscrapers or bridges). The reason I use X and Y and not actual software names is because X and Y are supposed to be black-boxes. In no way is my coupling algorithm to be dependent on the implementation of X and Y. The algorithm will only depend on the output of X and Y. This way an end-user can select which ever X or Y is available to them or which ever X or Y is capable of doing what the end-user wants to achieve.
Because I want to use a black-box partitioned approach, software X knows nothing of Y and vice-versa. But how do I simulate the deformation of a bridge without knowing anything of the surrounding air flow and how to I know in which way the surrounding air flow is perturbed by the structure without knowing anything about its deformation? The answer is simple: start with a guess and use an iterative approach to converge to the correct solution. This approach is however very computationally expensive. To reduce the computational cost the coupling algorithm can be written in a clever way using very efficient technologies, not to be discussed here. All I would like to say is that some heavy linear algebra number-crunching is required.
3. Requirements and preferences
What I need to do is:
establish communication between third-party open-source or proprietary software
perform some heavy number-crunching (linear algebra)
visualise results (2D / 3D plotting and animating)
deliver an interactive analysis and development environment
create an intuitive graphical user interface
What I want my software to be:
open-source
cross-platform
extendable through scripts and/or shared libraries
What I am going to use:
C++ for heavy number-crunching
CPython for programming logic
NumPy / SciPy for some number-crunching in CPython
Matplotlib for results visualisation in CPython
4. Additional information
Facts:
one-man project at start, grow to company if successful
primary OS is a KDE-based Linux distribution
Business model:
Free software and basic documentation.
Paid services and elaborate documentation.
5. List of advice requests
I want to do all number-crunching in C++ by writing many functions which individually perform just a tiny task. The program logic is to be contained in a CPython package which executes the entire simulation while relying on the C++ functions to perform the number-crunching. The C++ / CPython algorithm is to be extended with scripts written in CPython (using NumPy, SciPy, SymPy and Matplotlib) to generate and visualise results from raw numerical data. I want to be able to do parallel computing and I need to communicate with several third party open-source AND proprietary software.
To accomplish all that I am going to need a whole bunch of existing libraries/packages/technologies etc. And to all relevant issues I know what I can use, however I do not know what I should use. The best solution is as always to try everything out and see what works best. However if any experienced user can weed out some of the more unlikely candidates I would gladly receive his or hers advice, suggestion, pro / con list on:
Glueing C++ and CPython (e.g. CTypes, SIP, SWIG etc.)
C++ linear algebra number-crunching library (e.g. Armadillo, Eigen, PETSc etc.)
Graphical interface development library (e.g. Qt, GTK, wxWidgets etc.)
Software communication and parallel computing (e.g. MPICH, OpenMPI, OpenMP etc.)
CPython 2.7.x or CPython 3.x
NOTE: I have summed some options above, but these are only exemplary and not a limitation to. I am open to everything as long as it is written in C, C++, Fortran or Python. Also I do not expect an answer in all five categories enlisted above from one individual. Let the collective knowledge of the community take care of that.
I thank all contributors and wish you all the best of luck in your own endeavors.
You mention parallelism but not how you intend to make this project parallel. This is a much more complex issue than simply choosing a couple libraries. There are several major considerations required before moving forward.
You mention the intended platform briefly, but you also have to consider whether the simulation will be run on a single computer/node or multiple. Considering that you are doing an iterative simulation of a building, you are probably going to require far more compute power than any one computer can provide. This means that, unless you want to go with a hybrid multiple-process, multiple-thread approach, you are limited to a multiple-process model of parallelism. OpenCL and MPI are then each options for your implementation. (note: MPICH and OpenMPI are each just implementations of MPI, and your code should be agnostic of these) Message passing with MPI is a good general model of parallelism however it can be quite difficult for those not used to working with parallel code. My personal experience is with MPI and some hybrid programming so I cannot say much else regarding your choice of parallel model.
A problem that follows from the issue of the parallel model is that it directly impacts the simulation software. I am not entirely certain how separate you are planning on keeping your algorithm from the simulations. If you plan to have your code fork separate process to run the simulations, you will have issues with cross-platform support as you may not have the luxury of being able to run arbitrary simulations in this manner. If you instead intend to run the simulations within your software, the parallel model has to be consistent throughout. Although this puts limitations on the black box strategy, it may make the entire thing that much more feasible.
A good deal has already been said about applicable libraries. I don't have any more to say about specific libraries that hasn't already been said. Just keep in mind that many of the same issues have to be addressed with these as when running the simulations.
TLDR: Parallelism should not be looked over. You need to know which parallel model that you will be using before making decisions on libraries.
Graphical interface development library (e.g. Qt, GTK, wxWidgets etc.)
If your "primary OS is a KDE-based Linux distribution", then QT wins this one hands down.
Logic behind this:-
KDE is writen in QT. A QT app running in KDE is an eagle in the air! It's in its element. With KDE Being target number 1, your QT GUI will most likely work out of the box without users having to download additional gui libs. Your GUI will also look super native.
QT is the most portable of the three. (you mentioned "primary OS", hinting that other platforms might follow). Therefore with qt you can port to Windows, OSX, GNOME, Embeded Linux, Android, Symbian, HAIKU, Solaris ..etc
QT has arguably the best RAD tools of the top three cross platform GUI libs (IMHO). Think QTCreator vs wxSmith vs Anjuta/Glade.
wxWidgets on linux is basically a wapper for GTK+ (v1 to v3) + additional helpers. Tho I preffer it over GTK. It also wraps around X11 and motif but trust me chief, you will not like those ports.
wxWidgets portability is not as seamless as one would think. Each port is a totaly different implementation, each wrapping totally different backends! I once ported a small app that uses wxDataViewCtrl with a custom tree model. SIGSEGVs became the order of the day. So I eventually decided to go with the generic wxDataViewCtrl (that looks funny in GTK+3). I still like wxWidgets tho.
NB: Consider also using the latest web technologies for the C&V part of the MVC (model view controller).HTML5+CSS3+JS can be run by a web-view widget on a desktop app. All the above 3 GUI Libs sport this control (for wx, it's wx2.9.3 and above).
Web technologies:-
Have (arguably) the fastest time-to-market of any GUI lib.
Have (arguably) the most available and affordable developers of any GUI technology today.
Produce the most stunning UIs of any GUI lib.
Produce the least "RIGID" UIs of any GUI lib....you can rotate a gui element e.g. a html table around any axis with fancy animation just by mouse over, without any programming overhead!..no js..no c++..nada!
CPython 2.7.x or CPython 3.x
- CPython might not be well suited to your project's requirements (I think) chiefly because of the mutex monster that is the Global Interpreter Lock (GIL) bottleneck.
Maybe PyPy would be a better python implementation for your project?
By the way, have you also considered:- Javascript on V8 vs. Python (PyPy,CPython et. all)?
Javascript run by V8 can interact with Native Code (c++) sort of like Ctypes with python
I also came across this interesting blog (JS on V8 vs Py).
Possibly, gmp. You can find more details here: http://gmplib.org/
sounds like premature optimization. You need to write code, a lot of code, put lots of prints everywhere to get statistics, then try at least two different approaches to get a benchmark and then make a reasonable decision. There is no replacement for doing the work, anything else is just handwaving.
I am currently looking for a discrete event simulator written for C++. I did not find much on the web written specifically in OO-style; there are some, but outdated. Some others, such as Opnet, Omnet and ns3 are way too complicated for what I need to do. And besides, I need to simulate agent-based algorithms capable of simulating systems of thousands of nodes.
Does anybody know anything suitable for my needs?
Others have good direct answers, but I'm going to suggest an alternative. If I understand you right, you want a system in C++ or such where you can post events that fire in the future, and code is run when those events fire.
I had a project to do like this, and I started out trying to write such an event system in C++ and then quickly realized I had a better solution.
Have you considered writing your program in behavioral Verilog? That may seem strange to write software in a hardware description language, but a Verilog simulator is an event-based system underneath, and behavioral Verilog is a very convenient way to express events, timing, triggers, etc. There is a free Verilog simulator (which is what I used) called Icarus Verilog. If you're not using Ubuntu or some Linux distro with Icarus already in a package, building from source is straightforward.
I would recommend having a second look to OmNet++. At first sight it may look quite complex, but if you look it into more detail you will find that most of the complexity is in the network add-on (the INET Framework). Unless you are going to do a detailed network simulation you do not need the INET.
Using OmNet++ core is not specially difficult and it may be simpler than other similar tools.
You may want to have a look to an intro.
One of the things that makes OmNet++ attractive to me is its scalability. Is possible to run large simulations in a desktop. Besides, it is possible to scale the same simulation to a cluster without rewriting the code.
You should consider SystemC, although I'd also recommend taking a second look at OmNet++.
We use SIMLIB at my school. It is very fast, easy to understand, object oriented, discrete and continuous simulator. It might look outdated but it is still maintained.
There is CSIM from Mesquite Software which supports developing models in C, C++ and Java. However, it is paid-commercial, AFAIK.
Take a look at GBL library. It's written in modern C++ and even supports C++0x features like move semantics and lambda functions. It offers several modeling mechanisms: synchronous and asynchronous event handlers, preemptive threads, and fibers. You can create purely behavioral, cycle accurate, and real-time models, or any mixture of those.
The (directed) graphs represent finite automata. Up until now my test program has been writing out dot files for testing. This is pretty good both for regression testing (keep the verified output files in subversion, ask it if there has been a change) and for visualisation. However, there are some problems...
Basically, I want something callable from C++ and which plans a layout for my states and transitions but leaves the drawing to me - something that will allow me to draw things however I want and draw on GUI (wxWidgets) windows.
I also want a license which will allow commercial use - I don't need that at present, and I may very well release as open source, but I don't want to limit my options ATM.
The problems with GraphViz are (1) the warnings about building from source on Windows, (2) all the unnecessary dependencies for rendering and parsing, and (3) the (presumed) lack of a documented API specifically and purely for layout.
Basically, I want to be able to specify my states (with bounding rectangle sizes) and transitions, and read out positions for the states and waypoints for each transition, then draw based on those co-ordinates myself. I haven't really figured out how annotations on transitions should be handled, but there should be some kind of provision for specifying bounding-box-sizes for those, associating them with transitions, and reading out positions.
Does anyone know of a library that can handle those requirements?
I'm not necessarily against implementing something for myself, but in this case I'd rather avoid it if possible.
Hmm, GDToolkit (or GDT) looks okay: many of the images in the tutorial look pretty nice, and it doesn't look like it's terribly complicated to use.
Edit: But checking the license, it looks like it's commercial software :-(. Whoops!
OGDF is under the GPL.
Pigale is also under the GPL.
GoVisual is commercial software, but it looks like it starts at $1800 for one developer.
I was dealing with a similar problem earlier this year. One important input parameter for a decision however is the expected number of nodes.
I decided to use the Browser as the GUI and therefore looked for nice Javascript libraries, one i came across was wireit, it is very well suited for technical layouts (and also editing with drag and drop and "on the fly" layouting). You could easily connect that to your c++ by running a small webserver in a thread (You will need some kind of eventloop/thread thingie for GUI anyways).
Well just my 2 cents.
Although the answers so far were worth an upvote, I can't really accept any of them. I've still been searching, though.
One thing I found is AGLO. The code is GPL v1, but there are papers that describe the algorithms, so it should be easy enough to re-implement from scratch if necessary.
There's also the paper by Gansner, Koutsofios, North and Vo - "A Technique for Drawing Directed Graphs" - available from here on the Graphviz site.
I've also been looking closely at the BSD-licensed (but Java) JGraph.
One way or the other, it looks like I might be re-implementing the wheel, if not actually re-inventing it.
Here is a good collection of Graph Libs with comparison and searching functionality:
http://gvsr.polytech.univ-nantes.fr/GVSR/task?action=browse#
Maybe you find a lib which fits for you.
I am attempting to use the pipe interface to gnuplot (a standard one gnuplot_i.{cpp,hpp}) in order to generate a real time display of values that are continually changing within another program written in C++. This works ok but I wanted to see if anyone had any suggestions for improvement.
This implementation contains a convenience method to plot a single vector and 2 vectors as a 2D plot. It achieved this by writing out to a temporary file via a standard library call to the mktemp function and then using that as input to a gnuplot plot call. This generated too many temporary files and didn't appear to work well when the update rate on the plot is high (maybe IO limited at a point). I have decided to use the '-' pseudo file in the plot call and just send the vectors directly to the pipe (ended with a single line with "e" on it). This works better but is still not great.
Is there a slicker way to do what I am attempting to do than to continually regenerate the plot when the values have changed? How often is it safe to update the plot with new information? Alternatively, maybe there's a much simpler way to achieve what I am trying to do?
#Andy Ross
I have no "requirements" per se. What I meant by slick was that maybe there was a more elegant approach to doing what I was attempting while still using gnuplot. Although elegant is subjective, I find the approach I am presently taking particularly inelegant. What I meant by safe was whether anyone knew at what update rate there would be IO problems (e.g., latency, lock-up of display, etc.) with said approach.
I'd like to avoid using a toolkit for the following reasons (my short-list at least).
I have found that they are generally nontrivial to install properly on different architectures especially as non-root (and when they require dependencies that aren't standard across OSes).
They incur an additional compilation dependency for other people using this software.
There doesn't appear to be any real standard that most people use for this purpose afiak (myself as well as most people I work with generally just saves off log type files and does post run analysis in MATLAB).
I know/learning gnuplot syntax. I do not know superPlottingApiXX's syntax.
The feature set of gnuplot is almost ideal for the types of things I'd like to be able to do with this software.
However, if you have any particular suggestions in terms of C/C++ plotting libraries that seem like a good fit given the above list I am always interested in suggestions (warning: I have already looked around a good bit to find them).
gnuplot-cpp is an object-oriented C++ wrapper interface around a POSIX pipe connection with Gnuplot.
The example file compiled right away and the interfacing code looks decent; I'll be trying it in my current project.
there is a C2gnuplot library I wrote few years ago. It is very simple but may give you some tips. Basically it uses FIFO files to pass data into Gnuplot.It is able to generate animation from the plots. Here is a video created with the app. I hope this will be useful for you.
Slicker? Safe? Can you be more specific about your requirements?
It sounds like you are trying to do an animated visualization with a tool designed for generating static images. If your display is as simple as you say, why not write a quick GUI app (using the toolkit of your choice) to do the drawing instead?