Skip to content

ModelPart entities

Vicente Mataix Ferrándiz edited this page Mar 27, 2019 · 3 revisions

Starting

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 :

import KratosMultiphysics
import KratosMultiphysics.StructuralMechanicsApplication

this_model = Model()
structural_model_part = this_model.CreateModelPart("StructuralPart", 3)

structural_model_part.AddNodalSolutionStepVariable(DISPLACEMENT)
structural_model_part.AddNodalSolutionStepVariable(REACTION)

structural_model_part_io = ModelPartIO("KratosWorkshop2019_high_rise_building_CSM")
structural_model_part_io.ReadModelPart(structural_model_part)

Accessing Elements

The elements stored in the ModelPart can be accessed using the Elements parameter:

model_part_elements = structural_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 structural_model_part.Elements:
    print(element)

and printing the ID for all of the elements:

for element in structural_model_part.Elements:
    print(element.Id)

Accessing Conditions

Conditions parameter of model part provides access to the conditions it stores:

model_part_conditions = structural_model_part.Conditions

Iteration over conditions is very similar to the elements. In the same way printing conditions is as follow:

for condition in structural_model_part.Conditions:
    print(condition)

and printing the ID for all of the conditions:

for condition in structural_model_part.Conditions:
    print(condition.Id)

Project information

Getting Started

Tutorials

Developers

Kratos structure

Conventions

Solvers

Debugging, profiling and testing

HOW TOs

Utilities

Kratos API

Kratos Structural Mechanics API

Clone this wiki locally