Muscat.FE.Fields.IPField module¶
- class IPField(name: str | None = None, mesh: Mesh | None = None, rule: MeshQuadrature | None = None, ruleName: str | None = None, data: Dict[ElementType, ArrayLike] | None = None)[source]¶
Bases:
FieldBase
Class to hold information at the integration points
- Allocate(val: float64 = 0.0)[source]¶
Allocate the memory to store the data
- Parameters:
val (MuscatFloat, optional) – initial fill value, by default 0.
- CheckCompatibility(B: Any) None [source]¶
Check of two field are compatible to make arithmetic operations
- Parameters:
B (Any) – the other IpField
- Raises:
Exception – In the case the fields are not compatible
- Flatten(elementFilter: ElementFilter = None) np.ndarray [source]¶
Flatten all the data into a single ndarray
see also: self.SetDataFromNumpy
- Parameters:
elementFilter (ElementFilter, optional) – ElementFilter to operate, by default (None) all element are treated
- Returns:
the extracted data
- Return type:
np.ndarray
- GetCellRepresentation(fillValue: MuscatFloat = 0.0, method: str | int = 'mean') np.ndarray [source]¶
Function to push the data from the field into a vector homogeneous to the mesh (for visualization for example).
- Parameters:
fillValue (MuscatFloat, optional) – field value for cell without data, by default 0.
method (Union[str,int], optional) – the method to pass the information from the integration points to the cells: ‘mean’ : compute the mean value in every cell ‘max’ : extract the max value for every cell ‘min’ : extract the min value for every cell ‘maxDiff’: compute the maximal difference for every cell max(abs(vi-vj)) for i!=j in range(number of integration point) ‘maxDiffFraction’: same as before but divided by the mean value ‘int’ or, int: a int select a specific integration point the value is clipped to [0,number of integration point[ , by default ‘mean’
- Returns:
np.ndarray of size (number of elements in the mesh, 1) with the extracted information
- Return type:
np.ndarray
- GetDataFor(elementType: ED.ElementType) np.ndarray [source]¶
Get the numpy array storing the data for one type of element
- Parameters:
elementType (str) – the element name
- Returns:
the data of size (number of elements, number of integration points)
- Return type:
np.ndarray
- GetPointRepresentation(fillValue: MuscatFloat = 0.0, elementFilter: ElementFilter = None) np.ndarray [source]¶
Generate a point representation of this field
- Parameters:
fillValue (float, optional) – value to be used on nodes with no data available, by default 0.
elementFilter (ElementFilter, optional) – elements to construct the point representation, by default None
- Returns:
a numpy vector of size mesh.GetNumberOfNodes with the computed values
- Return type:
np.ndarray
- GetRestrictedIPField(elementFilter: ElementFilter) RestrictedIPField [source]¶
Create a RestrictedIPField only on element selected by the elementFilter
- Parameters:
elementFilter (ElementFilter) – ElementFilter to work on
- Returns:
a new RestrictedIPField
- Return type:
- GetRuleFor(elementType: ElementType) ElementaryQuadrature [source]¶
Helper function to get the integration rule for one type of elements
- Parameters:
elementType (str) – the element name
- Returns:
The integration rule, this is a tuple with the positions and the weight of the integration rule
- Return type:
ElementIntegrationRuleType
- SetDataFromNumpy(inData: ArrayLike, elementFilter: ElementFilter | None = None) None [source]¶
Set the internal data from a one dimensional array The user must allocate the memory before calling this function
see also: self.Flatten
- Parameters:
inData (ArrayLike) – the incoming data
elementFilter (ElementFilter, optional) – ElementFilter to operate, by default (None) all element are treated
- SetRule(ruleName: str | None = None, rule: MeshQuadrature | None = None)[source]¶
Set the integration rule to be used by the field
Please read the constructor documentation for more information about the arguments
- binaryOp(other: Any, op: Callable, out: IPField | None = None) IPField [source]¶
Internal function to apply a binary operator. A + B for example
- Parameters:
other (Any) – a second IPField
op (Callable) – the binary operator to apply
out (IPField, optional) – output IPFiled if Non is provided a new one is created, by default None, by default None
- Returns:
The output IPField
- Return type:
- Raises:
Exception – if the field are not compatible
Exception – if the binary operator cant be apply correctly
- class RestrictedIPField(name: str | None = None, mesh: Mesh | None = None, rule: MeshQuadrature | None = None, ruleName: str | None = None, data: Dict[str, ArrayLike] | None = None, elementFilter: ElementFilter | None = None)[source]¶
Bases:
IPField
Class to hold information at integration point on a subdomain of the mesh (ElementFilter) This class is experimental and for the moment not compatible with the integration module
- Allocate(val: float64 = 0.0) None [source]¶
Allocate the memory to store the data
- Parameters:
val (MuscatFloat, optional) – initial fill value, by default 0.
- AllocateFromIpField(inputIPField: IPField | RestrictedIPField) None [source]¶
Fill internal data from a external ipField (data is copied)
- Parameters:
ipField (Union[IPField,RestrictedIPField]) – The IPField to extract the data
- Raises:
Exception – In the case the inputIPField is not of the type IPField or RestrictedIPField
- CheckCompatibility(B: Any) None [source]¶
Check of two field are compatible to make arithmetic operations
- Parameters:
B (Any) – the other RestrictedIPField
- Raises:
Exception – In the case the fields are not compatible
- GetCellRepresentation(fillValue: MuscatFloat = 0.0, method: str | int = 'mean') np.ndarray [source]¶
Function to push the data from the field into a vector homogeneous to the mesh (for visualization for example).
- Parameters:
fillValue (MuscatFloat, optional) – field value for cell without data, by default 0.
method (Union[str,int], optional) – the method to pass the information from the integration points to the cells: ‘mean’ : compute the mean value in every cell ‘max’ : extract the max value for every cell ‘min’ : extract the min value for every cell ‘maxDiff’: compute the maximal difference for every cell max(abs(vi-vj)) for i!=j in range(number of integration point) ‘maxDiffFraction’: same as before but divided by the mean value ‘int’ or, int: a int select a specific integration point the value is clipped to [0,number of integration point[ , by default ‘mean’
- Returns:
np.ndarray of size (number of elements in the mesh, 1) with the extracted information
- Return type:
np.ndarray
- GetIpFieldRepresentation(fillValue: float64 = 0.0) IPField [source]¶
Get a IPFieldRepresentation. Function to expand the representation to he hold domain
- Parameters:
fillValue (MuscatFloat, optional) – field value for cell without data, by default 0.
- Returns:
IPField over the all the element with fillValue on element not covered by the RestrictedIPField
- Return type:
- GetRestrictedIPField(elementFilter: ElementFilter) RestrictedIPField [source]¶
Create a RestrictedIPField only on element intersection between elementFilter and the internal elementFilter
- Parameters:
elementFilter (ElementFilter) – ElementFilter to work on
- Returns:
a new RestrictedIPField
- Return type:
- SetDataFromNumpy(inData: ArrayLike) None [source]¶
Set the internal data from a one dimensional array The user must allocate the memory before calling this function
- Parameters:
inData (ArrayLike) – the incoming data
elementFilter (ElementFilter, optional) – ElementFilter to operate, by default (None) all element are treated
- binaryOp(other: Any, op: Callable, out: RestrictedIPField | None = None) RestrictedIPField [source]¶
Internal function to apply a binary operator. A + B for example
- Parameters:
other (Any) – a second RestrictedIPField
op (Callable) – the binary operator to apply
out (RestrictedIPField, optional) – output RestrictedIPFiled, if None is provided a new one is created, by default None, by default None, by default None
- Returns:
The output RestrictedIPField
- Return type:
- unaryOp(op: Callable, out: RestrictedIPField | None = None) RestrictedIPField [source]¶
Internal function to apply a unary operation
- Parameters:
op (Callable) – a function to apply to the data
out (RestrictedIPField, optional) – output IPFiled if non is provided a new one is created, by default None
- Returns:
The output RestrictedIPField
- Return type: