<commit_before>import numpy as nm

from sfepy.base.base import Struct
from sfepy.terms.terms import Term
from sfepy.terms.extmods import terms
import sfepy.mechanics.extmods.ccontres as cc

class ContactInfo(Struct):
    """
    Various contact-related data of contact terms.
    """
    def __init__(self, region, integral, geo, state):
        # Uses field connectivity (higher order nodes).
        sd = state.field.surface_data[region.name]

        ISN = state.field.efaces.T.copy()
        nsd = region.dim
        ngp = geo.n_qp
        nsn = ISN.shape[0]

        fis = region.get_facet_indices()
        elementID = fis[:, 0].copy()
        segmentID = fis[:, 1].copy()

        # geo.bf corresponds to the field approximation.
        H = nm.asfortranarray(geo.bf[0, :, 0, :])

        gname = state.field.gel.name
        ib = 3 if gname == '3_8' else 0

        bqpkey = (integral.order, sd.bkey)
        bqp = state.field.qp_coors[bqpkey]

        basis = state.field.create_basis_context()
        bfg3d = basis.evaluate(bqp.vals[ib], diff=True)
        bfg = bfg3d[:, :region.tdim - 1, state.field.efaces[ib]]
        if gname == '3_4':
            bfg = bfg[:, [1, 0], :]

        dH  = nm.asfortranarray(bfg.ravel().reshape(((nsd - 1) * ngp, nsn)))

        GPs = nm.empty((len(elementID)*ngp, 2*nsd+6),
                       dtype=nm.float64, order='F')

        Struct.__init__(self, name='contact_info_%s' % region.name,
                        sd=sd, nsd=nsd, ngp=ngp, neq=state.n_dof,
                        nsn=nsn, npd=region.tdim - 1,
                        elementID=elementID, segmentID=segmentID,<commit_msg>fix ContactInfo.__init__() for state and virtual with different field instances<commit_after>import numpy as nm

from sfepy.base.base import Struct
from sfepy.terms.terms import Term
from sfepy.terms.extmods import terms
import sfepy.mechanics.extmods.ccontres as cc

class ContactInfo(Struct):
    """
    Various contact-related data of contact terms.
    """
    def __init__(self, region, integral, geo, state):
        # Uses field connectivity (higher order nodes).
        sd = state.field.surface_data[region.name]

        ISN = state.field.efaces.T.copy()
        nsd = region.dim
        ngp = geo.n_qp
        nsn = ISN.shape[0]

        fis = region.get_facet_indices()
        elementID = fis[:, 0].copy()
        segmentID = fis[:, 1].copy()

        # geo.bf corresponds to the field approximation.
        H = nm.asfortranarray(geo.bf[0, :, 0, :])

        gname = state.field.gel.name
        ib = 3 if gname == '3_8' else 0

        bqpkey = (integral.order, sd.bkey)
        state.field.create_bqp(region.name, integral)
        bqp = state.field.qp_coors[bqpkey]

        basis = state.field.create_basis_context()
        bfg3d = basis.evaluate(bqp.vals[ib], diff=True)
        bfg = bfg3d[:, :region.tdim - 1, state.field.efaces[ib]]
        if gname == '3_4':
            bfg = bfg[:, [1, 0], :]

        dH  = nm.asfortranarray(bfg.ravel().reshape(((nsd - 1) * ngp, nsn)))

        GPs = nm.empty((len(elementID)*ngp, 2*nsd+6),
                       dtype=nm.float64, order='F')

        Struct.__init__(self, name='contact_info_%s' % region.name,
                        sd=sd, nsd=nsd, ngp=ngp, neq=state.n_dof,
                        nsn=nsn, npd=region.tdim - 1,
                        elementID=elementID, segmentID=segmentID,
{'fraction_non_alphanumeric': 0.1303708063566804, 'fraction_numerical': 0.012948793407886992, 'mean_word_length': 2.206603773584906, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6618528', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1153, 'n_words': 250}