# sfepy.homogenization.engine module

class sfepy.homogenization.engine.CoefVolume(name, problem, kwargs)

class sfepy.homogenization.engine.HomogenizationEngine(problem, options, app_options=None, volumes=None, output_prefix='he:', **kwargs)
  call(ret_all=False, time_tag='')
  static define_volume_coef(coef_info, volumes)

    Define volume coefficients and make all other dependent on them.

    Parameters:
      coef_info dict

        The coefficient definitions.

      volumes dict

        The definitions of volumes.

    Returns:
      coef_info dict

        The coefficient definitions extended by the volume coefficients.

  static process_options(options)

    Application options setup. Sets default values for missing non-compulsory options.

  set_micro_states(states)
  setup_options(app_options=None)

class sfepy.homogenization.engine.HomogenizationWorker
  static calculate(mini_app, problem, dependencies, dep_requires, save_names, micro_states, chunk_tab, mode, proc_id)
  static calculate_req(problem, opts, post_process_hook, name, req_info, coef_info, save_names, dependencies, micro_states, time_tag='', chunk_tab=None, proc_id='0')

    Calculate a requirement, i.e. correctors or coefficients.

    Parameters:
      problem problem

        The problem definition related to the microstructure.

      opts struct

        The options of the homogenization application.

      post_process_hook function

        The postprocessing hook.

      name str

        The name of the requirement.

      req_info dict

        The definition of correctors.

      coef_info dict

        The definition of homogenized coefficients.

      save_names dict

        The dictionary containing names of saved correctors.

      dependencies dict

        The dependencies required by the correctors/coefficients.

      micro_states array

        The configurations of multiple microstructures.

      time_tag str

        The label corresponding to the actual time step and iteration, used in the corrector file names.

      chunk_tab list

        In the case of multiprocessing the requirements are divided into several chunks that are solved in parallel.

      proc_id int

        The id number of the processor (core) which is solving the actual chunk.

    Returns:
      val coefficient/corrector or list of coefficients/correctors

        The resulting homogenized coefficients or correctors.

  static get_sorted_dependencies(req_info, coef_info, compute_only)

    Make corrs and coefs list sorted according to the dependencies.

class sfepy.homogenization.engine.HomogenizationWorkerMulti(num_workers)
  static calculate_req_multi(tasks, lock, remaining, numdeps, inverse_deps, problem, opts, post_process_hook, req_info, coef_info, save_names, dependencies, micro_states, time_tag, chunk_tab, proc_id)

    Calculate a requirement in parallel.

    Parameters:
      tasks queue

        The queue of requirements to be solved.

      lock lock

        The multiprocessing lock used to ensure save access to the global variables.

      remaining int

        The number of remaining requirements.

      numdeps dict

        The number of dependencies for the each requirement.

      inverse_deps dict

        The inverse dependencies - which requirements depend on a given one.

      For the definition of other parameters see ‘calculate_req’.
  static chunk_micro_tasks(num_workers, num_micro, reqs, coefs, chunks_per_worker=1, store_micro_idxs=[])

    Split multiple microproblems into several chunks that can be processed in parallel.

    Parameters:
      num_workers int

        The number of available CPUs.

      num_micro int

        The number of microstructures.

      reqs dict

        The requirement definitions.

      coefs dict

        The coefficient definitions.

      chunks_per_worker int

        The number of chunks per one worker.

      store_micro_idxs list of int

        The indices of microstructures whose results are to be stored.

    Returns:
      micro_tab list of slices

        The indices of microproblems contained in each chunk.

      new_reqs dict

        The new requirement definitions.

      new_coefs dict

        The new coefficient definitions.

  static dechunk_reqs_coefs(deps, num_chunks)

    Merge the results related to the multiple microproblems.

    Parameters:
      deps dict

        The calculated dependencies.

      num_chunks int

        The number of chunks.

    Returns:
      new_deps dict

        The merged dependencies.

  static process_reqs_coefs(old, num_workers, store_idxs=[])

class sfepy.homogenization.engine.HomogenizationWorkerMultiMPI(num_workers)

sfepy.homogenization.engine.get_dict_idxval(dict_array, idx)

sfepy.homogenization.engine.insert_sub_reqs(reqs, levels, req_info)

  Recursively build all requirements in correct order.