Commit c4f06a52 authored by Praetorius, Simon's avatar Praetorius, Simon

extensions demos

parent c396867c
dimension of world: 2
% ====================== VARIABLES ========================
output_folder: output
output_postfix: _drivenCavity
mesh_name: mesh
polynomial-degree: 1
% ====================== MESH =============================
mesh->refinement->epsilon: 0.01
% local refinement at cahn-hilliard interface
mesh->refinement->initial level: 10
mesh->refinement->level in inner domain: 8
mesh->refinement->level in outer domain: 8
mesh->refinement->level on interface: 16
mesh->min outer interface value: 0.05
mesh->max outer interface value: 0.95
% ====================== MESH =============================
${mesh_name}->macro file name: macro/macro.drivenCavity.2d
${mesh_name}->global refinements: 0
${mesh_name}->check: 0
% ====================== INCLUDES =========================
#include "init/reinit.inc.2d"
% ============= PROBLEM-SPACES ==================================
chns->space->components: 5
chns->space->polynomial degree[0]: ${polynomial-degree}
chns->space->polynomial degree[1]: ${polynomial-degree}
chns->space->polynomial degree[2]: ${polynomial-degree}+1
chns->space->polynomial degree[3]: ${polynomial-degree}+1
chns->space->polynomial degree[4]: ${polynomial-degree}
chns->space->dim: 2
chns->space->mesh: ${mesh_name}
% ================== SOLVER ======================================
chns->space->solver: umfpack
chns->space->solver->symmetric strategy: 0
chns->space->solver->ell: 3
chns->space->solver->max iteration: 500
chns->space->solver->restart: 10 % only used for GMRES
chns->space->solver->tolerance: 1.e-8
chns->space->solver->info: 1
chns->space->solver->left precon: ilu
% ====================== USER-PARAMETER - CH ==============
chns->initial interface: 0
chns->line->pos: 0.5
chns->initial epsilon: ${mesh->refinement->epsilon}
chns->epsilon: ${mesh->refinement->epsilon}
chns->gamma: 1 %0.001
chns->use mobility: 0
chns->double-well type: 1 % c in [-1,1]
chns->viscosity: 0.002
%chns->force: [0.0, 9.81] % gravitational force [m/s^2]
chns->laplace operator: 0 % 0... div(nu*grad(u)), 1... div(0.5*nu*(grad(u)+grad(u)^T)) [sehr langsam]
chns->non-linear term: 2 % 0... u^old*grad(u_i^old), 1... u'*grad(u_i^old), 2... u^old*grad(u'_i)
% ====================== USER_PARAMETER - COUPLING ==============
chns->sigma: 0.0 % surface tension
chns->use conservation form: 0
% ====================== TIMESTEPS ========================
adapt->max iteration: 1
adapt->max timestep iteration: 1
adapt->max time iteration: 1
adapt->timestep: 2e-3
adapt->max timestep: 1e+10
adapt->min timestep: 1e-6
adapt->start time: 0.0
adapt->end time: 10
% =========== OUTPUT ==============================================
chns->velocity->output->filename: ${output_folder}/velocity${output_postfix}_
chns->space->output[0]->filename: ${output_folder}/concentration${output_postfix}_
chns->space->output[4]->filename: ${output_folder}/pressure${output_postfix}_
chns->velocity->output->ParaView animation: 1
chns->velocity->output->ParaView vector format: 1
chns->velocity->output->write vector as 3d vector: 1
chns->velocity->output->write every i-th timestep: 1
%chns->velocity->output->compression: gzip
chns->velocity->output->append index: 1
chns->velocity->output->index length: 9
chns->velocity->output->index decimals: 7
chns->space->output[0]->ParaView animation: 1
chns->space->output[0]->ParaView format: 1
chns->space->output[0]->write every i-th timestep: 1
%chns->space->output[0]->compression: gzip
chns->space->output[0]->append index: 1
chns->space->output[0]->index length: 9
chns->space->output[0]->index decimals: 7
chns->space->output[4]->ParaView animation: 0
chns->space->output[4]->ParaView format: 0
chns->space->output[4]->write every i-th timestep: 1
%chns->space->output[4]->compression: gzip
chns->space->output[4]->append index: 1
chns->space->output[4]->index length: 9
chns->space->output[4]->index decimals: 7
% ====================== ESTIMATORS =======================
adapt->strategy: 0 % 0=explicit, 1=implicit
WAIT: 1
DIM: 2
DIM_OF_WORLD: 2
number of elements: 4
number of vertices: 5
element vertices:
0 1 4
1 2 4
2 3 4
3 0 4
element boundaries:
0 0 1
0 0 1
0 0 2
0 0 1
vertex coordinates:
0.0 0.0
1.0 0.0
1.0 1.0
0.0 1.0
0.5 0.5
element neighbours:
1 3 -1
2 0 -1
3 1 -1
0 2 -1
\ No newline at end of file
#include "AMDiS.h"
#include "CahnHilliardNavierStokes.h"
#include "SignedDistFunctors.h"
#include "PhaseFieldConvert.h"
#include "Refinement.h"
#include "MeshFunction_Level.h"
#include "boost/date_time/posix_time/posix_time.hpp"
using namespace AMDiS;
using namespace boost::posix_time;
struct DrivenCavityBC : AbstractFunction<double, WorldVector<double> >
{
double operator()(const WorldVector<double> &x) const {
return std::max(0.0, 1.0 - 4.0 * sqr(x[0] - 0.5));
}
};
class CHNS_DrivenCavity : public CahnHilliardNavierStokes
{
public:
CHNS_DrivenCavity(std::string name_) : CahnHilliardNavierStokes(name_) {}
void solveInitialProblem(AdaptInfo* adaptInfo)
{
super::solveInitialProblem(adaptInfo);
/// horizontale Linie
double a= 0.0, dir= -1.0;
double initialEps = eps;
Initfile::get(name + "->initial epsilon", initialEps);
Initfile::get(name + "->line->pos", a);
Initfile::get(name + "->line->direction", dir);
/// create phase-field from signed-dist-function
if (doubleWell == 0) {
prob->getSolution()->getDOFVector(0)->interpol(new SignedDistFctToPhaseField(initialEps, new Plane(a, dir)));
} else {
prob->getSolution()->getDOFVector(0)->interpol(new Plane(a, dir));
transformDOF(prob->getSolution()->getDOFVector(0),
new SignedDistToCh(initialEps));
}
}
void fillBoundaryConditions()
{ FUNCNAME("NS_DrivenCavity::fillBoundaryConditions()");
DOFVector<double> *zeroDOF = new DOFVector<double>(getFeSpace(0), "zero");
zeroDOF->set(0.0);
size_t dow = Global::getGeo(WORLD);
/// at rigid wall: no-slip boundary condition
for (size_t i = 0; i < dow; i++)
getProblem(0)->addDirichletBC(1, 2+i, 2+i, zeroDOF);
/// at upper wall: prescribed velocity
getProblem(0)->addDirichletBC(2, 2, 2, new DrivenCavityBC);
getProblem(0)->addDirichletBC(2, 3, 3, zeroDOF);
}
};
class RefinementTimeInterface : public CouplingTimeInterface
{
public:
RefinementTimeInterface(CHNS_DrivenCavity *chnsProb_) :
chnsProb(chnsProb_),
refFunction(NULL),
refinement(NULL)
{
addTimeInterface(chnsProb);
}
~RefinementTimeInterface()
{
if (refFunction)
delete refFunction;
if (refinement)
delete refinement;
}
virtual void initTimeInterface()
{
chnsProb->initTimeInterface();
}
/// Called at the end of each timestep.
virtual void closeTimestep(AdaptInfo *adaptInfo)
{
CouplingTimeInterface::closeTimestep(adaptInfo);
refinement->refine(1);
}
/// Set initial condition and perform initial refinement
virtual void solveInitialProblem(AdaptInfo *adaptInfo)
{
refFunction= new PhaseFieldRefinement("mesh->refinement",chnsProb->getMesh());
refinement= new RefinementLevelDOF(
chnsProb->getProblem(0)->getFeSpace(0),
refFunction,
new PhaseDOFView<double>(chnsProb->getProblem(0)->getSolution()->getDOFVector(0)));
// initial refinement
refinement->refine(0);
bool initialRefinement = true;
Parameters::get(chnsProb->getName() + "->initial refinement", initialRefinement);
if (initialRefinement) {
// refine until interfaces is solved
for (int i = 0; i < 3; ++i) {
chnsProb->solveInitialProblem(adaptInfo);
refinement->refine((i < 4 ? 4 : 10));
}
}
CouplingTimeInterface::solveInitialProblem(adaptInfo);
}
protected:
CHNS_DrivenCavity *chnsProb;
PhaseFieldRefinement* refFunction;
RefinementLevelDOF *refinement;
};
int main(int argc, char** argv)
{ FUNCNAME("main");
AMDiS::init(argc, argv);
CHNS_DrivenCavity chnsProb("chns");
chnsProb.initialize(INIT_ALL);
RefinementTimeInterface timeInterface(&chnsProb);
// Adapt-Infos
AdaptInfo adaptInfo("adapt", chnsProb.getNumComponents());
AdaptInstationary adaptInstat("adapt", chnsProb, adaptInfo, timeInterface, adaptInfo);
ptime start_time = microsec_clock::local_time();
chnsProb.initTimeInterface();
int error_code = adaptInstat.adapt();
time_duration td = microsec_clock::local_time()-start_time;
MSG("elapsed time= %d sec\n", td.total_seconds());
AMDiS::finalize();
return error_code;
};
#include "AMDiS.h"
#include "ExtendedProblemStat.h"
#include "MeshFunction_Level.h"
#include "Refinement.h"
#include "SignedDistFunctors.h"
#include "boost/date_time/posix_time/posix_time.hpp"
using namespace AMDiS;
using namespace boost::posix_time;
int main(int argc, char** argv)
{ FUNCNAME("main");
AMDiS::init(argc, argv);
ptime start_time = microsec_clock::local_time();
// initialize the problem
// ======================
ExtendedProblemStat prob("prob");
prob.initialize(INIT_ALL);
// refine the mesh
// ===============
double radius = 0.3;
WorldVector<double> center; center.set(0.5);
Parameters::get("refinement->radius", radius);
Parameters::get("refinement->center", center);
SignedDistRefinement refFunction("refinement", prob.getMesh());
RefinementLevelCoords2 refinement(prob.getFeSpace(), &refFunction,
new Circle(radius, center));
// initial refinement
// ==================
refinement.refine(10);
// Adapt-Infos
AdaptInfo adaptInfo("adapt", prob.getNumComponents());
prob.writeFiles(adaptInfo, false);
time_duration td = microsec_clock::local_time()-start_time;
MSG("elapsed time = %f sec\n", td.total_milliseconds()/1000.0);
AMDiS::finalize();
return 1;
};
#include "AMDiS.h"
#include "ExtendedProblemStat.h"
#include "MeshFunction_Level.h"
#include "Refinement.h"
#include "SignedDistFunctors.h"
#include "boost/date_time/posix_time/posix_time.hpp"
using namespace AMDiS;
using namespace boost::posix_time;
int main(int argc, char** argv)
{ FUNCNAME("main");
AMDiS::init(argc, argv);
ptime start_time = microsec_clock::local_time();
// initialize the problem
// ======================
ExtendedProblemStat prob("prob");
prob.initialize(INIT_ALL);
// refine the mesh
// ===============
int nPoints = 1;
Parameters::get("refinement->num points", nPoints);
WorldVector<double> point;
std::vector<WorldVector<double> > points(nPoints);
for (size_t i = 0; i < nPoints; i++)
Parameters::get("refinement->point["+boost::lexical_cast<std::string>(i)+"]", points[i]);
double radius = 0.1;
Parameters::get("refinement->radius", radius);
CoordsRefinement refFunction("refinement", prob.getMesh(), points, radius);
RefinementLevelCoords refinement(prob.getFeSpace(), &refFunction);
// initial refinement
// ==================
refinement.refine(10);
// Adapt-Infos
AdaptInfo adaptInfo("adapt", prob.getNumComponents());
prob.writeFiles(adaptInfo, false);
time_duration td = microsec_clock::local_time()-start_time;
MSG("elapsed time = %f sec\n", td.total_milliseconds()/1000.0);
AMDiS::finalize();
return 1;
};
Markdown is supported
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