Commit 0fee3b03 authored by Thomas Witkowski's avatar Thomas Witkowski

Code refactoring.

parent c03d1a79
......@@ -49,7 +49,8 @@ namespace AMDiS {
virtual ~AbstractFunction() {}
/// Returns \ref degree_.
inline int getDegree() const {
inline int getDegree() const
{
return degree_;
}
......@@ -80,7 +81,8 @@ namespace AMDiS {
virtual ~BinaryAbstractFunction() {}
/// Returns \ref degree_.
inline int getDegree() const {
inline int getDegree() const
{
return degree_;
}
......@@ -113,7 +115,8 @@ namespace AMDiS {
virtual ~TertiaryAbstractFunction() {}
/// Returns \ref degree_.
inline int getDegree() const {
inline int getDegree() const
{
return degree_;
}
......@@ -148,7 +151,8 @@ namespace AMDiS {
virtual ~QuartAbstractFunction() {}
/// Returns \ref degree_.
inline int getDegree() const {
inline int getDegree() const
{
return degree_;
}
......
......@@ -56,12 +56,14 @@ namespace AMDiS {
virtual ~AdaptInstationary();
/// Sets \ref strategy to aStrategy
inline void setStrategy(int aStrategy) {
inline void setStrategy(int aStrategy)
{
strategy = aStrategy;
}
/// Returns \ref strategy
const int getStrategy() const {
const int getStrategy() const
{
return strategy;
}
......
......@@ -45,7 +45,8 @@ namespace AMDiS {
virtual ~BallProject() {}
/// Implementation of Projection::project();
void project(WorldVector<double> &x) {
void project(WorldVector<double> &x)
{
x -= center_;
double norm = sqrt(x*x);
TEST_EXIT(norm != 0.0)("can't project vector x\n");
......
......@@ -90,12 +90,14 @@ namespace AMDiS {
public:
/// compares two BasisFunction objects.
virtual bool operator==(const BasisFunction& a) const {
virtual bool operator==(const BasisFunction& a) const
{
return a.getName() == name;
}
/// Returns !(*this == b)
inline bool operator!=(const BasisFunction& b) const {
inline bool operator!=(const BasisFunction& b) const
{
return !(operator == (b));
}
......@@ -134,22 +136,26 @@ namespace AMDiS {
virtual void getBound(const ElInfo*, BoundaryType *) const {};
/// Returns \ref degree of BasisFunction
inline const int getDegree() const {
inline const int getDegree() const
{
return degree;
}
/// Returns \ref dim of BasisFunction
inline const int getDim() const {
inline const int getDim() const
{
return dim;
}
/// Returns \ref nBasFcts which is the number of local basis functions
inline const int getNumber() const {
inline const int getNumber() const
{
return nBasFcts;
}
/// Returns \ref name of BasisFunction
inline const std::string& getName() const {
inline const std::string& getName() const
{
return name;
}
......@@ -157,7 +163,8 @@ namespace AMDiS {
int getNumberOfDOFs(int i) const;
/// Returns \ref nDOF
inline DimVec<int>* getNumberOfDOFs() const {
inline DimVec<int>* getNumberOfDOFs() const
{
return nDOF;
}
......@@ -197,17 +204,20 @@ namespace AMDiS {
WorldVector<double> *vec) = 0;
/// Returns the i-th local basis function
inline BasFctType *getPhi(int i) const {
inline BasFctType *getPhi(int i) const
{
return (*phi)[i];
}
/// Returns the gradient of the i-th local basis function
inline GrdBasFctType *getGrdPhi(int i) const {
inline GrdBasFctType *getGrdPhi(int i) const
{
return (*grdPhi)[i];
}
/// Returns the second derivative of the i-th local basis function
inline D2BasFctType *getD2Phi(int i) const {
inline D2BasFctType *getD2Phi(int i) const
{
return (*d2Phi)[i];
}
......
......@@ -50,7 +50,10 @@ namespace AMDiS {
virtual ~CoarseningManager() {}
/// Returns the Mesh the CoarseningManager belongs to.
inline Mesh* getMesh() { return mesh; }
inline Mesh* getMesh()
{
return mesh;
}
/** \brief
* Tries to coarsen every element of mesh at least mark times. First
......@@ -75,7 +78,10 @@ namespace AMDiS {
* how one element of the mesh is coarsened. The method can be overriden
* by sub classes, if used.
*/
virtual int coarsenFunction(ElInfo *) { return 0; };
virtual int coarsenFunction(ElInfo *)
{
return 0;
}
/** \brief
* Propagate coarsening information over the whole hierarchy
......
......@@ -49,7 +49,8 @@ namespace AMDiS {
protected:
/// Not needed in this sub class
int coarsenFunction(ElInfo *) {
int coarsenFunction(ElInfo *)
{
FUNCNAME("CoarseningManager1d::coarsenFunction");
ERROR_EXIT("not used for dim = 1");
return 0;
......
......@@ -38,46 +38,56 @@ namespace AMDiS {
status(0)
{}
void setFESpace(FiniteElemSpace *row, FiniteElemSpace *col = NULL) {
void setFESpace(FiniteElemSpace *row, FiniteElemSpace *col = NULL)
{
rowFESpace = row;
colFESpace = col;
}
void setAuxFESpaces(std::vector<const FiniteElemSpace*> feSpaces) {
void setAuxFESpaces(std::vector<const FiniteElemSpace*> feSpaces)
{
auxFESpaces = feSpaces;
}
void addAuxFESpace(const FiniteElemSpace *fe) {
void addAuxFESpace(const FiniteElemSpace *fe)
{
auxFESpaces.push_back(fe);
}
bool hasFESpace() {
bool hasFESpace()
{
return rowFESpace != NULL;
}
void updateStatus();
int getNumAuxFESpaces() {
int getNumAuxFESpaces()
{
return auxFESpaces.size();
}
FiniteElemSpace *getRowFESpace() {
FiniteElemSpace *getRowFESpace()
{
return rowFESpace;
}
FiniteElemSpace *getColFESpace() {
FiniteElemSpace *getColFESpace()
{
return colFESpace;
}
const FiniteElemSpace *getAuxFESpace(int i) {
const FiniteElemSpace *getAuxFESpace(int i)
{
return ((i < static_cast<int>(auxFESpaces.size())) ? auxFESpaces[i] : NULL);
}
void setAuxFESpace(const FiniteElemSpace* fe, int pos) {
void setAuxFESpace(const FiniteElemSpace* fe, int pos)
{
auxFESpaces[pos] = fe;
}
int getStatus() {
int getStatus()
{
return status;
}
......@@ -124,47 +134,54 @@ namespace AMDiS {
resize(n);
}
void resize(int n) {
void resize(int n)
{
nComponents = n;
matrixComponents.resize(n);
vectorComponents.resize(n);
for (int i = 0; i < n; i++) {
for (int i = 0; i < n; i++)
matrixComponents[i].resize(n);
}
}
void updateStatus() {
void updateStatus()
{
for (int i = 0; i < nComponents; i++) {
for (int j = 0; j < nComponents; j++) {
for (int j = 0; j < nComponents; j++)
matrixComponents[i][j].updateStatus();
}
vectorComponents[i].updateStatus();
}
}
SingleComponentInfo &getMatrix(int row, int col) {
SingleComponentInfo &getMatrix(int row, int col)
{
return matrixComponents[row][col];
}
SingleComponentInfo &getVector(int row) {
SingleComponentInfo &getVector(int row)
{
return vectorComponents[row];
}
int getStatus(int row, int col) {
int getStatus(int row, int col)
{
return matrixComponents[row][col].getStatus();
}
int getStatus(int row) {
int getStatus(int row)
{
return vectorComponents[row].getStatus();
}
const FiniteElemSpace* getAuxFESpace(int row, int col) {
const FiniteElemSpace* getAuxFESpace(int row, int col)
{
return matrixComponents[row][col].getAuxFESpace(0);
}
const FiniteElemSpace* getAuxFESpace(int row) {
const FiniteElemSpace* getAuxFESpace(int row)
{
return vectorComponents[row].getAuxFESpace(0);
}
......
......@@ -47,11 +47,13 @@ namespace AMDiS {
double estimate(double timestep);
inline int getElementCount() {
inline int getElementCount()
{
return elementCount_;
}
inline Estimator *getDecoratedEstimator() {
inline Estimator *getDecoratedEstimator()
{
return decoratedEstimator_;
}
......
......@@ -93,9 +93,8 @@ namespace AMDiS {
if (elData->getPartitionStatus() == OUT) {
Element *element = elInfo->getElement();
if (element->getMark() > 0) {
element->setMark(0);
}
if (element->getMark() > 0)
element->setMark(0);
}
int minLevel =
......@@ -103,9 +102,8 @@ namespace AMDiS {
localCoarseGridLevel_ :
globalCoarseGridLevel_;
if (elData->getLevel() + elInfo->getElement()->getMark() < minLevel) {
if (elData->getLevel() + elInfo->getElement()->getMark() < minLevel)
elInfo->getElement()->setMark(-(elData->getLevel() - minLevel));
}
}
}
......
......@@ -74,7 +74,8 @@ namespace AMDiS {
}
/// Solves the initial problem.
virtual void transferInitialSolution(AdaptInfo *adaptInfo) {
virtual void transferInitialSolution(AdaptInfo *adaptInfo)
{
int size = static_cast<int>(interfaces_.size());
for (int i = 0; i < size; i++)
interfaces_[i]->transferInitialSolution(adaptInfo);
......
......@@ -50,7 +50,8 @@ namespace AMDiS {
*/
virtual BaseClass* create() = 0;
virtual BaseClass* create(const DOFMatrix::base_matrix_type& A) {
virtual BaseClass* create(const DOFMatrix::base_matrix_type& A)
{
return 0;
}
......@@ -58,7 +59,8 @@ namespace AMDiS {
virtual void free(BaseClass *) {}
///
virtual bool isNullCreator() {
virtual bool isNullCreator()
{
return false;
}
};
......@@ -71,12 +73,14 @@ namespace AMDiS {
class NullCreator : public CreatorInterface<BaseClass>
{
/// Creates no object.
BaseClass* create() {
BaseClass* create()
{
return NULL;
}
///
virtual bool isNullCreator() {
virtual bool isNullCreator()
{
return true;
}
};
......
......@@ -52,7 +52,8 @@ namespace AMDiS {
}
/// Creates a object of the type corresponding to key.
static CreatorInterface<BaseClass>* getCreator(std::string key) {
static CreatorInterface<BaseClass>* getCreator(std::string key)
{
FUNCNAME("CreatorMap::getCreator()");
init();
CreatorInterface<BaseClass> *creator = creatorMap[key];
......@@ -66,7 +67,8 @@ namespace AMDiS {
protected:
/// Constructor is protected because derived maps should be singleton.
static void init() {
static void init()
{
if (!initialized) {
initialized = true;
NullCreator<BaseClass> *nullCreator = new NullCreator<BaseClass>;
......
......@@ -44,7 +44,7 @@ namespace AMDiS {
*/
virtual DegreeOfFreedom& operator[](int i) = 0;
virtual void freeDOFIndex(DegreeOfFreedom dof) {};
virtual void freeDOFIndex(DegreeOfFreedom dof) {}
/** \brief
* Used by DOFAdmin to actualize the DOF indices in this container after
......
......@@ -91,14 +91,13 @@ namespace AMDiS {
{
position = 0;
dofFreeIterator = dofFree->begin();
if (dofFreeIterator == dofFree->end()) {
if (dofFreeIterator == dofFree->end())
return;
}
goToBeginOfIteratedObject();
if (type != ALL_DOFS) {
if (type != ALL_DOFS)
if (*dofFreeIterator == (type == USED_DOFS))
operator++();
}
}
/** \brief
......
......@@ -117,12 +117,14 @@ namespace AMDiS {
virtual void freeDOFContent(int index);
/// Returns \ref coupleMatrix.
inline bool isCoupleMatrix() {
inline bool isCoupleMatrix()
{
return coupleMatrix;
}
/// Returns \ref coupleMatrix.
inline void setCoupleMatrix(bool c) {
inline void setCoupleMatrix(bool c)
{
coupleMatrix = c;
}
......@@ -139,27 +141,33 @@ namespace AMDiS {
*/
void addOperator(Operator *op, double* factor = NULL, double* estFactor = NULL);
inline std::vector<double*>::iterator getOperatorFactorBegin() {
inline std::vector<double*>::iterator getOperatorFactorBegin()
{
return operatorFactor.begin();
}
inline std::vector<double*>::iterator getOperatorFactorEnd() {
inline std::vector<double*>::iterator getOperatorFactorEnd()
{
return operatorFactor.end();
}
inline std::vector<double*>::iterator getOperatorEstFactorBegin() {
inline std::vector<double*>::iterator getOperatorEstFactorBegin()
{
return operatorEstFactor.begin();
}
inline std::vector<double*>::iterator getOperatorEstFactorEnd() {
inline std::vector<double*>::iterator getOperatorEstFactorEnd()
{
return operatorEstFactor.end();
}
inline std::vector<Operator*>::iterator getOperatorsBegin() {
inline std::vector<Operator*>::iterator getOperatorsBegin()
{
return operators.begin();
}
inline std::vector<Operator*>::iterator getOperatorsEnd() {
inline std::vector<Operator*>::iterator getOperatorsEnd()
{
return operators.end();
}
......@@ -250,27 +258,32 @@ namespace AMDiS {
* Returns whether restriction should be performed after coarsening
* (false by default)
*/
virtual bool coarseRestrict() {
virtual bool coarseRestrict()
{
return false;
}
/// Returns const \ref rowFESpace
const FiniteElemSpace* getRowFESpace() const {
const FiniteElemSpace* getRowFESpace() const
{
return rowFESpace;
}
/// Returns const \ref colFESpace
const FiniteElemSpace* getColFESpace() const {
const FiniteElemSpace* getColFESpace() const
{
return colFESpace;
}
/// Returns const \ref rowFESpace
const FiniteElemSpace* getFESpace() const {
const FiniteElemSpace* getFESpace() const
{
return rowFESpace;
}
/// Returns number of rows (\ref matrix.size())
inline int getSize() const {
inline int getSize() const
{
return num_rows(matrix);
}
......@@ -278,17 +291,20 @@ namespace AMDiS {
* Returns the number of used rows (equal to number of used DOFs in
* the row FE space).
*/
inline int getUsedSize() const {
inline int getUsedSize() const
{
return rowFESpace->getAdmin()->getUsedSize();
}
/// Returns \ref name
inline const std::string& getName() const {
inline const std::string& getName() const
{
return name;
}
/// Resizes \ref matrix to n rows
inline void resize(int n) {
inline void resize(int n)
{
TEST_EXIT_DBG(n >= 0)("Can't resize DOFMatrix to negative size\n");
}
......@@ -322,28 +338,34 @@ namespace AMDiS {
bool symmetric();
inline std::vector<Operator*> getOperators() {
inline std::vector<Operator*> getOperators()
{
return operators;
}
inline std::vector<double*> getOperatorFactor() {
inline std::vector<double*> getOperatorFactor()
{
return operatorFactor;
}
inline std::vector<double*> getOperatorEstFactor() {
inline std::vector<double*> getOperatorEstFactor()
{
return operatorEstFactor;
}
inline BoundaryManager* getBoundaryManager() const {
inline BoundaryManager* getBoundaryManager() const
{
return boundaryManager;
}
/// Returns a pointer to \ref applyDBCs.
std::set<int>* getApplyDBCs() {
std::set<int>* getApplyDBCs()
{
return &applyDBCs;
}
inline void setBoundaryManager(BoundaryManager *bm) {
inline void setBoundaryManager(BoundaryManager *bm)
{
boundaryManager = bm;
}
......@@ -426,7 +448,8 @@ namespace AMDiS {
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
/// Sets the petsc application ordering object to map dof indices.
void useApplicationOrdering(AO *ao) {
void useApplicationOrdering(AO *ao)
{
applicationOrdering = ao;
}
#endif
......
This diff is collapsed.
......@@ -66,15 +66,18 @@ namespace AMDiS {
return true;
}
virtual bool skipEl1(ElInfo *elInfo) {
virtual bool skipEl1(ElInfo *elInfo)
{
return false;
}
virtual bool skipEl2(ElInfo *elInfo) {
virtual bool skipEl2(ElInfo *elInfo)
{
return false;
}
inline void setFillSubElemMat(bool b, const BasisFunction *fcts) {
inline void setFillSubElemMat(bool b, const BasisFunction *fcts)
{
fillSubElemMat = b;
basisFcts = fcts;
}
......
......@@ -64,7 +64,8 @@ namespace AMDiS {
* Assignement operator.
* \param rhs right hand side.
*/
ElInfo& operator=(const ElInfo& rhs) {
ElInfo& operator=(const ElInfo& rhs)
{
mesh_ = rhs.mesh_;
element_ = rhs.element_;
parent_ = rhs.parent_;
......@@ -87,37 +88,44 @@ namespace AMDiS {
*/
/// Get ElInfo's \ref mesh_
inline Mesh* getMesh() const {
inline Mesh* getMesh() const
{
return mesh_;
}
/// Get ElInfo's \ref macroElement_
inline MacroElement* getMacroElement() const {
inline MacroElement* getMacroElement() const
{
return macroElement_;
}
/// Get ElInfo's \ref element
inline Element* getElement() const {
inline Element* getElement() const
{
return element_;
}
/// Get ElInfo's \ref parent_
inline Element* getParent() const {
inline Element* getParent() const
{
return parent_;
}
/// Get ElInfo's \ref fillFlag_
inline Flag getFillFlag() const {
inline Flag getFillFlag() const
{
return fillFlag_;
}
/// Get ElInfo's \ref level
inline int getLevel() const {
inline int getLevel() const
{
return level;
}
/// Get ElInfo's \ref iChild
inline int getIChild() const {
inline int getIChild() const
{
return iChild;
}
......@@ -125,7 +133,8 @@ namespace AMDiS {
* Get ElInfo's \ref coord_[i]. This is a WorldVector<double> filled with the
* coordinates of the i-th vertex of element \ref el.
*/
inline WorldVector<double>& getCoord(int i) {
inline WorldVector<double>& getCoord(int i)
{
return coord_[i];
}
......@@ -133,7 +142,8 @@ namespace AMDiS {
* Get ElInfo's \ref coord_[i]. This is a WorldVector<double> filled with the
* coordinates of the i-th vertex of element \ref el.
*/
inline const WorldVector<double>& getCoord(int i) const {
inline const WorldVector<double>& getCoord(int i) const
{
return coord_[i];
}
......@@ -141,7 +151,8 @@ namespace AMDiS {
* Get ElInfo's \ref coord_. This is a FixVec<WorldVector<double> > filled with the
* coordinates of the all vertice of element \ref el.
*/
inline FixVec<WorldVector<double>, VERTEX>& getCoords() {
inline FixVec<WorldVector<double>, VERTEX>& getCoords()
{
return coord_;
}
......@@ -149,17 +160,20 @@ namespace AMDiS {
* Get ElInfo's \ref coord_. This is a FixVec<WorldVector<double> > filled with the
* coordinates of the all vertice of element \ref el.
*/
inline const FixVec<WorldVector<double>, VERTEX>& getCoords() const {
inline const FixVec<WorldVector<double>, VERTEX>& getCoords() const
{
return coord_;
}
/// Get ElInfo's \ref oppCoord_[i]