Exemple #1
0
                /// <summary>
                /// Extrude the model entities `dimTags' by translation along (`dx', `dy',
                /// `dz'). 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. If `dx' ==
                /// `dy' == `dz' == 0, the entities are extruded along their normal.
                /// </summary>
                public static void Extrude(ValueTuple <int, int>[] dimTags, double dx, double dy, double dz, 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.GmshModelGeoExtrude(dimarray, dimarray.LongLength, dx, dy, dz, &ptrss, ref outcount, numElements, numElements.LongLength, heights, heights.LongLength, Convert.ToInt32(recombine), ref Gmsh._staticreff);
                        Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);

                        var outDimTagsint = UnsafeHelp.ToIntArray(ptrss, outcount);
                        outDimTags = outDimTagsint.ToIntPair();
                    }
                }
Exemple #2
0
                /// <summary>
                /// Extrude the model entities `dimTags' by rotation of `angle' radians 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 Revolve(ValueTuple <int, int>[] dimTags, double x, double y, double z, 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.GmshModelGeoRevolve(dimarray, dimarray.LongLength, x, y, z, ax, ay, az, angle, &ptrss, ref outcount, numElements, numElements.LongLength, heights, heights.LongLength, Convert.ToInt32(recombine), ref Gmsh._staticreff);
                        Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
                        var outDimTagsint = new int[outcount];
                        Marshal.Copy(new IntPtr(ptrss), outDimTagsint, 0, outDimTagsint.Length);
                        outDimTags = outDimTagsint.ToIntPair();
                    }
                }
Exemple #3
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);
     }
 }
Exemple #4
0
 /// <summary>
 /// Set one or more parameters in the ONELAB database, encoded in `format'.
 /// </summary>
 public static void Set(string data, string format = "json")
 {
     Gmsh_Warp.GmshOnelabSet(data, format, ref Gmsh._staticreff);
     Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
 }
Exemple #5
0
 /// <summary>
 /// Write a file. The export format is determined by the file extension.
 /// </summary>
 public static void Write(string fileName)
 {
     Gmsh_Warp.GmshWrite(fileName, ref _staticreff);
     CheckException(MethodBase.GetCurrentMethod().MethodHandle);
 }
Exemple #6
0
 /// <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);
 }
Exemple #7
0
 /// <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);
 }
Exemple #8
0
 /// <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);
 }
Exemple #9
0
 /// <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);
 }
Exemple #10
0
 /// <summary>
 /// Write the view to a file `fileName'. The export format is determined by the
 /// file extension. Append to the file if `append' is set.
 /// </summary>
 public static void Write(int tag, string fileName, bool append = true)
 {
     Gmsh_Warp.GmshViewWrite(tag, fileName, Convert.ToInt32(append), ref Gmsh._staticreff);
     Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
 }
Exemple #11
0
 /// <summary>
 /// Combine elements (if `what' == "elements") or steps (if `what' == "steps")
 /// of all views (`how' == "all"), all visible views (`how' == "visible") or all
 /// views having the same name (`how' == "name"). Remove original views if
 /// `remove' is set.
 /// </summary>
 public static void Combine(string what, string how, bool remove = true, bool copyOptions = true)
 {
     Gmsh_Warp.GmshViewCombine(what, how, Convert.ToInt32(remove), Convert.ToInt32(copyOptions), ref Gmsh._staticreff);
     Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
 }
Exemple #12
0
 /// <summary>
 /// Copy the options from the view with tag `refTag' to the view with tag `tag'.
 /// </summary>
 public static void CopyOptions(int refTag, int tag)
 {
     Gmsh_Warp.GmshViewCopyOptions(refTag, tag, ref Gmsh._staticreff);
     Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
 }
Exemple #13
0
 /// <summary>
 /// Add a post-processing view as an `alias' of the reference view with tag
 /// `refTag'. If `copyOptions' is set, copy the options of the reference view.
 /// 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 void AddAlias(int refTag, bool copyOptions = false, int tag = -1)
 {
     Gmsh_Warp.GmshViewAddAlias(refTag, Convert.ToInt32(copyOptions), tag, ref Gmsh._staticreff);
     Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
 }
Exemple #14
0
            /// <summary>
            /// Add list-based post-processing data to the view with tag `tag'. List-based
            /// datasets are independent from any model and any mesh. `dataType' identifies
            /// the data by concatenating the field type ("S" for scalar, "V" for vector,
            /// "T" for tensor) and the element type ("P" for point, "L" for line, "T" for
            /// triangle, "S" for tetrahedron, "I" for prism, "H" for hexaHedron, "Y" for
            /// pyramid). For example `dataType' should be "ST" for a scalar field on
            /// triangles. `numEle' gives the number of elements in the data. `data'
            /// contains the data for the `numEle' elements, concatenated, with node
            /// coordinates followed by values per node, repeated for each step: [e1x1, ...,
            /// e1xn, e1y1, ..., e1yn, e1z1, ..., e1zn, e1v1..., e1vN, e2x1, ...].
            /// </summary>
            public static void AddListData(int tag, string dataType, int numEle, double[] data)
            {
                Gmsh_Warp.GmshViewAddListData(tag, dataType, numEle, data, data.LongLength, ref Gmsh._staticreff);

                Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
            }
Exemple #15
0
 /// <summary>
 /// Set the value of the number parameter `name' in the ONELAB database. Create
 /// the parameter if it does not exist; update the value if the parameter
 /// exists.
 /// </summary>
 public static void SetNumber(string name, double[] value)
 {
     Gmsh_Warp.GmshOnelabSetNumber(name, value, value.LongLength, 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 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);
 }
Exemple #18
0
 /// <summary>
 /// Get the index of the view with tag `tag' in the list of currently loaded
 /// views. This dynamic index (it can change when views are removed) is used to
 /// access view options.
 /// </summary>
 public static void GetIndex(int tag)
 {
     Gmsh_Warp.GmshViewGetIndex(tag, ref Gmsh._staticreff);
     Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
 }
Exemple #19
0
 /// <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);
 }
Exemple #20
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 AddHomogeneousModelData(int tag, int step, string modelName, string dataType, long[] tags, double[] data, double time = 0, int numComponents = -1, int partition = 0)
 {
     Gmsh_Warp.GmshViewAddHomogeneousModelData(tag, step, modelName, dataType, tags, tags.LongLength, data, data.LongLength, time, numComponents, partition, ref Gmsh._staticreff);
     Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
 }
Exemple #21
0
 /// <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);
 }
Exemple #22
0
 /// <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);
 }
Exemple #23
0
 /// <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);
 }
Exemple #24
0
 /// <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);
 }
Exemple #25
0
 /// <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 the field with tag `tag'.
 /// </summary>
 public static void Remove(int tag)
 {
     Gmsh_Warp.GmshModelMeshFieldRemove(tag, ref Gmsh._staticreff);
     Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
 }
Exemple #27
0
#pragma warning disable CS0465

        /// <summary>
        /// Finalize Gmsh. This must be called when you are done using the Gmsh API.
        /// </summary>
        public static void Finalize()
#pragma warning restore CS0465 // 引入 "Finalize" 方法可能会妨碍析构函数调用
        {
            Gmsh_Warp.GmshFinalize(ref _staticreff);
            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);
 }
Exemple #29
0
 /// <summary>
 /// Clear all loaded models and post-processing data, and add a new empty model.
 /// </summary>
 public static void Clear()
 {
     Gmsh_Warp.GmshClear(ref _staticreff);
     CheckException(MethodBase.GetCurrentMethod().MethodHandle);
 }
Exemple #30
0
 /// <summary>
 /// Run a ONELAB client. If `name' is provided, create a new ONELAB client with
 /// name `name' and executes `command'. If not, try to run a client that might
 /// be linked to the processed input files.
 /// </summary>
 public static void Run(string name, string command = "")
 {
     Gmsh_Warp.GmshOnelabRun(name, command, ref Gmsh._staticreff);
     Gmsh.CheckException(MethodBase.GetCurrentMethod().MethodHandle);
 }