/// <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()); }
/// <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; }
/// <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()); }
/// <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()); }
/// <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; }
/// <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; }
/// <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); }
/// <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); }
///<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))); }
/// <summary> /// Deletes and regenerates surface mesh. Useful after making changes with <see cref="KratosMesh"/> /// </summary> public void RecreateProcessedMesh() { NativeModelPart.ModelPartWrapper_RecreateProcessedMesh(_nativeInstance); }
/// <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))); }
/// <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); }
/// <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); }
public void Dispose() { NativeModelPart.ModelPartWrapper_DisposeModelPartWrapper(_nativeInstance); }
internal ModelPart(IntPtr nativeInstance) { _nativeInstance = nativeInstance; KratosMesh = new KratosMesh(nativeInstance); IdTranslator = new IdTranslator(NativeModelPart.ModelPartWrapper_GetIdTranslator(nativeInstance)); }
/// <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))); }
/// <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); }
/// <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); }
/// <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)); }
/// <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))); }
/// <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))); }
/// <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))); }
/// <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); }
/// <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); }
/// <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); }