Skip to content

Commit

Permalink
fix debug test issue ref idaholab#22848
Browse files Browse the repository at this point in the history
  • Loading branch information
miaoyinb authored and MengnanLi91 committed Jan 4, 2023
1 parent ebc0929 commit b03d194
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
7 changes: 7 additions & 0 deletions framework/include/meshgenerators/FillBetweenCurvesGenerator.h
Expand Up @@ -54,4 +54,11 @@ class FillBetweenCurvesGenerator : public MeshGenerator
std::unique_ptr<MeshBase> & _input_1;
/// The mesh which contains the second input boundary
std::unique_ptr<MeshBase> & _input_2;

/**
* Calculates the centroid of a curve mesh.
* @param curve input mesh that contains the curve whose centroid needs to be calculated
* @return a Point data containing the curve centroid
*/
Point curveCentroidPoint(const ReplicatedMesh & curve);
};
33 changes: 22 additions & 11 deletions framework/src/meshgenerators/FillBetweenCurvesGenerator.C
Expand Up @@ -10,7 +10,6 @@
#include "FillBetweenCurvesGenerator.h"
#include "FillBetweenPointVectorsTools.h"

#include "MooseMeshUtils.h"
#include "CastUniquePointer.h"
#include "libmesh/node.h"

Expand Down Expand Up @@ -113,23 +112,21 @@ FillBetweenCurvesGenerator::generate()

try
{
FillBetweenPointVectorsTools::isCurveOpenSingleSegment(
*input_mesh_1,
max_input_mesh_1_node_radius,
curve_1_ordered_nodes,
MooseMeshUtils::meshCentroidCalculator(*input_mesh_1));
FillBetweenPointVectorsTools::isCurveOpenSingleSegment(*input_mesh_1,
max_input_mesh_1_node_radius,
curve_1_ordered_nodes,
curveCentroidPoint(*input_mesh_1));
}
catch (MooseException & e)
{
paramError("curve_1", e.what());
}
try
{
FillBetweenPointVectorsTools::isCurveOpenSingleSegment(
*input_mesh_2,
max_input_mesh_2_node_radius,
curve_2_ordered_nodes,
MooseMeshUtils::meshCentroidCalculator(*input_mesh_2));
FillBetweenPointVectorsTools::isCurveOpenSingleSegment(*input_mesh_2,
max_input_mesh_2_node_radius,
curve_2_ordered_nodes,
curveCentroidPoint(*input_mesh_2));
}
catch (MooseException & e)
{
Expand Down Expand Up @@ -165,3 +162,17 @@ FillBetweenCurvesGenerator::generate()

return dynamic_pointer_cast<MeshBase>(mesh);
}

Point
FillBetweenCurvesGenerator::curveCentroidPoint(const ReplicatedMesh & curve)
{
Point pt_tmp = Point(0.0, 0.0, 0.0);
Real length_tmp = 0.0;
for (const auto elem : curve.element_ptr_range())
{
Real elem_length = elem->hmax();
pt_tmp += (elem->vertex_average()) * elem_length;
length_tmp += elem_length;
}
return pt_tmp / length_tmp;
}

0 comments on commit b03d194

Please sign in to comment.