https://kratos-wiki.cimne.upc.edu/index.php?title=Special:Contributions/Amirbcn&feed=atom&deletedOnly=&limit=50&target=Amirbcn&topOnly=&year=&month=KratosWiki - User contributions [en]2022-05-20T10:30:49ZFrom KratosWikiMediaWiki 1.17.0https://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T23:50:57Z<p>Amirbcn: /* Getting a value from integration points */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and first we search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_Y with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a variable such as proc_info:<br />
<br />
'''Run.py:'''<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is an array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the filename of Displacement2D.cpp in custom_elements folder.<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step, you need to add the definition name of STRESS in the function of '''GetValueOnIntegrationPoints()''' in your element: <br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints()''' and define a procedure to calculate stress components:<br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Defining a Stress Vector<br />
<br />
## '''A code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
where Output is the output stress vector which is the vector of three components in our example. If you work with an element with more than one Gauss point, any additional stress vector for each point can be stored in Output[1], Output[2], ...</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T23:50:41Z<p>Amirbcn: /* Getting a value from integration points */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and first we search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_Y with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a variable such as proc_info:<br />
<br />
'''Run.py'''<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is an array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the filename of Displacement2D.cpp in custom_elements folder.<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step, you need to add the definition name of STRESS in the function of '''GetValueOnIntegrationPoints()''' in your element: <br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints()''' and define a procedure to calculate stress components:<br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Defining a Stress Vector<br />
<br />
## '''A code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
where Output is the output stress vector which is the vector of three components in our example. If you work with an element with more than one Gauss point, any additional stress vector for each point can be stored in Output[1], Output[2], ...</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T23:49:43Z<p>Amirbcn: /* Getting a value from integration points in C++ */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and first we search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_Y with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a variable such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is an array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the filename of Displacement2D.cpp in custom_elements folder.<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step, you need to add the definition name of STRESS in the function of '''GetValueOnIntegrationPoints()''' in your element: <br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints()''' and define a procedure to calculate stress components:<br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Defining a Stress Vector<br />
<br />
## '''A code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
where Output is the output stress vector which is the vector of three components in our example. If you work with an element with more than one Gauss point, any additional stress vector for each point can be stored in Output[1], Output[2], ...</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T23:45:23Z<p>Amirbcn: /* Applying boundary conditions */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and first we search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_Y with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a variable such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is an array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the filename of Displacement2D.cpp in custom_elements folder.<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step, you need to add the definition name of STRESS in the function of '''GetValueOnIntegrationPoints()''' in your element: <br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints()''' and define a procedure to calculate stress components:<br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Defining a Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
where Output is the output stress vector which is the vector of three components in our example. If you work with an element with more than one Gauss point, any additional stress vector for each point can be stored in Output[1], Output[2], ...</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T23:43:31Z<p>Amirbcn: /* Applying boundary conditions */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and first we search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a variable such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is an array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the filename of Displacement2D.cpp in custom_elements folder.<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step, you need to add the definition name of STRESS in the function of '''GetValueOnIntegrationPoints()''' in your element: <br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints()''' and define a procedure to calculate stress components:<br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Defining a Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
where Output is the output stress vector which is the vector of three components in our example. If you work with an element with more than one Gauss point, any additional stress vector for each point can be stored in Output[1], Output[2], ...</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T23:38:43Z<p>Amirbcn: /* Getting a value from integration points */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a variable such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is an array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the filename of Displacement2D.cpp in custom_elements folder.<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step, you need to add the definition name of STRESS in the function of '''GetValueOnIntegrationPoints()''' in your element: <br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints()''' and define a procedure to calculate stress components:<br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Defining a Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
where Output is the output stress vector which is the vector of three components in our example. If you work with an element with more than one Gauss point, any additional stress vector for each point can be stored in Output[1], Output[2], ...</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T23:37:34Z<p>Amirbcn: /* Getting a value from integration points in C++ */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a variable such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the filename of Displacement2D.cpp in custom_elements folder.<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step, you need to add the definition name of STRESS in the function of '''GetValueOnIntegrationPoints()''' in your element: <br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints()''' and define a procedure to calculate stress components:<br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Defining a Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
where Output is the output stress vector which is the vector of three components in our example. If you work with an element with more than one Gauss point, any additional stress vector for each point can be stored in Output[1], Output[2], ...</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T23:31:31Z<p>Amirbcn: /* Getting a value from integration points */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a variable such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the filename of Displacement2D.cpp in custom_elements folder.<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step, you need to add the definition name of STRESS in the function of '''GetValueOnIntegrationPoints()''' in your element: <br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints()''' and define a procedure to calculate stress components:<br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Defining a Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T23:29:36Z<p>Amirbcn: /* Getting a value from integration points */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a variable such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step, you need to add the definition name of STRESS in the function of '''GetValueOnIntegrationPoints()''' in your element: <br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints()''' and define a procedure to calculate stress components:<br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Defining a Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T23:27:54Z<p>Amirbcn: /* Getting a value from integration points in C++ */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step, you need to add the definition name of STRESS in the function of '''GetValueOnIntegrationPoints()''' in your element: <br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints()''' and define a procedure to calculate stress components:<br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Defining a Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T23:26:43Z<p>Amirbcn: /* Getting a value from integration points in C++ */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step, you need to add the definition name of STRESS in the function of '''GetValueOnIntegrationPoints()''' in your element: <br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints()''' and define a procedure to calculate stress components:<br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T23:26:13Z<p>Amirbcn: /* Getting a value from integration points in C++ */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step, you need to add the definition name of STRESS in the function of '''GetValueOnIntegrationPoints()''' in your element: <br />
<br />
<br />
'''Displacement2D.cpp:'''<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints()''' and define a procedure to calculate stress components:<br />
<br />
<br />
<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T23:25:42Z<p>Amirbcn: /* Getting a value from integration points in C++ */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step, you need to add the definition name of STRESS in the function of '''GetValueOnIntegrationPoints()''' in your element: <br />
<br />
<br />
'''Displacement2D.cpp'''<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints()''' and define a procedure to calculate stress components:<br />
<br />
<br />
<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T22:44:29Z<p>Amirbcn: /* Getting a value from integration points in C++ */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step , you need to add the definition name of STRESS in the function of '''GetValueOnIntegrationPoints()''' in your element: <br />
<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints()''' and define a procedure to calculate stress components:<br />
<br />
<br />
<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T22:43:25Z<p>Amirbcn: /* Getting a value from integration points in C++ */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step , you need to add the definition name of STRESS in the function of GetValueOnIntegrationPoints() in your element: <br />
<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints''' and define a procedure to calculate stress components:<br />
<br />
<br />
<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T22:42:44Z<p>Amirbcn: /* Getting a value from integration points in C++ */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step , you need to add the definition name of '''STRESS''' in the function of GetValueOnIntegrationPoints() in your element: <br />
<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move on to the function of '''CalculateOnIntegrationPoints''' and define a procedure to calculate stress components:<br />
<br />
<br />
<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T22:42:02Z<p>Amirbcn: /* Getting a value from integration points in C++ */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step , you need to add the definition name of '''STRESS''' in the function of GetValueOnIntegrationPoints() in your element: <br />
<br />
<br />
void Displacement2D::'''GetValueOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move one to the function of '''CalculateOnIntegrationPoints''' and define the procedure to calculate stress components:<br />
<br />
<br />
<br />
<br />
void Displacement2D::'''CalculateOnIntegrationPoints'''(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable=='''STRESS''')<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T22:39:06Z<p>Amirbcn: /* Getting a value from integration points in C++ */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step , you need to add the definition name of STRESS in the function of GetValueOnIntegrationPoints() in your element: <br />
<br />
<br />
void Displacement2D::GetValueOnIntegrationPoints(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move one to the function of CalculateOnIntegrationPoints and define the procedure to calculate stress components:<br />
<br />
<br />
<br />
<br />
void Displacement2D::CalculateOnIntegrationPoints(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable==STRESS)<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
Temp[ii] = msStressVector[ii];<br />
<br />
Output[0] = Temp;<br />
}<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T22:37:39Z<p>Amirbcn: /* Getting a value from integration points in C++ */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step , you need to add the definition name of STRESS in the function of GetValueOnIntegrationPoints() in your element: <br />
<br />
<br />
void Displacement2D::GetValueOnIntegrationPoints(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move one to the function of CalculateOnIntegrationPoints and define the procedure to calculate stress components:<br />
<br />
<br />
<br />
<br />
void Displacement2D::CalculateOnIntegrationPoints(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable==STRESS)<br />
{<br />
<br />
array_1d<double,3> msStressVector; // Stress Vector<br />
<br />
## '''The code to calculate the msStressVector should be added here according to your application'''<br />
##<br />
##<br />
<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStressVector.size(); ii++)<br />
{<br />
Temp[ii] = msStressVector[ii];<br />
}<br />
Output[0] = Temp;<br />
}<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T22:19:31Z<p>Amirbcn: /* Getting a value from integration points in C++ */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step , you need to add the definition name of STRESS in the function of GetValueOnIntegrationPoints() in your element: <br />
<br />
<br />
void Displacement2D::GetValueOnIntegrationPoints(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable=='''STRESS''')<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
The important output of this function is rValues which is defined as a Vector of vectors or a matrix. This output finally is transfered to python. For the next step, you should move one to the function of CalculateOnIntegrationPoints and define the procedure to calculate stress components:<br />
<br />
<br />
<br />
<br />
void Displacement2D::CalculateOnIntegrationPoints(const Variable<Vector>& rVariable, std::vector<Vector>& Output, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
KRATOS_TRY;<br />
<br />
if(rVariable==STRESS)<br />
{<br />
Temp.resize(msStressVector.size());<br />
<br />
for(unsigned int ii = 0; ii<msStrainVector.size(); ii++)<br />
{<br />
Temp[ii] = msStrainVector[ii];<br />
}<br />
Output[0] = Temp;<br />
}<br />
KRATOS_CATCH("")<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T22:06:59Z<p>Amirbcn: /* Getting a value from integration points in C++ */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step , you need to add the definition name of STRESS in the function of GetValueOnIntegrationPoints in your element: <br />
<br />
<br />
void Displacement2D::GetValueOnIntegrationPoints(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable==STRESS)<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T22:03:46Z<p>Amirbcn: /* Getting a value from integration points */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not anymore a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
<br />
<br />
==== Getting a value from integration points in C++ ====<br />
<br />
For the first step in our element, we need to go <br />
<br />
<br />
void Displacement2D::GetValueOnIntegrationPoints(const Variable<Vector>& rVariable, std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo)<br />
{<br />
if(rVariable==STRESS)<br />
{<br />
CalculateOnIntegrationPoints( rVariable, rValues, rCurrentProcessInfo );<br />
}<br />
}<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T21:54:43Z<p>Amirbcn: /* Getting a value from integration points */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element. With a 2D triangular linear element with one Gauss point, StressVector includes three components: two axial and one shear stresses. The important point is that when you work with an element with more than one Gauss point, the StressVector is not any more a vector and it converts to a matrix with the number of rows equal to the number of Gauss points. The dimension of this matrix depends on your definition in the element and it can be changed. In order to clarify this definition, we mention one example where we define the value of stress in a triangular linear element with one Gauss point. The name of our element is Displacement2D and we present the part of C++ code inside this element with the name of Displacement2D.cpp in custom_elements folder:<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T21:40:32Z<p>Amirbcn: /* Getting value from integration points */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting a value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
then you can use the following loop to get a value such as Stress from integration point of each element in the model:<br />
<br />
<br />
StressVector = [] # Defining an array to store stress components <br />
<br />
for element in model_part.Elements:<br />
StressVector = element.GetValuesOnIntegrationPoints(STRESS, proc_info)<br />
<br />
<br />
where StressVector is the array to store stress components. The size of this vector depends on the output vector that you define in your element<br />
<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T21:30:47Z<p>Amirbcn: /* Applying boundary conditions */</p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Getting value from integration points====<br />
<br />
The typical example of working with integration points is to get stress or strain values from these points for an element. For the first step, you should get the current process information and put it in a value such as proc_info:<br />
<br />
proc_info = model_part.ProcessInfo <br />
<br />
<br />
<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_work_with_nodes_and_elements_in_pythonHow to work with nodes and elements in python2009-03-18T21:20:50Z<p>Amirbcn: </p>
<hr />
<div>When you work with python, in many applications you may need to access the nodes and elements data or you may want to apply some boundary conditions directly from python. In these cases you need to use some simple commands in your run file of python which we present them as below:<br />
<br />
=== Nodes ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
To apply a boundary condition on some nodes, you should first detect your desirable nodes in the model and then save them in an array. We name this array as '''Dirirchlet_nodes''' and we first search all the nodes to detect some of them as our desirable nodes to apply a Dirichlet boundary condition. Dirichlet_nodes array will help us to access our desirable nodes faster, without searching all the nodes again. For example, we can add the following lines in our python run file, which we name it as Run.py:<br />
<br />
'''Run.py:'''<br />
<br />
Dirichlet_nodes = [] # Defining an array to store the nodes<br />
<br />
for node in model_part.Nodes:<br />
<br />
if(node.Y > 100):<br />
node.Fix(DISPLACEMENT_X)<br />
node.Fix(DISPLACEMENT_Y)<br />
Dirichlet_nodes.append(node)<br />
<br />
<br />
In this example we select the nodes whose Y coordinates are more than 100. To access the information of the nodes` coordinate, you can easily use the optional iterator '''node''' and then use the components of .X,.Y or .Z to access the X,Y and Z coordinates of each node respectively. '''model_part.Nodes''' is the interface to access the nodes information in python. For the selected nodes in this example, we want to fix the value of DISPLACEMENT_X and DISPLACEMENT_X with command '''.Fix''' and then we store each node in Dirichlet_nodes array with command '''.append'''. After fixing the nodes, we can apply any values for DISPLACEMENT_X and DISPLACEMENT_Y with the following commands:<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_X,0,1) <br />
Dirichlet_nodes[i].SetSolutionStepValue(DISPLACEMENT_Y,0,-1)<br />
<br />
where we apply the values of 1 and -1 for DISPLACEMENT_X and DISPLACEMENT_Y respectively. In this way we just need to make some iterations through the loop with the length of '''len(Dirichlet_nodes)''' instead of the number of total nodes and it makes the implementation of the boundary condition faster specially when we have to apply this condition several times in our application, i.e. transient problems. To make the nodes free from previous boundary conditions we can use command '''.Free''' as<br />
<br />
for i in range(0,len(Dirichlet_nodes)):<br />
Dirichlet_nodes[i].Free(DISPLACEMENT_X) <br />
Dirichlet_nodes[i].Free(DISPLACEMENT_Y)<br />
<br />
=== Elements ===<br />
<br />
==== Applying boundary conditions ====<br />
<br />
<br />
<br />
<br />
<br />
To be continued ............</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-11T00:08:17Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in python_scripts folder of your application. We suppose the name of Element2D for our application and the name of '''static_Element2D_solver_pardiso.py''' for pardiso solver python file and we add or modify the following lines in this file:<br />
:<br />
<br />
<br />
'''static_Element2D_solver_pardiso.py :'''<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
class StaticElement2DSolver:<br />
<br />
#######################################################################<br />
def __init__(self,model_part,domain_size):<br />
<br />
self.model_part = model_part<br />
self.time_scheme = '''ParallelResidualBasedIncrementalUpdateStaticScheme()'''<br />
<br />
<br />
self.Element2D_linear_solver = '''ParallelMKLPardisoSolver()'''<br />
<br />
<br />
#definition of the convergence criteria<br />
self.conv_criteria = '''ParallelDisplacementCriteria'''(1e-4,1e-9) <br />
<br />
#######################################################################<br />
<br />
#######################################################################<br />
def Initialize(self):<br />
#creating the solution strategy<br />
CalculateReactionFlag = False<br />
ReformDofSetAtEachStep = False<br />
MoveMeshFlag = False<br />
<br />
import '''parallel_strategy_python'''<br />
self.solver = '''parallel_strategy_python'''.SolvingStrategyPython(self.model_part,self.time_scheme,self.Element2D_linear_solver,self.conv_criteria,CalculateReactionFlag,ReformDofSetAtEachStep,MoveMeshFlag)<br />
<br />
#######################################################################<br />
<br />
The next step is to add this solver to our run code in test_examples folder or any folder that we put our run codes. We name the run code as Run.py:<br />
<br />
'''Run.py :'''<br />
<br />
applications_interface.Import_KratosR1MKLSolversApplication = True<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
import static_Element2D_solver_pardiso<br />
<br />
static_Element2D_solver_pardiso.AddVariables(model_part)<br />
static_Element2D_solver_pardiso.AddDofs(model_part)<br />
<br />
#creating a solver object<br />
solver = static_Element2D_solver_pardiso.StaticElement2DSolver(model_part,domain_size)<br />
solver.time_order = 1<br />
solver.echo_level = 0<br />
solver.Initialize()<br />
<br />
solver.Solve()<br />
<br />
For the final step we should compile Kratos using intel compiler but before that, two enviroment variables should be set to define the number of CPUs and the location of intel MKL library :<br />
<br />
export LD_LIBRARY_PATH="/opt/intel/mkl/10.0.3.020/lib"<br />
<br />
export OMP_NUM_THREADS = 2<br />
<br />
<br />
In these two lines we assigned the path of intel MKL library and the number of processors which in our case is the two cores of Core Duo Processor.<br />
<br />
For the last command we compile Kratos:<br />
<br />
bjam threading=multi -j2 -intel</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-11T00:07:05Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in python_scripts folder of your application. We suppose the name of Element2D for our application and the name of '''static_Element2D_solver_pardiso.py''' for pardiso solver python file and we add or modify the following lines in this file:<br />
:<br />
<br />
<br />
'''static_Element2D_solver_pardiso.py :'''<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
class StaticElement2DSolver:<br />
<br />
#######################################################################<br />
def __init__(self,model_part,domain_size):<br />
<br />
self.model_part = model_part<br />
self.time_scheme = '''ParallelResidualBasedIncrementalUpdateStaticScheme()'''<br />
<br />
<br />
self.Element2D_linear_solver = '''ParallelMKLPardisoSolver()'''<br />
<br />
<br />
#definition of the convergence criteria<br />
self.conv_criteria = '''ParallelDisplacementCriteria'''(1e-4,1e-9) <br />
<br />
#######################################################################<br />
<br />
<br />
#######################################################################<br />
def Initialize(self):<br />
#creating the solution strategy<br />
CalculateReactionFlag = False<br />
ReformDofSetAtEachStep = False<br />
MoveMeshFlag = False<br />
<br />
import '''parallel_strategy_python'''<br />
self.solver = '''parallel_strategy_python'''.SolvingStrategyPython(self.model_part,self.time_scheme,self.Element2D_linear_solver,self.conv_criteria,CalculateReactionFlag,ReformDofSetAtEachStep,MoveMeshFlag)<br />
<br />
#######################################################################<br />
<br />
<br />
The next step is to add this solver to our run code in test_examples folder or any folder that we put our run codes. We name the run code as Run.py:<br />
<br />
'''Run.py :'''<br />
<br />
applications_interface.Import_KratosR1MKLSolversApplication = True<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
import static_Element2D_solver_pardiso<br />
<br />
<br />
static_Element2D_solver_pardiso.AddVariables(model_part)<br />
static_Element2D_solver_pardiso.AddDofs(model_part)<br />
<br />
<br />
<br />
#creating a solver object<br />
solver = static_Element2D_solver_pardiso.StaticElement2DSolver(model_part,domain_size)<br />
solver.time_order = 1<br />
solver.echo_level = 0<br />
solver.Initialize()<br />
<br />
<br />
solver.Solve()<br />
<br />
For the final step we should compile Kratos using intel compiler but before that, two enviroment variables should be set to define the number of CPUs and the location of intel MKL library :<br />
<br />
export LD_LIBRARY_PATH="/opt/intel/mkl/10.0.3.020/lib"<br />
<br />
export OMP_NUM_THREADS = 2<br />
<br />
<br />
In these two lines we assigned the path of intel MKL library and the number of processors which in our case is the two cores of Core Duo Processor.<br />
<br />
For the last command we compile Kratos:<br />
<br />
bjam threading=multi -j2 -intel</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T23:57:38Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in python_scripts folder of your application. We suppose the name of Element2D for our application and the name of '''static_Element2D_solver_pardiso.py''' for pardiso solver python file and we add or modify the following lines in this file:<br />
:<br />
<br />
<br />
'''static_Element2D_solver_pardiso.py :'''<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
class StaticElement2DSolver:<br />
<br />
#######################################################################<br />
def __init__(self,model_part,domain_size):<br />
<br />
self.model_part = model_part<br />
self.time_scheme = '''ParallelResidualBasedIncrementalUpdateStaticScheme()'''<br />
<br />
<br />
self.Element2D_linear_solver = '''ParallelMKLPardisoSolver()'''<br />
<br />
<br />
#definition of the convergence criteria<br />
self.conv_criteria = '''ParallelDisplacementCriteria'''(1e-4,1e-9) <br />
<br />
#######################################################################<br />
<br />
<br />
#######################################################################<br />
def Initialize(self):<br />
#creating the solution strategy<br />
CalculateReactionFlag = False<br />
ReformDofSetAtEachStep = False<br />
MoveMeshFlag = False<br />
<br />
import '''parallel_strategy_python'''<br />
self.solver = '''parallel_strategy_python'''.SolvingStrategyPython(self.model_part,self.time_scheme,self.Element2D_linear_solver,self.conv_criteria,CalculateReactionFlag,ReformDofSetAtEachStep,MoveMeshFlag)<br />
<br />
#######################################################################<br />
<br />
<br />
The next step is to add this solver to our run code in test_examples folder or any folder that we put our run codes. We name the run code as Run.py:<br />
<br />
'''Run.py :'''<br />
<br />
applications_interface.Import_KratosR1MKLSolversApplication = True<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
import static_Element2D_solver_pardiso<br />
<br />
<br />
static_Element2D_solver_pardiso.AddVariables(model_part)<br />
static_Element2D_solver_pardiso.AddDofs(model_part)<br />
<br />
<br />
<br />
#creating a solver object<br />
solver = static_Element2D_solver_pardiso.StaticElement2DSolver(model_part,domain_size)<br />
solver.time_order = 1<br />
solver.echo_level = 0<br />
solver.Initialize()<br />
<br />
<br />
For the final step we should compile Kratos using intel compiler but before that, two enviroment variables should be set to define the number of CPUs and the location of intel MKL library :<br />
<br />
export LD_LIBRARY_PATH="/opt/intel/mkl/10.0.3.020/lib"<br />
<br />
export OMP_NUM_THREADS = 2<br />
<br />
<br />
In these two lines we assigned the path of intel MKL library and the number of processors which in our case is the two cores of Core Duo Processor.<br />
<br />
For the last command we compile Kratos:<br />
<br />
bjam threading=multi -j2 -intel</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T23:54:55Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in python_scripts folder of your application. We suppose the name of Element2D for our application and the name of '''static_Element2D_solver_pardiso.py''' for pardiso solver python file and we add or modify the following lines in this file:<br />
:<br />
<br />
<br />
'''static_Element2D_solver_pardiso.py :'''<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
class StaticElement2DSolver:<br />
<br />
#######################################################################<br />
def __init__(self,model_part,domain_size):<br />
<br />
self.model_part = model_part<br />
self.time_scheme = '''ParallelResidualBasedIncrementalUpdateStaticScheme()'''<br />
<br />
<br />
self.Element2D_linear_solver = '''ParallelMKLPardisoSolver()'''<br />
<br />
<br />
#definition of the convergence criteria<br />
self.conv_criteria = '''ParallelDisplacementCriteria'''(1e-4,1e-9) <br />
<br />
#######################################################################<br />
<br />
<br />
#######################################################################<br />
def Initialize(self):<br />
#creating the solution strategy<br />
CalculateReactionFlag = False<br />
ReformDofSetAtEachStep = False<br />
MoveMeshFlag = False<br />
<br />
import '''parallel_strategy_python'''<br />
self.solver = '''parallel_strategy_python'''.SolvingStrategyPython(self.model_part,self.time_scheme,self.Element2D_linear_solver,self.conv_criteria,CalculateReactionFlag,ReformDofSetAtEachStep,MoveMeshFlag)<br />
<br />
#######################################################################<br />
<br />
<br />
The next step is to add this solver to our run code in test_examples folder or any folder that we put our run codes. We name the run code as Run.py:<br />
<br />
'''Run.py :'''<br />
<br />
applications_interface.Import_KratosR1MKLSolversApplication = True<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
import static_Element2D_solver_pardiso<br />
<br />
<br />
static_Element2D_solver_pardiso.AddVariables(model_part)<br />
static_Element2D_solver_pardiso.AddDofs(model_part)<br />
<br />
<br />
<br />
#creating a solver object<br />
solver = static_Element2D_solver_pardiso.StaticElement2DSolver(model_part,domain_size)<br />
solver.time_order = 1<br />
solver.echo_level = 0<br />
solver.Initialize()<br />
<br />
<br />
For the final step we should compile Kratos using intel compiler but before that, two enviroment variables should be set to define the number of CPUs and the location of intel MKL library :<br />
<br />
export LD_LIBRARY_PATH="/opt/intel/mkl/10.0.3.020/lib"<br />
<br />
export OMP_NUM_THREADS = 2<br />
<br />
<br />
In these two lines we assigned the path of intel MKL library and the number of processors which in our case is the two cores of Core Duo Processor.<br />
<br />
For the last command we compile Kratos:</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T23:53:46Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in python_scripts folder of your application. We suppose the name of Element2D for our application and the name of '''static_Element2D_solver_pardiso.py''' for pardiso solver python file and we add or modify the following lines in this file:<br />
:<br />
<br />
<br />
'''static_Element2D_solver_pardiso.py :'''<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
class StaticElement2DSolver:<br />
<br />
#######################################################################<br />
def __init__(self,model_part,domain_size):<br />
<br />
self.model_part = model_part<br />
self.time_scheme = '''ParallelResidualBasedIncrementalUpdateStaticScheme()'''<br />
<br />
<br />
self.Element2D_linear_solver = '''ParallelMKLPardisoSolver()'''<br />
<br />
<br />
#definition of the convergence criteria<br />
self.conv_criteria = '''ParallelDisplacementCriteria'''(1e-4,1e-9) <br />
<br />
#######################################################################<br />
<br />
<br />
#######################################################################<br />
def Initialize(self):<br />
#creating the solution strategy<br />
CalculateReactionFlag = False<br />
ReformDofSetAtEachStep = False<br />
MoveMeshFlag = False<br />
<br />
import '''parallel_strategy_python'''<br />
self.solver = '''parallel_strategy_python'''.SolvingStrategyPython(self.model_part,self.time_scheme,self.Element2D_linear_solver,self.conv_criteria,CalculateReactionFlag,ReformDofSetAtEachStep,MoveMeshFlag)<br />
<br />
#######################################################################<br />
<br />
<br />
The next step is to add this solver to our run code in test_examples folder or any folder that we put our run codes. We name the run code as Run.py:<br />
<br />
'''Run.py :'''<br />
<br />
applications_interface.Import_KratosR1MKLSolversApplication = True<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
import static_Element2D_solver_pardiso<br />
<br />
<br />
static_Element2D_solver_pardiso.AddVariables(model_part)<br />
static_Element2D_solver_pardiso.AddDofs(model_part)<br />
<br />
<br />
<br />
#creating a solver object<br />
solver = static_Element2D_solver_pardiso.StaticElement2DSolver(model_part,domain_size)<br />
solver.time_order = 1<br />
solver.echo_level = 0<br />
solver.Initialize()<br />
<br />
<br />
For the final step we should compile Kratos using intel compiler but before that, two enviroment variables should be set to define the number of CPUs and the location of intel MKL library :<br />
<br />
export LD_LIBRARY_PATH=/opt/intel/mkl/10.0.3.020/lib<br />
<br />
export OMP_NUM_THREADS = 2<br />
<br />
<br />
In this two lines we assigned the path of intel MKL library and the number of processors which in our case is the two cores of Core Duo Processor.<br />
<br />
<br />
For the last command we compile Kratos:</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T23:42:43Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in python_scripts folder of your application. We suppose the name of Element2D for our application and the name of '''static_Element2D_solver_pardiso.py''' for pardiso solver python file and we add or modify the following lines in this file:<br />
:<br />
<br />
<br />
'''static_Element2D_solver_pardiso.py :'''<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
class StaticElement2DSolver:<br />
<br />
#######################################################################<br />
def __init__(self,model_part,domain_size):<br />
<br />
self.model_part = model_part<br />
self.time_scheme = '''ParallelResidualBasedIncrementalUpdateStaticScheme()'''<br />
<br />
<br />
self.Element2D_linear_solver = '''ParallelMKLPardisoSolver()'''<br />
<br />
<br />
#definition of the convergence criteria<br />
self.conv_criteria = '''ParallelDisplacementCriteria'''(1e-4,1e-9) <br />
<br />
#######################################################################<br />
<br />
<br />
#######################################################################<br />
def Initialize(self):<br />
#creating the solution strategy<br />
CalculateReactionFlag = False<br />
ReformDofSetAtEachStep = False<br />
MoveMeshFlag = False<br />
<br />
import '''parallel_strategy_python'''<br />
self.solver = '''parallel_strategy_python'''.SolvingStrategyPython(self.model_part,self.time_scheme,self.Element2D_linear_solver,self.conv_criteria,CalculateReactionFlag,ReformDofSetAtEachStep,MoveMeshFlag)<br />
<br />
#######################################################################<br />
<br />
<br />
The next step is to add this solver to our run code in test_examples folder or any folder that we put our run codes. We name the run code as Run.py:<br />
<br />
'''Run.py :'''<br />
<br />
applications_interface.Import_KratosR1MKLSolversApplication = True<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
import static_Element2D_solver_pardiso<br />
<br />
<br />
static_Element2D_solver_pardiso.AddVariables(model_part)<br />
static_Element2D_solver_pardiso.AddDofs(model_part)<br />
<br />
<br />
<br />
#creating a solver object<br />
solver = static_Element2D_solver_pardiso.StaticElement2DSolver(model_part,domain_size)<br />
solver.time_order = 1<br />
solver.echo_level = 0<br />
solver.Initialize()</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T23:41:57Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in python_scripts folder of your application. We suppose the name of Element2D for our application and the name of '''static_Element2D_solver_pardiso.py''' for pardiso solver python file and we add or modify the following lines in this file:<br />
:<br />
<br />
<br />
'''static_Element2D_solver_pardiso.py :'''<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
class StaticFerroVCrackSolver:<br />
<br />
#######################################################################<br />
def __init__(self,model_part,domain_size):<br />
<br />
self.model_part = model_part<br />
self.time_scheme = '''ParallelResidualBasedIncrementalUpdateStaticScheme()'''<br />
<br />
<br />
self.Element2D_linear_solver = '''ParallelMKLPardisoSolver()'''<br />
<br />
<br />
#definition of the convergence criteria<br />
self.conv_criteria = '''ParallelDisplacementCriteria'''(1e-4,1e-9) <br />
<br />
#######################################################################<br />
<br />
<br />
#######################################################################<br />
def Initialize(self):<br />
#creating the solution strategy<br />
CalculateReactionFlag = False<br />
ReformDofSetAtEachStep = False<br />
MoveMeshFlag = False<br />
<br />
import '''parallel_strategy_python'''<br />
self.solver = '''parallel_strategy_python'''.SolvingStrategyPython(self.model_part,self.time_scheme,self.Element2D_linear_solver,self.conv_criteria,CalculateReactionFlag,ReformDofSetAtEachStep,MoveMeshFlag)<br />
<br />
#######################################################################<br />
<br />
<br />
The next step is to add this solver to our run code in test_examples folder or any folder that we put our run codes. We name the run code as Run.py:<br />
<br />
'''Run.py :'''<br />
<br />
applications_interface.Import_KratosR1MKLSolversApplication = True<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
import static_Element2D_solver_pardiso<br />
<br />
<br />
static_Element2D_solver_pardiso.AddVariables(model_part)<br />
static_Element2D_solver_pardiso.AddDofs(model_part)<br />
<br />
<br />
<br />
#creating a solver object<br />
solver = static_Element2D_solver_pardiso.StaticElement2DSolver(model_part,domain_size)<br />
solver.time_order = 1<br />
solver.echo_level = 0<br />
solver.Initialize()</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T23:39:30Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in python_scripts folder of your application. We suppose the name of Element2D for our application and the name of '''static_Element2D_solver_pardiso.py''' for pardiso solver python file and we add or modify the following lines in this file:<br />
:<br />
<br />
<br />
'''static_Element2D_solver_pardiso.py :'''<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
<br />
#######################################################################<br />
def __init__(self,model_part,domain_size):<br />
<br />
self.model_part = model_part<br />
self.time_scheme = '''ParallelResidualBasedIncrementalUpdateStaticScheme()'''<br />
<br />
<br />
self.Element2D_linear_solver = '''ParallelMKLPardisoSolver()'''<br />
<br />
<br />
#definition of the convergence criteria<br />
self.conv_criteria = '''ParallelDisplacementCriteria'''(1e-4,1e-9) <br />
<br />
#######################################################################<br />
<br />
<br />
#######################################################################<br />
def Initialize(self):<br />
#creating the solution strategy<br />
CalculateReactionFlag = False<br />
ReformDofSetAtEachStep = False<br />
MoveMeshFlag = False<br />
<br />
import '''parallel_strategy_python'''<br />
self.solver = '''parallel_strategy_python'''.SolvingStrategyPython(self.model_part,self.time_scheme,self.Element2D_linear_solver,self.conv_criteria,CalculateReactionFlag,ReformDofSetAtEachStep,MoveMeshFlag)<br />
<br />
#######################################################################<br />
<br />
<br />
The next step is to add this solver to our run code in test_examples folder or any folder that we put our run codes. We name the run code as Run.py:<br />
<br />
'''Run.py :'''<br />
<br />
applications_interface.Import_KratosR1MKLSolversApplication = True<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
import static_Element2D_solver_pardiso<br />
<br />
<br />
static_Element2D_solver_pardiso.AddVariables(model_part)<br />
static_Element2D_solver_pardiso.AddDofs(model_part)<br />
<br />
<br />
<br />
#creating a solver object<br />
solver = static_Element2D_solver_pardiso.StaticElement2DSolver(model_part,domain_size)<br />
solver.time_order = 1<br />
solver.echo_level = 0<br />
solver.Initialize()</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T23:38:03Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in python_scripts folder of your application. We suppose the name of Element2D for our application and the name of '''static_Element2D_solver_pardiso.py''' for pardiso solver python file and we add or modify the following lines in this file:<br />
:<br />
<br />
<br />
'''static_Element2D_solver_pardiso.py :'''<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
<br />
#######################################################################<br />
def __init__(self,model_part,domain_size):<br />
<br />
self.model_part = model_part<br />
self.time_scheme = '''ParallelResidualBasedIncrementalUpdateStaticScheme()'''<br />
<br />
<br />
self.Element2D_linear_solver = '''ParallelMKLPardisoSolver()'''<br />
<br />
<br />
#definition of the convergence criteria<br />
self.conv_criteria = '''ParallelDisplacementCriteria'''(1e-4,1e-9) <br />
<br />
#######################################################################<br />
<br />
<br />
#######################################################################<br />
def Initialize(self):<br />
#creating the solution strategy<br />
CalculateReactionFlag = False<br />
ReformDofSetAtEachStep = False<br />
MoveMeshFlag = False<br />
<br />
import '''parallel_strategy_python'''<br />
self.solver = '''parallel_strategy_python'''.SolvingStrategyPython(self.model_part,self.time_scheme,self.Element2D_linear_solver,self.conv_criteria,CalculateReactionFlag,ReformDofSetAtEachStep,MoveMeshFlag)<br />
<br />
#######################################################################<br />
<br />
<br />
The next step is to add this solver to our run code in test_examples folder or nay folder that we put our run codes. We name the run code as Run.py:<br />
<br />
'''Run.py :'''<br />
<br />
applications_interface.Import_KratosR1MKLSolversApplication = True<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
import static_Element2D_solver_pardiso<br />
<br />
<br />
static_Element2D_solver_pardiso.AddVariables(model_part)<br />
static_Element2D_solver_pardiso.AddDofs(model_part)<br />
<br />
<br />
<br />
#creating a solver object<br />
solver = static_Element2D_solver_pardiso.StaticElement2DSolver(model_part,domain_size)<br />
solver.time_order = 1<br />
solver.echo_level = 0<br />
solver.Initialize()</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T23:26:54Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in python_scripts folder of your application. We suppose the name of Element2D for our application and the name of '''static_Element2D_solver_pardiso.py''' for pardiso solver python file:<br />
:<br />
<br />
<br />
'''static_Element2D_solver_pardiso.py :'''<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
<br />
#######################################################################<br />
def __init__(self,model_part,domain_size):<br />
<br />
self.model_part = model_part<br />
self.time_scheme = '''ParallelResidualBasedIncrementalUpdateStaticScheme()'''<br />
<br />
<br />
self.Element2D_linear_solver = '''ParallelMKLPardisoSolver()'''<br />
<br />
<br />
#definition of the convergence criteria<br />
self.conv_criteria = '''ParallelDisplacementCriteria'''(1e-4,1e-9) <br />
<br />
#######################################################################<br />
<br />
<br />
#######################################################################<br />
def Initialize(self):<br />
#creating the solution strategy<br />
CalculateReactionFlag = False<br />
ReformDofSetAtEachStep = False<br />
MoveMeshFlag = False<br />
<br />
import '''parallel_strategy_python'''<br />
self.solver = '''parallel_strategy_python'''.SolvingStrategyPython(self.model_part,self.time_scheme,self.Element2D_linear_solver,self.conv_criteria,CalculateReactionFlag,ReformDofSetAtEachStep,MoveMeshFlag)<br />
<br />
#######################################################################</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T23:21:26Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in python_scripts folder of your application. We suppose the name of Element2D for our application and the name of '''static_Element2D_solver_pardiso.py''' for pardiso solver python file:<br />
:<br />
<br />
<br />
'''static_Element2D_solver_pardiso.py :'''<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
<br />
#######################################################################<br />
def __init__(self,model_part,domain_size):<br />
<br />
self.model_part = model_part<br />
self.time_scheme = ParallelResidualBasedIncrementalUpdateStaticScheme()<br />
<br />
<br />
self.Element2D_linear_solver = ParallelMKLPardisoSolver()<br />
<br />
<br />
#definition of the convergence criteria<br />
self.conv_criteria = ParallelDisplacementCriteria(1e-4,1e-9) <br />
<br />
#######################################################################</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T23:19:43Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in python_scripts folder of your application:<br />
<br />
<br />
'''static_Element2D_solver_pardiso.py :'''<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
<br />
#######################################################################<br />
def __init__(self,model_part,domain_size):<br />
<br />
self.model_part = model_part<br />
self.time_scheme = ParallelResidualBasedIncrementalUpdateStaticScheme()<br />
<br />
<br />
self.Element2D_linear_solver = ParallelMKLPardisoSolver()<br />
<br />
<br />
#definition of the convergence criteria<br />
self.conv_criteria = ParallelDisplacementCriteria(1e-4,1e-9) <br />
<br />
#######################################################################</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T23:17:40Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in python_scripts folder of your application:<br />
<br />
<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
<br />
#######################################################################<br />
def __init__(self,model_part,domain_size):<br />
<br />
self.model_part = model_part<br />
self.time_scheme = ParallelResidualBasedIncrementalUpdateStaticScheme()<br />
<br />
<br />
self.FerroVCrack_linear_solver = ParallelMKLPardisoSolver()<br />
<br />
<br />
#definition of the convergence criteria<br />
self.conv_criteria = ParallelDisplacementCriteria(1e-4,1e-9) <br />
<br />
#######################################################################</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T23:16:58Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in python_scripts folder of your application:<br />
<br />
<br />
<br />
from KratosR1MKLSolversApplication import *<br />
<br />
<br />
#######################################################################<br />
def __init__(self,model_part,domain_size):<br />
<br />
self.model_part = model_part<br />
self.time_scheme = ParallelResidualBasedIncrementalUpdateStaticScheme()<br />
<br />
<br />
self.FerroVCrack_linear_solver = ParallelMKLPardisoSolver()<br />
<br />
<br />
#definition of the convergence criteria<br />
self.conv_criteria = ParallelDisplacementCriteria(1e-4,1e-9) <br />
<br />
#######################################################################</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T23:10:33Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in custom_python folder of your application:</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T18:43:09Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in the following line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python interface files. The first modification is in the solver file in custom_python folder of your application:<br />
<br />
<br />
----- To be continued</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T18:39:16Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of LHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application\external_includes folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a flag in this line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric<br />
<br />
In this case, we suppose real and symmetric matrices. The next step is to add Pardiso solver into your Python run file.</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T18:35:57Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''<br />
<br />
<br />
After modifing Jamroot, we should specify the type of RHS matrix which we use it in our solution. This can be done by refering to the following file in mkl_solvers_application folder and change the following flag:<br />
<br />
in '''mkl_solvers_application\external_includes\mkl_pardiso_solver.h'''<br />
<br />
Setting a value in this line <br />
<br />
MKL_INT mtype = 1; /* real and structurally symmetric*/<br />
<br />
This flag can be assigned according to different matrix structures:<br />
<br />
TYPE Matrix<br />
1 real and structurally symmetric<br />
2 real and symmetric positive definite<br />
-2 real and symmetric indefinite<br />
3 complex and structurally symmetric<br />
4 complex and Hermitian positive definite<br />
-4 complex and Hermitian indefinite<br />
6 complex and symmetric<br />
11 real and nonsymmetric<br />
13 complex and nonsymmetric</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T18:22:09Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel compiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
The next step is to activate two lines in Jamroot file to include the mkl_solvers_application in the list of applications for compilation and linking to Kratos. The following bold lines should be activated (removing #):<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T18:17:22Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should install intel MKL library on your computer and compile Kratos with Intel comiler, otherwise you can not use this solver. The first step is to introduce the path of installed intel MKL library on your computer :<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
##path to the mkl library (STRICTLY OPTIONAL)<br />
'''path-constant MKL_INCLUDE_DIR : /opt/intel/mkl/10.0.3.020/include/ ;'''<br />
'''path-constant MKL_LIB_DIR : /opt/intel/mkl/10.0.3.020/lib ;'''<br />
<br />
<br />
<br />
## MKL solvers: will not be compiled by default ###################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
'''use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;'''<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T18:13:42Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should compile Kratos with Intel comiler, otherwise you can not use this solver:<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################################<br />
## this requires intel MKL library installed properly on your system ##############<br />
<br />
use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T18:13:18Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation lines in the Jamfile and the command to compile Kratos. It is important that you should compile Kratos with Intel comiler, otherwise you can not use this solver:<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## MKL solvers: will not be compiled by default ###################################################<br />
## this requires intel MKL library (v. 10.0.1.014) installed properly on your system ##############<br />
<br />
use-project /kratos-prj/mkl_solvers_application : $(TOP)/applications/mkl_solvers_application ;<br />
<br />
<br />
# installation<br />
alias install :<br />
'''/kratos-prj/mkl_solvers_application//install'''</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T18:09:56Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation line in the Jamfile and the command to compile Kratos. It is important that you should compile Kratos with Intel comiler, otherwise you can not use this solver:<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
# installation<br />
alias install :<br />
/kratos-prj/mkl_solvers_application//install</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T18:09:38Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation line in the Jamfile and the command to compile Kratos. It is important that you should compile Kratos with Intel comiler, otherwise you can not use this solver:<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
# installation<br />
alias install :<br />
/kratos-prj/mkl_solvers_application//install</div>Amirbcnhttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parallel_Pardiso_solver_for_your_exampleHow to use parallel Pardiso solver for your example2009-03-10T18:09:26Z<p>Amirbcn: </p>
<hr />
<div>The package PARDISO is a thread-safe, high-performance, robust, memory efficient and easy to use software for solving large sparse symmetric and unsymmetric linear systems of equations on shared memory multiprocessors. The solver has has been licensed to thousands of researchers at international scientific laboratories and universities since its first release in 2004 [http://www.pardiso-project.org/]. You can use this parallel solver to solve the system of equations and matrices in Kratos. For this purpose, we present some modifications in your Python interface files which help you to solve your problems faster. The important thing is that you should have the new version of Kratos, which includes the folder of '''mkl_solvers_application''' in the applications. This folder contains Pardiso solver interface and if you activate it in the main Jamroot of Kratos, it will be automatically compiled and linked to Kratos. We mention the activation line in the Jamfile and the command to compile Kratos. It is important that you should compile Kratos with Intel comiler, otherwise you can not use this solver:<br />
<br />
<br />
'''Jamroot:'''<br />
<br />
## installation<br />
alias install :<br />
/kratos-prj/mkl_solvers_application//install</div>Amirbcn