#acl +All:read Default #format wiki #language en <<TableOfContents>> = Target Outcome = Finite element mesh of a tissue of interest ready for model development: * node definitions * element definitions * node set definitions * element set definitions * surface set definitions ---- = Prerequisites = <<Include(Infrastructure/AuxiliarySoftware, "Infrastructure", 2, from="= Geometry & Mesh Generation & Manipulation =", to="= Scripting & Numerical Analysis =")>> == Previous Protocols == For more details, see [[Specifications/GeometryGeneration]]. ---- = Protocols = == Input == * Explicit surface representation of tissue of interest; in STL format in MRI coordinate system (processed with volume preserving smoothing) ---- == Overview == There is a script which performs the following tasks: 1. Import surface into mesh module of SALOME 1. Define mesh generation parameters, e.g. NETGEN 3D Parameters. (this will dictate internal mesh density) 1. Compute the mesh. 1. Define groups, e.g. element, node, face sets. 1. Export mesh using the .med extention In order to run the script: 1. Create an xml file with connectivity between components according to these directions 1. Run the script !StlToMed.py for tetrahedral meshing of the tissues of interest in Salome. == Creating the Connectivity File == To create the connectivity file the user should have the STLs for all the tissues that were created in the Geometry Generation step. Each part is referenced as an XML element. Within this element several child elements are needed: file, material, Tie, and Contact. === File === The path to the stl file === Material === The pre-defined materials are elastic, rigid === Tie and Contact === The Tie and Contact elements contain the parts that they are paired with as sub-elements Definition of Tie and Contact Constraints: * Tie- there is no “slip” between the parts, they are “tied together” * Contact- the parts are touching, but they can slip/move with respect to one another. The Tie and Contact constraints which will be used to create the node groups are defined by geometric principles relating the two tissues. The currently defined principles are: * Proximity – find all nodes on the paired surface within a distance related to the element size. This is the default for Tie constraints. * Normals – select faces that have normal vectors that point toward the barycenter of the other tissue. This can also be limited by the proximity if desired. * Contains – one mesh contains the other, select faces that have normal vectors that point inward or outward. * All – all the surfaces. This is the default for contact. === Sample Connectivity File === Click [[https://simtk.org/svn/openknee/oks/oks001/dat/Model/Connectivity.xml|here]] to view a full knee model Connectivity File. Here is an excerpt from connectivity xml file for the knee model to demonstrate the use of the xml elements. It includes the Femur and Fibula elements. <Assembly> <Femur> <file>/path/to/file/Femur.stl</file> <material>rigid</material> <Contact> <MCL/> <LCL type="normals" multiplier="5"/> <QT type="normals" multiplier = "15"/> </Contact> <Tie> <FMC/> <LCL multiplier="2"/> <ACL multiplier="0.8"/> <PCL multiplier="1"/> </Tie> </Femur> <Fibula> <file>/path/to/file/Fibula.stl</file> <material>rigid</material> <Contact> </Contact> <Tie> <LCL/> </Tie> </Fibula> </Assembly> === Connectivity File when generating mesh for a single tissue === It may be desired to re-generate the groups for a single tissue, for example if the other groups were already created, and then a change was made to a single geometry in the model. In order to do this, a Connectivity File can be created including only the groups that need to be regenerated. '''IMPORTANT NOTE!!''' When running the script (see directions below), be sure to place the Connectivity File in a new directory not containing the previous MED folder. This is to avoid overwriting the previously generated MED files with the new med files. The single tissue MED file can be moved to the 'old' MED folder after it is generated. For example, if the ACL and all its groups were to be re-generated, the Connectivity File should look like below. Note that any parts that the ACL is contacting/tied with are included in the file, however none of the tie/contact groups for any other tissues are included, as we do not wish to re-generate those groups. (MED files will still be created for the other parts, but they will not include any groups. These files can be deleted afterwards, the only one we are interested in is the ACL) <Assembly> <ACL> <file>oks001_MRC_ACL_AGS_01_LVTIT.stl</file> <material>elastic</material> <Tie> <FMB multiplier="2"/> <TBB multiplier="2"/> </Tie> <Contact> <PCL/> <FMB type="normals"/> <TBB type="normals"/> </Contact> </ACL> <FMB> <file>oks001_MRG_FMB_CPL_LVTIT_02.stl</file> <material>rigid</material> <Tie> </Tie> <Contact> </Contact> </FMB> <TBB> <file>oks001_MRC_TBB_SKC_01_LVTIT.stl</file> <material>rigid</material> <Tie> </Tie> <Contact> </Contact> </TBB> </Assembly> == Scripted Procedure for Tetrahedral Meshing == Refer to [[https://simtk.org/svn/openknee/utl/ModelAssembly/|this]] folder for python scripts including (!StlToMed.py) and (!ConnectivityXml.py) to read the xml file with the connectivity of several stl files in the same coordinate system. It will then mesh them in 3D, and create groups of elements and nodes for applying boundary conditions. Currently it makes groups of all, outer surface, and a proximity based tie condition. The 3D meshes are saved in MED format. === Directions for running the script === 1. Save the script (!StlToMed.py) in a Folder on your computer. 1. Link the external python packages to Salome. Add a new text file with the extension .pth to Salome's python site-packages directory. The .pth file should contain the path to the site-packages of the other python installation you wish to use. * There are two possible locations for Salome's python site-packages directory depending on the Salome installation method: 1. ROOT/appli_V7_7_1/lib/python2.7/site-packages/salome. 1. ROOT/PREREQUISITES/INSTALL/Python-2.7.10/FROM_nothing/lib/python2.7/site-packages. * Example: If the path to the folder containing the python script !StlToMed.py is: home/user/Documents/FolderContainingScript, you will type that in a text file, and save it in Salome's Python site-packages folder with .pth extension. 1. Save the connectivity file (!NameOfConnectivityFile.xml), and tissues surfaces (Tibia.stl, Femur.stl, etc.) on your computer. Be sure that the Connectivity File points to the correct file locations for the stl files. * '''IMPORTANT NOTE:''' The script will generate the MED folder in the same directory as the Connectivity File. If a MED folder already exists, it will use that folder, and overwrite any MED files with the same file names. If you do not wish for this to occur, either move the Connectivity file to a different directory, or re-name the previous MED folder so that the script creates a new one. 1. Call the script from the terminal, giving the xml file as the argument. Be sure to include the paths to the script and xml file, if you are not already in the directory containing them (or if one is in a different directory). To do this, type in the terminal: salome /path/to/script/StlToMed.py args:/path/to/xml/NameOfConnectivityFile.xml *If already in desired folder in terminal, no need to include path to file.To do this, type in the terminal: salome !StlToMed.py args:!NameOfConnectivityFile.xml * '''IMPORTANT NOTE:''' everything is case sensitive, and can be sensitive to extra spaces. For example, the script will not run properly if you type args: !NameofConnectivityFile.xml instead of args:!NameofConnectivityFile.xml due to the improper space after args: == Output == Template finite element mesh of all tissues of interest in MED format, including: * node, and node set definitions * element, and element set definitions * surface set definitions more information can be found in the [[Specifications/MeshGeneration/Discussion|Discussion]] page