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

linear elasticity

parent 172ef97f
dimension of world: 2
elliptMesh->macro file name: ./macro/macro.big.2d
elliptMesh->macro file name: ./macro/macro.square.2d
elliptMesh->global refinements: 0
mesh->refinement->initial level: 10
......
dimension of world: 2
% ====================== VARIABLES ========================
output_folder: output
output_postfix: _plate
mesh_name: mesh
polynomial-degree: 1
% ====================== MESH =============================
mesh->H: 4.1
beam->num vertices: 4
beam->vertex[0]: [0.2, 0.2]
beam->vertex[1]: [0.8, 0.2]
beam->vertex[2]: [0.8, 0.8]
beam->vertex[3]: [0.2, 0.8]
beam->center: [0.5, 0.5]
boundary->num vertices: 8
boundary->vertex[0]: [-0.5, 1.5]
boundary->vertex[1]: [1.5, 1.5]
boundary->vertex[2]: [0.7, 0.7]
boundary->vertex[3]: [0.7, 0.3]
boundary->vertex[4]: [1.5, -0.5]
boundary->vertex[5]: [-0.5, -0.5]
boundary->vertex[6]: [0.3, 0.3]
boundary->vertex[7]: [0.3, 0.7]
boundary->factor: 0.1
mesh->refinement->initial level: 6
mesh->refinement->level on interface: 14
mesh->refinement->level in inner domain: 6
mesh->refinement->level in outer domain: 0
mesh->refinement->interface width: 0.03
mesh->refinement->fade out width: 0.03
% ====================== MESH =============================
${mesh_name}->macro file name: macro/macro.stand.2d
${mesh_name}->global refinements: 0
${mesh_name}->check: 0
% ====================== INCLUDES =========================
#include "init/linearElasticity.inc.2d"
% ====================== USER_PARAMETER - NS ==============
elasticity->mu: 1.0
elasticity->lambda: 1.0
elasticity->rho: 1.0
elasticity->epsilon: 0.05
%elasticity->force: [0.0, -0.981] % gravitational force [m/s^2]
% ====================== TIMESTEPS ========================
adapt->max iteration: 1
adapt->max timestep iteration: 1
adapt->max time iteration: 1
adapt->timestep: 1.e-3
adapt->max timestep: 1e+10
adapt->min timestep: 1e-6
adapt->start time: 0.0
adapt->end time: 0.5
% ====================== ESTIMATORS =======================
adapt->strategy: 0 % 0=explicit, 1=implicit
WAIT: 1
......@@ -12,16 +12,16 @@ element vertices:
element boundaries:
0 0 1
0 0 1
0 0 1
0 0 1
0 0 2
0 0 3
0 0 4
vertex coordinates:
-1.0 -1.0
1.0 -1.0
1.0 1.0
-1.0 1.0
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
......
#include "AMDiS.h"
#include "LinearElasticityPhase.h"
#include "navierStokes.h"
#include "Refinement.h"
#include "MeshFunction_Level.h"
#include "PhaseFieldConvert.h"
#include "Helpers.h"
#include "boost/date_time/posix_time/posix_time.hpp"
using namespace AMDiS;
using namespace boost::posix_time;
struct BoundaryStress : AbstractFunction<double, WorldVector<double> >
{
BoundaryStress(int comp_,
WorldVector<double> center_,
AbstractFunction<double, WorldVector<double> >* phaseFct_,
double factor_)
: comp(comp_),
center(center_),
phaseFct(phaseFct_),
factor(factor_) {}
double operator()(const WorldVector<double>& x) const
{
return factor*(x[comp]-center[comp])*(*phaseFct)(x);
}
private:
int comp;
WorldVector<double> center;
AbstractFunction<double, WorldVector<double> >* phaseFct;
double factor;
};
class ElasticityDemo : public LinearElasticityPhase
{
public:
typedef LinearElasticityPhase super;
public:
ElasticityDemo(std::string name_) : super(name_) {}
void initData()
{
super::initData();
phaseField = new DOFVector<double>(getFeSpace(0), "phase");
super::setPhase(phaseField);
for (int i = 0; i < dow; i++) {
boundaryDOFs[i] = new DOFVector<double>(getFeSpace(i), "boundary" + Helpers::toString(i));
}
}
void solveInitialProblem(AdaptInfo *adaptInfo)
{
super::solveInitialProblem(adaptInfo);
size_t nVertices = 0;
WorldVector<double> x;
Parameters::get("beam->num vertices",nVertices);
std::vector<WorldVector<double> > v(nVertices,x);
for (size_t i = 0; i < nVertices; i++)
Parameters::get("beam->vertex["+boost::lexical_cast<std::string>(i)+"]",v[i]);
v.push_back(v[0]);
SignedDistRefinement refFunction(getMesh());
RefinementLevelCoords2 refinement(
getFeSpace(),
&refFunction,
new Polygon(v));
// initial refinement
refinement.refine(10);
phaseField->interpol(new SignedDistFctToPhaseField(getEpsilon(), new Polygon(v), 3.0));
VtkWriter::writeFile(phaseField, "phaseField.vtu");
transformDOF(phaseField, 1.e-5, phaseField, new AMDiS::Max<double>);
nVertices = 0;
Parameters::get("boundary->num vertices",nVertices);
std::vector<WorldVector<double> > v2(nVertices,x);
for (size_t i = 0; i < nVertices; i++)
Parameters::get("boundary->vertex["+boost::lexical_cast<std::string>(i)+"]",v2[i]);
v2.push_back(v2[0]);
DOFVector<double> boundaryPhase(getFeSpace(0), "boundaryPhase");
boundaryPhase.interpol(new SignedDistFctToPhaseField(getEpsilon(), new Polygon(v2), 3.0));
VtkWriter::writeFile(&boundaryPhase, "boundaryPhase.vtu");
WorldVector<double> center; center.set(0.5);
Parameters::get("beam->center", center);
double factor = 1.0;
Parameters::get("boundary->factor", factor);
boundaryDOFs[0]->interpol(new BoundaryStress(1, center, new SignedDistFctToPhaseField(getEpsilon(), new Polygon(v2), 3.0), factor));
boundaryDOFs[1]->interpol(new BoundaryStress(0, center, new SignedDistFctToPhaseField(getEpsilon(), new Polygon(v2), -3.0), factor));
VtkWriter::writeFile(boundaryDOFs[0], "boundaryDOF0.vtu");
}
protected:
void fillBoundaryConditions()
{ FUNCNAME("NS_DrivenCavity::fillBoundaryConditions()");
for (int i = 0; i < dow; i++)
super::setBcDOF(boundaryDOFs[i],i);
super::fillBoundaryConditions();
WorldVector<double> center; center.set(0.5);
Parameters::get("beam->center", center);
AbstractFunction<double, WorldVector<double> > *zero = new AMDiS::Const<double, WorldVector<double> >(0.0);
prob->addSingularDirichletBC(center, 1, 1, *zero);
}
DOFVector<double>* phaseField;
WorldVector<DOFVector<double>*> boundaryDOFs;
};
int main(int argc, char** argv)
{ FUNCNAME("main");
AMDiS::init(argc, argv);
ElasticityDemo elastProb("elasticity");
elastProb.initialize(INIT_ALL);
// Adapt-Infos
AdaptInfo adaptInfo("adapt", elastProb.getNumComponents());
// adaption loop
AdaptInstationary adaptInstat("adapt", elastProb, adaptInfo, elastProb, adaptInfo);
ptime start_time = microsec_clock::local_time();
elastProb.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;
};
......@@ -4,6 +4,7 @@
#define NAVIER_STOKES_H
#include "AMDiS.h"
#include "Views.h"
#include "GeometryTools.h"
struct InflowBC : AbstractFunction<double, WorldVector<double> >
......
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