Ejemplo n.º 1
0
            /// <summary>
            /// Add a physical group of dimension `dim', grouping the model entities with
            /// tags `tags'. Return the tag of the physical group, equal to `tag' if `tag'
            /// is positive, or a new tag if `tag' < 0.
            /// </summary>
            public static int AddPhysicalGroup(int dim, int[] tags, int tag = -1)
            {
                var index = Gmsh_Warp.GmshModelAddPhysicalGroup(dim, tags, tags.LongLength, tag, ref Gmsh._staticreff);

                Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                return(index);
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Get the geometrical dimension of the current model.
            /// </summary>
            public static int GetDimension()
            {
                var index = Gmsh_Warp.GmshModelGetDimension(ref Gmsh._staticreff);

                Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                return(index);
            }
Ejemplo n.º 3
0
            /// <summary>
            /// Return CPU time.
            /// </summary>
            public static double GetCpuTime()
            {
                var time = Gmsh_Warp.GmshLoggerGetCpuTime(ref Gmsh._staticreff);

                Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                return(time);
            }
Ejemplo n.º 4
0
                    /// <summary>
                    /// Add a new mesh size field of type `fieldType'. If `tag' is positive,
                    /// assign the tag explicitly; otherwise a new tag is assigned
                    /// automatically. Return the field tag.
                    /// </summary>
                    public static int Add(string fieldType, int tag = -1)
                    {
                        var index = Gmsh_Warp.GmshModelMeshFieldAdd(fieldType, tag, ref Gmsh._staticreff);

                        Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                        return(index);
                    }
Ejemplo n.º 5
0
                /// <summary>
                /// Add a cubic b-spline curve with `pointTags' control points. If `tag' is
                /// positive, set the tag explicitly; otherwise a new tag is selected
                /// automatically. Creates a periodic curve if the first and last points are
                /// the same. Return the tag of the b-spline curve.
                /// </summary>
                public static int AddBSpline(int[] pointTags, int tag = -1)
                {
                    var index = Gmsh_Warp.GmshModelGeoAddBSpline(pointTags, pointTags.LongLength, tag, ref Gmsh._staticreff);

                    Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                    return(index);
                }
Ejemplo n.º 6
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.º 7
0
            /// <summary>
            /// Check if the parametric coordinates provided in `parametricCoord' correspond
            /// to points inside the entitiy of dimension `dim' and tag `tag', and return
            /// the number of points inside. This feature is only available for a subset of
            /// curves and surfaces, depending on the underyling geometrical representation.
            /// </summary>
            public static int IsInside(int dim, int tag, double[] parametricCoord)
            {
                var index = Gmsh_Warp.GmshModelIsInside(dim, tag, parametricCoord, parametricCoord.LongLength, ref Gmsh._staticreff);

                Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                return(index);
            }
Ejemplo n.º 8
0
 /// <summary>
 /// In a partitioned model, get the parent of the entity of dimension `dim' and
 /// tag `tag', i.e. from which the entity is a part of, if any. `parentDim' and
 /// `parentTag' are set to -1 if the entity has no parent.
 /// </summary>
 public static void GetParent(int dim, int tag, out int parentDim, out int parentTag)
 {
     parentDim = default;
     parentTag = default;
     Gmsh_Warp.GmshModelGetParent(dim, tag, ref parentDim, ref parentTag, ref Gmsh._staticreff);
     Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
 }
Ejemplo n.º 9
0
                    /// <summary>
                    /// Set a mesh size constraint on the model entities `dimTags'. Currently
                    /// only entities of dimension 0 (points) are handled.
                    /// </summary>
                    public static void SetSize(ValueTuple <int, int>[] dimTags, double size)
                    {
                        var list = dimTags.ToIntArray();

                        Gmsh_Warp.GmshModelGeoMeshSetSize(list, list.LongLength, size, ref Gmsh._staticreff);
                        Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                    }
Ejemplo n.º 10
0
                /// <summary>
                /// Get the maximum tag of entities of dimension `dim' in the built-in CAD
                /// representation.
                /// </summary>
                public static int GetMaxTag(int dim)
                {
                    var index = Gmsh_Warp.GmshModelGeoGetMaxTag(dim, ref Gmsh._staticreff);

                    Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                    return(index);
                }
Ejemplo n.º 11
0
                /// <summary>
                /// Add a straight line segment between the two points with tags `startTag'
                /// and `endTag'. If `tag' is positive, set the tag explicitly; otherwise a
                /// new tag is selected automatically. Return the tag of the line.
                /// </summary>
                public static int AddLine(int startTag, int endTag, int tag = -1)
                {
                    var index = Gmsh_Warp.GmshModelGeoAddLine(startTag, endTag, tag, ref Gmsh._staticreff);

                    Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                    return(index);
                }
Ejemplo n.º 12
0
                public static void Dilate(ValueTuple <int, int>[] dimTags, double x, double y, double z, double a, double b, double c)
                {
                    var list = dimTags.ToIntArray();

                    Gmsh_Warp.GmshModelGeoDilate(list, list.LongLength, x, y, z, a, b, c, ref Gmsh._staticreff);
                    Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                }
Ejemplo n.º 13
0
                /// <summary>
                /// Add a geometrical point in the built-in CAD representation, at coordinates
                /// (`x', `y', `z'). If `meshSize' is > 0, add a meshing constraint at that
                /// point. If `tag' is positive, set the tag explicitly; otherwise a new tag
                /// is selected automatically. Return the tag of the point. (Note that the
                /// point will be added in the current model only after `synchronize' is
                /// called. This behavior holds for all the entities added in the geo module.)
                /// </summary>
                public static int AddPoint(double x, double y, double z, double meshsize = 0, int tag = -1)
                {
                    var index = Gmsh_Warp.GmshModelGeoAddPoint(x, y, z, meshsize, tag, ref Gmsh._staticreff);

                    Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                    return(index);
                }
Ejemplo n.º 14
0
                /// <summary>
                /// Translate the model entities `dimTags' along (`dx', `dy', `dz').
                /// </summary>
                public static void Translate(ValueTuple <int, int>[] dimTags, double dx, double dy, double dz)
                {
                    var list = dimTags.ToIntArray();

                    Gmsh_Warp.GmshModelGeoTranslate(list, list.LongLength, dx, dy, dz, ref Gmsh._staticreff);
                    Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                }
Ejemplo n.º 15
0
            /// <summary>
            /// Set the color of the model entities `dimTags' to the RGBA value (`r', `g',
            /// `b', `a'), where `r', `g', `b' and `a' should be integers between 0 and 255.
            /// Apply the color setting recursively if `recursive' is true.
            /// </summary>
            public static void SetColor(ValueTuple <int, int>[] dimTags, int r, int g, int b, int a = 255, bool recursive = false)
            {
                var dimarray = dimTags.ToIntArray();

                Gmsh_Warp.GmshModelSetColor(dimarray, dimarray.LongLength, r, g, b, a, Convert.ToInt32(recursive), ref Gmsh._staticreff);
                Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
            }
Ejemplo n.º 16
0
                /// <summary>
                /// Add a surface loop (a closed shell) formed by `surfaceTags'.  If `tag' is
                /// positive, set the tag explicitly; otherwise a new tag is selected
                /// automatically. Return the tag of the shell.
                /// </summary>
                public static int AddSurfaceLoop(int[] surfaceTags, int tag = -1)
                {
                    var index = Gmsh_Warp.GmshModelGeoAddSurfaceLoop(surfaceTags, surfaceTags.LongLength, tag, ref Gmsh._staticreff);

                    Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                    return(index);
                }
Ejemplo n.º 17
0
            /// <summary>
            /// Remove the physical groups `dimTags' of the current model. If `dimTags' is
            /// empty, remove all groups.
            /// </summary>
            public static void RemovePhysicalGroups(ValueTuple <int, int>[] dimTags)
            {
                var dimTags_array = dimTags.ToIntArray();

                Gmsh_Warp.GmshModelRemovePhysicalGroups(dimTags_array, dimTags_array.LongLength, ref Gmsh._staticreff);
                Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
            }
Ejemplo n.º 18
0
                /// <summary>
                /// Add a b-spline with control points sampling the curves in `curveTags'. The
                /// density of sampling points on each curve is governed by `numIntervals'. If
                /// `tag' is positive, set the tag explicitly; otherwise a new tag is selected
                /// automatically. Return the tag of the b-spline.
                /// </summary>
                public static int AddCompoundBSpline(int[] curveTags, int numIntervals = 20, int tag = -1)
                {
                    var index = Gmsh_Warp.GmshModelGeoAddCompoundBSpline(curveTags, curveTags.LongLength, numIntervals, tag, ref Gmsh._staticreff);

                    Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                    return(index);
                }
Ejemplo n.º 19
0
            /// <summary>
            /// Check if the user interface is available (e.g. to detect if it has been
            /// closed).
            /// </summary>
            public static int IsAvailable()
            {
                var index = Gmsh_Warp.GmshFltkIsAvailable(ref Gmsh._staticreff);

                Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                return(index);
            }
Ejemplo n.º 20
0
                /// <summary>
                /// Add an ellipse arc (strictly smaller than Pi) between the two points
                /// `startTag' and `endTag', with center `centerTag' and major axis point
                /// `majorTag'. If `tag' is positive, set the tag explicitly; otherwise a new
                /// tag is selected automatically. If (`nx', `ny', `nz') != (0, 0, 0),
                /// explicitly set the plane of the circle arc. Return the tag of the ellipse
                /// arc.
                /// </summary>
                public static int AddEllipseArc(int startTag, int centerTag, int majorTag, int endTag, int tag = -1, double nx = 0, double ny = 0, double nz = 0)
                {
                    var index = Gmsh_Warp.GmshModelGeoAddEllipseArc(startTag, centerTag, majorTag, endTag, tag, nx, ny, nz, ref Gmsh._staticreff);

                    Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                    return(index);
                }
Ejemplo n.º 21
0
                /// <summary>
                /// Remove the entities `dimTags'. If `recursive' is true, remove all the
                /// entities on their boundaries, down to dimension 0.
                /// </summary>
                public static void Remove(ValueTuple <int, int>[] dimTags, bool recursive = false)
                {
                    var dimarray = dimTags.ToIntArray();

                    Gmsh_Warp.GmshModelGeoRemove(dimarray, dimarray.LongLength, Convert.ToInt32(recursive), ref Gmsh._staticreff);
                    Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                }
Ejemplo n.º 22
0
            /// <summary>
            // Add a new post-processing view, with name `name'. If `tag' is positive use
            // it (and remove the view with that tag if it already exists), otherwise
            // associate a new tag. Return the view tag.
            /// </summary>
            public static int Add(string name, int tag = -1)
            {
                var index = Gmsh_Warp.GmshViewAdd(name, tag, ref Gmsh._staticreff);

                Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                return(index);
            }
Ejemplo n.º 23
0
                /// <summary>
                /// Mirror the model entities `dimTag', with respect to the plane of equation
                /// `a' * x + `b' * y + `c' * z + `d' = 0. (This is a synonym for `mirror',
                /// which will be deprecated in a future release.)
                /// </summary>
                public static void Symmetrize(ValueTuple <int, int>[] dimTags, double a, double b, double c, double d)
                {
                    var list = dimTags.ToIntArray();

                    Gmsh_Warp.GmshModelGeoSymmetrize(list, list.LongLength, a, b, c, d, ref Gmsh._staticreff);
                    Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                }
Ejemplo n.º 24
0
                /// <summary>
                /// Add a surface filling the curve loops in `wireTags'. Currently only a
                /// single curve loop is supported; this curve loop should be composed by 3 or
                /// 4 curves only. If `tag' is positive, set the tag explicitly; otherwise a
                /// new tag is selected automatically. Return the tag of the surface.
                /// </summary>
                public static int AddSurfaceFilling(int[] wireTags, int tag = -1, int sphereCenterTag = -1)
                {
                    var index = Gmsh_Warp.GmshModelGeoAddSurfaceFilling(wireTags, wireTags.LongLength, tag, sphereCenterTag, ref Gmsh._staticreff);

                    Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                    return(index);
                }
Ejemplo n.º 25
0
 public void Dispose()
 {
     if (!_finalize)
     {
         Gmsh.Finalize();
         _finalize = true;
     }
 }
Ejemplo n.º 26
0
            /// <summary>
            /// Get the `value' of a numerical option. `name' is of the form
            /// "category.option" or "category[num].option". Available categories and
            /// options are listed in the Gmsh reference manual.
            /// </summary>
            public static double GetNumber(string name)
            {
                var value = 0.0;

                Gmsh_Warp.GmshOptionGetNumber(name, ref value, ref Gmsh._staticreff);
                Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                return(value);
            }
Ejemplo n.º 27
0
            /// <summary>
            /// Get the visibility of the model entity of dimension `dim' and tag `tag'.
            /// </summary>
            public static int GetVisibility(int dim, int tag)
            {
                int value = 0;

                Gmsh_Warp.GmshModelGetVisibility(dim, tag, ref value, ref Gmsh._staticreff);
                Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                return(value);
            }
Ejemplo n.º 28
0
 /// <summary>
 /// Add model-based post-processing data to the view with tag `tag'. `modelName'
 /// identifies the model the data is attached to. `dataType' specifies the type
 /// of data, currently either "NodeData", "ElementData" or "ElementNodeData".
 /// `step' specifies the identifier (>= 0) of the data in a sequence. `tags'
 /// gives the tags of the nodes or elements in the mesh to which the data is
 /// associated. `data' is a vector of the same length as `tags': each entry is
 /// the vector of double precision numbers representing the data associated with
 /// the corresponding tag. The optional `time' argument associate a time value
 /// with the data. `numComponents' gives the number of data components (1 for
 /// scalar data, 3 for vector data, etc.) per entity; if negative, it is
 /// automatically inferred (when possible) from the input data. `partition'
 /// allows to specify data in several sub-sets.
 /// </summary>
 public static void AddModelData(int tag, int step, string modelName, string dataType, long[] tags, double[][] data, double time = 0, int numComponents = -1, int partition = 0)
 {
     unsafe
     {
         var ptr = Marshal.UnsafeAddrOfPinnedArrayElement(data, 0);
         Gmsh_Warp.GmshViewAddModelData(tag, step, modelName, dataType, tags, tags.LongLength, (double **)ptr.ToPointer(), data.Select(d => d.LongLength).ToArray(), data.LongLength, time, numComponents, partition, ref Gmsh._staticreff);
         Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
     }
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Set a transfinite meshing constraint on the surface `tag'. `cornerTags'
 /// can be used to specify the (6 or 8) corners of the transfinite
 /// interpolation explicitly.
 /// </summary>
 public static void SetTransfiniteVolume(int tag, int[] cornerTags = default)
 {
     if (cornerTags == default)
     {
         cornerTags = new int[0];
     }
     Gmsh_Warp.GmshModelGeoMeshSetTransfiniteVolume(tag, cornerTags, cornerTags.LongLength, ref Gmsh._staticreff);
     Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Add a discrete model entity (defined by a mesh) of dimension `dim' in the
 /// current model. Return the tag of the new discrete entity, equal to `tag' if
 /// `tag' is positive, or a new tag if `tag' < 0. `boundary' specifies the tags
 /// of the entities on the boundary of the discrete entity, if any. Specifying
 /// `boundary' allows Gmsh to construct the topology of the overall model.
 /// </summary>
 public static void AddDiscreteEntity(int dim, int tag, int[] boundary = default)
 {
     if (boundary == default)
     {
         boundary = new int[0];
     }
     Gmsh_Warp.GmshModelAddDiscreteEntity(dim, tag, boundary, boundary.LongLength, ref Gmsh._staticreff);
     Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
 }