167 lines
5.1 KiB
C#
167 lines
5.1 KiB
C#
|
|
using CaeGlobals;
|
|||
|
|
using CaeKnowledge.View;
|
|||
|
|
using CaeMesh;
|
|||
|
|
using CaeResults;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
|
|||
|
|
namespace CPSO.Forms._92_Knowledge
|
|||
|
|
{
|
|||
|
|
public partial class FrmAnalysisResult : Form
|
|||
|
|
{
|
|||
|
|
public FrmAnalysisResult()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
|
|||
|
|
dataGridView1.AllowUserToAddRows = false;
|
|||
|
|
dataGridView1.AllowUserToDeleteRows = false;
|
|||
|
|
|
|||
|
|
dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically;
|
|||
|
|
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private Controller _self;
|
|||
|
|
|
|||
|
|
public Controller Self { get { return _self; } }
|
|||
|
|
|
|||
|
|
private Dictionary<string, string> _data = new Dictionary<string, string>();
|
|||
|
|
|
|||
|
|
public void PrepareForm(Controller self)
|
|||
|
|
{
|
|||
|
|
_data.Clear();
|
|||
|
|
|
|||
|
|
if (self != null)
|
|||
|
|
{
|
|||
|
|
_self = self;
|
|||
|
|
|
|||
|
|
toolStripComboBox1.Items.Clear();
|
|||
|
|
|
|||
|
|
// 分析结果
|
|||
|
|
foreach (var job in self.CompletedJobs)
|
|||
|
|
{
|
|||
|
|
toolStripComboBox1.Items.Add(job.JobName);
|
|||
|
|
|
|||
|
|
_data.Add(job.JobName, job.SurfaceName);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void toolStripButton1_Click(object sender, System.EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (dataGridView1.DataSource is BindingList<ViewFeLog> list)
|
|||
|
|
{
|
|||
|
|
list.Clear();
|
|||
|
|
|
|||
|
|
if (toolStripComboBox1.SelectedIndex >= 0)
|
|||
|
|
{
|
|||
|
|
var jobName = toolStripComboBox1.SelectedItem as string;
|
|||
|
|
var surfaceName = toolStripTextBox1.Text;
|
|||
|
|
|
|||
|
|
LoadJob(list, jobName, surfaceName);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
MessageBox.Show($"没有选择指定作业Job,将提取全部结果!",
|
|||
|
|
"消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|||
|
|
|
|||
|
|
foreach (var job in Self.CompletedJobs)
|
|||
|
|
{
|
|||
|
|
LoadJob(list, job.JobName, job.SurfaceName);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void LoadJob(BindingList<ViewFeLog> list, string jobName, string surfaceName)
|
|||
|
|
{
|
|||
|
|
var job = Self.GetJob(jobName);
|
|||
|
|
var surface = Self.GetSurface(surfaceName);
|
|||
|
|
|
|||
|
|
// 读取结果文件
|
|||
|
|
if (job != null && job.Active && surface != null && surface.Active)
|
|||
|
|
{
|
|||
|
|
var loadJobs = LoadResult(jobName, surfaceName);
|
|||
|
|
|
|||
|
|
loadJobs.ForEach(x => list.Add(x));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private List<ViewFeLog> LoadResult(string jobName, string surfaceName)
|
|||
|
|
{
|
|||
|
|
var job = Self.Jobs[jobName];
|
|||
|
|
|
|||
|
|
var resultName = job.ResultsFileName; // 分析结果文件名
|
|||
|
|
|
|||
|
|
if (resultName.IsNullOrEmptyOrWhiteSpace())
|
|||
|
|
return null;
|
|||
|
|
|
|||
|
|
var list = new List<ViewFeLog>();
|
|||
|
|
|
|||
|
|
// 1. 分析结果文件
|
|||
|
|
if(!_self.AllResults.ContainsResult(resultName))
|
|||
|
|
{
|
|||
|
|
FeResults results = FrdFileReader.Read(resultName);
|
|||
|
|
|
|||
|
|
_self.AllResults.Add(resultName, results);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
FeResults fr = _self.AllResults.GetResult(resultName);
|
|||
|
|
|
|||
|
|
// 2. 对应的曲面集
|
|||
|
|
FeSurface surface = Self.GetSurface(surfaceName);
|
|||
|
|
|
|||
|
|
var nodeSet = Self.GetNodeSet(surface.NodeSetName); // 该曲面集对应的内部节点集合
|
|||
|
|
|
|||
|
|
int[] labels = nodeSet.Labels; // 对应的节点
|
|||
|
|
|
|||
|
|
// 3. 物理场
|
|||
|
|
var allFieldData = fr.GetAllFieldData();
|
|||
|
|
|
|||
|
|
// 3.1 位移场
|
|||
|
|
Field disp = fr.GetField(allFieldData[0]);
|
|||
|
|
|
|||
|
|
var allValues = disp.GetComponentValues("ALL");
|
|||
|
|
var uValues = disp.GetComponentValues("U1");
|
|||
|
|
var vValues = disp.GetComponentValues("U2");
|
|||
|
|
var wValues = disp.GetComponentValues("U3");
|
|||
|
|
|
|||
|
|
foreach (var id in labels)
|
|||
|
|
{
|
|||
|
|
var node = Self.GetNode(id);
|
|||
|
|
int index = id - 1;
|
|||
|
|
|
|||
|
|
list.Add(new ViewFeLog(
|
|||
|
|
jobName, // 作业名称
|
|||
|
|
id, node.X, node.Y, node.Z, // 节点Id, x, y, z
|
|||
|
|
allValues[index], // 位移All, u, v, w
|
|||
|
|
uValues[index],
|
|||
|
|
vValues[index],
|
|||
|
|
wValues[index])
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return list;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void FrmAnalysisResult_Load(object sender, System.EventArgs e)
|
|||
|
|
{
|
|||
|
|
dataGridView1.Columns.Clear();
|
|||
|
|
dataGridView1.DataSource = new BindingList<ViewFeLog>();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void toolStripComboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (toolStripComboBox1.SelectedIndex >= 0)
|
|||
|
|
{
|
|||
|
|
toolStripTextBox1.Text = _data[toolStripComboBox1.SelectedItem as string];
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
toolStripTextBox1.Text = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|