-
Notifications
You must be signed in to change notification settings - Fork 248
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 3 commits
92fd157
859abbd
7a518dd
9f49410
625d3af
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 |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// | / | | ||
// ' / __| _` | __| _ \ __| | ||
// . \ | ( | | ( |\__ ` | ||
// _|\_\_| \__,_|\__|\___/ ____/ | ||
// Multi-Physics | ||
// | ||
// License: BSD License | ||
// Kratos default license: kratos/license.txt | ||
// | ||
// Main authors: Nicolo' Antonelli | ||
// Andrea Gorgi | ||
// | ||
|
||
// Project includes | ||
#include "includes/define.h" | ||
#include "nurbs_geometry_modeler_sbm.h" | ||
#include "geometries/nurbs_shape_function_utilities/nurbs_volume_refinement_utilities.h" | ||
#include "custom_utilities/create_breps_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) | ||
{ | ||
|
||
// 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"; | ||
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(); | ||
|
||
if (!mpModel->HasModelPart(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. you can use |
||
KRATOS_ERROR << "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(); | ||
|
||
if (!mpModel->HasModelPart(skin_model_part_outer_initial_name)) | ||
KRATOS_ERROR << "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,129 @@ | ||
// | / | | ||
// ' / __| _` | __| _ \ __| | ||
// . \ | ( | | ( |\__ ` | ||
// _|\_\_| \__,_|\__|\___/ ____/ | ||
// Multi-Physics | ||
// | ||
// License: BSD License | ||
// Kratos default license: kratos/license.txt | ||
// | ||
// Main authors: Nicolo' Antonelli | ||
// Andrea Gorgi | ||
// | ||
|
||
#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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// System includes | ||
|
||
// External includes | ||
|
||
// Project includes | ||
#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 commentThe reason will be displayed to describe this comment to others. Learn more. can those includes go to the .cpp? |
||
#include "geometries/nurbs_shape_function_utilities/nurbs_surface_refinement_utilities.h" | ||
#include "geometries/brep_curve_on_surface.h" | ||
#include "utilities/nurbs_utilities/snake_sbm_utilities.h" | ||
|
||
namespace Kratos { | ||
|
||
class KRATOS_API(IGA_APPLICATION) NurbsGeometryModelerSbm | ||
: public NurbsGeometryModeler | ||
{ | ||
public: | ||
///@name Type Definitions | ||
///@{ | ||
KRATOS_CLASS_POINTER_DEFINITION( NurbsGeometryModelerSbm ); | ||
|
||
typedef std::size_t IndexType; | ||
typedef std::size_t SizeType; | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. now we use |
||
|
||
typedef NurbsSurfaceGeometry<3, PointerVector<NodeType>> NurbsSurfaceGeometryType; | ||
typedef typename NurbsSurfaceGeometryType::Pointer NurbsSurfaceGeometryPointerType; | ||
|
||
typedef NurbsVolumeGeometry<PointerVector<NodeType>> NurbsVolumeGeometryType; | ||
typedef typename NurbsVolumeGeometryType::Pointer NurbsVolumeGeometryPointerType; | ||
|
||
typedef PointerVector<Node> ContainerNodeType; | ||
typedef PointerVector<Point> ContainerEmbeddedNodeType; | ||
|
||
///@} | ||
///@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 |
||
: NurbsGeometryModeler() {} | ||
|
||
/// Constructor. | ||
NurbsGeometryModelerSbm( | ||
Model & rModel, | ||
const Parameters ModelerParameters = Parameters()) | ||
: NurbsGeometryModeler(rModel, ModelerParameters) | ||
, mpModel(&rModel) | ||
{ | ||
} | ||
|
||
/// Destructor. | ||
virtual ~NurbsGeometryModelerSbm() = default; | ||
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 shoud be 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. We copied it from the base class nurbsGeometryModeler.h |
||
|
||
/// 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; | ||
|
||
///@} | ||
///@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 | ||
#endif // KRATOS_NURBS_GEOMETRY_MODELER_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.
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.