myToCreateNewNodes(DefaultToCreateNewNodes()),
myToUseBoundaryRecoveryVersion(DefaultToUseBoundaryRecoveryVersion()),
myToUseFemCorrection(DefaultToUseFEMCorrection()),
- myToRemoveCentralPoint(DefaultToRemoveCentralPoint())
+ myToRemoveCentralPoint(DefaultToRemoveCentralPoint()),
+ myUseLib(DefaultToUseLib())
{
_name = "HYBRID_Parameters";
_param_algo_dim = 3;
}
}
+//=======================================================================
+//function : SetToUseLibrary
+//=======================================================================
+
+void HYBRIDPlugin_Hypothesis::SetToUseLibrary(bool toUseLib)
+{
+ if ( myUseLib != toUseLib ) {
+ myUseLib = toUseLib;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=======================================================================
+//function : GetToUseLibrary
+//=======================================================================
+
+bool HYBRIDPlugin_Hypothesis::GetToUseLibrary() const
+{
+ return myUseLib;
+}
+
+//=======================================================================
+//function : GetToUseLibrary
+//=======================================================================
+
+bool HYBRIDPlugin_Hypothesis::GetToUseLibrary(const HYBRIDPlugin_Hypothesis* hyp)
+{
+ bool res;
+ if ( hyp )
+ res = hyp->GetToUseLibrary();
+ else
+ res = DefaultToUseLib();
+ return res;
+}
+
//=======================================================================
//function : SetLayersOnAllWrap
_groupsToRemove.clear();
}
+//=======================================================================
+//function : DefaultToUseLib
+//=======================================================================
+
+bool HYBRIDPlugin_Hypothesis::DefaultToUseLib()
+{
+ // default is false but it can be change by environment variable
+ if (getenv("MG_HYBRID_USE_LIB"))
+ return true;
+ return false;
+}
//=======================================================================
//function : DefaultLayersOnAllWrap
geom_groups = [Inlet_x, Inlet_z, Outlet, Wall]
d_geom_groups = {}
+for geom_group in geom_groups:
+ name = geom_group.GetName()
+ d_geom_groups[name] = geom_group
+
+shape_volume = geompy.BasicProperties(piquage)[2]
###
### SMESH component
MG_Hybrid_Parameters_1.SetNbOfBoundaryLayers( 3 )
MG_Hybrid_Parameters_1.SetFacesWithLayers( wall_ids )
+Mesh_1.Compute()
-isDone = Mesh_1.Compute()
+def checkMesh_1(Mesh_1):
+ Mesh_1.CheckCompute()
-if not isDone:
- raise Exception("Error when computing Mesh_without_imprinting")
+ d_groups_1 = {}
-d_groups_1 = {}
+ for geom_group in geom_groups:
+ name = geom_group.GetName()
+ gr = Mesh_1.Group(geom_group)
+ d_groups_1[name] = gr
+ d_geom_groups[name] = geom_group
-for geom_group in geom_groups:
- name = geom_group.GetName()
- gr = Mesh_1.Group(geom_group)
- d_groups_1[name] = gr
- d_geom_groups[name] = geom_group
+ assert Mesh_1.NbQuadrangles() == 0
-assert Mesh_1.NbQuadrangles() == 0
+ # Compare whole mesh volume
+ volume_error_1 = abs(shape_volume-Mesh_1.GetVolume())/shape_volume
-shape_volume = geompy.BasicProperties(piquage)[2]
+ assert volume_error_1 < 0.02
-# Compare whole mesh volume
-volume_error_1 = abs(shape_volume-Mesh_1.GetVolume())/shape_volume
+ return d_groups_1
-assert volume_error_1 < 0.02
+d_groups_1 = checkMesh_1(Mesh_1)
+
+# Compute same mesh with library
+MG_Hybrid_Parameters_1.SetToUseLibrary(True)
+Mesh_1.Clear()
+Mesh_1.Compute()
+d_groups_1 = checkMesh_1(Mesh_1)
# Viscous layers with imprinting
# ==============================
isDone = Mesh_2.Compute()
-if not isDone:
- raise Exception("Error when computing Mesh_with_imprinting")
+mesh_2_volume = Mesh_2.GetVolume()
+faces_imprinted = ["Inlet_x", "Inlet_z", "Outlet"]
+
+def checkMesh_2(Mesh_2, d_groups_1):
+ Mesh_2.CheckCompute()
+ assert Mesh_2.NbQuadrangles() > 0
-assert Mesh_2.NbQuadrangles() > 0
+ d_groups_2 = {}
-d_groups_2 = {}
+ for geom_group in geom_groups:
+ name = geom_group.GetName()
+ gr = Mesh_2.Group(geom_group)
+ d_groups_2[name] = gr
-for geom_group in geom_groups:
- name = geom_group.GetName()
- gr = Mesh_2.Group(geom_group)
- d_groups_2[name] = gr
+ # Check viscous layers with imprinting
+ for name in faces_imprinted:
+ geom_area = geompy.BasicProperties(d_geom_groups[name])[1]
+ gr_1 = d_groups_1[name]
+ gr_2 = d_groups_2[name]
+ #assert gr_1.Size() > 0
+ assert gr_2.Size() > 0
+ # Nb of quadrangles is in 7th index of mesh info
+ assert gr_2.GetMeshInfo()[7] > 0
-faces_imprinted = ["Inlet_x", "Inlet_z", "Outlet"]
+ # Compare mesh group and geom group
+ area_error_1 = abs(geom_area-smesh.GetArea(gr_2))/geom_area
+ assert area_error_1 < 0.025
+ # Compare mesh group with imprinting and mesh group without imprinting
+ area_error_2 = abs(smesh.GetArea(gr_1)-smesh.GetArea(gr_2))/smesh.GetArea(gr_1)
+ assert area_error_2 < 1e-08
-# Check viscous layers with imprinting
-for name in faces_imprinted:
- geom_area = geompy.BasicProperties(d_geom_groups[name])[1]
- gr_1 = d_groups_1[name]
- gr_2 = d_groups_2[name]
- #assert gr_1.Size() > 0
- assert gr_2.Size() > 0
- # Nb of quadrangles is in 7th index of mesh info
- assert gr_2.GetMeshInfo()[7] > 0
-
- # Compare mesh group and geom group
- area_error_1 = abs(geom_area-smesh.GetArea(gr_2))/geom_area
- assert area_error_1 < 0.025
- # Compare mesh group with imprinting and mesh group without imprinting
- area_error_2 = abs(smesh.GetArea(gr_1)-smesh.GetArea(gr_2))/smesh.GetArea(gr_1)
- assert area_error_2 < 1e-08
-
-# Compare whole mesh volume
-mesh_2_volume = Mesh_2.GetVolume()
-volume_error_2 = abs(shape_volume-mesh_2_volume)/shape_volume
+ # Compare whole mesh volume
+ volume_error_2 = abs(shape_volume-mesh_2_volume)/shape_volume
+
+ assert volume_error_2 < 0.02
-assert volume_error_2 < 0.02
+ return d_groups_2
+
+d_groups_2 = checkMesh_2(Mesh_2, d_groups_1)
+
+# Compute same mesh with library
+MG_Hybrid_Parameters_2.SetToUseLibrary(True)
+Mesh_2.Clear()
+Mesh_2.Compute()
+d_groups_2 = checkMesh_2(Mesh_2, d_groups_1)
# Viscous layers with imprinting set by groups
# ============================================
isDone = Mesh_3.Compute()
-if not isDone:
- raise Exception("Error when computing Mesh_with_imprinting_set_by_groups")
+def checkMesh_3(Mesh_3, d_groups_2):
+ Mesh_3.CheckCompute()
-d_groups_3 = {}
+ d_groups_3 = {}
-for geom_group in geom_groups:
- name = geom_group.GetName()
- gr = Mesh_3.Group(geom_group)
- d_groups_3[name] = gr
+ for geom_group in geom_groups:
+ name = geom_group.GetName()
+ gr = Mesh_3.Group(geom_group)
+ d_groups_3[name] = gr
+
+ # Compare whole mesh volume
+ mesh_3_volume = Mesh_3.GetVolume()
+ volume_error_3 = abs(mesh_2_volume-mesh_3_volume)/mesh_2_volume
+
+ assert math.isclose(mesh_3_volume,mesh_2_volume,rel_tol=1e-7)
-# Compare whole mesh volume
-mesh_3_volume = Mesh_3.GetVolume()
-volume_error_3 = abs(mesh_2_volume-mesh_3_volume)/mesh_2_volume
+ # Check viscous layers with imprinting
+ for name in faces_imprinted:
+ gr_2 = d_groups_2[name]
+ gr_3 = d_groups_3[name]
+ assert gr_3.Size() > 0
+ # Nb of quadrangles is in 7th index of mesh info
+ assert gr_2.GetMeshInfo()[7] == gr_3.GetMeshInfo()[7]
-assert math.isclose(mesh_3_volume,mesh_2_volume,rel_tol=1e-7)
+ # Compare mesh group with imprinting set by ids and mesh group with imprinting set by geom group
+ assert math.isclose( smesh.GetArea(gr_2), smesh.GetArea(gr_3))
-# Check viscous layers with imprinting
-for name in faces_imprinted:
- gr_2 = d_groups_2[name]
- gr_3 = d_groups_3[name]
- assert gr_3.Size() > 0
- # Nb of quadrangles is in 7th index of mesh info
- assert gr_2.GetMeshInfo()[7] == gr_3.GetMeshInfo()[7]
+checkMesh_3(Mesh_3, d_groups_2)
- # Compare mesh group with imprinting set by ids and mesh group with imprinting set by geom group
- assert math.isclose( smesh.GetArea(gr_2), smesh.GetArea(gr_3))
+# Compute same mesh with library
+MG_Hybrid_Parameters_3.SetToUseLibrary(True)
+Mesh_3.Clear()
+Mesh_3.Compute()
+checkMesh_3(Mesh_3, d_groups_2)