Ejemplo n.º 1
0
 /// <summary>
 /// Evaluate the principal curvatures of the surface with tag `tag' at the
 /// parametric coordinates `parametricCoord', as well as their respective
 /// directions. `parametricCoord' are given by pair of u and v coordinates,
 /// concatenated: [p1u, p1v, p2u, ...].
 /// </summary>
 public static void GetPrincipalCurvatures(int dim, double[] parametricCoord, out double[] curvatureMax, out double[] curvatureMin, out double[] directionMax, out double[] directionMin)
 {
     unsafe
     {
         double *curvatureMax_ptr;
         long    curvatureMax_n = 0;
         double *curvatureMin_ptr;
         long    curvatureMin_n = 0;
         double *directionMax_ptr;
         long    directionMax_n = 0;
         double *directionMin_ptr;
         long    directionMin_n = 0;
         Gmsh_Warp.GmshModelGetPrincipalCurvatures(dim, parametricCoord, parametricCoord.LongLength,
                                                   &curvatureMax_ptr, ref curvatureMax_n,
                                                   &curvatureMin_ptr, ref curvatureMin_n,
                                                   &directionMax_ptr, ref directionMax_n,
                                                   &directionMin_ptr, ref directionMin_n,
                                                   ref Gmsh._staticreff);
         curvatureMax = UnsafeHelp.ToDoubleArray(curvatureMax_ptr, curvatureMax_n);
         curvatureMin = UnsafeHelp.ToDoubleArray(curvatureMin_ptr, curvatureMin_n);
         directionMax = UnsafeHelp.ToDoubleArray(directionMax_ptr, directionMax_n);
         directionMin = UnsafeHelp.ToDoubleArray(directionMin_ptr, directionMin_n);
         Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Get the value of the number parameter `name' from the ONELAB database.
 /// Return an empty vector if the parameter does not exist.
 /// </summary>
 public static double[] GetNumber(string name)
 {
     unsafe
     {
         double *value_ptr;
         long    value_n = 0;
         Gmsh_Warp.GmshOnelabGetNumber(name, &value_ptr, ref value_n, ref Gmsh._staticreff);
         var value = UnsafeHelp.ToDoubleArray(value_ptr, value_n);
         Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
         return(value);
     }
 }
Ejemplo n.º 3
0
            /// <summary>
            /// Reparametrize the boundary entity (point or curve, i.e. with `dim' == 0 or
            /// `dim' == 1) of tag `tag' on the surface `surfaceTag'. If `dim' == 1,
            /// reparametrize all the points corresponding to the parametric coordinates
            /// `parametricCoord'. Multiple matches in case of periodic surfaces can be
            /// selected with `which'. This feature is only available for a subset of
            /// entities, depending on the underyling geometrical representation.
            /// </summary>
            public static void ReparametrizeOnSurface(int dim, int tag, double[] parametricCoord, int surfaceTag, out double[] surfaceParametricCoord, int which = 0)
            {
                unsafe
                {
                    double *surfaceParametricCoord_ptr;
                    long    surfaceParametricCoord_n = 0;

                    Gmsh_Warp.GmshModelReparametrizeOnSurface(dim, tag, parametricCoord, parametricCoord.LongLength, surfaceTag, &surfaceParametricCoord_ptr, ref surfaceParametricCoord_n, which, ref Gmsh._staticreff);
                    surfaceParametricCoord = UnsafeHelp.ToDoubleArray(surfaceParametricCoord_ptr, surfaceParametricCoord_n);
                    Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                }
            }
Ejemplo n.º 4
0
 /// <summary>
 /// Get the parametric coordinates `parametricCoord' for the points `coord' on
 /// the entity of dimension `dim' and tag `tag'. `coord' 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 double[] GetParametrization(int dim, int tag, double[] coord)
 {
     unsafe
     {
         double *ptr;
         long    outcount = 0;
         Gmsh_Warp.GmshModelGetParametrization(dim, tag, coord, coord.LongLength, &ptr, ref outcount, ref Gmsh._staticreff);
         var parametricCoord = UnsafeHelp.ToDoubleArray(ptr, outcount);
         Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
         return(parametricCoord);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Get the normal to the surface with tag `tag' at the parametric coordinates
 /// `parametricCoord'. `parametricCoord' are given by pairs of u and v
 /// coordinates, concatenated: [p1u, p1v, p2u, ...]. `normals' are returned as
 /// triplets of x, y, z components, concatenated: [n1x, n1y, n1z, n2x, ...].
 /// </summary>
 public static double[] GetNormal(int tag, double[] parametricCoord)
 {
     unsafe
     {
         double *ptr;
         long    outcount = 0;
         Gmsh_Warp.GmshModelGetNormal(tag, parametricCoord, parametricCoord.LongLength, &ptr, ref outcount, ref Gmsh._staticreff);
         var normals = UnsafeHelp.ToDoubleArray(ptr, outcount);
         Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
         return(normals);
     }
 }
Ejemplo n.º 6
0
            /// <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, &parametricCoord_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);
                }
            }
Ejemplo n.º 7
0
            /// <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);
                }
            }
Ejemplo n.º 8
0
            /// <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);
                }
            }
Ejemplo n.º 9
0
            /// <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);
                }
            }
Ejemplo n.º 10
0
            /// <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);
                }
            }
Ejemplo n.º 11
0
 /// <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);
     }
 }