Commit 7c35d72d authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Some optimizations.

parent 03a3f621
......@@ -77,12 +77,11 @@ class ElementLevelSet
mesh = mesh_;
dim = mesh->getDim();
elIntersecPoints =
NEW VectorOfFixVecs<DimVec<double> >(dim,
MAX_INTERSECTION_POINTS,
NO_INIT);
elVertexStatusVec = new int[dim+1];
elVertexLevelSetVec = new double[dim+1];
elIntersecPoints = new VectorOfFixVecs<DimVec<double> >(dim,
MAX_INTERSECTION_POINTS,
NO_INIT);
elVertexStatusVec = new int[dim + 1];
elVertexLevelSetVec = new double[dim + 1];
int setElementLevelSetTol = 0;
GET_PARAMETER(0, name + "->set ElementLevelSet tolerances", "%d",
......@@ -106,7 +105,7 @@ class ElementLevelSet
if(elVertexLevelSetVec)
delete [] elVertexLevelSetVec;
if (elIntersecPoints)
DELETE elIntersecPoints;
delete elIntersecPoints;
}
/**
......@@ -138,18 +137,15 @@ class ElementLevelSet
int createElementLevelSet(const ElInfo *elInfo_,
const bool doCalcIntersecPts_ = true);
/**
* Gets value of level set function at point given in
* barycentric coordinates.
*/
inline double calcLevelSetFct(const DimVec<double>& bary) {
/// Gets value of level set function at point given in barycentric coordinates.
inline double calcLevelSetFct(const DimVec<double>& bary)
{
return (*lSFct)(bary);
};
}
/**
* Resets level set information on element.
*/
inline void resetElement() {
/// Resets level set information on element.
inline void resetElement()
{
FUNCNAME("ElementLevelSet::resetElement");
numElVertexInterior = 0;
......@@ -157,116 +153,109 @@ class ElementLevelSet
numElVertexExterior = 0;
numIntersecPoints = 0;
elStatus = LEVEL_SET_UNDEFINED;
};
}
/**
* Defines current element (elInfo).
*/
inline void setElement(const ElInfo *elInfo_) {
/// Defines current element (elInfo).
inline void setElement(const ElInfo *elInfo_)
{
elInfo = elInfo_;
resetElement();
};
/**
* Set level_set_domain.
*/
inline void setLevelSetDomain(int status_) {
}
/// Set level_set_domain.
inline void setLevelSetDomain(int status_)
{
TEST_EXIT(status_ == LEVEL_SET_INTERIOR ||
status_ == LEVEL_SET_EXTERIOR ||
status_ == LEVEL_SET_BOUNDARY)("illegal level set status !\n");
level_set_domain = status_;
};
}
/**
* Functions to set tolerances for intersection point calculation.
*/
inline void setLsValTol(double tol) {LS_VAL_TOL = tol;};
inline void setLsValMin(double min) {LS_VAL_MIN = min;};
inline void setSpBaryTol(double tol) {SP_BARY_TOL = tol;};
/// Functions to set tolerances for intersection point calculation.
inline void setLsValTol(double tol)
{
LS_VAL_TOL = tol;
}
/**
* Get level_set_domain.
*/
inline const int& getLevelSetDomain() const {
inline void setLsValMin(double min)
{
LS_VAL_MIN = min;
}
inline void setSpBaryTol(double tol)
{
SP_BARY_TOL = tol;
}
/// Get level_set_domain.
inline const int& getLevelSetDomain() const
{
return level_set_domain;
};
}
/**
* Get LevelSet-Status of element.
*/
inline const int& getElementLevelSetStatus() const {
/// Get LevelSet-Status of element.
inline const int& getElementLevelSetStatus() const
{
return elStatus;
};
}
/**
* Get number of vertices which are intersection points.
*/
inline const int& getNumVertIntPoints() const {
/// Get number of vertices which are intersection points.
inline const int& getNumVertIntPoints() const
{
FUNCNAME("ElementLevelSet::getNumVertIntPoints");
TEST_EXIT(numElVertexBoundary == 0)("numElVertexBoundary should be zero!\n");
return numElVertexBoundary;
};
};
/**
* Get vector elVertexStatusVec.
*/
inline const int *getElVertStatusVec() const {
/// Get vector elVertexStatusVec.
inline const int *getElVertStatusVec() const
{
return elVertexStatusVec;
};
}
/**
* Get i-th component of vector elVertexLevelSetVec.
*/
inline const double getElVertLevelSetVec(const int i) const {
/// Get i-th component of vector elVertexLevelSetVec.
inline const double getElVertLevelSetVec(const int i) const
{
return elVertexLevelSetVec[i];
};
}
/**
* Get vector elVertexLevelSetVec.
*/
inline const double *getElVertLevelSetVec() const {
/// Get vector elVertexLevelSetVec.
inline const double *getElVertLevelSetVec() const
{
return elVertexLevelSetVec;
};
}
/**
* Get levelSetFct.
*/
inline ElementFunction<double> *getLevelSetFct() const {
/// Get levelSetFct.
inline ElementFunction<double> *getLevelSetFct() const
{
return lSFct;
};
}
/**
* Get mesh.
*/
inline Mesh *getMesh() const {
/// Get mesh.
inline Mesh *getMesh() const
{
return mesh;
};
}
/**
* Get dim.
*/
inline int getDim() const {
/// Get dim.
inline int getDim() const
{
return dim;
};
}
/**
* Get the intersection points.
*/
inline VectorOfFixVecs<DimVec<double> > *getElIntersecPoints() const {
/// Get the intersection points.
inline VectorOfFixVecs<DimVec<double> > *getElIntersecPoints() const
{
return elIntersecPoints;
};
}
/**
* Get number of intersection points.
*/
inline int getNumElIntersecPoints() const {
/// Get number of intersection points.
inline int getNumElIntersecPoints() const
{
return numIntersecPoints;
};
}
/**
* Calculate exterior normal to intersection plane.
*/
/// Calculate exterior normal to intersection plane.
void calcIntersecNormal(WorldVector<double> &normal);
/**
......@@ -287,9 +276,7 @@ class ElementLevelSet
int getVertexPos(const DimVec<double> barCoords);
protected:
/**
* Calculates level set value of each vertex of element.
*/
/// Calculates level set value of each vertex of element.
void calculateElementLevelSetVal();
/**
......
......@@ -565,17 +565,15 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
for (int iq = 0; iq < nPoints; iq++)
result[iq] +=
fac *
(*f)(vecAtQPs1[iq], vecAtQPs2[iq], gradAtQPs1[iq], gradAtQPs2[iq]) *
fac * (*f)(vecAtQPs1[iq], vecAtQPs2[iq], gradAtQPs1[iq], gradAtQPs2[iq]) *
uhAtQP[iq];
}
void Vec2AndGrad2AtQP_ZOT::getC(const ElInfo *, int nPoints,
std::vector<double> &C) const
void Vec2AndGrad2AtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C)
{
for (int iq = 0; iq < nPoints; iq++)
C[iq] += (*f)(vecAtQPs1[iq], vecAtQPs2[iq], gradAtQPs1[iq], gradAtQPs2[iq]);
......@@ -605,8 +603,7 @@ namespace AMDiS {
gradAtQPs = getGradientsAtQPs(vecGrd, elInfo, subAssembler, quad);
}
void Vec2AndGradVecAtQP_ZOT::getC(const ElInfo *, int nPoints,
std::vector<double> &C) const
void Vec2AndGradVecAtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C)
{
for (int iq = 0; iq < nPoints; iq++)
C[iq] += (*f)(vec1AtQPs[iq], vec2AtQPs[iq], gradAtQPs[iq]);
......@@ -617,7 +614,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
for (int iq = 0; iq < nPoints; iq++)
result[iq] +=
......@@ -643,6 +640,9 @@ namespace AMDiS {
auxFeSpaces.insert(grads[i]->getFESpace());
}
vecsArg.resize(vecs_.size());
gradsArg.resize(grads_.size());
}
GeneralParametric_ZOT::GeneralParametric_ZOT(std::vector<DOFVectorBase<double>*> vecs,
......@@ -758,7 +758,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
if (grdUhAtQP)
for (int iq = 0; iq < nPoints; iq++)
......@@ -798,11 +798,11 @@ namespace AMDiS {
}
void FctVecAtQP_FOT::eval(int nPoints,
const double *uhAtQP,
const double *uhAtQP,
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
if (grdUhAtQP)
for (int iq = 0; iq < nPoints; iq++)
......@@ -857,7 +857,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
if (grdUhAtQP)
for (int iq = 0; iq < nPoints; iq++)
......@@ -926,7 +926,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
if (grdUhAtQP)
for (int iq = 0; iq < nPoints; iq++)
......@@ -1156,7 +1156,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double factor) const
double factor)
{
int dow = Global::getGeo(WORLD);
......@@ -1683,7 +1683,7 @@ namespace AMDiS {
lb(Lambda, (*g)(coordsAtQPs[iq]), Lb[iq], 1.0);
}
void VecAtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C) const
void VecAtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C)
{
if (f) {
for (int iq = 0; iq < nPoints; iq++)
......@@ -1699,7 +1699,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
if (f) {
for (int iq = 0; iq < nPoints; iq++)
......@@ -1711,7 +1711,7 @@ namespace AMDiS {
}
void MultVecAtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C) const
void MultVecAtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C)
{
for (int iq = 0; iq < nPoints; iq++)
C[iq] += (*f1)(vecAtQPs1[iq]) * (*f2)(vecAtQPs2[iq]);
......@@ -1722,13 +1722,13 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
for (int iq = 0; iq < nPoints; iq++)
result[iq] += fac * (*f1)(vecAtQPs1[iq]) * (*f2)(vecAtQPs2[iq]) * uhAtQP[iq];
}
void Vec2AtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C) const
void Vec2AtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C)
{
for (int iq = 0; iq < nPoints; iq++)
C[iq] += (*f)(vecAtQPs1[iq], vecAtQPs2[iq]);
......@@ -1739,13 +1739,13 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
for (int iq = 0; iq < nPoints; iq++)
result[iq] += fac * (*f)(vecAtQPs1[iq], vecAtQPs2[iq]) * uhAtQP[iq];
}
void Vec3AtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C) const
void Vec3AtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C)
{
for (int iq = 0; iq < nPoints; iq++)
C[iq] += (*f)(vecAtQPs1[iq], vecAtQPs2[iq], vecAtQPs3[iq]);
......@@ -1756,7 +1756,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
for (int iq = 0; iq < nPoints; iq++)
result[iq] +=
......@@ -1764,8 +1764,7 @@ namespace AMDiS {
}
void VecAndCoordsAtQP_ZOT::getC(const ElInfo *, int nPoints,
std::vector<double> &C) const
void VecAndCoordsAtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C)
{
for (int iq = 0; iq < nPoints; iq++)
C[iq] += (*f)(vecAtQPs[iq], coordsAtQPs[iq]);
......@@ -1776,15 +1775,14 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
for (int iq = 0; iq < nPoints; iq++)
result[iq] += fac * (*f)(vecAtQPs[iq], coordsAtQPs[iq]) * uhAtQP[iq];
}
void FctGradientCoords_ZOT::getC(const ElInfo *, int nPoints,
std::vector<double> &C) const
void FctGradientCoords_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C)
{
for (int iq = 0; iq < nPoints; iq++)
C[iq] += (*f)(gradAtQPs[iq], coordsAtQPs[iq]);
......@@ -1795,15 +1793,14 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
for (int iq = 0; iq < nPoints; iq++)
result[iq] +=
fac * (*f)(gradAtQPs[iq], coordsAtQPs[iq]) * uhAtQP[iq];
}
void VecGradCoordsAtQP_ZOT::getC(const ElInfo *, int nPoints,
std::vector<double> &C) const
void VecGradCoordsAtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C)
{
for (int iq = 0; iq < nPoints; iq++)
C[iq] += (*f)(vecAtQPs[iq], gradAtQPs[iq], coordsAtQPs[iq]);
......@@ -1814,7 +1811,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
for (int iq = 0; iq < nPoints; iq++)
result[iq] +=
......@@ -1828,7 +1825,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
for (int iq = 0; iq < nPoints; iq++)
result[iq] +=
......@@ -1837,15 +1834,13 @@ namespace AMDiS {
uhAtQP[iq];
}
void Vec2AndGradAtQP_ZOT::getC(const ElInfo *, int nPoints,
std::vector<double> &C) const
void Vec2AndGradAtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C)
{
for (int iq = 0; iq < nPoints; iq++)
C[iq] += (*f)(vecAtQPs1[iq], gradAtQPs[iq], vecAtQPs2[iq]);
}
void VecAndGradAtQP_ZOT::getC(const ElInfo *, int nPoints,
std::vector<double> &C) const
void VecAndGradAtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C)
{
for (int iq = 0; iq < nPoints; iq++)
C[iq] += (*f)(vecAtQPs[iq], gradAtQPs[iq]);
......@@ -1856,14 +1851,13 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
for (int iq = 0; iq < nPoints; iq++)
result[iq] += fac * (*f)(vecAtQPs[iq], gradAtQPs[iq]) * uhAtQP[iq];
}
void VecAndGradVecAtQP_ZOT::getC(const ElInfo *, int nPoints,
std::vector<double> &C) const
void VecAndGradVecAtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C)
{
for (int iq = 0; iq < nPoints; iq++)
C[iq] += (*f)(vecAtQPs[iq], gradAtQPs[iq]);
......@@ -1874,14 +1868,13 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
for (int iq = 0; iq < nPoints; iq++)
result[iq] += fac * (*f)(vecAtQPs[iq], gradAtQPs[iq]) * uhAtQP[iq];
}
void VecAndGradVec2AtQP_ZOT::getC(const ElInfo *, int nPoints,
std::vector<double> &C) const
void VecAndGradVec2AtQP_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C)
{
for (int iq = 0; iq < nPoints; iq++)
C[iq] += (*f)(vecAtQPs[iq], grad1AtQPs[iq], grad2AtQPs[iq]);
......@@ -1892,14 +1885,14 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
for (int iq = 0; iq < nPoints; iq++)
result[iq] +=
fac * (*f)(vecAtQPs[iq], grad1AtQPs[iq], grad2AtQPs[iq]) * uhAtQP[iq];
}
void FctGradient_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C) const
void FctGradient_ZOT::getC(const ElInfo *, int nPoints, std::vector<double> &C)
{
for (int iq = 0; iq < nPoints; iq++)
C[iq] += (*f)(gradAtQPs[iq]);
......@@ -1910,14 +1903,13 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
for (int iq = 0; iq < nPoints; iq++)
result[iq] += fac * (*f)(gradAtQPs[iq]) * uhAtQP[iq];
}
void CoordsAtQP_ZOT::getC(const ElInfo *elInfo, int nPoints,
std::vector<double> &C) const
void CoordsAtQP_ZOT::getC(const ElInfo *elInfo, int nPoints, std::vector<double> &C)
{
for (int iq = 0; iq < nPoints; iq++)
C[iq] += (*g)(coordsAtQPs[iq]);
......@@ -1928,7 +1920,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
for (int iq = 0; iq < nPoints; iq++)
result[iq] += fac * (*g)(coordsAtQPs[iq]) * uhAtQP[iq];
......@@ -1939,7 +1931,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double factor) const
double factor)
{
int dow = Global::getGeo(WORLD);
......@@ -1977,7 +1969,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double factor) const
double factor)
{
int dow = Global::getGeo(WORLD);
......@@ -2006,7 +1998,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double factor) const
double factor)
{
int dow = Global::getGeo(WORLD);
......@@ -2050,7 +2042,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
int dow = Global::getGeo(WORLD);
......@@ -2080,7 +2072,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double fac) const
double fac)
{
int dow = Global::getGeo(WORLD);
......@@ -2110,7 +2102,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,
const WorldMatrix<double> *D2UhAtQP,
double *result,
double f) const
double f)
{
int dow = Global::getGeo(WORLD);
......@@ -2140,7 +2132,7 @@ namespace AMDiS {
const WorldVector<double> *grdUhAtQP,