Refactoring itk::FEM framework - V4
This page outlines the proposed changes to the itk::FEM framework. A number of these changes will break backwards compatibility.
Submission Of Code
http://review.source.kitware.com/#change,1993
Authors
The proposed changes for the itk::FEM framework are being proposed by the University of Iowa. This group is made up of investigators from the Departments of Radiology, Biomedical Engineering, and Psychiatry. Questions and comments regarding these changes should be sent to
- Vincent Magnotta (vincent-magnotta -at- uiowa.edu) - Radiology
Other team members include
- Nicole Grosland - Biomedical Engineering, MIMX
- Kiran Shivanna - MIMX
- Hans Johnson - Psychiatry
- Kent Williams - Psychiatry
Changes to the FEM Framework Classes
itk::fem::FEMLightObject
This class has been updated to remove public access to the class variables. All fem classes derive from this class. This class was also converted to support smart pointers.
- Move the following class variables from public to protected:
- GN - This variable was renamed to m_GlobalNumber
- The following member functions were added to support setting the global number for fem objects
- void SetGlobalNumber(int)
- int GetGlobalNumber()
itk::FEMObject
Currently the itk::fem framework offers a complicated interface for specifying mesh to be used for analysis. We will create a new ITK object called itk::FEMObject which will define the entire FE model. The itk::FEMObject will inherit from itk::DataObject. This object will allow the user to completely specify the Nodes, Elements, Loads, and Materials for the problem. This decision was based on the decision to make a parallel structure to itk::Mesh without a complete refactoring of the mesh data structure. This also removes the specification of the FE simulation from the solver.
In order to support input/output, we have decided to use SpatialObjects. To support the new FEMObject, a new FEMSpatialObject was created. This also required that additions be added to the metaIO library to support this new spatial object type. The minor disadvantage of this implementation is that new element, load, and material types will require additions in multiple locations. We have decided to use the same FEM model specification that was used previously, but it is now encoded in a spatial object.
Migration Guide
The itk::fem::FEMObject was created to provide support for a first class object in ITK that will define the finite element problem being used for analysis. This used to be defined only in the itk::fem::Solver. All support for file I/O was removed from this class. The user would now define a FEMObject object and use this an input into the solver. Here is an outline on how to define a new problem.
itk::fem::FEMObject::Pointer fem = itk::fem::FEMObject::New(); . . . itk::fem::Solver::Pointer solver = itk::fem::Solver::New(); solver->SetInput( fem ); solver->Update( ); itk::fem::FEMObject::Pointer result = solver->GetOutput();
The FEMObject has interfaces to define the nodes, elements, materials, and loads used to define the finite element problem. Here are the public member functions used to manipulate the various portions of the FEM problem.
- Nodes:
- AddNextNode (Element::Node::Pointer e) - Add another node to the FEM problem. This will be added as the last node in the node container
- InsertElement (Element::Pointer e, ElementIdentifier index) - Add another node at the specified position in the node container
- GetNode (NodeIdentifier index) - Get the node at the specified index of the node container
- GetNodeWithGlobalNumber (int globalNumber) - Get the node with the specified global number. This is independent of the order in the node container, and is defined by the user when defining the FEM problem.
- GetNumberOfElements (void) - Get number of nodes in the FEM problem
- GetNodeContainer () - Get the entire node container
- Elements:
- AddNextElement (Element::Pointer e) - Add another element to the FEM problem. This will be added as the last element in the element container
- GetElementContainer () - Get the entire element container
- GetNumberOfElements (void) - Get number of elements in the FEM problem
- InsertElement (Element::Pointer e, ElementIdentifier index) - Add another element at the specified position in the element container
- GetElement (ElementIdentifier index) - Get the element at the specified index of the element container
- GetElementWithGlobalNumber (int globalNumber) - Get the element with the specified global number. This is independent of the order in the element container, and is defined by the user when defining the FEM problem.
- Loads:
- AddNextLoad() - Add another load to the FEM problem. This will be added as the last load in the load container
- InsertLoad() - Add another load at the specified position in the load container
- GetNumberOfLoads() - Get number of loads in the FEM problem
- GetLoadContainer() - Get the entire load container
- GetLoadWithGlobalNumber() - Get the load with the specified global number. This is independent of the order in the load container, and is defined by the user when defining the FEM problem.
- GetLoad() - Get the load at the specified index in the load container.
- Materials:
- GetMaterialContainer () - Get the entire material container
- AddNextMaterial (MaterialLinearElasticity::Pointer mat) - Add another material at the specified position in the material container
- GetNumberOfMaterials (void) - Get number of materials in the FEM problem
- InsertMaterial (Material::Pointer e, MaterialIdentifier index) - Add another material at the specified position in the material container
- GetMaterial (MaterialIdentifier index)
- GetMaterialWithGlobalNumber (int globalNumber) - Get the material with the specified global number. This is independent of the order in the material container, and is defined by the user when defining the FEM problem.
- Other Public Membership Functions:
- Clear () - Initialize the FEMObject
- DeepCopy (FEMObject *Copy) - Copy the FEMObject into the current FEMObject
- FinalizeMesh () - Finalize the mesh. This must be called before using this object in the itk::fem::Solver
- GetNumberOfDegreesOfFreedom (void) - Get the degrees of freedom for the FEMObject
- GetNumberOfMultiFreedomConstraints (void) - Get the number of constraints for the FEMObject
itk::fem::Node
This class is defined in itkFEMElementBase.h and defines the degree of freedom and coordinate for the node. A node is essentially a point in space.
- Public Member Functions:
- VectorType & GetCoordinates(void) - get the spatial coordinates for the node
- void SetCoordinates(const VectorType & coords) - Set the spatial coordinates of the node
- DegreeOfFreedomIDType GetDegreeOfFreedom(unsigned int i) - Get the degree of freedom for the spatial coordinate (x,y,z)
- void SetDegreeOfFreedom(unsigned int i, DegreeOfFreedomIDType dof) - Set the degree of freedom for the spatial coordinate
- void ClearDegreesOfFreedom(void) - Remove all of the degrees of freedom
itk::fem::Element
This is the base class and specific element types are defined below. This class did not change from its implementation in previous versions of ITK. The following changes were made to each of the specific element types.
- The following variables have been moved from public to protected:
- mat - This variable is now called m_mat
- The following variables have been moved from public to protected:
- Material::ConstPointer GetMaterial(void) - Get the material property used for the element
- void SetMaterial(Material::ConstPointer mat_) - Set the material property for the element
- The following public membership functions have been removed:
- void Read(std::istream &, void *info)
- void Write(std::ostream & f)
The specific element types available are defined below:
- Element2DC1Beam
- Element2DC0LinearQuadrilateralStress
- Element2DC0LinearQuadrilateralStrain
- Element2DC0LinearQuadrilateralMembrane
- Element2DC0LinearTriangularStress
- Element2DC0LinearTriangularStrain
- Element2DC0LinearTriangularMembrane
- Element2DC0QuadraticTriangularStress
- Element2DC0QuadraticTriangularStrain
- Element3DC0LinearHexahedronMembrane
- Element3DC0LinearHexahedronStrain
- Element3DC0LinearTetrahedronMembrane
- Element3DC0LinearTetrahedronStrain
- Element3DC0LinearTriangularLaplaceBeltrami
- Element3DC0LinearTriangularMembrane
itk::fem::MaterialLinearElasticity
MaterialLinearElasticity is the only material type that currently exists in ITK. Several modifications were made to this class during the ITKv4 refactoring.
- Move the following class variables were moved from public to protected signatures:
- A - renamed to m_CrossSectionalArea
- E - renamed m_YoungModulus
- h - renamed m_Thickness
- I - renamed m_MomentOfInertia
- nu - renamed m_PoissonRatio
- RhoC - renamed m_DensityHeatCapacity
- Add the following public class member functions to get/set the class variables.
- void SetCrossSectionalArea(double) – Set the cross sectional area
- void SetYoungsModulus(double) – Set the Youngs Modulus
- void SetThickness(double) – Set the cross sectional thickness
- void SetMomentOfInertia(double) – Set the Moment of Inertia
- void SetPoissonsRatio(double) – Set the Poisson’s ratio
- void SetDensityHeatProduct(double) – Set the Density - Heat Capacity product
- double GetCrossSectionalArea() – Get the cross sectional area
- double GetYoungsModulus() – Get the Youngs Modulus
- double GetThickness() – Get the cross sectional thickness
- double GetMomentOfInertia() – Get the Moment of Inertia
- double GetPoissonsRatio() – Get the Poisson’s ratio
- double GetDensityHeatProduct() – Get the Density - Heat Capacity product
itk::fem::Load
This is the load base class for all specific implementations used in the itk::fem framework.
itk::fem::LoadBC
- The following class variables were from public to protected:
- m_dof - renamed to m_DegreeOfFreedom
- m_element - renamed to m_Element
- m_value - renamed to m_Value
- The following class variable was removed
- CLID
- The following class functions were added, allowing the user to get and set the class variables:
- void SetDegreeOfFreedom(unsigned int dof) – Set the degree of freedom for the local element for which the boundary condition is being applied.
- void SetElement(Element::ConstPointer element) – Set the element for which the boundary condition is being applied.
- void SetValue(vnl_vector< Element::Float > value) – Set the boundary condition using a vector representation. This can be used to restrict motion of an element in a particular direction.
- unsigned int GetDegreeOfFreedom() – Returns the local degree of freedom for the element on which the boundary condition is being applied.
- Element::ConstPointer GetElement() – Returns the element on which the boundary condition is being applied.
- vnl_vector< Element::Float > GetValue() – Returns the assigned boundary condition.
itk::fem::LoadBCMFC
- The following class variables were from public to protected:
- Index - renamed to m_Index
- lhs - renamed to m_LeftHandSide
- rhs - renamed to m_RightHandSide
- Add class methods to get and set the class variables.
- void SetIndex(int) – Set the index variable for the multi freedom displacement constraint. This is used internally by the itk::Fem::Solver.
- void AddLeftHandSideTerm(LoadBCMFC::MFCTerm) – Add terms to the right hand side of the multi freedom displacement constraint. Used to replace loadBCMFC.lhs.push_back().
- void AddRightHandSideTerm(vnl_vector< Element::Float >) – Set the right hand side of the linear equation that defines the constraints. Replaces loadBCMFC.rhs = a;
- int GetIndex – Get the index variable for the multi freedom displacement constraint.
- int GetNumberOfLeftHandSideTerms() – Returns the number of terms used to define the left hand side of the multi freedom displacement constraint.
- itk::LoadBFMC GetLeftHandSideTerm(int index) – Returns the specified left hand side term.
- int GetNumberOfRightHandSideTerms()– Returns the number of terms used to define the left hand side of the multi freedom displacement constraint.
- Element::Float GetRightHandSideTerm(int index) – Returns the specified right hand side term.
- std::vector< MFCTerm >& GetLeftHandSideArray() - Get the left hand side of the FEM system
- vnl_vector< Element::Float >& GetRightHandSideArray() - Get the right hand side of the FEM system
itk::fem::LoadEdge
- The following member variables were moved from public to protected signatures:
- m_Edge
- m_Force
- The following public membership functions are now provided to get/set class variables
- void SetEdge(int) – Set the edge to apply the desired force.
- void SetForce(vnl_matrix< Float >) – Set the force to be applied to an edge.
- int GetEdge() – Get the edge for the applied force.
- vnl_matrix< Float > GetForce() – Get the force applied.
- void ApplyLoad(Element::ConstPointer element, Element::VectorType & Fe) - Apply the load to the elements on which it is applied.
itk::fem::LoadGravConst
- Move the following class variables from public to protected signatures.
- Fg_value
- Provide class methods to get/set the class variables
- void SetForce(vnl_vector< Float >) – Set the constant force vector that exists for every point in space.
- vnl_vector< Float > GetForce() – Return the constant force vector that exists for every point in space.
itk::fem::LoadLandmark
- Move the following class variables from public to protected signatures.
- eta
- m_force
- m_pt
- m_Solution
- m_Source
- m_Target
- Add the following public interface
- void SetEta(double) – Set the square root of the variance.
- double GetEta(double) – Get the square root of the variance.
itk::fem::LoadNode
- Move the following class variables from public to protected signatures:
- F
- m_element
- m_pt
- Add the following class member functions
- void SetForce(vnl_vector< Float >) – Set the applied force to the node.
- void SetElement(Element::ConstPointer) – Set the element in the system that contains the degrees of freedom on which the force is applied.
- void SetNode(unsigned int) – Set the point on which the force is being applied.
- vnl_vector< Float > &GetForce() – Get the applied force.
- Element::ConstPointer GetElement() – Get the element in the system that contains the degrees of freedom on which the force is applied.
- Unsigned int GetNode() – Get the point on which the force is being applied.
itk::fem::LoadPoint
- Move the following class variables from public to protected signatures:
- Fp
- point
- Add public class methods to access these variables:
- void SetForce(vnl_vector<Float>) – Set the force to be applied to the specified point location.
- void SetPoint(vnl_vector<Float>) – Set the point where the force is applied in global coordinates.
- vnl_vector<Float> & GetForce(vnl_vector<Float>) – Get the applied force.
- vnl_vector<Float> & GetPoint (vnl_vector<Float>) – Get the point where the force is applied.
itk::Solver
- Move the following class variables from public to protected:
- node
- el
- load
- mat
- Add the following member functions:
- bool AddNextElement(ElementType *element) – Add the next element to the mesh data structure. This will be used to replace the solver->el.push_back()
- bool InsertElement(ElementType *element, unsigned long index) – Insert the element to the position within the mesh data structure.
- bool AddNextNode(NodeType *node) – Add the next node to the mesh data structure. This will be used to replace the solver->node.push_back()
- bool InsertNode(NodeType *node, unsigned long index) – Insert the node into the desired location within the mesh data structure.
- bool AddNextMaterial(itk::fem::FEMP<itk::fem::Material>) – Add the next material type to the solver.
- bool InsertMaterial(itk::fem::FEMP<itk::fem::Material>, int) – Insert the material property to the specified index in the solver material property array.
- bool AddNextLoad(itk::fem::FEMP<itk::fem::Load>) – Add the next load to the solver.
- bool InsertLoad(itk::fem::FEMP<itk::fem::Load>, int) – Insert the load to the specified index in the solver load array.
- bool GetElement(unsigned long index, ElementType *element) – Get the specified element from the mesh data structure
- bool GetNode(unsigned long index, NodeType *node) – Get the specified node from the mesh data structure
- bool GetMaterial(itk::fem::FEMP<itk::fem::Material>, int) – Get the specified material from the solver.
- bool GetLoad(itk::fem::FEMP<itk::fem::Load>, int) – Get the specified load from the solver.
- unsigned int GetNumberOfNodes() – Returns the number of nodes stored in the solver.
- unsigned int GetNumberOfElements()– Returns the number of element stored in the solver.
- unsigned int GetNumberOfMaterials()– Returns the number of materials stored in the solver.
- unsigned int GetNumberOfLoads() – Returns the number of loads stored in the solver
- bool ClearMaterialArray() – Insert the load to the specified index in the solver load array.
- bool ClearloadArray() – Insert the load to the specified index in the solver load array.
- bool RemoveMaterial(int) – Remove the material property at the specified index from the solver Material array.
- bool RemoveLoad(int) – Remove the load at the specified index from the solver load array.
- void SetMesh(itk::Mesh) – Specify the entire mesh to be used by the solver.
- itk::Mesh GetMesh() – Returns the mesh used by the solver.
- MeshType::Pointer GetDeformedMesh() – Returns the resulting mesh after applying the loading and boundary conditions on the mesh.
- itk::Array<double>::Pointer GetMeshStresses() – Returns the stresses for the mesh with each element of the array corresponding to an element in the mesh.
- itk::Array<double>::Pointer GetMeshStrains()– Returns the strains for the mesh with each element of the array corresponding to an element in the mesh.
Update the itk::FEMRegistrationFilter
To make the FEMRegistrationFilter similar to the other registration filters the following changes will be made
- Remove these public member functions. The application programmer will be responsible for loading the images and setting the parameters for the filter. The configuration file will be removed.
- GetConfigFileName ()
- GetFixedFile ()
- GetMovingFile ()
- GetResultsFileName ()
- GetWriteDisplacements ()
- ReadConfigFile (const char *)
- SetConfigFileName (const char *f)
- SetDisplacementsFile (const char *r)
- SetFixedFile (const char *t)
- SetLandmarkFile (const char *l)
- SetMovingFile (const char *r)
- SetResultsFile (const char *r)
- SetResultsFileName (const char *f)
- WriteDisplacementField (unsigned int index)
- WriteDisplacementFieldMultiComponent ()
- WriteWarpedImage (const char *fn)
- Add these new public member functions
- bool AddNextMovingLandmark(PointType) – Add another point for the moving image to the registration.
- bool AddNextFixedLandmark(PointType) – Add another point from the fixed image to the registration.
- void ClearMovingLandmarks() – Remove all of the existing landmarks for the moving image.
- void ClearFixedLandmarks() – Remove all of the existing landmarks for the fixed image.
- bool InsertMovingLandmark(PointType p, int index) – Insert the moving landmark at the specified index.
- bool InsertFixedLandmark(PointType p, int index) – Insert the fixed landmark at the specified index.
- bool RemoveMovingLandmark(int index)
- bool RemoveFixedLandmark(int index)
- void SetFEMesh() – Set the mesh to be used for the registration.
- void GetFEMesh() – Get the mesh used in the registration.
- void SetUserDefinedMesh(bool) – Specifies if the user will provide a custom mesh or if it will be generated based on the image.
File Formats
We are proposing to support I/O of the finite element models using Spatial Objects. There currently exists the itk::MeshSpatialObject, but this data structure does not completely contain all of the information required for a FEM. Therefore we are proposing to create a new object (itk::FEMObject) in ITK to hold the FE model information and use spatial objects to support the I/O. This is similar to what currently exists for itk::Mesh.
Other Formats
- Netgen supports gmsh format
- tetgen supports VTK
- VTK supports several additional formats
Data Structure
- Spatial Objects -
- ITK::Mesh -
- VTK Unstructured Grids -
Solvers
- SuperLU
- PETSc