예제 #1
0
        /// <summary>
        /// Calculate interpolation weights for the point (x,y) inside the triangle defined by
        /// the nodes in <paramref name="elmtNodes"/>.
        ///<para>
        /// Check
        /// <see cref="InterpolationWeights(double,double,double,double,double,double,double,double)"/>
        /// for details.
        /// </para>
        /// </summary>
        /// <param name="x">Point X coordinate</param>
        /// <param name="y">Point Y coordinate</param>
        /// <param name="elmtNodes">Nodes in element</param>
        /// <returns>Interpolation weights (w1,w2,w3)</returns>
        public static Weights InterpolationWeights(double x, double y, IList <MeshNode> elmtNodes)
        {
            double x1 = elmtNodes[0].X;
            double x2 = elmtNodes[1].X;
            double x3 = elmtNodes[2].X;
            double y1 = elmtNodes[0].Y;
            double y2 = elmtNodes[1].Y;
            double y3 = elmtNodes[2].Y;

            return(InterpTriangle.InterpolationWeights(x, y, x1, y1, x2, y2, x3, y3));
        }
예제 #2
0
        /// <summary>
        /// Calculate interpolation weights for the point (x,y) inside the triangle defined by
        /// the nodes in <paramref name="elmtNodes"/>.
        ///<para>
        /// Check
        /// <see cref="InterpolationWeights(double,double,double,double,double,double,double,double)"/>
        /// for details.
        /// </para>
        /// </summary>
        /// <param name="x">Point X coordinate</param>
        /// <param name="y">Point Y coordinate</param>
        /// <param name="smesh">MeshData object</param>
        /// <param name="elmtNodes">Nodes in element</param>
        /// <returns>Interpolation weights (w1,w2,w3)</returns>
        public static Weights InterpolationWeights(double x, double y, SMeshData smesh, int[] elmtNodes)
        {
            double x1 = smesh.X[elmtNodes[0]];
            double x2 = smesh.X[elmtNodes[1]];
            double x3 = smesh.X[elmtNodes[2]];
            double y1 = smesh.Y[elmtNodes[0]];
            double y2 = smesh.Y[elmtNodes[1]];
            double y3 = smesh.Y[elmtNodes[2]];

            return(InterpTriangle.InterpolationWeights(x, y, x1, y1, x2, y2, x3, y3));
        }
예제 #3
0
 private void Init()
 {
     _interpQ = new InterpQuadrangle()
     {
         DelVal = DeleteValue
     };
     _interpT = new InterpTriangle()
     {
         DelVal = DeleteValue
     };
     _interpEN = new InterpElmtNode()
     {
         DelVal = DeleteValue
     };
 }
예제 #4
0
        /// <summary>
        /// Interpolate node values to the (x,y) coordinate.
        /// </summary>
        /// <param name="x">X coordinate</param>
        /// <param name="y">Y coordinate</param>
        /// <param name="nodeValues">Node values</param>
        public double InterpolateNodeToXY(double x, double y, double[] nodeValues)
        {
            // Find element that includes the (x,y) coordinate
            int element = _ssearcher.FindElement(x, y);

            // Check if element has been found, i.e. includes the (x,y) point
            if (element >= 0)
            {
                int[] nodes = _smesh.ElementTable[element];
                if (nodes.Length == 3)
                {
                    var weights = InterpTriangle.InterpolationWeights(x, y, _smesh, nodes);
                    return(_interpT.GetValue(weights, nodes, _smesh, nodeValues));
                }
                if (nodes.Length == 4)
                {
                    var weights = InterpQuadrangle.InterpolationWeights(x, y, _smesh, nodes);
                    return(_interpQ.GetValue(weights, nodes, _smesh, nodeValues));
                }
            }
            return(DeleteValue);
        }
예제 #5
0
        /// <summary>
        /// Add a target, by specifying its (x,y) coordinate.
        /// </summary>
        private void AddSTarget(double x, double y)
        {
            // Find element that includes the (x,y) coordinate
            int element = _ssearcher.FindElement(x, y);

            // Setup interpolation from node values
            if (NodeValueInterpolation)
            {
                InterpNodeData interp;
                if (element >= 0)
                {
                    int[] nodes = _smesh.ElementTable[element];
                    if (nodes.Length == 3)
                    {
                        var weights = InterpTriangle.InterpolationWeights(x, y, _smesh, nodes);
                        interp = new InterpNodeData(element, weights.w1, weights.w2, weights.w3);
                    }
                    else if (nodes.Length == 4)
                    {
                        var weights = InterpQuadrangle.InterpolationWeights(x, y, _smesh, nodes);
                        interp = new InterpNodeData(element, weights.dx, weights.dy);
                    }
                    else
                    {
                        interp = InterpNodeData.Undefined();
                    }
                }
                else
                {
                    interp = InterpNodeData.Undefined();
                }

                if (_targetsNode == null)
                {
                    _targetsNode = new List <InterpNodeData>();
                }
                _targetsNode.Add(interp);
            }

            // Setup interpolation from element+node values
            if (ElmtNodeValueInterpolation)
            {
                InterpElmtNode.Weights weights;

                // Check if element has been found, i.e. includes the (x,y) point
                if (element >= 0)
                {
                    weights = InterpElmtNode.InterpolationWeights(x, y, element, _smesh);
                }
                else
                {
                    weights = InterpElmtNode.Undefined();
                }

                if (_targetsElmtNode == null)
                {
                    _targetsElmtNode = new List <InterpElmtNode.Weights>();
                }
                _targetsElmtNode.Add(weights);
            }
        }
예제 #6
0
        /// <summary>
        /// Add a target, by specifying its (x,y) coordinate.
        /// </summary>
        public void AddTarget(double x, double y)
        {
            if (_mesh == null)
            {
                AddSTarget(x, y);
                return;
            }

            // Find element that includes the (x,y) coordinate
            MeshElement element = _searcher.FindElement(x, y);

            // Setup interpolation from node values
            if (NodeValueInterpolation)
            {
                InterpNodeData interp;
                // Check if element has been found, i.e. includes the (x,y) point
                if (element != null)
                {
                    var nodes = element.Nodes;
                    if (nodes.Count == 3)
                    {
                        var weights = InterpTriangle.InterpolationWeights(x, y, nodes);
                        interp = new InterpNodeData(element.Index, weights.w1, weights.w2, weights.w3);
                    }
                    else if (nodes.Count == 4)
                    {
                        var weights = InterpQuadrangle.InterpolationWeights(x, y, nodes);
                        interp = new InterpNodeData(element.Index, weights.dx, weights.dy);
                    }
                    else
                    {
                        interp = InterpNodeData.Undefined();
                    }
                }
                else
                {
                    interp = InterpNodeData.Undefined();
                }

                if (_targetsNode == null)
                {
                    _targetsNode = new List <InterpNodeData>();
                }
                _targetsNode.Add(interp);
            }

            // Setup interpolation from element+node values
            if (ElmtNodeValueInterpolation)
            {
                InterpElmtNode.Weights weights;
                // Check if element has been found, i.e. includes the (x,y) point
                if (element != null)
                {
                    weights = InterpElmtNode.InterpolationWeights(x, y, element);
                }
                else
                {
                    weights = InterpElmtNode.Undefined();
                }

                if (_targetsElmtNode == null)
                {
                    _targetsElmtNode = new List <InterpElmtNode.Weights>();
                }
                _targetsElmtNode.Add(weights);
            }
        }