00001 #include "poissonfem.h"
00002 #include "assemblyorthomeshsystem.h"
00003 #include "hdf5orthowriter.h"
00004 #include "gnuplotanim.h"
00005 #include "fconst3d.h"
00006 #include "assemblyorthomeshsystemII.h"
00007 #include "varform.h"
00008 #include <fstream>
00009
00010
00011 PoissonFEM::PoissonFEM(OrthoMesh &mesh, VecDouble &cK, Function3D &fD, Function3D &fN,LinearSolver &solver, unsigned debugLevel)
00012 :m_mesh(mesh), m_cK(cK),m_eqvar(ff),m_solver(solver),m_debugLevel(debugLevel), m_fN(fN)
00013 {
00014 m_eqvar.reinit(mesh);
00015 m_eqvar.setParameters(cK);
00016 AssemblyOrthoMeshSystemII<VarFormPoisson> ass;
00017 std::cout << "Resp 2: " << ass.max_nz_per_row(m_eqvar) << std::endl;
00018 unsigned rank = ass.global_system_rank(m_eqvar);
00019 std::cout << "Resp 1: " << rank << std::endl;
00020
00021
00022 ass.buildSparsityPattern(m_sparsity,m_eqvar);
00023 m_M.reinit(m_sparsity);
00024 m_vRHS.reinit(rank);
00025 m_sol.reinit(rank);
00026
00027
00028
00029
00030 ass.setBoundaryValue(m_mesh,m_eqvar,fD,m_dirichlet_bc);
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 }
00045
00046
00047 void PoissonFEM::iterate(TransportBase &trans)
00048 {
00049
00050 printf("Building system\n");
00051 AssemblyOrthoMeshSystemII<VarFormPoisson> assembler;
00052 assembler.buildGlobalMatrix(m_M, m_eqvar);
00053 assembler.buildGlobalRHS(m_vRHS,m_eqvar);
00054
00055 assembler.addNeumannCondition(m_vRHS,m_eqvar,m_fN);
00056
00057 m_vRHS.print(std::cout);
00058 assembler.applyBoundaryValue(m_dirichlet_bc,m_vRHS);
00059 assembler.applyBoundaryValue(m_dirichlet_bc,m_M);
00060
00061
00062 printf("Solving\n");
00063 m_solver.solve(m_M,m_sol,m_vRHS);
00064 printf("done");
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 }
00081
00082
00083
00084 void PoissonFEM::printOutput()
00085 {
00086 AssemblyOrthoMeshSystemII<VarFormPoisson> assembler;
00087 VecDouble dofSol(m_sol.size());
00088 assembler.getDOFSolAtVertices(dofSol,m_sol,m_eqvar);
00089 HDF5OrthoWriter &hdf5 = HDF5OrthoWriter::getHDF5OrthoWriter();
00090 hdf5.writeScalarField(dofSol,"P");
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 }
00110
00111
00112 void PoissonFEM::getVelocitiesAtFaces(Matrix& M)
00113 {
00114 throw new Exception("PoissonFEM::getVelocitiesAtFaces Not implemented yet\n");
00115 }