-
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?
Changes from all commits
92fd157
859abbd
7a518dd
9f49410
625d3af
05c0290
cfb7ba4
2abf0c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ class KRATOS_API(IGA_APPLICATION) NurbsGeometryModeler | |
} | ||
|
||
/// Destructor. | ||
virtual ~NurbsGeometryModeler() = default; | ||
~NurbsGeometryModeler() = default; | ||
|
||
/// Creates the Modeler Pointer | ||
Modeler::Pointer Create(Model& rModel, const Parameters ModelParameters) const override | ||
|
@@ -82,15 +82,8 @@ class KRATOS_API(IGA_APPLICATION) NurbsGeometryModeler | |
|
||
///@} | ||
|
||
private: | ||
///@name Private Member Variables | ||
///@{ | ||
|
||
Model* mpModel; | ||
|
||
///@} | ||
///@name Private Operations | ||
///@{ | ||
protected: | ||
///@{ | ||
|
||
/** | ||
* @brief Creates a regular grid composed out of bivariant B-splines. | ||
|
@@ -100,8 +93,26 @@ class KRATOS_API(IGA_APPLICATION) NurbsGeometryModeler | |
* @param NumKnotSpans Number of equidistant elements/knot spans in each direction u,v. | ||
* @note The CP'S are defined as nodes and added to the rModelPart. | ||
**/ | ||
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 ); | ||
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); | ||
|
||
Comment on lines
+96
to
+98
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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 |
||
NurbsSurfaceGeometryPointerType mpSurface; | ||
|
||
Vector mKnotVectorU; | ||
Vector mKnotVectorV; | ||
std::vector<double> mInsertKnotsU; | ||
std::vector<double> mInsertKnotsV; | ||
|
||
|
||
private: | ||
///@name Private Member Variables | ||
///@{ | ||
Comment on lines
+108
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just an FYI on doxygen annotations:
|
||
|
||
Model* mpModel; | ||
|
||
///@} | ||
///@name Private Operations | ||
|
||
|
||
/** | ||
* @brief Creates a cartesian grid composed out of trivariant B-spline cubes. | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,126 @@ | ||||||||||||||
// | / | | ||||||||||||||
// ' / __| _` | __| _ \ __| | ||||||||||||||
// . \ | ( | | ( |\__ ` | ||||||||||||||
// _|\_\_| \__,_|\__|\___/ ____/ | ||||||||||||||
// Multi-Physics | ||||||||||||||
// | ||||||||||||||
// License: BSD License | ||||||||||||||
// Kratos default license: kratos/license.txt | ||||||||||||||
// | ||||||||||||||
// Main authors: Nicolo' Antonelli | ||||||||||||||
// Andrea Gorgi | ||||||||||||||
// | ||||||||||||||
|
||||||||||||||
// Project includes | ||||||||||||||
#include "nurbs_geometry_modeler_sbm.h" | ||||||||||||||
#include "custom_utilities/create_breps_sbm_utilities.h" | ||||||||||||||
#include "utilities/nurbs_utilities/snake_sbm_utilities.h" | ||||||||||||||
|
||||||||||||||
namespace Kratos | ||||||||||||||
{ | ||||||||||||||
|
||||||||||||||
///@name Stages | ||||||||||||||
///@{ | ||||||||||||||
|
||||||||||||||
void NurbsGeometryModelerSbm::SetupGeometryModel(){ | ||||||||||||||
|
||||||||||||||
//---------------------------------------------------------------------------------------------------------------- | ||||||||||||||
KRATOS_INFO_IF("NurbsGeometryModelerSbm", mEchoLevel > 1) << "[NURBS MODELER SBM]:: calling NurbsGeometryModeler" << std::endl; | ||||||||||||||
|
||||||||||||||
// Call the SetupGeometryModel method of the base class NurbsGeometryModeler | ||||||||||||||
NurbsGeometryModeler::SetupGeometryModel(); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
///@} | ||||||||||||||
///@name Private Operations | ||||||||||||||
///@{ | ||||||||||||||
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) | ||||||||||||||
Comment on lines
+37
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this is an
Suggested change
+ same comment about variable naming in general. |
||||||||||||||
{ | ||||||||||||||
|
||||||||||||||
// Call the CreateAndAddRegularGrid2D method of the base class NurbsGeometryModeler | ||||||||||||||
NurbsGeometryModeler::CreateAndAddRegularGrid2D(r_model_part, A_xyz, B_xyz, | ||||||||||||||
A_uvw, B_uvw, OrderU, OrderV, NumKnotSpansU, NumKnotSpansV, false); | ||||||||||||||
|
||||||||||||||
// Create the Domain/Iga Model Part | ||||||||||||||
const std::string iga_model_part_name = mParameters["model_part_name"].GetString(); | ||||||||||||||
ModelPart& iga_model_part = mpModel->HasModelPart(iga_model_part_name) | ||||||||||||||
? mpModel->GetModelPart(iga_model_part_name) | ||||||||||||||
: 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 commentThe 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 commentThe 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 commentThe 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 commentThe 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 |
||||||||||||||
std::string skin_model_part_outer_initial_name = "skin_model_part_outer_initial_name"; | ||||||||||||||
std::string skin_model_part_name; | ||||||||||||||
if (mParameters.Has("skin_model_part_inner_initial_name")) { | ||||||||||||||
skin_model_part_inner_initial_name = mParameters["skin_model_part_inner_initial_name"].GetString(); | ||||||||||||||
|
||||||||||||||
KRATOS_ERROR_IF_NOT(mpModel->HasModelPart(skin_model_part_inner_initial_name)) | ||||||||||||||
<< "The skin_model_part '" << skin_model_part_inner_initial_name << "' was not created in the model.\n" | ||||||||||||||
<< "Check the reading of the mdpa file in the import mdpa modeler."<< std::endl; | ||||||||||||||
} | ||||||||||||||
if (mParameters.Has("skin_model_part_outer_initial_name")) { | ||||||||||||||
skin_model_part_outer_initial_name = mParameters["skin_model_part_outer_initial_name"].GetString(); | ||||||||||||||
|
||||||||||||||
KRATOS_ERROR_IF_NOT(mpModel->HasModelPart(skin_model_part_outer_initial_name)) | ||||||||||||||
<< "The skin_model_part '" << skin_model_part_outer_initial_name << "' was not created in the model.\n" | ||||||||||||||
<< "Check the reading of the mdpa file in the import mdpa modeler."<< std::endl; | ||||||||||||||
} | ||||||||||||||
// If there is not neither skin_inner nor skin_outer throw an error since you are using the sbm modeler | ||||||||||||||
if (!(mParameters.Has("skin_model_part_inner_initial_name") || mParameters.Has("skin_model_part_outer_initial_name"))){ | ||||||||||||||
|
||||||||||||||
// Create the breps for the outer sbm boundary | ||||||||||||||
CreateBrepsSBMUtilities<Node, Point> CreateBrepsSBMUtilities(mEchoLevel); | ||||||||||||||
CreateBrepsSBMUtilities.CreateSurrogateBoundary(mpSurface, r_model_part, A_uvw, B_uvw); | ||||||||||||||
|
||||||||||||||
KRATOS_WARNING("None of the 'skin_model_part_name' have not been defined ") << | ||||||||||||||
"in the nurbs_geometry_modeler_sbm in the project paramer json" << std::endl; | ||||||||||||||
return; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
if (mParameters.Has("skin_model_part_name")) | ||||||||||||||
skin_model_part_name = mParameters["skin_model_part_name"].GetString(); | ||||||||||||||
else | ||||||||||||||
KRATOS_ERROR << "The skin_model_part name '" << skin_model_part_name << "' was not defined in the project parameters.\n" << std::endl; | ||||||||||||||
|
||||||||||||||
// inner | ||||||||||||||
ModelPart& skin_model_part_inner_initial = mpModel->HasModelPart(skin_model_part_inner_initial_name) | ||||||||||||||
? mpModel->GetModelPart(skin_model_part_inner_initial_name) | ||||||||||||||
: mpModel->CreateModelPart(skin_model_part_inner_initial_name); | ||||||||||||||
// outer | ||||||||||||||
ModelPart& skin_model_part_outer_initial = mpModel->HasModelPart(skin_model_part_outer_initial_name) | ||||||||||||||
? mpModel->GetModelPart(skin_model_part_outer_initial_name) | ||||||||||||||
: mpModel->CreateModelPart(skin_model_part_outer_initial_name); | ||||||||||||||
|
||||||||||||||
// Create the surrogate sub model parts inner and outer | ||||||||||||||
ModelPart& surrogate_sub_model_part_inner = iga_model_part.CreateSubModelPart("surrogate_inner"); | ||||||||||||||
ModelPart& surrogate_sub_model_part_outer = iga_model_part.CreateSubModelPart("surrogate_outer"); | ||||||||||||||
|
||||||||||||||
// Skin model part refined after Snake Process | ||||||||||||||
ModelPart& skin_model_part = mpModel->CreateModelPart(skin_model_part_name); | ||||||||||||||
skin_model_part.CreateSubModelPart("inner"); | ||||||||||||||
skin_model_part.CreateSubModelPart("outer"); | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
// compute unique_knot_vector_u | ||||||||||||||
Vector unique_knot_vector_u(2+(NumKnotSpansU-1)); | ||||||||||||||
unique_knot_vector_u[0] = mKnotVectorU[0]; unique_knot_vector_u[NumKnotSpansU] = mKnotVectorU[mKnotVectorU.size()-1]; | ||||||||||||||
for (SizeType i_knot_insertion = 0; i_knot_insertion < NumKnotSpansU-1; i_knot_insertion++) { | ||||||||||||||
unique_knot_vector_u[i_knot_insertion+1] = mInsertKnotsU[i_knot_insertion]; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
// compute unique_knot_vector_v | ||||||||||||||
Vector unique_knot_vector_v(2+(NumKnotSpansV-1)); | ||||||||||||||
unique_knot_vector_v[0] = mKnotVectorV[0]; unique_knot_vector_v[NumKnotSpansV] = mKnotVectorV[mKnotVectorV.size()-1]; | ||||||||||||||
|
||||||||||||||
for (SizeType i_knot_insertion = 0; i_knot_insertion < NumKnotSpansV-1; i_knot_insertion++) { | ||||||||||||||
unique_knot_vector_v[i_knot_insertion+1] = mInsertKnotsV[i_knot_insertion]; | ||||||||||||||
} | ||||||||||||||
SnakeSBMUtilities::CreateTheSnakeCoordinates(iga_model_part, skin_model_part_inner_initial, skin_model_part_outer_initial, skin_model_part, mEchoLevel, | ||||||||||||||
unique_knot_vector_u, unique_knot_vector_v, mParameters) ; | ||||||||||||||
// Create the breps for the outer sbm boundary | ||||||||||||||
CreateBrepsSBMUtilities<Node, Point> CreateBrepsSBMUtilities(mEchoLevel); | ||||||||||||||
CreateBrepsSBMUtilities.CreateSurrogateBoundary(mpSurface, r_model_part, surrogate_sub_model_part_inner, surrogate_sub_model_part_outer, A_uvw, B_uvw); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
} // end namespace kratos |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// | / | | ||
// ' / __| _` | __| _ \ __| | ||
// . \ | ( | | ( |\__ ` | ||
// _|\_\_| \__,_|\__|\___/ ____/ | ||
// Multi-Physics | ||
// | ||
// License: BSD License | ||
// Kratos default license: kratos/license.txt | ||
// | ||
// Main authors: Nicolo' Antonelli | ||
// Andrea Gorgi | ||
// | ||
|
||
# pragma once | ||
|
||
// System includes | ||
|
||
// External includes | ||
|
||
// Project includes | ||
#include "nurbs_geometry_modeler.h" | ||
|
||
namespace Kratos { | ||
|
||
class KRATOS_API(IGA_APPLICATION) NurbsGeometryModelerSbm | ||
: public NurbsGeometryModeler | ||
{ | ||
public: | ||
///@name Type Definitions | ||
///@{ | ||
KRATOS_CLASS_POINTER_DEFINITION( NurbsGeometryModelerSbm ); | ||
|
||
using IndexType = std::size_t; | ||
using SizeType = std::size_t; | ||
using NodeType = Node; | ||
|
||
using GeometryType = Geometry<NodeType>; | ||
using GeometryPointerType = GeometryType::Pointer; | ||
|
||
using NurbsSurfaceGeometryType = NurbsSurfaceGeometry<3, PointerVector<NodeType>>; | ||
using NurbsSurfaceGeometryPointerType = NurbsSurfaceGeometryType::Pointer; | ||
|
||
using NurbsVolumeGeometryType = NurbsVolumeGeometry<PointerVector<NodeType>>; | ||
using NurbsVolumeGeometryPointerType = NurbsVolumeGeometryType::Pointer; | ||
|
||
using ContainerNodeType = PointerVector<Node>; | ||
using ContainerEmbeddedNodeType = PointerVector<Point>; | ||
|
||
///@} | ||
///@name Life Cycle | ||
///@{ | ||
|
||
/// Default constructor. | ||
NurbsGeometryModelerSbm() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. those defaults maybe they can be removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I'm not wrong, the compiler will add it if not in there. |
||
: NurbsGeometryModeler() {} | ||
|
||
/// Constructor. | ||
NurbsGeometryModelerSbm( | ||
Model & rModel, | ||
const Parameters ModelerParameters = Parameters()) | ||
: NurbsGeometryModeler(rModel, ModelerParameters) | ||
, mpModel(&rModel) | ||
{ | ||
} | ||
|
||
/// Destructor. | ||
~NurbsGeometryModelerSbm() = default; | ||
|
||
/// Creates the Modeler Pointer | ||
Modeler::Pointer Create(Model& rModel, const Parameters ModelParameters) const override | ||
{ | ||
return Kratos::make_shared<NurbsGeometryModelerSbm>(rModel, ModelParameters); | ||
} | ||
|
||
///@} | ||
///@name Stages | ||
///@{ | ||
|
||
void SetupGeometryModel() override; | ||
|
||
///@} | ||
|
||
protected: | ||
|
||
/** | ||
* @brief Creates a regular grid composed out of bivariant B-splines. | ||
* @param PointA Lower point of bounding box. | ||
* @param PointB Upper point of bounding box. | ||
* @param Order Polynomial degree in each direction u,v. | ||
* @param NumKnotSpans Number of equidistant elements/knot spans in each direction u,v. | ||
* @note The CP'S are defined as nodes and added to the rModelPart. | ||
**/ | ||
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 ) override; | ||
|
||
private: | ||
|
||
///@name Private Member Variables | ||
///@{ | ||
|
||
Model* mpModel; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, doesn't the base class already have a pointer to the You could just expose that through a |
||
|
||
///@} | ||
///@name Private Operations | ||
///@{ | ||
|
||
/** | ||
* @brief Creates a cartesian grid composed out of trivariant B-spline cubes. | ||
* @param PointA Lower point of bounding box. | ||
* @param PointB Upper point of bounding box. | ||
* @param Order Polynomial degree in each direction u,v,w. | ||
* @param NumKnotSpans Number of equidistant elements/knot spans in each direction u,v,w. | ||
* @note The CP'S are defined as nodes and added to the rModelPart. | ||
**/ | ||
void CreateAndAddRegularGrid3D( 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 OrderW, SizeType NumKnotSpansU, SizeType NumKnotSpansV, SizeType NumKnotSpansW ); | ||
|
||
Parameters ReadParamatersFile(const std::string& rDataFileName) const; | ||
}; | ||
|
||
} // End namesapce Kratos |
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 know, it looks stupid. In fact, it is stupid, but only because the geometry container is still weird.