Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core][NURBS] nurbs geometry #5361

Merged
merged 66 commits into from
Oct 1, 2019
Merged

[Core][NURBS] nurbs geometry #5361

merged 66 commits into from
Oct 1, 2019

Conversation

tteschemacher
Copy link
Contributor

@tteschemacher tteschemacher commented Aug 6, 2019

Hi all,

I am adding here the geometries for pure NURBS entitities and the necessary utiltity functions.

Those are ported from the very good work of @oberbichler with ANurbs and #5344. We adapted it to fully fit to the KRATOS style.

///@name Get and Set functions
///@{

bool IsRational() const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Doxygen doc (same for everything)

Copy link
Member

@loumalouomega loumalouomega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commments, why ints?

return mKnots;
}

int NumberOfKnots() const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why int and not std::size_t?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for the ints: The algorithms in the nurbs book assume that signed-integer operations can be performed. In some cases usigned integers led to wrong results. Since no error occurs, it is very difficult to debug something like this. Adapting the algorithms from the book is also not very easy in these cases.


std::vector<Interval> KnotSpanIntervals() const
{
const int first_span = mPolynomialDegree - 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wht ints?

#if !defined(KRATOS_NURBS_CURVE_SHAPE_FUNCTIONS_H_INCLUDED )
#define KRATOS_NURBS_CURVE_SHAPE_FUNCTIONS_H_INCLUDED

#include "nurbs_utilities.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate properly:

// System includes

// External includes

// Project includes

mDerivativeOrder = DerivativeOrder;
}

int PolynomialDegree() const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why int?, missing doxygen

return mPolynomialDegree;
}

int NumberOfNonzeroControlPoints() const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem in the following

///@name Member Variables
///@{

double m_t0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CammelCase

const Vector& rKnots,
const double ParameterT)
{
auto span = std::lower_bound(std::begin(rKnots) + PolynomialDegree,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const?

///@{

static int GetUpperSpan(
const int PolynomialDegree,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why int?

{
// clang-format off
return
(K > N) ? 0 : // out of range
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is efficient

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I thought so, too. However, precalculated values have produced surprisingly poor results. But it would still make sense to take the function from boost.

@tteschemacher
Copy link
Contributor Author

Thanks @loumalouomega, I tried to change as suggested.

@oberbichler
Copy link
Contributor

Thank you for the compliments but maybe there was a misunderstanding.

Last friday we decided that you would take care of the container for the shape functions. I should then adjust the geometries in my last pull-request as I discussed with @pooyan-dadvand and @RiccardoRossi in the bistro and use this container.

Why is there now a new pull-request containing only the curve geometry (without surfaces and tests) and without the container?

@tteschemacher
Copy link
Contributor Author

I tried to ease the review process, further, I only adapted to the Kratos style.

@oberbichler
Copy link
Contributor

This is basically a good idea but now we have pull-requests for the branches "nurbs-geometries" and "nurbs_geometries". Instead of creating this new branch (and making changes that lead to errors) it would make more sense to prepare the container as discussed last week.

@tteschemacher
Copy link
Contributor Author

@philbucher you requested changes. I adressed your issues, are you ok with it now?

@philbucher
Copy link
Member

can you please merge master?

Copy link
Member

@philbucher philbucher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some more comments, but nothing significant

other than that for me is ok

kratos/geometries/nurbs_curve_geometry.h Outdated Show resolved Hide resolved
kratos/geometries/nurbs_curve_geometry.h Show resolved Hide resolved
result[i] = Interval(t0, t1);
}

return result;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would using std::move make sense here?

not sure, asking the others

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy elision?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::move would make it more explicit (which is good) but as result is rvalue, the optimizer will use the move.

kratos/geometries/nurbs_curve_geometry.h Show resolved Hide resolved
kratos/geometries/nurbs_curve_geometry.h Outdated Show resolved Hide resolved
const Vector& rKnots,
const double ParameterT)
{
const auto span = std::lower_bound(std::begin(rKnots) + PolynomialDegree,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping

KRATOS_CHECK_NEAR(shape_functions(1, 6), -0.132366199073095, TOLERANCE);
KRATOS_CHECK_NEAR(shape_functions(2, 6), 0.161718941270974, TOLERANCE);
KRATOS_CHECK_NEAR(shape_functions(3, 6), -0.295903990157367, TOLERANCE);
KRATOS_CHECK_NEAR(shape_functions(4, 6), 0.227141701884515, TOLERANCE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you could use the new matrix-check macro

KRATOS_CHECK_NEAR(shape_functions(8,14), 6.244572963750500e+00, TOLERANCE);
KRATOS_CHECK_NEAR(shape_functions(9,14), -4.328015755205562e+00, TOLERANCE);
KRATOS_CHECK_NEAR(shape_functions(10,14), -2.987503354121680e+00, TOLERANCE);
KRATOS_CHECK_NEAR(shape_functions(11,14), -1.031093322633297e+00, TOLERANCE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

unrolling those macros apparently takes quite some time

@RiccardoRossi
Copy link
Member

this is the first one that should go in, right?

Copy link
Member

@RiccardoRossi RiccardoRossi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as i can see this is essentially ready for merging.

@philbucher could u make a resume of what is still a TODO here?
please if you do tell what is crucial and what is "wish"

once that is done according to me this can go in

@tteschemacher
Copy link
Contributor Author

Yes, this is very important

Copy link
Member

@philbucher philbucher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to me looks ready
(although adding the docu as I pointed out would be nice ;) )

@pooyan-dadvand do you still want to take a look?

@tteschemacher
Copy link
Contributor Author

I tried to adress all your comments. @pooyan-dadvand if you say yes I would merge.

Copy link
Member

@pooyan-dadvand pooyan-dadvand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@tteschemacher tteschemacher merged commit 9adfe8c into master Oct 1, 2019
@oberbichler oberbichler deleted the core/nurbs_geometry branch December 12, 2019 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants