-
Notifications
You must be signed in to change notification settings - Fork 248
Python Script Tutorial: ModelPart Elements and Conditions
The elements and conditions are the main extension points of the Kratos. In input script accessing them improves the flexibility in dealing with complex problems.
First of all we need to create a python file with following code to import the Kratos, create a ModelPart
and read it from input as described in the here :
from KratosMultiphysics import *
import KratosMultiphysics.FluidDynamicsApplication
this_model = Model()
fluid_model_part = this_model.CreateModelPart("FluidPart")
fluid_model_part.AddNodalSolutionStepVariable(VELOCITY)
fluid_model_part.AddNodalSolutionStepVariable(PRESSURE)
fluid_model_part.AddNodalSolutionStepVariable(TEMPERATURE)
fluid_model_part_io = ModelPartIO("path/to/file/example")
fluid_model_part_io.ReadModelPart(fluid_model_part)
fluid_model_part.SetBufferSize(3)
The elements stored in the ModelPart can be accessed using the Elements parameter:
model_part_elements = fluid_model_part.Elements
Iteration over all elements in a model part is very similar to the nodes. For example writing the elements in a model part can be done as follow:
for element in fluid_model_part.Elements:
print(element)
and printing the ID for all of the elements:
for element in fluid_model_part.Elements:
print(element.Id)
Conditions parameter of model part provides access to the conditions it stores:
model_part_conditions = fluid_model_part.Conditions
Iteration over conditions is very similar to the elements. In the same way printing conditions is as follow:
for condition in fluid_model_part.Conditions:
print(condition)
and printing the ID for all of the conditions:
for condition in fluid_model_part.Conditions:
print(condition.Id)
Prev Nodes and Nodal Data
- Getting Kratos (Last compiled Release)
- Compiling Kratos
- Running an example from GiD
- Kratos input files and I/O
- Data management
- Solving strategies
- Manipulating solution values
- Multiphysics
- Video tutorials
- Style Guide
- Authorship of Kratos files
- Configure .gitignore
- How to configure clang-format
- How to use smart pointer in Kratos
- How to define adjoint elements and response functions
- Visibility and Exposure
- Namespaces and Static Classes
Kratos structure
Conventions
Solvers
Debugging, profiling and testing
- Compiling Kratos in debug mode
- Debugging Kratos using GDB
- Cross-debugging Kratos under Windows
- Debugging Kratos C++ under Windows
- Checking memory usage with Valgind
- Profiling Kratos with MAQAO
- Creating unitary tests
- Using ThreadSanitizer to detect OMP data race bugs
- Debugging Memory with ASAN
HOW TOs
- How to create applications
- Python Tutorials
- Kratos For Dummies (I)
- List of classes and variables accessible via python
- How to use Logger
- How to Create a New Application using cmake
- How to write a JSON configuration file
- How to Access DataBase
- How to use quaternions in Kratos
- How to do Mapping between nonmatching meshes
- How to use Clang-Tidy to automatically correct code
- How to use the Constitutive Law class
- How to use Serialization
- How to use GlobalPointerCommunicator
- How to use PointerMapCommunicator
- How to use the Geometry
- How to use processes for BCs
- How to use Parallel Utilities in futureproofing the code
- Porting to Pybind11 (LEGACY CODE)
- Porting to AMatrix
- How to use Cotire
- Applications: Python-modules
- How to run multiple cases using PyCOMPSs
- How to apply a function to a list of variables
- How to use Kratos Native sparse linear algebra
Utilities
Kratos API
Kratos Structural Mechanics API