Skip to content

[IgaApplication] nurbs geometry modeler extension to 3D #13465

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,8 @@ namespace Kratos
}


void NurbsGeometryModeler::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 )
Comment on lines -253 to -255
Copy link
Contributor

Choose a reason for hiding this comment

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

idem

void NurbsGeometryModeler::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, bool AddVolumeToModelPart)
{
KRATOS_ERROR_IF( B_xyz.X() <= A_xyz.X() || B_xyz.Y() <= A_xyz.Y() || B_xyz.Z() <= A_xyz.Z() ) << "NurbsGeometryModeler: "
<< "The two Points A_xyz and B_xyz must meet the following requirement: (B_xyz-A_xyz) > (0,0,0). However, (B_xyz-A_xyz)=" << B_xyz-A_xyz << std::endl;
Expand Down Expand Up @@ -340,20 +339,23 @@ namespace Kratos
insert_knots_w[i] = knot_w;
}

// Add geometry to model part
if( mParameters.Has("geometry_name") ){
p_volume_geometry->SetId(mParameters["geometry_name"].GetString());
} else {
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();
// In some cases there is no need of add the volume geometry, AddSurfaceToModelPart is true by default
if (AddVolumeToModelPart) {
// Add geometry to model part
if( mParameters.Has("geometry_name") ){
p_volume_geometry->SetId(mParameters["geometry_name"].GetString());
} else {
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();
}
}
p_volume_geometry->SetId(last_geometry_id+1);
}
p_volume_geometry->SetId(last_geometry_id+1);
r_model_part.AddGeometry(p_volume_geometry);
}
r_model_part.AddGeometry(p_volume_geometry);

// Perform knot refinement.
PointerVector<NodeType> PointsRefined = p_volume_geometry->Points();
Expand Down Expand Up @@ -407,6 +409,15 @@ namespace Kratos
p_volume_geometry->SetInternals(PointsRefined,
p_volume_geometry->PolynomialDegreeU(), p_volume_geometry->PolynomialDegreeV(), p_volume_geometry->PolynomialDegreeW(),
p_volume_geometry->KnotsU(), p_volume_geometry->KnotsV(), p_volume_geometry->KnotsW());

// assign the value p_volume_geometry to the class member mpVolume for derived classes
mpVolume = p_volume_geometry;
mInsertKnotsU = insert_knots_u;
mInsertKnotsV = insert_knots_v;
mInsertKnotsW = insert_knots_w;
mKnotVectorU = knot_vector_u;
mKnotVectorV = knot_vector_v;
mKnotVectorW = knot_vector_w;
}
///@}
} // end namespace kratos
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,28 @@ class KRATOS_API(IGA_APPLICATION) NurbsGeometryModeler
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);


/**
* @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.
**/
virtual 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, bool add_volume_to_model_part = true);


NurbsSurfaceGeometryPointerType mpSurface;
NurbsVolumeGeometryPointerType mpVolume;

Vector mKnotVectorU;
Vector mKnotVectorV;
Vector mKnotVectorW;
std::vector<double> mInsertKnotsU;
std::vector<double> mInsertKnotsV;
std::vector<double> mInsertKnotsW;


private:
Expand All @@ -113,18 +129,6 @@ class KRATOS_API(IGA_APPLICATION) NurbsGeometryModeler
///@}
///@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 );

};

} // End namesapce Kratos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,124 @@ void NurbsGeometryModelerSbm::CreateAndAddRegularGrid2D(
CreateBrepsSbmUtilities.CreateSurrogateBoundary(mpSurface, surrogate_sub_model_part_inner, surrogate_sub_model_part_outer, A_uvw, B_uvw, r_iga_model_part);
}

// 3D
void NurbsGeometryModelerSbm::CreateAndAddRegularGrid3D(
ModelPart& rModelPart,
const Point& A_xyz,
const Point& B_xyz,
const Point& A_uvw,
const Point& B_uvw,
const SizeType OrderU,
const SizeType OrderV,
const SizeType OrderW,
const SizeType NumKnotSpansU,
const SizeType NumKnotSpansV,
const SizeType NumKnotSpansW,
const bool AddVolumeToModelPart)
{

// Call the CreateAndAddRegularGrid3D method of the base class NurbsGeometryModeler
NurbsGeometryModeler::CreateAndAddRegularGrid3D(rModelPart, A_xyz, B_xyz,
A_uvw, B_uvw, OrderU, OrderV, OrderW, NumKnotSpansU, NumKnotSpansV, NumKnotSpansW, false);

// Create the Domain/Iga Model Part
const std::string iga_model_part_name = mParameters["model_part_name"].GetString();
ModelPart& r_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_name;
std::string skin_model_part_inner_initial_name = mParameters["skin_model_part_inner_initial_name"].GetString();
std::string skin_model_part_outer_initial_name = mParameters["skin_model_part_outer_initial_name"].GetString();

// Create the surrogate sub model parts inner and outer
// ModelPart& surrogate_sub_model_part_inner = r_iga_model_part.CreateSubModelPart("surrogate_inner"); // uncomment this line (next PR)
// ModelPart& surrogate_sub_model_part_outer = r_iga_model_part.CreateSubModelPart("surrogate_outer"); // uncomment this line (next PR)

// If there is not neither skin_inner nor skin_outer throw a warning 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);
// TODO: NEXT PR CreateSurrogateBoundary with Volume
// CreateBrepsSbmUtilities.CreateSurrogateBoundary(mpVolume, A_uvw, B_uvw, rModelPart);

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
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
mpModel->HasModelPart(skin_model_part_outer_initial_name)
? mpModel->GetModelPart(skin_model_part_outer_initial_name)
: mpModel->CreateModelPart(skin_model_part_outer_initial_name);

// 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];
}

// compute unique_knot_vector_w
Vector unique_knot_vector_w(2+(NumKnotSpansW-1));
unique_knot_vector_w[0] = mKnotVectorW[0]; unique_knot_vector_w[NumKnotSpansW] = mKnotVectorW[mKnotVectorW.size()-1];
for (SizeType i_knot_insertion = 0; i_knot_insertion < NumKnotSpansW-1; i_knot_insertion++) {
unique_knot_vector_w[i_knot_insertion+1] = mInsertKnotsW[i_knot_insertion];
}

// Set the value of the knot vectors
r_iga_model_part.SetValue(KNOT_VECTOR_U, unique_knot_vector_u);
r_iga_model_part.SetValue(KNOT_VECTOR_V, unique_knot_vector_v);
r_iga_model_part.SetValue(KNOT_VECTOR_W, unique_knot_vector_w);

// Create the parameters for the SnakeSbmProcess
Kratos::Parameters snake_parameters;
snake_parameters.AddString("model_part_name", iga_model_part_name);
snake_parameters.AddString("skin_model_part_name", skin_model_part_name);
snake_parameters.AddDouble("echo_level", mEchoLevel);
snake_parameters.AddString("skin_model_part_inner_initial_name", skin_model_part_inner_initial_name);
snake_parameters.AddString("skin_model_part_outer_initial_name", skin_model_part_outer_initial_name);
if (mParameters.Has("lambda_inner"))
snake_parameters.AddDouble("lambda_inner", mParameters["lambda_inner"].GetDouble());
if (mParameters.Has("lambda_outer"))
snake_parameters.AddDouble("lambda_outer", mParameters["lambda_outer"].GetDouble());
if (mParameters.Has("number_of_inner_loops"))
snake_parameters.AddDouble("number_of_inner_loops", mParameters["number_of_inner_loops"].GetInt());

// Create the surrogate_sub_model_part for inner and outer // TODO: extend this in 3D
SnakeSbmProcess snake_sbm_process(*mpModel, snake_parameters);
snake_sbm_process.Execute();

// Create the breps for the outer sbm boundary // TODO: extend this in 3D
CreateBrepsSbmUtilities<Node, Point> CreateBrepsSbmUtilities(mEchoLevel);
// TODO: NEXT PR CreateSurrogateBoundary with Volume
// CreateBrepsSbmUtilities.CreateSurrogateBoundary(mpVolume, surrogate_sub_model_part_inner, surrogate_sub_model_part_outer, A_uvw, B_uvw, iga_model_part);
}


const Parameters NurbsGeometryModelerSbm::GetDefaultParameters() const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,28 @@ class KRATOS_API(IGA_APPLICATION) NurbsGeometryModelerSbm
const SizeType NumKnotSpansV,
const bool AddSurfaceToModelPart) override;

/**
* @brief Creates a regular grid composed out of bivariant B-splines.
* @param PointA Lower point of bounding 3D box.
* @param PointB Upper point of bounding 3D 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& rModelPart,
const Point& A_xyz,
const Point& B_xyz,
const Point& A_uvw,
const Point& B_uvw,
const SizeType OrderU,
const SizeType OrderV,
const SizeType OrderW,
const SizeType NumKnotSpansU,
const SizeType NumKnotSpansV,
const SizeType NumKnotSpansW,
const bool AddVolumeToModelPart) override;

Comment on lines +109 to +122
Copy link
Contributor

Choose a reason for hiding this comment

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

idem

private:

///@name Private Member Variables
Expand Down
1 change: 1 addition & 0 deletions applications/IgaApplication/iga_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ KRATOS_INFO("") << " KRATOS _____ _____\n"
KRATOS_REGISTER_VARIABLE(CONDITION_NAME)
KRATOS_REGISTER_VARIABLE(KNOT_VECTOR_U)
KRATOS_REGISTER_VARIABLE(KNOT_VECTOR_V)
KRATOS_REGISTER_VARIABLE(KNOT_VECTOR_W)
KRATOS_REGISTER_VARIABLE(KNOT_SPAN_SIZES)
KRATOS_REGISTER_VARIABLE(PARAMETER_SPACE_CORNERS)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ KRATOS_CREATE_VARIABLE(std::string, BOUNDARY_CONDITION_TYPE)
KRATOS_CREATE_VARIABLE(std::string, CONDITION_NAME)
KRATOS_CREATE_VARIABLE(Vector, KNOT_VECTOR_U)
KRATOS_CREATE_VARIABLE(Vector, KNOT_VECTOR_V)
KRATOS_CREATE_VARIABLE(Vector, KNOT_VECTOR_W)
KRATOS_CREATE_VARIABLE(Vector, KNOT_SPAN_SIZES)
KRATOS_CREATE_VARIABLE(std::vector<Vector>, PARAMETER_SPACE_CORNERS)

Expand Down
1 change: 1 addition & 0 deletions applications/IgaApplication/iga_application_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ KRATOS_DEFINE_APPLICATION_VARIABLE(IGA_APPLICATION, std::string, BOUNDARY_CONDIT
KRATOS_DEFINE_APPLICATION_VARIABLE(IGA_APPLICATION, std::string, CONDITION_NAME)
KRATOS_DEFINE_APPLICATION_VARIABLE(IGA_APPLICATION, Vector, KNOT_VECTOR_U)
KRATOS_DEFINE_APPLICATION_VARIABLE(IGA_APPLICATION, Vector, KNOT_VECTOR_V)
KRATOS_DEFINE_APPLICATION_VARIABLE(IGA_APPLICATION, Vector, KNOT_VECTOR_W)
KRATOS_DEFINE_APPLICATION_VARIABLE(IGA_APPLICATION, Vector, KNOT_SPAN_SIZES)
KRATOS_DEFINE_APPLICATION_VARIABLE(IGA_APPLICATION, std::vector<Vector>, PARAMETER_SPACE_CORNERS)

Expand Down
Loading