:py:mod:`FELiCS.Fields.meanFlowClass` ===================================== .. py:module:: FELiCS.Fields.meanFlowClass Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: FELiCS.Fields.meanFlowClass.meanFlowClass FELiCS.Fields.meanFlowClass.meanFlowVertexValues Attributes ~~~~~~~~~~ .. autoapisummary:: FELiCS.Fields.meanFlowClass.logger .. py:data:: logger .. py:class:: meanFlowClass(param, FEMSpaces, mesh) Bases: :py:obj:`FELiCS.Fields.fieldProperties.fieldProperties`, :py:obj:`FELiCS.Equation.dependentVariables.energyHandler.energyHandler`, :py:obj:`FELiCS.Equation.dependentVariables.reactionHandler.reactionHandler`, :py:obj:`FELiCS.Equation.dependentVariables.equationOfStateHandler.equationOfStateHandler` Container and handler for mean-flow fields on a given mesh. This class manages reading, storing, and post-processing of mean-flow quantities from external files and provides auxiliary fields and thermodynamic/transport properties required by FELiCS solvers. **Initialize the meanFlowClass object** :param param: Global parameter object providing case, mixture and I/O configuration, e.g. `param.FlowInput`, `param.Case`, and `param.Mixture`. :type param: :py:class:`object` :param FEMSpaces: Collection of finite element function spaces, expected to provide attributes such as ``P2`` and ``FunctionSpaceVectorVelocity``. :type FEMSpaces: :py:class:`object` :param mesh: Mesh object used to define the function spaces, expected to provide attributes such as ``coordinateSystem`` and ``exportMesh``. :type mesh: :py:class:`object` :ivar _isMean: Flag indicating that this instance represents a mean flow (always True). :vartype _isMean: :py:class:`bool` :ivar _isFluctuation: Flag indicating that this instance represents a fluctuation field (always False for mean flow). :vartype _isFluctuation: :py:class:`bool` :ivar _param: Reference to the global parameter object used for configuration. :vartype _param: :py:class:`object` :ivar _FEMSpaces: Reference to the FEM spaces used for field definitions. :vartype _FEMSpaces: :py:class:`object` :ivar _mesh: Reference to the mesh used for the fields. :vartype _mesh: :py:class:`object` :ivar _coordinateSystem: Coordinate system information taken from the mesh. :vartype _coordinateSystem: :py:class:`str` or :py:class:`object` :ivar _meanflowFilename: Optional path to the processed mean-flow file (set when exporting). :vartype _meanflowFilename: :py:class:`str` or :py:obj:`None` :ivar _mixture: Mixture model taken from ``param.Mixture``. :vartype _mixture: :py:class:`object` :ivar _zeroVectorField: Vector field initialized to zero on the velocity space. :vartype _zeroVectorField: :py:class:`Field` :ivar _zeroField: Scalar field initialized to zero on the scalar space. :vartype _zeroField: :py:class:`Field` :ivar _oneField: Scalar field initialized to one on the scalar space. :vartype _oneField: :py:class:`Field` :ivar _customMeanFlowQuantities: List of additional mean-flow quantity names requested by the user. :vartype _customMeanFlowQuantities: :py:class:`list` of :py:class:`str` :ivar _fieldDict: Dictionary of all mean-flow fields after import. :vartype _fieldDict: :py:class:`dict` of ``{str: Field}`` :ivar _notInFileList: Names of requested fields that were not found in the input file. :vartype _notInFileList: :py:class:`list` of :py:class:`str` :ivar _ScalarFunctionSpace: Scalar function space used for viscosity and diffusion fields. :vartype _ScalarFunctionSpace: :py:class:`object` :ivar _VectorFunctionSpace: Vector function space used for velocity-related fields. :vartype _VectorFunctionSpace: :py:class:`object` :ivar xmfHeader: Metadata returned by the writer when exporting mean fields. :vartype xmfHeader: :py:class:`object` .. admonition:: Notes The class delegates the specification of additional required fields to the handler base classes (`energyHandler`, `equationOfStateHandler`, `reactionHandler`). These base classes provide lists of extra field names needed for their respective models. .. py:method:: importDataFromFileAndExportToH5(writer) Import mean-flow fields from the configured input file and export them. This method reads the mean-flow quantities from the file specified in ``param.FlowInput.MeanFlowFilePath``, constructs `Field` instances for all required variables, computes additional transport and thermodynamic quantities, and exports the assembled set of fields to an HDF5 file. :param writer: Writer object providing an ``exportListOfFieldsToH5`` method used to export the list of mean-flow fields. :type writer: :py:class:`object` .. admonition:: Notes The set of fields to be read is assembled from: - the mean-flow field names defined in ``param``, - additional fields required by the energy, equation-of-state, and reaction handlers and - any custom mean-flow quantities added by the user. If the density field ``rho`` is requested but not present in the file, its values are initialized to a constant of 1.0. If a turbulent velocity field ``ut`` exists, it is initialized to zero. After import, transport coefficients and thermodynamic quantities are initialized via :meth:`initLamDiff` and :meth:`initThermodynamicQuantities`. .. py:method:: initLamDiff() Initialize molecular viscosity and species diffusion coefficients. Based on the selected molecular viscosity model and the mixture data, this method constructs the laminar viscosity field ``nulam`` (if a constant model is used) and computes species diffusion coefficients ``D_`` using the corresponding Schmidt numbers. The effective kinematic viscosity for each species is assembled from the available contributions: ``nulam``, ``nuturb`` and ``nuSGS``, if present in ``_fieldDict``. .. admonition:: Notes This routine populates the following entries in ``_fieldDict``: - ``'nulam'`` : Field Constant laminar viscosity (for constant viscosity models). - ``'D_'`` : Field Species diffusion coefficients for transported species. .. py:method:: initThermodynamicQuantities() Initialize thermodynamic mean-flow quantities. Currently this method creates and initializes the Prandtl number field ``'Pr'`` in ``_fieldDict`` using the value from ``param.Case.PrandtlNumber``. .. admonition:: Notes The ``'Pr'`` field is defined on the scalar P2 function space. .. py:method:: calculateSpeciesEnthalpy() Compute and store species sensible enthalpies. This method constructs JANAF thermodynamic species for several common gas components and evaluates their sensible enthalpy expressions at the current temperature field ``T``. The resulting enthalpy fields are projected onto the P2 space and stored in the ``_hSpec`` dictionary. .. admonition:: Notes The following species are currently supported: - CH₄ - O₂ - CO - CO₂ - H₂O (gaseous) The resulting dictionary entries are: - ``_hSpec['CH4']`` - ``_hSpec['O2']`` - ``_hSpec['CO']`` - ``_hSpec['CO2']`` - ``_hSpec['H2O']`` Each entry holds a finite element function representing the sensible enthalpy of the corresponding species. .. py:method:: getVertexValues() Return vertex-based values of all mean-flow fields. The method converts the internal dictionary of finite element fields to vertex-based arrays and wraps them into a :class:`meanFlowVertexValues` instance. :returns: Object containing vertex values for all fields in ``_fieldDict``, based on the mesh exported by ``self._mesh.exportMesh``. :rtype: :py:class:`meanFlowVertexValues` .. py:method:: addCustomMeanFlowQuantity(key) Register an additional mean-flow quantity to be read. :param key: Name of the additional mean-flow quantity that should be included when assembling the list of fields to import. :type key: :py:class:`str` .. admonition:: Notes The key is appended to the internal list ``_customMeanFlowQuantities`` and will be included by :meth:`_getMeanFieldsToBeRead`. Duplicates are removed when the final list of field names is constructed. .. py:class:: meanFlowVertexValues(fieldDict, mesh) Bases: :py:obj:`FELiCS.Fields.fieldProperties.fieldProperties` Vertex-based representation of mean-flow fields. This class converts `Field` objects storing finite element solutions into arrays of vertex values, providing a convenient interface for post-processing and exporting mean-flow quantities on the mesh vertices. **Initialize the meanFlowVertexValues object** :param fieldDict: Dictionary of mean-flow fields whose vertex values will be extracted. :type fieldDict: :py:class:`dict` of ``{str: Field}`` :param mesh: Mesh object providing coordinates for the vertex arrays (typically ``mesh.exportMesh`` from the mean-flow class). :type mesh: :py:class:`object` :ivar _fieldDict: Dictionary mapping field names to vertex-value arrays. For scalar fields, the values are stored as 1D arrays. For vector-valued fields, the values are stored as 2D arrays with shape ``(num_components, num_vertices)``. :vartype _fieldDict: :py:class:`dict` :ivar _isMean: Flag indicating that these values correspond to mean-flow quantities. :vartype _isMean: :py:class:`bool` :ivar _zeroField: Convenience array of zeros with length equal to the number of mesh vertices. :vartype _zeroField: :py:class:`ndarray` :ivar _oneField: Convenience array of ones with length equal to the number of mesh vertices. :vartype _oneField: :py:class:`ndarray` .. admonition:: Notes Vector-valued fields are handled by extracting each component from the corresponding subspace and assembling them into a single stacked array.