Topic: Reference angle in beam3d

Hi all,
I want to share with you the implementation of the referenceAngle (mutually exclusive with referenceNode) that we implemented in beam3d (see attachment).

With this mod. you can use:

Beam3d 1 nodes 2 1 2 mat 1 crossSect 1 refAngle 90

instead of

Beam3d 1 nodes 2 1 2 mat 1 crossSect 1 refNode 9

I kindly ask, if you agree and if interested, to include the modification in the next release of OOFEM.

Thanks,
Giovanni

Post's attachments

beam3d.zip 12.32 kb, 2 downloads since 2014-11-04 

You don't have the permssions to download the attachments of this post.

Re: Reference angle in beam3d

Hi Giovanni,

I have two comments;

1.
For submitting changes, please make a patch. Using git you can create patches easily. Under linux you would do

git diff src/oofemlib/fileA.C src/sm/someotherfile.h src/sm/CMakelists.txt    >  my_changes.patch

Under windows, I'm not sure. You can probably find how to make a diff through whatever graphical GIT tools you might be using.

A diff lets us see what specific changes has been done.


2.
Please fix the indent and coding style on the changes.
This might seem picky, but with several authors, different indenting and coding styles, even though it's mostly just whitespace characters, can cause a lot of headaches when there are merge conflicts.

Re: Reference angle in beam3d

Ok, I run uncrustify on both files, I attach the patch obatined via command line in Git under Windows.
Let me know if it is all fine, I'm not so good with Git.

Giovanni

Post's attachments

beam3d_rotationAngle.patch 9.28 kb, 2 downloads since 2014-11-04 

You don't have the permssions to download the attachments of this post.

Re: Reference angle in beam3d

You managed to include a few lines in the beginning that is not part of the patch. You also included some changes from an unrelated files.
Always make patches as small as possible, single out features (rarely will it be all your changes)

I just mention this for future reference. You don't need to include a new file, because it's simple enough for me to delete these other changes myself.

Re: Reference angle in beam3d

Yes, you're right: CMakeLists.txt and constanctfunction.h have nothing to do with beam3d patch.

Some other changes have been done by uncrustify.exe (spaces before and after arguments), I don't understand why, because the other parts of the code in beam3d.c have been mantained unmodified.

Re: Reference angle in beam3d

It's not that strict that all code checked in has to go through uncrustify, though we do it occasionally to the whole code base.
The problem was the tabs used for indenting, which would all be modified if any other developer touched the code later.

If you can set up your IDE to be as close as possible to the uncrustified code (tabs, where to add newlines, etc.) then I wouldn't have bothered to ask you to uncrustify anything.

Re: Reference angle in beam3d

In attachment a further correction for beam3d.

Giovanni

Post's attachments

beam3d.zip 3.01 kb, 2 downloads since 2014-11-19 

You don't have the permssions to download the attachments of this post.

Re: Reference angle in beam3d

Hi Giovanni,

I was planning on merging in these changes now, but the patch is no good.
It has a bad path;
diff --git "a/C:\\Users\\Giovanni\\AppData\\Local\\Temp\\TortoiseGit\\bea541A.tmp\\beam3d-c4e7651-left.C" "b/C:\\oofem\\src\\sm\\beam3d.C"
Your other patch did it correctly, so please remake this one. Patches should be self-contained, so please don't make patches for individual files.


Even better, if you plan on making contributions in the future, I recommend that you learn git and send me a pull-request on github (though sending patches is also OK if it's just going to be a few changes).

Re: Reference angle in beam3d

Hi Mikael,
thanks for the reply. In attachment you can find the patch file for beam3d.h and beam3d.c.

I'm still learning Git, I obtained this patch from command line; until now I was using TortoiseGit, but I want to abandon it because it does not allow to create a single patch file for one or more files.
When I'll learn Git a little deeper, I'll ask you a pull-request.

Giovanni

Post's attachments

beam3d_rotAngle.patch 3.28 kb, 1 downloads since 2014-12-31 

You don't have the permssions to download the attachments of this post.

Re: Reference angle in beam3d

Actually, you would be sending me a pull request (which i could choose to accept, reject, or request changes to be made).

This last patch doesn't contain all the changes, it just fixes the indentation so the critical changes are actually missing.

Re: Reference angle in beam3d

Sorry for that, I hope this will be ok.

Post's attachments

beam3d_rotAngle.patch 8.56 kb, 2 downloads since 2014-12-31 

You don't have the permssions to download the attachments of this post.

Re: Reference angle in beam3d

Since it was a patch to an old version, I'm not sure if everything went in correctly. It seems to work, so you will have to try it out to be sure.


In the future, if someone wants me to include changes it should either be
1. New files (if someone has written a new element/material)
or
2. A pull request on github

Anything else always tends to turn into to much of a hazzle if the patch isn't perfect (and relative to the latest version), like in this case.

I understand that when you first wrote this patch it was relatice to the latest version, but before anyone had time to look at it, it was to late. But, unfortunately, I will still have to require the submitter to do the extra work in the future.

Re: Reference angle in beam3d

I'm learning Git but as a windows user is difficult to interact with your github repository, since all the vs project are not already present and must be recreated. I noticed that other users in your github repo has already used it in windows, so I have just two questions: is it better to merge my current local repo with the master branch in github? or better to have (seems so reading this) all the files in github?

Since it was a patch to an old version, I'm not sure if everything went in correctly. It seems to work, so you will have to try it out to be sure.

I'll try it on the base on the new git cloning I've made from your github; if necessary I'll resend the correct patch.

Re: Reference angle in beam3d

Yes, my github repo should work with windows (we fixed a few minor things recently), but I'm not personally testing VS that often (or ever).
The plan would be to have nightly builds on all supported platforms.

Do not send any more patches for this, since I have already applied this one (with a bit of manual changes) (unless you have to make corrections).
We should have done it via pull-requests to start with, where I allow you to make additional commits until the the changes are ready to be merged.
So, the price to pay for this, is that now both repos (yours and mine) now has different changes, is that a merge is *not* advised (there would have duplicated changes, and probably a lot of ugly merge conflicts).

Side note: sending patches (which is still a good way if you only plan on making a single change) stems more from the old SVN days, where you couldn't make any commits if you weren't granted access. Now, with distributed version control, everyone can work on their own copy, and then the maintainer merges changes regurlarly.


The best thing you could do now, is to do a fresh clone of my github repo (any repo would have worked, but I have only merged your patches into my github repo yet), and if you have other changes, copy over those files and make a new commits for those changes again. From here on out, we'll stick to pull requests.
The main problem is that of CMakeLists.txt changes you had to do for PETSc. I could selectively avoid pulling in those changes, but a better solution would be to solve this in a satisfactory way once and for all.

The easiest way is to fork from my github account (so that you can send pull requests). You can on your local machine add however many repositories you want. I have my github repo, and the oofem.org repo added to my local repos, so that I can pull in changes from either easily.

Re: Reference angle in beam3d

Got it.
You said to have already applied the patch for beam3d, but I cannot still see it in your github.

Re: Reference angle in beam3d

I hadn't pushed the changes from my local machine yet. They are there now.

Re: Reference angle in beam3d

Thanks. I tried to compile the fresh git clone from your repo, but I get these 2 errors (with DSS and IML ON):

Error    2    error C2664: 'bool DSSolver::SetMatrixPattern(SparseMatrixF *,unsigned char)': impossibile convertire l'argomento 1 da 'std::unique_ptr<SparseMatrixF,std::default_delete<_Ty>>' a 'SparseMatrixF *'    C:\oofemM\oofem\src\dss\dssmatrix.C    268    1    dss
Error    4    error C2664: 'bool DSSolver::SetMatrixPattern(SparseMatrixF *,unsigned char)': impossibile convertire l'argomento 1 da 'std::unique_ptr<SparseMatrixF,std::default_delete<_Ty>>' a 'SparseMatrixF *'    C:\oofemM\oofem\src\dss\dssmatrix.C    272    1    dss

this is very strange because that lines

_dss->SetMatrixPattern(_sm, bsize);

are identical to the previous versions that compiles fine. Any clue?

Re: Reference angle in beam3d

Yes. My mistake. It should be fixed now.