Utilities

EdelweissFE contains several classes and modules, which are not directly employed by the user, but very handy if fundamental new functionalities should be added.

Matrix conversion from COO sparse format to CSR format

Module edelweissfe.numerics.csrgenerator

class edelweissfe.numerics.csrgenerator.CSRGenerator

This cdef class generates Compressed Sparse Row Matrices from the COO format, and offers the possibility to update the matrix without reanalyzing the pattern (in contrast to SciPy). Very fast and convenient!

Parameters

systemMatrix – The system matrix in COO format, for the first initialization V can be a dummy (empty) vector.

Methods

updateCSR(V)

Get updated copies of the CSR matrix.

updateCSR(V)

Get updated copies of the CSR matrix.

Returns

The system matrix in CSR format.

Return type

csr_matrix

Gathering efficiently of element results

Module edelweissfe.utils.elementresultcollector

class edelweissfe.utils.elementresultcollector.ElementResultCollector

A cdef class for collecting element results (by using the permanent results pointer (i.e., a numpy array) in large array of all elements and all quadrature points.

Collecting elemental results may be a performance critical part. This cdef class allows for the efficient gathering. A 3D array is assembled if multiple quadrature points are requested (shape [elements, quadraturePoints, resultVector] ) or a 2D array for one quadrature point ( shape [elements, resultVector] ).

Method getCurrentResults() updates the assembly array and passes it back.

The caller is responsible to make a copy of it, if persistent results are needed!

Parameters
  • elements – The list of elements for which the results should be collected.

  • quadraturePoints – The slice defining the desired quadrature points.

  • result – The name of the requested result.

Attributes
resultsTable

Methods

getCurrentResults()

Update and get current results.

update()

Update all results.

getCurrentResults()

Update and get current results.

Returns

The results array.

Return type

np.ndarray

update()

Update all results.

Adaptive time stepping

Module edelweissfe.timesteppers.adaptivetimestepper

class edelweissfe.timesteppers.adaptivetimestepper.AdaptiveTimeStepper(currentTime, stepLength, startIncrement, maxIncrement, minIncrement, maxNumberIncrements, journal, increaseFactor=1.1)[source]

An increment generator for incremental-iterative simulations.

Implementation as generator class.

Parameters
  • currentTime (float) – The current (start) time.

  • stepLength (float) – The total length of the step.

  • startIncrement (float) – The size of the start increment.

  • maxIncrement (float) – The maximum size of an increment.

  • minIncrement (float) – The minimum size of an increment.

  • maxNumberIncrements (int) – The maximum number of allowed increments.

  • journal (Journal) – The journal instance for logging purposes.

  • increaseFactor – The ratio to increase the increments in case of good convergence.

Methods

discardAndChangeIncrement(scaleFactor)

Change increment size between minIncrement and maxIncrement by a given scale factor.

generateTimeStep()

Generate the next increment.

preventIncrementIncrease()

May be called before an increment is requested, to prevent from automatically increasing, e.g.

readRestart(restartFile)

Read restart information from a file.

reduceNextIncrement(scaleFactor)

Reduce the increment size for the next increment.

writeRestart(restartFile)

Write restart information to a file.

discardAndChangeIncrement(scaleFactor)[source]

Change increment size between minIncrement and maxIncrement by a given scale factor.

Parameters

scaleFactor (float) – The factor for scaling based on the previous increment.

generateTimeStep()[source]

Generate the next increment.

Returns

The current time step.

Return type

TimeStep

preventIncrementIncrease()[source]

May be called before an increment is requested, to prevent from automatically increasing, e.g. in case of bad convergency.

readRestart(restartFile)[source]

Read restart information from a file.

Parameters

restartFile – The file to read the restart information from.

reduceNextIncrement(scaleFactor)[source]

Reduce the increment size for the next increment.

Parameters

scaleFactor (float) –

writeRestart(restartFile)[source]

Write restart information to a file.

Parameters

restartFile – The file to write the restart information to.