/// <summary> /// In a partitioned model, return the tags of the partition(s) to which the /// entity belongs. /// </summary> public static int[] GetPartitions(int dim, int tag) { unsafe { int *partitions_ptr; long partitions_n = default; Gmsh_Warp.GmshModelGetPartitions(dim, tag, &partitions_ptr, ref partitions_n, ref Gmsh._staticreff); var partitions = UnsafeHelp.ToIntArray(partitions_ptr, partitions_n); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); return(partitions); } }
/// <summary> /// Evaluate the derivative of the parametrization of the entity of dimension /// `dim' and tag `tag' at the parametric coordinates `parametricCoord'. Only /// valid for `dim' equal to 1 (with `parametricCoord' containing parametric /// coordinates on the curve) or 2 (with `parametricCoord' containing pairs of /// u, v parametric coordinates on the surface, concatenated: [p1u, p1v, p2u, /// ...]). For `dim' equal to 1 return the x, y, z components of the derivative /// with respect to u [d1ux, d1uy, d1uz, d2ux, ...]; for `dim' equal to 2 return /// the x, y, z components of the derivate with respect to u and v: [d1ux, d1uy, /// d1uz, d1vx, d1vy, d1vz, d2ux, ...]. /// </summary> public static double[] GetDerivative(int dim, int tag, double[] parametricCoord) { unsafe { double *ptr; long outcount = 0; Gmsh_Warp.GmshModelGetDerivative(dim, tag, parametricCoord, parametricCoord.LongLength, &ptr, ref outcount, ref Gmsh._staticreff); var derivatives = UnsafeHelp.ToDoubleArray(ptr, outcount); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); return(derivatives); } }
/// <summary> /// List the names of all models. /// </summary> public static string[] List() { unsafe { byte **names_ptr; long name_n = 0; Gmsh_Warp.GmshModelList(&names_ptr, ref name_n, ref Gmsh._staticreff); var names = UnsafeHelp.ToString(names_ptr, name_n); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); return(names); } }
/// <summary> /// Get the model entities in the bounding box defined by the two points /// (`xmin', `ymin', `zmin') and (`xmax', `ymax', `zmax'). If `dim' is >= 0, /// return only the entities of the specified dimension (e.g. points if `dim' == /// 0). /// </summary> public static ValueTuple <int, int>[] GetEntitiesInBoundingBox(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax, int dim = -1) { unsafe { int *tags_ptr; long tags_n = 0; Gmsh_Warp.GmshModelGetEntitiesInBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax, &tags_ptr, ref tags_n, dim, ref Gmsh._staticreff); var pairs = UnsafeHelp.ToIntArray(tags_ptr, tags_n); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); return(pairs.ToIntPair()); } }
/// <summary> /// Get the tags of the physical groups (if any) to which the model entity of /// dimension `dim' and tag `tag' belongs. /// </summary> public static int[] GetPhysicalGroupsForEntity(int dim, int tag) { unsafe { int *physicalTagsptr; long physicalTags_n = default; Gmsh_Warp.GmshModelGetPhysicalGroupsForEntity(dim, tag, &physicalTagsptr, ref physicalTags_n, ref Gmsh._staticreff); var physicalTags = UnsafeHelp.ToIntArray(physicalTagsptr, physicalTags_n); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); return(physicalTags); } }
/// <summary> /// Get all the physical groups in the current model. If `dim' is >= 0, return /// only the entities of the specified dimension (e.g. physical points if `dim' /// == 0). The entities are returned as a vector of (dim, tag) integer pairs. /// </summary> public static ValueTuple <int, int>[] GetPhysicalGroups(int dim = -1) { unsafe { int *dimTags_ptr; long dimTags_n = 0; Gmsh_Warp.GmshModelGetPhysicalGroups(&dimTags_ptr, ref dimTags_n, dim, ref Gmsh._staticreff); var array = UnsafeHelp.ToIntArray(dimTags_ptr, dimTags_n); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); return(array.ToIntPair()); } }
/// <summary> /// Add a string to a list-based post-processing view with tag `tag'. If `coord' /// contains 3 coordinates the string is positioned in the 3D model space ("3D /// string"); if it contains 2 coordinates it is positioned in the 2D graphics /// viewport ("2D string"). `data' contains one or more (for multistep views) /// strings. `style' contains key-value pairs of styling parameters, /// concatenated. Available keys are "Font" (possible values: "Times-Roman", /// "Times-Bold", "Times-Italic", "Times-BoldItalic", "Helvetica", "Helvetica- /// Bold", "Helvetica-Oblique", "Helvetica-BoldOblique", "Courier", "Courier- /// Bold", "Courier-Oblique", "Courier-BoldOblique", "Symbol", "ZapfDingbats", /// "Screen"), "FontSize" and "Align" (possible values: "Left" or "BottomLeft", /// "Center" or "BottomCenter", "Right" or "BottomRight", "TopLeft", /// "TopCenter", "TopRight", "CenterLeft", "CenterCenter", "CenterRight"). /// </summary> public static void AddListDataString(int tag, double[] coord, string[] data, string[] style = default) { unsafe { byte *dataptr = (byte *)Marshal.UnsafeAddrOfPinnedArrayElement(data, 0); if (style == default) { style = new string[0]; } byte *styleptr = (byte *)Marshal.UnsafeAddrOfPinnedArrayElement(style, 0); Gmsh_Warp.GmshViewAddListDataString(tag, coord, coord.LongLength, &dataptr, data.LongLength, &styleptr, style.LongLength, ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); } }
/// <summary> /// Copy the entities `dimTags'; the new entities are returned in /// `outDimTags'. /// </summary> public static void Copy(ValueTuple <int, int>[] dimTags, out ValueTuple <int, int>[] outDimTags) { long outcount = 0; var list = dimTags.ToIntArray(); unsafe { int *ptrss; Gmsh_Warp.GmshModelGeoCopy(list, list.LongLength, &ptrss, ref outcount, ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); var outDimTagsint = UnsafeHelp.ToIntArray(ptrss, outcount); outDimTags = outDimTagsint.ToIntPair(); } }
/// <summary> /// Get the points `closestCoord' on the entity of dimension `dim' and tag `tag' /// to the points `coord', by orthogonal projection. `coord' and `closestCoord' /// are given as triplets of x, y, z coordinates, concatenated: [p1x, p1y, p1z, /// p2x, ...]. `parametricCoord' returns the parametric coordinates t on the /// curve (if `dim' = 1) or pairs of u and v coordinates concatenated on the /// surface (if `dim' = 2), i.e. [p1t, p2t, ...] or [p1u, p1v, p2u, ...]. /// </summary> public static void GetClosestPoint(int dim, int tag, double[] coord, out double[] closestCoord, out double[] parametricCoord) { unsafe { double *closestCoord_ptr; long closestCoord_n = 0; double *parametricCoord_ptr; long parametricCoord_n = 0; Gmsh_Warp.GmshModelGetClosestPoint(dim, tag, coord, coord.LongLength, &closestCoord_ptr, ref closestCoord_n, ¶metricCoord_ptr, ref parametricCoord_n, ref Gmsh._staticreff); closestCoord = UnsafeHelp.ToDoubleArray(closestCoord_ptr, closestCoord_n); parametricCoord = UnsafeHelp.ToDoubleArray(parametricCoord_ptr, parametricCoord_n); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); } }
/// <summary> /// Get the `min' and `max' bounds of the parametric coordinates for the entity /// of dimension `dim' and tag `tag'. /// </summary> public static void GetParametrizationBounds(int dim, int tag, out double[] min, out double[] max) { unsafe { double *min_ptr; long min_n = 0; double *max_ptr; long max_n = 0; Gmsh_Warp.GmshModelGetParametrizationBounds(dim, tag, &min_ptr, ref min_n, &max_ptr, ref max_n, ref Gmsh._staticreff); min = UnsafeHelp.ToDoubleArray(min_ptr, min_n); max = UnsafeHelp.ToDoubleArray(max_ptr, max_n); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); } }
/// <summary> /// Get the boundary of the model entities `dimTags'. Return in `outDimTags' the /// boundary of the individual entities (if `combined' is false) or the boundary /// of the combined geometrical shape formed by all input entities (if /// `combined' is true). Return tags multiplied by the sign of the boundary /// entity if `oriented' is true. Apply the boundary operator recursively down /// to dimension 0 (i.e. to points) if `recursive' is true. /// </summary> public static ValueTuple <int, int>[] GetBoundary(ValueTuple <int, int>[] dimTags, bool combined = true, bool oriented = true, bool recursive = false) { unsafe { int *outDimTagsptr; long outdimTags_n = 0; var dimarray = dimTags.ToIntArray(); Gmsh_Warp.GmshModelGetBoundary(dimarray, dimarray.LongLength, &outDimTagsptr, ref outdimTags_n, Convert.ToInt32(combined), Convert.ToInt32(oriented), Convert.ToInt32(recursive), ref Gmsh._staticreff); var array = UnsafeHelp.ToIntArray(outDimTagsptr, outdimTags_n); var outDimTags = array.ToIntPair(); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); return(outDimTags); } }
/// <summary> /// Get list-based post-processing data strings (2D strings if `dim' = 2, 3D /// strings if `dim' = 3) from the view with tag `tag'. Return the coordinates /// in `coord', the strings in `data' and the styles in `style'. /// </summary> public static void GetListDataStrings(int tag, int dim, out double[] coord, out string[] data, out string[] style) { unsafe { double *coord_ptr; long coord_n = 0; byte ** data_ptr; long data_n = 0; byte ** style_ptr; long style_n = 0; Gmsh_Warp.GmshViewGetListDataStrings(tag, dim, &coord_ptr, ref coord_n, &data_ptr, ref data_n, &style_ptr, ref style_n, ref Gmsh._staticreff); coord = UnsafeHelp.ToDoubleArray(coord_ptr, coord_n); data = UnsafeHelp.ToString(data_ptr, data_n); style = UnsafeHelp.ToString(style_ptr, style_n); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); } }
/// <summary> /// Add homogeneous model-based post-processing data to the view with tag `tag'. /// The arguments have the same meaning as in `addModelData', except that `data' /// is supposed to be homogeneous and is thus flattened in a single vector. For /// data types that can lead to different data sizes per tag (like /// "ElementNodeData"), the data should be padded. /// </summary> public static void GetListData(int tag, out string[] dataType, out int[] numElements, out double[][] data) { unsafe { byte ** dataType_ptr; long dataType_n = 0; int * numElements_ptr; long numElements_n = 0; double **data_ptr; long * data_n_ptr; long data_nn = 0; Gmsh_Warp.GmshViewGetListData(tag, &dataType_ptr, ref dataType_n, &numElements_ptr, ref numElements_n, &data_ptr, &data_n_ptr, ref data_nn, ref Gmsh._staticreff); dataType = UnsafeHelp.ToString(dataType_ptr, dataType_n); numElements = UnsafeHelp.ToIntArray(numElements_ptr, numElements_n); data = UnsafeHelp.ToDoubleArray(data_ptr, data_n_ptr, data_nn); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); } }
/// <summary> /// Add homogeneous model-based post-processing data to the view with tag `tag'. /// The arguments have the same meaning as in `addModelData', except that `data' /// is supposed to be homogeneous and is thus flattened in a single vector. For /// data types that can lead to different data sizes per tag (like /// "ElementNodeData"), the data should be padded. /// </summary> public static void GetModelData(int tag, int step, out string dataType, out long[] tags, out double[][] data, out double time, out int numComponents) { unsafe { byte * dataType_ptr; long * tags_ptr; long tags_n = 0; double **data_ptr; long * data_n_ptr; long data_nn = 0; time = 0; numComponents = 0; Gmsh_Warp.GmshViewGetModelData(tag, step, &dataType_ptr, &tags_ptr, ref tags_n, &data_ptr, &data_n_ptr, ref data_nn, ref time, ref numComponents, ref Gmsh._staticreff); dataType = UnsafeHelp.ToString(dataType_ptr); tags = UnsafeHelp.ToLongArray(tags_ptr, tags_n); data = UnsafeHelp.ToDoubleArray(data_ptr, data_n_ptr, data_nn); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); } }
/// <summary> /// Extrude the model entities `dimTags' by a combined translation and /// rotation of `angle' radians, along (`dx', `dy', `dz') and around the axis /// of revolution defined by the point (`x', `y', `z') and the direction /// (`ax', `ay', `az'). The angle should be strictly smaller than Pi. Return /// extruded entities in `outDimTags'. If `numElements' is not empty, also /// extrude the mesh: the entries in `numElements' give the number of elements /// in each layer. If `height' is not empty, it provides the (cumulative) /// height of the different layers, normalized to 1. /// </summary> public static void Twist(ValueTuple <int, int>[] dimTags, double x, double y, double z, double dx, double dy, double dz, double ax, double ay, double az, double angle, out ValueTuple <int, int>[] outDimTags, int[] numElements = default, double[] heights = default, bool recombine = false) { var dimarray = dimTags.ToIntArray(); unsafe { int *ptrss; long outcount = 0; if (numElements == default) { numElements = new int[0]; } if (heights == default) { heights = new double[0]; } Gmsh_Warp.GmshModelGeoTwist(dimarray, dimarray.LongLength, x, y, z, dx, dy, dz, ax, ay, az, angle, &ptrss, ref outcount, numElements, numElements.LongLength, heights, heights.LongLength, Convert.ToInt32(recombine), ref Gmsh._staticreff); var array = UnsafeHelp.ToIntArray(ptrss, outcount); outDimTags = array.ToIntPair(); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); } }
/// <summary> /// Probe the view `tag' for its `value' at point (`x', `y', `z'). Return only /// the value at step `step' is `step' is positive. Return only values with /// `numComp' if `numComp' is positive. Return the gradient of the `value' if /// `gradient' is set. Probes with a geometrical tolerance (in the reference /// unit cube) of `tolerance' if `tolerance' is not zero. Return the result from /// the element described by its coordinates if `xElementCoord', `yElementCoord' /// and `zElementCoord' are provided. /// </summary> public static double[] Probe(int tag, double x, double y, double z, int step = -1, int numComp = -1, bool gradient = false, double tolerance = 0, double[] xElemCoord = default, double[] yElemCoord = default, double[] zElemCoord = default) { unsafe { double *value_ptr; long value_n = 0; if (xElemCoord == default) { xElemCoord = new double[0]; } if (yElemCoord == default) { yElemCoord = new double[0]; } if (zElemCoord == default) { zElemCoord = new double[0]; } Gmsh_Warp.GmshViewProbe(tag, x, y, z, &value_ptr, ref value_n, step, numComp, Convert.ToInt32(gradient), tolerance, xElemCoord, xElemCoord.LongLength, yElemCoord, yElemCoord.LongLength, zElemCoord, zElemCoord.LongLength, ref Gmsh._staticreff); var value = UnsafeHelp.ToDoubleArray(value_ptr, value_n); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); return(value); } }
/// <summary> /// Set a smoothing meshing constraint on the model entity of dimension /// `dim' and tag `tag'. `val' iterations of a Laplace smoother are applied. /// </summary> public static void SetSmoothing(int dim, int tag, int val) { Gmsh_Warp.GmshModelGeoMeshSetSmoothing(dim, tag, val, ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); }
/// <summary> /// Set a transfinite meshing constraint on the curve `tag', with `numNodes' /// nodes distributed according to `meshType' and `coef'. Currently /// supported types are "Progression" (geometrical progression with power /// `coef') and "Bump" (refinement toward both extremities of the curve). /// </summary> public static void SetTransfiniteCurve(int tag, int nPoints, string meshType = "Progression", double coef = 1) { Gmsh_Warp.GmshModelGeoMeshSetTransfiniteCurve(tag, nPoints, meshType, coef, ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); }
/// <summary> /// Set a recombination meshing constraint on the model entity of dimension /// `dim' and tag `tag'. Currently only entities of dimension 2 (to /// recombine triangles into quadrangles) are supported. /// </summary> public static void SetRecombine(int dim, int tag, double angle = 45) { Gmsh_Warp.GmshModelGeoMeshSetRecombine(dim, tag, angle, ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); }
/// <summary> /// Set the field `tag' as a boundary layer size field. /// </summary> public static void SetAsBoundaryLayer(int tag) { Gmsh_Warp.GmshModelMeshFieldSetAsBoundaryLayer(tag, ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); }
/// <summary> /// Set a reverse meshing constraint on the model entity of dimension `dim' /// and tag `tag'. If `val' is true, the mesh orientation will be reversed /// with respect to the natural mesh orientation (i.e. the orientation /// consistent with the orientation of the geometry). If `val' is false, the /// mesh is left as-is. /// </summary> public static void SetReverse(int dim, int tag, bool val = true) { Gmsh_Warp.GmshModelGeoMeshSetReverse(dim, tag, Convert.ToInt32(val), ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); }
/// <summary> /// Set the numerical list option `option' to value `value' for field `tag'. /// </summary> public static void SetNumbers(int tag, string option, double[] value) { Gmsh_Warp.GmshModelMeshFieldSetNumbers(tag, option, value, value.LongLength, ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); }
/// <summary> /// Set the string option `option' to value `value' for field `tag'. /// </summary> public static void SetString(int tag, string option, string value) { Gmsh_Warp.GmshModelMeshFieldSetString(tag, option, value, ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); }
/// <summary> /// Remove the field with tag `tag'. /// </summary> public static void Remove(int tag) { Gmsh_Warp.GmshModelMeshFieldRemove(tag, ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); }
/// <summary> /// Run the event loop of the graphical user interface, i.e. repeatedly call /// `wait()'. First automatically create the user interface if it has not yet /// been initialized. Can only be called in the main thread. /// </summary> public static void Run() { Gmsh_Warp.GmshFltkRun(ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); }
/// <summary> /// Set the maximum tag `maxTag' for entities of dimension `dim' in the built- /// in CAD representation. /// </summary> public static void SetMaxTag(int dim, int maxTag) { Gmsh_Warp.GmshModelGeoSetMaxTag(dim, maxTag, ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); }
/// <summary> /// Remove all duplicate entities (different entities at the same geometrical /// location). /// </summary> public static void RemoveAllDuplicates() { Gmsh_Warp.GmshModelGeoRemoveAllDuplicates(ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); }
/// <summary> /// Wait at most `time' seconds for user interface events and return. If `time' /// < 0, wait indefinitely. First automatically create the user interface if it /// has not yet been initialized. Can only be called in the main thread. /// </summary> public static void Wait(double time = -1) { Gmsh_Warp.GmshFltkWait(time, ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); }
/// <summary> /// Synchronize the built-in CAD representation with the current Gmsh model. /// This can be called at any time, but since it involves a non trivial amount /// of processing, the number of synchronization points should normally be /// minimized. /// </summary> public static void Synchronize() { Gmsh_Warp.GmshModelGeoSynchronize(ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); }
/// <summary> /// Awake the main user interface thread and process pending events, and /// optionally perform an action (currently the only `action' allowed is /// "update"). /// </summary> public static void Awake(string action = "") { Gmsh_Warp.GmshFltkAwake(action, ref Gmsh._staticreff); Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle); }