コード例 #1
0
ファイル: Catch.cs プロジェクト: mihsamusev/CodendOOP
        //public void LabelCatchBoundary(NetTriangle Tri, int label)
        //{
        //    if (Tri.HasCatch)
        //    {
        //        double min = new double[3] { Tri.n1.Y, Tri.n2.Y, Tri.n3.Y }.Min();
        //        if(Tri.n1.Y == min)
        //        {
        //            Tri.n1.Label = label;
        //        }
        //        if (Tri.n2.Y == min)
        //        {
        //            Tri.n2.Label = label;
        //        }
        //        if (Tri.n3.Y == min)
        //        {
        //            Tri.n3.Label = label;
        //        }
        //    }
        //}

        public void Apply(Codend Codend, int catchNumber)
        {
            int nTri = Codend.TriangleList.Count;

            if (nTri == 0)
            {
                throw new ArgumentException("Codend should be meshed in order to apply catch. Provide initial shape");
            }

            // Apply by blocked meshes
            if (applyMethod.Equals(method1, StringComparison.InvariantCultureIgnoreCase))
            {
                if (Codend.SameLengthPanels())
                {
                    double CodendLengthInMeshes = Codend.PanelList[0].LengthInMeshes;
                    double NumBlockedMeshes     = BlockedMeshes[catchNumber];


                    if (Codend.PanelList[0].Material.MeshType.Equals("Diamond", StringComparison.InvariantCultureIgnoreCase))
                    {
                        for (int i = 0; i < nTri; i++)
                        {
                            ApplyToDiamondByBlockedMeshes(Codend.TriangleList[i], CodendLengthInMeshes, NumBlockedMeshes);
                        }
                    }
                    else if (Codend.PanelList[0].Material.MeshType.Equals("Square", StringComparison.InvariantCultureIgnoreCase))
                    {
                        for (int i = 0; i < nTri; i++)
                        {
                            ApplyToSquareByBlockedMeshes(Codend.TriangleList[i], CodendLengthInMeshes, NumBlockedMeshes);
                        }
                    }
                }
                else
                {
                    throw new ArgumentException("Panels must have same amount of meshes along to apply catch by blocked meshes method");
                }
            }
            // Apply by length ratios
            else if (applyMethod.Equals(method2, StringComparison.InvariantCultureIgnoreCase))
            {
                if (BlockingRatio[catchNumber] != 0)
                {
                    double blockingRatio = BlockingRatio[catchNumber];
                    for (int i = 0; i < nTri; i++)
                    {
                        ApplyByBlockingRatio(Codend.TriangleList[i], Codend.Length, blockingRatio);
                    }
                }
                else
                {
                    throw new ArgumentException("Blocking ration cannot be 0 to apply catch by blocking ratio method");
                }
            }
        }
コード例 #2
0
        //=========================
        // constructors
        //=========================

        public Simulation(Codend Codend, Catch Catch, Towing Towing)
        {
            this.Codend = Codend;
            this.Catch  = Catch;
            this.Towing = Towing;

            SolverSettings = new SolverSettings(); // start with default settings

            Codend.SetCylInitialShape();
            Codend.RestrainEntrance();
            CalculateBoundaryDOF();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: mihsamusev/CodendOOP
        static void Main(string[] args)
        {
            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
            try
            {
                Console.WindowWidth  = 100;
                Console.WindowHeight = 50;
            }
            catch
            {
            }
            Console.WindowHeight = 50;

            //=========================
            // INPUT
            //=========================

            var inputReader = new InputReader();

            inputReader.PrintInfo();

            var nPanels         = inputReader.CountPanels();
            var nPanelMaterials = inputReader.CountPanelMaterials();

            //=========================================
            // INITIALIZE PANEL MATERIALS
            //=========================================

            List <PanelMaterial> PanelMaterialList = new List <PanelMaterial>();

            for (int i = 0; i < nPanelMaterials; i++)
            {
                PanelMaterialList.Add(new PanelMaterial(i + 1, inputReader));
            }

            //foreach (var m in PanelMaterialList)
            //{
            //    m.PrintInfo();
            //}

            //=========================================
            // INITIALIZE PANELS
            //=========================================

            List <Panel> PanelList = new List <Panel>();

            for (int i = 0; i < nPanels; i++)
            {
                var panelInput = inputReader.ReadPanelInput(i + 1);

                if (panelInput.type.Equals("DiamondPanel", StringComparison.InvariantCultureIgnoreCase))
                {
                    PanelList.Add(new DiamondMeshPanel(
                                      LengthInMeshes: panelInput.meshesAlong,
                                      WidthInMeshes: panelInput.meshesAcross,
                                      Orientation: panelInput.orientation,
                                      Material: PanelMaterialList[panelInput.materialID - 1]));
                }
                else if (panelInput.type.Equals("SquarePanel", StringComparison.InvariantCultureIgnoreCase))
                {
                    PanelList.Add(new SquareMeshPanel(
                                      LengthInMeshes: panelInput.meshesAlong,
                                      WidthInMeshes: panelInput.meshesAcross,
                                      Orientation: panelInput.orientation,
                                      Material: PanelMaterialList[panelInput.materialID - 1]));
                }
                else
                {
                    throw new ArgumentException("Panel types should be ither \'DiamondPanel\' or \'SquarePanel\'");
                }
            }

            //foreach (var p in PanelList)
            //{
            //    p.PrintInfo();
            //}

            //=========================================
            // INITIALIZE SELVEDGES
            //=========================================

            List <Selvedge> SelvedgeList = new List <Selvedge>();

            if (inputReader.SelvedgesIncluded())
            {
                for (int i = 0; i < nPanels; i++)
                {
                    SelvedgeList.Add(new Selvedge(i, inputReader));
                }
            }

            //=========================================
            // INITIALIZE ROUND STRAPS
            //=========================================

            List <RoundStrap> RoundStrapList = new List <RoundStrap>();

            if (inputReader.RoundStrapsIncluded())
            {
                int strapCount = inputReader.CountRoundStraps();
                for (int i = 0; i < strapCount; i++)
                {
                    RoundStrapList.Add(new RoundStrap(i + 1, inputReader));
                }
            }

            //=========================================
            // INITIALIZE CODEND
            //=========================================

            double R      = inputReader.ReadCodendEntranceRadius();
            var    Codend = new Codend(PanelList, R)
            {
                SelvedgeList = SelvedgeList,
                StrapList    = RoundStrapList,
                MeshSettings = new MeshSettings(inputReader)
            };

            //=========================================
            // INITIALIZE CATCH
            //=========================================

            var Catch = new Catch(inputReader);

            //=========================================
            // INITIALIZE TOWING
            //=========================================

            var TowingAlongY = new Towing(inputReader);

            //=========================================
            // INITIALIZE SIMULATION
            //=========================================

            var TowingSimulation = new Simulation(Codend, Catch, TowingAlongY)
            {
                SolverSettings = new SolverSettings(inputReader),
                FilePaths      = inputReader
            };


            TowingSimulation.Simulate();

            ////TowingSimulation.ConvergenceStudy();

            //Console.ReadKey();
        }