/// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            if (this.Equals(Constraints.Released))
            {
                return("Release");
            }

            if (this.Equals(Constraints.Fixed))
            {
                return("Fixed");
            }

            if (this.Equals(Constraints.MovementFixed))
            {
                return("Movement Fixed");
            }

            if (this.Equals(Constraints.RotationFixed))
            {
                return("Rotation Fixed");
            }

            var arr = new DofConstraint[] { dx, dy, dz, rx, ry, rz };

            var buf = new char[6];

            for (int i = 0; i < 6; i++)
            {
                buf[i] = arr[i] == DofConstraint.Fixed ? '1' : '0';
            }

            return(new string(buf));
        }
Ejemplo n.º 2
0
        internal List <Condition> GetShapeFunctionConditions(BarElement targetElement)
        {
            var cnds = CondsListPool.Allocate();

            var bar = targetElement as BarElement;

            //var l = (bar.StartNode.Location - bar.EndNode.Location).Length;

            var n = bar.NodeCount;

            /*
             * var xis = new Func<int, double>(i =>
             * {
             *  var delta = 2.0 / (n - 1);
             *
             *  return -1 + delta * i;
             * });
             */

            var cv = new DofConstraint[n]; //shear constraint
            var cm = new DofConstraint[n]; //moment constraints

            for (var i = 0; i < n; i++)
            {
                if (this._direction == BeamDirection.Z)
                {
                    cv[i] = bar._nodalReleaseConditions[i].DY;
                    cm[i] = bar._nodalReleaseConditions[i].RZ;
                }
                else
                {
                    cv[i] = bar._nodalReleaseConditions[i].DZ;
                    cm[i] = bar._nodalReleaseConditions[i].RY;
                }
            }

            #region detect conditions

            for (var bnode = 0; bnode < n; bnode++)
            {
                for (var tnode = 0; tnode < n; tnode++)
                {
                    var l1 = GetMCondition(targetElement, bnode, tnode, cv, cm);
                    cnds.AddRange(l1);
                    CondsListPool.Free(l1);

                    var l2 = GetNCondition(targetElement, bnode, tnode, cv, cm);
                    cnds.AddRange(l2);
                    CondsListPool.Free(l2);
                }
            }

            #endregion

            //cnds.Sort(new Condition.ConditionEqualityComparer());

            return(cnds);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Constraint"/> struct.
 /// </summary>
 /// <param name="dx">The dx.</param>
 /// <param name="dy">The dy.</param>
 /// <param name="dz">The dz.</param>
 /// <param name="rx">The rx.</param>
 /// <param name="ry">The ry.</param>
 /// <param name="rz">The rz.</param>
 public Constraint(DofConstraint dx, DofConstraint dy, DofConstraint dz, DofConstraint rx, DofConstraint ry, DofConstraint rz)
 {
     this.dx = dx;
     this.dy = dy;
     this.dz = dz;
     this.ry = ry;
     this.rz = rz;
     this.rx = rx;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="Constraint"/> struct.
        /// </summary>
        /// <param name="info">The information.</param>
        /// <param name="context">The context.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        private Constraint(SerializationInfo info, StreamingContext context) : this()
        {
            this.dx = (DofConstraint)info.GetInt32("dx");
            this.dy = (DofConstraint)info.GetInt32("dy");
            this.dz = (DofConstraint)info.GetInt32("dz");

            this.rx = (DofConstraint)info.GetInt32("rx");
            this.ry = (DofConstraint)info.GetInt32("ry");
            this.rz = (DofConstraint)info.GetInt32("rz");
        }
Ejemplo n.º 5
0
        public override int GetExtraEquationsCount()
        {
            var arr = new DofConstraint[] {
                Constraint.DX, Constraint.DY, Constraint.DZ,
                Constraint.RX, Constraint.RY, Constraint.RZ
            };

            var restCount = arr.Count(i => i == DofConstraint.Fixed);

            return(restCount * Nodes.Count);
        }
        public string ToString_01()
        {
            var arr = new DofConstraint[] { dx, dy, dz, rx, ry, rz };

            var buf = new char[12];

            for (int i = 0; i < 6; i++)
            {
                buf[2 * i + 0] = arr[i] == DofConstraint.Fixed ? '1' : '0';
                buf[2 * i + 1] = ' ';
            }

            return(new string(buf).Trim());
        }
Ejemplo n.º 7
0
        public static DofMappingManager Create(Model model, LoadCase cse)
        {
            var n = model.Nodes.Count;
            var m = 0;

            for (var i = 0; i < n; i++)
            {
                model.Nodes[i].Index = i;
            }

            var masters = CalcUtil.GetMasterMapping(model, cse);

            for (var i = 0; i < n; i++)
            {
                if (masters[i] == i)
                {
                    m++;
                }
            }

            var cnt = 0;

            var fixity = new DofConstraint[6 * n];


            #region Map4 and rMap4

            var map4  = new int[n];
            var rMap4 = new int[m];

            map4.FillNegative();
            rMap4.FillNegative();

            for (var i = 0; i < n; i++)
            {
                if (masters[i] == i)
                {
                    map4[i]    = cnt;
                    rMap4[cnt] = i;
                    cnt++;
                }
            }

            #endregion

            #region Map1 and rMap1

            var map1  = new int[6 * n];
            var rMap1 = new int[6 * m];

            map1.FillNegative();
            rMap1.FillNegative();

            cnt = 0;

            for (var i = 0; i < m; i++)
            {
                var ir = i;
                var it = rMap4[i];

                for (var j = 0; j < 6; j++)
                {
                    map1[it * 6 + j]  = ir * 6 + j;
                    rMap1[ir * 6 + j] = it * 6 + j;
                }
            }

            #endregion

            #region map2,map3,rmap2,rmap3

            var mf = 0;//fixes
            var mr = 0;

            for (var i = 0; i < n; i++)
            {
                if (masters[i] != i)
                {
                    continue;
                }

                var ctx = model.Nodes[i].Constraints;
                var s   = ctx.Sum();
                mf += s;
            }

            mr = 6 * m - mf;

            var rMap2 = new int[mr];
            var rMap3 = new int[mf];
            var map2  = new int[6 * m];
            var map3  = new int[6 * m];

            rMap2.FillNegative();
            rMap3.FillNegative();
            map2.FillNegative();
            map3.FillNegative();


            var rcnt = 0;
            var fcnt = 0;

            for (var i = 0; i < m; i++)
            {
                var arr = model.Nodes[rMap4[i]].Constraints.ToArray();

                for (var j = 0; j < 6; j++)
                {
                    if (arr[j] == DofConstraint.Released)
                    {
                        map2[6 * i + j] = rcnt;
                        rMap2[rcnt]     = 6 * i + j;
                        rcnt++;
                    }
                    else
                    {
                        map3[6 * i + j] = fcnt;
                        rMap3[fcnt]     = 6 * i + j;
                        fcnt++;
                    }
                }
            }


            for (var i = 0; i < n; i++)
            {
                var ctx = model.Nodes[i].Constraints.ToArray();

                for (var j = 0; j < 6; j++)
                {
                    fixity[6 * i + j] = ctx[j];
                }
            }

            #endregion

            #region RMaster

            var rMaster = new int[n];
            rMaster.FillNegative();

            cnt = 0;

            for (var i = 0; i < masters.Length; i++)
            {
                if (masters[i] == i)
                {
                    rMaster[i] = cnt++;
                }
            }

            #endregion


            var buf = new DofMappingManager();

            buf.Map1  = map1;
            buf.RMap1 = rMap1;

            buf.Map2  = map2;
            buf.RMap2 = rMap2;

            buf.Map3  = map3;
            buf.RMap3 = rMap3;

            buf.Map4  = map4;
            buf.RMap4 = rMap4;

            buf.Fixity = fixity;

            buf.M = m;
            buf.N = n;

            buf.MasterMap  = masters;
            buf.RMasterMap = rMaster;

            return(buf);
        }
Ejemplo n.º 8
0
        public bool GetShapeFunctions(Element targetElement, out Polynomial[] nss, out Polynomial[] mss)
        {
            var cnds = new List <Condition>();

            var sb = new StringBuilder();
            //var conditions = new List<>();

            //var xii = isoCoordsii[0];

            var bar = targetElement as BarElement;
            var l   = (bar.StartNode.Location - bar.EndNode.Location).Length;

            if (bar == null)
            {
                nss = null;
                mss = null;
                return(false);
            }

            var n = bar.NodeCount;

            var xis = new Func <int, double>(i =>
            {
                var delta = 2.0 / (n - 1);

                return(-1 + delta * i);
            });


            var ms = new Matrix[n];
            var ns = new Matrix[n];

            var rms = new Matrix[n];
            var rns = new Matrix[n];

            var nflags = new bool[n];
            var mflags = new bool[n];

            var cv = new DofConstraint[n]; //shear constraint
            var cm = new DofConstraint[n]; //moment constraints

            for (var i = 0; i < n; i++)
            {
                if (this._direction == BeamDirection.Z)
                {
                    cv[i] = bar._nodalReleaseConditions[i].DY;
                    cm[i] = bar._nodalReleaseConditions[i].RZ;
                }
                else
                {
                    cv[i] = bar._nodalReleaseConditions[i].DZ;
                    cm[i] = bar._nodalReleaseConditions[i].RY;
                }
            }


            if (cv.All(i => i == DofConstraint.Fixed) && cm.All(i => i == DofConstraint.Fixed))
            {
                if (n == 2)
                {
                    //return GetNMatrixBar2Node(targetElement, isoCoords);
                    //return GetShapeFunction2Node(targetElement, out nss, out mss);
                }
            }

            #region detect conditions

            for (var bnode = 0; bnode < n; bnode++)
            {
                //var mConds = new List<Condition>();

                for (var tnode = 0; tnode < n; tnode++)
                {
                    cnds.AddRange(GetMCondition(targetElement, bnode, tnode, cv, cm));
                    cnds.AddRange(GetNCondition(targetElement, bnode, tnode, cv, cm));
                }
            }

            #endregion

            cnds.Sort(new Condition.ConditionEqualityComparer());

            var grpd = cnds.GroupBy(i => Tuple.Create(i.NodeNumber, i.Type)).ToArray();

            mss = new Polynomial[n];
            nss = new Polynomial[n];

            foreach (var grp in grpd)
            {
                var nodeNum   = grp.Key.Item1;
                var tp        = grp.Key.Item2;
                var condCount = grp.Count();

                var mtx       = new Matrix(condCount, condCount);
                var rightSide = new Matrix(condCount, 1);

                var arr = grp.ToArray();

                for (var i = 0; i < arr.Length; i++)
                {
                    var itm = arr[i];

                    mtx.SetRow(i, Diff(itm.Xi, condCount - 1, itm.DifferentialDegree));

                    rightSide.SetRow(i, itm.RightSide);
                }

                Polynomial pl;

                if (arr.Length != 0)
                {
                    var cfs = mtx.Inverse2() * rightSide;

                    pl = new Polynomial(cfs.CoreArray);
                }
                else
                {
                    pl = new Polynomial();
                }


                if (tp == Condition.FunctionType.M)
                {
                    mss[nodeNum] = pl;
                }

                if (tp == Condition.FunctionType.N)
                {
                    nss[nodeNum] = pl;
                }
            }

            return(true);
        }