Open looooo opened 7 years ago
I have no own fork of FreeCAD. I just could fork from your's. But I am rather unexperienced with branching. Could you shortly outline a typical workflow, if I only want to work on your generical solver proposal branch? (My other project is only a python workbench, so there's no interference with the FreeCAD repo necessary.)
Uh, nevermind. Maybe I should have read http://www.freecadweb.org/wiki/index.php?title=Source_code_management :-)
Good article. How far did you come? I would do like this:
fork with github
clone your fork
add freecad master as upstream
add my branch as sidestream :-) 5.a.1. checkout the generic solver branch 5.a.2. checkout a new branch where you want to write code alternitive 5.b.1 checkout a new branch where you want to write code 5.b.2 reset this branch on the sidestream/genericSolver
make changes to the code
push to github (simple with git push, there will be a message how to upload the branch)
make a pull request with github (you can choose on which branch, directly freecad master or my branch or any other...)
I could also add you as a contributer to this repository, but I think it's not possible to give access only to one branch. So I think it's better to take the pullrequest approach. This is maybe a bit more difficult for you, but it's the way how developers at freecad work, so maybe it's a good idea to learn it anyway. And once you have worked a bit with git, it's not difficult anymore...
Thank you for the introduction. I didn't understand the reset branch step at 5.b.2. Could you please explain that part shortly? I have no problem with the pullrequest approach. I think the contributor approach is only useful for a small project. And you're right: I have to learn it anyway sometime. My first pull request will only contribute to your proposal document anyway so I cannot mess up the code ;-)
Somehow I have messed with the lists...
if you have created a branch you can simple reset the branch by the state of another branch. git reset upstream/master (or whatever branch) Sometimes this will fail. but if you want to have a local branch that looks exactly the same as any other branch you can pass the --hard option.
"git checkout -b new_branch" creates a new branch which is identical to the previously active branch.
OK, I had your branch and created my own with git checkout -b 'genericsolver_joha'. afterwards i renamed the file due to a typo in the filename and did git commit -a -m 'file renamed'. then i did git push and he told me that everything is up to date, although i changed the file. what did I do wrong?
what was the message at git commit -a -m ? normally you have to add a new (renamed) file with "git add file_name" Ah I see, you are on a good way :-)
git commit -a -m 'msg' adds all changed files to a commit and puts msg on that commit. now with the push i did git push --all -u now there are two branches on my fork: genericsolver_joha and genericSolver. is this correct?
now i will delete my branch here at github. if i want to have the newest changes to your branch i have to do: git fetch loooo/genericSolver? then git checkout -b mynewestchanges and git commit -a -m, git push --all -u. then at some point pullrequest, commit commit commit, and after merge delete the branch mynewestchanges again. same game again and again?
hmm, never used that command. "git push --all -u" most likely will add all your local branches to github. I don't think this is what you wanted. But it's no problem to delete a branch on github... "git branch -D branch_name" "git push -u" would have been enough.
I have merged your commit. There were actually 2 commits. The one you have made and one merge-commit. Next time I will try to avoid this. I think there is also an option to use re-basing as merge-strategy..., which will lead to a cleaner history
you do not have to delete your branch.
after fetching you can do this: git rebase looooo/genericSolver
this will add all my commits to your current branch. (but at the moment the branches are the same. so nothin will happen)
hm I still don't understood it. too much new things to learn :D could you please show me an appropriate workflow loop (from update from your branch to pull request and to be ready for the next workflow loop)? my git behaves also strange or somehow different than yours :-( sorry that i ask these dumb questions, but i only contributed to a small project where pull requests only without branching are sufficient :-(
ok I have now rebased on freecad/master. So you can try to update your branch:
git checkout your_branch
git rebase looooo/genericSolver
git push origin +genericsolver_joha #(the + is necessary, I don't know why, but it's always necessary for rebasing, maybe because rebasing can be dangerous :-)
now you add things, change stuff ...
git add .
git commit -a -m "message"
git push
and then do a pull-request... thats all.
oh oh, somehow the last file rename has been vanished. ok, i'll try your loop and see if it works. thanks btw. for writing all this stuff down :D
ok now you can see my second pull request: but there are conflicts. i don't understand why. :-(
Somehow your first commit is not there anymore. Maybe you rebase your local branch on my branch again.
just the rebase command or do i also have to perform the command with push origin +genericsolver_joha?
I have merged your pull request manually. What I have done is the following:
git remote add joha "your_branch"
git fetch joha
git checkout joha/genericSolver_joha
git checkout -b temp_branch
git rebase origing/genericSolver
# checked the log
git log
# git very nice :-)
git checkout genericSolver
git reset temp_branch
git push origin +genericSolver
That would be the way how you could have done it. Now you should look to sync with my branch. Maybe it's best to delete your branch and create a new to not mess up somethings again :-) Or simple "git reset looooo/genericSolver" should also work. Updating your github branch with "git push origin +genericSolver_joha".
Yesterday I wanted to compile freecad, but I have big troubles with that at the moment. Especially as we need the netgen/occt7 package for fem... And there are so many other new things... I will try to get anaconda builds updated first and then go on with this branch.
I am also messing around a bit :-) I have renamed your commit, because there was the "rename file" twice. Hopefully this is ok. You can edit commits with "git rebase -i HEAD~2" where 2 is the number of commits you want to go back to make changes. With this you can edit commit messages and join commits. But this all is a bit dangerous when there is some bigger work involved. So trying it out first on a temp_branch makes always sense.
Thanks for repairing my mess :-). My main problem is, that i don't understand most of the commands really. And reading in the git help doesn't help because there are too much information and no simple examples (it's getting to difficult for an unexperienced user). Anyway i also set up a new freecad clone within my docker image with fenics and have to finish compiling, therefore there is no hurry necessary :-) but i certainly will ask a few questions about the workflow: e.g. is our workflow to only have two (genericSolver and genericsolver_joha) branches and do pull-requests from one to another or do i have to create a new branch for every changeset i'll intend to do?
Now on my docker I merged my local genericsolver_joha branch from your looooo/genericSolver branch and got 38 commits from files which are in other parts of FreeCAD. is that correct? did you a merge from the FreeCAD master? I am sceptics with the rebase command. Why not that way:
i think this works because we are only two developers. as far as i understood performing rebase in my branch from your branch is ok, but the other way around is not ok. is this correct?
Ah now I see: Your branch is 41 commits behind FreeCAD/master and i forked from FreeCAD/master. Therefore the large difference.
hmm i have rebased on freecad/master yesterday. So there shouldn't be that much commits between these branches.
regarding merge vs rebase: Doesn't git merge add a merge commit message?
I have rebased again. git diff FreeCAD/master shows only proposal stuff. So this branch should be up to date right now.
i think this works because we are only two developers. as far as i understood performing rebase in my branch from your branch is ok, but the other way around is not ok. is this correct?
The pull-request on github has the option to merge with a rebase. That is was I wanted for your first pull request. But I have choosen merge, and then there was this merge commit, which is not really necessary. So I think rebasing my branch on yours if you are some commit in front of my branch isn't a problem.
yes, but i didn't push yet. i wanted to know your opinion for that first. As you can see, i made a pull request: But it is still strange. Now there 5 files changed, which is just not correct. It's very complicated to find an appropriate workflow :-(
Ah ok, now we are equal. The pull request clearly shows. And this is how it should be. So i also could substitute the merge by a rebase? Is this correct?
I am wondering what your last pull-request was all about. All commits are already in the commit history of my branch.
rebase is better, beause there is no merge commit.
The last pullrequest was only a test. I wanted to make sure that we are at the same starting point. Sorry for that i am learning the git basics in our forks :-( :-)
No problem. But there is something wrong with your branch. Maybe you simply reset it with my branch: 'git reset looooo/genericSolver' then these two branches are definetly equal without additional merge commits. It could be my fault that the branches diverged that much.... But if you have a clean commit history (no unnecessary merge commits) I could simply accept the pullrequest via github, and we wouldn't have any problems. Maybe this was the problem.
ok. i performed the the git reset status, but my git informed me that my branch is 17 commits behind origin/genericsolver_joha. it asked me to perform a git pull to be up-to-date. is this correct?
Sounds like a little mess ;-). You can simple force to reset and then force the github branch to be identical to your local branch. git reset looooo/genericSolver --hard git push origin +genericsolver_joha
It's quite difficult to help you with git-stuff. Maybe the best is if you simple mess around a bit, and read git tutorials on the internet. Also there are some post about git worflow for freecad in the forum...
Yeah I will have a look at those forum tutorials. But anyway thanks for your patience and your help! Until i figured out how these workflows work ;-) I'll read your contributions for the genericSolver anyway and i am still interested in contributing myself. so please feel free to discuss your ideas here or via new git commits. I still have to figure out how docker/fenics with FreeCAD and x11 in combination works, therefore it is still no large problem that i am rather unexperienced in git. do you have any literature/tutorial on how the FEM workbench is constructed internally (besides reading the source code ;-))?
do you have any literature/tutorial on how the FEM workbench is constructed internally (besides reading the source code ;-))?
not really. But I think we do not need to get into fem-wb too much. The interface for the solver should be quite simple. Using existing boundaries should be also possible. The additional generic property editor will be the hardest part. But not necessary for a first implementation to test the interface. The big problem is the compilation of freecad with all the latest tools :-)
Yeah I will have a look at those forum tutorials. But anyway thanks for your patience and your help! Until i figured out how these workflows work ;-) I'll read your contributions for the genericSolver anyway and i am still interested in contributing myself.
I also think the idea is really worth to take to the next level. I do not know of any tool where fem is implemented to cad in this way. I like the idea. Also I would like to use the generic solver on other tools I have written: https://github.com/booya-at/paraFEM, https://github.com/booya-at/paraBEM, https://github.com/looooo/stVenantTorsion
Wow! These are very cool tools! Why did you implement them? If I may ask: What is your profession? And where do you learned all this FEM stuff? :-]
thanks for the kind words. The para stuff is mainly for designing para-gliders. By now all the stuff was developed either as university-projects or as free-time projects. So nothing commercial involved. All is based on quite old methods. The BEM library is based on algorithms found in low speed aerodynamics and the FEM-library on a quite old article (~1984) Explicit Algorithms for the nonlinear dynamics of shells. You can find many interesting documents on FEM, BEM, ... on the internet... But fenics is for sure also a good way to learn FEM, allthough I find virtual energy based methods easier to understand, then the weak-formulation of pde approach. (In theory it should be the same.)
I progressed with the conda build process. All latest dependencies of freecad are available. Building freecad also works. So theoretically everything should be ready to start the implementation. How far is the docker approach? What version of fenics are you using? I will try this version: https://anaconda.org/conda-forge/fenics
Thanks for the information! I will also check the literature you recommended. I also looked at the conda-link and saw that the fenics versions, we use, is identical (so mine is 2016.1). I got FreeCAD compiled in a fenics docker image but unfortunately I get no access to my X display such that FreeCAD is not starting its GUI. Therefore I will setup a new docker image starting from the fenics one (is described in the documentation) and just put all the packages into it which are necessary for compiling FreeCAD. Further I will grant the container access to my X display (one section below the "Setup your own docker image" in the documentation). So i think we could soon start our investigations :-))
Is there any literature which gives an introduction into the weak-formulation, which you could recommend? At the moment it seems like black magic for me. (For the Poisson equation it's easy, for linear elasticity it's easy if you know what to do, for generalized biharmonic equations (e.g. Laplace^2 u + alpha Laplace u + beta u = f) I don't know how to reformulate it into a satisfying and easy weak formulation).
Is there any literature which gives an introduction into the weak-formulation, which you could recommend? At the moment it seems like black magic for me. (For the Poisson equation it's easy, for linear elasticity it's easy if you know what to do, for generalized biharmonic equations (e.g. Laplace^2 u + alpha Laplace u + beta u = f) I don't know how to reformulate it into a satisfying and easy weak formulation).
Normally getting a weak formulation involves multiplying by test-function, integrating and using gauss theorem to reduce the order of the derivative. But I have never tried this on any more difficult pde then the poisson-equation. :-) There is also the fenics book available online: https://fenicsproject.org/pub/book/book/fenics-book-2011-06-14.pdf
I think there is another problem. At least with the anaconda fenics package I get this error when importing fenics with freecad. There seems to be a problem with logging.
>>> import fenics
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/lo/anaconda/envs/fc_2_build/lib/python2.7/site-packages/fenics/__init__.py", line 7, in <module>
from dolfin import *
File "/home/lo/anaconda/envs/fc_2_build/lib/python2.7/site-packages/dolfin/__init__.py", line 5, in <module>
import dolfin.importhandler
File "/home/lo/anaconda/envs/fc_2_build/lib/python2.7/site-packages/dolfin/importhandler/__init__.py", line 41, in <module>
__import__(dep)
File "/home/lo/anaconda/envs/fc_2_build/lib/python2.7/site-packages/ufl/__init__.py", line 196, in <module>
from ufl.log import get_handler, get_logger, set_handler, set_level, add_logfile, \
File "/home/lo/anaconda/envs/fc_2_build/lib/python2.7/site-packages/ufl/log.py", line 50, in <module>
if sys.stdout.isatty() and sys.stderr.isatty():
AttributeError: isatty
When I call
>>> import sys
>>> sys.stdout.isatty()
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: isatty
directly in FreeCAD I get the same error. It seems that there are some attributes missing in the FreeCAD python console. But I don't know why this should be the case. This probably would also happen when I perform the same operation with my docker image. Maybe we should ask at the FreeCAD forum.
Edit: I searched the forum for an entry about this, but I didn't find anything.
Edit2: I think the critical object is https://github.com/looooo/FreeCAD/blob/master/src/Gui/PythonConsolePy.cpp#L41 because it's the implementation of the stdout object used in the FreeCAD console. As you can see, it has no isatty attribute. For the corresponding Stderr class it's the same.
Weak formulation: Yeah this multiplying by a test function and integrating by parts is the easy part. But how do you decide how often you integrate by parts. E.g. for the generalized biharmonic equation, you can either integrate by parts several times and always get another formulation. Or the other possibilty is to split the equation into a system of two second order equations and split up the weak formulation also into two formulations of reaction-diffusion equations. It's a little strange, there seems to be no general receipe how to do this.
I had a look how it is done with ipython-notebook. There this function simple returns False. So we maybe should implement this function for freecad in the same way. I will add a request to the freecad forum.
Yes I think so, too. Do you start a new thread or do you add it into the Fenics as a solver thread?
oh, didn't see your edit. Thats nice, you have found this file so fast. So we can do this by ourselvs.
fenics import should work now. Thanks again for finding this file. I have also added a genericSolver and genericProperty icon to the fem toolbox. I think it's now possible to add new functionality without building freecad. I simple link new python files to the build dir. (But not forget to add these files in the CmakeList.txt... https://github.com/looooo/FreeCAD/commit/f47a98cd75f729162e0eed434ce33e91305a6aa5)
I had not that much luck. My graphics driver seems to segfault when I start FreeCAD within the docker image. I have to further investigate this issue. Meanwhile I will have a look at your code ;-).
OK now it works also for me. Time to go to bed ;-).
Would it make sense to open a Wiki here at your fork again (at least for persistent information)? I would like to share my information about setting up a docker image. Maybe it would also be useful for others if you would share your setup information for the anaconda repo.
nice to hear you have figured out the problem.
Would it make sense to open a Wiki yes that is a good idea. writing the proposal as a wiki article would have been the better solution.
another issue with isatty: importing fenics from the freecad console works, but importing fenics inside of a file in fem workbench shows a window with a text "isatty". After importing fenics manually from console, switching to fem workbench works.
Perhaps FreeCAD and fenics expect different boolean values from isatty. Could you show me a picture of this issue?
As a workaround we could do something like FreeCADGui.doCommand("import fenics").
Strange! Where does the change of the workbench "Wechsel von Arbeitsbereich" take place in the source? I grepped through the source and found some VC9 comments about isatty. But nothing which fits into our problem.
I think the traceback is partially reported to this window. Tested the workaround, and it also isn't working. Placing this in the file gives the same error:
import sys
sys.stdout.isatty()
In the freecad-console sys.stdout has no autocompletion for isatty. So there is maybe something wrong with the implementation I have made.
Can you please give me a link to your correction?
TODO
proposal