private void ParsePatch(ParseTreeNode node, BoundaryPatch s) { foreach (ParseTreeNode rootEntryNode in node.FindDictEntries(null)) { var identifier = rootEntryNode.GetEntryIdentifier(); switch (identifier) { case "type": s.PatchType = rootEntryNode.GetBasicValEnum <PatchType>(); break; case "rho": s.Rho = rootEntryNode.GetBasicValString(); break; case "gradient": s.GradientFieldType = GetFieldType(rootEntryNode); s.GradientValue = GetFieldValue(rootEntryNode.ChildNodes[2].ChildNodes[0]); break; case "value": s.ValueFieldType = GetFieldType(rootEntryNode); s.ValueValue = GetFieldValue(rootEntryNode.ChildNodes[2].ChildNodes[0]); break; } } }
private void ParsePatches(ParseTreeNode node, FieldData rawData) { foreach (ParseTreeNode rootEntryNode in node.FindDictEntries(null)) { var s = new BoundaryPatch(); s.Name = rootEntryNode.GetEntryIdentifier(); rawData.Patches.Add(s); ParsePatch(rootEntryNode.ChildNodes[2], s); } }
public Action GetSaveCommand() { return () => { var path = _fileHandler.GetPath(_vProject.ProjectDir); var d = (Offwind.Sowfa.Time.FieldData.FieldData) _fileHandler.Read(path); d.InternalFieldType = _model.InternalFieldType; if (d.FieldClass == FieldClass.volScalarField) { d.InternalFieldValue = new decimal[1]; d.InternalFieldValue[0] = _model.InternalFieldValue1; } else if (d.FieldClass == FieldClass.volVectorField) { d.InternalFieldValue = new decimal[3]; d.InternalFieldValue[0] = _model.InternalFieldValue1; d.InternalFieldValue[1] = _model.InternalFieldValue2; d.InternalFieldValue[2] = _model.InternalFieldValue3; } d.Patches.Clear(); foreach (var vp in _model.Patches) { var p = new BoundaryPatch(); p.Name = vp.Name; p.PatchType = vp.PatchType; p.Rho = vp.Rho; p.GradientFieldType = vp.GradientFieldType; p.ValueFieldType = vp.ValueFieldType; if (d.FieldClass == FieldClass.volScalarField) { p.GradientValue = new decimal[1]; p.GradientValue[0] = vp.GradientValue1; p.ValueValue = new decimal[1]; p.ValueValue[0] = vp.ValueValue1; } else if (d.FieldClass == FieldClass.volVectorField) { p.GradientValue = new decimal[3]; p.GradientValue[0] = vp.GradientValue1; p.GradientValue[1] = vp.GradientValue2; p.GradientValue[2] = vp.GradientValue3; p.ValueValue = new decimal[3]; p.ValueValue[0] = vp.ValueValue1; p.ValueValue[1] = vp.ValueValue2; p.ValueValue[2] = vp.ValueValue3; } d.Patches.Add(p); } _fileHandler.Write(path, d); _model.AcceptChanges(); }; }
private void ParsePatch(ParseTreeNode node, BoundaryPatch s) { foreach (ParseTreeNode rootEntryNode in node.FindDictEntries(null)) { var identifier = rootEntryNode.GetEntryIdentifier(); switch (identifier) { case "type": s.PatchType = rootEntryNode.GetBasicValEnum<PatchType>(); break; case "rho": s.Rho = rootEntryNode.GetBasicValString(); break; case "gradient": s.GradientFieldType = GetFieldType(rootEntryNode); s.GradientValue = GetFieldValue(rootEntryNode.ChildNodes[2].ChildNodes[0]); break; case "value": s.ValueFieldType = GetFieldType(rootEntryNode); s.ValueValue = GetFieldValue(rootEntryNode.ChildNodes[2].ChildNodes[0]); break; } } }