-
Notifications
You must be signed in to change notification settings - Fork 249
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
[IgaApplication] Add Nurbs modeler for SBM #13009
base: master
Are you sure you want to change the base?
Conversation
…rSbm Co-authored-by: Nicolò Antonelli <[email protected]>
if (mParameters.Has("skin_model_part_inner_initial_name")) { | ||
skin_model_part_inner_initial_name = mParameters["skin_model_part_inner_initial_name"].GetString(); | ||
|
||
if (!mpModel->HasModelPart(skin_model_part_inner_initial_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use KRATOS_ERROR_IF()
: mpModel->CreateModelPart(iga_model_part_name); | ||
|
||
// Create the True Model Part -> contains all the true boundary features | ||
std::string skin_model_part_inner_initial_name = "skin_model_part_inner_initial_name"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouls it be useful to set this name from the json file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually the "default" name which is overwritten few lines below if the "skin_model_part_inner_inner_initial_name" is provided in the json file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Json defaults should automatically handle this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you suggest us an example to start form for the json defaults? @rubenzorrilla
// | ||
|
||
#if !defined(KRATOS_NURBS_GEOMETRY_MODELER_SBM_H_INCLUDED ) | ||
#define KRATOS_NURBS_GEOMETRY_MODELER_SBM_H_INCLUDED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pragma once
#include "includes/model_part.h" | ||
#include "nurbs_geometry_modeler.h" | ||
#include "geometries/nurbs_volume_geometry.h" | ||
#include "geometries/nurbs_surface_geometry.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can those includes go to the .cpp?
typedef Node NodeType; | ||
|
||
typedef Geometry<NodeType> GeometryType; | ||
typedef typename GeometryType::Pointer GeometryPointerType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now we use using GeometryType = Geometry<NodeType>;
|
||
xy_coord_i_cond[0][0] = i_cond.GetGeometry()[0].X(); // x_true_boundary1 | ||
xy_coord_i_cond[1][0] = i_cond.GetGeometry()[0].Y(); // y_true_boundary1 | ||
xy_coord_i_cond[0][1] = i_cond.GetGeometry()[1].X(); // x_true_boundary2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
knot_spans_available[idMatrix][i][j] = 1; // The knot span is considered DEACTIVE | ||
} | ||
|
||
// exit(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
IndexType idSnakeNode = id_first_node+1; | ||
|
||
// Follow the clockwise loop | ||
int end = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SizeType?
// We are going orizontally | ||
int direction = 0 ; // 0 = up_vertical, 1 = right_orizontal, 2 = down_vertical, 3 = left_orizontal | ||
int I = start_i+1; | ||
int J = start_j+1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SizeType
// | ||
|
||
#if !defined(KRATOS_SNAKE_SBM_UTILITIES_H_INCLUDED ) | ||
#define KRATOS_SNAKE_SBM_UTILITIES_H_INCLUDED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pragma once
Co-authored-by: Nicolò Antonelli <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for my late review. I have minor comments related to the writing convention style.
|
||
// Follow the clockwise loop | ||
bool end = false; | ||
// We are going orizontally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
if (direction == -1) {direction = 3;} | ||
} | ||
else { | ||
// Need to try to go straight or right w.r.t. the current direction; risetto e muovo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check comment :)
* @param skin_model_part_in Input skin model part. | ||
* @return True if the point is inside the boundary, false otherwise. | ||
*/ | ||
static bool isPointInsideSkinBoundary(Point& pointToSearch, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsPointInsideSkinBoundary
(naming convention)
* @param knot_vector_v Knot vector in the V-direction. | ||
* @param starting_pos_uv Starting position in UV space. | ||
*/ | ||
static void CreateSurrogateBuondaryFromSnake_inner (std::vector<std::vector<std::vector<int>>> & knot_spans_available, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CreateSurrogateBuondaryFromSnakeInner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐍❓🤣
* @param knot_vector_v Knot vector in the V-direction. | ||
* @param starting_pos_uv Starting position in UV space. | ||
*/ | ||
static void CreateSurrogateBuondaryFromSnake_outer (DynamicBins& testBin_out, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CreateSurrogateBuondaryFromSnakeOuter
idSnakeNode++; | ||
} | ||
else { | ||
// Need to search to hte right; rese e muovo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check comment :)
kratos/geometries/brep_surface.h
Outdated
ModelPart* mpSurrogateModelPart_inner = nullptr; | ||
ModelPart* mpSurrogateModelPart_outer = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mpSurrogateModelPartInner
mpSurrogateModelPartOuter
@@ -141,6 +142,7 @@ class KRATOS_API(IGA_APPLICATION) KratosIgaApplication : public KratosApplicatio | |||
const IgaModeler mIgaModeler; | |||
const RefinementModeler mRefinementModeler; | |||
const NurbsGeometryModeler mNurbsGeometryModeler; | |||
const NurbsGeometryModelerSbm mNurbsGeometryModelerSbm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mNurbsGeometryModelerSBM
(make it consistent with mSBMLaplacianCondition
)
@@ -90,6 +90,7 @@ KRATOS_INFO("") << " KRATOS _____ _____\n" | |||
KRATOS_REGISTER_MODELER("IgaModeler", mIgaModeler); | |||
KRATOS_REGISTER_MODELER("RefinementModeler", mRefinementModeler); | |||
KRATOS_REGISTER_MODELER("NurbsGeometryModeler", mNurbsGeometryModeler); | |||
KRATOS_REGISTER_MODELER("NurbsGeometryModelerSbm", mNurbsGeometryModelerSbm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idem
Also, I have a few remarks: |
Thanks @rickyaristio for your comments! |
I see. Looking forward to the next PR about iga_sbm_modeler. |
I'll review this after @rickyaristio's and @AlejandroCornejo's suggestions are applied. |
const SizeType number_of_geometries = r_model_part.NumberOfGeometries(); | ||
SizeType last_geometry_id = 0; | ||
if( number_of_geometries > 0 ){ | ||
for( auto it = r_model_part.GeometriesBegin(); it!= r_model_part.GeometriesEnd(); ++it){ | ||
last_geometry_id = it->Id(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const SizeType number_of_geometries = r_model_part.NumberOfGeometries(); | |
SizeType last_geometry_id = 0; | |
if( number_of_geometries > 0 ){ | |
for( auto it = r_model_part.GeometriesBegin(); it!= r_model_part.GeometriesEnd(); ++it){ | |
last_geometry_id = it->Id(); | |
} | |
} | |
const SizeType last_geometry_id = r_model_part.NumberOfGeometries() | |
? r_model_part.Geometries().Geometries().back().Id() | |
: 0; |
I know, it looks stupid. In fact, it is stupid, but only because the geometry container is still weird.
///@name Private Member Variables | ||
///@{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an FYI on doxygen annotations:
- no doxygen docs are generated for private members, so there's no point marking these sections. Of course commenting the purpose of members is still good practice but it will only be visible in the code, and not the docs.
doxygen
automatically detects and highlights the visibility (public
/protected
/private
) of members so again: there's no point in doing section annontations.
void NurbsGeometryModelerSbm::CreateAndAddRegularGrid2D( ModelPart& r_model_part, const Point& A_xyz, const Point& B_xyz, | ||
const Point& A_uvw, const Point& B_uvw, SizeType OrderU, SizeType OrderV,SizeType NumKnotSpansU, SizeType NumKnotSpansV, bool add_surface_to_model_part) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is an override
of a virtual
member. If so, mark it as such. Also, you can use the @copydoc
doxygen command to pull in the annotations from the base class.
void NurbsGeometryModelerSbm::CreateAndAddRegularGrid2D( ModelPart& r_model_part, const Point& A_xyz, const Point& B_xyz, | |
const Point& A_uvw, const Point& B_uvw, SizeType OrderU, SizeType OrderV,SizeType NumKnotSpansU, SizeType NumKnotSpansV, bool add_surface_to_model_part) | |
/// @copydoc NurbsGeometryModeler::CreateAndAddRegularGrid2D | |
void NurbsGeometryModelerSbm::CreateAndAddRegularGrid2D( ModelPart& r_model_part, const Point& A_xyz, const Point& B_xyz, | |
const Point& A_uvw, const Point& B_uvw, SizeType OrderU, SizeType OrderV,SizeType NumKnotSpansU, SizeType NumKnotSpansV, bool add_surface_to_model_part) override |
+ same comment about variable naming in general.
virtual void CreateAndAddRegularGrid2D( ModelPart& r_model_part, const Point& A_xyz, const Point& B_xyz, const Point& A_uvw, const Point& B_uvw, | ||
SizeType OrderU, SizeType OrderV, SizeType NumKnotSpansU, SizeType NumKnotSpansV, bool add_surface_to_model_part = true); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a lot of arguments, and the docstring seems to be wildly out of date. Please update it and write a @param
entry for each argument with some explanations.
Oh and please pick a naming format and stick with it. I suggest the one in the kratos style guide if you don't want the technical committee get mad at you. It would also help you avoid @loumalouomega
reformatting your code.
///@name Private Member Variables | ||
///@{ | ||
|
||
Model* mpModel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, doesn't the base class already have a pointer to the Model
?
You could just expose that through a protected
member of the base class to avoid duplication/ambiguity.
const auto span = std::lower_bound(std::begin(rKnots) + PolynomialDegree, | ||
std::end(rKnots) - PolynomialDegree, ParameterT) - std::begin(rKnots) - 1; | ||
std::end(rKnots) - PolynomialDegree, parameter_t_corrected) - std::begin(rKnots) - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can parameter_t_corrected <= rKnots.front()
ever happen? If so, that'd be scary.
As a general comment for this function: you don't really need that first loop. As I understand, it's just handling cases that are close to knots. You could just use the output of std::lower_bound
and check its neighbors.
e.g.:
auto it = std::lower_bound(...);
if (it + 1 != rKnots.end()) {
it = std::abs(ParameterT - it[1]) < tolerance
? it + 1
: it;
}
return std::distance(rKnots.begin(), it - 1);
Also keep in mind that you might have to clamp your output to 0
if you don't handle potentially negative spans later on.
DynamicBins& testBins, | ||
ModelPart& skin_model_part_in); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my fav ❤️:
DynamicBins& testBins,
ModelPart& skinModelPartIn);
ancient C dev (or annoying 🦀 crusader):
DynamicBins& test_bins,
ModelPart& skin_model_part_in);
kratos style:
DynamicBins& TestBins,
ModelPart& SkinModelPartIn);
* @param rEchoLevel Verbosity level for logging. | ||
* @param knot_vector_u Knot vector in the U-direction. | ||
* @param knot_vector_v Knot vector in the V-direction. | ||
* @param mParameters Input parameters for the process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the docs 👍.
You need to explain what you expect as parameters here though.
for (IndexType i = 0; i < numberOfLoops; ++i) { | ||
std::vector<std::vector<int>> matrix; | ||
matrix.reserve(n_knot_spans_uv[1]); | ||
for (int j = 0; j <= n_knot_spans_uv[1]-1; ++j) { | ||
std::vector<int> row(n_knot_spans_uv[0]); | ||
matrix.push_back(row); | ||
} | ||
knot_spans_available.push_back(matrix); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::vector<std::vector<int>> matrix;
ouch
How big can numberOfLoops
get? If it's on the order of magnitude as elements/nodes or larger, this is going to be very pricey.
I see vector
nesting is a running theme in this utility but I'd strongly advise against it. Consider using a dense matrix instead.
I know transitioning to a more efficient data structure would be a big change so I'm not suggesting that you do it in this PR. Just keep it in mind and do it when you have the time.
} | ||
// Create "fictituos element" to memorize starting and ending node id for each surrogate boundary loop | ||
std::vector<ModelPart::IndexType> elem_nodes{1, idSnakeNode-1}; | ||
IndexType elem_id = surrogate_model_part_outer.GetRootModelPart().Elements().size()+1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch out: index != identifier
.
IndexType elem_id = surrogate_model_part_outer.GetRootModelPart().Elements().size()+1; | |
const ModelPart& r_root = surrogate_model_part_outer.GetRootModelPart(); | |
IndexType elem_id = r_root.Elements().empty() | |
? 1 | |
: r_root.Elements().back().Id() + 1; |
📝 Description
We have added the NURBS Modeler SBM:
In particular, we have developed two utilities: one to identify the surrogate boundaries and another to create the BREP entities. These utilities were created to enhance clarity and because they might be used separately in other applications.
Please mark the PR with appropriate tags: