Commit ecf4d835 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* AbstractFunction changed to value (not reference) return

parent 3dc9cf95
......@@ -18,12 +18,9 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const
{
static double result;
result = exp(-10.0*(x*x));
return result;
};
double operator()(const WorldVector<double>& x) const {
return exp(-10.0 * (x * x));
}
};
/** \brief
......@@ -39,14 +36,12 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const {
static double result = 0.0;
double operator()(const WorldVector<double>& x) const {
int dim = x.getSize();
double r2 = (x*x);
double r2 = x * x;
double ux = exp(-10.0*r2);
result = -(400.0*r2 - 20.0*dim)*ux;
return result;
};
return -(400.0 * r2 - 20.0 * dim) * ux;
}
};
// ===========================================================================
......
......@@ -20,11 +20,9 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const {
static double result = 0.0;
result = -2 * x[0];
return result;
};
double operator()(const WorldVector<double>& x) const {
return -2 * x[0];
}
};
/** \brief
......@@ -38,11 +36,11 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const {
static double result = 10000.0;
return result;
};
double operator()(const WorldVector<double>& x) const {
return 10000.0;
}
};
// ===========================================================================
// ===== main program ========================================================
// ===========================================================================
......
......@@ -8,12 +8,9 @@ class G : public AbstractFunction<double, WorldVector<double> >
public:
MEMORY_MANAGED(G);
const double& operator()(const WorldVector<double>& x) const
{
static double result;
result = exp(-10.0*(x*x));
return result;
};
double operator()(const WorldVector<double>& x) const {
return exp(-10.0 * (x * x));
}
};
class F : public AbstractFunction<double, WorldVector<double> >
......@@ -23,14 +20,12 @@ public:
F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {};
const double& operator()(const WorldVector<double>& x) const {
static double result = 0.0;
double operator()(const WorldVector<double>& x) const {
int dow = x.getSize();
double r2 = (x*x);
double ux = exp(-10.0*r2);
result = -(400.0*r2 - 20.0*dow)*ux;
return result;
};
double r2 = (x * x);
double ux = exp(-10.0 * r2);
return -(400.0 * r2 - 20.0 * dow) * ux;
}
};
class MyCoupledIteration : public ProblemIterationInterface
......@@ -39,8 +34,9 @@ public:
MyCoupledIteration(ProblemStatBase *prob1,
ProblemStatBase *prob2)
: problem1(prob1),
problem2(prob2)
{};
problem2(prob2),
name("MyCoupledIteration")
{}
void beginIteration(AdaptInfo *adaptInfo)
{
......@@ -48,14 +44,14 @@ public:
MSG("\n");
MSG("begin of iteration number: %d\n", adaptInfo->getSpaceIteration()+1);
MSG("=============================\n");
};
}
void endIteration(AdaptInfo *adaptInfo) {
FUNCNAME("StandardProblemIteration::endIteration()");
MSG("\n");
MSG("end of iteration number: %d\n", adaptInfo->getSpaceIteration()+1);
MSG("=============================\n");
};
}
Flag oneIteration(AdaptInfo *adaptInfo, Flag toDo = FULL_ITERATION)
{
......@@ -71,25 +67,43 @@ public:
if(toDo.isSet(ESTIMATE)) problem1->estimate(adaptInfo);
return flag;
};
}
int getNumProblems()
{
return 2;
};
}
ProblemStatBase *getProblem(int number = 0)
{
FUNCNAME("CoupledIteration::getProblem()");
if(number == 0) return problem1;
if(number == 1) return problem2;
if (number == 0)
return problem1;
if (number == 1)
return problem2;
ERROR_EXIT("invalid problem number\n");
return NULL;
};
}
const std::string& getName()
{
return name;
}
void serialize(std::ostream&)
{}
void deserialize(std::istream&)
{}
private:
ProblemStatBase *problem1;
ProblemStatBase *problem2;
std::string name;
};
class Identity : public AbstractFunction<double, double>
......@@ -99,11 +113,9 @@ public:
Identity(int degree) : AbstractFunction<double, double>(degree) {};
const double& operator()(const double& x) const {
static double result;
result = x;
return result;
};
double operator()(const double& x) const {
return x;
}
};
int main(int argc, char* argv[])
......
......@@ -15,12 +15,9 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const
{
static double result;
result = exp(-10.0 * (x * x));
return result;
};
double operator()(const WorldVector<double>& x) const {
return exp(-10.0 * (x * x));
}
};
/** \brief
......@@ -34,14 +31,12 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const {
static double result = 0.0;
double operator()(const WorldVector<double>& x) const {
int dow = x.getSize();
double r2 = (x * x);
double ux = exp(-10.0 * r2);
result = -(400.0 * r2 - 20.0 * dow) * ux;
return result;
};
return -(400.0 * r2 - 20.0 * dow) * ux;
}
};
// // ===== main program //
......
......@@ -19,11 +19,8 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const
{
static double result;
result = sin(M_PI*(*timePtr)) * exp(-10.0*(x*x));
return result;
double operator()(const WorldVector<double>& x) const {
return sin(M_PI * (*timePtr)) * exp(-10.0 * (x * x));
};
};
......@@ -41,14 +38,12 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const {
static double result;
double operator()(const WorldVector<double>& x) const {
int dim = x.getSize();
double r2 = (x*x);
double ux = sin(M_PI * (*timePtr)) * exp(-10.0*r2);
double ut = M_PI * cos(M_PI*(*timePtr)) * exp(-10.0*r2);
result = ut -(400.0*r2 - 20.0*dim)*ux;
return result;
double r2 = x * x;
double ux = sin(M_PI * (*timePtr)) * exp(-10.0 * r2);
double ut = M_PI * cos(M_PI * (*timePtr)) * exp(-10.0 * r2);
return ut -(400.0 * r2 - 20.0 * dim) * ux;
};
};
......
......@@ -18,12 +18,9 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const
{
static double result;
result = exp(-10.0*(x*x));
return result;
};
double operator()(const WorldVector<double>& x) const
return exp(-10.0 * (x * x));
}
};
/** \brief
......@@ -39,59 +36,35 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const {
static double result = 0.0;
double operator()(const WorldVector<double>& x) const {
int dim = x.getSize();
double r2 = (x*x);
double ux = exp(-10.0*r2);
result = -(400.0*r2 - 20.0*dim)*ux;
return result;
};
double r2 = x * x;
double ux = exp(-10.0 * r2);
return -(400.0 * r2 - 20.0 * dim) * ux;
}
};
class WaitingProblem : public ProblemScal
{
public:
WaitingProblem(const char *name) : ProblemScal(name) {};
WaitingProblem(const char *name)
: ProblemScal(name)
{}
void solve(AdaptInfo *adaptInfo) {
FUNCNAME("WaitingProblem::solve()");
static MultiGridSolver *mgSolver = NULL;
if(!mgSolver) mgSolver = NEW MultiGridSolver(feSpace_,
NEW GSSmoother(1.0),
systemMatrix_,
solution_,
rhs_);
if (!mgSolver)
mgSolver = NEW MultiGridSolver(feSpace_,
NEW GSSmoother(1.0),
systemMatrix_,
solution_,
rhs_);
mgSolver->solve();
};
// void endIteration(AdaptInfo *adaptInfo)
// {
// int myConvergence =
// (adaptInfo->getSpaceIteration() == adaptInfo->getMaxSpaceIteration()) ||
// adaptInfo->spaceToleranceReached() ? CCI_STOP : CCI_CONTINUE;
// int convergence;
// int syncPointID = 1;
// int quantityID = 1;
// ProblemScal::endIteration(adaptInfo);
// static MpCCIAdapter mpcciAdapter(123, 1, 1,
// feSpace_, 1, -1,
// 1, &quantityID, &solution_,
// 1, &syncPointID);
// mpcciAdapter.remesh();
// mpcciAdapter.checkConvergence(myConvergence, &convergence);
// mpcciAdapter.putNodes(1);
// mpcciAdapter.reachSyncPoint(1);
// WAIT;
// };
}
};
// // ===== main program //
......
......@@ -16,12 +16,9 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const
{
static double result;
result = exp(-10.0*(x*x));
return result;
};
double operator()(const WorldVector<double>& x) const {
return exp(-10.0 * (x * x));
}
};
/** \brief
......@@ -37,14 +34,12 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const {
static double result = 0.0;
double operator()(const WorldVector<double>& x) const {
int dim = x.getSize();
double r2 = (x*x);
double ux = exp(-10.0*r2);
result = -(400.0*r2 - 20.0*dim)*ux;
return result;
};
double r2 = (x * x);
double ux = exp(-10.0 * r2);
return -(400.0 * r2 - 20.0 * dim) * ux;
}
};
// // ===== main program //
......
......@@ -18,12 +18,9 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const
{
static double result;
result = exp(-10.0*(x*x));
return result;
};
double operator()(const WorldVector<double>& x) const {
return exp(-10.0 * (x * x));
}
};
/** \brief
......@@ -39,15 +36,12 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const {
static double result = 0.0;
double operator()(const WorldVector<double>& x) const {
int dim = x.getSize();
double r2 = (x*x);
double ux = exp(-10.0*r2);
result = -(400.0*r2 - 20.0*dim)*ux;
// result = 1000 * sin(2*M_PI*x[0])*cos(10*2*M_PI*x[1]);
return result;
};
return -(400.0*r2 - 20.0*dim)*ux;
}
};
// ===== main program //
......
......@@ -20,12 +20,9 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const
{
static double result;
result = x[comp];
return result;
};
double operator()(const WorldVector<double>& x) const {
return x[comp];
}
protected:
/** \brief
......@@ -51,12 +48,9 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const
{
static double result = 0.0;
result = constant;
return result;
};
double operator()(const WorldVector<double>& x) const {
return constant;
}
protected:
double constant;
......@@ -74,12 +68,9 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const
{
static double result = 0.0;
result = (x[0] == 0.0) || (x[0] == 1.0) ? 0.0 : 1.0;
return result;
};
double operator()(const WorldVector<double>& x) const {
return (x[0] == 0.0) || (x[0] == 1.0) ? 0.0 : 1.0;
}
protected:
double constant;
......
......@@ -8,11 +8,9 @@ class N : public AbstractFunction<double, WorldVector<double> >
public:
MEMORY_MANAGED(N);
const double& operator()(const WorldVector<double>& x) const
{
static double result = 1.0;
return result;
};
double operator()(const WorldVector<double>& x) const {
return 1.0;
}
};
// ===== function definitions //
......@@ -27,12 +25,9 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const
{
static double result;
result = exp(-10.0*(x*x));
return result;
};
double operator()(const WorldVector<double>& x) const {
return exp(-10.0 * (x * x));
}
};
/** \brief
......@@ -48,14 +43,12 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const {
static double result = 0.0;
double operator()(const WorldVector<double>& x) const {
int dow = x.getSize();
double r2 = (x*x);
double ux = exp(-10.0*r2);
result = -(400.0*r2 - 20.0*dow)*ux;
return result;
};
return -(400.0*r2 - 20.0*dow)*ux;
}
};
// // ===== main program //
......
......@@ -18,11 +18,9 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const {
static double result;
result = exp(-10.0*(x*x));
return result;
};
double operator()(const WorldVector<double>& x) const {
return exp(-10.0*(x*x));
}
};
/** \brief
......@@ -43,12 +41,12 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const {
static double result;
double r2 = x*x, ux = exp(-10.0*r2), ux4 = ux*ux*ux*ux;
result = sigma*ux4 - k*(400.0*r2 - 20.0*dim)*ux;
return result;
};
double operator()(const WorldVector<double>& x) const {
double r2 = x*x;
double ux = exp(-10.0*r2);
double ux4 = ux*ux*ux*ux;
return sigma*ux4 - k*(400.0*r2 - 20.0*dim)*ux;
}
private:
double sigma;
......@@ -74,11 +72,9 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const double& x) const {
static double result = 0.0;
result = sigma * x * x * x;
return result;
};
double operator()(const double& x) const {
return sigma * x * x * x;
}
private:
double sigma;
......
......@@ -18,11 +18,9 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const {
static double result;
result = exp(-10.0*(x*x));
return result;
};
double operator()(const WorldVector<double>& x) const {
return exp(-10.0 * (x * x));
}
};
class Zero : public AbstractFunction<double, WorldVector<double> >
......@@ -31,8 +29,7 @@ public:
MEMORY_MANAGED(Zero);
const double& operator()(const WorldVector<double>& x) const {
static double result = 0.0;
return result;
return 0.0;
};
};
......@@ -54,13 +51,13 @@ public:
/** \brief
* Implementation of AbstractFunction::operator().
*/
const double& operator()(const WorldVector<double>& x) const {
static double result;
double operator()(const WorldVector<double>& x) const {
int dow = x.getSize();
double r2 = x*x, ux = exp(-10.0*r2), ux4 = ux*ux*ux*ux;
result = ux4 -(400.0*r2 - 20.0*dow)*ux;
return result;
};
double r2 = x*x;
double ux = exp(-10.0*r2);
double ux4 = ux*ux*ux*ux;
return ux4 -(400.0*r2 - 20.0*dow)*ux;
}
};