Commit 50f0ad87 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

polarizationField base-problem updated

parent 65250d15
...@@ -20,19 +20,31 @@ ...@@ -20,19 +20,31 @@
#include "AMDiS.h" #include "AMDiS.h"
#include "BaseProblem.h" #include "BaseProblem.h"
#include "ExtendedProblemStat.h"
#include "GenericOperatorTerm.h" #include "GenericOperatorTerm.h"
namespace detail namespace detail
{ {
using namespace AMDiS; using namespace AMDiS;
/** \ingroup PolarizationField /** \ingroup BaseProblems
* \brief * \brief
* Simulation of the relaxation of an orientation field (polarization field) * Simulation of the relaxation of an orientation field (polarization field).
*/ * The evolution equation reads:
*
* d_t P = alpha2*laplace(P#) - alpha4*P#
* P#= 1/eps * (|P|^2 - 1)*P - K*laplace(P)
*
* with P=(P1, P2), P#=(P#1, P#2) and
* |P| = sqrt(P^T*P), [laplace(P)]_i = laplace(P_i)
*
* As time-discretization a semi-implicit Euler discretization is implemented.
*
* A filewriter for P is provided via the initfile parameter
* "[name]->vectorField->output". You have to set the sup-parameter
* "(...)->ParaView vector format: 1" and
* "(...)->write vector as 3d vector: 1" to visualize the field P as
* vectorfield in ParaView.
*/
template<typename ProblemStatType> template<typename ProblemStatType>
class PolarizationField : public BaseProblem<ProblemStatType> class PolarizationField : public BaseProblem<ProblemStatType>
{ {
...@@ -43,20 +55,27 @@ namespace detail ...@@ -43,20 +55,27 @@ namespace detail
public: // methods public: // methods
PolarizationField(const std::string &name_); /// constructor
PolarizationField_RB(const std::string &name_);
~PolarizationField(); /// destructor
~PolarizationField_RB();
/// initialize the vectorField and corresponding fileWriter
void initData() override; void initData() override;
/// calls \ref calcVectorField and \ref super::transferInitialSolution
void transferInitialSolution(AdaptInfo *adaptInfo) override; void transferInitialSolution(AdaptInfo *adaptInfo) override;
/// calls \ref calcVectorField and \ref super::closeTimestep
void closeTimestep(AdaptInfo *adaptInfo) override; void closeTimestep(AdaptInfo *adaptInfo) override;
/// write the solution and the vectorField
void writeFiles(AdaptInfo *adaptInfo, bool force = false) override; void writeFiles(AdaptInfo *adaptInfo, bool force = false) override;
// === getting/setting methods === // === getting/setting methods ===
/// return a DOFVector that describes the vectorField P
DOFVector<WorldVector<double> >* getVectorField() DOFVector<WorldVector<double> >* getVectorField()
{ FUNCNAME_DBG("getVectorField()"); { FUNCNAME_DBG("getVectorField()");
TEST_EXIT_DBG(vectorField != NULL) TEST_EXIT_DBG(vectorField != NULL)
...@@ -64,6 +83,7 @@ namespace detail ...@@ -64,6 +83,7 @@ namespace detail
return vectorField; return vectorField;
} }
/// return a pointer to the solution in the last timestep
DOFVector<double> *getOldSolution(int i) DOFVector<double> *getOldSolution(int i)
{ FUNCNAME_DBG("getOldSolution()"); { FUNCNAME_DBG("getOldSolution()");
TEST_EXIT_DBG(oldSolution[i] != NULL) TEST_EXIT_DBG(oldSolution[i] != NULL)
...@@ -71,7 +91,10 @@ namespace detail ...@@ -71,7 +91,10 @@ namespace detail
return oldSolution[i]; return oldSolution[i];
} }
/// implementation of BaseProblem::fillOperators
void fillOperators() override; void fillOperators() override;
/// used in fillOperators to add the term (grad(P_i), grad(psi))
virtual void fillLaplacian(); virtual void fillLaplacian();
protected: // variables protected: // variables
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
******************************************************************************/ ******************************************************************************/
#include "Helpers.h" #include "Helpers.h"
#include "POperators.h"
namespace detail { namespace detail {
...@@ -55,7 +54,7 @@ PolarizationField<P>::~PolarizationField() ...@@ -55,7 +54,7 @@ PolarizationField<P>::~PolarizationField()
vectorField = NULL; vectorField = NULL;
} }
for (size_t i = 0; i < self::dow; i++) { for (size_t i = 0; i < oldSolution.size(); i++) {
if (oldSolution[i] != NULL) if (oldSolution[i] != NULL)
delete oldSolution[i]; delete oldSolution[i];
oldSolution[i] = NULL; oldSolution[i] = NULL;
...@@ -166,6 +165,7 @@ void PolarizationField<P>::fillOperators() ...@@ -166,6 +165,7 @@ void PolarizationField<P>::fillOperators()
template<typename P> template<typename P>
void PolarizationField<P>::fillLaplacian() void PolarizationField<P>::fillLaplacian()
{ {
const FiniteElemSpace* feSpace = self::getFeSpace(0);
for (size_t i = 0; i < self::dow; ++i) { for (size_t i = 0; i < self::dow; ++i) {
/// < -K*grad(P) , grad(psi) > /// < -K*grad(P) , grad(psi) >
Operator *opL = new Operator(feSpace, feSpace); Operator *opL = new Operator(feSpace, feSpace);
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "AMDiS.h" #include "AMDiS.h"
#include "BaseProblem_RB.h" #include "BaseProblem_RB.h"
#include "ExtendedProblemStat.h"
#include "GenericOperatorTerm.h" #include "GenericOperatorTerm.h"
...@@ -28,11 +27,30 @@ namespace detail ...@@ -28,11 +27,30 @@ namespace detail
{ {
using namespace AMDiS; using namespace AMDiS;
/** \ingroup PolarizationField_RB /** \ingroup BaseProblems
* \brief * \brief
* Simulation of the relaxation of an orientation field (polarization field) * Simulation of the relaxation of an orientation field (polarization field).
*/ * The evolution equation reads:
*
* d_t P = alpha2*laplace(P#) - alpha4*P#
* P#= 1/eps * (|P|^2 - 1)*P - K*laplace(P)
*
* with P=(P1, P2), P#=(P#1, P#2) and
* |P| = sqrt(P^T*P), [laplace(P)]_i = laplace(P_i)
*
* As time-discretization a Rosenbrock scheme is implemented. You have to use
* an ExtendedRosenbrockAdaptInstationary<ThisType> to run the time evolution.
* Therefor you have to set Rosenbrock parameters in the initfile:
* "[name]->space->rosenbrock->method: METHOD"
* "[name]->space->rosenbrock->error weights: [1,1,0,0]"
* "adapt[0]->time tolerance: TOL"
*
* A filewriter for P is provided via the initfile parameter
* "[name]->vectorField->output". You have to set the sup-parameter
* "(...)->ParaView vector format: 1" and
* "(...)->write vector as 3d vector: 1" to visualize the field P as
* vectorfield in ParaView.
*/
template<typename ProblemStatType> template<typename ProblemStatType>
class PolarizationField_RB : public BaseProblem_RB //<ProblemStatType> class PolarizationField_RB : public BaseProblem_RB //<ProblemStatType>
{ {
...@@ -43,20 +61,27 @@ namespace detail ...@@ -43,20 +61,27 @@ namespace detail
public: // methods public: // methods
/// constructor
PolarizationField_RB(const std::string &name_); PolarizationField_RB(const std::string &name_);
/// destructor
~PolarizationField_RB(); ~PolarizationField_RB();
/// initialize the vectorField and corresponding fileWriter
void initData() override; void initData() override;
/// calls \ref calcVectorField and \ref super::transferInitialSolution
void transferInitialSolution(AdaptInfo *adaptInfo) override; void transferInitialSolution(AdaptInfo *adaptInfo) override;
/// calls \ref calcVectorField and \ref super::closeTimestep
void closeTimestep(AdaptInfo *adaptInfo) override; void closeTimestep(AdaptInfo *adaptInfo) override;
/// write the solution and the vectorField
void writeFiles(AdaptInfo *adaptInfo, bool force = false) override; void writeFiles(AdaptInfo *adaptInfo, bool force = false) override;
// === getting/setting methods === // === getting/setting methods ===
/// return a DOFVector that describes the vectorField P
DOFVector<WorldVector<double> >* getVectorField() DOFVector<WorldVector<double> >* getVectorField()
{ FUNCNAME_DBG("getVectorField()"); { FUNCNAME_DBG("getVectorField()");
TEST_EXIT_DBG(vectorField != NULL) TEST_EXIT_DBG(vectorField != NULL)
...@@ -64,7 +89,10 @@ namespace detail ...@@ -64,7 +89,10 @@ namespace detail
return vectorField; return vectorField;
} }
/// implementation of BaseProblem::fillOperators
void fillOperators() override; void fillOperators() override;
/// used in fillOperators to add the term (grad(P_i), grad(psi))
virtual void fillLaplacian(); virtual void fillLaplacian();
protected: // variables protected: // variables
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
******************************************************************************/ ******************************************************************************/
#include "Helpers.h" #include "Helpers.h"
#include "POperators.h"
namespace detail { namespace detail {
...@@ -153,6 +152,7 @@ void PolarizationField_RB<P>::fillOperators() ...@@ -153,6 +152,7 @@ void PolarizationField_RB<P>::fillOperators()
template<typename P> template<typename P>
void PolarizationField_RB<P>::fillLaplacian() void PolarizationField_RB<P>::fillLaplacian()
{ {
const FiniteElemSpace* feSpace = self::getFeSpace(0);
for (size_t i = 0; i < self::dow; ++i) { for (size_t i = 0; i < self::dow; ++i) {
/// < -K*grad(P) , grad(psi) > /// < -K*grad(P) , grad(psi) >
Operator *opLaplace2 = new Operator(feSpace, feSpace); Operator *opLaplace2 = new Operator(feSpace, feSpace);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment