Gmsh2OPS¶
- class opstool.pre.Gmsh2OPS(ndm=3, ndf=3)[source]¶
Bases:
objectGenerate OpenSees code from GMSH.
Parameters¶
- ndm: int, default=3
Model dimension
- ndf: int, default=3
Number of degrees of freedom.
Methods
Create
OpenSeesPyelements at runtime.Create fix constraints for OpenSeesPy at runtime.
Create
OpenSeesPynodes at runtime.Get all boundaries of the GMSH entities, including corner points.
Get dim_entity_tags from GMSH.
Return element tags in Gmsh, which will also be the same as in OpenSeesPy.
Return node tags in Gmsh, which will also be the same as in OpenSeesPy.
Get the GMSH physical groups.
Read data from
GMSHat runtime.Read an
.mshfile generated byGMSH.Parameters: filename: str, default = "src.tcl". The output file-path-name must end with .tcl or .py. encoding: str, default = "utf-8". The file encoding.
Write elements a command file,
TclorPython.Write node fix commands file, Tcl or Python.
Write a node commands file, Tcl or Python.
- set_output_file(filename='src.tcl', encoding='utf-8')[source]¶
Parameters:¶
- filename: str, default = “src.tcl”.
The output file-path-name must end with
.tclor.py.- encoding: str, default = “utf-8”.
The file encoding.
- read_gmsh_file(file_path, encoding='utf-8', print_info=True)[source]¶
Read an
.mshfile generated byGMSH.Note
You only need to use one of
read_gmsh_fileandread_gmsh_data.read_gmsh_fileis used to read data from the.mshfile, andread_gmsh_datais used to read data from the runtime memory.Parameters¶
- file_path: str
the file path.
- encoding: str, default=’utf-8’
The file encoding.
- print_info: bool, default=True
Print info.
- read_gmsh_data(print_info=True)[source]¶
Read data from
GMSHat runtime.Note
When using a command such as
gmsh.finalize()to close gmsh, you need to use it after this command, otherwise the data cannot be read.You only need to use one of
read_gmsh_fileandread_gmsh_data.read_gmsh_fileis used to read data from the.mshfile, andread_gmsh_datais used to read data from the runtime memory.
Parameters¶
- print_info: bool, default=True
Print info.
- get_node_tags(dim_entity_tags=None, physical_group_names=None)[source]¶
Return node tags in Gmsh, which will also be the same as in OpenSeesPy.
- Return type:
list
Parameters¶
- dim_entity_tags: list, the GMSH [(dim, entity tag), …].
A list of GMSH dimension and entity tags. If None, physical_group_names will be used.
- physical_group_names: list, tuple, str, or None, default None.
The physical group name or list of physical group names. If None, dim_entity_tags will be used.
Note
If dim_entity_tags and physical_group_names are both None, all entities will be converted.
If dim_entity_tags and physical_group_names are both not None, dim_entity_tags will be used.
Returns¶
- node_tags: list
A list containing node tags.
- create_node_cmds(dim_entity_tags=None, physical_group_names=None)[source]¶
Create
OpenSeesPynodes at runtime.- Return type:
list
Parameters¶
- dim_entity_tags: list, the GMSH [(dim, entity tag), …].
A list of GMSH dimension and entity tags. If None, physical_group_names will be used.
- physical_group_names: list, tuple, str, or None, default None.
The physical group name or list of physical group names. If None, dim_entity_tags will be used.
Note
If dim_entity_tags and physical_group_names are both None, all entities will be converted.
If dim_entity_tags and physical_group_names are both not None, dim_entity_tags will be used.
Returns¶
node_tags: list, a list containing openseespy node tags.
- write_node_file(dim_entity_tags=None, physical_group_names=None)[source]¶
Write a node commands file, Tcl or Python.
Parameters¶
- dim_entity_tags: list, the GMSH [(dim, entity tag), …].
A list of GMSH dimension and entity tags. If None, physical_group_names will be used.
- physical_group_names: list, tuple, str, or None, default None.
The physical group name or list of physical group names. If None, dim_entity_tags will be used.
Note
If dim_entity_tags and physical_group_names are both None, all entities will be converted.
If dim_entity_tags and physical_group_names are both not None, dim_entity_tags will be used.
- get_element_tags(dim_entity_tags=None, physical_group_names=None)[source]¶
Return element tags in Gmsh, which will also be the same as in OpenSeesPy.
- Return type:
list
Parameters¶
- dim_entity_tags: list, the GMSH [(dim, entity tag), …].
A list of dimension and entity tag containing element information that will be converted to OpenSeesPy elements. If None, physical_group_names will be used.
- physical_group_names: list, tuple, str, or None, default None.
The physical group name or list of physical group names. If None, dim_entity_tags will be used.
Note
If dim_entity_tags and physical_group_names are both None, all entities will be converted.
If dim_entity_tags and physical_group_names are both not None, dim_entity_tags will be used.
Returns¶
- ele_tags: list
A list containing element tags.
- create_element_cmds(ops_ele_type, ops_ele_args=None, dim_entity_tags=None, physical_group_names=None)[source]¶
Create
OpenSeesPyelements at runtime.- Return type:
list
Parameters¶
- ops_ele_type: str
the OpenSeesPy element type to generate.
- ops_ele_args: list, default None
Parameters except OpenSeesPy element tag and connected node tags. If None, an empty list will be used.
- dim_entity_tags: list, the GMSH [(dim, entity tag), …].
A list of dimension and entity tag containing element information that will be converted to OpenSeesPy elements. If None, physical_group_names will be used.
- physical_group_names: list, tuple, str, or None, default None.
The physical group name or list of physical group names. If None, dim_entity_tags will be used.
Note
If dim_entity_tags and physical_group_names are both None, all entities will be converted.
If dim_entity_tags and physical_group_names are both not None, dim_entity_tags will be used.
Returns¶
ele_tags: list, a list containing openseespy element tags.
- write_element_file(ops_ele_type, ops_ele_args=None, dim_entity_tags=None, physical_group_names=None)[source]¶
Write elements a command file,
TclorPython.Parameters¶
- ops_ele_type: str
the OpenSeesPy element type to generate.
- ops_ele_args: list, default None
Parameters except OpenSeesPy element tag and connected node tags. If None, an empty list will be used.
- dim_entity_tags: list, the GMSH [(dim, entity tag), …].
A list of dimension and entity tag containing element information that will be converted to OpenSeesPy elements. If None, physical_group_names will be used.
- physical_group_names: list, tuple, str, or None, default None.
The physical group name or list of physical group names. If None, dim_entity_tags will be used.
Note
If dim_entity_tags and physical_group_names are both None, all entities will be converted.
If dim_entity_tags and physical_group_names are both not None, dim_entity_tags will be used.
Returns¶
ele_tags: list, a list containing openseespy element tags.
- create_fix_cmds(dofs, dim_entity_tags=None, physical_group_names=None)[source]¶
Create fix constraints for OpenSeesPy at runtime.
- Return type:
list
Parameters¶
- dofs: list, degrees of freedom to be constrained.
Forexample, [1, 1, 1] for 3D and 3Dof.
- dim_entity_tags: list, the GMSH [(dim, entity tag), …].
A list of GMSH dimension and entity tags. If None, physical_group_names will be used.
- physical_group_names: list, tuple, str, or None, default None.
The physical group name or list of physical group names. If None, dim_entity_tags will be used.
Note
If dim_entity_tags and physical_group_names are both None, all entities will be converted.
If dim_entity_tags and physical_group_names are both not None, dim_entity_tags will be used.
Returns¶
node_tags: list, a list containing openseespy fixed node tags.
- write_fix_file(dofs, dim_entity_tags=None, physical_group_names=None)[source]¶
Write node fix commands file, Tcl or Python.
Parameters¶
- dofs: list, degrees of freedom to be constrained.
Forexample, [1, 1, 1] for 3D and 3Dof.
- dim_entity_tags: list, the GMSH [(dim, entity tag), …].
A list of GMSH dimension and entity tags. If None, physical_group_names will be used.
- physical_group_names: list, tuple, str, or None, default None.
The physical group name or list of physical group names. If None, dim_entity_tags will be used.
Note
If dim_entity_tags and physical_group_names are both None, all entities will be converted.
If dim_entity_tags and physical_group_names are both not None, dim_entity_tags will be used.
- get_dim_entity_tags(dim=None)[source]¶
Get dim_entity_tags from GMSH.
- Return type:
list
Parameters¶
- dim: int, optional, default None
The dimension tag. If None, all entities will be returned.
Returns¶
dim_entity_tags: list, the GMSH [(dim, entity tag), …].
- get_physical_groups()[source]¶
Get the GMSH physical groups.
- Return type:
dict
Returns¶
gmsh_physical_groups: dict, the GMSH physical groups. dict[key=name, value=[(dim, entity_tag), …]]
- get_boundary_dim_tags(dim_entity_tags=None, physical_group_names=None, include_self=False)[source]¶
Get all boundaries of the GMSH entities, including corner points.
- Return type:
list
Parameters¶
- dim_entity_tags: list, the GMSH [(dim, entity tag), …].
A list of GMSH dimension and entity tags. If None, physical_group_names will be used.
- physical_group_names: list, tuple, str, or None, default None.
The physical group name or list of physical group names. If None, dim_entity_tags will be used.
- include_self: bool, default False
If True, the output contains itself, which is dim_entity_tags.
Note
If dim_entity_tags and physical_group_names are both None, all entities will be converted.
If dim_entity_tags and physical_group_names are both not None, dim_entity_tags will be used.
Returns¶
Boundary dimension and entity tags list.