Mordicus.Core.IO.SolutionReaderBase module

class Mordicus.Core.IO.SolutionReaderBase.SolutionReaderBase[source]

Bases: object

Class containing the SolutionReaderBase associated to a HF solution file

ReadReducedOrderBasis(fileName, solutionStructure, fieldName)[source]

Converts the format into Mordicus reduced order basis for reading fields

Parameters
  • fileName (str) – file to read reduced basis from

  • fieldStructure (SolutionStructureBase) – field structure giving the context to interpret the vector in terms of field values on the mesh

  • fieldName (str) – name of field associated with the basis (e.g. “U”, “sigma”)

Returns

reducedOrderBasis – numpy array of the modes

Return type

nparray(numberOfModes, numberOfDofs)

ReadSnapshotComponent(fieldName, time, primality)[source]

Reads a snapshots from the solutions of name “fieldName”, at time “time” and of primality “primality”, from the HF computation

Parameters
  • fieldName (str) – name of the solution from which the snapshot is read

  • time (float) – time at which the snapshot is read

  • primality (bool) – primality of the solution from which the snapshot is read

Returns

of size (numberOfDofs,)

Return type

np.ndarray

ReadSnapshotComponentTimeSequence(fieldName, timeSequence, primality)[source]

Reads a snapshots from the solutions of name “fieldName”, at time sequence “timeSequence” and of primality “primality”, from the HF computation

Parameters
  • fieldName (str) – name of the solution from which the snapshot is read

  • timeSequence (np.ndarray) – of size (numberOfSnapshots,)

  • primality (bool) – primality of the solution from which the snapshot is read

Returns

of size (numberOfSnapshots,numberOfDofs)

Return type

np.ndarray

ReadTimeSequenceFromSolutionFile()[source]

Reads the time sequence from the solution file of the HF computation (may be different from the ones defined in the input data file if the solver chose to solve at additional time steps)

Returns

of size (numberOfSnapshots,)

Return type

np.ndarray

WriteNumbering(fileName, fieldStructure, fieldName, nameInFile=None)[source]

Write an identity application on the input, gets the permutation application on the output. This method is used to convert operators from a FEM code to the numbering system associated

with the format of the results (for instance be able to get a consistent numbering between a mass matrix computed with Code_Aster and the results written to MED format)

Parameters
  • fileName (str) – MED file to write permutation to

  • fieldStructure (SolutionStructureBase) – field structure for which the numbering system has to be converted

  • fieldName (str) – identifier of the physical quantity for the field

  • nameInFile (str) – to customize field name in output MED file fileName

WriteReducedOrderBasis(fileName, solutionStructure, reducedOrderBasis, fieldName)[source]

Converts Mordicus reduced order basis into the format for writing fields

Parameters
  • fileName (str) – file to write reduced basis to

  • fieldStructure (SolutionStructureBase) – field structure giving the context to interpret the vector in terms of field values on the mesh

  • reducedOrderBasis (nparray(numberOfModes, numberOfDofs)) – numpy array of the modes

  • fieldName (str) – name of field associated with the basis (e.g. “U”, “sigma”)

WriteSolution(fileName, fieldStructure, solution, fieldName, nameInFile=None, append=False)[source]

Convert a Mordicus snapshot into a field, relying on SolutionStructure to build relations between the vector of values and the mesh.

Parameters
  • fileName (str) – MED file to write solution to

  • fieldStructure (MEDAsterSolutionStructure) – field structure giving the context to interpret the vector in terms of field values on the mesh

  • solution (Solution) – solution to write

  • fieldName (str) – identifier of the physical quantity for the field

WriteSparseFieldOfEmpiricalWeights(fileName, fieldStructure, np_coor_gauss, empirical_weights)[source]

Writes found empirical_weights to a Gauss field

Parameters
  • fileName (str) – file to write field of empirical weights to

  • fieldStructure (MEDAsterSolutionStructure) – field structure giving the context to interpret the vector in terms of field values on the mesh

  • np_coor_gauss – numpy array of empirical Gauss points coordinates

  • empirical_weights – numpy array of empirical weights