Inheritance: ImageEffectBase
Example #1
0
        private MembraneStressTensor GetMembraneInternalForce(LoadCombination combination)
        {
            //Note: membrane internal force is constant

            //step 1 : get transformation matrix
            //step 2 : convert globals points to locals
            //step 3 : convert global displacements to locals
            //step 4 : calculate B matrix and D matrix
            //step 5 : M=D*B*U
            //Note : Steps changed...

            var trans = this.GetTransformationMatrix();

            var lp = GetLocalPoints();

            var g2l = new Func <Vector, Vector>(glob => (trans.Transpose() * glob.ToMatrix()).ToVector());
            //var l2g = new Func<Vector, Vector>(local => (trans*local.ToMatrix()).ToPoint());


            var d1g = this.nodes[0].GetNodalDisplacement(combination);
            var d2g = this.nodes[1].GetNodalDisplacement(combination);
            var d3g = this.nodes[2].GetNodalDisplacement(combination);

            //step 3
            var d1l = new Displacement(g2l(d1g.Displacements), g2l(d1g.Rotations));
            var d2l = new Displacement(g2l(d2g.Displacements), g2l(d2g.Rotations));
            var d3l = new Displacement(g2l(d3g.Displacements), g2l(d3g.Rotations));

            var uCst =
                new Matrix(new[]
                           { d1l.DX, d1l.DY, d2l.DX, d2l.DY, /**/ d3l.DX, d3l.DY });

            var dbCst = CstElement.GetDMatrix(_elasticModulus, _poissonRatio, _formulationType);

            var bCst = CstElement.GetBMatrix(lp.Select(i => i.X).ToArray(),
                                             lp.Select(i => i.Y).ToArray());

            var sCst = dbCst * bCst * uCst;

            var buf = new MembraneStressTensor();

            buf.Sx  = sCst[0, 0];
            buf.Sy  = sCst[1, 0];
            buf.Txy = sCst[2, 0];

            return(buf);
        }

        private PlateBendingStressTensor GetBendingInternalForce(double localX, double localY, LoadCombination cmb)
        {
            //step 1 : get transformation matrix
            //step 2 : convert globals points to locals
            //step 3 : convert global displacements to locals
            //step 4 : calculate B matrix and D matrix
            //step 5 : M=D*B*U
            //Note : Steps changed...

            var trans = this.GetTransformationMatrix();

            var lp = GetLocalPoints();

            var g2l = new Func <Vector, Vector>(glob => (trans.Transpose() * glob.ToMatrix()).ToVector());
            //var l2g = new Func<Vector, Vector>(local => (trans*local.ToMatrix()).ToPoint());


            var d1g = this.nodes[0].GetNodalDisplacement(cmb);
            var d2g = this.nodes[1].GetNodalDisplacement(cmb);
            var d3g = this.nodes[2].GetNodalDisplacement(cmb);

            //step 3
            var d1l = new Displacement(g2l(d1g.Displacements), g2l(d1g.Rotations));
            var d2l = new Displacement(g2l(d2g.Displacements), g2l(d2g.Rotations));
            var d3l = new Displacement(g2l(d3g.Displacements), g2l(d3g.Rotations));

            var uDkt =
                new Matrix(new[]
                           { d1l.DZ, d1l.RX, d1l.RY, /**/ d2l.DZ, d2l.RX, d2l.RY, /**/ d3l.DZ, d3l.RX, d3l.RY });


            var dbDkt = DktElement.GetDMatrix(this._thickness, this._elasticModulus, this._poissonRatio);



            var b = DktElement.GetBMatrix(localX, localY,
                                          lp.Select(i => i.X).ToArray(),
                                          lp.Select(i => i.Y).ToArray());

            var mDkt = dbDkt * b * uDkt; //eq. 32, batoz article

            var buf = new PlateBendingStressTensor();

            buf.Mx  = mDkt[0, 0];
            buf.My  = mDkt[1, 0];
            buf.Mxy = mDkt[2, 0];

            return(buf);
        }
Example #2
0
        public static DataTable[] OpenseesValidate(Model model, LoadCase loadcase, bool validateStiffness = false)
        {
            var gen = new TclGenerator();

            gen.ElementTranslators.Add(new BarElement2Tcl()
            {
                TargetGenerator = gen
            });
            gen.ElementTranslators.Add(new TetrahedronToTcl()
            {
                TargetGenerator = gen
            });
            gen.ElementLoadTranslators.Add(new UniformLoad2Tcl()
            {
                TargetGenerator = gen
            });

            gen.ExportElementForces      = false;
            gen.ExportNodalDisplacements = true;
            gen.ExportTotalStiffness     = validateStiffness;
            gen.ExportNodalReactions     = true;

            var tcl = gen.Create(model, LoadCase.DefaultLoadCase);

            var nodesFile     = gen.nodesOut;
            var elementsFile  = gen.elementsOut;
            var stiffnessFile = gen.stiffnessOut;

            var tclFile = System.IO.Path.GetTempFileName() + ".tcl";


            Debug.WriteLine("{0}", tclFile);

            System.IO.File.WriteAllText(tclFile, tcl);

            if (!System.IO.File.Exists(openSeeslocation))
            {
                throw new Exception("Opensees.exe not found, please put opensees.exe into 'C:\\Opensees\\Opensees.exe'");
            }

            var stInf = new ProcessStartInfo(openSeeslocation);

            stInf.Arguments = tclFile;
            stInf.RedirectStandardOutput = true;
            stInf.UseShellExecute        = false;

            var prc = Process.Start(stInf);

            prc.WaitForExit();
            var code = prc.ExitCode;

            var stiffness = stiffnessFile == null ? null : System.IO.File.ReadAllText(stiffnessFile);

            var ndisp = new XmlDocument();

            ndisp.Load(nodesFile);

            var nreact = new XmlDocument();

            nreact.Load(gen.reactionsOut);


            if (gen.ExportElementForces)
            {
                var elOut = new XmlDocument();
                elOut.Load(elementsFile);

                var elmParts = elOut.DocumentElement.LastChild.InnerText.Trim().Split('\n').Select(i => i.Trim()).Where(i => !string.IsNullOrEmpty(i)).ToArray();
            }


            var nodalDispParts  = ndisp.DocumentElement.LastChild.InnerText.Trim().Split('\n').Select(i => i.Trim()).Where(i => !string.IsNullOrEmpty(i)).ToArray();
            var nodalReactParts = nreact.DocumentElement.LastChild.InnerText.Trim().Split('\n').Select(i => i.Trim()).Where(i => !string.IsNullOrEmpty(i)).ToArray();


            var openseesDs     = nodalDispParts[0].Split(' ').Select(double.Parse).ToArray();
            var openseesReacts = nodalReactParts[0].Split(' ').Select(double.Parse).ToArray();

            var myDs = model.Nodes.SelectMany(i => Displacement.ToVector(i.GetNodalDisplacement(loadcase))).ToArray();

            var myReacts = model.Nodes.SelectMany(i => Force.ToVector(i.GetSupportReaction(loadcase))).ToArray();

            var absNodalDisp = new double[myDs.Length];
            var relNodalDisp = new double[myDs.Length];

            var absNodalReac = new double[myDs.Length];
            var relNodalReac = new double[myDs.Length];

            var nums = Enumerable.Range(0, myDs.Length).ToArray();

            FindError(openseesDs, myDs, relNodalDisp, absNodalDisp);
            FindError(openseesReacts, myReacts, relNodalReac, absNodalReac);

            //var k = absNodalDisp;
            //var key = new Func<double[]>(() => (double[])absNodalDisp.Clone());

            var nodalDispTbl  = new DataTable();
            var nodalReactTbl = new DataTable();
            var elmFrcTbl     = new DataTable();

            {
                nodalDispTbl.Columns.Add("Node #", typeof(int));
                nodalDispTbl.Columns.Add("DoF", typeof(string));
                nodalDispTbl.Columns.Add("DoF #", typeof(int));
                nodalDispTbl.Columns.Add("OpenSees Delta", typeof(double));
                nodalDispTbl.Columns.Add("BFE Delta", typeof(double));
                nodalDispTbl.Columns.Add("Relative Error", typeof(double));
                nodalDispTbl.Columns.Add("Absolute Error", typeof(double));
            }


            {
                nodalReactTbl.Columns.Add("Node #", typeof(int));
                nodalReactTbl.Columns.Add("DoF", typeof(string));
                nodalReactTbl.Columns.Add("DoF #", typeof(int));
                nodalReactTbl.Columns.Add("OpenSees Support Reaction", typeof(double));
                nodalReactTbl.Columns.Add("BFE Support Reaction", typeof(double));
                nodalReactTbl.Columns.Add("Relative Error", typeof(double));
                nodalReactTbl.Columns.Add("Absolute Error", typeof(double));
            }

            {
                elmFrcTbl.Columns.Add("Elm #", typeof(int));
                elmFrcTbl.Columns.Add("Relative Error", typeof(double));
                elmFrcTbl.Columns.Add("Absolute Error", typeof(double));
            }

            for (int i = 0; i < myDs.Length; i++)
            {
                nodalDispTbl.Rows.Add(
                    i / 6,
                    ((DoF)(i % 6)).ToString(),
                    nums[i],
                    openseesDs[i],
                    myDs[i],
                    relNodalDisp[i],
                    absNodalDisp[i]
                    );

                nodalReactTbl.Rows.Add(
                    i / 6,
                    ((DoF)(i % 6)).ToString().Replace("D", "F").Replace("R", "M"),
                    nums[i],
                    openseesReacts[i],
                    myReacts[i],
                    relNodalReac[i],
                    absNodalReac[i]
                    );
            }

            /*
             * for (int i = 0; i < model.Elements.Count; i++)
             * {
             *  var bar = model.Elements[i] as BarElement;
             *
             *  var myFrc = bar.GetInternalForceAt(0, LoadCase.DefaultLoadCase);
             *
             *  nodalDispTbl.Rows.Add(
             *      i ,
             *      ((DoF)(i % 6)).ToString(),
             *      nums[i],
             *      openseesDs[i],
             *      myDs[i],
             *      relNodalDisp[i],
             *      absNodalDisp[i]
             *      );
             *
             * }
             */

            return(new[] { nodalDispTbl, nodalReactTbl });
        }
Example #3
0
        private MembraneStressTensor GetMembraneInternalForce(LoadCombination combination)
        {
            //Note: membrane internal force is constant

            //step 1 : get transformation matrix
            //step 2 : convert globals points to locals
            //step 3 : convert global displacements to locals
            //step 4 : calculate B matrix and D matrix
            //step 5 : M=D*B*U
            //Note : Steps changed...

            var trans = this.GetTransformationMatrix();

            var lp = GetLocalPoints();

            var g2l = new Func <Vector, Vector>(glob => (trans.Transpose() * glob.ToMatrix()).ToVector());
            //var l2g = new Func<Vector, Vector>(local => (trans*local.ToMatrix()).ToPoint());


            var d1g = this.nodes[0].GetNodalDisplacement(combination);
            var d2g = this.nodes[1].GetNodalDisplacement(combination);
            var d3g = this.nodes[2].GetNodalDisplacement(combination);

            //step 3
            var d1l = new Displacement(g2l(d1g.Displacements), g2l(d1g.Rotations));
            var d2l = new Displacement(g2l(d2g.Displacements), g2l(d2g.Rotations));
            var d3l = new Displacement(g2l(d3g.Displacements), g2l(d3g.Rotations));

            var uCst =
                new Matrix(new[]
                           { d1l.DX, d1l.DY, d2l.DX, d2l.DY, /**/ d3l.DX, d3l.DY });

            var dbCst = CstElement.GetDMatrix(_elasticModulus, _poissonRatio, _formulationType);

            var bCst = CstElement.GetBMatrix(lp.Select(i => i.X).ToArray(),
                                             lp.Select(i => i.Y).ToArray());

            var sCst = dbCst * bCst * uCst;

            var buf = new MembraneStressTensor();

            buf.Sx  = sCst[0, 0];
            buf.Sy  = sCst[1, 0];
            buf.Txy = sCst[2, 0];

            return(buf);
        }

        private PlateBendingStressTensor GetBendingInternalForce(double localX, double localY, LoadCombination cmb)
        {
            //step 1 : get transformation matrix
            //step 2 : convert globals points to locals
            //step 3 : convert global displacements to locals
            //step 4 : calculate B matrix and D matrix
            //step 5 : M=D*B*U
            //Note : Steps changed...

            var trans = this.GetTransformationMatrix();

            var lp = GetLocalPoints();

            var g2l = new Func <Vector, Vector>(glob => (trans.Transpose() * glob.ToMatrix()).ToVector());
            //var l2g = new Func<Vector, Vector>(local => (trans*local.ToMatrix()).ToPoint());


            var d1g = this.nodes[0].GetNodalDisplacement(cmb);
            var d2g = this.nodes[1].GetNodalDisplacement(cmb);
            var d3g = this.nodes[2].GetNodalDisplacement(cmb);

            //step 3
            var d1l = new Displacement(g2l(d1g.Displacements), g2l(d1g.Rotations));
            var d2l = new Displacement(g2l(d2g.Displacements), g2l(d2g.Rotations));
            var d3l = new Displacement(g2l(d3g.Displacements), g2l(d3g.Rotations));

            var uDkt =
                new Matrix(new[]
                           { d1l.DZ, d1l.RX, d1l.RY, /**/ d2l.DZ, d2l.RX, d2l.RY, /**/ d3l.DZ, d3l.RX, d3l.RY });


            var dbDkt = DktElement.GetDMatrix(this._thickness, this._elasticModulus, this._poissonRatio);



            var b = DktElement.GetBMatrix(localX, localY,
                                          lp.Select(i => i.X).ToArray(),
                                          lp.Select(i => i.Y).ToArray());

            var mDkt = dbDkt * b * uDkt; //eq. 32, batoz article

            var buf = new PlateBendingStressTensor();

            buf.Mx  = mDkt[0, 0];
            buf.My  = mDkt[1, 0];
            buf.Mxy = mDkt[2, 0];

            return(buf);
        }

        #endregion

        #region stresses
        /// <summary>
        /// Gets the internal stress at defined location.
        /// tensor is in local coordinate system.
        /// </summary>
        /// <param name="localX">The X in local coordinate system (see remarks).</param>
        /// <param name="localY">The Y in local coordinate system (see remarks).</param>
        /// <param name="combination">The load combination.</param>
        /// <param name="probeLocation">The probe location for the stress.</param>
        /// <param name="thickness">The location for the bending stress. Maximum at the shell thickness</param>
        /// <returns>Stress tensor of flat shell, in local coordination system</returns>
        /// <remarks>
        /// for more info about local coordinate of flat shell see page [72 of 166] (page 81 of pdf) of "Development of Membrane, Plate and Flat Shell Elements in Java" thesis by Kaushalkumar Kansara freely available on the web
        /// </remarks>
        public FlatShellStressTensor GetInternalStress(double localX, double localY, LoadCombination combination, double thickness, SectionPoints probeLocation)
        {
            var buf = new FlatShellStressTensor();

            if ((this._behaviour & PlaneElementBehaviour.ThinPlate) != 0)
            {
                buf.MembraneTensor = GetMembraneInternalForce(combination);
            }

            if ((this._behaviour & PlaneElementBehaviour.Membrane) != 0)
            {
                buf.BendingTensor = GetBendingInternalForce(localX, localY, combination);
            }

            buf.UpdateTotalStress(thickness, probeLocation);
            return(buf);
        }

        #endregion

        #region strains
        public StrainTensor GetMembraneInternalStrain(LoadCombination combination)
        {
            //Note: membrane internal force is constant

            //step 1 : get transformation matrix
            //step 2 : convert globals points to locals
            //step 3 : convert global displacements to locals
            //step 4 : calculate B matrix
            //step 5 : e=B*U
            //Note : Steps changed...

            var trans = this.GetTransformationMatrix();

            var lp = GetLocalPoints();

            var g2l = new Func <Vector, Vector>(glob => (trans.Transpose() * glob.ToMatrix()).ToVector());
            //var l2g = new Func<Vector, Vector>(local => (trans*local.ToMatrix()).ToPoint());


            var d1g = this.nodes[0].GetNodalDisplacement(combination);
            var d2g = this.nodes[1].GetNodalDisplacement(combination);
            var d3g = this.nodes[2].GetNodalDisplacement(combination);

            //step 3
            var d1l = new Displacement(g2l(d1g.Displacements), g2l(d1g.Rotations));
            var d2l = new Displacement(g2l(d2g.Displacements), g2l(d2g.Rotations));
            var d3l = new Displacement(g2l(d3g.Displacements), g2l(d3g.Rotations));

            var uCst =
                new Matrix(new[]
                           { d1l.DX, d1l.DY, d2l.DX, d2l.DY, /**/ d3l.DX, d3l.DY });

            var bCst = CstElement.GetBMatrix(lp.Select(i => i.X).ToArray(),
                                             lp.Select(i => i.Y).ToArray());

            var ECst = bCst * uCst;

            var buf = new StrainTensor();

            buf.S11 = ECst[0, 0];
            buf.S22 = ECst[1, 0];
            buf.S12 = ECst[2, 0];

            return(buf);
        }
Example #4
0
    public override string ToString()
    {
        StringBuilder sb = new StringBuilder();

        sb.AppendFormat("{0}{1}:\n", offset, Model);
        sb.AppendFormat("{0}{0}Power: {1}\n", offset, Power);
        sb.AppendFormat("{0}{0}Displacement: {1}\n", offset, Displacement == -1 ? "n/a" : Displacement.ToString());
        sb.AppendFormat("{0}{0}Efficiency: {1}\n", offset, Efficiency);

        return(sb.ToString());
    }
 protected VirtualConstraint(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     _settlement = (Displacement)info.GetValue("_settlement", typeof(Displacement));
     _constraint = (Constraint)info.GetValue("_constraint", typeof(Constraint));
 }
Example #6
0
        public override string ToString()
        {
            if (IsRegister)
            {
                return(Register.Name);
            }

            if (IsImmediate)
            {
                return(Immediate.ToString());
            }

            if (IsLabel)
            {
                if (IsMemory)
                {
                    return("[" + Label + "]");
                }
                else
                {
                    return(Label);
                }
            }

            if (IsMemory)
            {
                //  Register + (Index * Scale) + Displacement
                string s = "[";

                if (Register != null)
                {
                    s = s + Register.Name;
                }
                else
                {
                    s = s + Immediate.ToString();
                }

                if (Index != null)
                {
                    s = s + "+" + Index.Name;
                }

                if (Scale != 0)
                {
                    s = s + "*" + Scale.ToString();
                }

                if (Displacement != 0)
                {
                    if (Displacement >= 0)
                    {
                        s = s + "+" + Displacement.ToString();
                    }
                    else
                    {
                        s = s + Displacement.ToString();
                    }
                }

                s = s + "]";

                return(s);
            }

            return(string.Empty);
        }
Example #7
0
 private static GenericStructure WriteDisplacement(Displacement disp)
 {
     throw new NotImplementedException();
 }