public void SetColors(uint bubbleValueId, FieldDerivativeType dt, FEWorld world, IColorMap colorMap) { FieldValue fv = world.GetFieldValue(bubbleValueId); System.Diagnostics.Debug.Assert(fv.IsBubble == true); uint quantityId = fv.QuantityId; var mesh = world.Mesh; MeshType meshType; int[] vertexs; mesh.GetConnectivity(MeshId, out meshType, out vertexs); if (Type == ElementType.Tri) { Colors = new float[ElemCount * 3]; for (int iTri = 0; iTri < ElemCount; iTri++) { // Bubble uint feId = world.GetTriangleFEIdFromMesh(quantityId, MeshId, (uint)iTri); System.Diagnostics.Debug.Assert(feId != 0); double value = fv.GetShowValue((int)(feId - 1), 0, dt); var color = colorMap.GetColor(value); for (int iColor = 0; iColor < 3; iColor++) { Colors[iTri * 3 + iColor] = (float)color[iColor]; } } } else if (Type == ElementType.Quad) { // TRIと同じでよいが要素IDを取得するメソッドが現状ない throw new NotImplementedException(); } }
private void UpdateSymmetricTensor2(uint valueId, FieldDerivativeType dt, FEWorld world) { ValueDof = 6; FieldValue fv = world.GetFieldValue(valueId); uint quantityId = fv.QuantityId; uint dof = fv.Dof; System.Diagnostics.Debug.Assert(fv.IsBubble == true); var mesh = world.Mesh; MeshType meshType; int[] vertexs; mesh.GetConnectivity(MeshId, out meshType, out vertexs); if (Type == ElementType.Tri) { Values = new double[ElemCount * ValueDof]; for (int iTri = 0; iTri < ElemCount; iTri++) { // Bubble uint feId = world.GetTriangleFEIdFromMesh(quantityId, MeshId, (uint)iTri); System.Diagnostics.Debug.Assert(feId != 0); double[] sigma = new double[dof]; for (int iDof = 0; iDof < dof; iDof++) { sigma[iDof] = fv.GetShowValue((int)(feId - 1), iDof, dt); } double[] vecs; double ls; double[] vecl; double ll; GetPrincipalStressVectorForSymmetricTensor2(sigma, out vecs, out ls, out vecl, out ll); Values[iTri * ValueDof + 0] = vecs[0]; Values[iTri * ValueDof + 1] = vecs[1]; Values[iTri * ValueDof + 2] = ls; Values[iTri * ValueDof + 3] = vecl[0]; Values[iTri * ValueDof + 4] = vecl[1]; Values[iTri * ValueDof + 5] = ll; } } else if (Type == ElementType.Quad) { // TRIと同じでよいが要素IDを取得するメソッドが現状ない throw new NotImplementedException(); } }
private void UpdateVector(uint valueId, FieldDerivativeType dt, FEWorld world) { ValueDof = 2; FieldValue fv = world.GetFieldValue(valueId); uint quantityId = fv.QuantityId; uint dof = fv.Dof; System.Diagnostics.Debug.Assert(fv.IsBubble == true); var mesh = world.Mesh; MeshType meshType; int[] vertexs; mesh.GetConnectivity(MeshId, out meshType, out vertexs); if (Type == ElementType.Tri) { Values = new double[ElemCount * ValueDof]; for (int iTri = 0; iTri < ElemCount; iTri++) { // Bubble uint feId = world.GetTriangleFEIdFromMesh(quantityId, MeshId, (uint)iTri); System.Diagnostics.Debug.Assert(feId != 0); System.Diagnostics.Debug.Assert(dof >= ValueDof); for (int iDof = 0; iDof < ValueDof; iDof++) { double u = fv.GetShowValue((int)(feId - 1), iDof, dt); Values[iTri * ValueDof + iDof] = u; } } } else if (Type == ElementType.Quad) { // TRIと同じでよいが要素IDを取得するメソッドが現状ない throw new NotImplementedException(); } }
public void Update(FEWorld world) { FieldValue fv = world.GetFieldValue(ValueId); uint quantityId = fv.QuantityId; uint dim = world.Dimension; uint ptCnt = 0; if (IsNsvDraw) { ptCnt = fv.GetPointCount(); // あとで実装する throw new NotImplementedException(); } else { ptCnt = world.GetCoordCount(quantityId); } System.Diagnostics.Debug.Assert(VertexArray.PointCount == ptCnt); if (!IsntDisplacementValue) { // 変位を伴う場合 if (dim == 2 && (fv.Type == FieldValueType.Scalar || fv.Type == FieldValueType.ZScalar)) { // 垂直方向の変位として捉える System.Diagnostics.Debug.Assert(VertexArray.Dimension == 3); for (int coId = 0; coId < ptCnt; coId++) { double[] coord = world.GetCoord(quantityId, coId); FieldDerivativeType dt = ValueDt; double value = fv.GetShowValue(coId, 0, dt); VertexArray.VertexCoordArray[coId * 3 + 0] = coord[0]; VertexArray.VertexCoordArray[coId * 3 + 1] = coord[1]; VertexArray.VertexCoordArray[coId * 3 + 2] = value; } } else { System.Diagnostics.Debug.Assert(VertexArray.Dimension == dim); for (int coId = 0; coId < ptCnt; coId++) { double[] coord = world.GetCoord(quantityId, coId); FieldDerivativeType dt = ValueDt; for (int iDim = 0; iDim < dim; iDim++) { double value = fv.GetShowValue(coId, iDim, dt); VertexArray.VertexCoordArray[coId * dim + iDim] = coord[iDim] + value; } } } } else { System.Diagnostics.Debug.Assert(VertexArray.Dimension == dim); for (int coId = 0; coId < ptCnt; coId++) { double[] coord = world.GetCoord(quantityId, coId); for (int iDim = 0; iDim < dim; iDim++) { VertexArray.VertexCoordArray[coId * dim + iDim] = coord[iDim]; } } } if (world.IsFieldValueId(ColorValueId)) { FieldValue colorfv = world.GetFieldValue(ColorValueId); FieldDerivativeType dt = ColorValueDt; bool isBubble = colorfv.IsBubble; uint colorQuantityId = colorfv.QuantityId; uint colorPtCnt = world.GetCoordCount(colorQuantityId); if (!ColorMap.IsFixedMinMax) { double min; double max; colorfv.GetMinMaxShowValue(out min, out max, 0, dt); ColorMap.MinValue = min; ColorMap.MaxValue = max; } if (!isBubble) { // color is assigned to vertex if (ColorArray == null) { ColorArray = new float[colorPtCnt * 4]; } for (int coId = 0; coId < colorPtCnt; coId++) { double value = colorfv.GetShowValue(coId, 0, dt); double[] color = ColorMap.GetColor(value); ColorArray[coId * 4] = (float)color[0]; ColorArray[coId * 4 + 1] = (float)color[1]; ColorArray[coId * 4 + 2] = (float)color[2]; ColorArray[coId * 4 + 3] = 0.0f; } } else { // color is assigned to face for (int idp = 0; idp < DrawParts.Count; idp++) { FaceFieldDrawPart dp = DrawParts[idp]; dp.SetColors(ColorValueId, dt, world, ColorMap); } } } if (NormalArray != null) { MakeNormal(); } if (UVArray != null) { for (int coId = 0; coId < ptCnt; coId++) { double[] coord = world.GetCoord(quantityId, coId); UVArray[coId * 2 + 0] = coord[0] * TexScale; UVArray[coId * 2 + 1] = coord[1] * TexScale; } } }
public void Update(FEWorld world) { FieldValue fv = world.GetFieldValue(ValueId); uint quantityId = fv.QuantityId; uint dim = world.Dimension; uint ptCnt = LineCount * LinePtCount; uint lineCnt = LineCount; uint drawDim = VertexArray.Dimension; if (IsntDisplacementValue) { System.Diagnostics.Debug.Assert(drawDim == 2); // いまはそうなってる for (int iEdge = 0; iEdge < lineCnt; iEdge++) { LineFE lineFE = LineFEs[iEdge]; for (int iPt = 0; iPt < LinePtCount; iPt++) { int coId = lineFE.NodeCoordIds[iPt]; double[] co = world.GetCoord(quantityId, coId); VertexArray.VertexCoordArray[(iEdge * LinePtCount + iPt) * drawDim + 0] = co[0]; VertexArray.VertexCoordArray[(iEdge * LinePtCount + iPt) * drawDim + 1] = co[1]; } } } else { // 変位を伴う場合 if (dim == 2 && drawDim == 3) { for (int iEdge = 0; iEdge < LineCount; iEdge++) { LineFE lineFE = LineFEs[iEdge]; System.Diagnostics.Debug.Assert(lineFE.NodeCoordIds.Length == LinePtCount); for (int iPt = 0; iPt < LinePtCount; iPt++) { int coId = lineFE.NodeCoordIds[iPt]; double[] coord = world.GetCoord(quantityId, coId); FieldDerivativeType dt = ValueDt; double value = fv.GetShowValue(coId, 0, dt); VertexArray.VertexCoordArray[(iEdge * LinePtCount + iPt) * drawDim + 0] = coord[0]; VertexArray.VertexCoordArray[(iEdge * LinePtCount + iPt) * drawDim + 1] = coord[1]; VertexArray.VertexCoordArray[(iEdge * LinePtCount + iPt) * drawDim + 2] = value; } } } else { for (int iEdge = 0; iEdge < lineCnt; iEdge++) { LineFE lineFE = LineFEs[iEdge]; System.Diagnostics.Debug.Assert(lineFE.NodeCoordIds.Length == LinePtCount); for (int iPt = 0; iPt < LinePtCount; iPt++) { int coId = lineFE.NodeCoordIds[iPt]; double[] coord = world.GetCoord(quantityId, coId); FieldDerivativeType dt = ValueDt; for (int iDim = 0; iDim < drawDim; iDim++) { double value = fv.GetShowValue(coId, iDim, dt); VertexArray.VertexCoordArray[(iEdge * LinePtCount + iPt) * drawDim + iDim] = coord[iDim] + value; } } } } } }