How to Add a New Variable

From KratosWiki
(Difference between revisions)
Jump to: navigation, search
Line 6: Line 6:
 
  KRATOS_DEFINE_VARIABLE(double, NEW_VARIABLE)
 
  KRATOS_DEFINE_VARIABLE(double, NEW_VARIABLE)
  
or for a vectorial variable
+
or for a vectorial variable:
  
 
  KRATOS_DEFINE_3D_VARIABLE_WITH_COMPONENTS(NEW_VARIABLE)
 
  KRATOS_DEFINE_3D_VARIABLE_WITH_COMPONENTS(NEW_VARIABLE)
Line 18: Line 18:
  
  
or for a vectorial variable
+
or for a vectorial variable:
  
 
  KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(NEW_VARIABLE)
 
  KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(NEW_VARIABLE)
Line 29: Line 29:
 
  KRATOS_REGISTER_IN_PYTHON_VARIABLE( NEW_VARIABLE)
 
  KRATOS_REGISTER_IN_PYTHON_VARIABLE( NEW_VARIABLE)
  
or for a vectorial variable
+
or for a vectorial variable:
  
 
  KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS( NEW_VARIABLE)
 
  KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS( NEW_VARIABLE)

Revision as of 16:32, 15 July 2013

If you need to add a new variable NEW_VARIABLE to Kratos which doesn`t exist 4 passes are needed:


1. Define the variable in .../kratos/includes/variables.h (if you want to share the variable with different applications) or in .../applications/your_application/your_application.h (if the variable will be used by your application only)

KRATOS_DEFINE_VARIABLE(double, NEW_VARIABLE)

or for a vectorial variable:

KRATOS_DEFINE_3D_VARIABLE_WITH_COMPONENTS(NEW_VARIABLE)


2. Create & Register in .../kratos/sources/variables.cpp (if you want to share the variable with different applications) or in .../applications/your_application/your_application.cpp (if the variable will be used by your application only)

KRATOS_CREATE_VARIABLE(double, NEW_VARIABLE)
KRATOS_REGISTER_VARIABLE( NEW_VARIABLE)


or for a vectorial variable:

KRATOS_CREATE_3D_VARIABLE_WITH_COMPONENTS(NEW_VARIABLE)
KRATOS_REGISTER_3D_VARIABLE_WITH_COMPONENTS(NEW_VARIABLE)

3. Now, it is also necessary to make python aware of its existence by inserting in .../kratos/kratos/python/add_containers_to_python.cpp (if you want to share the variable with different applications) or in .../applications/your_application/custom_python/your_application_python_application.cpp (if the variable will be used by your application only):

KRATOS_REGISTER_IN_PYTHON_VARIABLE( NEW_VARIABLE)

or for a vectorial variable:

KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS( NEW_VARIABLE)

4. In your python script, remember to allocate memory for your new variable:

   AddVariables(model_part)
   model_part.AddNodalSolutionStepVariable( NEW_VARIABLE)
Personal tools
Categories