OOF2: The Manual

Name

Element — Element class for finite element meshes

Synopses

C++ Synopsis

#include "engine/element.h"
class Element {
  const Material * material() const;
  int nnodes() const;
  int nfuncnodes() const;
  int shapefun_degree() const;
  int dshapefun_degree() const;
  ElementNodeIterator node_iterator() const;
  ElementMapNodeIterator mapnode_iterator() const;
  ElementFuncNodeIterator funcnode_iterator() const;
  ElementCornerNodeIterator cornernode_iterator() const;
  MasterCoord to_master(const Coord& position) const;
  Coord from_master(const MasterCoord& position) const;
  MasterCoord center() const;
  double area() const;
  OutputValue outputField(const Field& field,
                          const MasterPosition& position) const;

  OutputValue outputFieldDeriv(const Field& field,
                               int derivative,
                               const MasterPosition& position) const;

  OutputValue outputFlux(const FEMesh* mesh,
                         const Flux& flux,
                         const MasterPosition& position) const;

  int appendData(ElementData* data) const;
  void setData(int i,
               ElementData* data) const;

  void setDataByName(ElementData* data) const;
  ElementData* getData(int i) const;
  ElementData* getDataByName(const std::string& name) const;
  int getIndexByName(const std::string& name) const;
  void delData(int i) const;
  void delDataByName(std::string& name) const;
}

Python Synopsis

from ooflib.SWIG.engine import element
class Element:
  def material(self)
  def area(self)
  def shapefun_degree(self)
  def dshapefun_degree(self)
  def node_iterator(self)
  def mapnode_iterator(self)
  def funcnode_iterator(self)
  def cornernode_iterator(self)
  def outputField(self, field, position)
  def outputFlux(self, mesh, flux, position)
  def from_master(self, point)
  def to_master(self, point)
  def appendData(self, data)
  def setData(self, index, data)
  def setDataByName(self, data)
  def getData(self, index, data)
  def getDataByName(self, data)
  def delData(self, index)
  def delDataByName(self, name)

Source Files

  • SRC/engine/element.C: C++ source code
  • SRC/engine/element.h: C++ header file
  • SRC/engine/element.swg: swig source code

Description

Element is a swigged C++ class for describing a finite element. It is a generic class: each Element contains a pointer to a MasterElement object that contains all of the geometry-specific details.

Only those parts of the Element class that are useful for writing OOF2 extensions are described here. There are actually many more functions and data members. Consult the source code for the details.

Methods

const Material* material() const

material simply returns a pointer to the Material object that describes the Element's physical features.

int nnodes() const

nnodes returns the number of nodes in the Element.

int nfuncnodes() const

nfuncnodes returns the number of so-called function nodes in the element. These are the nodes that store Field values.

int shapefun_degree() const

shapefun_degree returns the polynomial degree of the Element's shape functions, more or less. It actually returns the Gaussian integration order required to perform integrals over the Element's area.

int dshapefun_degree() const

dshapefun_degree returns the Gaussian integration order required to integrate the derivatives of the shape function over the area of the Element.

ElementNodeIterator node_iterator() const

node_iterator returns an ElementNodeIterator which can be used to access all of the Element's Nodes.

ElementMapNodeIterator mapnode_iterator() const

mapnode_iterator returns an ElementMapNodeIterator which can be used to access all of the Element's mapping Nodes. These are the Nodes that determine the Element's shape and position in space. That is, they determine the mapping between master coordinates and physical coordinates.

ElementFuncNodeIterator funcnode_iterator() const

funcnode_iterator returns an ElementFuncNodeIterator which can be used to access all of the Element's FuncNodes. FuncNodes are Nodes which store Field values.

ElementCornerNodeIterator cornernode_iterator() const

cornernode_iterator returns an ElementCornerNodeIterator which can be used to access the Nodes at the corners of the Element.

MasterCoord to_master(const Coord&) const

to_master converts a position in physical space to a position in the Element's master coordinate space. The C++ version takes a Coord argument. The Python version accepts any indexable object with at least two components, such as a tuple, list, Point, or Coord. Both versions return a MasterCoord object.

to_master is a fairly expensive function to compute, so it should be used judiciously.

Coord from_master(const MasterCoord&) const

from_master takes a position in master coordinate space in the form of a MasterCoord object in C++ or any indexable object in Python, such as a tuple, list, or MasterCoord. It returns the corresponding point in physical space in the form of a Coord.

MasterCoord center() const

center returns the position of the center of the Element in master coordinate space. This can be converted to a physical coordinate with from_master.

double area() const

area returns the physical area of the Element.

OutputValue outputField(const Field& field, const MasterPosition& position) const

outputField uses finite element interpolation to evaluate a given Field at a given position within the Element. The position must be specified in the Element's master coordinate space. The value of the Field is returned inside a generic OutputValue wrapper, allowing it to be used in the Outputs.

OutputValue outputFieldDeriv(const Field& field, int derivative, const MasterPosition& position)

outputFieldDeriv is just like outputField, but it computes a derivative of the Field.

The derivative argument is a int object. outputFieldDeriv returns the x derivative if derivative==0 and the y derivative if derivative==1.

OutputValue outputFlux(const FEMesh* mesh, const Flux& flux, const MasterPosition& position) const

outputFlux is just like outputField, except that it computes the value of a Flux.

Element Methods for Handling ElementData

New Properties and other extension code can assign data to individual Elements using the ElementData class and the Element methods listed here.

int appendData(ElementData *data) const

Attach the given ElementData object to this Element, and return its index. It can be retrieved later using Element::getData(index).

See the note about ElementData reference counting in Python.

void setDataByName(ElementData* data) const

Attach the given ElementData object to the Element, identifying it by the name that the data was given when it was constructed. If the Element already contains an ElementData with the same name, the pointer to the existing data will be overwritten. If no data with the given name exists, the new data will be appended.

Note that this never deletes the old data, it just overwrites the pointer to it.

See the note about ElementData reference counting in Python.

void setData(int index, ElementData* data) const

Replace the ElementData at the given index with the given data. It is an error if the index does not exist. This is more efficient than Element::setDataByName, but more error prone. Use Element::getIndexByName to retrieve an unknown index.

Note that this never deletes the old data, it just overwrites the pointer to it.

See the note about ElementData reference counting in Python.

ElementData* getDataByName(const std::string& name) const

Retrieve the ElementData with the given name. A null pointer is returned if no such data exists in the Element.

See the note about ElementData reference counting in Python.

ElementData* getData(int index) const

Retrieve the ElementData with the given index. This is more efficient than getDataByName but more error prone. No error checking is done to ensure that the index exists. Use Element::getIndexByName to retrieve an unknown index.

See the note about ElementData reference counting in Python.

void delDataByName(const std::string& name) const

Remove the ElementData with the given name. It is an error if the data doesn't exist in the Element. This does not actually delete the ElementData object — it just removes the pointer from the Element. This can change the index of other ElementData objects stored in the Element.

See the note about ElementData reference counting in Python.

void delData(int index) const

Delete the ElementData at the given index. It is an error if there is no data there. This does not actually delete the ElementData object — it just removes the pointer from the Element. This can change the index of other ElementData objects stored in the Element.

See the note about ElementData reference counting in Python.

int getIndexByName(const std::string& name) const

Return the index of the ElementData with the given name. The returned index can be use in subsequent calls to setData, getData, and delData, as long as there have been no intervening calls to delData or delDataByName If there is no data with the given name, getIndexByName returns -1.