Esempio n. 1
0
int main(int argc, char *argv[])
{
    
    InitializePZLOG();
    gRefDBase.InitializeUniformRefPattern(EOned);
    gRefDBase.InitializeUniformRefPattern(EQuadrilateral);
    gRefDBase.InitializeUniformRefPattern(ETriangle);
    
    ofstream saidaerros("ErroMDP.txt");
    saidaerros << "\nCalculo do Erro\n";
    int h= 0;
    int p=0, pr;
    
    int dim = 1;
    fc = 0.1;
    fk = 0.0001;
    saidaerros.precision(8);
    
    for(p=1; p<2; p++)
    {
        pr = p+3;
        saidaerros << "\n";
        saidaerros << "Ordens p = " << p << " and Ordens pr = " << pr <<"\n";
        for(h=7; h<8; h++)
        {
            saidaerros << "\nRefinamento: h = "<< h <<"\n";
            
            //if(dim>1){
            //TPZAutoPointer<TPZGeoMesh> gmesh;
             TPZGeoMesh *gmesh;
            if(dim>1){
                gmesh = MalhaGeom(1.,1.,false);
                TPZVec<int> dims(dim,dim);
                if(dim>1) dims[0]=1;
                int nref = h;
                RefinamentoUniforme(gmesh, nref, dims);
            }else
                gmesh = MalhaGeom1D(3.,h);
            
            ofstream arg("gmesh.txt");
            gmesh->Print(arg);
            
            TPZCompMesh * cmesh1;
            TPZCompMesh * cmesh2;
            if(dim>1){
                cmesh1 = CompMesh(gmesh,pr);
                cmesh2 = CompMesh(gmesh,p);
            }else{
                cmesh1 = CompMesh1D(gmesh,pr);
                cmesh2 = CompMesh1D(gmesh,p);
            }
            
            // Criando a malha computacional multifísica
            //malha multifisica
            TPZVec<TPZCompMesh *> meshvec(2);
            meshvec[0] = cmesh1;
            meshvec[1] = cmesh2;
            TPZCompMesh * mphysics;
            if(dim>1){
                mphysics = MalhaMDP(meshvec,gmesh);
            }else
                mphysics = MalhaMDP1D(meshvec,gmesh);

            //analysis
            TPZAnalysis an(mphysics,false);
            TPZStepSolver<STATE> step;
            //TPZBandStructMatrix bst(mphysics);
            //TPZFStructMatrix bst(mphysics);
            TPZSkylineNSymStructMatrix bst(mphysics);
            an.SetStructuralMatrix(bst);
            //bst.SetNumThreads(8);
            step.SetDirect(ELU);
            an.SetSolver(step);
            an.Assemble();
            an.Solve();
            
            TPZBuildMultiphysicsMesh::TransferFromMultiPhysics(meshvec, mphysics);
            
            std::string plotfile("result.vtk");
            TPZStack<std::string> scalnames,vecnames;
            scalnames.Push("Solution");
            scalnames.Push("ExactSolution");
            scalnames.Push("OptimalTestFunction");
            an.DefineGraphMesh(mphysics->Dimension(), scalnames, vecnames, plotfile);
            an.PostProcess(0,dim);
            
            saidaerros<<"\n\nErro da simulacao MDP  para a pressao";
//            TPZVec<REAL> erros(3);
//            TPZAnalysis an2(cmesh2);
//            an2.SetExact(*SolSuave);
//            an2.PostProcessError(erros, saidaerros);
            ErrorH1(cmesh2, saidaerros);
            
            mphysics->CleanUp();
            gmesh->CleanUp();
            delete mphysics;
        }
    }
    
    return EXIT_SUCCESS;
}
Esempio n. 2
0
int mainfem(int argc, char *argv[])
{
    //InitializePZLOG();
    gRefDBase.InitializeUniformRefPattern(EOned);
    gRefDBase.InitializeUniformRefPattern(EQuadrilateral);
    gRefDBase.InitializeUniformRefPattern(ETriangle);
    
    ofstream saidaerros("ErroProjecaoSemiH1.txt");
    saidaerros << "\nCalculo do Erro\n";
    int h= 0;
    int p=0;
    
    saidaerros.precision(16);
    
    for(p=1; p<5; p++)
    {
        saidaerros << "\n";
        saidaerros << "Ordens p = " << p <<"\n";
        for(h=0; h<6; h++)
        {
            saidaerros << "\nRefinamento: h = "<< h <<"\n";
            
            //TPZGeoMesh * gmesh = MalhaGeom(1.,1.,false);
            TPZAutoPointer<TPZGeoMesh> gmesh = MalhaGeom(1.,1.,false);
            TPZVec<int> dims(2,0);
            dims[0]=1; dims[1]=2;
            int nref = h;
            RefinamentoUniforme(gmesh, nref, dims);
            
            
            TPZCompMesh * cmesh = CompMesh(gmesh.operator->(),p);
            
            //analysis
            TPZAnalysis an(cmesh,false);
            TPZSkylineStructMatrix skyl(cmesh);
            an.SetStructuralMatrix(skyl);
            TPZStepSolver<STATE> step;
            step.SetDirect(ELDLt);
            an.SetSolver(step);
            an.Assemble();
            an.Solve();
            
//            std::string plotfile("result.vtk");
//            TPZStack<std::string> scalnames,vecnames;
//            scalnames.Push("Solution");
//            scalnames.Push("ExactPressure");
//            an.DefineGraphMesh(cmesh->Dimension(), scalnames, vecnames, plotfile);
//            an.PostProcess(0,2);
            
 //           TPZVec<REAL> erros(3);
//            an.SetExact(*SolSuave);
//            an.PostProcessError(erros,saidaerros);
            ErrorH1(cmesh, saidaerros);
            
            cmesh->CleanUp();
            gmesh->CleanUp();
            delete cmesh;
        }
    }
    
    return EXIT_SUCCESS;
}