# This file was automatically generated by SWIG (https://www.swig.org).
# Version 4.1.1
#
# Do not make changes to this file unless you know what you are doing - modify
# the SWIG interface file instead.

from sys import version_info as _swig_python_version_info
# Import the low-level C/C++ module
if __package__ or "." in __name__:
    from . import _field
else:
    import _field

try:
    import builtins as __builtin__
except ImportError:
    import __builtin__

def _swig_repr(self):
    try:
        strthis = "proxy of " + self.this.__repr__()
    except __builtin__.Exception:
        strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)


def _swig_setattr_nondynamic_instance_variable(set):
    def set_instance_attr(self, name, value):
        if name == "this":
            set(self, name, value)
        elif name == "thisown":
            self.this.own(value)
        elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
            set(self, name, value)
        else:
            raise AttributeError("You cannot add instance attributes to %s" % self)
    return set_instance_attr


def _swig_setattr_nondynamic_class_variable(set):
    def set_class_attr(cls, name, value):
        if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
            set(cls, name, value)
        else:
            raise AttributeError("You cannot add class attributes to %s" % cls)
    return set_class_attr


def _swig_add_metaclass(metaclass):
    """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
    def wrapper(cls):
        return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
    return wrapper


class _SwigNonDynamicMeta(type):
    """Meta class to enforce nondynamic attributes (no new attributes) for a class"""
    __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)


import ooflib.SWIG.engine.csubproblem
import ooflib.SWIG.common.coord
import ooflib.SWIG.common.doublevec
import ooflib.SWIG.common.lock
import ooflib.SWIG.engine.element
import ooflib.SWIG.engine.edge
import ooflib.SWIG.engine.node
import ooflib.SWIG.engine.pointdata
import ooflib.SWIG.engine.mastercoord
import ooflib.SWIG.engine.outputval
import ooflib.SWIG.engine.fieldindex
import ooflib.SWIG.engine.planarity
import ooflib.SWIG.engine.elementnodeiterator
import ooflib.SWIG.engine.femesh
import ooflib.SWIG.common.cmicrostructure
import ooflib.SWIG.common.pixelgroup
import ooflib.SWIG.common.pixelattribute
import ooflib.SWIG.common.timestamp
import ooflib.SWIG.engine.material
import ooflib.SWIG.common.abstractimage
import ooflib.SWIG.common.ccolor
import ooflib.SWIG.engine.property
import ooflib.SWIG.engine.meshiterator
import ooflib.SWIG.engine.gausspoint
import ooflib.SWIG.engine.equation
import ooflib.SWIG.engine.flux
import ooflib.SWIG.engine.nodalequation
import ooflib.SWIG.engine.linearizedsystem
import ooflib.SWIG.engine.sparsemat
import ooflib.SWIG.engine.freedom
class Field(object):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr

    def name(self):
        return _field.Field_name(self)

    def objectid(self):
        return _field.Field_objectid(self)

    def index(self):
        return _field.Field_index(self)

    def ndof(self):
        return _field.Field_ndof(self)

    def classname(self):
        return _field.Field_classname(self)

    def c_time_derivative(self):
        return _field.Field_c_time_derivative(self)

    def c_components(self, p):
        return _field.Field_c_components(self, p)

    def c_outOfPlaneComponents(self):
        return _field.Field_c_outOfPlaneComponents(self)

    def registerProperty(self, arg2):
        return _field.Field_registerProperty(self, arg2)

    def is_active(self, arg2):
        return _field.Field_is_active(self, arg2)

    def is_defined(self, arg2):
        return _field.Field_is_defined(self, arg2)

    def value(self, arg2, n, component):
        return _field.Field_value(self, arg2, n, component)

    def setValueFromOutputValue(self, arg2, arg3, arg4):
        return _field.Field_setValueFromOutputValue(self, arg2, arg3, arg4)

    def getIndex(self, arg2):
        return _field.Field_getIndex(self, arg2)

    def newOutputValue(self):
        return _field.Field_newOutputValue(self)

    def output(self, arg2, arg3):
        return _field.Field_output(self, arg2, arg3)

    def setvalue(self, mesh, n, component, x):
        return _field.Field_setvalue(self, mesh, n, component, x)

    def dof(self, n, component):
        return _field.Field_dof(self, n, component)

# Register Field in _field:
_field.Field_swigregister(Field)
class CompoundField(Field):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr

    def in_plane(self, arg2):
        return _field.CompoundField_in_plane(self, arg2)

    def c_out_of_plane(self):
        return _field.CompoundField_c_out_of_plane(self)

    def c_out_of_plane_time_derivative(self):
        return _field.CompoundField_c_out_of_plane_time_derivative(self)

# Register CompoundField in _field:
_field.CompoundField_swigregister(CompoundField)

def countFields():
    return _field.countFields()

def getCompoundFieldByIndex(arg1):
    return _field.getCompoundFieldByIndex(arg1)

def countCompoundFields():
    return _field.countCompoundFields()
class ScalarField(CompoundField, Field):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self, name):
        _field.ScalarField_swiginit(self, _field.new_ScalarField(name))

        finishCompoundFieldConstruction(self)




    def classname(self):
        return _field.ScalarField_classname(self)
    __swig_destroy__ = _field.delete_ScalarField

# Register ScalarField in _field:
_field.ScalarField_swigregister(ScalarField)
class TwoVectorField(CompoundField, Field):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self, name):
        _field.TwoVectorField_swiginit(self, _field.new_TwoVectorField(name))

        finishCompoundFieldConstruction(self)




    def classname(self):
        return _field.TwoVectorField_classname(self)
    __swig_destroy__ = _field.delete_TwoVectorField

# Register TwoVectorField in _field:
_field.TwoVectorField_swigregister(TwoVectorField)
class ThreeVectorField(Field):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self, name):
        _field.ThreeVectorField_swiginit(self, _field.new_ThreeVectorField(name))

    def classname(self):
        return _field.ThreeVectorField_classname(self)
    __swig_destroy__ = _field.delete_ThreeVectorField

# Register ThreeVectorField in _field:
_field.ThreeVectorField_swigregister(ThreeVectorField)
class SymmetricTensorField(Field):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self, name):
        _field.SymmetricTensorField_swiginit(self, _field.new_SymmetricTensorField(name))

    def classname(self):
        return _field.SymmetricTensorField_classname(self)
    __swig_destroy__ = _field.delete_SymmetricTensorField

# Register SymmetricTensorField in _field:
_field.SymmetricTensorField_swigregister(SymmetricTensorField)

def testIterators():
    return _field.testIterators()
# -*- python -*-


# This software was produced by NIST, an agency of the U.S. government,
# and by statute is not subject to copyright in the United States.
# Recipients of this software assume all responsibilities associated
# with its operation, modification and maintenance. However, to
# facilitate maintenance we ask that before distributing modified
# versions of this software, you first contact the authors at
# oof_manager@nist.gov.

from ooflib.common import debug
from ooflib.common import utils
from ooflib.SWIG.engine import fieldindex
from ooflib.SWIG.engine import planarity
from ooflib.SWIG.common import switchboard

Field.__repr__ = Field.name
CompoundField.__repr__ = CompoundField.name
ScalarField.__repr__ = ScalarField.name
TwoVectorField.__repr__ = TwoVectorField.name
ThreeVectorField.__repr__ = ThreeVectorField.name
SymmetricTensorField.__repr__ = SymmetricTensorField.name

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#

# Fields are sometimes stored in an OrderedSet and so need to have
# __lt__ defined.

def _Field___lt__(self, other):
    try:
        return self.objectid() < other.objectid()
    except:
        return NotImplemented

Field.__lt__ = _Field___lt__

def _Field___hash__(self):
    return self.objectid()

Field.__hash__ = _Field___hash__

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#

_allFields = {}                 # dict of Fields keyed by name

# allCompoundFields is like _allFields, but it only includes
# CompoundFields.  It's an OrderedDict because it's used to list
# Fields in the GUI, where we want the order to be predictable.
# allCompoundFields is used externally.
allCompoundFields = utils.OrderedDict()

def newField(fld):
    _allFields[fld.name()] = fld
    utils.OOFdefine(fld.name(), fld)

def newCompoundField(fld):
    newField(fld)
    allCompoundFields[fld.name()] = fld

def getField(name):
    return _allFields[name]

utils.OOFdefine('getField', getField)

def allFields():
    return list(_allFields.values())

# finishCompoundFieldConstruction is called after the swigged
# constructors for all of the CompoundField subclasses.  It's
# installed by %pythonappend lines in field.swg.
def finishCompoundFieldConstruction(fld):
    newCompoundField(fld)
    newField(fld.c_time_derivative())
    newField(fld.c_out_of_plane())
    newField(fld.c_out_of_plane_time_derivative())
# "new field" must be sent after the field is defined in the OOF
#  namespace by newField and newCompoundField
    switchboard.notify("new field")

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#

# See comment in field.swg about Field::time_derivative.

def _Field_time_derivative(self):
    return _allFields[self.name() + "_t"]

Field.time_derivative = _Field_time_derivative

def _Field_out_of_plane(self):
    return _allFields[self.name() + "_z"]

CompoundField.out_of_plane = _Field_out_of_plane

def _Field_out_of_plane_time_derivative(self):
    return _allFields[self.name() + "_tz"]

CompoundField.out_of_plane_time_derivative = _Field_out_of_plane_time_derivative

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#

def _fielditer(comps):
# comps is a swigged generic ComponentsP object
    beginp = comps.begin()      # generic ComponentIteratorP object
    endp = comps.end()          # generic ComponentIteratorP object
    while beginp != endp:
        yield beginp.current()  # derived FieldIndex class object
        beginp.increment()

def _Field_components(self, plan=planarity.ALL_INDICES):
    return _fielditer(self.c_components(plan))

Field.components = _Field_components

def _Field_outOfPlaneComponents(self):
    return _fielditer(self.c_outOfPlaneComponents())

Field.outOfPlaneComponents = _Field_outOfPlaneComponents


