Elmer Integration (GSoC) - Activity Log

Hi everyone,
in this topic I will post regular (at least weekly) updates about progress and news on the elmer integration gsoc project. My proposal for this project is avaliable on google docs: https://docs.google.com/document/d/1mX34Hy00eTQ42R4eObHOVzElMbCpKAUYtMO_bwQWr8E/edit?usp=sharing.

Currently I’m trying to find similar projects that could help me out as well as making contatct with the elmer community. Also I’m reading lot’s of source code and experiment with differnt ways of exporting/importing the mesh scene for elmer. The first post will follow soon, so stay tuned :wink:

Not being very familiar with FEM I was wondering what a multiphysics workbench with Elmer would bring to the table so I took the opportunity to attend a COMSOL webinar. COMSOL being a commercial product and I am now looking forward to Elmer integration.

If you are interested in what commercial multiphysics software has to offer COMSOL offer some interesting Webinars at https://www.comsol.com/events/webinars. Might be worth checking some for ideas for the Elmer workbench.

Hi everyone,

The first “week” of coding is over and my first activity log overdue.

So what have I been up to? Yesterday I already ran my first simulation from within FreeCAD. Today I did a little polishing work, improved error handling and so on. I also created a small demo video for you guys to show off what I accomplished till now:

https://archive.org/download/elmerintegration_201706/elmerintegration.webm

Most of whats happend in the video should be quite straight foreword. One new thing I created is the free text input because phase 1 of the elmer integration project doesn’t include support for FreeCADs constraint objects. Right now the free text input (for the SIF file) is prepolulated with a SIF text that replicates the CalculiX fem demo (showen in the video) but the .Text property can be changed to hold every arbitrary string. Whats missing is a editor inside FreeCAD but that shouldn’t be difficult to implement and I plan to do so on tuesday next week. On monday I plan to implement futher tests and fix a few known (to me xD) bugs.

As soon as the code is “ready” I will “publish” it on https://github.com/drhooves/FreeCAD.git elmer_integration. I expect this to happen on wednesday next week (including the GUI).

There is one but I don’t know where it’s implemented. In the FEM prefs under the Calculix tab there is an option to use the internal one or specify an external one.
Cool video.

Great video! Please keep producing more of those! :wink:
Have a look at the macro editor of freecad, it might be usable/modificable to edit your sif file…

Sorry for asking off-topic: Is there a straightforward way to use the macro editor within python?
I once had a similar problem and after some trying I just used the stringlist property editor, but this is obviously not optimal.

@m42kus: nice video! :slight_smile:

Best wishes
Johannes

Hey,
Unfortunately I was sick the last few days and didn’t get as much done as I planned. Because of this the GUI (for FreeText) will take me one or two days longer than expected. Today I added a new test and also improved the handling of external calls to ElmerGrid and ElmerSolver.

There are a few different examples of editors, but none fits my usecase. The macro and calculix editor both operate directly on files and not document objecs. The spreadsheet editor may be a better example because it operates on document objects. As far as I can tell right now I have to subclass MDIView and embed a QPlainTextEdit into it. If there is an easier way please let me know :wink:

Indeed there is currently no python way to open a macro editor.

However the code that opens it is fairly simple (src/Gui/DlgMacroExecuteImp.cpp, L289), one could easily add some FreeCADGui.openMacroEditor(filepath) function. @ma42kus if that is useful to you, tell me and I’ll add it. But that would add maybe a lot of hassle, you’ll need to save your text to a temp file, then watch that file for changes… It might be easier to stick to your current way.

BTW, in Path there is a quick-and-dirty text editor too, that even does syntax highlighting. Might be useful to you… src/Mod/Path/PathScripts/PathInspect.py

I’m really sorry, my question is off-topic again :mrgreen:
Is it possible to add for these type of tasks a new property (e.g. PropertySourceCode) which has a property editor with syntax highlighting? I think such a property could at least be useful for all the FEM guys who implement their own solver since they have to prepare a script file at some point in the solution process for communication with the solver.

However the code that opens it is fairly simple (src/Gui/DlgMacroExecuteImp.cpp, L289), one could easily add some FreeCADGui.openMacroEditor(filepath) function. @ma42kus if that is useful to you, tell me and I’ll add it. But that would add maybe a lot of hassle, you’ll need to save your text to a temp file, then watch that file for changes… It might be easier to stick to your current way.

I don’t know if you need more but there is already a generic open function that will open a Python editor when opening a py file or script.

FreeCADGui.open("file.fcmacro")

The file formats that open the Python editor are .py, .fcscript, .fcmacro

One more “thing that was in FreeCAD since the beginning but that I only discovered now” for my collection :smiley:

Thanks for all the suggestions! For now i’m going to stick to implementing a EditorView that directly edits the “Text” property.

Hmm, I think one way to implement this would be a PropertyItem that only shows a button which will open a full size EditorView? Don’t know if that makes sense though. Maybe a hidden Text property and a doubleClicked method that opens the editor would be sufficient. The syntax highlighting part would have to be implemented separately in the editor anyway (doesn’t matter which property type).

A new document object type TextDocument would be quite helpful. Maybe with a Text and a FileType property? Or does something like that already exist?

@wmayer nice one! I was not aware that opening those files is so simple. @m42kus I also thought about such solutions, but since I am not experienced enough with the FreeCAD API I didn’t know how to implement e.g. PropertyItems with just a button to do something. The other solution, you suggested is also interesting and I think both would be useful to all users who need a scripting interfaces besides the macros. Unfortunately I am not aware that these user defined document type, you mentioned, exists. :frowning:

Best wishes
Johannes

So, today I implemented the before mentioned TextDocument object as well as an editor which operates directly on the Text property of the TextDocument. There are no python bindings yet and I still need to test it a little.

I think i should handle that change seperately from the Elmer integration project? Maybe even make a separate topic to discuss it?

If you added a new object type outside of FEM, it’s always a good idea to separate that in another branch, and submit a pull request only for that. It makes it much easier for us to merge, and afterwards to find /identify issues, and it’s cleaner when pull requests are either for core features only, or module-only.

If you wish to discuss that further, it could be in this thread or another, as you prefer!

Time for a new status update and I also have a new video to share :smiley:

https://ia801509.us.archive.org/1/items/elmerintegration_gui/elmerintegration_gui.webm

The video shows the TextDocument object together with the new TextDocumentEditorView MDIView widget. The SifFile is atm only a TextDocument which is by default initialized with the text shown in the video. I consider phase 1 to be finished now (excluding bug fixes of course). The code used to record the video above is avaliable at https://github.com/drhooves/FreeCAD.git elmer_integration. Feel free to test it and report in this thread. Feedback is very welcome :slight_smile:

The implementation of the TextDocument is far from perfect but it works for the Elmer Integration project. I think that there would be much potential in a more general approach to text documents in FreeCAD. Im on holiday for the next three days but I will defenitely start a discussion about that after I’m home again.

I don’t know jet how much I’m able to reply to comments the next days but as soon as im home I will do so at once :wink:

My plan for next week
As I already said I will start a discussion about text documents in FreeCAD. That shouldn’t take too much time though. Most of time time next week will go to fixing bugs and initiating the development of a sif-file-generation library, hopefully together with the guys behind https://github.com/physici/ElmerSalomeModule. They already showed some interest into doing so :wink:

Excellent feature! You will certainly get hundreds of ideas of improvements, but it seems to me already pretty useful as it is.

Hi, sorry for the long delay since my last update. I was very busy with a project for university last week and couldn’t get as much done as I hoped.

Anyway, this week I coded the sif file generator and also added support for the fixed and force constraint objects. The video below shows a run that solves the example 3D beam analysis with elmer.

https://ia601504.us.archive.org/35/items/elmerintegration_beam/elmerintegration_beam.webm

As you may have noticed in the video I generated MeshGroups before solving the analysis. Right now this is required because of the way I export the mesh: export unv → convert with ElmerGrid to native elmer format. Without groups I wouldn’t be able to refer to the faces/body in the sif file.

There a feature in FemGmshTools that creates groups for each constraint, but as I can tell they way it does it is problematic: The native elmer mesh format only supports one name for each boundary element. And if two constraint objects refere to the same face FemGmshTools creates two names which can’t possibly work for elmer.

There are other issues with meshing about which I’m going to write more tomorrow. It’s going to include the problems that I see (for the Elmer Integration project as well as more general ones) and solution proposals I already thought and talked about a little with HoWil.

Edit: I’m going to rebase the code used for the video above tomorrow into the elmer_integration branch.