Example #1
0
        public void writeNodePositions(Node[][] NodeArray)
        {
            try
            {
                SaveFileDialog saveFile = new SaveFileDialog();

                saveFile.Filter = "CSV|*.csv";
                saveFile.Title = "Save the data file:";
                saveFile.DefaultExt = "*.csv";

                saveFile.ShowDialog();

                string directory = saveFile.FileName;

                TextWriter dataWrite = new StreamWriter(directory);

                dataWrite.WriteLine("Node ID" + "," + "XPOS" + "," + "YPOS" + "," + "Material");

                //for (int i = 1; i < scanCount; i++)
                  //  dataWrite.WriteLine(ampArraytoWrite[i] + "," + timeArray[i] + "," + tempArray[i] + "," + dTdt[i]);

                foreach (Node[] node in NodeArray)
                {
                    foreach (Node ind_node in node)
                    {
                        int node_Material = 0;

                        if (ind_node.Material == "Copper")
                            node_Material = 1;
                        else if (ind_node.Material == "BiTe")
                            node_Material = 2;
                        else if (ind_node.Material == "Ceramic")
                            node_Material = 3;
                        else if (ind_node.Material == "Air")
                            node_Material = 4;

                        dataWrite.WriteLine(ind_node.Node_ID + "," + ind_node.x_pos + "," + ind_node.y_pos + "," + node_Material);
                    }
                }

                dataWrite.Close();
            }
            catch
            {
                MessageBox.Show("Error saving file, or writing was canceled ", "Error!", MessageBoxButtons.OK);
            }
        }
        /// <summary>
        /// Constructor for BoundaryConditions class
        /// </summary>
        /// <param name="Nodal_Array">Node array with which to apply the boundary conditions to</param>
        /// <param name="local_ErrorHandler">Errorhandler to pass messages to the Main UI</param>
        /// <param name="T_Base">Constant temperature of the south face of the TEM in Kelvin</param>
        /// <param name="h_Top">Heat transfer coefficient (initial) operating off of the top surface of the TEM</param>
        /// <param name="T_inf">Ambient temperature utilized for the convective coefficient off of the top surface</param>
        public BoundaryConditions(Node[][] Nodal_Array, ErrorHandler local_ErrorHandler, bool[] BC_CONVECTION, bool[] BC_CONST_T, bool[] BC_ADIABATIC, float[] h, float[] T_INFINITY, float[] T_CONST)
        {
            Nodes = Nodal_Array;

            BC_ErrorHandler = local_ErrorHandler;

            BC_h = BC_CONVECTION;

            BC_T = BC_CONST_T;

            BC_Adiabatic = BC_ADIABATIC;

            h_Coefficient = h;

            Constant_T = T_CONST;

            T_inf = T_INFINITY;

            Check_Boundary_Condition();

            Apply_Boundary_Conditions();
        }
Example #3
0
        // ListToJaggedArray
        //
        /// <summary>
        ///          When passed in a sorted NodeList, ListToJaggedArray arranges the nodes into a 2D jagged array 
        ///          of Node[][].  This ensures that Node[0][0] is the least node in the (x,y) and Node[0][1] is just
        ///          to the right of it, etc.
        /// </summary>
        /// <param name="p_NodeList">Grouped nodes with which to convert to a jagged array for further analysis</param>
        /// <returns></returns>
        private Node[][] ListtoJaggedArray(IList<IGrouping<float, Node>> p_NodeList)
        {
            // Creates new jagged array to hold NodeList data
            var result = new Node[p_NodeList.Count][];

            for (var i = 0; i < p_NodeList.Count; i++)
            {
                result[i] = p_NodeList[i].ToArray();
            }

            Mesh_Errors.Post_Error("NOTE:  Finished arranging node list into jagged array");

            // Display Jagged Array to User
            for (var i = 0; i < result[i].Count(); i++)
            {
                Mesh_Errors.Post_Error("NOTE:  Final Array is Node[" + result.Count().ToString() + ", " + result[i].Count().ToString() + "]");
            }

            for (int i = 0; i < result.Count(); i++)
            {
                for (int j = 0; j < result[i].Count(); j++)
                {
                    result[i][j].i = i;
                    result[i][j].j = j;
                }
            }

            // Returns Node[][] to user
            return result;
        }
Example #4
0
        /// <summary>
        /// Checks the passed in node to see if it is inside the layer bounds
        /// </summary>
        /// <param name="node">Current node object to inspect</param>
        /// <param name="Current_Layer">Current layer in which the node object resides</param>
        private void Check_Node(Node node, Layer Current_Layer)
        {
            if (node.x_pos > Current_Layer.Layer_xf)
                Mesh_Errors.Post_Error("MESH ERROR:  Node assignment outside of layer bounds {xf-" + Current_Layer.Layer_xf.ToString() + ", x_node-" + node.x_pos.ToString() + "}");

            if (node.y_pos > Current_Layer.Layer_y0)
                Mesh_Errors.Post_Error("MESH ERROR:  Node assignment outside of layer bounds {y0-" + Current_Layer.Layer_y0.ToString() + ", y_node-" + node.y_pos.ToString() + "}");

            if (node.y_pos < Current_Layer.Layer_yf)
                Mesh_Errors.Post_Error("MESH ERROR:  Node assignment outside of layer bounds {yf-" + Current_Layer.Layer_yf.ToString() + ", y_node-" + node.y_pos.ToString() + "}");

            if (node.x_pos < Current_Layer.Layer_x0)
                Mesh_Errors.Post_Error("MESH ERROR:  Node assignment outside of layer bounds {x0-" + Current_Layer.Layer_x0.ToString() + ", x_node-" + node.x_pos.ToString() + "}");
        }
Example #5
0
 public CSVWriter(Node[][] NodeArray)
 {
     writeNodePositions(NodeArray);
 }
Example #6
0
 public Solver(ErrorHandler local_ErrorHandler, Node[][] NodeArray)
 {
     Solver_ErrorHandler = local_ErrorHandler;
     Nodes = NodeArray;
 }
Example #7
0
        /// <summary>
        /// Constructor of the NodeInitializer Class.
        /// </summary>
        /// <param name="Nodes">Node Array of Numeric Model</param>
        /// <param name="local_ErrorHandler">Error Handler for Message Passing</param>
        /// <param name="Materials">Material Manager which holds all the material properties</param>
        /// <param name="Layers">List of Layers holding material information for each node inside of it</param>
        public NodeInitializer(Node[][] Nodes, ErrorHandler local_ErrorHandler, MaterialManager Materials, List<Layer> Layers, float dt, float Amps, bool is_Warming_Top)
        {
            this.dt = dt;

            this.Amps = Amps;

            this.is_Warming_Top = is_Warming_Top;

            x_Max_DX = 0.0f;
            y_Max_DY = 0.0f;

            max_X = 0.0f;
            max_Y = 0.0f;

            foreach (Node[] node_array in Nodes)
            {
                foreach (Node node in node_array)
                {
                    if (node.x_pos > x_Max_DX)
                        x_Max_DX = node.x_pos;

                    if (node.y_pos > y_Max_DY)
                        y_Max_DY = node.y_pos;

                }
            }

            foreach (Layer layer in Layers)
            {
                if (layer.Layer_xf > max_X)
                    max_X = layer.Layer_xf;
                if (layer.Layer_y0 > max_Y)
                    max_Y = layer.Layer_y0;
            }

            LayerList = Layers;

            NodeArray = Nodes;

            Node_I_ErrorHandler = local_ErrorHandler;

            Mat_Manager = Materials;

            x_MinpDX = Nodes[0][0].x_pos;
            y_MinpDY = Nodes[0][0].y_pos;

            Assign_Materials();

            Calculate_DxDy();

            Initialize_Heat_Generation(Amps, is_Warming_Top); // Passed in 5.0f value represents an initialization current... this needs to be fed in

            Initialize_Influence_Coefficients(Nodes); // Must come after heat generation initialization
        }
Example #8
0
        /// <summary>
        /// Initializes influence coefficients for each node passed in
        /// </summary>
        /// <param name="Nodes">Jagged 2D array of nodes</param>
        private void Initialize_Influence_Coefficients(Node[][] Nodes)
        {
            List<Node> BoundaryNodes = new List<Node>();

            foreach (Node[] Node_Array in Nodes)
            {
                foreach (Node node in Node_Array)
                {
                    node.Initialize_Influence_Coefficients(dt);

                    if (node.is_Boundary)
                    {
                        BoundaryNodes.Add(node);
                    }
                }
            }

            int boundary_Counter = 0;
            int s_boundary_Counter = 0;

            List<Material> MaterialList = new List<Material>();

            MaterialList = Mat_Manager.Material_List;

            // Need to iterate through Boundary_Nodes, to find nearest material to boundary nodes
            foreach (Node b_Node in BoundaryNodes)
            {
                if (LayerList[b_Node.Layer_ID].Layer_Material != b_Node.Boundary_Material && b_Node.Boundary_Material != "")
                {
                    boundary_Counter++;
                }

                if (LayerList[b_Node.Layer_ID].Layer_Material == b_Node.Boundary_Material && b_Node.Boundary_Material != "")
                {
                    s_boundary_Counter++;
                }

                b_Node.Initialize_Effective_Conductivities(MaterialList);
            }

            Node_I_ErrorHandler.Post_Error("NOTE: " + boundary_Counter.ToString() + " number of material boundaries detected with " + s_boundary_Counter.ToString() +
                " boundary materials matching their own material");

            Node_I_ErrorHandler.Post_Error("NOTE:  Finished Initializing Influence Coefficients");
        }
Example #9
0
        /// <summary>
        /// Finds the closest boundary material for a given boundary node in the y direction (N or S)
        /// </summary>
        /// <param name="node">Node with which to assign the boundary material to</param>
        /// <param name="N_Or_S">Flag value indicating whether to look in the North or South direction</param>
        /// <returns>String value containing the name of the boundary material</returns>
        private string get_Boundary_Material_Y(Node node, string N_Or_S)
        {
            float dy = 0.00000015f;
            float y0 = 0.0f;
            string material = LayerList[node.Layer_ID].Layer_Material;

            y0 = node.y_pos;

            if (N_Or_S == "N") // plus
            {
                while (material == LayerList[node.Layer_ID].Layer_Material)
                {
                    y0 += dy;

                    if (y0 > max_Y)
                        break;

                    material = checkRectangle(node.x_pos, y0);
                }
            }

            if (N_Or_S == "S") // minus
            {
                while (material == LayerList[node.Layer_ID].Layer_Material)
                {
                    y0 -= dy;

                    if (y0 < 0.0000000f)
                        break;

                    material = checkRectangle(node.x_pos, y0);
                }
            }

            return material;
        }
Example #10
0
        /// <summary>
        /// Finds the closest boundary material for a given boundary node in the x direction (E or W)
        /// </summary>
        /// <param name="node">Node with which to assign the boundary material to</param>
        /// <param name="E_Or_W">Flag value indicating whether to look in the East or West direction</param>
        /// <returns>String value containing the name of the boundary material</returns>
        private string get_Boundary_Material_X(Node node, string E_Or_W)
        {
            float dx = 0.00000015f; // [m]
            float x0 = 0.0f;
            string material = LayerList[node.Layer_ID].Layer_Material;

            x0 = node.x_pos;

            if (E_Or_W == "E") // plus
            {
                while (material == LayerList[node.Layer_ID].Layer_Material)
                {
                    x0 += dx;
                    if (x0 >= max_X)
                        break;
                    material = checkRectangle(x0, node.y_pos);
                }
            }

            if (E_Or_W == "W") // minus
            {
                while (material == LayerList[node.Layer_ID].Layer_Material)
                {
                    x0 -= dx;

                    if (x0 <= 0.0000000f)
                        break;
                    material = checkRectangle(x0, node.y_pos);
                }
            }

            return material;
        }
Example #11
0
        /// <summary>
        /// Finds the closest boundary position (either vertical (Y) or horizontal (X)) to the passed
        /// in node element
        /// </summary>
        /// <param name="node">Node object's position is used to calculate the distance from a list of positions</param>
        /// <param name="Positions">List of positions to be checked</param>
        /// <returns>Distance in meters of closest nodal boundary</returns>
        private float FindClosestBoundary_Y(Node node, List<float> Positions)
        {
            float delta_Y = 100.0f;

            Layer currentLayer = LayerList[node.Layer_ID];

            foreach (float pos in Positions)
            {
                if (pos != node.y_pos)
                {
                    if (pos < currentLayer.Layer_yf | pos > currentLayer.Layer_y0)
                    {
                        float val = Math.Abs(node.y_pos - pos);

                        if (val < delta_Y)
                        {
                            delta_Y = val;
                        }
                    }
                }
            }

            if (delta_Y == 100.0f)
            {
                Node_I_ErrorHandler.Post_Error("NODE INITIALIZATION ERROR:  DELTA_Y SET INCORRECTLY");
            }

            return delta_Y;
        }