Model.elementqualitysmoothnodesnew#

Model.elementqualitysmoothnodesnew(elem_collection, nodes_collection, algorithm, target_qi, max_iterations, time_limit)#

Smooths/optimizes nodes of selected elements. This function only functions between a Model.elementqualitysetup() function and a Model.elementqualityshutdown() function. Current element quality criteria for optimization must be set before using this function. The function may be applied at any time without resetting the current quality criteria.

Parameters:
  • elem_collection (Collection) – The collection containing the element entities to smooth.

  • nodes_collection (Collection) – The collection containing the anchor node entities.

  • algorithm (int) –

    0 - Autodecide.

    1 - Size corrected.

    2 - Shape corrected.

    3 - QI optimization.

    4 - QI optimization maintaining nodes on geometry edges. For models without geometry, this is the same as 3.

  • target_qi (double) – The target QI value, when algorithm=3.

  • max_iterations (int) – The maximum number of iterations, when algorithm=3.

  • time_limit (int) – The maximum time limit, when algorithm=3.

Example#

Smooth elements with IDs 1 - 100 use QI optimization with a target QI of 0.2 use quality criteria from a file#
import hm
import hm.entities as ent

model = hm.Model()

model.readqualitycriteria(file_name="c:/criteria/mycriteria.txt")

elems = model.CreateCollectionByDisplayed(ent.Element)
model.elementqualitysetup(elementcollection=elems)

elem_collection = hm.Collection(model, ent.Element, list(range(1,101)))
Filter = hm.FilterByCollection(ent.Node, ent.Line)
nodes_collection = [n for n in hm.Collection(model, Filter, elem_collection)]

model.elementqualitysmoothnodesnew(elem_collection=elem_collection, nodes_collection, algorithm=3, target_qi=0.2, max_iterations=5, time_limit=0)

model.elementqualityshutdown(dontsaveflag=1)