diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt index bc464828a87641352e10a7b96fe6c1fd604036ab..97400cf4713f3658ea6b5ec2c0cda2782c3852b2 100644 --- a/demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -10,14 +10,40 @@ if(AMDIS_FOUND) SET(BASIS_LIBS ${AMDIS_LIBRARIES}) endif(AMDIS_FOUND) -file(GLOB sources src/*.cc) -foreach(s ${sources}) - get_filename_component(swe ${s} NAME_WE) - add_executable(${swe} ${s}) - target_link_libraries(${swe} ${BASIS_LIBS}) - install(TARGETS ${swe} - RUNTIME DESTINATION bin ) -endforeach(s) + +# file(GLOB sources src/*.cc) +# foreach(s ${sources}) +# get_filename_component(swe ${s} NAME_WE) +# add_executable(${swe} ${s}) +# target_link_libraries(${swe} ${BASIS_LIBS}) +# install(TARGETS ${swe} +# RUNTIME DESTINATION bin ) +# endforeach(s) + +set(TOOLS_DIR /opt/amdis_trunk/tools) +include_directories(${TOOLS_DIR}/diffuseDomain) +include_directories(${TOOLS_DIR}/baseProblems) + +set(ch_source src/cahn_hilliard.cc + ${TOOLS_DIR}/baseProblems/CahnHilliard.cc) + +set(elliptImplicit src/elliptImplicit.cc) +set(elliptBase src/elliptBaseProblem.cc) + +set(roberto src/newmodel_s.cc) + +add_executable("cahn_hilliard" ${ch_source}) +target_link_libraries("cahn_hilliard" ${BASIS_LIBS}) + +# Problem von Robert +add_executable("roberto" ${roberto}) +target_link_libraries("roberto" ${BASIS_LIBS}) + +add_executable("elliptImplicit" ${elliptImplicit}) +target_link_libraries("elliptImplicit" ${BASIS_LIBS}) + +add_executable("elliptBase" ${elliptBase}) +target_link_libraries("elliptBase" ${BASIS_LIBS}) #create the output dir -file(MAKE_DIRECTORY output) +# file(MAKE_DIRECTORY output) \ No newline at end of file diff --git a/demo/init/ellipt.dat.2d b/demo/init/ellipt.dat.2d index 803ea0da605618ab05131da46f2d4cb4e5b8e977..e9d814c8c9e6c2a2b59016b77ebb7a16b4b531af 100644 --- a/demo/init/ellipt.dat.2d +++ b/demo/init/ellipt.dat.2d @@ -1,7 +1,7 @@ dimension of world: 2 elliptMesh->macro file name: ./macro/macro.stand.2d -elliptMesh->global refinements: 0 +elliptMesh->global refinements: 5 ellipt->mesh: elliptMesh ellipt->dim: 2 @@ -24,7 +24,7 @@ ellipt->estimator[0]->C1: 0.1 % constant of jump residual ellipt->marker[0]->strategy: 2 % 0: no adaption 1: GR 2: MS 3: ES 4:GERS ellipt->marker[0]->MSGamma: 0.5 -ellipt->adapt[0]->tolerance: 1e-4 +ellipt->adapt[0]->tolerance: 1e-6 ellipt->adapt[0]->refine bisections: 2 ellipt->adapt->max iteration: 10 diff --git a/demo/init/elliptBase.dat.2d b/demo/init/elliptBase.dat.2d new file mode 100644 index 0000000000000000000000000000000000000000..f321625790828890d58c515484f754fb54978b72 --- /dev/null +++ b/demo/init/elliptBase.dat.2d @@ -0,0 +1,35 @@ +dimension of world: 2 + +elliptMesh->macro file name: ./macro/stand.macro.2d +elliptMesh->global refinements: 5 + +ellipt->space->mesh: elliptMesh +ellipt->space->dim: 2 +ellipt->space->components: 1 +ellipt->space->polynomial degree[0]: 1 + +ellipt->space->solver: cg +ellipt->space->solver->ell: 1 +ellipt->space->solver->max iteration: 1000 +ellipt->space->solver->tolerance: 1.e-8 +ellipt->space->solver->info: 10 +ellipt->space->solver->left precon: ilu +ellipt->space->solver->right precon: no + +ellipt->space->estimator[0]: residual +ellipt->space->estimator[0]->error norm: H1_NORM % 1: H1_NORM, 2: L2_NORM +ellipt->space->estimator[0]->C0: 0.1 % constant of element residual +ellipt->space->estimator[0]->C1: 0.1 % constant of jump residual + +ellipt->space->marker[0]->strategy: 2 % 0: no adaption 1: GR 2: MS 3: ES 4:GERS +ellipt->space->marker[0]->MSGamma: 0.5 + +ellipt->adapt[0]->tolerance: 1e-6 +ellipt->adapt[0]->refine bisections: 2 + +ellipt->adapt->max iteration: 10 + +ellipt->space->output->filename: output/elliptBase.2d +ellipt->space->output->ParaView format: 1 +ellipt->space->output->ARH format: 1 +ellipt->space->output->AMDiS format: 1 diff --git a/demo/init/elliptImplicit.dat.2d b/demo/init/elliptImplicit.dat.2d new file mode 100644 index 0000000000000000000000000000000000000000..eb6b42ee80811a00f4d1cdb8255fd9597a8a62a2 --- /dev/null +++ b/demo/init/elliptImplicit.dat.2d @@ -0,0 +1,41 @@ +dimension of world: 2 + +elliptMesh->macro file name: ./macro/macro.big.2d +elliptMesh->global refinements: 0 + +mesh->refinement->initial level: 10 +mesh->refinement->level on interface: 17 +mesh->refinement->level in inner domain: 10 +mesh->refinement->level in outer domain: 0 +mesh->refinement->interface width: 0.01 + +ellipt->mesh: elliptMesh +ellipt->dim: 2 +ellipt->components: 1 +ellipt->polynomial degree[0]: 1 + +ellipt->solver: cg +ellipt->solver->ell: 1 +ellipt->solver->max iteration: 1000 +ellipt->solver->tolerance: 1.e-8 +ellipt->solver->info: 10 +ellipt->solver->left precon: ilu +ellipt->solver->right precon: no + +ellipt->estimator[0]: residual +ellipt->estimator[0]->error norm: H1_NORM % 1: H1_NORM, 2: L2_NORM +ellipt->estimator[0]->C0: 0.1 % constant of element residual +ellipt->estimator[0]->C1: 0.1 % constant of jump residual + +ellipt->marker[0]->strategy: 2 % 0: no adaption 1: GR 2: MS 3: ES 4:GERS +ellipt->marker[0]->MSGamma: 0.5 + +ellipt->adapt[0]->tolerance: 1e-6 +ellipt->adapt[0]->refine bisections: 2 + +ellipt->adapt->max iteration: 5 + +ellipt->output->filename: output/elliptImplicit.2d +ellipt->output->ParaView format: 1 +ellipt->output->ARH format: 1 +ellipt->output->AMDiS format: 1 diff --git a/demo/src/ellipt.cc b/demo/src/ellipt.cc index f735c0bd41e6a95d43010d59f9d4a656e4975e9a..4495b92a9488b40c0411c9845b13c74501d57271 100644 --- a/demo/src/ellipt.cc +++ b/demo/src/ellipt.cc @@ -1,7 +1,9 @@ #include "AMDiS.h" +#include "boost/date_time/posix_time/posix_time.hpp" + using namespace AMDiS; -using namespace std; +using namespace boost::posix_time; // =========================================================================== // ===== function definitions ================================================ @@ -57,7 +59,6 @@ int main(int argc, char* argv[]) // === create adapt === AdaptStationary adapt("ellipt->adapt", ellipt, adaptInfo); - // ===== create matrix operator ===== Operator matrixOperator(ellipt.getFeSpace()); @@ -70,14 +71,17 @@ int main(int argc, char* argv[]) Operator rhsOperator(ellipt.getFeSpace()); rhsOperator.addZeroOrderTerm(new CoordsAtQP_ZOT(new F(degree))); ellipt.addVectorOperator(rhsOperator, 0); - - + // ===== add boundary conditions ===== ellipt.addDirichletBC(1, 0, 0, new G); // ===== start adaption loop ===== + ptime start_time= microsec_clock::local_time(); adapt.adapt(); + time_duration td= microsec_clock::local_time()-start_time; + + MSG("elapsed time= %f msec\n", td.total_milliseconds()/1000.0); ellipt.writeFiles(adaptInfo, true); diff --git a/demo/src/elliptBaseProblem.cc b/demo/src/elliptBaseProblem.cc new file mode 100644 index 0000000000000000000000000000000000000000..1b1ce2632c58665e735f62f7d068dff758ce1ef1 --- /dev/null +++ b/demo/src/elliptBaseProblem.cc @@ -0,0 +1,107 @@ +#include "AMDiS.h" +#include "BaseProblem.h" + +#include "boost/date_time/posix_time/posix_time.hpp" + +using namespace AMDiS; +using namespace boost::posix_time; + +// =========================================================================== +// ===== function definitions ================================================ +// =========================================================================== + +/// Dirichlet boundary function +class G : public AbstractFunction<double, WorldVector<double> > +{ +public: + + /// Implementation of AbstractFunction::operator(). + double operator()(const WorldVector<double>& x) const + { + return exp(-10.0 * (x * x)); + } +}; + +/// RHS function +class F : public AbstractFunction<double, WorldVector<double> > +{ +public: + + F(int degree) : AbstractFunction<double, WorldVector<double> >(degree) {} + + /// Implementation of AbstractFunction::operator(). + double operator()(const WorldVector<double>& x) const + { + int dow = Global::getGeo(WORLD); + double r2 = (x * x); + double ux = exp(-10.0 * r2); + return -(400.0 * r2 - 20.0 * dow) * ux; + } +}; + +class ElliptBase : public StandardBaseProblem +{ +public: + typedef StandardBaseProblem super; + +public: + ElliptBase(std::string name_) : super(name_) {} + +protected: + void fillOperators() + { + // ===== create matrix operator ===== + Operator *matrixOperator = new Operator(getFeSpace()); + matrixOperator->addSecondOrderTerm(new Simple_SOT); + prob->addMatrixOperator(matrixOperator, 0, 0); + + + // ===== create rhs operator ===== + int degree = getFeSpace()->getBasisFcts()->getDegree(); + Operator *rhsOperator = new Operator(getFeSpace()); + rhsOperator->addZeroOrderTerm(new CoordsAtQP_ZOT(new F(degree))); + prob->addVectorOperator(rhsOperator, 0); + } + + void fillBoundaryCondition() + { + // ===== add boundary conditions ===== + prob->addDirichletBC(1, 0, 0, new G); + } +}; + +// =========================================================================== +// ===== main program ======================================================== +// =========================================================================== + +int main(int argc, char* argv[]) +{ + FUNCNAME("main"); + + AMDiS::init(argc, argv); + + // ===== create and init the scalar problem ===== + ElliptBase ellipt("ellipt"); + ellipt.initialize(INIT_ALL); + + + // === create adapt info === + AdaptInfo adaptInfo("ellipt->adapt", ellipt.getNumComponents()); + + + // === create adapt === + AdaptStationary adapt("ellipt->adapt", ellipt, adaptInfo); + + + // ===== start adaption loop ===== + ptime start_time= microsec_clock::local_time(); + ellipt.initTimeInterface(); // fillOperators() and fillBoundaryCondition() + adapt.adapt(); + time_duration td= microsec_clock::local_time()-start_time; + + MSG("elapsed time= %f msec\n", td.total_milliseconds()/1000.0); + + ellipt.writeFiles(&adaptInfo, true); + + AMDiS::finalize(); +} diff --git a/demo/src/elliptImplicit.cc b/demo/src/elliptImplicit.cc new file mode 100644 index 0000000000000000000000000000000000000000..aefb47bee4831b71991c1f7e56d4e58fcb7b15c2 --- /dev/null +++ b/demo/src/elliptImplicit.cc @@ -0,0 +1,99 @@ +#include "AMDiS.h" +#include "SignedDistFunctors.h" +#include "ExtendedProblemStat.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; + +/** + * solve poisson-equation in domain defined by signed-dist function, using + * dirichlet boundary condition on the implicit boundary (zero level set of + * signed-dist function) and an algebraic equation in the outer domain (sign + * of the signed-dist function poisitive). + **/ + + +// =========================================================================== +// ===== function definitions ================================================ +// =========================================================================== + +/// Dirichlet boundary function +class G : public AbstractFunction<double, WorldVector<double> > +{ +public: + + /// Implementation of AbstractFunction::operator(). + double operator()(const WorldVector<double>& x) const + { + return 0.0; + } +}; + +// =========================================================================== +// ===== main program ======================================================== +// =========================================================================== + +int main(int argc, char* argv[]) +{ + FUNCNAME("main"); + + AMDiS::init(argc, argv); + + // ===== create and init the scalar problem ===== + ExtendedProblemStat ellipt("ellipt"); + ellipt.initialize(INIT_ALL); + + + // === create adapt info === + AdaptInfo adaptInfo("ellipt->adapt", ellipt.getNumComponents()); + + // === create adapt === + AdaptStationary adapt("ellipt->adapt", ellipt, adaptInfo); + + // ===== signedDist function that describes the geometry ===== + AbstractFunction<double, WorldVector<double> > *signedDistFct = new InverseCircle(1.0); + + // ===== refine mesh at interface ===== + SignedDistRefinement refFunction(ellipt.getMesh()); + RefinementLevelCoords2 refinement( + ellipt.getFeSpace(), + &refFunction, + signedDistFct); + refinement.refine(9); + + // ===== create matrix operator ===== + Operator matrixOperator(ellipt.getFeSpace()); + matrixOperator.addSecondOrderTerm(new Simple_SOT); + ellipt.addMatrixOperator(matrixOperator, 0, 0); + + // ===== create rhs operator ===== + Operator rhsOperator(ellipt.getFeSpace()); + rhsOperator.addZeroOrderTerm(new Simple_ZOT(1.0)); + ellipt.addVectorOperator(rhsOperator, 0); + + // ===== add boundary conditions ===== + DOFVector<double> G_dof(ellipt.getFeSpace(), "G"); + G_dof.interpol(new G); + + DOFVector<double> signedDist_dof(ellipt.getFeSpace(), "signedDist"); + signedDist_dof.interpol(signedDistFct); + + ellipt.addImplicitDirichletBC(signedDist_dof, 0, 0, G_dof); + + // ===== start adaption loop ===== + ptime start_time= microsec_clock::local_time(); + adapt.adapt(); + time_duration td= microsec_clock::local_time()-start_time; + + MSG("elapsed time= %f msec\n", td.total_milliseconds()/1000.0); + + ellipt.writeFiles(adaptInfo, true); + + AMDiS::finalize(); +} + +