CRIMSONCore

CRIMSONCore.FaceIdentifier

class CRIMSONCore.FaceIdentifier.FaceIdentifier(faceType, parentSolidIndices)

The FaceIdentifier object represents a unique identifier for a geometric model face. Unique face identifier consists of a list of solid identifiers (strings) automatically generated by CRIMSON during the lofting operation, and a face type which can be a wall, an inflow, or an outflow. The face types are defined by the PythonQt.CRIMSON.FaceType enumeration.

For the models not created in CRIMSON, but created in an external tool and imported, the flat faces are marked as FaceType.ftCapOutflow and the curved faces are marked as FaceType.ftWall, and the parentSolidIndices contain a single string of form face #, where # is the index of the face computed during model import.

CRIMSONCore.PropertyStorage

class CRIMSONCore.PropertyStorage.PropertyStorage

The PropertyStorage class is a convenience class for communicating the various properties of a boundary condition or solver parameters to the C++ code for the user to edit.

The property is defined as a dictionary which must contain at least one string key with a value. The type of the property value is determined by the type of value itself:

{
    "IntegerProperty": 42
}

will define a property with an integer value, whereas

{
    "DoubleProperty": 42.0
}

will define a property with a floating-point value.

Each property can also have multiple attributes that affect the user interaction for value editing, such as minimum and maximum values, stored in a dictionary:

{
    "PropertyWithAttributes": 42,
    "attributes": {"minumum": 3, "maximum": 100}
}

The types of properties and their attributes are described in section Property reference.

In addition to value-properties, various properties can also be grouped. The group is a property, whose value attribute is a list of other properties:

{
    "Group": [
        {
            "Property 1": 0
        },
        {
            "Property 2": 5.0
        }
    ]
}

Group properties can also be nested.

The PropertyStorage.properties is a top-level group which contains all the properties for a boundary condition or solver parameters.

All the properties should be defined in the constructor of the class inheriting from PropertyStorage and cannot be changed at run time. Here’s a complete example of defining a solver parameters with multiple grouped parameters:

class SolverParameters(PropertyStorage):
def __init__(self):
    PropertyStorage.__init__(self)
    self.properties = [
        {
            "Time parameters": [
                {
                    "Number of time steps": 200,
                    "attributes": {"minimum": 1}
                },
                {
                    "Time step size": 0.01,
                    "attributes": {"minimum": 0.0, "suffix": " s"}
                }
            ]
        },
        {
            "Fluid parameters": [
                {
                    "Viscosity": 0.004,
                    "attributes": {"minimum": 0.0, "suffix": u" g/(mm\u00B7s)"}
                },
                {
                    "Density": 0.00106,
                    "attributes": {"minimum": 0.0, "suffix": u" g/mm\u00B3"}
                }
            ]
        },
    ]

Property reference

Each property is a dictionary with a required keys-value pair from property name to its value, and an optional key attributes:

{
    str: value_type,
    "attributes": dict
}

The attributes only affect the user interaction with a GUI element representing the value. The attributes available for each property type are described below.

Integer property

value_type is int. Represented as a spin box.

Attributes
minimum:int minimum value (default: minimum representable int).
maximum:int maximum value (default: maximum representable int).
prefix:str the prefix to be added before the value (default: "").
suffix:str the suffix to be added after the value (default: ""). For example, measurement unit.
singleStep:int a single step for increment/decrement buttons (default: 1).

Example:

{
    "Number of time steps": 200,
    "attributes": {
        "minimum": 1,
        "maximum": 10000,
        "prefix": "",
        "suffix": " s",
        "singleStep": 5
        }
},

Floating-point property

value_type is float. Represented as a double-valued spin box.

Attributes
minimum:float minimum value (default: minimum representable float).
maximum:float maximum value (default: maximum representable float).
prefix:str the prefix to be added before the value (default: "").
suffix:str the suffix to be added after the value (default: ""). For example, measurement unit.
singleStep:float a single step for increment/decrement buttons (default: 1.0).
decimals:int the displayed precision of the floating point value (default: 50). Only necessary digits are displayed, i.e. 1.5 will be shown and not 1.50000000.

Example:

{
    "Viscosity": 0.004,
    "attributes": {
        "minimum": 0.0,
        "maximum": 100.0,
        "prefix": "",
        "suffix": u" g/(mm\u00B7s)",
        "singleStep": 0.1,
        "decimals": 2
        }
}
Boolean property

value_type is bool. Represented as a check box with text for True and False values.

Attributes
  • None

Example:

{
    "Residual control": True,
}
String property

value_type is str. Represented as a text edit.

Attributes
  • None

Example:

{
    "Simulation name": "Great simulation",
}
Enumeration property

value_type is int. The enumeration properties are int properties that also have the enumNames attribute. Represented as a combo-box with the items to be selected.

Attributes
enumNames:list A list of strings that correspond to the values of the enumeration.

Example:

class CouplingType(object):
    enumNames = ["Explicit", "Implicit", "P-Implicit"]
    Explicit, Implicit, PImplicit = range(3)


# ...

{
    "Pressure coupling": CouplingType.Implicit,
    "attributes": {"enumNames": CouplingType.enumNames}
}
getProperties()

Get an accessor proxy class that allows to query the properties simply by name. To access a property with a particular name, e.g., 'Number of time steps', use:

getProperties()['Number of time steps'] 

If the property name is not unique, e.g., there is a 'Number of time steps' property in property groups 'Run 1' and 'Run 2', use:

getProperties()['Run 2']['Number of time steps']

to disambiguate the access.

CRIMSONCore.FaceData

class CRIMSONCore.FaceData.FaceData

Base class for all face-attached data classes (e.g. boundary conditions and materials).

In addition to having the functionality of a PropertyStorage, the face data also stores a list of face identifiers stored in FaceData.faceIdentifiers which are filled by the C++ code through user interaction.

CRIMSONCore.SolutionStorage

class CRIMSONCore.SolutionStorage.SolutionStorage(arrays=None)

SolutionStorage class is used to pass the loaded solution data to the C++ code. The arrays data member is a dict mapping name of the data array, e.g. ‘velocity’ or ‘pressure’, to the instance of SolutionStorage.ArrayInfo class. SolutionStorage.ArrayInfo contains the data itself in form of a 2D numpy.ndarray and the names of components for multi-component arrays. Allowed data types for the data are numpy.int32 and numpy.float64.

class ArrayInfo(data, componentNames=None)

A convenience class for storing the solution name (string) and data (numpy.ndarray).