示例#1
0
        /// <returns>All conditions in this model part</returns>
        public KratosCondition[] GetConditions()
        {
            IntPtr pConditions = NativeModelPart.ModelPartWrapper_GetConditions(_nativeModelPartInstance);
            int    size        = NativeModelPart.ModelPartWrapper_GetNumberOfConditions(_nativeModelPartInstance);

            IntPtr[] unmarshaled = new IntPtr[size];
            Marshal.Copy(pConditions, unmarshaled, 0, size);
            return(unmarshaled.Select(x => new KratosCondition(x)).ToArray());
        }
示例#2
0
        /// <summary>
        /// Retrieves Von Misses stress values from last simulation.
        /// Before first invocation <see cref="EnableSurfaceStressResults"/> must be called.
        ///  Returns one float for every triangle in the same order, as in <see cref="GetTriangles"/>.
        /// Remeber to call <see cref="RetrieveResults"/> after each simulation.
        /// </summary>
        /// <param name="surfaceStresses">Results array.</param>
        /// <seealso cref="RetrieveResults"/>
        public void GetSurfaceStress(out float[] surfaceStresses)
        {
            IntPtr pReactions = NativeModelPart.ModelPartWrapper_GetSurfaceStress(_nativeInstance);
            int    size       = NativeModelPart.ModelPartWrapper_GetTrianglesCount(_nativeInstance);

            float[] unmarshaled = new float[size];
            Marshal.Copy(pReactions, unmarshaled, 0, size);
            surfaceStresses = unmarshaled;
        }
示例#3
0
        /// <returns>All nodes in this model part</returns>
        public KratosNode[] GetNodes()
        {
            IntPtr pNodes = NativeModelPart.ModelPartWrapper_GetNodes(_nativeModelPartInstance);
            int    size   = NativeModelPart.ModelPartWrapper_GetNodesCount(_nativeModelPartInstance);

            IntPtr[] unmarshaled = new IntPtr[size];
            Marshal.Copy(pNodes, unmarshaled, 0, size);
            return(unmarshaled.Select(x => new KratosNode(x)).ToArray());
        }
示例#4
0
        /// <returns>All elements in the model part</returns>
        public KratosElement[] GetElements()
        {
            IntPtr pElements = NativeModelPart.ModelPartWrapper_GetElements(_nativeModelPartInstance);
            int    size      = NativeModelPart.ModelPartWrapper_GetNumberOfElements(_nativeModelPartInstance);

            IntPtr[] unmarshaled = new IntPtr[size];
            Marshal.Copy(pElements, unmarshaled, 0, size);
            return(unmarshaled.Select(x => new KratosElement(x)).ToArray());
        }
示例#5
0
        /// <summary>
        /// Copies triangles of Kratos model into given array. Result length will always be a multiple of 3.
        /// </summary>
        public void GetTriangles(out int[] triangles)
        {
            IntPtr pTriangles = NativeModelPart.ModelPartWrapper_GetTriangles(_nativeInstance);
            int    size       = NativeModelPart.ModelPartWrapper_GetTrianglesCount(_nativeInstance);

            int[] unmarshaled = new int[size * 3];

            Marshal.Copy(pTriangles, unmarshaled, 0, size * 3);

            triangles = unmarshaled;
        }
示例#6
0
        /// <summary>
        /// Copies internal node coordinates of Kratos model into given arrays.
        /// </summary>
        /// <remarks>
        /// Coordinates of first node are (xCoordinates[0], yCoordinates[0], zCoordinates[0]).
        /// Remember to call <see cref="RetrieveResults"/> after each simulation.
        /// </remarks>
        /// <seealso cref="RetrieveResults"/>
        public void GetNodesPos(out float[] xCoordinates, out float[] yCoordinates, out float[] zCoordinates)
        {
            IntPtr pxValues = NativeModelPart.ModelPartWrapper_GetXCoordinates(_nativeInstance);
            IntPtr pyValues = NativeModelPart.ModelPartWrapper_GetYCoordinates(_nativeInstance);
            IntPtr pzValues = NativeModelPart.ModelPartWrapper_GetZCoordinates(_nativeInstance);

            int size = NativeModelPart.ModelPartWrapper_GetNodesCount(_nativeInstance);

            float[] xResult = new float[size];
            float[] yResult = new float[size];
            float[] zResult = new float[size];

            Marshal.Copy(pxValues, xResult, 0, size);
            Marshal.Copy(pyValues, yResult, 0, size);
            Marshal.Copy(pzValues, zResult, 0, size);

            xCoordinates = xResult;
            yCoordinates = yResult;
            zCoordinates = zResult;
        }
示例#7
0
 /// <summary>
 /// Adds conditions to this model part. They must already exist in the model.
 /// </summary>
 /// <param name="conditionIds">Ids of conditions to add</param>
 public void AddConditions(int[] conditionIds)
 {
     NativeModelPart.ModelPartWrapper_AddConditions(_nativeModelPartInstance, conditionIds, conditionIds.Length);
 }
示例#8
0
 /// <summary>
 /// Creates new condition and adds it to this model part.
 /// </summary>
 /// <param name="name">Kratos condition name. For example "SurfaceCondition3D3N"</param>
 /// <param name="id">New condition id. Must be unique in the whole model. <seealso cref="MaxElementId"/></param>
 /// <param name="nodeIds">Nodes of the new condition</param>
 public void CreateCondition(String name, int id, int[] nodeIds)
 {
     NativeModelPart.ModelPartWrapper_CreateNew2dCondition(_nativeModelPartInstance, name, id, nodeIds);
 }
示例#9
0
 ///<summary>
 /// Searches model part for element with given id.
 /// </summary>
 /// <param name="id">Element id to find</param>
 /// <returns>Found element</returns>
 public KratosElement GetElement(int id)
 {
     return(new KratosElement(NativeModelPart.ModelPartWrapper_GetElement(_nativeModelPartInstance, id)));
 }
示例#10
0
 /// <summary>
 /// Deletes and regenerates surface mesh. Useful after making changes with <see cref="KratosMesh"/>
 /// </summary>
 public void RecreateProcessedMesh()
 {
     NativeModelPart.ModelPartWrapper_RecreateProcessedMesh(_nativeInstance);
 }
示例#11
0
 /// <summary>
 /// Returns existing submodel part
 /// </summary>
 /// <param name="name">Part name to find</param>
 /// <returns>Submodel part with given name</returns>
 /// <seealso cref="HasSubmodelPart"/>
 /// <seealso cref="CreateSubModelPart"/>
 public ModelPart GetSubmodelPart(string name)
 {
     return(new ModelPart(NativeModelPart.ModelPartWrapper_GetSubmodelPart(_nativeInstance, name)));
 }
示例#12
0
 /// <summary>
 /// Removes condition from this model part.
 /// </summary>
 /// <param name="id">Id of the condition to remove</param>
 public void RemoveCondition(int id)
 {
     NativeModelPart.ModelPartWrapper_RemoveCondition(_nativeModelPartInstance, id);
 }
示例#13
0
 /// <summary>
 /// Sets Kratos DISPLACEMENT variable for node with given id, so that its final position is equal to given xyz coordinates.
 /// </summary>
 public void UpdateNodePos(int nodeId, float x, float y, float z)
 {
     NativeModelPart.ModelPartWrapper_UpdateNodePos(_nativeInstance, nodeId, x, y, z);
 }
示例#14
0
 public void Dispose()
 {
     NativeModelPart.ModelPartWrapper_DisposeModelPartWrapper(_nativeInstance);
 }
示例#15
0
 internal ModelPart(IntPtr nativeInstance)
 {
     _nativeInstance = nativeInstance;
     KratosMesh      = new KratosMesh(nativeInstance);
     IdTranslator    = new IdTranslator(NativeModelPart.ModelPartWrapper_GetIdTranslator(nativeInstance));
 }
示例#16
0
 /// <summary>
 /// Searches model part for condition with given idd
 /// </summary>
 /// <param name="id">Id to find</param>
 /// <returns>Found condition</returns>
 public KratosCondition GetCondition(int id)
 {
     return(new KratosCondition(NativeModelPart.ModelPartWrapper_GetCondition(_nativeModelPartInstance, id)));
 }
示例#17
0
 /// <summary>
 /// Adds nodes to this model part. They must already exist in the model.
 /// </summary>
 /// <param name="nodes">Ids of nodes to add</param>
 public void AddNodes(int[] nodes)
 {
     NativeModelPart.ModelPartWrapper_AddNodes(_nativeModelPartInstance, nodes, nodes.Length);
 }
示例#18
0
 /// <summary>
 /// Enables collecting of Von Misses stress variable after each simulation.
 /// It can be then retrieved using <see cref="GetSurfaceStress"/> method
 /// </summary>
 public void EnableSurfaceStressResults()
 {
     NativeModelPart.ModelPartWrapper_EnableSurfaceStressResults(_nativeInstance);
 }
示例#19
0
 /// <summary>
 /// Checks if submodel part with given name exists
 /// </summary>
 /// <param name="name">Part name to check</param>
 /// <returns>true, if submodel part with this name exists</returns>
 public bool HasSubmodelPart(string name)
 {
     return(NativeModelPart.ModelPartWrapper_HasSubmodelPart(_nativeInstance, name));
 }
示例#20
0
 /// <summary>
 /// Creates and adds new node to the model part.
 /// </summary>
 /// <param name="id">Id of the new node. Must be unique in the whole model. <seealso cref="MaxNodeId"/></param>
 /// <param name="x">X coordinate of the new node</param>
 /// <param name="y">Y coordinate od the new node</param>
 /// <param name="z">Z coordinate of the new node</param>
 /// <returns>Created <see cref="KratosNode"/></returns>
 public KratosNode CreateNode(int id, double x, double y, double z)
 {
     return(new KratosNode(
                NativeModelPart.ModelPartWrapper_CreateNewNode(_nativeModelPartInstance, id, x, y, z)));
 }
示例#21
0
 /// <summary>
 /// Creates and adds new element to the model part
 /// </summary>
 /// <param name="name">Kratos element name. For example "TotalLagrangianElement3D4N"</param>
 /// <param name="id">New element Id. Must be unique in the whole model. <seealso cref="MaxElementId"/></param>
 /// <param name="nodes">Node ids.</param>
 /// <returns>Created Element</returns>
 public KratosElement CreateElement(string name, int id, int[] nodes)   //TODO check array length
 {
     return(new KratosElement(
                NativeModelPart.ModelPartWrapper_CreateNewElement(_nativeModelPartInstance, name, id, nodes)));
 }
示例#22
0
 /// <summary>
 /// Searches this model part for node with given Kratos id.
 /// </summary>
 /// <param name="id">Kratos id of node to find. Note, that this is different from ids used in <see cref="ModelPart"/> class</param>
 /// <returns><see cref="KratosNode"/> with given id</returns>
 /// <seealso cref="IdTranslator"/>
 public KratosNode GetNode(int id)
 {
     return(new KratosNode(NativeModelPart.ModelPartWrapper_GetNode(_nativeModelPartInstance, id)));
 }
示例#23
0
 /// <summary>
 /// Adds elements to this model part. They must already exist in the model.
 /// </summary>
 /// <param name="elements">Element ids to add</param>
 public void AddElements(int[] elements)
 {
     NativeModelPart.ModelPartWrapper_AddElements(_nativeModelPartInstance, elements, elements.Length);
 }
示例#24
0
 /// <summary>
 /// Removes node from model part
 /// </summary>
 /// <param name="id">Id of the node to remove. Note, that this is different from ids used in <see cref="ModelPart"/> class</param>
 public void RemoveNode(int id)
 {
     NativeModelPart.ModelPartWrapper_RemoveNode(_nativeModelPartInstance, id);
 }
示例#25
0
 /// <summary>
 /// Retrieves and stores simulation results like node positions or surface stresses. You should call this method
 /// after <see cref="Kratos.Calculate"/> and before <see cref="GetNodesPos"/> or <see cref="GetSurfaceStress"/>
 /// </summary>
 public void RetrieveResults()
 {
     NativeModelPart.ModelPartWrapper_RetrieveResults(_nativeInstance);
 }