https://kratos-wiki.cimne.upc.edu/index.php?title=Special:Contributions&feed=atom&deletedOnly=&limit=100&target=Rrossi&topOnly=KratosWiki - User contributions [en]2022-10-04T03:54:33ZFrom KratosWikiMediaWiki 1.17.0https://kratos-wiki.cimne.upc.edu/index.php/Kratos_TutorialsKratos Tutorials2016-06-03T15:00:00Z<p>Rrossi: /* Python Script */</p>
<hr />
<div>== New GiD interface ==<br />
This is the recommended version for end users. These tutorials use the ''nice'' GiD interface, which is more user-friendly but currently only supports the most common applications.<br />
<br />
* [https://kratos.cimne.upc.es/attachments/download/1297/0_kratos_workshop2014.zip Basic Tutorials]<br />
<br />
== Development GiD interface ==<br />
These tutorials are based on the ''development'' GiD interface, which is less user-friendly but supports all Kratos applications<br />
<br />
*[https://kratos.cimne.upc.es/attachments/download/1352/HowToRunAnExample_EulerianFreeSurfaceCode_v4.zip LevelSet_FreeSurface Analysis Tutorial and GiD Problem type] The zip file you donwload from this link contains the GiD problem type and the tutorial to use a code to treat free surface problems in presence or not of a porous medium (i.e. seepage is as well considered).<br />
* [https://kratos.cimne.upc.es/attachments/download/1354/HowToRunAnExample_NonNewtonianPT_v1.zip NonNewtonian_PFEM Analysis Tutorial] The zip file you donwload from this link contains the GiD problem type and the tutorial to use a code to solve Lagrangian Non-Newtonian problems with PFEM [http://www.cimne.com/pfem/].<br />
<br />
== Kratos Installation ==<br />
* [[Kratos Installation]]<br />
<br />
== Kratos Structure ==<br />
* [[Kratos Structure: Kernel and applications]]<br />
* [[Kratos Structure: Basic Components]]<br />
* [[Kratos Structure: Node and Nodal Data]]<br />
* [[Kratos Structure: Elements and Conditions]]<br />
* [[Kratos Structure: Mesh and ModelPart]]<br />
* [[Kratos Structure: Strategies and Processes]]<br />
* [[Kratos Structure: Workflow]]<br />
<br />
<br />
<br />
== Python Script ==<br />
* [[Python Script Tutorial: Getting Started]]<br />
* [[Python Script Tutorial: Hello Kratos]] <br />
* [[Python Script Tutorial: Reading ModelPart From Input File]]<br />
* [[Python Script Tutorial: Writing Output File]]<br />
* [[Python Script Tutorial: ModelPart Nodes and Nodal Data]]<br />
* [[Python Script Tutorial: ModelPart Elements and Conditions]]<br />
* [[Python Script Tutorial: Writing a JSon configuration file]]<br />
* [[Python Script Tutorial: Using Kratos Solvers]]<br />
* [[Python Script Tutorial: Main Solution]]<br />
* [[Python_Script_Tutorial:_Writing_a_JSon_configuration_file]]<br />
* [[Python Script Tutorial: Going for a unified script]]<br />
<br />
[[Category:Tutorials]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/Python_Script_Tutorial:_Going_for_a_unified_scriptPython Script Tutorial: Going for a unified script2016-06-02T19:13:36Z<p>Rrossi: </p>
<hr />
<div>The final step needed to solve an example is to run the "Main" script.<br />
<br />
In the previous section we described how a simple script can be mounted using the Kratos building blocks.<br />
In the practice it is convenient to have a "unified" script that looks essentially the same for <br />
problems of different sort. This is achieved by making use of the ProjectParameters mechanism in the configuration<br />
<br />
The main we currently employ is as follows<br />
<br />
from __future__ import print_function, absolute_import, division #makes KratosMultiphysics backward compatible with python 2.6 and 2.7<br />
<br />
#import kratos core and applications<br />
from KratosMultiphysics import *<br />
from KratosMultiphysics.SolidMechanicsApplication import *<br />
from KratosMultiphysics.StructuralMechanicsApplication import *<br />
from KratosMultiphysics.ExternalSolversApplication import *<br />
<br />
#### PARSING THE PARAMETERS ####<br />
parameter_file = open("ProjectParameters.json",'r')<br />
ProjectParameters = Parameters( parameter_file.read())<br />
<br />
#defining the model_part<br />
main_model_part = ModelPart(ProjectParameters["problem_data"]["model_part_name"].GetString())<br />
main_model_part.ProcessInfo.SetValue(DOMAIN_SIZE, ProjectParameters["problem_data"]["domain_size"].GetInt())<br />
<br />
###TODO replace this "model" for real one once available in kratos core<br />
Model = {ProjectParameters["problem_data"]["model_part_name"].GetString() : main_model_part}<br />
<br />
#construct the solver (main setting methods are located in the solver_module)<br />
solver_module = __import__(ProjectParameters["solver_settings"]["solver_type"].GetString())<br />
solver = solver_module.CreateSolver(main_model_part, ProjectParameters["solver_settings"])<br />
<br />
solver.AddVariables() #here we allocate the variables in the nodes<br />
solver.ImportModelPart() #here we import the data to the model part<br />
solver.AddDofs()<br />
<br />
#build sub_model_parts or submeshes (rearrange parts for the application of custom processes)<br />
##TODO: replace MODEL for the Kratos one ASAP<br />
##get the list of the submodel part in the object Model<br />
for i in range(ProjectParameters["solver_settings"]["processes_sub_model_part_list"].size()):<br />
part_name = ProjectParameters["solver_settings"]["processes_sub_model_part_list"][i].GetString()<br />
Model.update({part_name: main_model_part.GetSubModelPart(part_name)})<br />
<br />
#obtain the list of the processes to be applied<br />
import process_factory<br />
list_of_processes = process_factory.KratosProcessFactory(Model).ConstructListOfProcesses( ProjectParameters["constraints_process_list"] )<br />
list_of_processes += process_factory.KratosProcessFactory(Model).ConstructListOfProcesses( ProjectParameters["loads_process_list"] )<br />
<br />
#TODO: decide which is the correct place to initialize the processes <br />
for process in list_of_processes:<br />
process.ExecuteInitialize()<br />
<br />
computing_model_part = solver.GetComputeModelPart()<br />
<br />
# initialize GiD I/O (gid outputs, file_lists)<br />
from gid_output_process import GiDOutputProcess <br />
gid_output = GiDOutputProcess(computing_model_part,<br />
ProjectParameters["problem_data"]["problem_name"].GetString(),<br />
ProjectParameters["output_configuration"])<br />
<br />
gid_output.ExecuteInitialize()<br />
<br />
solver.Initialize()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteBeforeSolutionLoop()<br />
<br />
gid_output.ExecuteBeforeSolutionLoop()<br />
<br />
delta_time = ProjectParameters["problem_data"]["time_step"].GetDouble()<br />
step = 0<br />
time = ProjectParameters["problem_data"]["start_time"].GetDouble()<br />
end_time = ProjectParameters["problem_data"]["end_time"].GetDouble()<br />
<br />
while(time <= end_time):<br />
time = time + delta_time<br />
step = step + 1<br />
main_model_part.CloneTimeStep(time)<br />
<br />
for process in list_of_processes:<br />
process.ExecuteInitializeSolutionStep()<br />
<br />
gid_output.ExecuteInitializeSolutionStep()<br />
<br />
#here the solution is actually done<br />
solver.Solve()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteFinalizeSolutionStep()<br />
<br />
gid_output.ExecuteFinalizeSolutionStep()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteBeforeOutputStep()<br />
<br />
# write results <br />
if gid_output.IsOutputStep():<br />
gid_output.PrintOutput()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteAfterOutputStep()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteFinalize()<br />
<br />
# ending the problem (time integration finished)<br />
gid_output.ExecuteFinalize()<br />
<br />
This constitutes a working script that can be used for example to solve problems in structural mechanics. <br />
<br />
The script shown, which we consider as the "modern" way to solve the problem, presents two main differences<br />
with respect to a script that can be constructed by simply combining the building blocks:<br />
* The "solver" is put in charge of Importing the model part (read it from a file, from a restart file, or generate it from an existing model_part)<br />
* The idea of "process" is employed heavily in order to introduce standardized entry points to perform "operations".<br />
<br />
== The idea of "Processes" ==<br />
The idea behind the design of the Kratos processes is to '''standardize the application of "operations"''' over parts of the model, to be intended as groups of <br />
geometrical entitites.<br />
In this sense a "Process" shall thus be intended as the implementation of an "operation" (intended in a very broad sense) to be applied on a group<br />
of entities within the model (typically defined in kratos as a SubModelPart).<br />
The Process provides some standardized calls, to be performed in well defined positions within the simulation loop (think for example "ExecuteBeforeSolutionLoop").<br />
Internally a process could be easily implemented using the python scripting capabilities shown before, the advantage over the direct approach<br />
is that '''a catalogue of Processes can be developed over time''', so that one can provide a list of operations to be executed during the simulation.<br />
Some of them can be for example implemented in c++ to achieve a higher efficiency.<br />
<br />
The list of processes to be performed is described in the "ProjectParameters.json" as a list. The order of execution of the processes will match <br />
the order within the construction list.<br />
<br />
The Process API is given by the class "Process" defined in c++ by the header "includes/process.h". It is expected that all processes<br />
are derived from such base class so that they inherit its public API.<br />
<br />
The process API is :<br />
* ExecuteInitialize()<br />
* ExecuteBeforeSolutionLoop()<br />
* ExecuteInitializeSolutionStep()<br />
* ExecuteFinalizeSolutionStep()<br />
* ExecuteBeforeOutputStep()<br />
* ExecuteAfterOutputStep()<br />
* ExecuteFinalize()<br />
<br />
additionally a function <br />
* Execute() <br />
is defined as a place to implement specific operations</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/Python_Script_Tutorial:_Going_for_a_unified_scriptPython Script Tutorial: Going for a unified script2016-06-02T19:12:13Z<p>Rrossi: </p>
<hr />
<div>The final step needed to solve an example is to run the "Main" script.<br />
<br />
In the previous section we described how a simple script can be mounted using the Kratos building blocks.<br />
In the practice it is convenient to have a "unified" script that looks essentially the same for <br />
problems of different sort. This is achieved by making use of the ProjectParameters mechanism in the configuration<br />
<br />
The main we currently employ is as follows<br />
<br />
from __future__ import print_function, absolute_import, division #makes KratosMultiphysics backward compatible with python 2.6 and 2.7<br />
<br />
#import kratos core and applications<br />
from KratosMultiphysics import *<br />
from KratosMultiphysics.SolidMechanicsApplication import *<br />
from KratosMultiphysics.StructuralMechanicsApplication import *<br />
from KratosMultiphysics.ExternalSolversApplication import *<br />
<br />
#### PARSING THE PARAMETERS ####<br />
parameter_file = open("ProjectParameters.json",'r')<br />
ProjectParameters = Parameters( parameter_file.read())<br />
<br />
#defining the model_part<br />
main_model_part = ModelPart(ProjectParameters["problem_data"]["model_part_name"].GetString())<br />
main_model_part.ProcessInfo.SetValue(DOMAIN_SIZE, ProjectParameters["problem_data"]["domain_size"].GetInt())<br />
<br />
###TODO replace this "model" for real one once available in kratos core<br />
Model = {ProjectParameters["problem_data"]["model_part_name"].GetString() : main_model_part}<br />
<br />
#construct the solver (main setting methods are located in the solver_module)<br />
solver_module = __import__(ProjectParameters["solver_settings"]["solver_type"].GetString())<br />
solver = solver_module.CreateSolver(main_model_part, ProjectParameters["solver_settings"])<br />
<br />
solver.AddVariables() #here we allocate the variables in the nodes<br />
solver.ImportModelPart() #here we import the data to the model part<br />
solver.AddDofs()<br />
<br />
#build sub_model_parts or submeshes (rearrange parts for the application of custom processes)<br />
##TODO: replace MODEL for the Kratos one ASAP<br />
##get the list of the submodel part in the object Model<br />
for i in range(ProjectParameters["solver_settings"]["processes_sub_model_part_list"].size()):<br />
part_name = ProjectParameters["solver_settings"]["processes_sub_model_part_list"][i].GetString()<br />
Model.update({part_name: main_model_part.GetSubModelPart(part_name)})<br />
<br />
#obtain the list of the processes to be applied<br />
import process_factory<br />
list_of_processes = process_factory.KratosProcessFactory(Model).ConstructListOfProcesses( ProjectParameters["constraints_process_list"] )<br />
list_of_processes += process_factory.KratosProcessFactory(Model).ConstructListOfProcesses( ProjectParameters["loads_process_list"] )<br />
<br />
#TODO: decide which is the correct place to initialize the processes <br />
for process in list_of_processes:<br />
process.ExecuteInitialize()<br />
<br />
computing_model_part = solver.GetComputeModelPart()<br />
<br />
# initialize GiD I/O (gid outputs, file_lists)<br />
from gid_output_process import GiDOutputProcess <br />
gid_output = GiDOutputProcess(computing_model_part,<br />
ProjectParameters["problem_data"]["problem_name"].GetString(),<br />
ProjectParameters["output_configuration"])<br />
<br />
gid_output.ExecuteInitialize()<br />
<br />
solver.Initialize()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteBeforeSolutionLoop()<br />
<br />
gid_output.ExecuteBeforeSolutionLoop()<br />
<br />
delta_time = ProjectParameters["problem_data"]["time_step"].GetDouble()<br />
step = 0<br />
time = ProjectParameters["problem_data"]["start_time"].GetDouble()<br />
end_time = ProjectParameters["problem_data"]["end_time"].GetDouble()<br />
<br />
while(time <= end_time):<br />
time = time + delta_time<br />
step = step + 1<br />
main_model_part.CloneTimeStep(time)<br />
<br />
for process in list_of_processes:<br />
process.ExecuteInitializeSolutionStep()<br />
<br />
gid_output.ExecuteInitializeSolutionStep()<br />
<br />
#here the solution is actually done<br />
solver.Solve()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteFinalizeSolutionStep()<br />
<br />
gid_output.ExecuteFinalizeSolutionStep()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteBeforeOutputStep()<br />
<br />
# write results <br />
if gid_output.IsOutputStep():<br />
gid_output.PrintOutput()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteAfterOutputStep()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteFinalize()<br />
<br />
# ending the problem (time integration finished)<br />
gid_output.ExecuteFinalize()<br />
<br />
This constitutes a working script that can be used for example to solve problems in structural mechanics. <br />
<br />
The script shown, which we consider as the "modern" way to solve the problem, presents two main differences<br />
with respect to a script that can be constructed by simply combining the building blocks:<br />
1 - The "solver" is put in charge of Importing the model part (read it from a file, from a restart file, or generate it from an existing model_part)<br />
2 - The idea of "process" is employed heavily in order to introduce standardized entry points to perform "operations".<br />
<br />
== The idea of "Processes" ==<br />
The idea behind the design of the Kratos processes is to standardize the application of "operations" over parts of the model, to be intended as groups of <br />
geometrical entitites.<br />
In this sense a "Process" shall thus be intended as the implementation of an "operation" (intended in a very broad sense) to be applied on a group<br />
of entities within the model (typically defined in kratos as a SubModelPart).<br />
The Process provides some standardized calls, to be performed in well defined positions within the simulation loop (think for example "ExecuteBeforeSolutionLoop").<br />
Internally a process could be easily implemented using the python scripting capabilities shown before, the advantage over the direct approach<br />
is that a catalogue of Processes can be developed over time, so that one can provide a list of operations to be executed during the simulation.<br />
Some of them can be for example implemented in c++ to achieve a higher efficiency.<br />
<br />
The list of processes to be performed is described in the "ProjectParameters.json" as a list. The order of execution of the processes will match <br />
the order within the construction list.<br />
<br />
The Process API is given by the class "Process" defined in c++ by the header "includes/process.h". It is expected that all processes<br />
are derived from such base class so that they inherit its public API.<br />
<br />
The process API is :<br />
* ExecuteInitialize()<br />
* ExecuteBeforeSolutionLoop()<br />
* ExecuteInitializeSolutionStep()<br />
* ExecuteFinalizeSolutionStep()<br />
* ExecuteBeforeOutputStep()<br />
* ExecuteAfterOutputStep()<br />
* ExecuteFinalize()<br />
<br />
additionally a function <br />
* Execute() <br />
is defined as a place to implement specific operations</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/Python_Script_Tutorial:_Going_for_a_unified_scriptPython Script Tutorial: Going for a unified script2016-06-02T19:10:52Z<p>Rrossi: Created page with "The final step needed to solve an example is to run the "Main" script. In the previous section we described how a simple script can be mounted using the Kratos building blocks. ..."</p>
<hr />
<div>The final step needed to solve an example is to run the "Main" script.<br />
<br />
In the previous section we described how a simple script can be mounted using the Kratos building blocks.<br />
In the practice it is convenient to have a "unified" script that looks essentially the same for <br />
problems of different sort. This is achieved by making use of the ProjectParameters mechanism in the configuration<br />
<br />
The main we currently employ is as follows<br />
<br />
from __future__ import print_function, absolute_import, division #makes KratosMultiphysics backward compatible with python 2.6 and 2.7<br />
<br />
#import kratos core and applications<br />
from KratosMultiphysics import *<br />
from KratosMultiphysics.SolidMechanicsApplication import *<br />
from KratosMultiphysics.StructuralMechanicsApplication import *<br />
from KratosMultiphysics.ExternalSolversApplication import *<br />
<br />
#### PARSING THE PARAMETERS ####<br />
parameter_file = open("ProjectParameters.json",'r')<br />
ProjectParameters = Parameters( parameter_file.read())<br />
<br />
#defining the model_part<br />
main_model_part = ModelPart(ProjectParameters["problem_data"]["model_part_name"].GetString())<br />
main_model_part.ProcessInfo.SetValue(DOMAIN_SIZE, ProjectParameters["problem_data"]["domain_size"].GetInt())<br />
<br />
###TODO replace this "model" for real one once available in kratos core<br />
Model = {ProjectParameters["problem_data"]["model_part_name"].GetString() : main_model_part}<br />
<br />
#construct the solver (main setting methods are located in the solver_module)<br />
solver_module = __import__(ProjectParameters["solver_settings"]["solver_type"].GetString())<br />
solver = solver_module.CreateSolver(main_model_part, ProjectParameters["solver_settings"])<br />
<br />
solver.AddVariables() #here we allocate the variables in the nodes<br />
solver.ImportModelPart() #here we import the data to the model part<br />
solver.AddDofs()<br />
<br />
#build sub_model_parts or submeshes (rearrange parts for the application of custom processes)<br />
##TODO: replace MODEL for the Kratos one ASAP<br />
##get the list of the submodel part in the object Model<br />
for i in range(ProjectParameters["solver_settings"]["processes_sub_model_part_list"].size()):<br />
part_name = ProjectParameters["solver_settings"]["processes_sub_model_part_list"][i].GetString()<br />
Model.update({part_name: main_model_part.GetSubModelPart(part_name)})<br />
<br />
#obtain the list of the processes to be applied<br />
import process_factory<br />
list_of_processes = process_factory.KratosProcessFactory(Model).ConstructListOfProcesses( ProjectParameters["constraints_process_list"] )<br />
list_of_processes += process_factory.KratosProcessFactory(Model).ConstructListOfProcesses( ProjectParameters["loads_process_list"] )<br />
<br />
#TODO: decide which is the correct place to initialize the processes <br />
for process in list_of_processes:<br />
process.ExecuteInitialize()<br />
<br />
computing_model_part = solver.GetComputeModelPart()<br />
<br />
# initialize GiD I/O (gid outputs, file_lists)<br />
from gid_output_process import GiDOutputProcess <br />
gid_output = GiDOutputProcess(computing_model_part,<br />
ProjectParameters["problem_data"]["problem_name"].GetString(),<br />
ProjectParameters["output_configuration"])<br />
<br />
gid_output.ExecuteInitialize()<br />
<br />
solver.Initialize()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteBeforeSolutionLoop()<br />
<br />
gid_output.ExecuteBeforeSolutionLoop()<br />
<br />
delta_time = ProjectParameters["problem_data"]["time_step"].GetDouble()<br />
step = 0<br />
time = ProjectParameters["problem_data"]["start_time"].GetDouble()<br />
end_time = ProjectParameters["problem_data"]["end_time"].GetDouble()<br />
<br />
while(time <= end_time):<br />
time = time + delta_time<br />
step = step + 1<br />
main_model_part.CloneTimeStep(time)<br />
<br />
for process in list_of_processes:<br />
process.ExecuteInitializeSolutionStep()<br />
<br />
gid_output.ExecuteInitializeSolutionStep()<br />
<br />
#here the solution is actually done<br />
solver.Solve()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteFinalizeSolutionStep()<br />
<br />
gid_output.ExecuteFinalizeSolutionStep()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteBeforeOutputStep()<br />
<br />
# write results <br />
if gid_output.IsOutputStep():<br />
gid_output.PrintOutput()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteAfterOutputStep()<br />
<br />
for process in list_of_processes:<br />
process.ExecuteFinalize()<br />
<br />
# ending the problem (time integration finished)<br />
gid_output.ExecuteFinalize()<br />
<br />
This constitutes a working script that can be used for example to solve problems in structural mechanics. <br />
<br />
The script shown, which we consider as the "modern" way to solve the problem, presents two main differences<br />
with respect to a script that can be constructed by simply combining the building blocks:<br />
1 - The "solver" is put in charge of Importing the model part (read it from a file, from a restart file, or generate it from an existing model_part)<br />
2 - The idea of "process" is employed heavily in order to introduce standardized entry points to perform "operations".<br />
<br />
== The idea of "Processes" ==<br />
The idea behind the design of the Kratos processes is to standardize the application of "operations" over parts of the model, to be intended as groups of <br />
geometrical entitites.<br />
In this sense a "Process" shall thus be intended as the implementation of an "operation" (intended in a very broad sense) to be applied on a group<br />
of entities within the model (typically defined in kratos as a SubModelPart).<br />
The Process provides some standardized calls, to be performed in well defined positions within the simulation loop (think for example "ExecuteBeforeSolutionLoop").<br />
Internally a process could be easily implemented using the python scripting capabilities shown before, the advantage over the direct approach<br />
is that a catalogue of Processes can be developed over time, so that one can provide a list of operations to be executed during the simulation.<br />
Some of them can be for example implemented in c++ to achieve a higher efficiency.<br />
<br />
The list of processes to be performed is described in the "ProjectParameters.json" as a list. The order of execution of the processes will match <br />
the order within the construction list.<br />
<br />
The Process API is given by the class "Process" defined in c++ by the header "includes/process.h". It is expected that all processes<br />
are derived from such base class so that they inherit its public API.<br />
<br />
The process API is :<br />
* ExecuteInitialize()<br />
* ExecuteBeforeSolutionLoop()<br />
* ExecuteInitializeSolutionStep()<br />
* ExecuteFinalizeSolutionStep()<br />
* ExecuteBeforeOutputStep()<br />
* ExecuteAfterOutputStep()<br />
* ExecuteFinalize()<br />
<br />
additionally a function <br />
* Execute() <br />
is defined as a place to implement specific operations</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/Kratos_TutorialsKratos Tutorials2016-06-02T19:10:26Z<p>Rrossi: /* Python Script */</p>
<hr />
<div>== New GiD interface ==<br />
This is the recommended version for end users. These tutorials use the ''nice'' GiD interface, which is more user-friendly but currently only supports the most common applications.<br />
<br />
* [https://kratos.cimne.upc.es/attachments/download/1297/0_kratos_workshop2014.zip Basic Tutorials]<br />
<br />
== Development GiD interface ==<br />
These tutorials are based on the ''development'' GiD interface, which is less user-friendly but supports all Kratos applications<br />
<br />
*[https://kratos.cimne.upc.es/attachments/download/1352/HowToRunAnExample_EulerianFreeSurfaceCode_v4.zip LevelSet_FreeSurface Analysis Tutorial and GiD Problem type] The zip file you donwload from this link contains the GiD problem type and the tutorial to use a code to treat free surface problems in presence or not of a porous medium (i.e. seepage is as well considered).<br />
* [https://kratos.cimne.upc.es/attachments/download/1354/HowToRunAnExample_NonNewtonianPT_v1.zip NonNewtonian_PFEM Analysis Tutorial] The zip file you donwload from this link contains the GiD problem type and the tutorial to use a code to solve Lagrangian Non-Newtonian problems with PFEM [http://www.cimne.com/pfem/].<br />
<br />
== Kratos Installation ==<br />
* [[Kratos Installation]]<br />
<br />
== Kratos Structure ==<br />
* [[Kratos Structure: Kernel and applications]]<br />
* [[Kratos Structure: Basic Components]]<br />
* [[Kratos Structure: Node and Nodal Data]]<br />
* [[Kratos Structure: Elements and Conditions]]<br />
* [[Kratos Structure: Mesh and ModelPart]]<br />
* [[Kratos Structure: Strategies and Processes]]<br />
* [[Kratos Structure: Workflow]]<br />
<br />
<br />
<br />
== Python Script ==<br />
* [[Python Script Tutorial: Getting Started]]<br />
* [[Python Script Tutorial: Hello Kratos]] <br />
* [[Python Script Tutorial: Reading ModelPart From Input File]]<br />
* [[Python Script Tutorial: Writing Output File]]<br />
* [[Python Script Tutorial: ModelPart Nodes and Nodal Data]]<br />
* [[Python Script Tutorial: ModelPart Elements and Conditions]]<br />
* [[Python Script Tutorial: Writing a JSon configuration file]]<br />
* [[Python Script Tutorial: Using Kratos Solvers]]<br />
* [[Python Script Tutorial: Main Solution]]<br />
* [[Python Script Tutorial: Going for a unified script]]<br />
<br />
[[Category:Tutorials]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parametersHow to use parameters2016-06-02T07:50:02Z<p>Rrossi: </p>
<hr />
<div>please take a look at the link [[http://kratos-wiki.cimne.upc.edu/index.php/Python_Script_Tutorial:_Writing_a_JSon_configuration_file]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_parametersHow to use parameters2016-06-02T07:49:44Z<p>Rrossi: Created page with "please take a look at the link http://kratos-wiki.cimne.upc.edu/index.php/Python_Script_Tutorial:_Writing_a_JSon_configuration_file"</p>
<hr />
<div>please take a look at the link<br />
<br />
[[http://kratos-wiki.cimne.upc.edu/index.php/Python_Script_Tutorial:_Writing_a_JSon_configuration_file]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/HOW_TOsHOW TOs2016-06-02T07:49:22Z<p>Rrossi: /* Python */</p>
<hr />
<div>This section is intended as a list of "recipes" for common needs in using the Kratos<br />
<br />
== General ==<br />
* [[LinuxInstall | Installing kratos in Ubuntu Linux ]]<br />
* [[Windows 7 Download and Installation | Installing kratos in Windows]]<br />
* [[Install Kratos in OS X El Capitan (OS X 10.11) | Installing kratos in Mac OS X El Capitan]]<br />
<!-- * [[MacOSX Installation]] (Leopard) --><br />
<!-- * [[How to get Kratos]] --> <br />
<!-- * [[How to Compile Kratos]] --><br />
* [[How to Compile Kratos on the Acuario Cluster]]<br />
* [[How to Check Kratos is Correctly Installed in Windows]]<br />
* [[How to Check Kratos is Correctly Installed in Linux]]<br />
* [[How to subscribe to Kratos' mailing list]]<br />
* [[How to Profile an application (using google-perftools)]]<br />
* [[How to Measure memory consumption (using google-perftools)]]<br />
* [[How to work with Groups (Meshes)]]<br />
* [[How to make my application derivable]]<br />
<!--* [[Working]]--><br />
<!--* [[Working_kernel]]--><br />
<br />
== OpenMP Parallelism ==<br />
* [[How to Learn OpenMP]]<br />
* [[How to "survive" OpenMP parallelism]]<br />
* [[How to force a scalar run]]<br />
<br />
== MPI Parallelism ==<br />
* [[How to run your application in cluster]]<br />
* [[How to compile the Boost if you want to use MPI]]<br />
* [[How to use communicator for parallel synchronization]]<br />
<br />
== OpenCL Parallelism ==<br />
* [[Introduction to OpenCL Programming]]<br />
* [[Useful OpenCL links]]<br />
* [[How to set up OpenCL]]<br />
* [[How to debug OpenCL programs using GDB]]<br />
* [[Support for double-precision floating point basic arithmetic in ATI Stream SDK (2.1 and later)]]<br />
<br />
== Python ==<br />
'''General Python Use for Kratos'''<br />
* [[How to use Python]]<br />
* [[How to Use an Application]]<br />
* [[How to use parameters]]<br />
* [[How to import Kratos from Python using the KratosMultiphysics module]]<br />
* [[How to work with nodes and elements in python]]<br />
* [[How to use multiple model parts]]<br />
* [[How to construct a linear solver using the "Linear Solver Factory"]]<br />
* [[How to construct the "solving strategies"]]<br />
* [[How to create unitary tests]]<br />
* [[How to create a new application]]<br />
* [[strategy_python]]<br />
* [[Operations]]<br />
* [[How to acess the values of a Table]]<br />
'''Input/Output and GiD'''<br />
* [[How to read a mdpa file]]<br />
* [[How to use the GidIO]]<br />
* [[How to read a data file]]<br />
* [[How to plot graphs]]<br />
* [[How to create the problem_type.gid folder with the new problem type generator]]<br />
* [[How to use the Isosurface Node Printer]]<br />
'''Calculation tips for Kratos feasible from Python'''<br />
* [[How to Calculate Distance Function]]<br />
* [[How to Calculate Normals]]<br />
* [[How to execute an FFT analysis]]<br />
* [[How to execute fitting of data series]]<br />
* [[How to run python recursively]]<br />
* [[How to execute a SVD analysis]]<br />
* [[How to add automatic benchmarking to your example]]<br />
* [[How to use parallel Pardiso solver for your example]]<br />
* [[How to use the projection between no matching meshes]]<br />
* [[How to use the ReduceTimeStep]]<br />
* [[How to transfer nodal values between non-matching meshes]]<br />
* [[How to use the OpenCL linear solvers]]<br />
* [[How to refine an existing triangular or tetrahedral mesh]]<br />
<!-- * [[How to include the restart in python]] --><br />
* [[How to use the Cutting Application (Serial and Parallel)]]<br />
* [[How to use external linear solvers and preconditioners]]<br />
* [[How to create a restart (python) file]]<br />
* [[How to use the Cutting Isosurface Application]]<br />
* [[How to access a value in a 'Properties' block]]<br />
<br />
== C++ ==<br />
* [[How to use the Constitutive Law class]]<br />
* [[How to use "Smart Pointers" within Kratos]]<br />
* [[How to Use the ModelPart]]<br />
* [[How to Use the Meshes as Group]]<br />
* [[How to Add and Delete Components (Nodes, Elements, ...) from ModelPart]]<br />
* [[How to Access Neighbor Nodes and Elements]]<br />
* [[How to Access DataBase]]<br />
* [[How to Create a New Application using cmake]]<br />
* [[How to Create New Element]]<br />
* [[How to use the geometry within an element]]<br />
* [[How to Use Solving Strategy]]<br />
* [[How to understand Kratos Pointers]]<br />
* [[How to Use the std::vector (and the kratos containers)]]<br />
* [[How to Use Ublas]]<br />
* [[How to Export Function/Classes to the Python]]<br />
* [[How to Interpolate Data]]<br />
* [[How to Compile Kratos in Debug mode]]<br />
* [[How to debug with valgrind]]<br />
* [[How to Add a Custom_Utilities File]]<br />
* [[How to Create a GiD Problem Type]]<br />
* [[How to Add a New Element (Condition)]]<br />
* [[How to Add a New constitutive law]]<br />
* [[How to Add a New Variable]]<br />
* [[How to use the Geometry]]<br />
* [[How to Create Multi-step Elements]]<br />
* [[How to use push_back]]<br />
* [[How to Create a executable without Python]]<br />
* [[How to apply face pressures]]<br />
* [[How to print values on Gauss points]]<br />
* [[How to use Serialization]]<br />
* [[How to Search neighbors]]<br />
* [[How to use Doxygen to generate documentation for our code]]<br />
* [[News for constitutive laws]]<br />
* [[strategy_python]]<br />
* [[Compiling lapack++ for 64 bit Windows]]<br />
* [[Common errors ]]<br />
* [[Some aspects of programing]]<br />
* [[How to use the Spatial Containers]]<br />
* [[How to solve linker errors]]<br />
<br />
== Debbuging and optimizing your code ==<br />
* [[Debugging the Application]]<br />
* [[Profiling the Kratos]]<br />
* [[How to Profile (Measure Time Consumption)]]<br />
* [[Checking memory use with Valgrind]]<br />
<br />
== Graphical User Interfaces ==<br />
* [[How the GiD Graphical User Interface communicates with Kratos]]<br />
<br />
<br />
<br />
<!--== Theory Manual ==<br />
* [[GeneralTemplate]]<br />
* [[MiguelAngel]]<br />
* [[Kazem]]<br />
* [[Computational Fluid Dynamic Module (CFDm)]]<br />
* [[CFDm 1.Introduction]]<br />
* [[CFDm 2.Structure]]<br />
* [[CFDm 2.1.Fluid Types]]<br />
* [[CFDm 2.2.Kinematical Approaches]]<br />
* [[CFDm 2.3.Solution Strategies]]<br />
* [[CFDm 2.4.Elements]]<br />
* [[CFDm 2.5.Boundary Conditions]]<br />
* [[CFDm 2.6.Initial Conditions]]<br />
* [[CFDm 2.7.Turbulence Models]]<br />
* [[CFDm 2.8.HPC]]<br />
* [[CFDm 2.9.Problem Parameters]]<br />
* [[CFDm 2.10.Other Relevant Aspects]]<br />
* [[CFDm 3.Benchmarking]]<br />
* [[CFDm 4.Tutorials]]<br />
* [[CFDm 5.Contact People]]<br />
* [[CFDm 6.Aknowledgements]]<br />
* [[Computational Structural Mechanics Module (CSMm)]]<br />
* [[CSMm 1.Introduction]]<br />
* [[CSMm 2.Structure]]<br />
* [[CSMm 2.1.Analysis Type]]<br />
* [[CSMm 2.2.Elements]]<br />
* [[CSMm 2.3.Boundary Conditions]]<br />
* [[CSMm 2.4.Loads]]<br />
* [[CSMm 2.5.Constitutive Laws]]<br />
* [[CSMm 2.6.HPC]]<br />
* [[CSMm 2.7.Problem Parameters]]<br />
* [[CSMm 2.8.Other Relevant Aspects]]<br />
* [[CSMm 3.Benchmarking]]<br />
* [[CSMm 4.Tutorials]]<br />
* [[CSMm 5.Contact People]]<br />
* [[CSMm 6.Aknowledgements]]<br />
* [[Convection Diffusion Module (CDm)]]<br />
* [[CDm 1.Introduction]]<br />
* [[CDm 2.Structure]]<br />
* [[CDm 2.1.Analysis type]]<br />
* [[CDm 2.2.Kinematical Approaches]]<br />
* [[CDm 2.3.Solution Strategies]]<br />
* [[CDm 2.4.Elements]]<br />
* [[CDm 2.5.Boundary Conditions]]<br />
* [[CDm 2.6.Initial Conditions]]<br />
* [[CDm 2.7.HPC]]<br />
* [[CDm 2.8.Problem Parameters]]<br />
* [[CDm 2.9.Other Relevant Aspects]]<br />
* [[CDm 3.Benchmarking]]<br />
* [[CDm 4.Tutorials]]<br />
* [[CDm 5.Contact People]]<br />
* [[CDm 6.Aknowledgements]]<br />
<br />
<br />
[[Category: Theory Manual]]--></div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/Python_Script_Tutorial:_Writing_a_JSon_configuration_filePython Script Tutorial: Writing a JSon configuration file2016-06-02T07:45:57Z<p>Rrossi: </p>
<hr />
<div>As complexity increases one needs more and more flexibility in “configuring” a simulation. This is typically achieved by <br />
defining a "configuration file" which organizes all of the "user instructions" to be used in the configuration of the solver.<br />
<br />
Some requirements for this configuration are:<br />
* Must allow nesting of parameters (tree-like structure)<br />
* Should allow using default values<br />
* Must allow some form of type checking<br />
* Should permit to echo all of the defaults in a single place <br />
<br />
In order to meet such requirements Kratos introduces a "Parameters" object, which provides a thin wrapper to JSon strings.<br />
<br />
The typical structure of a JSon file is like the following:<br />
{<br />
"problem_data" : {<br />
"problem_name" : "minimal_structure",<br />
"model_part_name" : "Structure",<br />
"domain_size" : 2,<br />
"time_step" : 1.1,<br />
"start_time" : 0.0,<br />
"end_time" : 1.0,<br />
"echo_level" : 0<br />
},<br />
"solver_settings" : {<br />
"solver_type" : "solid_mechanics_static_solver",<br />
"echo_level" : 0,<br />
"solution_type" : "Static",<br />
"analysis_type" : "Linear",<br />
"model_import_settings" : {<br />
"input_type" : "mdpa",<br />
"input_filename" : "minimal_structure"<br />
},<br />
"line_search" : false,<br />
"convergence_criterion" : "Residual_criterion",<br />
"displacement_relative_tolerance" : 0.0001,<br />
"displacement_absolute_tolerance" : 1e-9,<br />
"residual_relative_tolerance" : 0.0001,<br />
"residual_absolute_tolerance" : 1e-9,<br />
"max_iteration" : 10,<br />
"linear_solver_settings" : {<br />
"solver_type" : "Super_LU",<br />
"scaling" : false,<br />
"verbosity" : 0<br />
},<br />
"problem_domain_sub_model_part_list" : ["Parts_Parts_Auto2"],<br />
"processes_sub_model_part_list" : ["DISPLACEMENT_Displacement_Auto1","SelfWeight2D_Self_weight_Auto1"],<br />
"rotation_dofs" : false<br />
},<br />
"constraints_process_list" : [{<br />
"implemented_in_file" : "impose_vector_value_by_components_process",<br />
"implemented_in_module" : "KratosMultiphysics",<br />
"help" : "This process fixes the selected components of a given vector variable",<br />
"process_name" : "ImposeVectorValueByComponentsProcess",<br />
"Parameters" : {<br />
"mesh_id" : 0,<br />
"model_part_name" : "DISPLACEMENT_Displacement_Auto1",<br />
"variable_name" : "DISPLACEMENT",<br />
"is_fixed_x" : true,<br />
"is_fixed_y" : true,<br />
"is_fixed_z" : true,<br />
"value" : [0.0,0.0,0.0]<br />
}<br />
}],<br />
"loads_process_list" : [{<br />
"implemented_in_file" : "process_factory",<br />
"implemented_in_module" : "KratosMultiphysics",<br />
"check" : "DirectorVectorNonZero direction",<br />
"help" : "This process ",<br />
"process_name" : "ApplyConstantVectorValueProcess",<br />
"Parameters" : {<br />
"mesh_id" : 0,<br />
"model_part_name" : "SelfWeight2D_Self_weight_Auto1",<br />
"variable_name" : "VOLUME_ACCELERATION",<br />
"factor" : 9.8,<br />
"direction" : [10.0,0.0,0.0]<br />
}<br />
}],<br />
"output_configuration" : {<br />
"result_file_configuration" : {<br />
"gidpost_flags" : {<br />
"GiDPostMode" : "GiD_PostBinary",<br />
"WriteDeformedMeshFlag" : "WriteDeformed",<br />
"WriteConditionsFlag" : "WriteConditions",<br />
"MultiFileFlag" : "SingleFile"<br />
},<br />
"file_label" : "step",<br />
"output_control_type" : "step",<br />
"output_frequency" : 1.0,<br />
"body_output" : true,<br />
"node_output" : false,<br />
"skin_output" : false,<br />
"plane_output" : [],<br />
"nodal_results" : ["DISPLACEMENT","REACTION"],<br />
"gauss_point_results" : ["VON_MISES_STRESS"]<br />
},<br />
"point_data_configuration" : []<br />
},<br />
"restart_options" : {<br />
"SaveRestart" : false,<br />
"RestartFrequency" : 0,<br />
"LoadRestart" : false,<br />
"Restart_Step" : 0<br />
},<br />
"constraints_data" : {<br />
"incremental_load" : false,<br />
"incremental_displacement" : false<br />
}<br />
}<br />
<br />
Such text shall be read to an "input_string" which is then parsed and stored within a "Parameters" object<br />
<br />
this is done in python as <br />
input_string = open("ProjectParameters.json",'r').read()<br />
settings = Parameters( input_string )<br />
<br />
the settings object now behaves effectively as a combination of lists and dictionaries, for example one can obtain<br />
the name of the problem to be solved as <br />
name = settings["problem_data"]["problem_name"].GetString()<br />
<br />
an important aspect of this is that the user is expected to ask specifically for the type to be provided<br />
For the case at hand (the name) one is asking for the item "settings["problem_data"]["problem_name"]" to be provided as a string by calling the "GetString()" method.<br />
<br />
similarly one can call<br />
* GetInt()/SetInt(...)<br />
* GetDouble()/SetDouble(...)<br />
* GetBool()/SetBool(...)<br />
* GetString()/SetString(...)<br />
<br />
the type can be queried by the functions<br />
* IsInt()<br />
* IsDouble()<br />
* IsBool()<br />
* IsString()<br />
* IsArray()<br />
* IsSubParameter()<br />
<br />
In the case of an array item the function "size()" is provided, and the different entries can be accessed by the [] operator. Note that each entry may have a different type and <br />
the GetXXX() method shall be used even for array entries.<br />
<br />
new values can be added to the "settings" by doing <br />
settings.AddEmptyValue("item_name")<br />
settings["item_name"].SetDouble(1.0) #this would set the new item to the value of 1.0<br />
<br />
entire parameter lists can be addeded by the function<br />
settings.AddValue("subparameter_name", other_parameters_object)<br />
<br />
at any point one can obtain a formatted echo of the "settings" by doing<br />
print(settings.PrettyPrintJsonString())<br />
<br />
a compact version, without any extra character (useful for example for serialization) can be obtained by doing<br />
settings.WriteJsonString()</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/Python_Script_Tutorial:_Writing_a_JSon_configuration_filePython Script Tutorial: Writing a JSon configuration file2016-06-02T07:41:14Z<p>Rrossi: </p>
<hr />
<div>As complexity increases one needs more and more flexibility in “configuring” a simulation. This is typically achieved by <br />
defining a "configuration file" which organizes all of the "user instructions" to be used in the configuration of the solver.<br />
<br />
Some requirements for this configuration are:<br />
* Must allow nesting of parameters (tree-like structure)<br />
* Should allow using default values<br />
* Must allow some form of type checking<br />
* Should permit to echo all of the defaults in a single place <br />
<br />
In order to meet such requirements Kratos introduces a "Parameters" object, which provides a thin wrapper to JSon strings.<br />
<br />
The typical structure of a JSon file is like the following:<br />
{<br />
"problem_data" : {<br />
"problem_name" : "minimal_structure",<br />
"model_part_name" : "Structure",<br />
"domain_size" : 2,<br />
"time_step" : 1.1,<br />
"start_time" : 0.0,<br />
"end_time" : 1.0,<br />
"echo_level" : 0<br />
},<br />
"solver_settings" : {<br />
"solver_type" : "solid_mechanics_static_solver",<br />
"echo_level" : 0,<br />
"solution_type" : "Static",<br />
"analysis_type" : "Linear",<br />
"model_import_settings" : {<br />
"input_type" : "mdpa",<br />
"input_filename" : "minimal_structure"<br />
},<br />
"line_search" : false,<br />
"convergence_criterion" : "Residual_criterion",<br />
"displacement_relative_tolerance" : 0.0001,<br />
"displacement_absolute_tolerance" : 1e-9,<br />
"residual_relative_tolerance" : 0.0001,<br />
"residual_absolute_tolerance" : 1e-9,<br />
"max_iteration" : 10,<br />
"linear_solver_settings" : {<br />
"solver_type" : "Super_LU",<br />
"scaling" : false,<br />
"verbosity" : 0<br />
},<br />
"problem_domain_sub_model_part_list" : ["Parts_Parts_Auto2"],<br />
"processes_sub_model_part_list" : ["DISPLACEMENT_Displacement_Auto1","SelfWeight2D_Self_weight_Auto1"],<br />
"rotation_dofs" : false<br />
},<br />
"constraints_process_list" : [{<br />
"implemented_in_file" : "impose_vector_value_by_components_process",<br />
"implemented_in_module" : "KratosMultiphysics",<br />
"help" : "This process fixes the selected components of a given vector variable",<br />
"process_name" : "ImposeVectorValueByComponentsProcess",<br />
"Parameters" : {<br />
"mesh_id" : 0,<br />
"model_part_name" : "DISPLACEMENT_Displacement_Auto1",<br />
"variable_name" : "DISPLACEMENT",<br />
"is_fixed_x" : true,<br />
"is_fixed_y" : true,<br />
"is_fixed_z" : true,<br />
"value" : [0.0,0.0,0.0]<br />
}<br />
}],<br />
"loads_process_list" : [{<br />
"implemented_in_file" : "process_factory",<br />
"implemented_in_module" : "KratosMultiphysics",<br />
"check" : "DirectorVectorNonZero direction",<br />
"help" : "This process ",<br />
"process_name" : "ApplyConstantVectorValueProcess",<br />
"Parameters" : {<br />
"mesh_id" : 0,<br />
"model_part_name" : "SelfWeight2D_Self_weight_Auto1",<br />
"variable_name" : "VOLUME_ACCELERATION",<br />
"factor" : 9.8,<br />
"direction" : [10.0,0.0,0.0]<br />
}<br />
}],<br />
"output_configuration" : {<br />
"result_file_configuration" : {<br />
"gidpost_flags" : {<br />
"GiDPostMode" : "GiD_PostBinary",<br />
"WriteDeformedMeshFlag" : "WriteDeformed",<br />
"WriteConditionsFlag" : "WriteConditions",<br />
"MultiFileFlag" : "SingleFile"<br />
},<br />
"file_label" : "step",<br />
"output_control_type" : "step",<br />
"output_frequency" : 1.0,<br />
"body_output" : true,<br />
"node_output" : false,<br />
"skin_output" : false,<br />
"plane_output" : [],<br />
"nodal_results" : ["DISPLACEMENT","REACTION"],<br />
"gauss_point_results" : ["VON_MISES_STRESS"]<br />
},<br />
"point_data_configuration" : []<br />
},<br />
"restart_options" : {<br />
"SaveRestart" : false,<br />
"RestartFrequency" : 0,<br />
"LoadRestart" : false,<br />
"Restart_Step" : 0<br />
},<br />
"constraints_data" : {<br />
"incremental_load" : false,<br />
"incremental_displacement" : false<br />
}<br />
}<br />
<br />
Such text shall be read to an "input_string" which is then parsed and stored within a "Parameters" object<br />
<br />
this is done in python as <br />
input_string = open("ProjectParameters.json",'r').read()<br />
settings = Parameters( input_string )<br />
<br />
the settings object now behaves effectively as a combination of lists and dictionaries, for example one can obtain<br />
the name of the problem to be solved as <br />
name = settings["problem_data"]["problem_name"].GetString()<br />
<br />
an important aspect of this is that the user is expected to ask specifically for the type to be provided<br />
For the case at hand (the name) one is asking for the item "settings["problem_data"]["problem_name"]" to be provided as a string by calling the "GetString()" method.<br />
<br />
similarly one can call<br />
* GetInt()/SetInt()<br />
* GetDouble()/SetDouble()<br />
* GetBool()/SetBool()<br />
* GetString()/SetString()<br />
<br />
the type can be queried by the functions<br />
* IsInt()<br />
* IsDouble()<br />
* IsBool()<br />
* IsString()<br />
* IsArray()<br />
* IsSubParameter()<br />
<br />
In the case of an array item the function "Size()" is provided, and the different entries can be accessed by the [] operator. Note that each entry may have a different type and <br />
the GetXXX() method shall be used even for array entries.</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/Python_Script_Tutorial:_Writing_a_JSon_configuration_filePython Script Tutorial: Writing a JSon configuration file2016-06-02T07:39:47Z<p>Rrossi: </p>
<hr />
<div>As complexity increases one needs more and more flexibility in “configuring” a simulation. This is typically achieved by <br />
defining a "configuration file" which organizes all of the "user instructions" to be used in the configuration of the solver.<br />
<br />
Some requirements for this configuration are:<br />
* Must allow nesting of parameters (tree-like structure)<br />
* Should allow using default values<br />
* Must allow some form of type checking<br />
* Should permit to echo all of the defaults in a single place <br />
<br />
In order to meet such requirements Kratos introduces a "Parameters" object, which provides a thin wrapper to JSon strings.<br />
<br />
The typical structure of a JSon file is like the following:<br />
{<br />
"problem_data" : {<br />
"problem_name" : "minimal_structure",<br />
"model_part_name" : "Structure",<br />
"domain_size" : 2,<br />
"time_step" : 1.1,<br />
"start_time" : 0.0,<br />
"end_time" : 1.0,<br />
"echo_level" : 0<br />
},<br />
"solver_settings" : {<br />
"solver_type" : "solid_mechanics_static_solver",<br />
"echo_level" : 0,<br />
"solution_type" : "Static",<br />
"analysis_type" : "Linear",<br />
"model_import_settings" : {<br />
"input_type" : "mdpa",<br />
"input_filename" : "minimal_structure"<br />
},<br />
"line_search" : false,<br />
"convergence_criterion" : "Residual_criterion",<br />
"displacement_relative_tolerance" : 0.0001,<br />
"displacement_absolute_tolerance" : 1e-9,<br />
"residual_relative_tolerance" : 0.0001,<br />
"residual_absolute_tolerance" : 1e-9,<br />
"max_iteration" : 10,<br />
"linear_solver_settings" : {<br />
"solver_type" : "Super_LU",<br />
"scaling" : false,<br />
"verbosity" : 0<br />
},<br />
"problem_domain_sub_model_part_list" : ["Parts_Parts_Auto2"],<br />
"processes_sub_model_part_list" : ["DISPLACEMENT_Displacement_Auto1","SelfWeight2D_Self_weight_Auto1"],<br />
"rotation_dofs" : false<br />
},<br />
"constraints_process_list" : [{<br />
"implemented_in_file" : "impose_vector_value_by_components_process",<br />
"implemented_in_module" : "KratosMultiphysics",<br />
"help" : "This process fixes the selected components of a given vector variable",<br />
"process_name" : "ImposeVectorValueByComponentsProcess",<br />
"Parameters" : {<br />
"mesh_id" : 0,<br />
"model_part_name" : "DISPLACEMENT_Displacement_Auto1",<br />
"variable_name" : "DISPLACEMENT",<br />
"is_fixed_x" : true,<br />
"is_fixed_y" : true,<br />
"is_fixed_z" : true,<br />
"value" : [0.0,0.0,0.0]<br />
}<br />
}],<br />
"loads_process_list" : [{<br />
"implemented_in_file" : "process_factory",<br />
"implemented_in_module" : "KratosMultiphysics",<br />
"check" : "DirectorVectorNonZero direction",<br />
"help" : "This process ",<br />
"process_name" : "ApplyConstantVectorValueProcess",<br />
"Parameters" : {<br />
"mesh_id" : 0,<br />
"model_part_name" : "SelfWeight2D_Self_weight_Auto1",<br />
"variable_name" : "VOLUME_ACCELERATION",<br />
"factor" : 9.8,<br />
"direction" : [10.0,0.0,0.0]<br />
}<br />
}],<br />
"output_configuration" : {<br />
"result_file_configuration" : {<br />
"gidpost_flags" : {<br />
"GiDPostMode" : "GiD_PostBinary",<br />
"WriteDeformedMeshFlag" : "WriteDeformed",<br />
"WriteConditionsFlag" : "WriteConditions",<br />
"MultiFileFlag" : "SingleFile"<br />
},<br />
"file_label" : "step",<br />
"output_control_type" : "step",<br />
"output_frequency" : 1.0,<br />
"body_output" : true,<br />
"node_output" : false,<br />
"skin_output" : false,<br />
"plane_output" : [],<br />
"nodal_results" : ["DISPLACEMENT","REACTION"],<br />
"gauss_point_results" : ["VON_MISES_STRESS"]<br />
},<br />
"point_data_configuration" : []<br />
},<br />
"restart_options" : {<br />
"SaveRestart" : false,<br />
"RestartFrequency" : 0,<br />
"LoadRestart" : false,<br />
"Restart_Step" : 0<br />
},<br />
"constraints_data" : {<br />
"incremental_load" : false,<br />
"incremental_displacement" : false<br />
}<br />
}<br />
<br />
Such text shall be read to an "input_string" which is then parsed and stored within a "Parameters" object<br />
<br />
this is done in python as <br />
input_string = open("ProjectParameters.json",'r').read()<br />
settings = Parameters( input_string )<br />
<br />
the settings object now behaves effectively as a combination of lists and dictionaries, for example one can obtain<br />
the name of the problem to be solved as <br />
name = settings["problem_data"]["problem_name"].GetString()<br />
<br />
an important aspect of this is that the user is expected to ask specifically for the type to be provided<br />
For the case at hand (the name) one is asking for the item "settings["problem_data"]["problem_name"]" to be provided as a string by calling the "GetString()" method.<br />
<br />
similarly one can call<br />
* GetInt()<br />
* GetDouble()<br />
* GetBool()<br />
* GetString()<br />
<br />
the type can be queried by the functions<br />
* IsInt()<br />
* IsDouble()<br />
* IsBool()<br />
* IsString()<br />
* IsArray()<br />
<br />
In the case of an array item the function "Size()" is provided, and the different entries can be accessed by the [] operator. Note that each entry may have a different type and <br />
the GetXXX() method shall be used even for array entries.</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/Python_Script_Tutorial:_Writing_a_JSon_configuration_filePython Script Tutorial: Writing a JSon configuration file2016-06-02T07:37:40Z<p>Rrossi: </p>
<hr />
<div>As complexity increases one needs more and more flexibility in “configuring” a simulation. This is typically achieved by <br />
defining a "configuration file" which organizes all of the "user instructions" to be used in the configuration of the solver.<br />
<br />
Some requirements for this configuration are:<br />
* Must allow nesting of parameters (tree-like structure)<br />
* Should allow using default values<br />
* Must allow some form of type checking<br />
* Should permit to echo all of the defaults in a single place <br />
<br />
In order to meet such requirements Kratos introduces a "Parameters" object, which provides a thin wrapper to JSon strings.<br />
<br />
The typical structure of a JSon file is like the following:<br />
{<br />
"problem_data" : {<br />
"problem_name" : "minimal_structure",<br />
"model_part_name" : "Structure",<br />
"domain_size" : 2,<br />
"time_step" : 1.1,<br />
"start_time" : 0.0,<br />
"end_time" : 1.0,<br />
"echo_level" : 0<br />
},<br />
"solver_settings" : {<br />
"solver_type" : "solid_mechanics_static_solver",<br />
"echo_level" : 0,<br />
"solution_type" : "Static",<br />
"analysis_type" : "Linear",<br />
"model_import_settings" : {<br />
"input_type" : "mdpa",<br />
"input_filename" : "minimal_structure"<br />
},<br />
"line_search" : false,<br />
"convergence_criterion" : "Residual_criterion",<br />
"displacement_relative_tolerance" : 0.0001,<br />
"displacement_absolute_tolerance" : 1e-9,<br />
"residual_relative_tolerance" : 0.0001,<br />
"residual_absolute_tolerance" : 1e-9,<br />
"max_iteration" : 10,<br />
"linear_solver_settings" : {<br />
"solver_type" : "Super_LU",<br />
"scaling" : false,<br />
"verbosity" : 0<br />
},<br />
"problem_domain_sub_model_part_list" : ["Parts_Parts_Auto2"],<br />
"processes_sub_model_part_list" : ["DISPLACEMENT_Displacement_Auto1","SelfWeight2D_Self_weight_Auto1"],<br />
"rotation_dofs" : false<br />
},<br />
"constraints_process_list" : [{<br />
"implemented_in_file" : "impose_vector_value_by_components_process",<br />
"implemented_in_module" : "KratosMultiphysics",<br />
"help" : "This process fixes the selected components of a given vector variable",<br />
"process_name" : "ImposeVectorValueByComponentsProcess",<br />
"Parameters" : {<br />
"mesh_id" : 0,<br />
"model_part_name" : "DISPLACEMENT_Displacement_Auto1",<br />
"variable_name" : "DISPLACEMENT",<br />
"is_fixed_x" : true,<br />
"is_fixed_y" : true,<br />
"is_fixed_z" : true,<br />
"value" : [0.0,0.0,0.0]<br />
}<br />
}],<br />
"loads_process_list" : [{<br />
"implemented_in_file" : "process_factory",<br />
"implemented_in_module" : "KratosMultiphysics",<br />
"check" : "DirectorVectorNonZero direction",<br />
"help" : "This process ",<br />
"process_name" : "ApplyConstantVectorValueProcess",<br />
"Parameters" : {<br />
"mesh_id" : 0,<br />
"model_part_name" : "SelfWeight2D_Self_weight_Auto1",<br />
"variable_name" : "VOLUME_ACCELERATION",<br />
"factor" : 9.8,<br />
"direction" : [10.0,0.0,0.0]<br />
}<br />
}],<br />
"output_configuration" : {<br />
"result_file_configuration" : {<br />
"gidpost_flags" : {<br />
"GiDPostMode" : "GiD_PostBinary",<br />
"WriteDeformedMeshFlag" : "WriteDeformed",<br />
"WriteConditionsFlag" : "WriteConditions",<br />
"MultiFileFlag" : "SingleFile"<br />
},<br />
"file_label" : "step",<br />
"output_control_type" : "step",<br />
"output_frequency" : 1.0,<br />
"body_output" : true,<br />
"node_output" : false,<br />
"skin_output" : false,<br />
"plane_output" : [],<br />
"nodal_results" : ["DISPLACEMENT","REACTION"],<br />
"gauss_point_results" : ["VON_MISES_STRESS"]<br />
},<br />
"point_data_configuration" : []<br />
},<br />
"restart_options" : {<br />
"SaveRestart" : false,<br />
"RestartFrequency" : 0,<br />
"LoadRestart" : false,<br />
"Restart_Step" : 0<br />
},<br />
"constraints_data" : {<br />
"incremental_load" : false,<br />
"incremental_displacement" : false<br />
}<br />
}<br />
<br />
Such text shall be read to an "input_string" which is then parsed and stored within a "Parameters" object<br />
<br />
this is done in python as <br />
input_string = open("ProjectParameters.json",'r').read()<br />
settings = Parameters( input_string )<br />
<br />
the settings object now behaves effectively as a combination of lists and dictionaries, for example one can obtain<br />
the name of the problem to be solved as <br />
name = settings["problem_data"]["problem_name"].GetString()<br />
<br />
an important aspect of this is that the user is expected to ask specifically for the type to be provided<br />
For the case at hand (the name) one is asking for the item "settings["problem_data"]["problem_name"]" to be provided as a string by calling the "GetString()" method.<br />
<br />
similarly one can call<br />
* GetInt()<br />
* GetDouble()<br />
* GetBool()<br />
* GetString()<br />
<br />
the type can be queried by the functions<br />
* IsInt()<br />
* IsDouble()<br />
* IsBool()<br />
* IsString()</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/Python_Script_Tutorial:_Writing_a_JSon_configuration_filePython Script Tutorial: Writing a JSon configuration file2016-06-01T16:21:23Z<p>Rrossi: </p>
<hr />
<div>As complexity increases one needs more and more flexibility in “configuring” a simulation. This is typically achieved by <br />
defining a "configuration file" which organizes all of the "user instructions" to be used in the configuration of the solver.<br />
<br />
Some requirements for this configuration are:<br />
* Must allow nesting of parameters (tree-like structure)<br />
* Should allow using default values<br />
* Must allow some form of type checking<br />
* Should permit to echo all of the defaults in a single place <br />
<br />
In order to meet such requirements Kratos introduces a "Parameters" object, which provides a thin wrapper to JSon strings.<br />
<br />
The typical structure of a JSon file is like the following:<br />
{<br />
"problem_data" : {<br />
"problem_name" : "minimal_structure",<br />
"model_part_name" : "Structure",<br />
"domain_size" : 2,<br />
"time_step" : 1.1,<br />
"start_time" : 0.0,<br />
"end_time" : 1.0,<br />
"echo_level" : 0<br />
},<br />
"solver_settings" : {<br />
"solver_type" : "solid_mechanics_static_solver",<br />
"echo_level" : 0,<br />
"solution_type" : "Static",<br />
"analysis_type" : "Linear",<br />
"model_import_settings" : {<br />
"input_type" : "mdpa",<br />
"input_filename" : "minimal_structure"<br />
},<br />
"line_search" : false,<br />
"convergence_criterion" : "Residual_criterion",<br />
"displacement_relative_tolerance" : 0.0001,<br />
"displacement_absolute_tolerance" : 1e-9,<br />
"residual_relative_tolerance" : 0.0001,<br />
"residual_absolute_tolerance" : 1e-9,<br />
"max_iteration" : 10,<br />
"linear_solver_settings" : {<br />
"solver_type" : "Super_LU",<br />
"scaling" : false,<br />
"verbosity" : 0<br />
},<br />
"problem_domain_sub_model_part_list" : ["Parts_Parts_Auto2"],<br />
"processes_sub_model_part_list" : ["DISPLACEMENT_Displacement_Auto1","SelfWeight2D_Self_weight_Auto1"],<br />
"rotation_dofs" : false<br />
},<br />
"constraints_process_list" : [{<br />
"implemented_in_file" : "impose_vector_value_by_components_process",<br />
"implemented_in_module" : "KratosMultiphysics",<br />
"help" : "This process fixes the selected components of a given vector variable",<br />
"process_name" : "ImposeVectorValueByComponentsProcess",<br />
"Parameters" : {<br />
"mesh_id" : 0,<br />
"model_part_name" : "DISPLACEMENT_Displacement_Auto1",<br />
"variable_name" : "DISPLACEMENT",<br />
"is_fixed_x" : true,<br />
"is_fixed_y" : true,<br />
"is_fixed_z" : true,<br />
"value" : [0.0,0.0,0.0]<br />
}<br />
}],<br />
"loads_process_list" : [{<br />
"implemented_in_file" : "process_factory",<br />
"implemented_in_module" : "KratosMultiphysics",<br />
"check" : "DirectorVectorNonZero direction",<br />
"help" : "This process ",<br />
"process_name" : "ApplyConstantVectorValueProcess",<br />
"Parameters" : {<br />
"mesh_id" : 0,<br />
"model_part_name" : "SelfWeight2D_Self_weight_Auto1",<br />
"variable_name" : "VOLUME_ACCELERATION",<br />
"factor" : 9.8,<br />
"direction" : [10.0,0.0,0.0]<br />
}<br />
}],<br />
"output_configuration" : {<br />
"result_file_configuration" : {<br />
"gidpost_flags" : {<br />
"GiDPostMode" : "GiD_PostBinary",<br />
"WriteDeformedMeshFlag" : "WriteDeformed",<br />
"WriteConditionsFlag" : "WriteConditions",<br />
"MultiFileFlag" : "SingleFile"<br />
},<br />
"file_label" : "step",<br />
"output_control_type" : "step",<br />
"output_frequency" : 1.0,<br />
"body_output" : true,<br />
"node_output" : false,<br />
"skin_output" : false,<br />
"plane_output" : [],<br />
"nodal_results" : ["DISPLACEMENT","REACTION"],<br />
"gauss_point_results" : ["VON_MISES_STRESS"]<br />
},<br />
"point_data_configuration" : []<br />
},<br />
"restart_options" : {<br />
"SaveRestart" : false,<br />
"RestartFrequency" : 0,<br />
"LoadRestart" : false,<br />
"Restart_Step" : 0<br />
},<br />
"constraints_data" : {<br />
"incremental_load" : false,<br />
"incremental_displacement" : false<br />
}<br />
}</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/Python_Script_Tutorial:_Writing_a_JSon_configuration_filePython Script Tutorial: Writing a JSon configuration file2016-06-01T16:07:29Z<p>Rrossi: </p>
<hr />
<div>As complexity increases one needs more and more flexibility in “configuring” a simulation. This is typically achieved by <br />
defining a "configuration file" which organizes all of the "user instructions" to be used in the configuration of the solver.<br />
<br />
Some requirements for this configuration are:<br />
* Must allow nesting of parameters (tree-like structure)<br />
* Should allow using default values<br />
* Must allow some form of type checking<br />
* Should permit to echo all of the defaults in a single place <br />
<br />
In order to meet such requirements Kratos introduces a "Parameters" object, which provides a thin wrapper to JSon strings.<br />
<br />
The typical structure of a JSon file is like the following:</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/Python_Script_Tutorial:_Writing_a_JSon_configuration_filePython Script Tutorial: Writing a JSon configuration file2016-06-01T08:25:54Z<p>Rrossi: Created page with "As complexity increases one needs more and more flexibility in “configuring” a simulation. This is typically achieved by defining a "configuration file" which organizes all ..."</p>
<hr />
<div>As complexity increases one needs more and more flexibility in “configuring” a simulation. This is typically achieved by <br />
defining a "configuration file" which organizes all of the "user instructions" to be used in the configuration of the solver.<br />
<br />
Some requirements for this configuration are:<br />
- Must allow nesting of parameters (tree-like structure)<br />
- Should allow using default values<br />
- Must allow some form of type checking<br />
- Should permit to echo all of the defaults in a single place <br />
<br />
In order to meet such requirements Kratos introduces a "Parameters" object, which provides a thin wrapper to JSon strings.<br />
<br />
The typical structure of a JSon file is like the following:</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/Kratos_TutorialsKratos Tutorials2016-06-01T08:21:20Z<p>Rrossi: /* Python Script */</p>
<hr />
<div>== New GiD interface ==<br />
This is the recommended version for end users. These tutorials use the ''nice'' GiD interface, which is more user-friendly but currently only supports the most common applications.<br />
<br />
* [https://kratos.cimne.upc.es/attachments/download/1297/0_kratos_workshop2014.zip Basic Tutorials]<br />
<br />
== Development GiD interface ==<br />
These tutorials are based on the ''development'' GiD interface, which is less user-friendly but supports all Kratos applications<br />
<br />
*[https://kratos.cimne.upc.es/attachments/download/1352/HowToRunAnExample_EulerianFreeSurfaceCode_v4.zip LevelSet_FreeSurface Analysis Tutorial and GiD Problem type] The zip file you donwload from this link contains the GiD problem type and the tutorial to use a code to treat free surface problems in presence or not of a porous medium (i.e. seepage is as well considered).<br />
* [https://kratos.cimne.upc.es/attachments/download/1354/HowToRunAnExample_NonNewtonianPT_v1.zip NonNewtonian_PFEM Analysis Tutorial] The zip file you donwload from this link contains the GiD problem type and the tutorial to use a code to solve Lagrangian Non-Newtonian problems with PFEM [http://www.cimne.com/pfem/].<br />
<br />
== Kratos Installation ==<br />
* [[Kratos Installation]]<br />
<br />
== Kratos Structure ==<br />
* [[Kratos Structure: Kernel and applications]]<br />
* [[Kratos Structure: Basic Components]]<br />
* [[Kratos Structure: Node and Nodal Data]]<br />
* [[Kratos Structure: Elements and Conditions]]<br />
* [[Kratos Structure: Mesh and ModelPart]]<br />
* [[Kratos Structure: Strategies and Processes]]<br />
* [[Kratos Structure: Workflow]]<br />
<br />
<br />
<br />
== Python Script ==<br />
* [[Python Script Tutorial: Getting Started]]<br />
* [[Python Script Tutorial: Hello Kratos]] <br />
* [[Python Script Tutorial: Reading ModelPart From Input File]]<br />
* [[Python Script Tutorial: Writing Output File]]<br />
* [[Python Script Tutorial: ModelPart Nodes and Nodal Data]]<br />
* [[Python Script Tutorial: ModelPart Elements and Conditions]]<br />
* [[Python Script Tutorial: Writing a JSon configuration file]]<br />
* [[Python Script Tutorial: Using Kratos Solvers]]<br />
* [[Python Script Tutorial: Main Solution]]<br />
<br />
[[Category:Tutorials]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/Python_Script_Tutorial:_Reading_ModelPart_From_Input_FilePython Script Tutorial: Reading ModelPart From Input File2016-06-01T08:16:38Z<p>Rrossi: /* Reading ModelPart File */</p>
<hr />
<div>The ModelPart represents an arbitrary part of the model to be simulated and stores the mesh and additional data for it. Most of the Kratos routines take a ModelPart as their argument. So always is necessary to create and fill a ModelPart. In this tutorial we will describe how to create and fill a model part from given input file. <br />
<br />
<br />
== Starting ==<br />
<br />
First of all we need to create a python file with following code to import the Kratos:<br />
<br />
from KratosMultiphysics import *<br />
from KratosMultiphysics.SolidMechanicsApplication import *<br />
<br />
== Creating a ModelPart ==<br />
<br />
<br />
To create a ModelPart, one has to call its constructor passing the ModelPart`s name as its argument:<br />
<br />
structure_model_part = ModelPart("StructurePart")<br />
<br />
You can print the fluid_model_part:<br />
<br />
>>> print structure_model_part<br />
StructurePart model part<br />
Buffer Size : 1<br />
Number of tables : 0<br />
Current solution step index : 0<br />
<br />
Mesh 0 : <br />
Number of Nodes : 0<br />
Number of Properties : 0<br />
Number of Elements : 0<br />
Number of Conditions : 0<br />
<br />
It can be seen that the ModelPart is empty and has the buffer size equal to 1. This means that no history of the nodal solution steps variables will be saved.<br />
<br />
The next step is to define the variables we want to store as historical variables in nodes of this ModelPart as follow:<br />
<br />
structure_model_part.AddNodalSolutionStepVariable(DISPLACEMENT)<br />
structure_model_part.AddNodalSolutionStepVariable(FORCE)<br />
<br />
== Reading ModelPart File ==<br />
<br />
The input file of the Kratos has .mdpa (stand for ModelPart) and contains the properties, nodes, elements, conditions and initial values. A convenient way to create this file is to use the interface prepared for [http://www.gidhome.com GiD] pre and post processor. [[Input Data | Here]] you can find more information about the input file. Here we assume that the example.mdpa input file is already created as follow:<br />
<br />
'''example.mdpa'''<br />
<br />
Begin ModelPartData<br />
// nothing here<br />
End ModelPartData<br />
<br />
<br />
Begin Properties 1<br />
DENSITY 2700.000000<br />
YOUNG_MODULUS 7000000.000000<br />
POISSON_RATIO 0.300000<br />
BODY_FORCE [3] (0.000000,0.000000,0.000000)<br />
THICKNESS 1.000000<br />
End Properties<br />
<br />
Begin Nodes<br />
1 0.0 0.0 0.0 //node number, coord x, cord y, coord z<br />
2 1.0 0.0 0.0 //node number, coord x, cord y, coord z<br />
3 1.0 1.0 0.0 //node number, coord x, cord y, coord z<br />
4 0.0 1.0 0.0 //node number, coord x, cord y, coord z<br />
End Nodes<br />
<br />
Begin Elements TotalLagrangianElement2D3N<br />
1 1 1 2 4 //the first column is the property<br />
2 1 3 4 2<br />
End Elements<br />
<br />
Begin NodalData DISPLACEMENT_X //be careful, variables are case sensitive!<br />
1 1 100.0 <span style="color:red"> // pos1 is the node, pos2 (a 1) means that the DOF is fixed, then (position 3) we write the fixed displacement (in this case, temperature) </span> <br />
End NodalData<br />
<br />
Begin NodalData DISPLACEMENT_Y <br />
1 1 100.0 <br />
End NodalData<br />
<br />
Begin NodalData FORCE_Y <br />
3 0 5.0 <span style="color:red"> //fixing it or not does not change anything since it is not a degree of freedom, it's just info that will be used by the condition </span> <br />
End NodalData<br />
<br />
Begin Conditions PointLoadCondition2D1N<br />
1 1 3 <span style="color:red"> //pos1:condition ID ; pos2:cond Property ( = 1 in this case) ; pos3:node to apply the condition. </span> <br />
End Conditions<br />
<br />
Begin SubModelPart BaseNodes // Note that this would be a sub sub modelpart<br />
Begin SubModelPartNodes<br />
1<br />
2<br />
End SubModelPartNodes<br />
End SubModelPart<br />
<br />
which represents the following 2D problem:<br />
<br />
<br />
[[File:elems.png]]<br />
<br />
For reading the .mdpa file first we have to create a ModelPartIO object passing the input file path/name to its constructor:<br />
<br />
model_part_io_structure = ModelPartIO("path/to/file/example")<br />
<br />
{{Note| <br />
the file name is used without the .mdpa extension!<br />
}}<br />
<br />
<br />
Then use this io object to read the file and store the mesh and data in ModelPart:<br />
<br />
model_part_io_structure.ReadModelPart(structure_model_part)<br />
<br />
<br />
And printing again the ModelPart:<br />
<br />
>>> print structure_model_part<br />
StructurePart model part<br />
Buffer Size : 1<br />
Number of tables : 0<br />
Current solution step index : 0<br />
<br />
Mesh 0 : <br />
Number of Nodes : 4<br />
Number of Properties : 1<br />
Number of Elements : 2<br />
Number of Conditions : 1<br />
<br />
== Setting the Buffer Size ==<br />
<br />
If we need to store the values of the nodal solution step variables in previous time steps, we must modify the buffer size '''AFTER''' defining the historical variables:<br />
<br />
structure_model_part.SetBufferSize(3)<br />
<br />
This would store the values for two previous steps in addition to the current ones. <br />
<br />
<br />
Next Tutorial : [[Python Script Tutorial: Writing Output File]] <br />
<br />
Previous Tutorial : [[Python Script Tutorial: Hello Kratos]] <br />
<br />
All Tutorials : [[Kratos_Tutorials#Python_Script| Kratos Tutorials]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-12-14T16:50:22Z<p>Rrossi: /* A comment on the small deformation case */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file [https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h constitutive_law.h].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
<br />
ask the constitutive law to compute these magnitudes and will be returned in the variables of the Data structure GetStrainVector(), GetStressVector() and GetConstitutiveMatrix() respectively.<br />
<br />
COMPUTE_STRAIN_ENERGY<br />
<br />
asks the constitutive law to compute the strain energy, elastic or plastic, after that you can get it using a GetValue(kratos<variable>, double).<br />
<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
these flags are used internally in the constitutive law to set the type of calculation needed depending on the law and the particular time sequence.<br />
<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL<br />
<br />
The constitutive law also provides helper functions to allow pushing/pulling stresses from one configuration to another.<br />
<br />
== Providing the Deformation gradient F or the strain ==<br />
Within Kratos the strain can be either provided to the constitutive law as an input parameter, OR obtained internally within the constitutive law<br />
depending on the kinematics chosen. <br />
<br />
=== OPTION 1 -- PROVIDE STRAIN AS INPUT PARAMETER ===<br />
This option is chosen by selecting <br />
flags.Set(COMPUTE_STRAIN, false)<br />
<br />
in this case the constitutive law reads the value of "StrainVector" and uses it as a basis for the computations of the stresses<br />
<br />
=== OPTION 1 -- PROVIDE F AS INPUT PARAMETER ===<br />
The idea in this case is to provide a DeformationGradient '''F''' as an input parameter.<br />
<br />
In the case of small deformation kinematics, is is not customary to define the deformation gradient. For this case (small deformations) one one can construct the deformation gradient given the strain vector as<br />
<br />
F(0,0) = 1+strain(0); F(0,1) = 0.5*strain(4); F(0,2) = 0.5*strain(6)<br />
F(1,0) = 0.5*strain(4); F(1,1) = 1+strain(1); F(1,2) = 0.5*strain(5)<br />
F(2,0) = 0.5*strain(6); F(2,1) = 0.5*strain(5); F(2,2) = 1+strain(2)<br />
<br />
for the 3D case.<br />
<br />
== Additional Material == <br />
[[How to use 3D laws for PlaneStress cases]]<br />
<br />
[[How to use constitutive law to describe RVE behaviour]]<br />
<br />
[[How to use an Abaqus "umat" function through the interface]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-12-14T15:12:29Z<p>Rrossi: /* A comment on the small deformation case */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file [https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h constitutive_law.h].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
<br />
ask the constitutive law to compute these magnitudes and will be returned in the variables of the Data structure GetStrainVector(), GetStressVector() and GetConstitutiveMatrix() respectively.<br />
<br />
COMPUTE_STRAIN_ENERGY<br />
<br />
asks the constitutive law to compute the strain energy, elastic or plastic, after that you can get it using a GetValue(kratos<variable>, double).<br />
<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
these flags are used internally in the constitutive law to set the type of calculation needed depending on the law and the particular time sequence.<br />
<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL<br />
<br />
The constitutive law also provides helper functions to allow pushing/pulling stresses from one configuration to another.<br />
<br />
== A comment on the small deformation case ==<br />
in the case of small deformations, it is usual to assume that strain is given as a vector (in voigt format) and <br />
stress = ConstitutiveMatrix * strain<br />
that is, Strain is typically an input parameter. '''This is not the case for Kratos'''.<br />
<br />
The idea is that even simple constitutive law accept a DeformationGradient '''F''' as an input parameter.<br />
<br />
In the case of small deformations one can construct the deformation gradient given the strain vector as<br />
<br />
F(0,0) = 1+strain(0); F(0,1) = 0.5*strain(4); F(0,2) = 0.5*strain(6)<br />
F(1,0) = 0.5*strain(4); F(1,1) = 1+strain(1); F(1,2) = 0.5*strain(5)<br />
F(2,0) = 0.5*strain(6); F(2,1) = 0.5*strain(5); F(2,2) = 1+strain(2)<br />
<br />
for the 3D case.<br />
<br />
== Additional Material == <br />
[[How to use 3D laws for PlaneStress cases]]<br />
<br />
[[How to use constitutive law to describe RVE behaviour]]<br />
<br />
[[How to use an Abaqus "umat" function through the interface]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-12-13T17:41:39Z<p>Rrossi: /* A comment on the small deformation case */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file [https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h constitutive_law.h].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
<br />
ask the constitutive law to compute these magnitudes and will be returned in the variables of the Data structure GetStrainVector(), GetStressVector() and GetConstitutiveMatrix() respectively.<br />
<br />
COMPUTE_STRAIN_ENERGY<br />
<br />
asks the constitutive law to compute the strain energy, elastic or plastic, after that you can get it using a GetValue(kratos<variable>, double).<br />
<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
these flags are used internally in the constitutive law to set the type of calculation needed depending on the law and the particular time sequence.<br />
<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL<br />
<br />
The constitutive law also provides helper functions to allow pushing/pulling stresses from one configuration to another.<br />
<br />
== A comment on the small deformation case ==<br />
in the case of small deformations, it is usual to assume that strain is given as a vector (in voigt format) and <br />
stress = ConstitutiveMatrix * strain<br />
that is, Strain is typically an input parameter. '''This is not the case for Kratos'''.<br />
<br />
The idea is that even simple constitutive law accept a DeformationGradient '''F''' as an input parameter.<br />
<br />
In the case of small deformations one can construct the deformation gradient given the strain vector as<br />
<br />
F(0,0) = 1+strain(0); F(0,1) = 0.5*strain(4); F(0,2) = 0.5*strain(6)<br />
F(1,0) = 0.5*strain(2); F(1,1) = 1+strain(1); F(1,2) = 0.5*strain(5)<br />
F(2,0) = 0.5*strain(6); F(2,1) = 0.5*strain(5); F(2,2) = 1+strain(3)<br />
<br />
for the 3D case.<br />
<br />
== Additional Material == <br />
[[How to use 3D laws for PlaneStress cases]]<br />
<br />
[[How to use constitutive law to describe RVE behaviour]]<br />
<br />
[[How to use an Abaqus "umat" function through the interface]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-12-13T17:07:05Z<p>Rrossi: /* A comment on the small deformation case */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file [https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h constitutive_law.h].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
<br />
ask the constitutive law to compute these magnitudes and will be returned in the variables of the Data structure GetStrainVector(), GetStressVector() and GetConstitutiveMatrix() respectively.<br />
<br />
COMPUTE_STRAIN_ENERGY<br />
<br />
asks the constitutive law to compute the strain energy, elastic or plastic, after that you can get it using a GetValue(kratos<variable>, double).<br />
<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
these flags are used internally in the constitutive law to set the type of calculation needed depending on the law and the particular time sequence.<br />
<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL<br />
<br />
The constitutive law also provides helper functions to allow pushing/pulling stresses from one configuration to another.<br />
<br />
== A comment on the small deformation case ==<br />
in the case of small deformations, it is usual to assume that strain is given as a vector (in voigt format) and <br />
stress = ConstitutiveMatrix * strain<br />
that is, Strain is typically an input parameter. '''This is not the case for Kratos'''.<br />
<br />
The idea is that even simple constitutive law accept a DeformationGradient '''F''' as an input parameter.<br />
<br />
In the case of small deformations one can construct the deformation gradient given the strain vector as<br />
<br />
F(0,0) = 1+strain(0); F(0,1) = 0.5*strain(4); F(0,2) = 0.5*strain(6)<br />
F(1,0) = 0.5*strain(2); F(1,1) = 1+strain(1); F(1,2) = 0.5*strain(5)<br />
F(2,0) = 0.5*strain(6); F(2,1) = 0.5*strain(5); F(2,2) = 1+strain(3)<br />
<br />
== Additional Material == <br />
[[How to use 3D laws for PlaneStress cases]]<br />
<br />
[[How to use constitutive law to describe RVE behaviour]]<br />
<br />
[[How to use an Abaqus "umat" function through the interface]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-12-13T17:03:40Z<p>Rrossi: /* Additional Material */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file [https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h constitutive_law.h].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
<br />
ask the constitutive law to compute these magnitudes and will be returned in the variables of the Data structure GetStrainVector(), GetStressVector() and GetConstitutiveMatrix() respectively.<br />
<br />
COMPUTE_STRAIN_ENERGY<br />
<br />
asks the constitutive law to compute the strain energy, elastic or plastic, after that you can get it using a GetValue(kratos<variable>, double).<br />
<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
these flags are used internally in the constitutive law to set the type of calculation needed depending on the law and the particular time sequence.<br />
<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL<br />
<br />
The constitutive law also provides helper functions to allow pushing/pulling stresses from one configuration to another.<br />
<br />
== A comment on the small deformation case ==<br />
in the case of small deformations, it is usual to assume that strain is given as a vector (in voigt format) and <br />
stress = ConstitutiveMatrix * strain<br />
that is, Strain is typically an input parameter. '''This is not the case for Kratos'''.<br />
<br />
The idea is that even simple constitutive law accept a DeformationGradient '''F''' as an input parameter.<br />
<br />
In the case of small deformations one can construct the deformation gradient given the strain vector as<br />
<br />
F(0,0) = 1+strain(0); F(0,1) = strain(2); F(0,2) = strain(3)<br />
F(1,0) = strain(2); F(0,1) = strain(2); F(0,2) = strain(3)<br />
F(2,0) = strain(3); F(0,1) = strain(2); F(0,2) = strain(3)<br />
<br />
== Additional Material == <br />
[[How to use 3D laws for PlaneStress cases]]<br />
<br />
[[How to use constitutive law to describe RVE behaviour]]<br />
<br />
[[How to use an Abaqus "umat" function through the interface]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-17T05:45:50Z<p>Rrossi: /* Additional Material */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file [https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h constitutive_law.h].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL<br />
<br />
The constitutive law also provides helper functions to allow pushing/pulling stresses from one configuration to another.<br />
<br />
== Additional Material == <br />
[[How to use 3D laws for PlaneStress cases]]<br />
<br />
[[How to use constitutive law to describe RVE behaviour]]<br />
<br />
[[How to use an Abaqus "umat" function through the interface]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-17T05:45:35Z<p>Rrossi: /* Usage API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file [https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h constitutive_law.h].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL<br />
<br />
The constitutive law also provides helper functions to allow pushing/pulling stresses from one configuration to another.<br />
<br />
== Additional Material == <br />
[[How to use 3D laws for PlaneStress cases]]<br />
[[How to use constitutive law to describe RVE behaviour]]<br />
[[How to use an Abaqus "umat" function through the interface]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-17T05:41:23Z<p>Rrossi: /* Conventions */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file [https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h constitutive_law.h].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T08:08:35Z<p>Rrossi: /* Usage API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file [https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h constitutive_law.h].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T08:07:59Z<p>Rrossi: /* Usage API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file [https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h constitutive_law.h].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T08:07:38Z<p>Rrossi: /* Usage API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file [https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h constitutive_law.h].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T08:07:02Z<p>Rrossi: /* Usage API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file [https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h constitutive_law.h].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T08:06:16Z<p>Rrossi: /* Usage API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file [https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h constitutive_law.h].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T08:06:01Z<p>Rrossi: /* Usage API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file constitutive_law.h [https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h constitutive_law.h].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T08:05:15Z<p>Rrossi: /* Usage API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file constitutive_law.h [[constitutive_law.h https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h]].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T08:04:35Z<p>Rrossi: /* Usage API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file constitutive_law.h [[https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h<br />
constitutive_law.h]].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T06:48:01Z<p>Rrossi: /* Usage API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file constitutive_law.hpp [[https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h<br />
]].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ConstitutiveTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(ConstitutiveTensor) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
//instruct the constitutive law that both stress and the constitutivetensor are needed<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
//actually do the computations in the ConstitutiveLaw <br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T06:46:25Z<p>Rrossi: /* Usage API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file constitutive_law.hpp [[https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h<br />
]].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )<br />
<br />
An example of usage of the ConstitutiveLaw from within a total lagrangian element could be as follows:<br />
Parameters parameters(GetGeometry(), GetProperties(), rCurrentProcessInfo);<br />
<br />
//here we essentially set the input parameters<br />
parameters.SetDeterminantF(detF) //assuming the determinant is computed somewhere else<br />
parameters.SetDeformationGradientF(F) //F computed somewhere else<br />
<br />
//here we set the space on which the results shall be written<br />
Matrix ElasticityTensor(strain_size,strain_size); //note that C is allocated in the element<br />
Vector stress(strain_size);<br />
parameters.SetConstitutiveMatrix(C) //assuming the determinant is computed somewhere else<br />
parameters.SetStressVector(stress) //F computed somewhere else<br />
<br />
parameters.GetOptions().Set(COMPUTE_STRESS, True)<br />
parameters.GetOptions().Set(COMPUTE_CONSTITUTIVE_TENSOR, True)<br />
<br />
constitutivelaw->CalculateMaterialResponsePK2(parameters); //here the calculations are actually done <br />
<br />
//here stress and C are already updated since we passed them to the CL</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T06:34:40Z<p>Rrossi: /* Usage API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file constitutive_law.hpp [[https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h<br />
]].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental feature of the constitutive law is to implement internally the transformations between different stress measures. <br />
When a user writes an element he should decide what<br />
stress measure is desired. The list of available options is provided in the enum:<br />
enum StressMeasure<br />
{<br />
StressMeasure_PK1, //stress related to reference configuration non-symmetric<br />
StressMeasure_PK2, //stress related to reference configuration<br />
StressMeasure_Kirchhoff, //stress related to current configuration<br />
StressMeasure_Cauchy //stress related to current configuration<br />
}<br />
<br />
at the moment of writing the element the developer should hence query to the constitutive law for the desired stress measure. This is achieved by picking<br />
one of the functions:<br />
CalculateMaterialResponsePK1( parameters )<br />
CalculateMaterialResponsePK2( parameters )<br />
CalculateMaterialResponseKirchhoff( parameters )<br />
CalculateMaterialResponseCauchy( parameters )<br />
<br />
the elasticity tensor and the corresponding stresses will be stored in the "parameters" and shall be accessed by the Getter funtions described above.<br />
<br />
At the end of a given solution step (typically in the FinalizeSolutionStep function of the element), internal variables should be updated by calling the function<br />
FinalizeMaterialResponsePK1( parameters )<br />
FinalizeMaterialResponsePK2( parameters )<br />
FinalizeMaterialResponseKirchhoff( parameters )<br />
FinalizeMaterialResponseCauchy( parameters )</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T06:25:42Z<p>Rrossi: /* API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== Usage API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file constitutive_law.hpp [[https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h<br />
]].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
GetConstitutiveMatrix() <br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.<br />
<br />
A fundamental</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T06:24:05Z<p>Rrossi: /* API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file constitutive_law.hpp [[https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h<br />
]].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
<br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
<br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
<br />
GetConstitutiveMatrix() <br />
<br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()<br />
<br />
there are additionally the two functions <br />
GetDeterminantF0() //DEPRECATED: please set to 1.0<br />
GetDeformationGradientF0() //DEPRECATED: please set to the IdentityMatrix<br />
that are currently '''deprecated''' to simplify the constitutive law usage. Until their complete removal please set them respectively to 1.0 and to the IdentityMatrix of correct size. They will be removed asap.<br />
<br />
The "Options" flag represents the fundamental tool in steering the control of the constitutive law behaviour. The interface provides a number of boolean flags that can be passed <br />
to the constitutive law:<br />
<br />
COMPUTE_STRAIN<br />
COMPUTE_STRESS<br />
COMPUTE_CONSTITUTIVE_TENSOR<br />
ISOCHORIC_TENSOR_ONLY <br />
VOLUMETRIC_TENSOR_ONLY <br />
TOTAL_TENSOR <br />
FINALIZE_MATERIAL_RESPONSE<br />
<br />
there are 3 additional ones but are currently deprecated and not reported here.</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T06:16:57Z<p>Rrossi: /* API */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
== API ==<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
The parameters data structure should be initialized using the following constructor:<br />
Parameters (const GeometryType& rElementGeometry<br />
,const Properties& rMaterialProperties<br />
,const ProcessInfo& rCurrentProcessInfo)<br />
Thus allowing to encapsulate the pointer to the elemental properties, to the element geometry and to the process info.<br />
<br />
The data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file constitutive_law.hpp [[https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h<br />
]].<br />
For ease, the getter interface, ''returning a reference to the encapsulated data'', is reported here<br />
<br />
GetOptions() //returns a reference to a flag container, to be employed in passing options to the CL<br />
<br />
GetDeterminantF() <br />
GetDeformationGradientF() <br />
<br />
GetShapeFunctionsValues() <br />
GetShapeFunctionsDerivatives() <br />
<br />
GetStrainVector() //INPUT/OUTPUT -- note that F will be used preferentially instead of the input strain<br />
GetStressVector() <br />
<br />
GetConstitutiveMatrix() <br />
<br />
GetProcessInfo() <br />
GetMaterialProperties() <br />
GetElementGeometry()</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-16T06:07:57Z<p>Rrossi: /* Conventions */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the '''total deformation gradient F''', defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw '''always returns the total stress'''. Formulations expressed in terms of strain increments shall store internally the strain stresses from which the increment<br />
shall be computed<br />
<br />
=== API ===<br />
The constitutive law API is based on the use of an auxiliary "Parameters" data structure, designed to encapsulate the data to be passed to the CL and received from it.<br />
Such data structure '''does not contain any internal storage''' and should be initialized with pointers to memory ''owned by the caller element''. <br />
Full documentation of the code can be found in the file constitutive_law.hpp [[https://kratos.cimne.upc.es/projects/kratos/repository/entry/kratos/kratos/includes/constitutive_law.h<br />
]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-15T16:14:19Z<p>Rrossi: /* Conventions */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
The constitutive law works on the basis of the deformation gradient F, defined as<br />
F := D(X) / D(X0) <br />
that is, as the deformation gradient connecting the original and deformed configuration<br />
<br />
where the initial position X0 is the one obtained by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
and the deformed one by <br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with X = node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
The ConstitutiveLaw always returns the '''total stress'''</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-13T18:33:11Z<p>Rrossi: /* Conventions */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
<br />
The constitutive law API is also designed to ease the implementation not only of Total Lagrangian but also of Updated Lagrandian and "Spatial Lagrangian" approaches.<br />
In order to understant the interface we shall consider 3 possible references:<br />
<br />
1 - The "Initial Reference", representing the position in space occupied by the nodes at the very beginning of the simulation, before any deformation is applied. We recall that in Kratos such position can be recovered by <br />
const array_1d<double,3>& X0 = node->GetInitialPosition()<br />
2 - The "last known position", identifying the position in space occupied in the last moment at which everything is considered known. We could name such position as "Xlast"<br />
3 - The "final" configuration of the mesh, identified as the position at which the nodes are located at the very latest iteration. This position can be obtained as<br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with node->GetInitialPosition() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
taking into account this definitions, the Constitutive Law defines <br />
<br />
- F0 := D(Xref) / D(X0) <br />
<br />
- F := D(X) / D(Xref) <br />
<br />
The total deformation gradient can hence be always obtained as<br />
Ftot = prod(F,F0)<br />
<br />
taking into account such definitions the CL API allows the user to define on which domain configuration to compute the given stress/strain measure<br />
There are thus 3 different possibilities<br />
<br />
1 - INITIAL CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := I<br />
F := D(X) / D(X0) <br />
In this case the user shall instruct the constitutive law to obtain this behaviour by setting<br />
<br />
2 - LAST KNOWN CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := D(Xref) / D(X0) <br />
F := D(X) / D(Xref) <br />
3 - FINAL CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := D(X) / D(X0) <br />
F := I</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-13T18:31:21Z<p>Rrossi: /* Conventions */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
<br />
The constitutive law API is also designed to ease the implementation not only of Total Lagrangian but also of Updated Lagrandian and "Spatial Lagrangian" approaches.<br />
In order to understant the interface we shall consider 3 possible references:<br />
<br />
1 - The "Initial Reference", representing the position in space occupied by the nodes at the very beginning of the simulation, before any deformation is applied. We recall that in Kratos such position can be recovered by <br />
const array_1d<double,3>& X0 = node->InitialCoordinates()<br />
2 - The "last known position", identifying the position in space occupied in the last moment at which everything is considered known. We could name such position as "Xlast"<br />
3 - The "final" configuration of the mesh, identified as the position at which the nodes are located at the very latest iteration. This position can be obtained as<br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with node->InitialCoordinates() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
taking into account this definitions, the Constitutive Law defines <br />
<br />
- F0 := D(Xref) / D(X0) <br />
<br />
- F := D(X) / D(Xref) <br />
<br />
The total deformation gradient can hence be always obtained as<br />
Ftot = prod(F,F0)<br />
<br />
taking into account such definitions the CL API allows the user to define on which domain configuration to compute the given stress/strain measure<br />
There are thus 3 different possibilities<br />
<br />
1 - INITIAL CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := I<br />
F := D(X) / D(X0) <br />
In this case the user shall instruct the constitutive law to obtain this behaviour by setting<br />
<br />
2 - LAST KNOWN CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := D(Xref) / D(X0) <br />
F := D(X) / D(Xref) <br />
3 - FINAL CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := D(X) / D(X0) <br />
F := I</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-13T18:24:43Z<p>Rrossi: /* Conventions */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
<br />
The constitutive law API is also designed to ease the implementation not only of Total Lagrangian but also of Updated Lagrandian and "Spatial Lagrangian" approaches.<br />
In order to understant the interface we shall consider 3 possible references:<br />
<br />
1 - The "Initial Reference", representing the position in space occupied by the nodes at the very beginning of the simulation, before any deformation is applied. We recall that in Kratos such position can be recovered by <br />
const array_1d<double,3>& X0 = node->InitialCoordinates()<br />
2 - The "last known position", identifying the position in space occupied in the last moment at which everything is considered known. We could name such position as "Xlast"<br />
3 - The "final" configuration of the mesh, identified as the position at which the nodes are located at the very latest iteration. This position can be obtained as<br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with node->InitialCoordinates() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
taking into account this definitions, the Constitutive Law defines <br />
<br />
- F0 := D(Xref) / D(X0) <br />
<br />
- F := D(X) / D(Xref) <br />
<br />
The total deformation gradient can hence be always obtained as<br />
Ftot = prod(F,F0)<br />
<br />
taking into account such definitions the CL API allows the user to define on which domain configuration to compute the given stress/strain measure<br />
There are thus 3 different possibilities<br />
<br />
1 - INITIAL CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := I<br />
F := D(X) / D(X0) <br />
In this case the user shall instruct the constitutive law to obtain this behaviour by setting<br />
<br />
2 - LAST KNOWN CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := D(Xref) / D(X0) ---> RICCARDOS PROPOSAL: should change this to Fref<br />
F := D(X) / D(Xref) ---> RICCARDOS PROPOSAL: should change the name to DF<br />
3 - INITIAL CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := D(X) / D(X0) <br />
F := I</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-13T18:24:03Z<p>Rrossi: /* Conventions */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
<br />
The constitutive law API is also designed to ease the implementation not only of Total Lagrangian but also of Updated Lagrandian and "Spatial Lagrangian" approaches.<br />
In order to understant the interface we shall consider 3 possible references:<br />
<br />
1 - The "Initial Reference", representing the position in space occupied by the nodes at the very beginning of the simulation, before any deformation is applied. We recall that in Kratos such position can be recovered by <br />
const array_1d<double,3>& X0 = node->InitialCoordinates()<br />
2 - The "last known position", identifying the position in space occupied in the last moment at which everything is considered known. We could name such position as "Xlast"<br />
3 - The "final" configuration of the mesh, identified as the position at which the nodes are located at the very latest iteration. This position can be obtained as<br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with node->InitialCoordinates() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
taking into account this definitions, the Constitutive Law defines <br />
<br />
- F0 := D(Xref) / D(X0) <br />
- F := D(X) / D(Xref) <br />
<br />
The total deformation gradient can hence be always obtained as<br />
Ftot = prod(F,F0)<br />
<br />
taking into account such definitions the CL API allows the user to define on which domain configuration to compute the given stress/strain measure<br />
There are thus 3 different possibilities<br />
<br />
1 - INITIAL CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := I<br />
F := D(X) / D(X0) <br />
In this case the user shall instruct the constitutive law to obtain this behaviour by setting<br />
<br />
<br />
2 - LAST KNOWN CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := D(Xref) / D(X0) ---> RICCARDOS PROPOSAL: should change this to Fref<br />
F := D(X) / D(Xref) ---> RICCARDOS PROPOSAL: should change the name to DF<br />
3 - INITIAL CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := D(X) / D(X0) <br />
F := I</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-13T18:22:39Z<p>Rrossi: /* Convenctions */</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Conventions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01<br />
<br />
<br />
The constitutive law API is also designed to ease the implementation not only of Total Lagrangian but also of Updated Lagrandian and "Spatial Lagrangian" approaches.<br />
In order to understant the interface we shall consider 3 possible references:<br />
<br />
1 - The "Initial Reference", representing the position in space occupied by the nodes at the very beginning of the simulation, before any deformation is applied. We recall that in Kratos such position can be recovered by <br />
const array_1d<double,3>& X0 = node->InitialCoordinates()<br />
2 - The "last known position", identifying the position in space occupied in the last moment at which everything is considered known. We could name such position as "Xlast"<br />
3 - The "final" configuration of the mesh, identified as the position at which the nodes are located at the very latest iteration. This position can be obtained as<br />
const array_1d<double,3>& X = node->Coordinates() <br />
//must coincide with node->InitialCoordinates() + node.FastGetSolutionStepValue(DISPLACEMENT);<br />
<br />
taking into account this definitions, the Constitutive Law defines <br />
- F0 := D(Xref) / D(X0) ---> RICCARDOS PROPOSAL: should change this to Fref<br />
- F := D(X) / D(Xref) ---> RICCARDOS PROPOSAL: should change the name to DF<br />
<br />
The total deformation gradient can hence be always obtained as<br />
Ftot = prod(F,F0)<br />
<br />
taking into account such definitions the CL API allows the user to define on which domain configuration to compute the given stress/strain measure<br />
There are thus 3 different possibilities<br />
<br />
1 - INITIAL CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := I<br />
F := D(X) / D(X0) <br />
In this case the user shall instruct the constitutive law to obtain this behaviour by setting<br />
<br />
<br />
2 - LAST KNOWN CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := D(Xref) / D(X0) ---> RICCARDOS PROPOSAL: should change this to Fref<br />
F := D(X) / D(Xref) ---> RICCARDOS PROPOSAL: should change the name to DF<br />
3 - INITIAL CONFIGURATION - in this case everything should be computed on the reference configuration, so that<br />
F0 := D(X) / D(X0) <br />
F := I</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-12T17:21:35Z<p>Rrossi: </p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Convenctions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 <br />
<br />
- 2D plane stress<br />
'''STRAIN''' Voigt Notation: e00 e11 2*e01 <br />
'''STRESS''' Voigt Notation: s00 s11 s01</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-12T17:19:26Z<p>Rrossi: </p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Convenctions ===<br />
Through the whole section, the following convenctions will be employed:<br />
<br />
''voigt notation:''<br />
- 3D case:<br />
'''STRAIN''' Voigt Notation: e00 e11 e22 2*e01 2*e12 2*e02<br />
'''STRESS''' Voigt Notation: s00 s11 s22 s01 s12 s02<br />
<br />
const unsigned int ConstitutiveLaw::msIndexVoigt2D4C [4][2] = { {0, 0}, {1, 1}, {2, 2}, {0, 1} };<br />
const unsigned int ConstitutiveLaw::msIndexVoigt2D3C [3][2] = { {0, 0}, {1, 1}, {0, 1} };<br />
<br />
<br />
- 2D plane strain/axisymmetric case (4 stress components)<br />
- 2D plane stress</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_the_Constitutive_Law_classHow to use the Constitutive Law class2015-07-12T17:13:37Z<p>Rrossi: Created page with "The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", with a public interface defined in the file kratos/kratos/includes/constitut..."</p>
<hr />
<div>The constitutive law behaviour is dealt with in kratos by the use of the class "ConstitutiveLaw", <br />
with a public interface defined in the file<br />
kratos/kratos/includes/constitutive_law.h<br />
which also provides some rather extensive inline documentation (in the form of comments in the code).<br />
<br />
By design such file aims to provide a very flexible interface to constitutive law modelling, with the specific goal of <br />
'''maximizing the flexibility in the implementation of complex constitutive behaviours'''. While such approach provide obvious advantages, it <br />
also implies that the API is more complex than what would be strictly needed for very simple constitutive laws.<br />
<br />
The objective of current HowTo is to provide a brief introduction to the interface<br />
<br />
=== Convenctions ===</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/HOW_TOsHOW TOs2015-07-12T17:06:46Z<p>Rrossi: /* C++ */</p>
<hr />
<div>This section is intended as a list of "recipes" for common needs in using the Kratos<br />
<br />
== General ==<br />
* [[LinuxInstall | Installing kratos in Ubuntu Linux ]]<br />
* [[Windows 7 Download and Installation | Installing kratos in Windows]]<br />
* [[MacOSX Installation]] (Leopard)<br />
* [[Mac OS X 10.6 Installation]] (Snow Leopard)<br />
<!-- * [[How to get Kratos]] --> <br />
<!-- * [[How to Compile Kratos]] --><br />
* [[How to Compile Kratos on the Acuario Cluster]]<br />
* [[How to Check Kratos is Correctly Installed in Windows]]<br />
* [[How to Check Kratos is Correctly Installed in Linux]]<br />
* [[How to subscribe to Kratos' mailing list]]<br />
* [[How to Profile an application (using google-perftools)]]<br />
* [[How to Measure memory consumption (using google-perftools)]]<br />
* [[How to work with Groups (Meshes)]]<br />
<!--* [[Working]]--><br />
<!--* [[Working_kernel]]--><br />
<br />
== OpenMP Parallelism ==<br />
* [[How to Learn OpenMP]]<br />
* [[How to "survive" OpenMP parallelism]]<br />
* [[How to force a scalar run]]<br />
<br />
== MPI Parallelism ==<br />
* [[How to run your application in cluster]]<br />
* [[How to compile the Boost if you want to use MPI]]<br />
* [[How to use communicator for parallel synchronization]]<br />
<br />
== OpenCL Parallelism ==<br />
* [[Introduction to OpenCL Programming]]<br />
* [[Useful OpenCL links]]<br />
* [[How to set up OpenCL]]<br />
* [[How to debug OpenCL programs using GDB]]<br />
* [[Support for double-precision floating point basic arithmetic in ATI Stream SDK (2.1 and later)]]<br />
<br />
== Python ==<br />
'''General Python Use for Kratos'''<br />
* [[How to use Python]]<br />
* [[How to Use an Application]]<br />
* [[How to import Kratos from Python using the KratosMultiphysics module]]<br />
* [[How to work with nodes and elements in python]]<br />
* [[How to use multiple model parts]]<br />
* [[How to construct a linear solver using the "Linear Solver Factory"]]<br />
* [[How to construct the "solving strategies"]]<br />
* [[strategy_python]]<br />
* [[Operations]]<br />
'''Input/Output and GiD'''<br />
* [[How to read a mdpa file]]<br />
* [[How to use the GidIO]]<br />
* [[How to read a data file]]<br />
* [[How to plot graphs]]<br />
* [[How to create the problem_type.gid folder with the new problem type generator]]<br />
* [[How to use the Isosurface Node Printer]]<br />
'''Calculation tips for Kratos feasible from Python'''<br />
* [[How to Calculate Distance Function]]<br />
* [[How to Calculate Normals]]<br />
* [[How to execute an FFT analysis]]<br />
* [[How to execute fitting of data series]]<br />
* [[How to run python recursively]]<br />
* [[How to execute a SVD analysis]]<br />
* [[How to add automatic benchmarking to your example]]<br />
* [[How to use parallel Pardiso solver for your example]]<br />
* [[How to use the projection between no matching meshes]]<br />
* [[How to use the ReduceTimeStep]]<br />
* [[How to transfer nodal values between non-matching meshes]]<br />
* [[How to use the OpenCL linear solvers]]<br />
* [[How to refine an existing triangular or tetrahedral mesh]]<br />
<!-- * [[How to include the restart in python]] --><br />
* [[How to use the Cutting Application (Serial and Parallel)]]<br />
* [[How to use external linear solvers and preconditioners]]<br />
* [[How to create a restart (python) file]]<br />
* [[How to use the Cutting Isosurface Application]]<br />
* [[How to access a value in a 'Properties' block]]<br />
<br />
== C++ ==<br />
* [[How to use the Constitutive Law class]]<br />
* [[How to use "Smart Pointers" within Kratos]]<br />
* [[How to Use the ModelPart]]<br />
* [[How to Use the Meshes as Group]]<br />
* [[How to Add and Delete Components (Nodes, Elements, ...) from ModelPart]]<br />
* [[How to Access Neighbor Nodes and Elements]]<br />
* [[How to Access DataBase]]<br />
* [[How to Create a New Application using cmake]]<br />
* [[How to Create New Element]]<br />
* [[How to use the geometry within an element]]<br />
* [[How to Use Solving Strategy]]<br />
* [[How to understand Kratos Pointers]]<br />
* [[How to Use the std::vector (and the kratos containers)]]<br />
* [[How to Use Ublas]]<br />
* [[How to Export Function/Classes to the Python]]<br />
* [[How to Interpolate Data]]<br />
* [[How to Compile Kratos in Debug mode]]<br />
* [[How to debug with valgrind]]<br />
* [[How to Add a Custom_Utilities File]]<br />
* [[How to Create a GiD Problem Type]]<br />
* [[How to Add a New Element (Condition)]]<br />
* [[How to Add a New constitutive law]]<br />
* [[How to Add a New Variable]]<br />
* [[How to use the Geometry]]<br />
* [[How to Create Multi-step Elements]]<br />
* [[How to use push_back]]<br />
* [[How to Create a executable without Python]]<br />
* [[How to apply face pressures]]<br />
* [[How to print values on Gauss points]]<br />
* [[How to use Serialization]]<br />
* [[How to Search neighbors]]<br />
* [[How to use Doxygen to generate documentation for our code]]<br />
* [[News for constitutive laws]]<br />
* [[strategy_python]]<br />
* [[Compiling lapack++ for 64 bit Windows]]<br />
* [[Common errors ]]<br />
* [[Some aspects of programing]]<br />
* [[How to use the Spatial Containers]]<br />
* [[How to solve linker errors]]<br />
<br />
== Debbuging and optimizing your code ==<br />
* [[Debugging the Application]]<br />
* [[Profiling the Kratos]]<br />
* [[How to Profile (Measure Time Consumption)]]<br />
* [[Checking memory use with Valgrind]]<br />
<br />
== Graphical User Interfaces ==<br />
* [[How the GiD Graphical User Interface communicates with Kratos]]<br />
<br />
<br />
<br />
== Theory Manual ==<br />
* [[GeneralTemplate]]<br />
* [[MiguelAngel]]<br />
* [[Kazem]]<br />
* [[Computational Fluid Dynamic Module (CFDm)]]<br />
* [[CFDm 1.Introduction]]<br />
* [[CFDm 2.Structure]]<br />
* [[CFDm 2.1.Fluid Types]]<br />
* [[CFDm 2.2.Kinematical Approaches]]<br />
* [[CFDm 2.3.Solution Strategies]]<br />
* [[CFDm 2.4.Elements]]<br />
* [[CFDm 2.5.Boundary Conditions]]<br />
* [[CFDm 2.6.Initial Conditions]]<br />
* [[CFDm 2.7.Turbulence Models]]<br />
* [[CFDm 2.8.HPC]]<br />
* [[CFDm 2.9.Problem Parameters]]<br />
* [[CFDm 2.10.Other Relevant Aspects]]<br />
* [[CFDm 3.Benchmarking]]<br />
* [[CFDm 4.Tutorials]]<br />
* [[CFDm 5.Contact People]]<br />
* [[CFDm 6.Aknowledgements]]<br />
* [[Computational Structural Mechanics Module (CSMm)]]<br />
* [[CSMm 1.Introduction]]<br />
* [[CSMm 2.Structure]]<br />
* [[CSMm 2.1.Analysis Type]]<br />
* [[CSMm 2.2.Elements]]<br />
* [[CSMm 2.3.Boundary Conditions]]<br />
* [[CSMm 2.4.Loads]]<br />
* [[CSMm 2.5.Constitutive Laws]]<br />
* [[CSMm 2.6.HPC]]<br />
* [[CSMm 2.7.Problem Parameters]]<br />
* [[CSMm 2.8.Other Relevant Aspects]]<br />
* [[CSMm 3.Benchmarking]]<br />
* [[CSMm 4.Tutorials]]<br />
* [[CSMm 5.Contact People]]<br />
* [[CSMm 6.Aknowledgements]]<br />
* [[Convection Diffusion Module (CDm)]]<br />
* [[CDm 1.Introduction]]<br />
* [[CDm 2.Structure]]<br />
* [[CDm 2.1.Analysis type]]<br />
* [[CDm 2.2.Kinematical Approaches]]<br />
* [[CDm 2.3.Solution Strategies]]<br />
* [[CDm 2.4.Elements]]<br />
* [[CDm 2.5.Boundary Conditions]]<br />
* [[CDm 2.6.Initial Conditions]]<br />
* [[CDm 2.7.HPC]]<br />
* [[CDm 2.8.Problem Parameters]]<br />
* [[CDm 2.9.Other Relevant Aspects]]<br />
* [[CDm 3.Benchmarking]]<br />
* [[CDm 4.Tutorials]]<br />
* [[CDm 5.Contact People]]<br />
* [[CDm 6.Aknowledgements]]<br />
<br />
<br />
[[Category: Theory Manual]]</div>Rrossihttps://kratos-wiki.cimne.upc.edu/index.php/How_to_use_%22Smart_Pointers%22_within_KratosHow to use "Smart Pointers" within Kratos2014-12-05T17:30:46Z<p>Rrossi: </p>
<hr />
<div>All the memory management within Kratos is done through "Shared Pointers". <br />
Essentially a shared pointer '''is an entity which holds a counter with the number of estisting instances of an object.'''<br />
EVERY TIME a new Shared Pointer is created such counter is incremented or decremented <br />
to represent the number of living instances of the object pointed to.<br />
<br />
A good description of the design and behaviour of shared ptr can be found at the links:<br />
<br />
[http://en.wikipedia.org/wiki/Smart_pointer]<br />
<br />
In the practice when using Shared Pointers within Kratos one should be aware of their performance pitfalls so to be able to avoid them.<br />
<br />
The use of an existing pointer does not imply any performance penalty with respect to a traditional pointer, HOWEVER<br />
while creating and destroying a traditional "c-style" pointer is a cheap operation, the creation or destruction of a shared point <br />
is relatively time consuming. This is so, as at the moment of creating/destructing a Shared Pointer the number of references to the object should be incremented or decremented, which implies<br />
an atomic operation if OpenMP parallelism is employed.<br />
<br />
Within Kratos the great majority of shaered_ptrs is stored in vectors, typically in the classes<br />
- PointerVector (used as a basis for the "geometry" class)<br />
- PointerVectorSet (NodesContainerType, ElementsContainerType, ConditionsContainerType)<br />
- PointerVectorMap<br />
<br />
all of such objects provide two distinct operators:<br />
<br />
== OPERATOR [] ==<br />
this returns a reference to the object pointed by the underlying pointer. '''This is FAST''', and is the way it should be used<br />
<br />
== OPERATOR () ==<br />
this returns a pointer to the object, which will often require creating a copy of the pointer. '''THIS IS OFTEN SLOW''', only use it if your REALLY need a pointer.<br />
<br />
It is normally wise to use the operator [] instead of ()!<br />
<br />
similarly, '''make an attempt of NOT using GetGeometry().pGetNode(...)''' unless you really need a pointer, since this will imply allocating a new pointer and is hence an expensive operation.</div>Rrossi