コード例 #1
0
ファイル: NEUWriter.cs プロジェクト: stjordanis/MSolve
        private List <string> MakeNodalDataVector(NEUOutputVectorProperties vectorProperties)
        {
            var lines = new List <string>();

            lines.Add(String.Format("{0},{1},1,", outputSet, vectorProperties.ID));
            lines.Add(vectorProperties.Title);
            lines.Add(String.Format("{0},{1},{2},", 0, 0, 0));
            lines.Add(String.Format("{0},0,0,0,0,0,0,0,", vectorProperties.ComponentVector));
            lines.Add("0,0,0,0,0,0,0,0,0,0,");
            lines.Add("0,");
            lines.Add(String.Format("{0},{1},1,7,", 0, 0));
            lines.Add("0,1,1,");

            var embeddedNodeValues = CalculateEmbeddedNodeValues();

            foreach (var node in model.NodalDOFsDictionary)
            {
                var key = new Tuple <int, DOFType>(node.Key, vectorProperties.DOFType);
                if (embeddedNodeValues.ContainsKey(key))
                {
                    lines.Add(String.Format(CultureInfo.InvariantCulture, "{0},{1},", node.Key, embeddedNodeValues[key]));
                }
                else
                {
                    //if (node.Value.ContainsKey(vectorProperties.DOFType) && node.Value[vectorProperties.DOFType] > -1)
                    //    lines.Add(String.Format(CultureInfo.InvariantCulture, "{0},{1},", node.Key, subdomain.Solution[node.Value[vectorProperties.DOFType]]));
                    if (!node.Value.ContainsKey(vectorProperties.DOFType))
                    {
                        continue;
                    }

                    if (node.Value[vectorProperties.DOFType] > -1)
                    {
                        lines.Add(String.Format(CultureInfo.InvariantCulture, "{0},{1},", node.Key, subdomain.Solution[node.Value[vectorProperties.DOFType]]));
                    }
                }
                //else
                //{
                //    var key = new Tuple<int, DOFType>(node.Key, vectorProperties.DOFType);
                //    if (embeddedNodeValues.ContainsKey(key))
                //        lines.Add(String.Format(CultureInfo.InvariantCulture, "{0},{1},", node.Key, embeddedNodeValues[key]));
                //}
            }
            lines.Add("-1,0.,");

            return(lines);
        }
コード例 #2
0
        private List <string> MakeNodalDataVector(NEUOutputVectorProperties vectorProperties)
        {
            var lines = new List <string>();

            lines.Add(String.Format("{0},{1},1,", outputSet, vectorProperties.ID));
            lines.Add(vectorProperties.Title);
            lines.Add(String.Format("{0},{1},{2},", 0, 0, 0));
            lines.Add(String.Format("{0},0,0,0,0,0,0,0,", vectorProperties.ComponentVector));
            lines.Add("0,0,0,0,0,0,0,0,0,0,");
            lines.Add("0,");
            lines.Add(String.Format("{0},{1},1,7,", 0, 0));
            lines.Add("0,1,1,");

            var embeddedNodeValues = CalculateEmbeddedNodeValues();

            foreach (var node in model.Nodes)
            {
                var key = new Tuple <int, IDofType>(node.ID, vectorProperties.DOFType);
                if (embeddedNodeValues.ContainsKey(key))
                {
                    lines.Add(String.Format(CultureInfo.InvariantCulture, "{0},{1},", node.ID, embeddedNodeValues[key]));
                }
                else
                {
                    bool nodeExists = model.GlobalDofOrdering.GlobalFreeDofs.TryGetDataOfRow(node,
                                                                                             out IReadOnlyDictionary <IDofType, int> dofTypesIndices);
                    if (nodeExists)
                    {
                        if (!dofTypesIndices.ContainsKey(vectorProperties.DOFType))
                        {
                            continue;
                        }
                        lines.Add(String.Format(CultureInfo.InvariantCulture, "{0},{1},",
                                                node.ID, subdomain.Solution[dofTypesIndices[vectorProperties.DOFType]]));
                    }
                }
            }
            lines.Add("-1,0.,");

            return(lines);
        }