private FeFrame AddNewOrGet_LineByCoordinate([NotNull] FeJoint inFrom, [NotNull] FeJoint inTo, [NotNull] FeSection inSection) { if (inFrom == null) { throw new ArgumentNullException(nameof(inFrom)); } if (inTo == null) { throw new ArgumentNullException(nameof(inTo)); } if (inSection == null) { throw new ArgumentNullException(nameof(inSection)); } // Already exists in the list? FeFrame alreadyExisting = Frames.FirstOrDefault(a => (a.Value.IJoint == inFrom && a.Value.JJoint == inTo) || (a.Value.JJoint == inFrom && a.Value.IJoint == inTo)).Value; if (alreadyExisting != null) { return(alreadyExisting); } //if () throw new InvalidOperationException("Finite Element Models are Limited to Having One Frame Per Location."); FeFrame newFrame = new FeFrame(_frameCount.ToString(), inSection, inFrom, inTo); Frames.Add(newFrame.Id, newFrame); _frameCount++; return(newFrame); }
/// <summary> /// Creates the abstraction of the FeModel. /// </summary> /// <param name="inSolPoint">The solution point that contain the Gh Geometry that will define the model. Usually the model is then saved into the its FeModel parameter</param> public FeModel([NotNull] NlOpt_Point inSolPoint) { try { if (inSolPoint == null) { throw new ArgumentNullException(nameof(inSolPoint)); } Owner = inSolPoint; // Generates the model ////////////////////////// // For each point list GH Geometry Parameter - Adds the joint foreach (PointList_GhGeom_ParamDef pointList_Output_ParamDef in inSolPoint.GhGeom_Values.Keys.OfType <PointList_GhGeom_ParamDef>()) { FeGroup grp = AddNewOrGet_Group(pointList_Output_ParamDef.FeGroupNameHelper); List <Point3d> pPoints = (List <Point3d>)inSolPoint.GhGeom_Values[pointList_Output_ParamDef]; foreach (Point3d p in pPoints) { FeJoint j = AddNewOrGet_JointByCoordinate(p); j.Restraint.IncorporateRestraint(pointList_Output_ParamDef.Restraint); grp.AddElement(j); } } // For each line list GH Geometry Parameter - Adds the joints and a frame foreach (LineList_GhGeom_ParamDef lineList_Output_ParamDef in inSolPoint.GhGeom_Values.Keys.OfType <LineList_GhGeom_ParamDef>()) { FeGroup grp = AddNewOrGet_Group(lineList_Output_ParamDef.FeGroupNameHelper); List <Line> pLines = (List <Line>)inSolPoint.GhGeom_Values[lineList_Output_ParamDef]; foreach (Line l in pLines) { // Adds the From joint FeJoint jFrom = AddNewOrGet_JointByCoordinate(l.From); jFrom.Restraint.IncorporateRestraint(lineList_Output_ParamDef.Restraint); grp.AddElement(jFrom); // Adds the To joint FeJoint jTo = AddNewOrGet_JointByCoordinate(l.To); jTo.Restraint.IncorporateRestraint(lineList_Output_ParamDef.Restraint); grp.AddElement(jTo); // Adds the Frame FeSection s = Owner.Owner.GetGhLineListSection(lineList_Output_ParamDef); FeFrame f = AddNewOrGet_LineByCoordinate(jFrom, jTo, s); grp.AddElement(f); } } // Adds the gravity loads if (AppSS.I.FeOpt.Gravity_IsLoad) { FeLoad_Inertial gravity = FeLoad_Inertial.GetStandardGravity(AppSS.I.FeOpt.Gravity_Multiplier); // Sets the direction based on the options switch (AppSS.I.FeOpt.Gravity_DirectionEnum_Selected) { case MainAxisDirectionEnum.xPos: gravity.Direction = Vector3d.XAxis; break; case MainAxisDirectionEnum.xNeg: gravity.Direction = -Vector3d.XAxis; break; case MainAxisDirectionEnum.yPos: gravity.Direction = Vector3d.YAxis; break; case MainAxisDirectionEnum.yNeg: gravity.Direction = -Vector3d.YAxis; break; case MainAxisDirectionEnum.zPos: gravity.Direction = Vector3d.ZAxis; break; case MainAxisDirectionEnum.zNeg: gravity.Direction = -Vector3d.ZAxis; break; default: throw new ArgumentOutOfRangeException(); } Loads.Add(gravity); } // Adds the point loads if (AppSS.I.FeOpt.PointLoads.Count > 0) { Loads.AddRange(AppSS.I.FeOpt.PointLoads); } } catch (Exception e) { throw new Exception($"Error defining the FeModel internal class.", e); } }