elliptImplicit.cc 2.93 KB
 Praetorius, Simon committed Mar 20, 2012 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 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 > { public: /// Implementation of AbstractFunction::operator(). double operator()(const WorldVector& 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 > *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 G_dof(ellipt.getFeSpace(), "G"); G_dof.interpol(new G); DOFVector 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(); } ``````