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