> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Check Mesh Connectivity

Check FEM-mesh connectivity using the Lua script API.

```lua theme={null}
base_path = sos.arg[0];
file_name = base_path .. "/connectivity/mesh.sdb"

-- load database
local settings = sos.LoadDataBaseSettings(file_name);
sos.loadDataBase(sos.database(), settings);
settings = nil
-- end of: Load database

sos.setLogLevel(3)

-- get a handle for the mesh:
mesh = sos.database():referenceMesh()

-- parts are an internal "scoping". every node/element is member of a "part".
num_parts = mesh:numParts();
print("num_parts: ", num_parts)
-- this will be our mesh part:
part = mesh:part(0) -- For ANSYS: there is only one part -> here #0

-- get some info:
num_nodes = part:pointSize()
num_elems = part:elementSize();
print("number of elements: " .. num_elems .. ", number of nodes: " .. num_nodes)

-- get a single node:
node100 = part:point(100)                                               -- get the node with ANSYS internal index 100
print("node100:");
print("node100.part_index: " .. node100:part_index() );                 -- which part ? -> should be zero
print("node100.index: " .. node100:index() );                           -- which node index in part ? (e.g. index in ANSYS FEM mesh)
print("node100.isPartOfSurface: " , node100:isPartOfSurface () );       -- is this node part of the surface ?
print("node100.numElements: " .. node100:numElements() );               -- how many elements are connected to this node ?
element = node100:elementAt(2-1)                                        -- get one of these elements (0..numElements-1)
for i=1,node100:numElements() do                                        -- loop over all elements connected to the node
    local current_element = node100:elementAt(i-1)                      -- get the current element iterate
    print("local element #" .. i .. ": element index " .. current_element:index() )
end
print("elememt #2 of node #100 has index " .. element:index() )         -- get element index (within the part, i.e.e the ANSYS FEM index)
print("element has type " .. element:elementTypeString() )              -- some information on the element type
print("element:isDegenerated():", element:isDegenerated() )             -- is it a true volume element - or degenerated somehow ?
print("element has " .. element:numNodes() .. " nodes.");               -- number of nodes belonging to the elements (multiple counting is posible for degenerated elements)
for i=1,element:numNodes() do                                           -- a loop over all element nodes
    local local_node = element:nodeAt(i-1)                              -- get the i-th element node (0..numNodes-1)
    print("local node #" ..i .. ": node index " .. local_node:index() ) -- print some info on this node
end

-- here we show how we access the data vector (e.g. obtained from FMOP) for the respective node or element:
print("Index of node100 in data vector: " .. sos.globalIndexFromNode   ( sos.database(), node100:part_index(), node100:index() ));
print("Index of element in data vector: " .. sos.globalIndexFromElement( sos.database(), element:part_index(), element:index() ));

-- print general information on the mesh:
sos.printMeshInfo(sos.database());
```
