Commit 83b6de2b authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Adapted demos to new AMDiS (DELETE/delete and dirichlet boundary conditions).

parent b8488200
...@@ -7,36 +7,27 @@ using namespace AMDiS; ...@@ -7,36 +7,27 @@ using namespace AMDiS;
// ===== function definitions ================================================ // ===== function definitions ================================================
// =========================================================================== // ===========================================================================
/** \brief /// Dirichlet boundary function
* Dirichlet boundary function
*/
class G : public AbstractFunction<double, WorldVector<double> > class G : public AbstractFunction<double, WorldVector<double> >
{ {
public: public:
MEMORY_MANAGED(G);
/// Implementation of AbstractFunction::operator().
/** \brief double operator()(const WorldVector<double>& x) const
* Implementation of AbstractFunction::operator(). {
*/
double operator()(const WorldVector<double>& x) const {
return exp(-10.0 * (x * x)); return exp(-10.0 * (x * x));
} }
}; };
/** \brief /// RHS function
* RHS function
*/
class F : public AbstractFunction<double, WorldVector<double> > class F : public AbstractFunction<double, WorldVector<double> >
{ {
public: public:
MEMORY_MANAGED(F); F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {}
F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {};
/** \brief /// Implementation of AbstractFunction::operator().
* Implementation of AbstractFunction::operator(). double operator()(const WorldVector<double>& x) const
*/ {
double operator()(const WorldVector<double>& x) const {
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);
...@@ -61,7 +52,7 @@ int main(int argc, char* argv[]) ...@@ -61,7 +52,7 @@ int main(int argc, char* argv[])
// ===== create projection ===== // ===== create projection =====
WorldVector<double> ballCenter; WorldVector<double> ballCenter;
ballCenter.set(0.0); ballCenter.set(0.0);
NEW BallProject(1, new BallProject(1,
BOUNDARY_PROJECTION, BOUNDARY_PROJECTION,
ballCenter, ballCenter,
1.0); 1.0);
...@@ -71,25 +62,25 @@ int main(int argc, char* argv[]) ...@@ -71,25 +62,25 @@ int main(int argc, char* argv[])
ball.initialize(INIT_ALL); ball.initialize(INIT_ALL);
// === create adapt info === // === create adapt info ===
AdaptInfo *adaptInfo = NEW AdaptInfo("ball->adapt"); AdaptInfo *adaptInfo = new AdaptInfo("ball->adapt");
// === create adapt === // === create adapt ===
AdaptStationary *adapt = NEW AdaptStationary("ball->adapt", AdaptStationary *adapt = new AdaptStationary("ball->adapt",
&ball, &ball,
adaptInfo); adaptInfo);
// ===== add boundary conditions ===== // ===== add boundary conditions =====
ball.addDirichletBC(1, NEW G); ball.addDirichletBC(1, new G);
// ===== create matrix operator ===== // ===== create matrix operator =====
Operator matrixOperator(Operator::MATRIX_OPERATOR, ball.getFESpace()); Operator matrixOperator(Operator::MATRIX_OPERATOR, ball.getFESpace());
matrixOperator.addSecondOrderTerm(NEW Laplace_SOT); matrixOperator.addSecondOrderTerm(new Laplace_SOT);
ball.addMatrixOperator(&matrixOperator); ball.addMatrixOperator(&matrixOperator);
// ===== create rhs operator ===== // ===== create rhs operator =====
int degree = ball.getFESpace()->getBasisFcts()->getDegree(); int degree = ball.getFESpace()->getBasisFcts()->getDegree();
Operator rhsOperator(Operator::VECTOR_OPERATOR, ball.getFESpace()); Operator rhsOperator(Operator::VECTOR_OPERATOR, ball.getFESpace());
rhsOperator.addZeroOrderTerm(NEW CoordsAtQP_ZOT(NEW F(degree))); rhsOperator.addZeroOrderTerm(new CoordsAtQP_ZOT(new F(degree)));
ball.addVectorOperator(&rhsOperator); ball.addVectorOperator(&rhsOperator);
// ===== start adaption loop ===== // ===== start adaption loop =====
......
...@@ -7,36 +7,27 @@ using namespace AMDiS; ...@@ -7,36 +7,27 @@ using namespace AMDiS;
// ===== function definitions ================================================ // ===== function definitions ================================================
// =========================================================================== // ===========================================================================
/** \brief /// RHS function
* RHS function
*/
class F : public AbstractFunction<double, WorldVector<double> > class F : public AbstractFunction<double, WorldVector<double> >
{ {
public: public:
MEMORY_MANAGED(F); F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {}
F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {}; /// Implementation of AbstractFunction::operator().
double operator()(const WorldVector<double>& x) const
/** \brief {
* Implementation of AbstractFunction::operator().
*/
double operator()(const WorldVector<double>& x) const {
return -2 * x[0]; return -2 * x[0];
} }
}; };
/** \brief /// boundary
* boundary
*/
class G : public AbstractFunction<double, WorldVector<double> > class G : public AbstractFunction<double, WorldVector<double> >
{ {
public: public:
MEMORY_MANAGED(G);
/** \brief /// Implementation of AbstractFunction::operator().
* Implementation of AbstractFunction::operator(). double operator()(const WorldVector<double>& x) const
*/ {
double operator()(const WorldVector<double>& x) const {
return 10000.0; return 10000.0;
} }
}; };
...@@ -58,7 +49,7 @@ int main(int argc, char* argv[]) ...@@ -58,7 +49,7 @@ int main(int argc, char* argv[])
// ===== create projection ===== // ===== create projection =====
WorldVector<double> ballCenter; WorldVector<double> ballCenter;
ballCenter.set(0.0); ballCenter.set(0.0);
NEW BallProject(1, new BallProject(1,
VOLUME_PROJECTION, VOLUME_PROJECTION,
ballCenter, ballCenter,
1.0); 1.0);
...@@ -68,20 +59,20 @@ int main(int argc, char* argv[]) ...@@ -68,20 +59,20 @@ int main(int argc, char* argv[])
bunny.initialize(INIT_ALL); bunny.initialize(INIT_ALL);
// === create adapt info === // === create adapt info ===
AdaptInfo *adaptInfo = NEW AdaptInfo("bunny->adapt"); AdaptInfo *adaptInfo = new AdaptInfo("bunny->adapt");
// === create adapt === // === create adapt ===
AdaptStationary *adapt = NEW AdaptStationary("bunny->adapt", AdaptStationary *adapt = new AdaptStationary("bunny->adapt",
&bunny, &bunny,
adaptInfo); adaptInfo);
// ===== add boundary conditions ===== // ===== add boundary conditions =====
//bunny.addDirichletBC(1111, NEW G); //bunny.addDirichletBC(1111, new G);
// ===== create matrix operator ===== // ===== create matrix operator =====
Operator matrixOperator(Operator::MATRIX_OPERATOR, Operator matrixOperator(Operator::MATRIX_OPERATOR,
bunny.getFESpace()); bunny.getFESpace());
matrixOperator.addSecondOrderTerm(NEW Laplace_SOT); matrixOperator.addSecondOrderTerm(new Laplace_SOT);
bunny.addMatrixOperator(&matrixOperator); bunny.addMatrixOperator(&matrixOperator);
// ===== create rhs operator ===== // ===== create rhs operator =====
...@@ -90,7 +81,7 @@ int main(int argc, char* argv[]) ...@@ -90,7 +81,7 @@ int main(int argc, char* argv[])
int degree = bunny.getFESpace()->getBasisFcts()->getDegree(); int degree = bunny.getFESpace()->getBasisFcts()->getDegree();
rhsOperator.addZeroOrderTerm(NEW CoordsAtQP_ZOT(NEW F(degree))); rhsOperator.addZeroOrderTerm(new CoordsAtQP_ZOT(new F(degree)));
bunny.addVectorOperator(&rhsOperator); bunny.addVectorOperator(&rhsOperator);
// ===== start adaption loop ===== // ===== start adaption loop =====
......
...@@ -6,9 +6,8 @@ using namespace AMDiS; ...@@ -6,9 +6,8 @@ using namespace AMDiS;
class G : public AbstractFunction<double, WorldVector<double> > class G : public AbstractFunction<double, WorldVector<double> >
{ {
public: public:
MEMORY_MANAGED(G); double operator()(const WorldVector<double>& x) const
{
double operator()(const WorldVector<double>& x) const {
return exp(-10.0 * (x * x)); return exp(-10.0 * (x * x));
} }
}; };
...@@ -16,11 +15,10 @@ public: ...@@ -16,11 +15,10 @@ public:
class F : public AbstractFunction<double, WorldVector<double> > class F : public AbstractFunction<double, WorldVector<double> >
{ {
public: public:
MEMORY_MANAGED(F); F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {}
F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {};
double operator()(const WorldVector<double>& x) const { double operator()(const WorldVector<double>& x) const
{
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);
...@@ -111,9 +109,10 @@ class Identity : public AbstractFunction<double, double> ...@@ -111,9 +109,10 @@ class Identity : public AbstractFunction<double, double>
public: public:
MEMORY_MANAGED(Identity); MEMORY_MANAGED(Identity);
Identity(int degree) : AbstractFunction<double, double>(degree) {}; Identity(int degree) : AbstractFunction<double, double>(degree) {}
double operator()(const double& x) const { double operator()(const double& x) const
{
return x; return x;
} }
}; };
...@@ -145,35 +144,35 @@ int main(int argc, char* argv[]) ...@@ -145,35 +144,35 @@ int main(int argc, char* argv[])
adoptFlag); adoptFlag);
// ===== add boundary conditions for problem1 ===== // ===== add boundary conditions for problem1 =====
problem1.addDirichletBC(1, NEW G); problem1.addDirichletBC(1, new G);
// ===== add boundary conditions for problem1 ===== // ===== add boundary conditions for problem1 =====
//problem2.addDirichletBC(1, NEW G); //problem2.addDirichletBC(1, new G);
// ===== create operators for problem1 ===== // ===== create operators for problem1 =====
Operator matrixOperator1(Operator::MATRIX_OPERATOR, problem1.getFESpace()); Operator matrixOperator1(Operator::MATRIX_OPERATOR, problem1.getFESpace());
matrixOperator1.addSecondOrderTerm(NEW Laplace_SOT); matrixOperator1.addSecondOrderTerm(new Laplace_SOT);
problem1.addMatrixOperator(&matrixOperator1); problem1.addMatrixOperator(&matrixOperator1);
int degree = problem1.getFESpace()->getBasisFcts()->getDegree(); int degree = problem1.getFESpace()->getBasisFcts()->getDegree();
Operator rhsOperator1(Operator::VECTOR_OPERATOR, problem1.getFESpace()); Operator rhsOperator1(Operator::VECTOR_OPERATOR, problem1.getFESpace());
rhsOperator1.addZeroOrderTerm(NEW CoordsAtQP_ZOT(NEW F(degree))); rhsOperator1.addZeroOrderTerm(new CoordsAtQP_ZOT(new F(degree)));
problem1.addVectorOperator(&rhsOperator1); problem1.addVectorOperator(&rhsOperator1);
// ===== create operators for problem2 ===== // ===== create operators for problem2 =====
Operator matrixOperator2(Operator::MATRIX_OPERATOR, problem2.getFESpace()); Operator matrixOperator2(Operator::MATRIX_OPERATOR, problem2.getFESpace());
matrixOperator2.addZeroOrderTerm(NEW Simple_ZOT); matrixOperator2.addZeroOrderTerm(new Simple_ZOT);
problem2.addMatrixOperator(&matrixOperator2); problem2.addMatrixOperator(&matrixOperator2);
Operator rhsOperator2(Operator::VECTOR_OPERATOR, problem2.getFESpace()); Operator rhsOperator2(Operator::VECTOR_OPERATOR, problem2.getFESpace());
rhsOperator2.addZeroOrderTerm(NEW VecAtQP_ZOT(problem1.getSolution(), rhsOperator2.addZeroOrderTerm(new VecAtQP_ZOT(problem1.getSolution(),
NEW Identity(degree))); new Identity(degree)));
problem2.addVectorOperator(&rhsOperator2); problem2.addVectorOperator(&rhsOperator2);
// ===== create adaptation loop and iteration interface ===== // ===== create adaptation loop and iteration interface =====
AdaptInfo *adaptInfo = NEW AdaptInfo("couple->adapt", 1); AdaptInfo *adaptInfo = new AdaptInfo("couple->adapt", 1);
MyCoupledIteration coupledIteration(&problem1, &problem2); MyCoupledIteration coupledIteration(&problem1, &problem2);
AdaptStationary *adapt = NEW AdaptStationary("couple->adapt", AdaptStationary *adapt = new AdaptStationary("couple->adapt",
&coupledIteration, &coupledIteration,
adaptInfo); adaptInfo);
......
...@@ -3,35 +3,30 @@ ...@@ -3,35 +3,30 @@
using namespace AMDiS; using namespace AMDiS;
using namespace std; using namespace std;
// ===== function definitions // // ===========================================================================
/** \brief // ===== function definitions ================================================
* Dirichlet boundary function // ===========================================================================
*/
/// Dirichlet boundary function
class G : public AbstractFunction<double, WorldVector<double> > class G : public AbstractFunction<double, WorldVector<double> >
{ {
public: public:
MEMORY_MANAGED(G);
/** \brief /// Implementation of AbstractFunction::operator().
* Implementation of AbstractFunction::operator(). double operator()(const WorldVector<double>& x) const
*/ {
double operator()(const WorldVector<double>& x) const {
return exp(-10.0 * (x * x)); return exp(-10.0 * (x * x));
} }
}; };
/** \brief /// RHS function
* RHS function
*/
class F : public AbstractFunction<double, WorldVector<double> > class F : public AbstractFunction<double, WorldVector<double> >
{ {
public: public:
MEMORY_MANAGED(F);
/** \brief /// Implementation of AbstractFunction::operator().
* Implementation of AbstractFunction::operator(). double operator()(const WorldVector<double>& x) const
*/ {
double operator()(const WorldVector<double>& x) const {
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);
...@@ -39,7 +34,10 @@ public: ...@@ -39,7 +34,10 @@ public:
} }
}; };
// // ===== main program // // ===========================================================================
// ===== main program ========================================================
// ===========================================================================
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
FUNCNAME("main"); FUNCNAME("main");
...@@ -55,24 +53,24 @@ int main(int argc, char* argv[]) ...@@ -55,24 +53,24 @@ int main(int argc, char* argv[])
ellipt.initialize(INIT_ALL); ellipt.initialize(INIT_ALL);
// === create adapt info === // === create adapt info ===
AdaptInfo *adaptInfo = NEW AdaptInfo("ellipt->adapt"); AdaptInfo *adaptInfo = new AdaptInfo("ellipt->adapt");
// === create adapt === // === create adapt ===
AdaptStationary *adapt = NEW AdaptStationary("ellipt->adapt", AdaptStationary *adapt = new AdaptStationary("ellipt->adapt",
&ellipt, &ellipt,
adaptInfo); adaptInfo);
// ===== add boundary conditions ===== // ===== add boundary conditions =====
ellipt.addDirichletBC(1, NEW G); ellipt.addDirichletBC(1, new G);
// ===== create matrix operator ===== // ===== create matrix operator =====
Operator matrixOperator(Operator::MATRIX_OPERATOR, ellipt.getFESpace()); Operator matrixOperator(Operator::MATRIX_OPERATOR, ellipt.getFESpace());
matrixOperator.addSecondOrderTerm(NEW Laplace_SOT); matrixOperator.addSecondOrderTerm(new Laplace_SOT);
ellipt.addMatrixOperator(&matrixOperator); ellipt.addMatrixOperator(&matrixOperator);
// ===== create rhs operator ===== // ===== create rhs operator =====
Operator rhsOperator(Operator::VECTOR_OPERATOR, ellipt.getFESpace()); Operator rhsOperator(Operator::VECTOR_OPERATOR, ellipt.getFESpace());
rhsOperator.addZeroOrderTerm(NEW CoordsAtQP_ZOT(NEW F())); rhsOperator.addZeroOrderTerm(new CoordsAtQP_ZOT(new F()));
ellipt.addVectorOperator(&rhsOperator); ellipt.addVectorOperator(&rhsOperator);
// ===== start adaption loop ===== // ===== start adaption loop =====
......
...@@ -7,38 +7,29 @@ using namespace AMDiS; ...@@ -7,38 +7,29 @@ using namespace AMDiS;
// ===== function definitions ================================================ // ===== function definitions ================================================
// =========================================================================== // ===========================================================================
/** \brief /// Dirichlet boundary function
* Dirichlet boundary function
*/
class G : public AbstractFunction<double, WorldVector<double> >, class G : public AbstractFunction<double, WorldVector<double> >,
public TimedObject public TimedObject
{ {
public: public:
MEMORY_MANAGED(G);
/// Implementation of AbstractFunction::operator().
/** \brief double operator()(const WorldVector<double>& x) const
* Implementation of AbstractFunction::operator(). {
*/
double operator()(const WorldVector<double>& x) const {
return sin(M_PI * (*timePtr)) * exp(-10.0 * (x * x)); return sin(M_PI * (*timePtr)) * exp(-10.0 * (x * x));
} }
}; };
/** \brief /// RHS function
* RHS function
*/
class F : public AbstractFunction<double, WorldVector<double> >, class F : public AbstractFunction<double, WorldVector<double> >,
public TimedObject public TimedObject
{ {
public: public:
MEMORY_MANAGED(F); F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {}
F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {}; /// Implementation of AbstractFunction::operator().
double operator()(const WorldVector<double>& x) const
/** \brief {
* Implementation of AbstractFunction::operator().
*/
double operator()(const WorldVector<double>& x) const {
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);
...@@ -51,17 +42,10 @@ public: ...@@ -51,17 +42,10 @@ public:
// ===== instationary problem ================================================ // ===== instationary problem ================================================
// =========================================================================== // ===========================================================================
/** \brief /// Instationary problem
* Instationary problem
*/
class Heat : public ProblemInstatScal class Heat : public ProblemInstatScal
{ {
public: public:
MEMORY_MANAGED(Heat);
/** \brief
* Constructor
*/
Heat(ProblemScal *heatSpace) Heat(ProblemScal *heatSpace)
: ProblemInstatScal("heat", heatSpace) : ProblemInstatScal("heat", heatSpace)
{ {
...@@ -77,121 +61,98 @@ public: ...@@ -77,121 +61,98 @@ public:
theta1 = theta - 1; theta1 = theta - 1;
} }
// ===== ProblemInstatBase methods =================================== // ===== ProblemInstatBase methods ===================================
/** \brief /// set the time in all needed functions!
* set the time in all needed functions! void setTime(AdaptInfo *adaptInfo)
*/ {
void setTime(AdaptInfo *adaptInfo) {
rhsTime = adaptInfo->getTime() - (1 - theta) * adaptInfo->getTimestep(); rhsTime = adaptInfo->getTime() - (1 - theta) * adaptInfo->getTimestep();
boundaryTime = adaptInfo->getTime(); boundaryTime = adaptInfo->getTime();
tau1 = 1.0 / adaptInfo->getTimestep(); tau1 = 1.0 / adaptInfo->getTimestep();
} }
void closeTimestep(AdaptInfo *adaptInfo) { void closeTimestep(AdaptInfo *adaptInfo)
{
ProblemInstatScal::closeTimestep(adaptInfo); ProblemInstatScal::closeTimestep(adaptInfo);
WAIT; WAIT;
} }
// ===== initial problem methods ===================================== // ===== initial problem methods =====================================
/** \brief /// Used by \ref problemInitial to solve the system of the initial problem
* Used by \ref problemInitial to solve the system of the initial problem void solve(AdaptInfo *adaptInfo)
*/ {
void solve(AdaptInfo *adaptInfo) {
problemStat->getSolution()->interpol(exactSolution); problemStat->getSolution()->interpol(exactSolution);
} }