Ejemplo n.º 1
0
 private void Init()
 {
     _interpQ = new InterpQuadrangle()
     {
         DelVal = DeleteValue
     };
     _interpT = new InterpTriangle()
     {
         DelVal = DeleteValue
     };
     _interpEN = new InterpElmtNode()
     {
         DelVal = DeleteValue
     };
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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);
            }
        }