Source code for pyleecan.Classes.Element

# -*- coding: utf-8 -*-
"""File generated according to Generator/ClassesRef/Mesh/Element.csv
WARNING! All changes made in this file will be lost!
"""

from os import linesep
from logging import getLogger
from ._check import check_var, raise_
from ..Functions.get_logger import get_logger
from ..Functions.save import save
from ._frozen import FrozenClass

from ._check import InitUnKnowClassError


[docs]class Element(FrozenClass): """Abstract class to define connectivity and getter.""" VERSION = 1 # save method is available in all object save = save # generic copy method
[docs] def copy(self): """Return a copy of the class """ return type(self)(init_dict=self.as_dict())
# get_logger method is available in all object get_logger = get_logger def __init__(self, init_dict=None, init_str=None): """Constructor of the class. Can be use in two ways : - __init__ (arg1 = 1, arg3 = 5) every parameters have name and default values for Matrix, None will initialise the property with an empty Matrix for pyleecan type, None will call the default constructor - __init__ (init_dict = d) d must be a dictionnary wiht every properties as keys ndarray or list can be given for Vector and Matrix object or dict can be given for pyleecan Object""" if init_dict is not None: # Initialisation by dict assert init_dict == {"__class__": "Element"} if init_str is not None: # Initialisation by str assert type(init_str) is str # The class is frozen, for now it's impossible to add new properties self.parent = None self._freeze() def __str__(self): """Convert this objet in a readeable string (for print)""" Element_str = "" if self.parent is None: Element_str += "parent = None " + linesep else: Element_str += "parent = " + str(type(self.parent)) + " object" + linesep return Element_str def __eq__(self, other): """Compare two objects (skip parent)""" if type(other) != type(self): return False return True
[docs] def as_dict(self): """Convert this objet in a json seriable dict (can be use in __init__) """ Element_dict = dict() # The class name is added to the dict fordeserialisation purpose Element_dict["__class__"] = "Element" return Element_dict
def _set_None(self): """Set all the properties to None (except pyleecan object)"""