Newer
Older
// ============================================================================
// == ==
// == AMDiS - Adaptive multidimensional simulations ==
// == ==

Thomas Witkowski
committed
// == http://www.amdis-fem.org ==
// == ==
// ============================================================================

Thomas Witkowski
committed
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.
/** \file ElementData.h */
#ifndef AMDIS_ELEMENTDATA_H
#define AMDIS_ELEMENTDATA_H
#include "Serializable.h"
#include "CreatorMap.h"
namespace AMDiS {
const int ESTIMATABLE = 1;
const int COARSENABLE = 2;
const int PERIODIC = 3;
const int ELEMENT_REGION = 4;
const int SURFACE_REGION = 5;
/** \brief
* Base class for element data. To allow to assign arbitrary data to arbitrary
* elements at run time, the decorator pattern in combination with the
* chain-of-responsibility pattern is applied. So only data have to be managed
* at each element which are used for this element at this time.
*/
class ElementData : public Serializable
{
public:
ElementData(ElementData *dec = NULL)
: decorated(dec)
virtual ~ElementData();
/// Refinement of parent to child1 and child2.
virtual bool refineElementData(Element* parent,
Element* child1,
Element* child2,
int elType)
{
decorated->refineElementData(parent, child1, child2, elType);
ElementData *tmp = decorated->decorated;
delete decorated;
decorated = tmp;
virtual void coarsenElementData(Element* parent,
Element* thisChild,
Element* otherChild,
/// Returns a copy of this ElementData object including all decorated data.
if (decorated)
return decorated->clone();
/// Returns the id of element data type.
/** \brief
* Returns whether the ElemnetData object is of the type specified by
* typeName. Must return true, even if typeName describes a base class.
*/
virtual bool isOfType(int typeID) const = 0;
/// Implements Serializable::serialize().
/// Implements Serializable::deserialize().
virtual void deserialize(std::istream& in);
/// Returns first element data in the chain which is of the spcified type.
inline ElementData *getElementData(int typeID)
{
if (decorated)
return decorated->getElementData(typeID);
if (decorated)
return decorated->getElementData(typeID);
* Search the \ref decorated chain for a specific type ID, and delets
* this entry.
*/
bool deleteDecorated(int typeID);
/// Delets the whole \ref decorated chain.
void deleteDecorated();
if (getTypeID() == 1)
if (d != NULL)
std::cout << "leafdata decorated with nonzero" << std::endl;
/// Pointer to next ElementData object in the chain of responsibility.
ElementData *decorated;
};
}
#endif