Beispiel #1
0
    def save_mappings(self):
        """
        Save current reference mappings to `mappings0` attribute.
        """
        import sfepy.base.multiproc as multi

        if multi.is_remote_dict(self.mappings0):
            for k, v in six.iteritems(self.mappings):
                m, _ = self.mappings[k]
                nv = (m.bf, m.bfg, m.det, m.volume, m.normal)
                self.mappings0[k] = nv
        else:
            self.mappings0 = self.mappings.copy()
Beispiel #2
0
    def save_mappings(self):
        """
        Save current reference mappings to `mappings0` attribute.
        """
        import sfepy.base.multiproc as multi

        if multi.is_remote_dict(self.mappings0):
            for k, v in six.iteritems(self.mappings):
                m, _ = self.mappings[k]
                nv = (m.bf, m.bfg, m.det, m.volume, m.normal)
                self.mappings0[k] = nv
        else:
            self.mappings0 = self.mappings.copy()
Beispiel #3
0
    def get_mapping(self,
                    region,
                    integral,
                    integration,
                    get_saved=False,
                    return_key=False):
        """
        For given region, integral and integration type, get a reference
        mapping, i.e. jacobians, element volumes and base function
        derivatives for Volume-type geometries, and jacobians, normals
        and base function derivatives for Surface-type geometries
        corresponding to the field approximation.

        The mappings are cached in the field instance in `mappings`
        attribute. The mappings can be saved to `mappings0` using
        `Field.save_mappings`. The saved mapping can be retrieved by
        passing `get_saved=True`. If the required (saved) mapping
        is not in cache, a new one is created.

        Returns
        -------
        geo : CMapping instance
            The reference mapping.
        mapping : VolumeMapping or SurfaceMapping instance
            The mapping.
        key : tuple
            The key of the mapping in `mappings` or `mappings0`.
        """
        import sfepy.base.multiproc as multi

        key = (region.name, integral.order, integration)

        if get_saved:
            out = self.mappings0.get(key, None)
            if multi.is_remote_dict(self.mappings0) and out is not None:
                m, i = self.create_mapping(region, integral, integration)
                m.bf[:], m.bfg[:], m.det[:], m.volume[:] = out[0:4]
                if m.normal is not None:
                    m.normal[:] = m[4]
                out = m, i
        else:
            out = self.mappings.get(key, None)

        if out is None:
            out = self.create_mapping(region, integral, integration)
            self.mappings[key] = out

        if return_key:
            out = out + (key, )

        return out
Beispiel #4
0
    def get_mapping(self, region, integral, integration,
                    get_saved=False, return_key=False):
        """
        For given region, integral and integration type, get a reference
        mapping, i.e. jacobians, element volumes and base function
        derivatives for Volume-type geometries, and jacobians, normals
        and base function derivatives for Surface-type geometries
        corresponding to the field approximation.

        The mappings are cached in the field instance in `mappings`
        attribute. The mappings can be saved to `mappings0` using
        `Field.save_mappings`. The saved mapping can be retrieved by
        passing `get_saved=True`. If the required (saved) mapping
        is not in cache, a new one is created.

        Returns
        -------
        geo : CMapping instance
            The reference mapping.
        mapping : VolumeMapping or SurfaceMapping instance
            The mapping.
        key : tuple
            The key of the mapping in `mappings` or `mappings0`.
        """
        import sfepy.base.multiproc as multi

        key = (region.name, integral.order, integration)

        if get_saved:
            out = self.mappings0.get(key, None)
            if multi.is_remote_dict(self.mappings0) and out is not None:
                m, i = self.create_mapping(region, integral, integration)
                m.bf[:], m.bfg[:], m.det[:], m.volume[:] = out[0:4]
                if m.normal is not None:
                    m.normal[:] = m[4]
                out = m, i
        else:
            out = self.mappings.get(key, None)

        if out is None:
            out = self.create_mapping(region, integral, integration)
            self.mappings[key] = out

        if return_key:
            out = out + (key,)

        return out