# Vibroacoustics
#
# E.Rohan, V.Lukeš
# Homogenization of the vibro–acoustic transmission on periodically
# perforated elastic plates with arrays of resonators.
# https://arxiv.org/abs/2104.01367 (arXiv:2104.01367v1)

import os
import numpy as nm
from sfepy.base.base import Struct
from sfepy.homogenization.coefficients import Coefficients
from sfepy.discrete.fem import Mesh, FEDomain


def coefs2qp(out, coefs, nqp):
    others = {}
    for k, v in coefs.items():
        if type(v) is nm.float64:
            v = nm.array(v)

        if type(v) is not nm.ndarray:
            others[k] = v
            continue

        if k[0] == 's':
            out[k] = nm.tile(v, (nqp, 1, 1))

        else:
            if not(k in out):
                out[k] = nm.tile(v, (nqp, 1, 1))

    out.update(others)

    return out


def get_homogmat(coors, mode, pb, coefs_filename, omega=None):

    if mode == 'qp':
        nqp = coors.shape[0]
        outdir = pb.conf.options['output_dir']
        cfname = os.path.join(outdir, coefs_filename + '.h5')

        out = {}
        print('>>> coefs from: ', cfname)
        coefs_ = 
Coefficients.from_file_hdf5(cfname)