コード例 #1
0
ファイル: CanvasData.cs プロジェクト: karcheba/SlopeFEA
        public AnalysisPhase( int number,
            string name ,
            AnalysisPhase begin ,
            bool reset ,
            int nsteps ,
            int niterations ,
            int nprint ,
            double gravityFactor )
        {
            Number = number;

            Name = name;
            BeginPhase = begin;
            ResetDisplacements = reset;

            NSteps = nsteps;
            NIterations = niterations;
            NPrintLines = nprint;
            GravityFactor = gravityFactor;
        }
コード例 #2
0
ファイル: SlopePlotCanvas.cs プロジェクト: karcheba/SlopeFEA
        /// <summary>
        /// (Constructor) Adds various drawing Polygons.
        /// </summary>
        public SlopePlotCanvas( SlopeCanvas source )
        {
            this.source = source;
            this.analysisType = source.AnalysisType;
            this.dpiX = source.DpiX;
            this.dpiY = source.DpiY;
            this.FilePath = source.FilePath;

            this.SizeChanged += new SizeChangedEventHandler( SlopePlotCanvas_SizeChanged );

            // For zooming to a particular area
            zoomRect = new ZoomRect();

            // Initialize material type list
            materialTypes = source.MaterialTypes;

            // Initialize list of FEA parameters
            feaParams = source.FEAParameters;

            // Initialize mesh
            substructs = new List<MaterialBlock>();
            nodes = new List<feNode>();
            deformedNodes = new List<feNode>();
            triElements = new List<fe3NodedTriElement>();
            deformedTriMesh = new List<fe3NodedTriElement>();
            stressTriMesh = new List<fe3NodedTriElement>();

            // Initialize disp vectors
            disp = new List<List<double>>();
            dispVectors = new List<DisplacementVector>();

            // Initialize plastic points
            plasticPoints = new List<PlasticPoint>();

            // Initialize stress vectors
            sxxE = new List<double>();
            syyE = new List<double>();
            sxyE = new List<double>();
            szzE = new List<double>();
            fbarE = new List<double>();
            sxxN = new List<double>();
            syyN = new List<double>();
            sxyN = new List<double>();
            szzN = new List<double>();
            fbarN = new List<double>();

            // Intialize analysis phase
            selectedPhase = source.AnalysisPhases[1];

            // Load mesh
            LoadNodeData();
            LoadElementData();
        }
コード例 #3
0
        private void add_Click( object sender , RoutedEventArgs e )
        {
            if ( phaseList.Text == "Add new analysis phase..." || phaseList.Text == "" )
            {
                MessageBox.Show( "Must give the phase a name." , "Error" );
                return;
            }

            if ( phaseList.Text == "NULL" )
            {
                MessageBox.Show( "NULL phase name is reserved." , "Error" );
                return;
            }

            if ( !(beginPhaseList.SelectedItem is AnalysisPhase) )
            {
                MessageBox.Show( "Must select an analysis phase to begin from.\nSelect NULL phase for \"stress-free\" state." , "Error" );
                return;
            }

            int nsteps;
            if ( !int.TryParse( loadSteps.Text , out nsteps ) || nsteps < 1 )
            {
                MessageBox.Show( "Number of load steps must be an integer >= 1." , "Error" );
                return;
            }

            int niter;
            if ( !int.TryParse( iterations.Text , out niter ) || niter < 1 )
            {
                MessageBox.Show( "Number of iterations must be an integer >= 1." , "Error" );
                return;
            }

            int nprint;
            if ( !int.TryParse( printLines.Text , out nprint ) || nprint < 1 )
            {
                MessageBox.Show( "Number of iterations / print line must be an integer >= 1." , "Error" );
                return;
            }

            double gfact;
            if ( !double.TryParse( gravityFactor.Text , out gfact ) || gfact < 0 )
            {
                MessageBox.Show( "Gravity factor must be a positive value." , "Error" );
                return;
            }

            AnalysisPhase newPhase = new AnalysisPhase( canvas.AnalysisPhases.Count ,
                phaseList.Text ,
                beginPhaseList.SelectedItem as AnalysisPhase ,
                (bool) resetDisplacements.IsChecked ,
                nsteps , niter , nprint , gfact );

            canvas.AnalysisPhases.Add( newPhase );
            int numPhases = canvas.AnalysisPhases.Count - 1;

            MaterialType currMaterial;
            MaterialBlock currBlock , currSub;
            DrawingPoint currNode;
            LineConstraint currLC;
            PointLoad currPL;
            LineLoad currLL;
            for ( int i = 0 ; i < inputCanvas.Substructs.Count ; i++ )
            {
                currSub = inputCanvas.Substructs[i];
                currBlock = canvas.MaterialBlocks[i];

                currMaterial = currSub.Material;
                currBlock.PhaseMaterials.Add( currMaterial );

                for ( int j = 0 ; j < currSub.BoundaryPoints.Count ; j++ )
                {
                    currNode = currBlock.BoundaryPoints[j];
                    if ( currNode.PhaseFixActiveX.Count < numPhases )
                    {
                        currNode.PhaseFixActiveX.Add( currSub.BoundaryPoints[j].IsFixActiveX );
                        currNode.PhaseFixActiveY.Add( currSub.BoundaryPoints[j].IsFixActiveY );
                    }
                }

                for ( int j = 0 ; j < currSub.LineConstraints.Count ; j++ )
                {
                    currLC = currBlock.LineConstraints[j];
                    if ( currLC.PhaseFixedX.Count < numPhases )
                    {
                        currLC.PhaseFixedX.Add( currSub.LineConstraints[j].IsActiveX );
                        currLC.PhaseFixedY.Add( currSub.LineConstraints[j].IsActiveY );
                    }
                }

                for ( int j = 0 ; j < currSub.PointLoads.Count ; j++ )
                {
                    currPL = currBlock.PointLoads[j];
                    if ( currPL.PhaseActiveX.Count < numPhases )
                    {
                        currPL.PhaseActiveX.Add( currSub.PointLoads[j].IsActiveX );
                        currPL.PhaseFactorX.Add( currSub.PointLoads[j].XFactor );
                        currPL.PhaseActiveY.Add( currSub.PointLoads[j].IsActiveY );
                        currPL.PhaseFactorY.Add( currSub.PointLoads[j].YFactor );
                    }
                }

                for ( int j = 0 ; j < currSub.LineLoads.Count ; j++ )
                {
                    currLL = currBlock.LineLoads[j];
                    if ( currLL.PhaseActiveN.Count < numPhases )
                    {
                        currLL.PhaseActiveN.Add( currSub.LineLoads[j].IsActiveN );
                        currLL.PhaseFactorN.Add( currSub.LineLoads[j].NFactor );
                        currLL.PhaseActiveT.Add( currSub.LineLoads[j].IsActiveT );
                        currLL.PhaseFactorT.Add( currSub.LineLoads[j].TFactor );
                    }
                }
            }

            beginPhaseList.Items.Clear();
            canvas.AnalysisPhases.ForEach( delegate( AnalysisPhase ap ) { beginPhaseList.Items.Add( ap ); } );

            phaseList.Items.Clear();
            phaseList.Items.Add( "Add new analysis phase..." );
            for ( int i = 1 ; i < canvas.AnalysisPhases.Count ; i++ )
            {
                phaseList.Items.Add( canvas.AnalysisPhases[i] );
            }
            phaseList.SelectedIndex = 0;
            phaseList.Focus();

            canvas.IsSaved = false;
        }