3
$\begingroup$

I am a beginner in computational science and programming. I am doing research in non linear solid mechanics analysis and using C++ for coding. I have been exploring various finite element open source programs and saw some nice works like Deal.ii, FEniCS, OOFEM, libmesh. But as a beginner in C++ programming and finite element , documentation of these programs are beyond my comprehension and confusing. I would like to see some simple object oriented C++ codes for solving finite element problems. My objective is not studying finite element analysis but to understand the implementation of algebra behind it in C++ Object oriented frame work.

Regarding my work, I am clear about the procedures and concepts in my mind. I have made a prototype in MATLAB. Since MATLAB program takes too much time to get the result I decided to switch to C++ considering the ease of future work. But various data structures in C++ makes me troubled to select appropriate storage and structure for nodes, elements, constraints and loads. In MATLAB I imported prepared data (nodes, element connectivity, loads and boundary constraints) from spread sheet and used in built functions for calculations. In the C++ implementation, I am thinking to use a text-file (like in Abaqus/Calculix) for input. How do I implement it?

I am searching for a well commented small finite element program source code for solving plane stress problems, like the kind of programs some university is using for teaching. I went through the book of S D Rajan, Numerical methods in C++ and got some insights about C++ data structures but still I need to go through some source codes for developing my own program. In later stages of my research I can make use of existing finite element libraries like Deal.ii and FEniCS.

$\endgroup$
  • $\begingroup$ You might want to take a look at FeaTure: utwente.nl/ctw/tm/research/NSM/software/feature It is small enough to be unintimidating but has a fair bit of functionality. A downside is that it doesn't appear to be under active development or have a large community associated with it. $\endgroup$ – Bill Greene Sep 21 '16 at 11:37
  • $\begingroup$ I don't like C++ very much, as one needs to import libraries to plot figures. What libraries do people use for figures? $\endgroup$ – feynman Dec 22 '18 at 10:51
4
$\begingroup$

Specific answers to this question are probably time-limited. However, the following general approach (from the great Eric S. Raymond) works very well:

  1. Rule of Modularity: Write simple parts connected by clean interfaces.
  2. Rule of Clarity: Clarity is better than cleverness.
  3. Rule of Composition: Design programs to be connected to other programs.
  4. Rule of Separation: Separate policy from mechanism; separate interfaces from engines.
  5. Rule of Simplicity: Design for simplicity; add complexity only where you must.
  6. Rule of Parsimony: Write a big program only when it is clear by demonstration that nothing else will do.
  7. Rule of Transparency: Design for visibility to make inspection and debugging easier.
  8. Rule of Robustness: Robustness is the child of transparency and simplicity.
  9. Rule of Representation: Fold knowledge into data so program logic can be stupid and robust.
  10. Rule of Least Surprise: In interface design, always do the least surprising thing.
  11. Rule of Silence: When a program has nothing surprising to say, it should say nothing.
  12. Rule of Repair: When you must fail, fail noisily and as soon as possible.
  13. Rule of Economy: Programmer time is expensive; conserve it in preference to machine time.
  14. Rule of Generation: Avoid hand-hacking; write programs to write programs when you can.
  15. Rule of Optimization: Prototype before polishing. Get it working before you optimize it.
  16. Rule of Diversity: Distrust all claims for "one true way".
  17. Rule of Extensibility: Design for the future, because it will be here sooner than you think.
$\endgroup$
1
$\begingroup$

This is not really a program as much as a big repository of codes. John Burkardt from Florida State University maintains a rich collection of scripts in C++, Matlab and Fortran for a large range of problems. You can check out the FEM 2D library or go up a level and look at other codes listed there. These have good commenting on them and you can look at the source directly.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.