Esempio n. 1
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <IMaterialFragment> ReadMaterials(List <string> ids = null)
        {
            object[] lusasMaterials            = d_LusasData.getAttributes("Material");
            List <IMaterialFragment> materials = new List <IMaterialFragment>();

            for (int i = 0; i < lusasMaterials.Count(); i++)
            {
                IFAttribute       lusasMaterial = (IFAttribute)lusasMaterials[i];
                IMaterialFragment material      = Adapters.Lusas.Convert.ToMaterial(lusasMaterial);
                if (material != null)
                {
                    materials.Add(material);
                }
            }

            return(materials);
        }
Esempio n. 2
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private List <ISurfaceProperty> Read2DProperties(List <string> ids = null)
        {
            object[] lusasGeometrics = d_LusasData.getAttributes("Surface Geometric");
            List <ISurfaceProperty> surfaceProperties = new List <ISurfaceProperty>();

            for (int i = 0; i < lusasGeometrics.Count(); i++)
            {
                IFAttribute      lusasGeometric  = (IFAttribute)lusasGeometrics[i];
                ISurfaceProperty surfaceProperty = Adapters.Lusas.Convert.ToSurfaceProperty(lusasGeometric);
                if (surfaceProperty != null)
                {
                    surfaceProperties.Add(surfaceProperty);
                }
            }

            return(surfaceProperties);
        }
Esempio n. 3
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static MeshSettings1D ToMeshSettings1D(this IFAttribute lusasAttrbute)
        {
            string attributeName = GetName(lusasAttrbute);

            IFMeshLine lusasMeshLine = (IFMeshLine)lusasAttrbute;

            double  value       = 0;
            Split1D splitMethod = Split1D.Automatic;
            int     meshType    = 0;

            lusasMeshLine.getMeshDivisions(ref meshType);

            if (meshType == 0)
            {
                value = 0;
            }
            else if (meshType == 1)
            {
                splitMethod = Split1D.Divisions;
                object[] ratios = lusasMeshLine.getValue("ratio");
                value = ratios.Count();
                if (value == 0)
                {
                    value = 4;
                }
            }
            else if (meshType == 2)
            {
                splitMethod = Split1D.Length;
                value       = lusasMeshLine.getValue("size");
            }

            MeshSettings1D meshSettings1D = new MeshSettings1D
            {
                Name           = attributeName,
                SplitMethod    = splitMethod,
                SplitParameter = value
            };

            int adapterNameId = GetAdapterID(lusasMeshLine, 'e');

            meshSettings1D.SetAdapterId(typeof(LusasId), adapterNameId);

            return(meshSettings1D);
        }
Esempio n. 4
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private static List <string> GetAttributeAssignments(IFGeometry lusasGeometry, string attributeType)
        {
            object[] lusasAssignments = lusasGeometry.getAssignments(attributeType);

            List <string> attributeNames = new List <string>();

            int n = lusasAssignments.Count();

            for (int i = 0; i < n; i++)
            {
                IFAssignment lusasAssignment = lusasGeometry.getAssignments(attributeType)[i];
                IFAttribute  lusasAttribute  = lusasAssignment.getAttribute();
                string       attributeName   = GetName(lusasAttribute);
                attributeNames.Add(attributeName);
            }

            return(attributeNames);
        }
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private void DeletePointAssignments(object[] lusasAttributes)
        {
            for (int i = 0; i < lusasAttributes.Count(); i++)
            {
                IFAttribute lusasAttribute   = (IFAttribute)lusasAttributes[i];
                object[]    lusasAssignments = lusasAttribute.getAssignments();
                for (int j = 0; j < lusasAssignments.Count(); j++)
                {
                    IFAssignment lusasAssignment = (IFAssignment)lusasAssignments[j];
                    IFGeometry   lusasGeometry   = (IFGeometry)lusasAssignment.getDatabaseObject();
                    if (lusasGeometry is IFPoint)
                    {
                        Engine.Base.Compute.RecordWarning(lusasAttribute.getName() + " has been deleted because it was assigned to a point");
                        d_LusasData.Delete(lusasAttribute);
                        break;
                    }
                }
            }
        }
Esempio n. 6
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private IFLine CreateEdge(Edge edge, IFPoint startPoint, IFPoint endPoint)
        {
            IFLine lusasLine = d_LusasData.createLineByPoints(startPoint, endPoint);

            int adapterIdName = lusasLine.getID();

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

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

            if (!(edge.Support == null))
            {
                IFAttribute lusasSupport = d_LusasData.getAttribute("Support", edge.Support.AdapterId <int>(typeof(LusasId)));
                lusasSupport.assignTo(lusasLine);
            }

            return(lusasLine);
        }
Esempio n. 7
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        public static Tuple <bool, double, BarRelease, BarFEAType> GetMeshProperties(IFLine lusasLine)
        {
            bool       meshAssigned = true;
            double     betaAngle    = 0;
            BarRelease barRelease   = null;
            BarFEAType barType      = BarFEAType.Flexural;

            object[] meshAssignments = lusasLine.getAssignments("Mesh");

            if (meshAssignments.Length > 0)
            {
                foreach (object assignment in meshAssignments)
                {
                    IFAssignment lusasAssignment = (IFAssignment)assignment;
                    IFAttribute  lusasMesh       = lusasAssignment.getAttribute();
                    IFMeshLine   lusasLineMesh   = (IFMeshLine)lusasMesh;
                    betaAngle = lusasAssignment.getBetaAngle();

                    barRelease = GetBarRelease(lusasLineMesh);

                    object[] barMeshName = lusasLineMesh.getElementNames();

                    foreach (object type in barMeshName)
                    {
                        barType = GetFEAType(type);
                    }
                }
            }
            else
            {
                meshAssigned = false;
            }

            Tuple <bool, double, BarRelease, BarFEAType> lineMeshProperties =
                new Tuple <bool, double, BarRelease, BarFEAType>(meshAssigned, betaAngle, barRelease, barType);

            return(lineMeshProperties);
        }
Esempio n. 8
0
        /***************************************************/

        private IFAttribute CreateSupport(Constraint4DOF constraint)
        {
            if (!Engine.Adapters.Lusas.Query.CheckIllegalCharacters(constraint.DescriptionOrName()))
            {
                return(null);
            }

            IFAttribute lusasSupport = null;

            if (d_LusasData.existsAttribute("Support", constraint.DescriptionOrName()))
            {
                lusasSupport = d_LusasData.getAttribute("Support", constraint.DescriptionOrName());
            }
            else
            {
                lusasSupport = d_LusasData.createSupportStructural(constraint.DescriptionOrName());

                List <string> releaseNames = new List <string> {
                    "U", "V", "W", "THX"
                };
                List <double> stiffness = new List <double> {
                    constraint.TranslationalStiffnessX,
                    constraint.TranslationalStiffnessY,
                    constraint.TranslationalStiffnessZ,
                    constraint.RotationalStiffnessX
                };
                List <DOFType> fixities = new List <DOFType> {
                    constraint.TranslationX,
                    constraint.TranslationY,
                    constraint.TranslationZ,
                    constraint.RotationX
                };

                for (int i = 0; i < releaseNames.Count(); i++)
                {
                    if (fixities[i] == DOFType.Fixed)
                    {
                        lusasSupport.setValue(releaseNames[i], "R");
                    }
                    else if (stiffness[i] == 0)
                    {
                        lusasSupport.setValue(releaseNames[i], "F");
                    }
                    else
                    {
                        lusasSupport.setValue(releaseNames[i], "S");
                        lusasSupport.setValue(releaseNames[i] + "stiff", stiffness[i]);
                    }
                }
            }

            if (lusasSupport != null)
            {
                int adapterIdName = lusasSupport.getID();
                constraint.SetAdapterId(typeof(LusasId), adapterIdName);

                return(lusasSupport);
            }

            return(null);
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static ISectionProperty ToSection(this IFAttribute lusasAttribute)
        {
            string attributeName = GetName(lusasAttribute);
            string attributeType = lusasAttribute.getAttributeType();

            int rows = lusasAttribute.countRows("A");

            IProfile        profile;
            GenericSection  section             = null;
            List <int>      interpolationOrders = new List <int>();
            List <double>   positions           = new List <double>();
            List <IProfile> profiles            = new List <IProfile>();

            for (int i = 0; i < rows; i++)
            {
                profile = ToProfile(lusasAttribute, i);
                double area    = lusasAttribute.getValue("A", i);
                double rgy     = lusasAttribute.getValue("ky", i);
                double rgz     = lusasAttribute.getValue("kz", i);
                double j       = lusasAttribute.getValue("J", i);
                double iy      = lusasAttribute.getValue("Iyy", i);
                double iz      = lusasAttribute.getValue("Izz", i);
                double iw      = lusasAttribute.getValue("Cw", i);
                double wely    = Math.Min(Math.Abs(lusasAttribute.getValue("Syt", i)), Math.Abs(lusasAttribute.getValue("Syb", i)));
                double welz    = Math.Min(Math.Abs(lusasAttribute.getValue("Szt", i)), Math.Abs(lusasAttribute.getValue("Szb", i)));
                double wply    = lusasAttribute.getValue("Zpy", i);
                double wplz    = lusasAttribute.getValue("Zpz", i);
                double centreZ = 0; //Eccentricity is handeled in the Bar not at the section
                double centreY = 0; //Eccentricity is handeled in the Bar not at the section
                double zt      = lusasAttribute.getValue("zt", i);
                double zb      = Math.Abs(lusasAttribute.getValue("zb", i));
                double yt      = Math.Abs(lusasAttribute.getValue("yb", i)); //Lusas Y-Axis is opposite to the BHoM Y-axis
                double yb      = lusasAttribute.getValue("yt", i);
                double asy     = lusasAttribute.getValue("Asy", i);
                double asz     = lusasAttribute.getValue("Asz", i);

                if (profile == null)
                {
                    return(null);
                }

                profile = Engine.Structure.Compute.Integrate(profile, oM.Geometry.Tolerance.MicroDistance).Item1;

                if (attributeType == "Multiple Varying Geometric")
                {
                    double position = lusasAttribute.getValue("distanceAlongBeam", i);
                    positions.Add(position);
                    profiles.Add(profile);
                }
                else
                {
                    section = new GenericSection(profile, area, rgy, rgz, j, iy, iz, iw, wely, welz, wply, wplz, centreZ, centreY, zt, zb, yt, yb, asy, asz);
                }
            }

            if (lusasAttribute.getAttributeType() == "Multiple Varying Geometric")
            {
                for (int i = 0; i < profiles.Count - 1; i++)
                {
                    interpolationOrders.Add(1);
                }
                TaperedProfile taperedProfile = Engine.Spatial.Create.TaperedProfile(positions, profiles, interpolationOrders);
                if (taperedProfile == null)
                {
                    return(null);
                }
                section = Engine.Structure.Create.GenericSectionFromProfile(taperedProfile);
            }

            section.Name = attributeName;

            int adapterNameId = lusasAttribute.getID();

            section.SetAdapterId(typeof(LusasId), adapterNameId);

            return(section);
        }
Esempio n. 11
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private IFAttribute CreateMaterial(IMaterialFragment material)
        {
            IFAttribute lusasMaterial = null;

            if (material is IIsotropic)
            {
                IIsotropic isotropic = material as IIsotropic;
                if (d_LusasData.existsAttribute("Material", material.DescriptionOrName()))
                {
                    lusasMaterial = d_LusasData.getAttribute("Material", material.DescriptionOrName());
                }
                else
                {
                    if (CheckPropertyWarning(isotropic, x => x.YoungsModulus) &&
                        CheckPropertyWarning(isotropic, x => x.PoissonsRatio) &&
                        CheckPropertyWarning(isotropic, x => x.ThermalExpansionCoeff) &&
                        CheckPropertyWarning(isotropic, x => x.Density))
                    {
                        lusasMaterial = d_LusasData.createIsotropicMaterial(material.DescriptionOrName(),
                                                                            isotropic.YoungsModulus, isotropic.PoissonsRatio, isotropic.Density, isotropic.ThermalExpansionCoeff);
                    }
                }
            }
            else if (material is IOrthotropic)
            {
                IOrthotropic orthotropic = material as IOrthotropic;
                if (d_LusasData.existsAttribute("Material", material.DescriptionOrName()))
                {
                    lusasMaterial = d_LusasData.getAttribute("Material", material.DescriptionOrName());
                }
                else
                {
                    if (CheckPropertyWarning(orthotropic, x => x.YoungsModulus) &&
                        CheckPropertyWarning(orthotropic, x => x.PoissonsRatio) &&
                        CheckPropertyWarning(orthotropic, x => x.ThermalExpansionCoeff) &&
                        CheckPropertyWarning(orthotropic, x => x.ShearModulus) &&
                        CheckPropertyWarning(orthotropic, x => x.Density))
                    {
                        lusasMaterial = d_LusasData.createOrthotropicAxisymmetricMaterial(material.DescriptionOrName(),
                                                                                          orthotropic.YoungsModulus.X, orthotropic.YoungsModulus.Y, orthotropic.YoungsModulus.Z,
                                                                                          orthotropic.ShearModulus.X, orthotropic.PoissonsRatio.X, orthotropic.PoissonsRatio.Y, orthotropic.PoissonsRatio.Z,
                                                                                          0.0, orthotropic.Density, 0.0);

                        lusasMaterial.setValue("ax", orthotropic.ThermalExpansionCoeff.X);
                        lusasMaterial.setValue("ay", orthotropic.ThermalExpansionCoeff.Y);
                        lusasMaterial.setValue("az", orthotropic.ThermalExpansionCoeff.Z);

                        lusasMaterial.setValue("axy", System.Math.Sqrt(System.Math.Pow(orthotropic.ThermalExpansionCoeff.X, 2)
                                                                       + System.Math.Pow(orthotropic.ThermalExpansionCoeff.Y, 2)));
                    }
                }
            }

            if (lusasMaterial != null)
            {
                int adapterIdName = lusasMaterial.getID();
                material.SetAdapterId(typeof(LusasId), adapterIdName);

                return(lusasMaterial);
            }

            return(null);
        }
Esempio n. 12
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static IProfile ToProfile(IFAttribute lusasAttribute, int i)
        {
            int sectionType = lusasAttribute.getValue("Type");

            IProfile profile = null;

            switch (sectionType)
            {
            case 1:
            {
                profile = BH.Engine.Spatial.Create.RectangleProfile(
                    lusasAttribute.getValue("D", i),
                    lusasAttribute.getValue("B", i),
                    0
                    );
                break;
            }

            case 2:
            {
                profile = BH.Engine.Spatial.Create.BoxProfile(
                    lusasAttribute.getValue("D", i),
                    lusasAttribute.getValue("B", i),
                    lusasAttribute.getValue("t", i),
                    lusasAttribute.getValue("r", i),
                    lusasAttribute.getValue("r", i)
                    );
                break;
            }

            case 3:
            {
                profile = BH.Engine.Spatial.Create.CircleProfile(
                    lusasAttribute.getValue("D", i)
                    );
                break;
            }

            case 4:
            {
                profile = BH.Engine.Spatial.Create.TubeProfile(
                    lusasAttribute.getValue("D", i),
                    lusasAttribute.getValue("t", i)
                    );
                break;
            }

            case 5:
            {
                profile = BH.Engine.Spatial.Create.ISectionProfile(
                    lusasAttribute.getValue("D", i),
                    lusasAttribute.getValue("B", i),
                    lusasAttribute.getValue("tw", i),
                    lusasAttribute.getValue("tf", i),
                    lusasAttribute.getValue("r", i),
                    lusasAttribute.getValue("r", i)
                    );
                break;
            }

            case 7:
            {
                profile = BH.Engine.Spatial.Create.AngleProfile(
                    lusasAttribute.getValue("D", i),
                    lusasAttribute.getValue("B", i),
                    lusasAttribute.getValue("tw", i),
                    lusasAttribute.getValue("tf", i),
                    lusasAttribute.getValue("r1", i),
                    lusasAttribute.getValue("r2", i)
                    );
                break;
            }

            case 8:
            {
                profile = BH.Engine.Spatial.Create.TSectionProfile(
                    lusasAttribute.getValue("D", i),
                    lusasAttribute.getValue("B", i),
                    lusasAttribute.getValue("tw", i),
                    lusasAttribute.getValue("tf", i),
                    lusasAttribute.getValue("r", i),
                    lusasAttribute.getValue("r", i)
                    );
                break;
            }

            case 10:
            {
                profile = BH.Engine.Spatial.Create.ChannelProfile(
                    lusasAttribute.getValue("D", i),
                    lusasAttribute.getValue("B", i),
                    lusasAttribute.getValue("tw", i),
                    lusasAttribute.getValue("tf", i),
                    lusasAttribute.getValue("r", i),
                    lusasAttribute.getValue("r", i)
                    );
                break;
            }

            case 14:
            {
                profile = BH.Engine.Spatial.Create.FabricatedISectionProfile(
                    lusasAttribute.getValue("D", i),
                    lusasAttribute.getValue("Bt", i),
                    lusasAttribute.getValue("Bb", i),
                    lusasAttribute.getValue("tw", i),
                    lusasAttribute.getValue("tft", i),
                    lusasAttribute.getValue("tfb", i),
                    lusasAttribute.getValue("r", i)
                    );
                break;
            }

            case 15:
            {
                profile = BH.Engine.Spatial.Create.FabricatedBoxProfile(
                    lusasAttribute.getValue("D", i),
                    lusasAttribute.getValue("B", i),
                    lusasAttribute.getValue("tw", i),
                    lusasAttribute.getValue("tf", i),
                    lusasAttribute.getValue("tf", i),
                    0
                    );
                break;
            }

            case 16:
            {
                profile = BH.Engine.Spatial.Create.ZSectionProfile(
                    lusasAttribute.getValue("D", i),
                    lusasAttribute.getValue("B", i),
                    lusasAttribute.getValue("tw", i),
                    lusasAttribute.getValue("tf", i),
                    lusasAttribute.getValue("r", i),
                    lusasAttribute.getValue("r", i)
                    );
                break;
            }
            }

            return(profile);
        }
Esempio n. 13
0
        /***************************************************/
        /**** Internal Methods                          ****/
        /***************************************************/

        internal static string GetName(IFAttribute lusasAttribute)
        {
            return(lusasAttribute.getName());
        }