private void CalcMatrixs() { int nodeCnt = (int)World.GetPortNodeCount(QuantityId, PortId); IList <uint> feIds = World.GetPortLineFEIds(QuantityId, PortId); Txx = new IvyFEM.Lapack.DoubleMatrix(nodeCnt, nodeCnt); Ryy = new IvyFEM.Lapack.DoubleMatrix(nodeCnt, nodeCnt); Uzz = new IvyFEM.Lapack.DoubleMatrix(nodeCnt, nodeCnt); foreach (uint feId in feIds) { LineFE lineFE = World.GetLineFE(QuantityId, feId); uint elemNodeCnt = lineFE.NodeCount; int[] nodes = new int[elemNodeCnt]; for (int iNode = 0; iNode < elemNodeCnt; iNode++) { int coId = lineFE.NodeCoordIds[iNode]; int nodeId = World.PortCoord2Node(QuantityId, PortId, coId); nodes[iNode] = nodeId; } Material ma0 = World.GetMaterial(lineFE.MaterialId); System.Diagnostics.Debug.Assert(ma0 is DielectricMaterial); var ma = ma0 as DielectricMaterial; double[,] sNN = lineFE.CalcSNN(); double[,] sNyNy = lineFE.CalcSNxNx(); for (int row = 0; row < elemNodeCnt; row++) { int rowNodeId = nodes[row]; if (rowNodeId == -1) { continue; } for (int col = 0; col < elemNodeCnt; col++) { int colNodeId = nodes[col]; if (colNodeId == -1) { continue; } double txxVal = (1.0 / ma.Muxx) * sNyNy[row, col]; double ryyVal = (1.0 / ma.Muyy) * sNN[row, col]; double uzzVal = ma.Epzz * sNN[row, col]; Txx[rowNodeId, colNodeId] += txxVal; Ryy[rowNodeId, colNodeId] += ryyVal; Uzz[rowNodeId, colNodeId] += uzzVal; } } } }
private void SetABC(IvyFEM.Linear.ComplexSparseMatrix A, System.Numerics.Complex[] B) { uint quantityId = 0; if (World.GetPortCount(quantityId) == 0) { return; } System.Diagnostics.Debug.Assert(World.GetPortCount(quantityId) == 1); IList <PortCondition> portConditions = World.GetPortConditions(quantityId); PortCondition portCondition = portConditions[0]; IList <uint> abcEIds = portCondition.EIds; IList <uint> feIds = World.GetLineFEIds(quantityId); foreach (uint feId in feIds) { LineFE lineFE = World.GetLineFE(quantityId, feId); uint meshId = lineFE.MeshId; //int meshElemId = lineFE.MeshElemId; uint eId; { uint elemCount; MeshType meshType; int loc; uint cadId; World.Mesh.GetMeshInfo(meshId, out elemCount, out meshType, out loc, out cadId); System.Diagnostics.Debug.Assert(meshType == MeshType.Bar); eId = cadId; } if (abcEIds.Contains(eId)) { // ABCを適用する辺 } else { continue; } // ABC uint elemNodeCnt = lineFE.NodeCount; int[] coIds = lineFE.NodeCoordIds; int[] nodes = new int[elemNodeCnt]; for (int iNode = 0; iNode < elemNodeCnt; iNode++) { int coId = coIds[iNode]; nodes[iNode] = World.Coord2Node(quantityId, coId); } Material ma0 = World.GetMaterial(lineFE.MaterialId); System.Diagnostics.Debug.Assert(ma0 is HelmholtzMaterial); var ma = ma0 as HelmholtzMaterial; double v = ma.Velocity; //System.Numerics.Complex f = ma.F; double omega = 2.0 * Math.PI * Frequency; double k = omega / v; double[,] sNN = lineFE.CalcSNN(); double[,] sNxNx = lineFE.CalcSNxNx(); for (int row = 0; row < elemNodeCnt; row++) { int rowNodeId = nodes[row]; if (rowNodeId == -1) { continue; } for (int col = 0; col < elemNodeCnt; col++) { int colNodeId = nodes[col]; if (colNodeId == -1) { continue; } System.Numerics.Complex a = System.Numerics.Complex.ImaginaryOne * k * sNN[row, col] - System.Numerics.Complex.ImaginaryOne / (2.0 * k) * sNxNx[row, col]; A[rowNodeId, colNodeId] += a; } } } }