Skip to content

Add new API for getting Jacobian information about model.#41

Merged
hsorby merged 8 commits intoABI-Software:mainfrom
hsorby:main
Feb 13, 2025
Merged

Add new API for getting Jacobian information about model.#41
hsorby merged 8 commits intoABI-Software:mainfrom
hsorby:main

Conversation

@hsorby
Copy link
Contributor

@hsorby hsorby commented Feb 8, 2025

No description provided.

"""
with ChangeManager(self._fieldmodule):
jacobian = calculate_jacobian(self._modelCoordinatesField)
report = report_on_lowest_value(jacobian, mesh_group if mesh_group else None)
Copy link
Member

Choose a reason for hiding this comment

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

Add following line within context manager:
del jacobian
so no notification about field ever existing.
Note I'd also prefer mesh_3d to be discovered here and a mesh or mesh_group passed to the function creating the jacobian field.


return None, None

def getModelWorstElementJacobianInfo(self, mesh_group=None):
Copy link
Member

Choose a reason for hiding this comment

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

getLowestElementJacobian(self, mesh_group=None)
Add comment that a value <= 0.0 is bad, either zero or negative volume / left-handed coordinates.

:param group_name: Name of group to make calculation over.
:return: Element identifier, minimum jacobian value.
"""
with ChangeManager(self._fieldmodule):
Copy link
Member

Choose a reason for hiding this comment

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

ChangeManager is redundant here.


return report

def getModelWorstElementJacobianInfoForGroup(self, group_name):
Copy link
Member

Choose a reason for hiding this comment

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

getLowestElementJacobianForGroupName

If the group_name is not a valid group name then None, None is returned.

:param group_name: Name of group to make calculation over.
:return: Element identifier, minimum jacobian value.
Copy link
Member

Choose a reason for hiding this comment

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

Need to note returns -1, inf if failed to evaluate, but this is at odds with returning None, None below.

"""
group = self._fieldmodule.findFieldByName(group_name).castGroup()
if group.isValid():
return self.getLowestElementJacobian(group)
Copy link
Member

Choose a reason for hiding this comment

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

Need to get mesh group for highest dimension mesh and pass it here; it doesn't a group field.

from cmlibs.utils.zinc.finiteelement import evaluate_field_nodeset_range, findNodeWithName, getMaximumNodeIdentifier
from cmlibs.utils.zinc.finiteelement import evaluate_field_nodeset_range, findNodeWithName
from cmlibs.utils.zinc.general import ChangeManager
from cmlibs.utils.zinc.field import get_element_jacobian_field, get_scalar_field_minimum_in_mesh
Copy link
Member

Choose a reason for hiding this comment

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

Might be some changes to name and locations of these cmlibs.utils.

Copy link
Member

@rchristie rchristie left a comment

Choose a reason for hiding this comment

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

Looks good.

@hsorby hsorby merged commit 1578de6 into ABI-Software:main Feb 13, 2025
1 check passed
:return: Element identifier, minimum jacobian value. Values are -1, inf if there is no data or bad fields.
"""
with ChangeManager(self._fieldmodule):
jacobian = create_xi_reference_jacobian_determinant_field(self._modelCoordinatesField)
Copy link
Member

Choose a reason for hiding this comment

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

needs reference coordinate field argument:
jacobian = create_jacobian_determinant_field(self._modelCoordinatesField, self._modelReferenceCoordinatesField)
also do a test evaluation in any test. in test_fitcube.py test_alignMarkersFitRegularData

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants