Commit 0879bc18 by Praetorius, Simon

### some baseproblems extended

parent f429edf0
 ... ... @@ -21,6 +21,7 @@ #include "HL_SignedDistTraverse.h" #include "Recovery.h" #include "GenericZeroOrderTerm.h" using namespace AMDiS; ... ... @@ -154,52 +155,66 @@ void CahnHilliard

 ... ... @@ -21,6 +21,7 @@ #include "AMDiS.h" #include "BaseProblem.h" #include "chns.h" #include "GenericOperatorTerm.h" namespace detail { ... ... @@ -65,6 +66,51 @@ namespace detail { double minusEpsSqr; }; class MobilityCH0_ : public FunctorBase //: public AbstractFunction { public: MobilityCH0_(double gamma_=1.0) : gamma(gamma_), delta(1.e-6) { } typedef double value_type; int getDegree(int d0) const { return d0 * 4; } double operator()(const double &ch) const { double phase = std::max(0.0, std::min(1.0, ch)); double mobility = 0.25*sqr(phase)*sqr(phase-1.0); return gamma * std::max(mobility, delta); } protected: double gamma; double delta; }; class MobilityCH1_ : public FunctorBase // : public AbstractFunction { public: MobilityCH1_(double gamma_=1.0) : gamma(gamma_), delta(1.e-6) { } typedef double value_type; int getDegree(int d0) const { return d0 * 4; } double operator()(const double &ch) const { double phase = std::max(-1.0, std::min(1.0, ch)); double mobility = 0.25*sqr(sqr(phase)-1.0); return gamma * std::max(mobility, delta); } protected: double gamma; double delta; }; } // end namespace detail #include "CahnHilliard.hh" ... ...
 ... ... @@ -154,53 +154,41 @@ void CahnHilliard

::fillOperators() self::prob->addMatrixOperator(*opChLM,1,1); /// < phi*grad(mu) , grad(psi) > // . . . vectorOperators . . . . . . . . . . . . . . . self::prob->addVectorOperator(*opChMold,1, self::getInvTau()); /// < phi*c^old/tau , psi > } ... ...

 ... ... @@ -66,6 +66,30 @@ namespace detail { /// Functor for generic loops. Method fillBoundaryConditions() is called for each element in a sequence. struct FillBoundaryConditions { template static void call(B& b) { b.fillBoundaryConditions(); } }; struct FindProblem { template static void call(BaseProblemType& baseProblem, const std::string& name, ProblemType& prob) { if (baseProblem.getName() == name) prob = baseProblem.getProblem(); } }; struct FindBaseProblem { template static void call(BaseProblemType& baseProblem, const std::string& name, ProblemType& prob) { typedef typename boost::mpl::if_::type, boost::mpl::int_, boost::mpl::bool_ >::type assign; call(baseProblem, name, prob, assign()); } template static void call(BaseProblemType& baseProblem, const std::string& name, BaseProblemType& prob, boost::mpl::int_) { if (baseProblem.getName() == name) prob = &baseProblem; } template static void call(BaseProblemType& baseProblem, const std::string& name, BaseProblemType& prob, boost::mpl::int_) {} }; } // end namespace detail /** ... ... @@ -156,7 +180,7 @@ public: template DOFVector *getSolution(int j) { FUNCNAME("CouplingBaseProblem::getSolution(j)"); BOOST_STATIC_ASSERT_MSG(0 <= i && i < _LENGTH_::value , "BaseProblem-index out of range"); BOOST_STATIC_ASSERT_MSG(0 <= i && i < _LENGTH_::value , "********** ERROR: BaseProblem-index out of range **********"); TEST_EXIT(0 <= j && j <= _GET_(baseProblems).getNumComponents())("Indices out of range!\n"); return _GET_(baseProblems).getSolution()->getDOFVector(j); ... ... @@ -167,7 +191,7 @@ public: template inline const FiniteElemSpace* getFeSpace(int j=0) { FUNCNAME("CouplingBaseProblem::getFeSpace(j)"); BOOST_STATIC_ASSERT_MSG(0 <= i && i < _LENGTH_::value , "BaseProblem index out of range"); BOOST_STATIC_ASSERT_MSG(0 <= i && i < _LENGTH_::value , "********** ERROR: BaseProblem index out of range **********"); TEST_EXIT(0 <= j && j <= _GET_(baseProblems).getNumComponents())("Indices out of range!\n"); return _GET_(baseProblems).getFeSpace(j); ... ... @@ -175,6 +199,28 @@ public: std::string getName() { return name; } template BaseProblemType *getBaseProblem(std::string name_) { BaseProblemType *prob = NULL; tools::FOR_EACH< detail::FindBaseProblem >::loop1(baseProblems, name_, prob); if (prob) return prob; else throw(std::runtime_error("problem with given name '" + name_ + "' does not exist")); } ProblemType *getProblem(std::string name_) { ProblemType *prob = NULL; tools::FOR_EACH< detail::FindProblem >::loop1(baseProblems, name_, prob); if (prob) return prob; else throw(std::runtime_error("problem with given name '" + name_ + "' does not exist")); } protected: BaseProblemsTupleType baseProblems; ... ...
 ... ... @@ -68,6 +68,32 @@ namespace detail { static void call(BaseProblemType& baseProblem) { baseProblem.fillBoundaryConditions(); } }; struct FindProblem { template static void call(BaseProblemType& baseProblem, const std::string& name, ProblemType& prob) { if (baseProblem.getName() == name) prob = baseProblem.getProblem(); } }; struct FindBaseProblem { template static void call(BaseProblemType& baseProblem, const std::string& name, ProblemType*& prob) { typedef typename boost::mpl::if_::type, boost::mpl::bool_, boost::mpl::bool_ >::type assign; call(baseProblem, name, prob, assign()); } template static void call(BaseProblemType& baseProblem, const std::string& name, ProblemType*& prob, boost::mpl::bool_) { if (baseProblem.getName() == name) prob = &baseProblem; } template static void call(BaseProblemType& baseProblem, const std::string& name, ProblemType*& prob, boost::mpl::bool_) {} }; } // end namespace detail /** ... ... @@ -151,7 +177,7 @@ public: template DOFVector *getSolution(int j) { FUNCNAME("CouplingBaseProblem::getSolution(j)"); BOOST_STATIC_ASSERT_MSG(0 <= i && i < _LENGTH_::value , "BaseProblem-index out of range"); BOOST_STATIC_ASSERT_MSG(0 <= i && i < _LENGTH_::value , "********** ERROR: BaseProblem-index out of range **********"); TEST_EXIT(0 <= j && j <= _GET_(baseProblems).getNumComponents())("Indices out of range!\n"); return _GET_(baseProblems).getSolution()->getDOFVector(j); ... ... @@ -162,7 +188,7 @@ public: template inline const FiniteElemSpace* getFeSpace(int j=0) { FUNCNAME("CouplingBaseProblem::getFeSpace(j)"); BOOST_STATIC_ASSERT_MSG(0 <= i && i < _LENGTH_::value , "BaseProblem index out of range"); BOOST_STATIC_ASSERT_MSG(0 <= i && i < _LENGTH_::value , "********** ERROR: BaseProblem index out of range **********"); TEST_EXIT(0 <= j && j <= _GET_(baseProblems).getNumComponents())("Indices out of range!\n"); return _GET_(baseProblems).getFeSpace(j); ... ... @@ -170,6 +196,28 @@ public: std::string getName() { return name; } ProblemType *getProblem(std::string name_) { ProblemType *prob = NULL; tools::FOR_EACH< detail::FindProblem >::loop1(baseProblems, name_, prob); if (prob) return prob; else throw(std::runtime_error("problem with given name '" + name_ + "' does not exist")); } template BaseProblemType *getBaseProblem(std::string name_) { BaseProblemType *prob = NULL; tools::FOR_EACH< detail::FindBaseProblem >::loop1(baseProblems, name_, prob); if (prob) return prob; else throw(std::runtime_error("problem with given name '" + name_ + "' does not exist")); } protected: BaseProblemsTupleType baseProblems; ... ...
 ... ... @@ -19,6 +19,7 @@ #define NAVIER_STOKES_PHASE_TAYLOR_HOOD_H #include "NavierStokes_TaylorHood.h" #include "ExtendedProblemStat.h" using namespace AMDiS; ... ... @@ -29,11 +30,11 @@ using namespace AMDiS; * dt(phase*u_j) + phase*u*grad(u_j) = phase*d_j(p) - nu*div(phase*grad(u_j)) - beta/eps^alpha (1-phase)*(u_j - g_j); j=1...d * div(phase*u) = grad(phase)*g */ class NavierStokesPhase_TaylorHood : public NavierStokes_TaylorHood class NavierStokesPhase_TaylorHood : public ::detail::NavierStokes_TaylorHood { public: // typedefs typedef NavierStokes_TaylorHood super; typedef ::detail::NavierStokes_TaylorHood super; public: // methods ... ...
 ... ... @@ -19,23 +19,28 @@ #include "NavierStokes_TaylorHood.h" namespace detail { using namespace AMDiS; /** \ingroup NavierStokes_TaylorHood * \brief * Navier-Stokes multi-phase problem, using Taylor Hood elements * Standard implementation for two phases, but can be extended to * many more, by defining the multiPhase variable and overloading * the initTimestep, where densityPhase and viscosityPhase are defined * depending on the phases */ class NavierStokes_TH_MultiPhase : public NavierStokes_TaylorHood { public: // typedefs /** \ingroup NavierStokes_TaylorHood * \brief * Navier-Stokes multi-phase problem, using Taylor Hood elements * Standard implementation for two phases, but can be extended to * many more, by defining the multiPhase variable and overloading * the initTimestep, where densityPhase and viscosityPhase are defined * depending on the phases */ template class NavierStokes_TH_MultiPhase : public NavierStokes_TaylorHood { public: // typedefs typedef NavierStokes_TaylorHood super; typedef NavierStokes_TaylorHood super; typedef NavierStokes_TH_MultiPhase self; public: // methods public: // methods NavierStokes_TH_MultiPhase(const std::string &name_, bool createProblem = true); ... ... @@ -91,7 +96,7 @@ public: // methods return density2; } protected: // variables protected: // variables ///viscosity of phase 1 double viscosity1; ... ... @@ -116,15 +121,15 @@ protected: // variables /// phase inticator DOFVector *multiPhase; }; }; /** linear interpolation between two values (like density, viscosity) /** linear interpolation between two values (like density, viscosity) * using a phase-field variable in [-1,1] **/ class LinearInterpolation1 : public AbstractFunction { public: class LinearInterpolation1 : public AbstractFunction { public: LinearInterpolation1(double c1, double c2) : AbstractFunction(1) ... ... @@ -137,16 +142,16 @@ public: return result; } private: private: double a,b,cmin,cmax; }; }; /** linear interpolation between two values (like density, viscosity) /** linear interpolation between two values (like density, viscosity) * using a phase-field variable in [0,1] **/ class LinearInterpolation0 : public AbstractFunction { public: class LinearInterpolation0 : public AbstractFunction { public: LinearInterpolation0(double val1_, double val2_) : AbstractFunction(1), ... ... @@ -156,10 +161,16 @@ public: return phase*val1 + (1.0-phase)*val2; } private: private: double val1; double val2; }; }; } #include "NavierStokes_TH_MultiPhase.hh" typedef ::detail::NavierStokes_TH_MultiPhase NavierStokes_TH_MultiPhase; #endif // NAVIER_STOKES_TAYLOR_HOOD_MULTIPHASE_H
 ... ... @@ -14,11 +14,17 @@ * See also license.opensource.txt in the distribution. * ******************************************************************************/ #include "NavierStokes_TH_MultiPhase.h" // #ifdef HAVE_PARALLEL_DOMAIN_AMDIS // #include "parallel/MeshDistributor.h" // #endif namespace detail { using namespace AMDiS; NavierStokes_TH_MultiPhase::NavierStokes_TH_MultiPhase(const std::string &name_, bool createProblem) : template NavierStokes_TH_MultiPhase

::NavierStokes_TH_MultiPhase(const std::string &name_, bool createProblem) : super(name_, createProblem), viscosity1(1.0), viscosity2(1.0), ... ... @@ -30,22 +36,23 @@ NavierStokes_TH_MultiPhase::NavierStokes_TH_MultiPhase(const std::string &name_, multiPhase(NULL) { FUNCNAME("NavierStokes_TH_MultiPhase::_constructor()"); Initfile::get(name + "->viscosity1", viscosity1); // viscosity of fluid 1 Initfile::get(name + "->viscosity2", viscosity2); // viscosity of fluid 2 Initfile::get(name + "->density1", density1); // density of fluid 1 Initfile::get(name + "->density2", density2); // density of fluid 2 Initfile::get(self::name + "->viscosity1", viscosity1); // viscosity of fluid 1 Initfile::get(self::name + "->viscosity2", viscosity2); // viscosity of fluid 2 Initfile::get(self::name + "->density1", density1); // density of fluid 1 Initfile::get(self::name + "->density2", density2); // density of fluid 2 phaseFieldType = 1; Initfile::get(name + "->phase field type", phaseFieldType); // 0: [0,1], 1: [-1,1] Initfile::get(self::name + "->phase field type", phaseFieldType); // 0: [0,1], 1: [-1,1] if (viscosity1 <= 0.0 && viscosity > 0.0) viscosity1 = viscosity; if (viscosity1 <= 0.0 && self::viscosity > 0.0) viscosity1 = self::viscosity; TEST_EXIT(viscosity1 > 0.0)("Positive viscosity is necessary!\n"); } NavierStokes_TH_MultiPhase::~NavierStokes_TH_MultiPhase() template NavierStokes_TH_MultiPhase

::~NavierStokes_TH_MultiPhase() { if (densityPhase) { delete densityPhase; ... ... @@ -58,10 +65,16 @@ NavierStokes_TH_MultiPhase::~NavierStokes_TH_MultiPhase() } void NavierStokes_TH_MultiPhase::initData() template void NavierStokes_TH_MultiPhase

::initData()