コード例 #1
0
ファイル: GMesh.cs プロジェクト: msruzy/Gmsh.Net
        public void GetNode(uint nodeTag, out double[] coord, out double[] parametricCoord)
        {
            IntPtr api_coordPtr           = IntPtr.Zero;
            IntPtr api_parametricCoordPtr = IntPtr.Zero;

            ulong api_coord_n           = 0;
            ulong api_parametricCoord_n = 0;

            GMshNativeMethods.gmshModelMeshGetNode(nodeTag, ref api_coordPtr, ref api_coord_n, ref api_parametricCoordPtr, ref api_parametricCoord_n, ref ierr);
            if (ierr != 0)
            {
                throw new GMshException(ierr);
            }

            coord           = new double[api_coord_n];
            parametricCoord = new double[api_parametricCoord_n];

            if (api_coord_n != 0)
            {
                Marshal.Copy(api_coordPtr, coord, 0, api_coord_n.Toint());
            }
            if (api_coord_n != 0)
            {
                Marshal.Copy(api_parametricCoordPtr, parametricCoord, 0, api_parametricCoord_n.Toint());
            }

            api_coordPtr.GmshFree();
            api_parametricCoordPtr.GmshFree();
        }
コード例 #2
0
ファイル: GMesh.cs プロジェクト: msruzy/Gmsh.Net
        public void GetElementsByType(ElementTypes elementTypes, out long[] elementTags, out long[] nodeTags, int tag = -1, ulong task = 0, ulong numTasks = 1)
        {
            IntPtr elementTagsPtr = IntPtr.Zero;
            IntPtr nodeTagsPtr    = IntPtr.Zero;

            ulong elementTags_n = 0;
            ulong nodeTags_n    = 0;

            GMshNativeMethods.gmshModelMeshGetElementsByType((int)elementTypes, ref elementTagsPtr, ref elementTags_n, ref nodeTagsPtr, ref nodeTags_n, tag, task, numTasks, ref ierr);
            if (ierr != 0)
            {
                throw new GMshException(ierr);
            }

            elementTags = new long[elementTags_n];
            nodeTags    = new long[nodeTags_n];

            if (elementTags_n != 0)
            {
                Marshal.Copy(elementTagsPtr, elementTags, 0, elementTags_n.Toint());
            }
            if (nodeTags_n != 0)
            {
                Marshal.Copy(nodeTagsPtr, nodeTags, 0, nodeTags_n.Toint());
            }

            elementTagsPtr.GmshFree();
            nodeTagsPtr.GmshFree();
        }
コード例 #3
0
 /// <summary>
 /// Get the `value' of a string 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 void GetString(string name, string value)
 {
     GMshNativeMethods.gmshOptionGetString(name, value, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #4
0
ファイル: GMesh.cs プロジェクト: msruzy/Gmsh.Net
 /// <summary>
 /// Refine the mesh of the current model by uniformly splitting the elements.
 /// </summary>
 public void Refine()
 {
     GMshNativeMethods.gmshModelMeshRefine(ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #5
0
ファイル: GMesh.cs プロジェクト: msruzy/Gmsh.Net
 /// <summary>
 /// Unpartition the mesh of the current model.
 /// </summary>
 public void Unpartition()
 {
     GMshNativeMethods.gmshModelMeshUnpartition(ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #6
0
ファイル: GMesh.cs プロジェクト: msruzy/Gmsh.Net
 /// <summary>
 /// Partition the mesh of the current model into `numPart' partitions.
 /// </summary>
 public void Partition(int numPart)
 {
     GMshNativeMethods.gmshModelMeshPartition(numPart, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #7
0
 /// <summary>
 /// Set the field `tag' as a boundary layer size field.
 /// </summary>
 public void SetAsBoundaryLayer(int tag)
 {
     GMshNativeMethods.gmshModelMeshFieldSetAsBoundaryLayer(tag, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #8
0
ファイル: Fltk.cs プロジェクト: msruzy/Gmsh.Net
 /// <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 void Wait(double time = -1)
 {
     GMshNativeMethods.gmshFltkWait(time, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #9
0
ファイル: Fltk.cs プロジェクト: msruzy/Gmsh.Net
 /// <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 void Awake(string action = "")
 {
     GMshNativeMethods.gmshFltkAwake(action, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #10
0
 /// <summary>
 /// Write a file. The export format is determined by the file extension.
 /// </summary>
 public void Write(string filename)
 {
     GMshNativeMethods.gmshWrite(filename, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #11
0
 /// <summary>
 /// Clear all loaded models and post-processing data, and add a new empty model.
 /// </summary>
 public void Clear()
 {
     GMshNativeMethods.gmshClear(ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #12
0
 /// <summary>
 /// Finalize Gmsh. This must be called when you are done using the Gmsh API.
 /// </summary>
 public void Dispose()
 {
     GMshNativeMethods.gmshFinalize(ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #13
0
 /// <summary>
 /// Initialize Gmsh.
 /// </summary>
 public GMsh()
 {
     GMshNativeMethods.gmshInitialize(0, null, 1, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #14
0
 public void SetColor(string name, Color color)
 {
     GMshNativeMethods.gmshOptionSetColor(name, color.R, color.G, color.B, color.A, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #15
0
 /// <summary>
 /// Set the string option `option' to value `value' for field `tag'.
 /// </summary>
 public void SetString(int tag, string option, string value)
 {
     GMshNativeMethods.gmshModelMeshFieldSetString(tag, option, value, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #16
0
ファイル: Fltk.cs プロジェクト: msruzy/Gmsh.Net
 /// <summary>
 /// Create the FLTK graphical user interface. Can only be called in the main thread.
 /// </summary>
 public void Initialize()
 {
     GMshNativeMethods.gmshFltkInitialize(ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #17
0
 /// <summary>
 /// Set the numerical list option `option' to value `value' for field `tag'.
 /// </summary>
 public void SetNumbers(int tag, string option, double[] value)
 {
     GMshNativeMethods.gmshModelMeshFieldSetNumbers(tag, option, value, value.Length.ToUlong(), ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #18
0
ファイル: Fltk.cs プロジェクト: msruzy/Gmsh.Net
 /// <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 void Run()
 {
     GMshNativeMethods.gmshFltkRun(ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #19
0
ファイル: GMesh.cs プロジェクト: msruzy/Gmsh.Net
 /// <summary>
 /// Set the order of the elements in the mesh of the current model to `order'.
 /// </summary>
 public void SetOrder(int order)
 {
     GMshNativeMethods.gmshModelMeshSetOrder(order, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #20
0
 /// <summary>
 /// Write a `message'. `level' can be "info", "warning" or "error".
 /// </summary>
 public void Write(string message, string level = "info")
 {
     GMshNativeMethods.gmshLoggerWrite(message, level, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #21
0
ファイル: GMesh.cs プロジェクト: msruzy/Gmsh.Net
 /// <summary>
 /// Generate a mesh of the current model, up to dimension `dim' (0, 1, 2 or 3).
 /// </summary>
 public void Generate(int dim = 3)
 {
     GMshNativeMethods.gmshModelMeshGenerate(dim, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #22
0
 /// <summary>
 ///  Stop logging messages.
 /// </summary>
 public void Stop()
 {
     GMshNativeMethods.gmshLoggerTime(ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #23
0
ファイル: GMesh.cs プロジェクト: msruzy/Gmsh.Net
        /// <summary>
        /// Add elements classified on the entity of dimension `dim' and tag `tag'.
        /// `types' contains the MSH types of the elements (e.g. `2' for 3-node
        /// triangles: see the Gmsh reference manual). `elementTags' is a vector of
        /// the same length as `types'; each entry is a vector containing the tags
        /// (unique, strictly positive identifiers) of the elements of the
        /// corresponding type. `nodeTags' is also a vector of the same length as
        /// `types'; each entry is a vector of length equal to the number of elements
        /// of the given type times the number N of nodes per element, that contains
        /// the node tags of all the elements of the given type, concatenated: [e1n1,
        /// e1n2, ..., e1nN, e2n1, ...].
        /// </summary>
        //public void AddElements(int dim, int tag, ElementTypes[] elementTypes, long[][] elementTags, long[][] nodeTags)
        //{
        //    GMshNativeMethods.gmshModelMeshAddNodes(dim, tag, nodeTags, nodeTags.Length.ToUint(), coord, coord.Length.ToUint(), parametricCoord, parametricCoord.Length.ToUint(), ref ierr);
        //}

        public void AddElementsByType(ElementTypes elementType, long[] elementTags, long[] nodeTags, int tag = -1)
        {
            GMshNativeMethods.gmshModelMeshAddElementsByType(tag, (int)elementType, elementTags, elementTags.Length.ToUint(), nodeTags, nodeTags.Length.ToUint(), ref ierr);
            if (ierr != 0)
            {
                throw new GMshException(ierr);
            }
        }
コード例 #24
0
ファイル: GeoFunc.cs プロジェクト: msruzy/Gmsh.Net
 public void Synchronize()
 {
     GMshNativeMethods.gmshModelGeoSynchronize(ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #25
0
ファイル: GMesh.cs プロジェクト: msruzy/Gmsh.Net
 public void CreateTopology()
 {
     GMshNativeMethods.gmshModelMeshCreateTopology(ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #26
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 void Add(string fieldType, int tag = -1)
 {
     GMshNativeMethods.gmshModelMeshFieldAdd(fieldType, tag, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #27
0
ファイル: GMesh.cs プロジェクト: msruzy/Gmsh.Net
 /// <summary>
 /// Optimize the mesh of the current model using `method' (empty for default
 /// tetrahedral mesh optimizer, "Netgen" for Netgen optimizer, "HighOrder" for
 /// direct high-order mesh optimizer, "HighOrderElastic" for high-order
 /// elastic smoother). If `force' is set apply the optimization also to
 /// discrete entities.
 /// </summary>
 public void Optimize(string method, bool force = false)
 {
     GMshNativeMethods.gmshModelMeshOptimize(method, force.Toint(), ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #28
0
 /// <summary>
 /// Remove the field with tag `tag'.
 /// </summary>
 public void Remove(int tag)
 {
     GMshNativeMethods.gmshModelMeshFieldRemove(tag, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #29
0
ファイル: GMesh.cs プロジェクト: msruzy/Gmsh.Net
 /// <summary>
 /// Smooth the mesh of the current model.
 /// </summary>
 public void Smooth()
 {
     GMshNativeMethods.gmshModelMeshSmooth(ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }
コード例 #30
0
 /// <summary>
 /// Set a string option to `value'. `name' is of the form "category.option" or
 /// "category[num].option". Available categories and options are listed in the
 /// Gmsh reference manual.
 /// </summary>
 public void SetNumber(string filename, double value)
 {
     GMshNativeMethods.gmshOptionSetNumber(filename, value, ref ierr);
     if (ierr != 0)
     {
         throw new GMshException(ierr);
     }
 }