Model.morphfittosurface#

Model.morphfittosurface(n_collection, e_collection, h_collection, s_collection, face, nhand, sym, con, mode, maxiter)#

Maps domains, elements, or morph volume faces to surfaces or a mesh, fitting the boundaries of the entities to the edges of the surfaces or mesh and projecting the interior nodes on to the target entities. In the case of domains and morph volume faces being fit to surfaces, multiple entities may be fitted to multiple surfaces with the intent of matching them one to one. In those cases, the interior edges of the entities will be mapped to interior edges of the surfaces as well.

This function can be used as a one step solution or in conjunction with the Model.morphmaptshp(), Model.morphmaptshpedge(), and Model.morphmaptshpface() functions if you want to place handles, edge domains, 2D domains, or morph volume faces before applying the fit operation.

When mapping domains to surfaces one to one, this function can also be used in conjunction with the Model.morphstorematch() function which allows you to manually set which domains should be mapped to which surfaces or automatically have it determine matches based on which domains currently lie on which surfaces.

Parameters:
  • n_collection (Collection) – The collection containing the node entities on the node entities to be fitted. This collection is for internal use and me left empty.

  • e_collection (Collection) – The collection containing the entities to be fitted. Valid entities are domains, elements and morphvolumes.

  • h_collection (Collection) – The collection containing the handle entities that are followers.

  • s_collection (Collection) – The collection containing the entities onto which the entites will be fitted. Valid entities are surfaces and elements.

  • face (int) – The face ID of selected morph volume edges and faces to be fitted. Valid values are 0 and 1. See the functions Model.morphmanageedgemark and Model.morphmanagefacemark for information on how to fill this collection.

  • nhand (int) – The number of handles per edge any morph volume faces will be updated to having during the fitting operation. The maximum value is 5. If you want to retain the current number of handles on the edges, set this value to -1.

  • sym (int) – 0 - Do not use symmetry

  • con (int) – 1 - Use constraints

  • mode (int) –

    0 - Match as group. Use with handle, edge, and face mapping functions.

    1 - Match as group. One step solution.

    2 - Match one to one. Use with handle, edge, and face mapping fucntions.

    3 - Match one to one. One step solution.

    4 - Match one to one. Use stored matches. Use with handle, edge, and face mapping functions.

    5 - Match one to one. Use stored matches. One step solution. When fitting to a collection of elements, only mode 0 and 1 are valid.

  • maxiter (unsigned int) – When matching entities one to one (mode 2 - 5), this is the maximum number of iterations attempted before settling on the best current solution. For mode 0 and 1 it is ignored.

Examples#

Fit a domain to a surface in one step#
import hm
import hm.entities as ent

model = hm.Model()

model.morphmanagefacemark(
    mvol_entity=ent.Morphvolume(model, 1), face_id=0, mlist=0, mode=3
)

model.morphmanagefacemark(
    mvol_entity=ent.Morphvolume(model, 2), face_id=2, mlist=0, mode=1
)

model.morphmanagefacemark(
    mvol_entity=ent.Morphvolume(model, 1), face_id=2, mlist=0, mode=1
)

model.morphfittosurface(
    n_collection=hm.Collection(model, ent.Node),
    e_collection=hm.Collection(model, ent.Domain),
    h_collection=hm.Collection(model, ent.Handle),
    s_collection=hm.Collection(model, ent.Surface, [3]),
    face=0,
    nhand=0,
    sym=0,
    con=1,
    mode=1,
    maxiter=0
)
Fit multiple morph volume faces to multiple surfaces one to one, increasing the handle density to 3 handles per edge#
import hm
import hm.entities as ent

model = hm.Model()

model.morphmanageedgemark(edge_id=0,user_mark_id=0,mode=3)
model.morphmanageedgemark(edge_id=0,user_mark_id=1,mode=3)
model.morphmanagefacemark(
    mvol_entity=ent.Morphvolume(model, 1), face_id=0, mlist=0, mode=3
)

model.morphmanageedgemark(edge_id=0,user_mark_id=0,mode=1)
model.morphmanageedgemark(edge_id=5,user_mark_id=0,mode=1)
model.morphmanageedgemark(edge_id=1,user_mark_id=0,mode=1)
model.morphmanageedgemark(edge_id=14,user_mark_id=0,mode=1)
model.morphmanagefacemark(
    mvol_entity=ent.Morphvolume(model, 2), face_id=4, mlist=0, mode=1
)

model.morphmanageedgemark(edge_id=5,user_mark_id=0,mode=1)
model.morphmanageedgemark(edge_id=10,user_mark_id=0,mode=1)
model.morphmanageedgemark(edge_id=6,user_mark_id=0,mode=1)
model.morphmanageedgemark(edge_id=19,user_mark_id=0,mode=1)
model.morphmanagefacemark(
    mvol_entity=ent.Morphvolume(model, 3), face_id=4, mlist=0, mode=1
)

model.morphmanageedgemark(edge_id=13,user_mark_id=0,mode=1)
model.morphmanageedgemark(edge_id=18,user_mark_id=0,mode=1)
model.morphmanageedgemark(edge_id=14,user_mark_id=0,mode=1)
model.morphmanageedgemark(edge_id=26,user_mark_id=0,mode=1)
model.morphmanagefacemark(
    mvol_entity=ent.Morphvolume(model, 34), face_id=4, mlist=0, mode=1
)

model.morphmanageedgemark(edge_id=18,user_mark_id=0,mode=1)
model.morphmanageedgemark(edge_id=23,user_mark_id=0,mode=1)
model.morphmanageedgemark(edge_id=19,user_mark_id=0,mode=1)
model.morphmanageedgemark(edge_id=29,user_mark_id=0,mode=1)
model.morphmanagefacemark(
    mvol_entity=ent.Morphvolume(model, 5), face_id=4, mlist=0, mode=1
)

model.morphfittosurface(
    n_collection=hm.Collection(model, ent.Node),
    e_collection=hm.Collection(model, ent.Morphvolume, [1, 2, 3, 4, 5]),
    h_collection=hm.Collection(model, ent.Handle),
    s_collection=hm.Collection(model, ent.Surface, [1, 2, 3, 4, 5]),
    face=0,
    nhand=-1,
    sym=0,
    con=1,
    mode=3,
    maxiter=50
)