From 50f0ad8771d726f6cf566e2f15f91325ddaba8f4 Mon Sep 17 00:00:00 2001
From: Simon Praetorius <simon.praetorius@tu-dresden.de>
Date: Thu, 16 Jan 2014 09:04:07 +0000
Subject: [PATCH] polarizationField base-problem updated

---
 extensions/base_problems/PolarizationField.h  | 39 +++++++++++++++----
 extensions/base_problems/PolarizationField.hh |  4 +-
 .../base_problems/PolarizationField_RB.h      | 38 +++++++++++++++---
 .../base_problems/PolarizationField_RB.hh     |  2 +-
 4 files changed, 67 insertions(+), 16 deletions(-)

diff --git a/extensions/base_problems/PolarizationField.h b/extensions/base_problems/PolarizationField.h
index f45b4f50..72e72ae8 100644
--- a/extensions/base_problems/PolarizationField.h
+++ b/extensions/base_problems/PolarizationField.h
@@ -20,19 +20,31 @@
 
 #include "AMDiS.h"
 #include "BaseProblem.h"
-#include "ExtendedProblemStat.h"
 #include "GenericOperatorTerm.h"
 
-
 namespace detail 
 {
   using namespace AMDiS;
   
-  /** \ingroup PolarizationField
+  /** \ingroup BaseProblems
   * \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>
   class PolarizationField : public BaseProblem<ProblemStatType>
   {
@@ -43,20 +55,27 @@ namespace detail
     
   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;
 
+    /// calls \ref calcVectorField and \ref super::transferInitialSolution
     void transferInitialSolution(AdaptInfo *adaptInfo) override;  
 
+    /// calls \ref calcVectorField and \ref super::closeTimestep
     void closeTimestep(AdaptInfo *adaptInfo) override;
     
+    /// write the solution and the vectorField
     void writeFiles(AdaptInfo *adaptInfo, bool force = false) override;
 
     // === getting/setting methods ===
 
+    /// return a DOFVector that describes the vectorField P
     DOFVector<WorldVector<double> >* getVectorField()
     { FUNCNAME_DBG("getVectorField()");
       TEST_EXIT_DBG(vectorField != NULL)
@@ -64,6 +83,7 @@ namespace detail
       return vectorField;
     }
     
+    /// return a pointer to the solution in the last timestep
     DOFVector<double> *getOldSolution(int i)
     { FUNCNAME_DBG("getOldSolution()");
       TEST_EXIT_DBG(oldSolution[i] != NULL)
@@ -71,7 +91,10 @@ namespace detail
       return oldSolution[i];
     }
 
+    /// implementation of BaseProblem::fillOperators
     void fillOperators() override;
+    
+    /// used in fillOperators to add the term (grad(P_i), grad(psi))
     virtual void fillLaplacian();
 
   protected: // variables
diff --git a/extensions/base_problems/PolarizationField.hh b/extensions/base_problems/PolarizationField.hh
index bcba79bb..342df737 100644
--- a/extensions/base_problems/PolarizationField.hh
+++ b/extensions/base_problems/PolarizationField.hh
@@ -16,7 +16,6 @@
  ******************************************************************************/
 
 #include "Helpers.h"
-#include "POperators.h"
 
 namespace detail {
 
@@ -55,7 +54,7 @@ PolarizationField<P>::~PolarizationField()
     vectorField = NULL;
   }
   
-  for (size_t i = 0; i < self::dow; i++) {
+  for (size_t i = 0; i < oldSolution.size(); i++) {
     if (oldSolution[i] != NULL)
       delete oldSolution[i];
     oldSolution[i] = NULL;
@@ -166,6 +165,7 @@ void PolarizationField<P>::fillOperators()
 template<typename P> 
 void PolarizationField<P>::fillLaplacian()
 {
+  const FiniteElemSpace* feSpace = self::getFeSpace(0);
   for (size_t i = 0; i < self::dow; ++i) {
     /// < -K*grad(P) , grad(psi) >
     Operator *opL = new Operator(feSpace, feSpace);
diff --git a/extensions/base_problems/PolarizationField_RB.h b/extensions/base_problems/PolarizationField_RB.h
index f02c2acd..089f44d2 100644
--- a/extensions/base_problems/PolarizationField_RB.h
+++ b/extensions/base_problems/PolarizationField_RB.h
@@ -20,7 +20,6 @@
 
 #include "AMDiS.h"
 #include "BaseProblem_RB.h"
-#include "ExtendedProblemStat.h"
 #include "GenericOperatorTerm.h"
 
 
@@ -28,11 +27,30 @@ namespace detail
 {
   using namespace AMDiS;
   
-  /** \ingroup PolarizationField_RB
+  /** \ingroup BaseProblems
   * \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>
   class PolarizationField_RB : public BaseProblem_RB //<ProblemStatType>
   {
@@ -43,20 +61,27 @@ namespace detail
     
   public: // methods
 
+    /// constructor
     PolarizationField_RB(const std::string &name_);
 
+    /// destructor
     ~PolarizationField_RB();
 
+    /// initialize the vectorField and corresponding fileWriter
     void initData() override;
 
+    /// calls \ref calcVectorField and \ref super::transferInitialSolution
     void transferInitialSolution(AdaptInfo *adaptInfo) override;  
 
+    /// calls \ref calcVectorField and \ref super::closeTimestep
     void closeTimestep(AdaptInfo *adaptInfo) override;
     
+    /// write the solution and the vectorField
     void writeFiles(AdaptInfo *adaptInfo, bool force = false) override;
 
     // === getting/setting methods ===
 
+    /// return a DOFVector that describes the vectorField P
     DOFVector<WorldVector<double> >* getVectorField()
     { FUNCNAME_DBG("getVectorField()");
       TEST_EXIT_DBG(vectorField != NULL)
@@ -64,7 +89,10 @@ namespace detail
       return vectorField;
     }
 
+    /// implementation of BaseProblem::fillOperators
     void fillOperators() override;
+    
+    /// used in fillOperators to add the term (grad(P_i), grad(psi))
     virtual void fillLaplacian();
 
   protected: // variables
diff --git a/extensions/base_problems/PolarizationField_RB.hh b/extensions/base_problems/PolarizationField_RB.hh
index 45c50c72..cd432b80 100644
--- a/extensions/base_problems/PolarizationField_RB.hh
+++ b/extensions/base_problems/PolarizationField_RB.hh
@@ -16,7 +16,6 @@
  ******************************************************************************/
 
 #include "Helpers.h"
-#include "POperators.h"
 
 namespace detail {
 
@@ -153,6 +152,7 @@ void PolarizationField_RB<P>::fillOperators()
 template<typename P> 
 void PolarizationField_RB<P>::fillLaplacian()
 {
+  const FiniteElemSpace* feSpace = self::getFeSpace(0);
   for (size_t i = 0; i < self::dow; ++i) {
     /// < -K*grad(P) , grad(psi) >
     Operator *opLaplace2 = new Operator(feSpace, feSpace);
-- 
GitLab