Skip to content

ModelPart and SubModelPart

Vicente Mataix Ferrándiz edited this page Mar 24, 2019 · 20 revisions

Here we introduce the basics to create and access to model parts and submodelparts.

Starting

First of all we need to create a python file with following code to import the KratosMultiphysics.

import KratosMultiphysics

Create Model

Then we need to create the Model, which will be the resposible to manage the different ModelParts that we will create.

this_model = KratosMultiphysics.Model()

Create ModelPart

Now we can create a ModelPart. For now we create the Main model part, which will store the successive submodelparts.

main_model_part = this_model.CreateModelPart("Main")

We can create a new model part with a certain buffer size using the following (we need to delete the model part to avoid errors):

this_model.DeleteModelPart("Main")
main_model_part = this_model.CreateModelPart("Main", 2)

We can now execute different operations with the Model:

print(this_model.HasModelPart("Main")) # It will return True
print(this_model.GetModelPartNames()) # It will return ['Main']
main_model_part_again = this_model.GetModelPart("Main") # Getting again

Create sub ModelPart

We can create a submodelpart with the following:

bc_model_part = main_model_part.CreateSubModelPart("BC")

Now we can do several operations with this:

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