public final void collectBoundaryNodes(int[] shapes) { for (int id : shapes) { BDiscretization d = mapDiscretizations.get(id); int[] refs = null; try { refs = Storage.readNodeReferences(d); } catch (IOException ex) { LOGGER.warning("Error when reading references"); } if (refs == null) continue; int numberOfNodes = Storage.getNumberOfNodes(d); nrBoundaryNodes += refs.length / 2; nrInnerNodes += numberOfNodes - refs.length / 2; } }
public final void processOneShape(int groupId, String groupName, int iFace) { BDiscretization d = mapDiscretizations.get(iFace); int[] refs = null; double[] coord = null; int[] connectivity = null; try { refs = Storage.readNodeReferences(d); coord = Storage.readNodeCoordinates(d); connectivity = Storage.readConnectivity(d); } catch (IOException ex) { LOGGER.warning("Error when reading references"); return; } TIntIntHashMap labels = new TIntIntHashMap(coord.length / 3); for (int i = 0; i < refs.length; i += 2) { if (!mapReferences.containsValue(refs[i + 1])) { indexBoundaryNodes++; mapReferences.put(refs[i + 1], indexBoundaryNodes + nrInnerNodes); } labels.put(refs[i], mapReferences.get(refs[i + 1])); } // Convert inner nodes and store boundary nodes double[] c = new double[3]; int idx = 0; for (int i = 0; i < coord.length; i += 3) { idx++; if (mapReferences.contains(idx)) { int label = mapReferences.get(idx) - nrInnerNodes; coordRefs[3 * label - 3] = coord[i]; coordRefs[3 * label - 2] = coord[i + 1]; coordRefs[3 * label - 1] = coord[i + 2]; } else { c[0] = coord[i]; c[1] = coord[i + 1]; c[2] = coord[i + 2]; indexInnerNodes++; labels.put(idx, indexInnerNodes); unvWriter.writeNode(indexInnerNodes, c); } } // Convert elements TIntArrayList group = new TIntArrayList(); if (d.getGraphCell().getType().equals(CADShapeEnum.EDGE)) { int[] localIndex = new int[3]; localIndex[0] = 2; for (int i = 0; i < connectivity.length; i += localIndex.length - 1) { if (connectivity[i] < 0 || connectivity[i + 1] < 0) { // Skip outer beams continue; } localIndex[1] = labels.get(connectivity[i]); localIndex[2] = labels.get(connectivity[i + 1]); indexElements++; unvWriter.writeElement(indexElements, localIndex); group.add(indexElements); } } else if (d.getGraphCell().getType().equals(CADShapeEnum.FACE)) { int[] localIndex = new int[4]; localIndex[0] = 3; for (int i = 0; i < connectivity.length; i += localIndex.length - 1) { if (connectivity[i] < 0 || connectivity[i + 1] < 0 || connectivity[i + 2] < 0) { // Skip outer triangles continue; } localIndex[1] = labels.get(connectivity[i]); localIndex[2] = labels.get(connectivity[i + 1]); localIndex[3] = labels.get(connectivity[i + 2]); indexElements++; unvWriter.writeElement(indexElements, localIndex); group.add(indexElements); } } else if (d.getGraphCell().getType().equals(CADShapeEnum.SOLID)) { int[] localIndex = new int[5]; localIndex[0] = 4; for (int i = 0; i < connectivity.length; i += localIndex.length - 1) { localIndex[1] = labels.get(connectivity[i]); localIndex[2] = labels.get(connectivity[i + 1]); localIndex[3] = labels.get(connectivity[i + 2]); localIndex[4] = labels.get(connectivity[i + 3]); indexElements++; unvWriter.writeElement(indexElements, localIndex); group.add(indexElements); } } unvWriter.writeGroup(groupId, groupName, group.toArray()); }