How to Add a New Variable

From KratosWiki
Revision as of 15:51, 15 July 2013 by Maceli (Talk | contribs)
Jump to: navigation, search

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

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

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 make python aware of its existence inserting .../kratos/kratos/python/add_containers_to_python.cpp

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 if you need to use it:

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