Example #1
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private IFLocalCoord CreateLocalCoordinate(IFLine lusasLine)
        {
            object lineXAxis = null;
            object lineYAxis = null;
            object lineZAxis = null;
            object origin    = null;

            lusasLine.getAxesAtNrmCrds(0, ref origin, ref lineXAxis, ref lineYAxis, ref lineZAxis);

            double[] localXAxis = Adapters.Lusas.Convert.ToDouble(lineXAxis);
            double[] localYAxis = Adapters.Lusas.Convert.ToDouble(lineYAxis);
            double[] localZAxis = Adapters.Lusas.Convert.ToDouble(lineZAxis);

            IF3dCoords barStart = lusasLine.getStartPositionCoords();

            double[] worldXAxis = new double[] { 1, 0, 0 };
            double[] worldYAxis = new double[] { 0, 1, 0 };
            double[] worldZAxis = new double[] { 0, 0, 1 };

            double[] barorigin = new double[] { barStart.getX(), barStart.getY(), barStart.getZ() };

            double[] matrixCol0 = new double[]
            {
                worldXAxis.Zip(localXAxis, (d1, d2) => d1 * d2).Sum(),
                worldYAxis.Zip(localXAxis, (d1, d2) => d1 * d2).Sum(),
                worldZAxis.Zip(localXAxis, (d1, d2) => d1 * d2).Sum(),
            };

            double[] matrixCol1 = new double[]
            {
                worldXAxis.Zip(localYAxis, (d1, d2) => d1 * d2).Sum(),
                worldYAxis.Zip(localYAxis, (d1, d2) => d1 * d2).Sum(),
                worldZAxis.Zip(localYAxis, (d1, d2) => d1 * d2).Sum(),
            };

            double[] matrixCol2 = new double[]
            {
                worldXAxis.Zip(localZAxis, (d1, d2) => d1 * d2).Sum(),
                worldYAxis.Zip(localZAxis, (d1, d2) => d1 * d2).Sum(),
                worldZAxis.Zip(localZAxis, (d1, d2) => d1 * d2).Sum(),
            };

            string lusasName = "L" + lusasLine.getID().ToString() + "/ Local Axis";

            IFLocalCoord barLocalAxis = d_LusasData.createLocalCartesianAttr(
                lusasName, barorigin,
                matrixCol0, matrixCol1, matrixCol2);

            return(barLocalAxis);
        }
Example #2
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private IFLine CreateLine(Bar bar)
        {
            if (!CheckPropertyError(bar, b => b.StartNode, true) || !CheckPropertyError(bar, b => b.EndNode, true) ||
                !CheckPropertyError(bar, b => b.StartNode.Position, true) || !CheckPropertyError(bar, b => b.EndNode.Position, true))
            {
                return(null);
            }

            if (
                bar.FEAType == BarFEAType.CompressionOnly ||
                bar.FEAType == BarFEAType.TensionOnly)
            {
                Engine.Base.Compute.RecordError("Lusas does not support " + bar.FEAType.ToString() + " Bars");
                return(null);
            }

            string startNodeId = GetAdapterId <string>(bar.StartNode);
            string endNodeId   = GetAdapterId <string>(bar.EndNode);

            if (string.IsNullOrEmpty(startNodeId) || string.IsNullOrEmpty(endNodeId))
            {
                Engine.Base.Compute.RecordError("Could not find the ids for at least one end node for at least one Bar. Bar not created.");
                return(null);
            }

            IFPoint startPoint = d_LusasData.getPointByNumber(bar.StartNode.AdapterId <int>(typeof(LusasId)));
            IFPoint endPoint   = d_LusasData.getPointByNumber(bar.EndNode.AdapterId <int>(typeof(LusasId)));
            IFLine  lusasLine  = d_LusasData.createLineByPoints(startPoint, endPoint);

            int adapterIdName = lusasLine.getID();

            bar.SetAdapterId(typeof(LusasId), adapterIdName);

            if (bar.Tags.Count != 0)
            {
                AssignObjectSet(lusasLine, bar.Tags);
            }

            if (CheckPropertyWarning(bar, b => b.SectionProperty) && !Engine.Adapters.Lusas.Query.InvalidSectionProperty(bar.SectionProperty))
            {
                if (!Engine.Adapters.Lusas.Query.InvalidSectionProfile(bar.SectionProperty))
                {
                    //Needed in case the SectionProfile is null and was not created
                    if (d_LusasData.existsAttribute("Line Geometric", bar.SectionProperty.AdapterId <int>(typeof(LusasId))))
                    {
                        IFAttribute lusasGeometricLine = d_LusasData.getAttribute("Line Geometric", bar.SectionProperty.AdapterId <int>(typeof(LusasId)));
                        lusasGeometricLine.assignTo(lusasLine);
                    }

                    if (CheckPropertyWarning(bar, b => b.SectionProperty.Material))
                    {
                        if (bar.SectionProperty.Material is IOrthotropic)
                        {
                            Engine.Base.Compute.RecordWarning($"Orthotropic Material {bar.SectionProperty.Material.DescriptionOrName()} cannot be assigned to Bar {bar.AdapterId<int>(typeof(LusasId))}, " +
                                                              $"orthotropic materials can only be applied to 2D and 3D elements in Lusas.");
                        }
                        else if (bar.SectionProperty.Material is IIsotropic)
                        {
                            if (d_LusasData.existsAttribute("Material", bar.SectionProperty.Material.AdapterId <int>(typeof(LusasId))))
                            {
                                IFAttribute lusasMaterial = d_LusasData.getAttribute("Material", bar.SectionProperty.Material.AdapterId <int>(typeof(LusasId)));
                                lusasMaterial.assignTo(lusasLine);
                            }
                        }
                    }
                }
            }

            if (bar.Support != null)
            {
                IFAttribute lusasSupport = d_LusasData.getAttribute("Support", System.Convert.ToInt32(bar.Support.AdapterId <int>(typeof(LusasId))));
                lusasSupport.assignTo(lusasLine);
                IFLocalCoord barLocalAxis = CreateLocalCoordinate(lusasLine);
                barLocalAxis.assignTo(lusasLine);
            }

            if (bar.Fragments.Contains(typeof(MeshSettings1D)))
            {
                IFAssignment meshAssignment = m_LusasApplication.newAssignment();
                meshAssignment.setAllDefaults();
                if (bar.OrientationAngle != 0 && bar.FEAType == BarFEAType.Axial)
                {
                    Engine.Base.Compute.RecordWarning(
                        "Orientation angle not supported in Lusas for " + bar.FEAType +
                        " element types, this information will be lost when pushed to Lusas");
                }

                meshAssignment.setBetaAngle(bar.OrientationAngle);

                MeshSettings1D meshSettings1D = bar.FindFragment <MeshSettings1D>();
                IFMeshAttr     mesh           = d_LusasData.getMesh(
                    meshSettings1D.Name + "\\" + bar.FEAType.ToString() + "|" + CreateReleaseString(bar.Release));
                mesh.assignTo(lusasLine, meshAssignment);
            }

            if (bar.Offset != null)
            {
                Engine.Base.Compute.RecordWarning("Offsets are currently unsupported.");
            }

            return(lusasLine);
        }