/// <summary> /// Create a BoSSS grid from an OpenFOAM mesh /// </summary> /// <param name="_ref"></param> /// <param name="ierr">output, error code; on success, set to 0</param> /// <param name="faces"> /// point labels (indices) of faces, according to OpenFOAM polymesh description (array of arrays) /// </param> /// <param name="vertices_per_face"> /// number of vertices for each face /// </param> /// <param name="nCells"> /// number of cells in OpenFOAM polymesh /// </param> /// <param name="neighbour"> /// Neighbor cell labels for internal faces /// </param> /// <param name="owner"> /// for each face, the owner cell label /// </param> /// <param name="nPoints">number of points/vertices</param> /// <param name="nFaces"> /// number of faces /// </param> /// <param name="nInternalFaces"> /// number of internal faces /// </param> /// <param name="points"> /// point coordinates, array of <paramref name="nPoints"/>*3 /// </param> unsafe public static void CreateGrid(out int _ref, ref int nPoints, ref int nCells, ref int nFaces, ref int nInternalFaces, int **faces, int *vertices_per_face, int *neighbour, int *owner, double *points, out int ierr) { try { // copy data (unmanaged to managed) int[][] _faces = new int[nFaces][]; int[] _neighbour = new int[nInternalFaces]; int[] _owner = new int[nFaces]; double[,] _points = new double[nPoints, 3]; for (int i = 0; i < nFaces; i++) { int N = vertices_per_face[i]; _faces[i] = new int[N]; for (int n = 0; n < N; n++) { _faces[i][n] = faces[i][n]; } } for (int i = 0; i < nInternalFaces; i++) { _neighbour[i] = neighbour[i]; } for (int i = 0; i < nFaces; i++) { _owner[i] = owner[i]; } for (int i = 0; i < nPoints; i++) { _points[i, 0] = points[i * 3 + 0]; _points[i, 0] = points[i * 3 + 1]; _points[i, 0] = points[i * 3 + 2]; } // create BoSSS grid GridData g = FOAMmesh_to_BoSSS(nCells, _faces, _neighbour, _owner, _points); // register object _ref = Infrastructure.RegisterObject(g); ierr = 0; return; } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); _ref = -1; return; } }
public static void New(out int _ref, ref int LocalNumberOfRows, ref int NoOfColumns, ref int _RowsPerBlock, ref int _ColPerBlock, out int ierr) { ierr = 0; try { _ref = Infrastructure.RegisterObject(new MsrMatrix(LocalNumberOfRows, NoOfColumns, _RowsPerBlock, _ColPerBlock)); } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); _ref = -1; } }
public static void SetEntry(ref int _ref, ref int i, ref int j, ref double val, out int ierr) { ierr = 0; try { IMutableMatrix M = (IMutableMatrix)Infrastructure.GetObject(_ref); M[i, j] = val; } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
public static void GetLocLen(ref int _ref, out int LocLen, out int ierr) { ierr = 0; LocLen = -1; try { ISparseMatrix M = (ISparseMatrix)Infrastructure.GetObject(_ref); LocLen = M.RowPartitioning.LocalLength; } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
public static void GetI0(ref int _ref, out int i0, out int ierr) { ierr = 0; i0 = -1; try { ISparseMatrix M = (ISparseMatrix)Infrastructure.GetObject(_ref); i0 = (int)M.RowPartitioning.i0; } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
public static void GetMPIsize(ref int _ref, out int MPIsize, out int ierr) { ierr = 0; MPIsize = -1; try { IPartitioning p = (IPartitioning)Infrastructure.GetObject(_ref); MPIsize = (int)p.MpiSize; } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
public static void GetLocLen(ref int _ref, out int LocLen, out int ierr) { ierr = 0; LocLen = -1; try { IPartitioning p = (IPartitioning)Infrastructure.GetObject(_ref); LocLen = (int)p.LocalLength; } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
public static void GetI0(ref int _ref, out int i0, out int ierr) { ierr = 0; i0 = -1; try { IPartitioning p = (IPartitioning)Infrastructure.GetObject(_ref); i0 = (int)p.i0; } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
public static void GetRowPart(ref int MtxRef, out int PartRef, out int ierr) { ierr = 0; PartRef = -1; try { ISparseMatrix M = (ISparseMatrix)Infrastructure.GetObject(MtxRef); PartRef = Infrastructure.RegisterObject(M.RowPartitioning); } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
unsafe public static void SaveToTextFileSparseF(ref int _ref, byte *termchar, byte *path, out int ierr) { ierr = 0; try { string _path = Infrastructure.FortranToDotNET(path, *termchar); IMutableMatrixEx M = (IMutableMatrixEx)Infrastructure.GetObject(_ref); M.SaveToTextFileSparse(_path); } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
unsafe public static void SaveToTextFileSparse(ref int _ref, byte *path, out int ierr) { ierr = 0; try { string _paht = Marshal.PtrToStringAnsi((IntPtr)path); IMutableMatrixEx M = (IMutableMatrixEx)Infrastructure.GetObject(_ref); //Console.WriteLine("saving: >" + _paht + "<"); M.SaveToTextFileSparse(_paht); } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
/// <summary> /// releases all C# - references on an object, making it ready for garbage-collection. /// </summary> public static void ReleaseObject(ref int _ref, out int ierr) { ierr = 0; try { object o = Infrastructure.GetObject(_ref); if (o is IDisposable) { ((IDisposable)o).Dispose(); } Infrastructure.ForgetObject(_ref); } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } }
unsafe public static void Laplacian(ref int GridRef, ref int DgDegree, out int ierr) { try { // grid, etc // ========= GridData grd = null;// (GridData)(Infrastructure.GetObject(GridRef)); var b = new Basis(grd, DgDegree); var map = new UnsetteledCoordinateMapping(b); var L = new Laplace(1.3, grd.Cells.cj); var op = new SpatialOperator(1, 0, 1, QuadOrderFunc.Linear(), "T", "c1"); op.EquationComponents["c1"].Add(L); op.Commit(); // evaluate operator // ================= var Mtx = new BlockMsrMatrix(map, map); double[] B = new double[map.LocalLength]; var eval = op.GetMatrixBuilder(map, null, map); eval.ComputeMatrix(Mtx, B); // return data // =========== throw new NotImplementedException("todo"); } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } ierr = 0; }