Using Elmer as a library from an external software

Discussion about coding and new developments
Post Reply
Marazo
Posts: 4
Joined: 10 Oct 2018, 11:06
Antispam: Yes

Using Elmer as a library from an external software

Post by Marazo »

I'm looking into ways of using Elmer as an FEM solver for a program that I'm writing. I want to get everything done from a one single piece of software.

Normally using any library that is compiled to a dll is just a matter of importing the dll to project and then, well, starting to use it. Now the first thing is that I'm stuck using C# and Elmer is done in C++. This complicates some things, but still everything should be doable?

Or is there something I'm getting completely wrong here?

Has anyone done such a thing?
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Using Elmer as a library from an external software

Post by mzenker »

Hi,

ElmerSolver is (mostly?) written in FORTRAN. I think the best and simplest way to go is to let your software write a sif file and launch ElmerSolver using a system call.

HTH,
Matthias
Marazo
Posts: 4
Joined: 10 Oct 2018, 11:06
Antispam: Yes

Re: Using Elmer as a library from an external software

Post by Marazo »

Aah.

Ok. Thanks.
That's kinda what I was afraid.

But if that is the only viable way to go, I'll have to look into it.
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Using Elmer as a library from an external software

Post by mzenker »

What would be the advantage of using Elmer as a library?
Marazo
Posts: 4
Joined: 10 Oct 2018, 11:06
Antispam: Yes

Re: Using Elmer as a library from an external software

Post by Marazo »

I imagine it would simplify the distribution of the program. Modelling, calculating and reporting would be done all inside one program. Also "communicating" between independent pieces of software is always trickier. That being said, I do realize you can launch external software and still use them as a one piece.

I haven't really studied Elmer yet in detail, so this is just thinking out loud type of thing. I've checked some other FEM engines that are also distributed as a libraries and was wondering if similar could be achieved with ElmerSolver.
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Using Elmer as a library from an external software

Post by mzenker »

I see.
Note that Elmer provides mainly the FEM solver. So for preprocessing (geometry definition, meshing) and postprocessing (results analysis and display), you will need additional software or do it with your own program.
There are attempts to use a FEM solver (Elmer or other) from within other software to build kind of a complete FEM suite:
  • FreeCAD (freecadweb.org) has a FEM workbench using Elmer
  • onelab (onelab.info): This is an addition to the gmsh meshing and postprocessing tool. They use the GetDP FEM solver, but seem to have also run Elmer within their framework
  • Salomé (salome-platform.org): There is a very basic Elmer plugin (see viewtopic.php?f=9&t=4482) which can be used from within Salomé.
Maybe you will want to check those out before reinventing the wheel... ;)

HTH,
Matthias
Marazo
Posts: 4
Joined: 10 Oct 2018, 11:06
Antispam: Yes

Re: Using Elmer as a library from an external software

Post by Marazo »

Thanks.
I'll definitely take a look at those.

Truth be told, I actually have major parts of the software already written. And it's somewhat in use.

The real problem is that the custom FEM that has been written is too basic and not a 'real' solver. It's written to solve only certain really specific problems. And as it so often happens things tend to evolve, what once was enough is not anymore. And I don't want to keep on writing that custom FEM if I can get away with using already built library.
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

Re: Using Elmer as a library from an external software

Post by mzenker »

Ok, then using Elmer instead of your custom FEM solver might be an option.
You will need to prepare a mesh, build a sif file, launch the solver and import the result back into your program. How much work this will be depends on what is already implemented in your program.
If you need more information, don't hesitate to ask.

Matthias
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Using Elmer as a library from an external software

Post by raback »

Hi

Elmer is usually used as an executable. There has been some rare uses of Elmer as library but it is clearly not designed so much to be a library.

Is your problem I/O critical. Often it is a simple setup to have different components coupled via the file system. ElmerGUI and Paraview always operate this way. ElmerSolver is designed to be even massively parallel which is usually not a good match with graphical operations.

-Peteru
Post Reply