Program: 70999
Project: 70999
Buggy source:
/** 
 * Creates an FemModel with uniform density based on ANSYS data contained in a specified file. The node coordinate data can be scaled non-uniformly using an optional parameter giving scale values about the x, y, and z axes.
 * @param model FEM model to be populated by ANSYS data
 * @param nodeReader reader supplying node data in the ANSYS format
 * @param elemReader reader supplying element data in the ANSYS format
 * @param density density of the model
 * @param scale if non-null, gives scaling about the x, y, and z axes
 * @param options option flags. Should be an or-ed combination of {@link #TETRAHEDRALIZE_HEXES} and {@link #ONE_BASED_NUMBERING}.
 * @throws IOException if this is a problem reading the file
 */
public static FemModel3d read(FemModel3d model,Reader nodeReader,Reader elemReader,double density,Vector3d scale,int options) throws IOException {
  boolean tetrahedralize=(options & TETRAHEDRALIZE_HEXES) != 0;
  boolean useAnsysNum=(options & ONE_BASED_NUMBERING) != 0;
  if (model == null) {
    model=new FemModel3d();
  }
 else {
    model.clear();
  }
  if (density >= 0) {
    model.setDensity(density);
  }
  if (useAnsysNum) {
    model.useAnsysNumbering();
  }
  LinkedHashMap<Integer,Point3d> nodeMap=readNodeFile(nodeReader,useAnsysNum);
  LinkedHashMap<Integer,Integer> nodeIdMap=new LinkedHashMap<Integer,Integer>();
  for (  int nodeId : nodeMap.keySet()) {
    Point3d pos=nodeMap.get(nodeId);
    if (scale != null) {
      pos.x*=scale.x;
      pos.y*=scale.y;
      pos.z*=scale.z;
    }
    FemNode3d node=new FemNode3d(pos);
    model.addNumberedNode(node,nodeId);
    nodeIdMap.put(nodeId,node.getNumber());
  }
  LinkedHashMap<Integer,ArrayList<Integer>> elemMap=readElemFile(elemReader,useAnsysNum);
  ArrayList<HexElement> hexElems=new ArrayList<HexElement>();
  boolean flip=false;
  if (scale != null) {
    double scaleProduct=scale.x * scale.y * scale.z;
    flip=(scaleProduct < 0);
  }
  for (  int elemId : elemMap.keySet()) {
    ArrayList<Integer> elemNumList=elemMap.get(elemId);
    int[] attrList=new int[5];
    for (int i=attrList.length - 1; i >= 0; i--) {
      attrList[i]=elemNumList.remove(0);
    }
    ArrayList<Integer> nodeList=getValidElemNodes(elemNumList,nodeIdMap,flip);
switch (nodeList.size()) {
case 4:
      createTet(model,nodeList,elemId,attrList);
    break;
case 5:
  createPyramid(model,nodeList,elemId,attrList);
break;
case 6:
createWedge(model,nodeList,elemId,attrList);
break;
case 8:
hexElems.add(createHex(model,nodeList,elemId,attrList));
break;
case 10:
createQuadTet(model,nodeList,elemId,attrList);
break;
case 20:
createQuadHex(model,nodeList,elemId,attrList);
break;
default :
System.out.println("String_Node_Str" + nodeList.size() + "String_Node_Str");
}
}
HexElement.setParities(hexElems);
if (tetrahedralize) {
for (HexElement hex : hexElems) {
FemNode3d[] n=hex.getNodes();
TetElement[] tets=TetElement.createCubeTesselation(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],hex.getParity() == 1);
model.removeElement(hex);
for (TetElement tet : tets) {
model.addElement(tet);
}
}
}
return model;
}

Fixed version (ground truth):
/** 
 * Creates an FemModel with uniform density based on ANSYS data contained in a specified file. The node coordinate data can be scaled non-uniformly using an optional parameter giving scale values about the x, y, and z axes.
 * @param model FEM model to be populated by ANSYS data
 * @param nodeReader reader supplying node data in the ANSYS format
 * @param elemReader reader supplying element data in the ANSYS format
 * @param density density of the model
 * @param scale if non-null, gives scaling about the x, y, and z axes
 * @param options option flags. Should be an or-ed combination of {@link #TETRAHEDRALIZE_HEXES} and {@link #ONE_BASED_NUMBERING}.
 * @throws IOException if this is a problem reading the file
 */
public static FemModel3d read(FemModel3d model,Reader nodeReader,Reader elemReader,double density,Vector3d scale,int options) throws IOException {
  boolean tetrahedralize=(options & TETRAHEDRALIZE_HEXES) != 0;
  boolean useAnsysNum=(options & ONE_BASED_NUMBERING) != 0;
  if (model == null) {
    model=new FemModel3d();
  }
 else {
    model.clear();
  }
  if (density >= 0) {
    model.setDensity(density);
  }
  if (useAnsysNum) {
    model.useAnsysNumbering();
  }
  LinkedHashMap<Integer,Point3d> nodeMap=readNodeFile(nodeReader,useAnsysNum);
  LinkedHashMap<Integer,Integer> nodeIdMap=new LinkedHashMap<Integer,Integer>();
  for (  int nodeId : nodeMap.keySet()) {
    Point3d pos=nodeMap.get(nodeId);
    if (scale != null) {
      pos.x*=scale.x;
      pos.y*=scale.y;
      pos.z*=scale.z;
    }
    FemNode3d node=new FemNode3d(pos);
    model.addNumberedNode(node,nodeId);
    nodeIdMap.put(nodeId,node.getNumber());
  }
  LinkedHashMap<Integer,ArrayList<Integer>> elemMap=readElemFile(elemReader,useAnsysNum);
  ArrayList<HexElement> hexElems=new ArrayList<HexElement>();
  boolean flip=false;
  if (scale != null) {
    double scaleProduct=scale.x * scale.y * scale.z;
    flip=(scaleProduct < 0);
  }
  for (  int elemId : elemMap.keySet()) {
    ArrayList<Integer> elemNumList=elemMap.get(elemId);
    int[] attrList=new int[5];
    for (int i=attrList.length - 1; i >= 0; i--) {
      attrList[i]=elemNumList.remove(0);
    }
    ArrayList<Integer> nodeList=getValidElemNodes(elemNumList,nodeIdMap,flip);
switch (nodeList.size()) {
case 4:
      createTet(model,nodeList,elemId,attrList);
    break;
case 5:
  createPyramid(model,nodeList,elemId,attrList);
break;
case 6:
createWedge(model,nodeList,elemId,attrList);
break;
case 8:
hexElems.add(createHex(model,nodeList,elemId,attrList));
break;
case 10:
createQuadTet(model,nodeList,elemId,attrList);
break;
case 20:
createQuadHex(model,nodeList,elemId,attrList);
break;
default :
System.out.println("String_Node_Str" + elemId + "String_Node_Str"+ nodeList.size()+ "String_Node_Str");
}
}
HexElement.setParities(hexElems);
if (tetrahedralize) {
for (HexElement hex : hexElems) {
FemNode3d[] n=hex.getNodes();
TetElement[] tets=TetElement.createCubeTesselation(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],hex.getParity() == 1);
model.removeElement(hex);
for (TetElement tet : tets) {
model.addElement(tet);
}
}
}
return model;
}