diff --git a/README.md b/README.md index 68dc8d70e..936fa056e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,62 @@ FEMuS ====== -Multiphysics Finite Element Multigrid Solver with selective mesh refinement. +Welcome to the FEMuS project! FEMuS is an opensource Finite Element C++ library +built on top of Petsc which allows scientists to build and solve multiphysics +problems with multigrid and domain decomposition techniques. -![alt tag](https://github.com/FeMTTU/femus/blob/master/doc/images/logo.jpg?raw=true) -![alt tag](https://github.com/FeMTTU/femus/blob/master/doc/images/FSI.jpg?raw=true) -======= + + + +Setup +===== + + +Clone the FEMuS source code from the github repository: + + + git clone https://github.com/FeMTTU/femus.git + + +Install petsc and libmesh in some common directory "my_external_directory" (please put it outside of the femus repo directory). +If they are not installed already, the script "install_external.sh" in contrib/scripts/ will do it automatically, with the following syntax: + + + ./femus/contrib/scripts/install_external.sh --prefix-external my_external_directory ) + + +Source the "configure_femus.sh" script and execute the function "fm_set_femus" in order to set some environment variables: + + + source femus/contrib/scripts/configure_femus.sh + + fm_set_femus --prefix-external my_external_directory --method-petsc [opt,dbg] --method-libmesh [opt,dbg] + + +Create the build directory, cd to it and run cmake: + + mkdir femus.build + + cd femus.build + + cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="[Debug Release RelWithDebInfo MinSizeRel None]" -DLIBMESH_DIR=my_libmesh_directory ../femus + + + +Authors +======== + +Eugenio Aulisa + +Simone Bnà + +Giorgio Bornia + + + +License +======== + +Femus is an open-source software distributed under the LGPL license, version 2.1 + diff --git a/applications/FSI/FSISteadyStateBenchmarks/main.cpp b/applications/FSI/FSISteadyStateBenchmarks/main.cpp index 5a639b801..e4ec22b46 100644 --- a/applications/FSI/FSISteadyStateBenchmarks/main.cpp +++ b/applications/FSI/FSISteadyStateBenchmarks/main.cpp @@ -15,19 +15,17 @@ double scale=1000.; using namespace std; using namespace femus; -void AssembleMatrixResFSI(MultiLevelProblem &ml_prob, unsigned level, const unsigned &gridn, const bool &assemble_matrix); - -bool SetBoundaryConditionTurek(const double &x, const double &y, const double &z,const char name[], - double &value, const int FaceName, const double = 0.); -bool SetBoundaryConditionDrum(const double &x, const double &y, const double &z,const char name[], - double &value, const int FaceName, const double = 0.); -bool SetBoundaryConditionBatheCylinder(const double &x, const double &y, const double &z,const char name[], - double &value, const int facename, const double time); - -bool SetBoundaryConditionBatheShell(const double &x, const double &y, const double &z,const char name[], - double &value, const int facename, const double time); -bool SetBoundaryConditionComsol(const double &x, const double &y, const double &z,const char name[], - double &value, const int FaceName, const double = 0.); +bool SetBoundaryConditionTurek_2D_FSI_and_solid(const double &x, const double &y, const double &z,const char name[], + double &value, const int FaceName, const double = 0.); +bool SetBoundaryConditionBathe_2D_FSI(const double &x, const double &y, const double &z,const char name[], + double &value, const int FaceName, const double = 0.); +bool SetBoundaryConditionBathe_3D_FSI_and_fluid(const double &x, const double &y, const double &z,const char name[], + double &value, const int facename, const double time); + +bool SetBoundaryConditionBathe_3D_solid(const double &x, const double &y, const double &z,const char name[], + double &value, const int facename, const double time); +bool SetBoundaryConditionComsol_2D_FSI(const double &x, const double &y, const double &z,const char name[], + double &value, const int FaceName, const double = 0.); bool SetRefinementFlag(const double &x, const double &y, const double &z, const int &ElemGroupNumber,const int &level); @@ -36,13 +34,14 @@ bool SetRefinementFlag(const double &x, const double &y, const double &z, const int main(int argc,char **args) { - /// Init Petsc-MPI communicator + // ******* Init Petsc-MPI communicator ******* FemusInit mpinit(argc,args,MPI_COMM_WORLD); - Files files; - files.CheckIODirectories(); - files.RedirectCout(); + //Files files; + //files.CheckIODirectories(); + //files.RedirectCout(); + // ******* Extract the problem dimension and simulation identifier based on the inline input ******* unsigned simulation; bool dimension2D; @@ -54,12 +53,12 @@ int main(int argc,char **args) { else if( !strcmp("turek_2D_solid",args[1])) { /** Solid Turek beam benchmark test. Beware: activate gravity in assembly */ simulation=2; dimension2D=1; - } + } else if( !strcmp("bathe_2D_FSI",args[1])){ /** Bathe 2D membrane benchmark */ simulation=3; dimension2D=1; - } - else if( !strcmp("bathe_3D_FSI",args[1])){ /** Bathe 3D cylinder FSI benchmark */ + } + else if( !strcmp("bathe_3D_FSI",args[1])){ /** Bathe 3D cylinder FSI benchmark */ simulation=4; dimension2D=0; } @@ -90,7 +89,7 @@ int main(int argc,char **args) { abort(); } - + // ******* Extract the preconditioner type based on the inline input ******* bool Vanka=0, Gmres=0, Asm=0; if(argc >= 3) { if( !strcmp("vanka",args[2])) Vanka=1; @@ -99,7 +98,7 @@ int main(int argc,char **args) { if(Vanka+Gmres+Asm==0) { cout << "wrong input arguments!" << endl; - exit(0); + abort(); } } else { @@ -108,26 +107,7 @@ int main(int argc,char **args) { } - - - unsigned short nm,nr; - std::cout<<"#MULTIGRID levels? (>=1) \n"; - //std::cin>>nm; - if(simulation < 3) - nm=3; - else if(simulation == 3 || simulation == 7) - nm=4; - else if(simulation < 7) - nm=2; - - - std::cout<<"#MAX_REFINEMENT levels? (>=0) \n"; - //std::cin>>nr; - nr=0; - int tmp=nm; - nm+=nr; - nr=tmp; - + // ******* Extract the mesh.neu file name based on the simulation identifier ******* std::string infile; if(1 == simulation){ @@ -152,26 +132,28 @@ int main(int argc,char **args) { infile = "./input/comsolbenchmark.neu"; } - double Lref, Uref, rhof, muf, rhos, ni, E; + + // ******* Set physics parameters ******* + double Lref, Uref, rhof, muf, rhos, ni, E; - Lref = 1.; - Uref = 1.; + Lref = 1.; + Uref = 1.; - if(simulation<3){ //turek FSI + if(simulation<3){ //turek 2D rhof = 1000.; muf = 1.; rhos = 1000; ni = 0.5; E = 1400000; } - else if(simulation==3){ //bathe membrane + else if(simulation==3){ //bathe 2D rhof = 1000; muf = 0.04; rhos = 800; ni = 0.5; E = 140000000; } - else if(simulation<7){ //bathe cylinder + else if(simulation<7){ //bathe 3D rhof = 100.; muf = 1.; rhos = 800; @@ -190,26 +172,8 @@ int main(int argc,char **args) { // Generate Solid Object Solid solid; - if(simulation<3){ - solid = Solid(par,E,ni,rhos,"Mooney-Rivlin-MassPenalty"); - //solid = Solid(par,E,ni,rhos,"Neo-Hookean-BW-MassPenalty"); - //solid = Solid(par,E,ni,rhos,"Neo-Hookean-BW-Penalty"); - } - else if(simulation==3 || simulation == 7){ - solid = Solid(par,E,ni,rhos,"Mooney-Rivlin"); - //solid = Solid(par,E,ni,rhos,"Neo-Hookean-BW-MassPenalty"); - //solid = Solid(par,E,ni,rhos,"Neo-Hookean-BW-Penalty"); - } - else if(simulation < 7){ - solid = Solid(par,E,ni,rhos,"Mooney-Rivlin"); - //solid = Solid(par,E,ni,rhos,"Neo-Hookean"); - //Solid solid(par,E,ni,rhos,"Neo-Hookean-BW"); - //solid = Solid(par,E,ni,rhos,"Neo-Hookean-BW-Penalty"); - //solid = Solid(par,E,ni,rhos,"Neo-Hookean-AB-Penalty"); //Allan Bower + solid = Solid(par,E,ni,rhos,"Mooney-Rivlin"); - } - - cout << "Solid properties: " << endl; cout << solid << endl; @@ -218,40 +182,61 @@ int main(int argc,char **args) { cout << "Fluid properties: " << endl; cout << fluid << endl; - MultiLevelMesh ml_msh(nm,nr,infile.c_str(),"fifth",Lref,SetRefinementFlag); + // ******* Init multilevel mesh from mesh.neu file ******* + unsigned short numberOfUniformRefinedMeshes, numberOfAMRLevels; + if(simulation < 3) + numberOfUniformRefinedMeshes=3; + else if(simulation == 3 || simulation == 7) + numberOfUniformRefinedMeshes=4; + else if(simulation < 7) + numberOfUniformRefinedMeshes=2; + + numberOfAMRLevels = 0; + + MultiLevelMesh ml_msh(numberOfUniformRefinedMeshes, numberOfUniformRefinedMeshes + numberOfAMRLevels, + infile.c_str(),"fifth",Lref,SetRefinementFlag); + + // mark Solid nodes + ml_msh.MarkStructureNode(); + + // ******* Init multilevel solution ****** MultiLevelSolution ml_sol(&ml_msh); - //Start System Variables + // ******* Add solution variables to multilevel solution and pair them ******* ml_sol.AddSolution("DX",LAGRANGE,SECOND,1); ml_sol.AddSolution("DY",LAGRANGE,SECOND,1); if (!dimension2D) ml_sol.AddSolution("DZ",LAGRANGE,SECOND,1); - ml_sol.AssociatePropertyToSolution("DX","Displacement"); // Add this line - ml_sol.AssociatePropertyToSolution("DY","Displacement"); // Add this line - if (!dimension2D) ml_sol.AssociatePropertyToSolution("DZ","Displacement"); // Add this line + ml_sol.AddSolution("U",LAGRANGE,SECOND,1); ml_sol.AddSolution("V",LAGRANGE,SECOND,1); if (!dimension2D) ml_sol.AddSolution("W",LAGRANGE,SECOND,1); + + // Pair each velocity varible with the corresponding displacement variable + ml_sol.PairSolution("U","DX"); // Add this line + ml_sol.PairSolution("V","DY"); // Add this line + if (!dimension2D) ml_sol.PairSolution("W","DZ"); // Add this line + // Since the Pressure is a Lagrange multiplier it is used as an implicit variable ml_sol.AddSolution("P",DISCONTINOUS_POLYNOMIAL,FIRST,1); - //ml_sol.AddSolution("P",LAGRANGE,FIRST,1); ml_sol.AssociatePropertyToSolution("P","Pressure"); // Add this line - //Initialize (update Init(...) function) + // ******* Initialize solution ******* ml_sol.Initialize("All"); - //Set Boundary (update Dirichlet(...) function) + // ******* Set boundary functions ******* if(1==simulation || 2==simulation) - ml_sol.AttachSetBoundaryConditionFunction(SetBoundaryConditionTurek); + ml_sol.AttachSetBoundaryConditionFunction(SetBoundaryConditionTurek_2D_FSI_and_solid); else if( 3==simulation) - ml_sol.AttachSetBoundaryConditionFunction(SetBoundaryConditionDrum); + ml_sol.AttachSetBoundaryConditionFunction(SetBoundaryConditionBathe_2D_FSI); else if (4==simulation || 6==simulation) - ml_sol.AttachSetBoundaryConditionFunction(SetBoundaryConditionBatheCylinder); + ml_sol.AttachSetBoundaryConditionFunction(SetBoundaryConditionBathe_3D_FSI_and_fluid); else if (5==simulation) - ml_sol.AttachSetBoundaryConditionFunction(SetBoundaryConditionBatheShell); + ml_sol.AttachSetBoundaryConditionFunction(SetBoundaryConditionBathe_3D_solid); else if (7 == simulation) - ml_sol.AttachSetBoundaryConditionFunction(SetBoundaryConditionComsol); + ml_sol.AttachSetBoundaryConditionFunction(SetBoundaryConditionComsol_2D_FSI); + // ******* Set boundary conditions ******* ml_sol.GenerateBdc("DX","Steady"); ml_sol.GenerateBdc("DY","Steady"); if (!dimension2D) ml_sol.GenerateBdc("DZ","Steady"); @@ -260,16 +245,15 @@ int main(int argc,char **args) { if (!dimension2D) ml_sol.GenerateBdc("W","Steady"); ml_sol.GenerateBdc("P","Steady"); + // ******* Define the FSI Multilevel Problem ******* MultiLevelProblem ml_prob(&ml_sol); // Add fluid object ml_prob.parameters.set("Fluid") = fluid; // Add Solid Object ml_prob.parameters.set("Solid") = solid; - // mark Solid nodes - ml_msh.MarkStructureNode(); + - //create systems - // add the system FSI to the MultiLevel problem + // ******* Add FSI system to the MultiLevel problem ******* MonolithicFSINonLinearImplicitSystem & system = ml_prob.add_system ("Fluid-Structure-Interaction"); system.AddSolutionToSystemPDE("DX"); system.AddSolutionToSystemPDE("DY"); @@ -278,98 +262,70 @@ int main(int argc,char **args) { system.AddSolutionToSystemPDE("V"); if (!dimension2D) system.AddSolutionToSystemPDE("W"); system.AddSolutionToSystemPDE("P"); - -// if(dimension2D){ -// bool sparsity_pattern_matrix[5][5]={{1, 0, 1, 0, 0}, -// {0, 1, 0, 1, 0}, -// {1, 1, 1, 1, 1}, -// {1, 1, 1, 1, 1}, -// {1, 1, 0, 0, 1}}; -// vector < bool > sparsity_pattern (sparsity_pattern_matrix[0],sparsity_pattern_matrix[0]+25*sizeof(bool)); -// system.SetSparsityPattern(sparsity_pattern); -// } -// else{ -// bool sparsity_pattern_matrix[7][7]={{1, 0, 0, 1, 0, 0, 0}, -// {0, 1, 0, 0, 1, 0, 0}, -// {0, 0, 1, 0, 0, 1, 0}, -// {1, 1, 1, 1, 1, 1, 1}, -// {1, 1, 1, 1, 1, 1, 1}, -// {1, 1, 1, 1, 1, 1, 1}, -// {1, 1, 1, 0, 0, 0, 1}}; -// vector < bool > sparsity_pattern (sparsity_pattern_matrix[0],sparsity_pattern_matrix[0]+49*sizeof(bool)); -// system.SetSparsityPattern(sparsity_pattern); -// } - // System Fluid-Structure-Interaction - system.SetAssembleFunction(IncompressibleFSIAssemblyAD_DD); - //system.SetAssembleFunction(AssembleMatrixResFSI); + // ******* System Fluid-Structure-Interaction Assembly ******* + system.SetAssembleFunction(IncompressibleFSIAssemblyAD_DD); + // ******* set MG-Solver ******* system.SetMgType(F_CYCLE); system.SetAbsoluteConvergenceTolerance(1.e-10); system.SetNonLinearConvergenceTolerance(1.e-10); + if( simulation == 7 ) + system.SetNonLinearConvergenceTolerance(1.e-5); system.SetNumberPreSmoothingStep(1); system.SetNumberPostSmoothingStep(1); - if(simulation < 3 || simulation == 7){ + if( simulation < 3 || simulation == 7 ) { system.SetMaxNumberOfLinearIterations(2); system.SetMaxNumberOfNonLinearIterations(10); } - else if(simulation < 7){ + else { system.SetMaxNumberOfLinearIterations(8); system.SetMaxNumberOfNonLinearIterations(15); } - - if(simulation == 7) system.SetNonLinearConvergenceTolerance(1.e-5); - - - //Set Smoother Options + + // ******* Set Preconditioner ******* if(Gmres) system.SetMgSmoother(GMRES_SMOOTHER); else if(Asm) system.SetMgSmoother(ASM_SMOOTHER); else if(Vanka) system.SetMgSmoother(VANKA_SMOOTHER); - // init all the systems system.init(); + // ******* Set Smoother ******* system.SetSolverFineGrids(GMRES); - if(3 >= simulation || 6 == simulation || 7 == simulation ) + if( simulation < 3 || simulation > 5 ) system.SetPreconditionerFineGrids(ILU_PRECOND); else system.SetPreconditionerFineGrids(MLU_PRECOND); - system.SetTolerances(1.e-12,1.e-20,1.e+50,20); + // ******* Add variables to be solved ******* system.ClearVariablesToBeSolved(); system.AddVariableToBeSolved("All"); - system.AddVariableToBeSolved("DX"); - system.AddVariableToBeSolved("DY"); - if (!dimension2D) system.AddVariableToBeSolved("DZ"); - - system.AddVariableToBeSolved("U"); - system.AddVariableToBeSolved("V"); - if (!dimension2D) system.AddVariableToBeSolved("W"); - system.AddVariableToBeSolved("P"); - - //for Vanka and ASM smoothers + // ******* Set the last (1) variables in system (i.e. P) to be a schur variable ******* system.SetNumberOfSchurVariables(1); + + // ******* Set block size for the ASM smoothers ******* if(simulation < 3){ system.SetElementBlockNumber(2); } - else if(simulation ==3 || !dimension2D){ - //system.SetElementBlockNumber("All"); - //system.SetElementBlockNumber(2); + else if(simulation < 7 ){ system.SetElementBlockNumberFluid(2); - //system.SetElementBlockNumberSolid(2); - //system.SetElementBlockFluidAll(); system.SetElementBlockSolidAll(); } else if(simulation == 7 ){ - system.SetElementBlockNumber(3); + system.SetElementBlockNumber(3); } - //for Gmres smoother - //system.SetDirichletBCsHandling(PENALTY); + // ******* For Gmres Preconditioner only ******* system.SetDirichletBCsHandling(ELIMINATION); + // ******* Solve ******* + std::cout << std::endl; + std::cout << " *********** Fluid-Structure-Interaction ************ " << std::endl; + system.solve(); + + // ******* Print solution ******* ml_sol.SetWriter(VTK); std::vector mov_vars; @@ -378,26 +334,14 @@ int main(int argc,char **args) { mov_vars.push_back("DZ"); ml_sol.GetWriter()->SetMovingMesh(mov_vars); - // Solving Fluid-Structure-Interaction system - std::cout << std::endl; - std::cout << " *********** Fluid-Structure-Interaction ************ " << std::endl; - system.solve(); - - //print solution std::vector print_vars; - print_vars.push_back("DX"); - print_vars.push_back("DY"); - if (!dimension2D) print_vars.push_back("DZ"); - print_vars.push_back("U"); - print_vars.push_back("V"); - if (!dimension2D) print_vars.push_back("W"); - print_vars.push_back("P"); + print_vars.push_back("All"); - ml_sol.GetWriter()->write_system_solutions(files.GetOutputPath(),"biquadratic",print_vars); - - // Destroy all the new systems + //ml_sol.GetWriter()->ParallelWrite(DEFAULT_OUTPUTDIR,"biquadratic",print_vars); + ml_sol.GetWriter()->write(DEFAULT_OUTPUTDIR,"biquadratic",print_vars); + + // ******* Clear all systems ******* ml_prob.clear(); - return 0; } @@ -416,7 +360,7 @@ bool SetRefinementFlag(const double &x, const double &y, const double &z, const //--------------------------------------------------------------------------------------------------------------------- -bool SetBoundaryConditionTurek(const double &x, const double &y, const double &z,const char name[], double &value, const int facename, const double time) { +bool SetBoundaryConditionTurek_2D_FSI_and_solid(const double &x, const double &y, const double &z,const char name[], double &value, const int facename, const double time) { bool test=1; //dirichlet value=0.; if(!strcmp(name,"U")) { @@ -426,9 +370,9 @@ bool SetBoundaryConditionTurek(const double &x, const double &y, const double &z value=1.5*um*4.0/0.1681*y*(0.41-y); } else if(2==facename ){ //outflow - test=0; - // test=1; - value=0.; + test=0; + // test=1; + value=0.; } else if(3==facename ){ // no-slip fluid wall test=1; @@ -449,9 +393,9 @@ bool SetBoundaryConditionTurek(const double &x, const double &y, const double &z value=0.; } else if(2==facename ){ //outflow - test=0; - // test=1; - value=0.; + test=0; + // test=1; + value=0.; } else if(3==facename ){ // no-slip fluid wall test=1; @@ -494,8 +438,8 @@ bool SetBoundaryConditionTurek(const double &x, const double &y, const double &z value=0.; } else if(2==facename ){ //outflow - test=1; - value=0.; + test=1; + value=0.; } else if(3==facename ){ // no-slip fluid wall test=0; //0 @@ -516,8 +460,8 @@ bool SetBoundaryConditionTurek(const double &x, const double &y, const double &z value=0.; } else if(2==facename ){ //outflow - test=0; // 0 - value=0.; + test=0; // 0 + value=0.; } else if(3==facename ){ // no-slip fluid wall test=1; @@ -535,7 +479,7 @@ bool SetBoundaryConditionTurek(const double &x, const double &y, const double &z return test; } -bool SetBoundaryConditionDrum(const double &x, const double &y, const double &z,const char name[], double &value, const int facename, const double time) { +bool SetBoundaryConditionBathe_2D_FSI(const double &x, const double &y, const double &z,const char name[], double &value, const int facename, const double time) { bool test=1; //dirichlet value=0.; if(!strcmp(name,"U")) { @@ -544,8 +488,8 @@ bool SetBoundaryConditionDrum(const double &x, const double &y, const double &z, value=0; } else if(2==facename ){ //top side - test=0; - value=0.; + test=0; + value=0.; } else if(3==facename ){ //top bottom test=1; @@ -565,13 +509,13 @@ bool SetBoundaryConditionDrum(const double &x, const double &y, const double &z, } } else if(!strcmp(name,"V")){ - if(1==facename){ //top + if(1==facename){ //top test=0; value=0; } else if(2==facename ){ //top side - test=0; - value=0.; + test=0; + value=0.; } else if(3==facename ){ //top bottom test=1; @@ -602,8 +546,8 @@ bool SetBoundaryConditionDrum(const double &x, const double &y, const double &z, value=0; } else if(2==facename ){ //top side - test=1; - value=0.; + test=1; + value=0.; } else if(3==facename ){ //top bottom test=0; @@ -623,13 +567,13 @@ bool SetBoundaryConditionDrum(const double &x, const double &y, const double &z, } } else if(!strcmp(name,"DY")){ - if(1==facename){ //top + if(1==facename){ //top test=1; value=0; } else if(2==facename ){ //top side - test=0; - value=0.; + test=0; + value=0.; } else if(3==facename ){ //top bottom test=1; @@ -654,7 +598,7 @@ bool SetBoundaryConditionDrum(const double &x, const double &y, const double &z, -bool SetBoundaryConditionBatheCylinder(const double &x, const double &y, const double &z,const char name[], double &value, const int facename, const double time) { +bool SetBoundaryConditionBathe_3D_FSI_and_fluid(const double &x, const double &y, const double &z,const char name[], double &value, const int facename, const double time) { bool test=1; //dirichlet value=0.; @@ -734,7 +678,7 @@ bool SetBoundaryConditionBatheCylinder(const double &x, const double &y, const d } } else if(!strcmp(name,"DX")){ - if(1==facename){ //outflow + if(1==facename){ //outflow test=1; value=0; } @@ -791,7 +735,7 @@ bool SetBoundaryConditionBatheCylinder(const double &x, const double &y, const d return test; } -bool SetBoundaryConditionBatheShell(const double &x, const double &y, const double &z,const char name[], double &value, const int facename, const double time) { +bool SetBoundaryConditionBathe_3D_solid(const double &x, const double &y, const double &z,const char name[], double &value, const int facename, const double time) { bool test=1; //dirichlet value=0.; @@ -852,7 +796,7 @@ bool SetBoundaryConditionBatheShell(const double &x, const double &y, const doub } } else if(!strcmp(name,"DX")){ - if(2==facename){ //stress + if(2==facename){ //stress test=0; value=0; } @@ -901,7 +845,7 @@ bool SetBoundaryConditionBatheShell(const double &x, const double &y, const doub //--------------------------------------------------------------------------------------------------------------------- -bool SetBoundaryConditionComsol(const double &x, const double &y, const double &z,const char name[], double &value, const int FaceName, const double time) { +bool SetBoundaryConditionComsol_2D_FSI(const double &x, const double &y, const double &z,const char name[], double &value, const int FaceName, const double time) { bool test=1; //Dirichlet value=0.; // cout << "Time bdc : " << time << endl; @@ -1035,18 +979,6 @@ bool SetBoundaryConditionComsol(const double &x, const double &y, const double & value=0.; } } - else if (!strcmp(name,"AX")) { - test=0; - value=0; - } - else if (!strcmp(name,"AY")) { - test=0; - value=0; - } - else if (!strcmp(name,"AZ")) { - test=0; - value=0; - } return test; } diff --git a/applications/FSI/FSITimeDependentBenchmarks/main.cpp b/applications/FSI/FSITimeDependentBenchmarks/main.cpp index a66e91bba..5ca9ae6f4 100644 --- a/applications/FSI/FSITimeDependentBenchmarks/main.cpp +++ b/applications/FSI/FSITimeDependentBenchmarks/main.cpp @@ -97,10 +97,14 @@ int main(int argc,char **args) { //Start System Variables ml_sol.AddSolution("DX",LAGRANGE,SECOND,1); ml_sol.AddSolution("DY",LAGRANGE,SECOND,1); - ml_sol.AssociatePropertyToSolution("DX","Displacement"); // Add this line - ml_sol.AssociatePropertyToSolution("DY","Displacement"); // Add this line +// ml_sol.AssociatePropertyToSolution("DX","Displacement"); // Add this line +// ml_sol.AssociatePropertyToSolution("DY","Displacement"); // Add this line ml_sol.AddSolution("U",LAGRANGE,SECOND,1); ml_sol.AddSolution("V",LAGRANGE,SECOND,1); + +// ml_sol.PairSolution("U","DX"); // Add this line +// ml_sol.PairSolution("V","DY"); // Add this line + // Since the Pressure is a Lagrange multiplier it is used as an implicit variable ml_sol.AddSolution("P",DISCONTINOUS_POLYNOMIAL,FIRST,1); ml_sol.AssociatePropertyToSolution("P","Pressure"); // Add this line @@ -208,7 +212,7 @@ int main(int argc,char **args) { std::vector mov_vars; mov_vars.push_back("DX"); mov_vars.push_back("DY"); - VTKWriter vtkio(ml_sol); + VTKWriter vtkio(&ml_sol); vtkio.SetMovingMesh(mov_vars); // Solving Fluid-Structure-Interaction system @@ -224,7 +228,7 @@ int main(int argc,char **args) { print_vars.push_back("V"); print_vars.push_back("P"); - vtkio.write_system_solutions(files.GetOutputPath(),"biquadratic",print_vars); + vtkio.write(files.GetOutputPath(),"biquadratic",print_vars); // Destroy all the new systems ml_prob.clear(); @@ -410,7 +414,7 @@ int main(int argc,char **args) { // print_vars.push_back("P"); // // // ml_probl.printsol_vtu_inline("biquadratic",print_vars,time_step); -// vtkio.write_system_solutions("biquadratic",print_vars,time_step); +// vtkio.write("biquadratic",print_vars,time_step); // } // // } //end loop timestep @@ -761,7 +765,7 @@ void AssembleMatrixResFSI(NonLinearMultiLevelProblem &nl_td_ml_prob2, unsigned l // mesh and procs unsigned nel = mymsh->GetElementNumber(); - unsigned igrid = mymsh->GetGridNumber(); + unsigned igrid = mymsh->GetLevel(); unsigned iproc = mymsh->GetProcID(); unsigned nprocs = mymsh->GetNumProcs(); @@ -1636,7 +1640,7 @@ void AssembleMatrixResFSI(MultiLevelProblem &ml_prob, unsigned level, const unsi // mesh and procs unsigned nel = mymsh->GetElementNumber(); - unsigned igrid = mymsh->GetGridNumber(); + unsigned igrid = mymsh->GetLevel(); unsigned iproc = mymsh->processor_id(); //---------------------------------------------------------------------------------- diff --git a/applications/FSI/FSI_TUREK_3/main.cpp b/applications/FSI/FSI_TUREK_3/main.cpp index a1aec14b5..de6b6fdc3 100644 --- a/applications/FSI/FSI_TUREK_3/main.cpp +++ b/applications/FSI/FSI_TUREK_3/main.cpp @@ -62,10 +62,14 @@ int main(int argc,char **args) { //Start System Variables ml_sol.AddSolution("DX",LAGRANGE,SECOND,2); ml_sol.AddSolution("DY",LAGRANGE,SECOND,2); - ml_sol.AssociatePropertyToSolution("DX","Displacement"); // Add this line - ml_sol.AssociatePropertyToSolution("DY","Displacement"); // Add this line +// ml_sol.AssociatePropertyToSolution("DX","Displacement"); // Add this line +// ml_sol.AssociatePropertyToSolution("DY","Displacement"); // Add this line ml_sol.AddSolution("U",LAGRANGE,SECOND,2); ml_sol.AddSolution("V",LAGRANGE,SECOND,2); + + // ml_sol.PairSolution("U","DX"); // Add this line + // ml_sol.PairSolution("V","DY"); // Add this line + ml_sol.AddSolution("AX",LAGRANGE,SECOND,1,0); ml_sol.AddSolution("AY",LAGRANGE,SECOND,1,0); // Since the Pressure is a Lagrange multiplier it is used as an implicit variable @@ -140,7 +144,7 @@ int main(int argc,char **args) { std::vector mov_vars; mov_vars.push_back("DX"); mov_vars.push_back("DY"); - VTKWriter vtkio(ml_sol); + VTKWriter vtkio(&ml_sol); vtkio.SetMovingMesh(mov_vars); for (unsigned time_step = 0; time_step < n_timesteps; time_step++) { @@ -168,7 +172,7 @@ int main(int argc,char **args) { print_vars.push_back("P"); // ml_prob.printsol_vtu_inline("biquadratic",print_vars,time_step); - vtkio.write_system_solutions(files.GetOutputPath(),"biquadratic",print_vars,time_step); + vtkio.write(files.GetOutputPath(),"biquadratic",print_vars,time_step); } } //end loop timestep diff --git a/applications/FSI/fsi_porous/main.cpp b/applications/FSI/fsi_porous/main.cpp index 97d38951f..335725af1 100644 --- a/applications/FSI/fsi_porous/main.cpp +++ b/applications/FSI/fsi_porous/main.cpp @@ -374,7 +374,7 @@ int AssembleMatrixResP(MultiLevelProblem &mg2, unsigned level, /*const elem_type // // // double geom_el_coords[SPACEDIM][MAX_EL_NODES]; // // // elem* myel = lsyspdemesh_lev->el; // // // unsigned nel = lsyspdemesh_lev->GetElementNumber(); -// // // unsigned igrid = lsyspdemesh_lev->GetGridNumber(); +// // // unsigned igrid = lsyspdemesh_lev->GetLevel(); // // // // // // // variables // // // PetscInt nodeP[MAX_EL_NODES]; @@ -546,7 +546,7 @@ int AssembleMatrixResP(MultiLevelProblem &mg2, unsigned level, /*const elem_type // // // // ***************** END ASSEMBLY ******************* // // // // // // // *** Computational info *** -// // // // cout<<"Grid="<< lsyspdemesh_lev->GetGridNumber()<GetDimension(); unsigned nel= mymsh->GetNumberOfElements(); - unsigned igrid= mymsh->GetGridNumber(); + unsigned igrid= mymsh->GetLevel(); unsigned iproc = mymsh->processor_id(); double ILambda = 0.; double IRe = ml_prob.parameters.get("Fluid").get_IReynolds_number(); diff --git a/applications/NavierStokes/NavierStokesTemp_AMR/main.cpp b/applications/NavierStokes/NavierStokesTemp_AMR/main.cpp index 7492b8af0..98b2ea358 100644 --- a/applications/NavierStokes/NavierStokesTemp_AMR/main.cpp +++ b/applications/NavierStokes/NavierStokesTemp_AMR/main.cpp @@ -259,8 +259,8 @@ int main(int argc,char **args) { print_vars.push_back("P"); print_vars.push_back("T"); - GMVWriter gmvio(ml_sol); - gmvio.write_system_solutions(files.GetOutputPath(),"biquadratic",print_vars); + GMVWriter gmvio(&ml_sol); + gmvio.write(files.GetOutputPath(),"biquadratic",print_vars); @@ -423,7 +423,7 @@ void AssembleMatrixResNS(MultiLevelProblem &ml_prob, unsigned level, const unsig //data const unsigned dim = mymsh->GetDimension(); unsigned nel= mymsh->GetNumberOfElements(); - unsigned igrid= mymsh->GetGridNumber(); + unsigned igrid= mymsh->GetLevel(); unsigned iproc = mymsh->processor_id(); double ILambda= 0; double IRe = ml_prob.parameters.get("Fluid").get_IReynolds_number(); @@ -744,7 +744,7 @@ void AssembleMatrixResT(MultiLevelProblem &ml_prob, unsigned level, const unsign //data const unsigned dim = mymsh->GetDimension(); unsigned nel = mymsh->GetNumberOfElements(); - unsigned igrid = mymsh->GetGridNumber(); + unsigned igrid = mymsh->GetLevel(); unsigned iproc = mymsh->processor_id(); double IPe = 1./(ml_prob.parameters.get("Fluid").get_Peclet_number()); diff --git a/applications/NavierStokes/SteadyNavierStokesParallel/main.cpp b/applications/NavierStokes/SteadyNavierStokesParallel/main.cpp index 40e545844..364f7ed30 100644 --- a/applications/NavierStokes/SteadyNavierStokesParallel/main.cpp +++ b/applications/NavierStokes/SteadyNavierStokesParallel/main.cpp @@ -231,16 +231,16 @@ int main(int argc,char **args) { print_vars.push_back("P"); print_vars.push_back("T"); - VTKWriter vtkio(ml_sol); - vtkio.write_system_solutions(files.GetOutputPath(),"biquadratic",print_vars); - //vtkio.write_system_solutions(DEFAULT_OUTPUTDIR,"biquadratic",print_vars); + VTKWriter vtkio(&ml_sol); + vtkio.write(files.GetOutputPath(),"biquadratic",print_vars); + //vtkio.write(DEFAULT_OUTPUTDIR,"biquadratic",print_vars); - GMVWriter gmvio(ml_sol); - gmvio.write_system_solutions(DEFAULT_OUTPUTDIR,"biquadratic",print_vars); - // gmvio.write_system_solutions(files.GetOutputPath(),"biquadratic",print_vars); + GMVWriter gmvio(&ml_sol); + gmvio.write(DEFAULT_OUTPUTDIR,"biquadratic",print_vars); + // gmvio.write(files.GetOutputPath(),"biquadratic",print_vars); // XDMFWriter xdmfio(ml_sol); - // xdmfio.write_system_solutions(files.GetOutputPath(),"biquadratic",print_vars); + // xdmfio.write(files.GetOutputPath(),"biquadratic",print_vars); //Destroy all the new systems ml_prob.clear(); @@ -511,7 +511,7 @@ void AssembleMatrixResNS(MultiLevelProblem &ml_prob, unsigned level, const unsig // mesh and procs unsigned nel = mymsh->GetNumberOfElements(); - unsigned igrid = mymsh->GetGridNumber(); + unsigned igrid = mymsh->GetLevel(); unsigned iproc = mymsh->processor_id(); //---------------------------------------------------------------------------------- @@ -1304,7 +1304,7 @@ void AssembleMatrixResT(MultiLevelProblem &ml_prob, unsigned level, const unsign //data const unsigned dim = mymsh->GetDimension(); unsigned nel = mymsh->GetNumberOfElements(); - unsigned igrid = mymsh->GetGridNumber(); + unsigned igrid = mymsh->GetLevel(); unsigned iproc = mymsh->processor_id(); double IPe = 1./(ml_prob.parameters.get("Fluid").get_Peclet_number()); diff --git a/applications/NavierStokes/SteadyStokes/main.cpp b/applications/NavierStokes/SteadyStokes/main.cpp index 4256aff45..526a28005 100644 --- a/applications/NavierStokes/SteadyStokes/main.cpp +++ b/applications/NavierStokes/SteadyStokes/main.cpp @@ -174,14 +174,14 @@ int main(int argc,char **args) { print_vars.push_back("P"); - VTKWriter vtkio(ml_sol); - vtkio.write_system_solutions(files.GetOutputPath(),"biquadratic",print_vars); + VTKWriter vtkio(&ml_sol); + vtkio.write(files.GetOutputPath(),"biquadratic",print_vars); // XDMFWriter xdmfio(ml_prob); -// xdmfio.write_system_solutions("biquadratic",print_vars); +// xdmfio.write("biquadratic",print_vars); // GMVWriter gmvio(ml_sol); -// gmvio.write_system_solutions("biquadratic",print_vars); +// gmvio.write("biquadratic",print_vars); //Destroy all the new systems ml_prob.clear(); @@ -324,7 +324,7 @@ void AssembleMatrixResSteadyStokes(MultiLevelProblem &ml_prob, unsigned level, c //data const unsigned dim = mymsh->GetDimension(); unsigned nel= mymsh->GetNumberOfElements(); - unsigned igrid= mymsh->GetGridNumber(); + unsigned igrid= mymsh->GetLevel(); unsigned iproc = mymsh->processor_id(); double ILambda= 0; double IRe = ml_prob.parameters.get("Fluid").get_IReynolds_number(); diff --git a/applications/NavierStokes/TaylorGreenVortexFlowGeneralisedalpha/main.cpp b/applications/NavierStokes/TaylorGreenVortexFlowGeneralisedalpha/main.cpp index 14ee09e9e..888253a1c 100644 --- a/applications/NavierStokes/TaylorGreenVortexFlowGeneralisedalpha/main.cpp +++ b/applications/NavierStokes/TaylorGreenVortexFlowGeneralisedalpha/main.cpp @@ -123,7 +123,7 @@ int main(int argc,char **args) { const unsigned int n_timesteps = 5; const unsigned int write_interval = 1; - VTKWriter vtkio(ml_sol); + VTKWriter vtkio(&ml_sol); for (unsigned time_step = 0; time_step < n_timesteps; time_step++) { @@ -150,7 +150,7 @@ int main(int argc,char **args) { print_vars.push_back("AY"); // ml_prob.printsol_vtu_inline("biquadratic",print_vars,time_step); - vtkio.write_system_solutions(files.GetOutputPath(),"biquadratic",print_vars,time_step); + vtkio.write(files.GetOutputPath(),"biquadratic",print_vars,time_step); } } //end loop timestep @@ -238,7 +238,7 @@ void AssembleMatrixResNS(MultiLevelProblem &ml_prob, unsigned level, const unsig double theta = 0.5; const unsigned dim = mymsh->GetDimension(); unsigned nel= mymsh->GetNumberOfElements(); - unsigned igrid= mymsh->GetGridNumber(); + unsigned igrid= mymsh->GetLevel(); unsigned iproc = mymsh->processor_id(); double ILambda = 0.; double IRe = ml_prob.parameters.get("Fluid").get_IReynolds_number(); diff --git a/applications/NumPdeSpring2015/Bhagya/CMakeLists.txt b/applications/NumPdeSpring2015/Bhagya/CMakeLists.txt index 482fcd056..93239845e 100644 --- a/applications/NumPdeSpring2015/Bhagya/CMakeLists.txt +++ b/applications/NumPdeSpring2015/Bhagya/CMakeLists.txt @@ -6,4 +6,7 @@ ADD_SUBDIRECTORY(${EXAMPLE_NUMBER}) set(EXAMPLE_NUMBER Ex2) ADD_SUBDIRECTORY(${EXAMPLE_NUMBER}) +set(EXAMPLE_NUMBER Ex3) +ADD_SUBDIRECTORY(${EXAMPLE_NUMBER}) + unset(EXAMPLE_NUMBER) diff --git a/applications/NumPdeSpring2015/Bhagya/Ex1/Ex1.cpp b/applications/NumPdeSpring2015/Bhagya/Ex1/Ex1.cpp index 0c5eaf37d..04b5866c5 100644 --- a/applications/NumPdeSpring2015/Bhagya/Ex1/Ex1.cpp +++ b/applications/NumPdeSpring2015/Bhagya/Ex1/Ex1.cpp @@ -69,13 +69,13 @@ int main(int argc, char **args) { variablesToBePrinted.push_back("P"); variablesToBePrinted.push_back("T"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); + GMVWriter gmvIO(&mlSol); variablesToBePrinted.push_back("all"); gmvIO.SetDebugOutput(false); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); return 0; } diff --git a/applications/NumPdeSpring2015/Bhagya/Ex2/Ex2.cpp b/applications/NumPdeSpring2015/Bhagya/Ex2/Ex2.cpp index ac0b0e406..641dd6216 100644 --- a/applications/NumPdeSpring2015/Bhagya/Ex2/Ex2.cpp +++ b/applications/NumPdeSpring2015/Bhagya/Ex2/Ex2.cpp @@ -25,71 +25,128 @@ bool SetBoundaryCondition(const double &x, const double &y, const double &z,cons void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix); +double GetErrorNorm(MultiLevelSolution *mlSol); int main(int argc, char **args) { // init Petsc-MPI communicator FemusInit mpinit(argc, args, MPI_COMM_WORLD); - - // define multilevel mesh + + + // define multilevel mesh MultiLevelMesh mlMsh; // read coarse level mesh and generate finers level meshes double scalingFactor=1.; - mlMsh.ReadCoarseMesh("./input/square.neu","seventh",scalingFactor); + mlMsh.ReadCoarseMesh("./input/square_tri.neu","seventh",scalingFactor); /* "seventh" is the order of accuracy that is used in the gauss integration scheme - probably in the furure it is not going to be an argument of this function */ - unsigned numberOfUniformLevels=2; - unsigned numberOfSelectiveLevels=0; - mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL); + probably in the furure it is not going to be an argument of this function */ - // erase all the coarse mesh levels - mlMsh.EraseCoarseLevels(numberOfUniformLevels-1); + unsigned maxNumberOfMeshes = 5; + vector < vector < double > > semiNorm; + semiNorm.resize(maxNumberOfMeshes); - // print mesh info - mlMsh.PrintInfo(); + for(unsigned i = 0; i < maxNumberOfMeshes; i++){ // loop on the mesh level + + unsigned numberOfUniformLevels = i+1; + unsigned numberOfSelectiveLevels = 0; + mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL); - // define the multilevel solution and attach the mlMsh object to it - MultiLevelSolution mlSol(&mlMsh); + // erase all the coarse mesh levels + mlMsh.EraseCoarseLevels(numberOfUniformLevels-1); - // add variables to mlSol - mlSol.AddSolution("u",LAGRANGE, FIRST); - mlSol.Initialize("All"); + // print mesh info + mlMsh.PrintInfo(); - // attach the boundary condition function and generate boundary data - mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition); - mlSol.GenerateBdc("u"); + FEOrder feOrder[3] = {FIRST, SERENDIPITY, SECOND}; + semiNorm[i].resize(3); + + for(unsigned j=0; j<3; j++){ // loop on the FE Order + // define the multilevel solution and attach the mlMsh object to it + MultiLevelSolution mlSol(&mlMsh); + + // add variables to mlSol + mlSol.AddSolution("u",LAGRANGE, feOrder[j]); + mlSol.Initialize("All"); - // define the multilevel problem attach the mlSol object to it - MultiLevelProblem mlProb(&mlSol); + // attach the boundary condition function and generate boundary data + mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition); + mlSol.GenerateBdc("u"); - // add system Poisson in mlProb as a Linear Implicit System - LinearImplicitSystem & system = mlProb.add_system < LinearImplicitSystem > ("Poisson"); + // define the multilevel problem attach the mlSol object to it + MultiLevelProblem mlProb(&mlSol); + + // add system Poisson in mlProb as a Linear Implicit System + LinearImplicitSystem & system = mlProb.add_system < LinearImplicitSystem > ("Poisson"); - // add solution "u" to system - system.AddSolutionToSystemPDE("u"); + // add solution "u" to system + system.AddSolutionToSystemPDE("u"); - // attach the assembling function to system - system.SetAssembleFunction(AssemblePoissonProblem); + // attach the assembling function to system + system.SetAssembleFunction(AssemblePoissonProblem); - // initilaize and solve the system - system.init(); - system.solve(); + // initilaize and solve the system + system.init(); + system.solve(); - // print solutions - std::vector < std::string > variablesToBePrinted; - variablesToBePrinted.push_back("All"); + semiNorm[i][j] = GetErrorNorm(&mlSol); + // print solutions + std::vector < std::string > variablesToBePrinted; + variablesToBePrinted.push_back("All"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); - gmvIO.SetDebugOutput(true); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - + GMVWriter gmvIO(&mlSol); + gmvIO.SetDebugOutput(true); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + } + } + + // print the seminorm of the error and the order of convergence between different levels + std::cout< &x){ + double pi=acos(-1.); + return cos(pi*x[0])*cos(pi*x[1]); +}; + + +void GetSolutionGradient(const vector < double > &x, vector < double > &solGrad){ + double pi=acos(-1.); + solGrad[0] = -pi*sin(pi*x[0])*cos(pi*x[1]); + solGrad[1] = -pi*cos(pi*x[0])*sin(pi*x[1]); +}; + + +double GetSolutionLaplace(const vector < double > &x){ + double pi=acos(-1.); + return -pi*pi*cos(pi*x[0])*cos(pi*x[1]) - pi*pi*cos(pi*x[0])*cos(pi*x[1]); +}; + /** * This function assemble the stiffnes matrix KK and the residual vector Res * such that @@ -97,7 +154,6 @@ int main(int argc, char **args) { * and consequently * u = u0 + w satisfies KK u = F **/ - void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix) { // ml_prob is the global object from/to where get/set all the data // level is the level of the PDE system to be assembled @@ -221,7 +277,7 @@ void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const un for(unsigned jdim=0; jdim_ml_msh->GetNumberOfLevels()-1u; + // extract pointers to the several objects that we are going to use + Mesh* msh = mlSol->_ml_msh->GetLevel(level); // pointer to the mesh (level) object + elem* el = msh->el; // pointer to the elem object in msh (level) + Solution* sol = mlSol->GetSolutionLevel(level); // pointer to the solution (level) object + + const unsigned dim = msh->GetDimension(); // get the domain dimension of the problem + unsigned iproc = msh->processor_id(); // get the process_id (for parallel computation) + + //solution variable + unsigned soluIndex; + + soluIndex = mlSol->GetIndex("u"); // get the position of "u" in the ml_sol object + unsigned soluType = mlSol->GetSolutionType(soluIndex); // get the finite element type for "u" + + vector < double > solu; // local solution + + vector < vector < double > > x(dim); // local coordinates + unsigned xType = 2; // get the finite element type for "x", it is always 2 (LAGRANGE QUADRATIC) + vector phi; // local test function + vector phi_x; // local test function first order partial derivatives + vector phi_xx; // local test function second order partial derivatives + double weight; // gauss point weight + + // reserve memory for the local standar vectors + const unsigned maxSize = static_cast< unsigned > (ceil(pow(3,dim))); // conservative: based on line3, quad9, hex27 + solu.reserve(maxSize); + for(unsigned i = 0; i < dim; i++) + x[i].reserve(maxSize); + phi.reserve(maxSize); + phi_x.reserve(maxSize*dim); + unsigned dim2=(3*(dim-1)+!(dim-1)); // dim2 is the number of second order partial derivatives (1,3,6 depending on the dimension) + phi_xx.reserve(maxSize*dim2); + + double seminorm = 0.; + double l2norm = 0.; + // element loop: each process loops only on the elements that owns + for (int iel=msh->IS_Mts2Gmt_elem_offset[iproc]; iel < msh->IS_Mts2Gmt_elem_offset[iproc+1]; iel++) { + + unsigned kel = msh->IS_Mts2Gmt_elem[iel]; // mapping between paralell dof and mesh dof + short unsigned kelGeom = el->GetElementType( kel ); // element geometry type + unsigned nDofs = el->GetElementDofNumber( kel, soluType); // number of solution element dofs + unsigned nDofs2 = el->GetElementDofNumber( kel, xType); // number of coordinate element dofs + + // resize local arrays + solu.resize(nDofs); + for(int i=0; iGetMeshDof(kel, i, soluType); // local to global solution node + unsigned solDof = msh->GetMetisDof(iNode, soluType); // global to global mapping between solution node and solution dof + solu[i] = (*sol->_Sol[soluIndex])(solDof); // global extraction and local storage for the solution + } + + // local storage of coordinates + for( unsigned i=0; iGetMeshDof(kel, i, xType); // local to global coordinates node + unsigned xDof = msh->GetMetisDof(iNode, xType); // global to global mapping between coordinates node and coordinate dof + for(unsigned jdim=0; jdim_coordinate->_Sol[jdim])(xDof); // global extraction and local storage for the element coordinates + } + } + + // *** Gauss point loop *** + for(unsigned ig=0; ig < msh->_finiteElement[kelGeom][soluType]->GetGaussPointNumber(); ig++) { + // *** get gauss point weight, test function and test function partial derivatives *** + msh->_finiteElement[kelGeom][soluType]->Jacobian(x,ig,weight,phi,phi_x,phi_xx); + + // evaluate the solution, the solution derivatives and the coordinates in the gauss point + double soluGauss = 0; + vector < double > soluGauss_x(dim,0.); + vector < double > xGauss(dim,0.); + + for(unsigned i=0; i solGrad(dim); + GetSolutionGradient(xGauss, solGrad); + for (unsigned j=0;j n_processors()) { + seminorm_vec->init(msh->n_processors(), 1, false, SERIAL); + } + else { + seminorm_vec->init(msh->n_processors(), 1 , false, PARALLEL); + } + + seminorm_vec->set(iproc, seminorm); + seminorm_vec->close(); + seminorm=seminorm_vec->l1_norm(); + + delete seminorm_vec; + +// return sqrt(seminorm); + return sqrt(l2norm); + +} diff --git a/applications/NumPdeSpring2015/Bhagya/Ex2/input/cube_hex.neu b/applications/NumPdeSpring2015/Bhagya/Ex2/input/cube_hex.neu new file mode 100644 index 000000000..28b45889e --- /dev/null +++ b/applications/NumPdeSpring2015/Bhagya/Ex2/input/cube_hex.neu @@ -0,0 +1,205 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +cube_hex +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 16:56:41 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 125 8 1 2 3 3 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 2 5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 3 5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 4 5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 5 5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 6 -5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 7 0.00000000000e+00 5.00000000000e-01 5.00000000000e-01 + 8 2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 9 -2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 10 -5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 11 -5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 12 -5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 13 -5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 14 0.00000000000e+00 -5.00000000000e-01 5.00000000000e-01 + 15 -2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 16 2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 5.00000000000e-01 + 18 2.50000000000e-01 0.00000000000e+00 5.00000000000e-01 + 19 0.00000000000e+00 -2.50000000000e-01 5.00000000000e-01 + 20 2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 21 0.00000000000e+00 2.50000000000e-01 5.00000000000e-01 + 22 2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 23 -2.50000000000e-01 0.00000000000e+00 5.00000000000e-01 + 24 -2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 25 -2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 26 5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 27 5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 28 5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 29 5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 30 5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 31 -5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 32 0.00000000000e+00 -5.00000000000e-01 -5.00000000000e-01 + 33 2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 34 -2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 35 -5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 36 -5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 37 -5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 38 -5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 39 0.00000000000e+00 5.00000000000e-01 -5.00000000000e-01 + 40 -2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 41 2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 42 0.00000000000e+00 0.00000000000e+00 -5.00000000000e-01 + 43 2.50000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 44 0.00000000000e+00 2.50000000000e-01 -5.00000000000e-01 + 45 2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 46 0.00000000000e+00 -2.50000000000e-01 -5.00000000000e-01 + 47 2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 48 -2.50000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 49 -2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 50 -2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 51 -5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 52 -5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 53 -5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 54 5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 55 5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 56 5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 57 0.00000000000e+00 -5.00000000000e-01 0.00000000000e+00 + 58 0.00000000000e+00 -5.00000000000e-01 2.50000000000e-01 + 59 2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 60 2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 61 -2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 62 -2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 63 0.00000000000e+00 -5.00000000000e-01 -2.50000000000e-01 + 64 2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 65 -2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 66 -5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 67 -5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 68 -5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 69 -5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 70 -5.00000000000e-01 0.00000000000e+00 2.50000000000e-01 + 71 -5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 72 -5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 73 -5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 74 -5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 75 -5.00000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 76 -5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 77 -5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 78 5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 79 5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 80 5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 81 0.00000000000e+00 5.00000000000e-01 0.00000000000e+00 + 82 0.00000000000e+00 5.00000000000e-01 2.50000000000e-01 + 83 -2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 84 -2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 85 2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 86 2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 87 0.00000000000e+00 5.00000000000e-01 -2.50000000000e-01 + 88 -2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 89 2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 90 5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 91 5.00000000000e-01 0.00000000000e+00 2.50000000000e-01 + 92 5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 93 5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 94 5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 95 5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 96 5.00000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 97 5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 98 5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 99 0.00000000000e+00 0.00000000000e+00 0.00000000000e+00 + 100 2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 101 0.00000000000e+00 0.00000000000e+00 2.50000000000e-01 + 102 0.00000000000e+00 -2.50000000000e-01 0.00000000000e+00 + 103 2.50000000000e-01 0.00000000000e+00 2.50000000000e-01 + 104 2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 105 0.00000000000e+00 -2.50000000000e-01 2.50000000000e-01 + 106 2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 107 0.00000000000e+00 2.50000000000e-01 0.00000000000e+00 + 108 2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 109 0.00000000000e+00 2.50000000000e-01 2.50000000000e-01 + 110 2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 111 0.00000000000e+00 0.00000000000e+00 -2.50000000000e-01 + 112 2.50000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 113 0.00000000000e+00 -2.50000000000e-01 -2.50000000000e-01 + 114 2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 115 0.00000000000e+00 2.50000000000e-01 -2.50000000000e-01 + 116 2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 117 -2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 118 -2.50000000000e-01 0.00000000000e+00 2.50000000000e-01 + 119 -2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 120 -2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 121 -2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 122 -2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 123 -2.50000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 124 -2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 125 -2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 4 27 1 4 3 55 95 91 54 + 94 90 16 20 18 60 106 + 103 59 104 100 14 19 17 + 58 105 101 57 102 99 + 2 4 27 3 5 2 91 93 79 90 + 92 78 18 22 8 103 110 + 86 100 108 85 17 21 7 + 101 109 82 99 107 81 + 3 4 27 54 94 90 56 98 96 27 + 30 28 59 104 100 64 114 + 112 33 47 43 57 102 99 + 63 113 111 32 46 42 + 4 4 27 90 92 78 96 97 80 28 + 29 26 100 108 85 112 116 + 89 43 45 41 99 107 81 + 111 115 87 42 44 39 + 5 4 27 14 19 17 58 105 101 57 + 102 99 15 24 23 62 120 + 118 61 119 117 10 13 11 + 52 72 70 51 71 69 + 6 4 27 17 21 7 101 109 82 99 + 107 81 23 25 9 118 122 + 84 117 121 83 11 12 6 + 70 74 67 69 73 66 + 7 4 27 57 102 99 63 113 111 32 + 46 42 61 119 117 65 124 + 123 34 50 48 51 71 69 + 53 76 75 31 37 36 + 8 4 27 99 107 81 111 115 87 42 + 44 39 117 121 83 123 125 + 88 48 49 40 69 73 66 + 75 77 68 36 38 35 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 8 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 5 6 7 8 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 16 0 6 + 2 4 5 + 1 4 5 + 4 4 5 + 3 4 5 + 1 4 4 + 5 4 4 + 3 4 4 + 7 4 4 + 5 4 6 + 6 4 6 + 7 4 6 + 8 4 6 + 6 4 2 + 2 4 2 + 8 4 2 + 4 4 2 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 2 1 8 0 6 + 4 4 3 + 3 4 3 + 8 4 3 + 7 4 3 + 1 4 1 + 2 4 1 + 5 4 1 + 6 4 1 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/cube_hex.dbs b/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/cube_hex.dbs new file mode 100644 index 000000000..7010f3c41 Binary files /dev/null and b/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/cube_hex.dbs differ diff --git a/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/cube_mix.dbs b/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/cube_mix.dbs new file mode 100644 index 000000000..142034c14 Binary files /dev/null and b/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/cube_mix.dbs differ diff --git a/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/default_id.dbs b/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/default_id.dbs new file mode 100644 index 000000000..67bb28b86 Binary files /dev/null and b/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/default_id.dbs differ diff --git a/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/square_quad.dbs b/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/square_quad.dbs new file mode 100644 index 000000000..80ba35cb0 Binary files /dev/null and b/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/square_quad.dbs differ diff --git a/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/square_tri.dbs b/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/square_tri.dbs new file mode 100644 index 000000000..fc17fdd02 Binary files /dev/null and b/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/square_tri.dbs differ diff --git a/applications/NumPdeSpring2015/Bhagya/Ex2/input/square_quad.neu b/applications/NumPdeSpring2015/Bhagya/Ex2/input/square_quad.neu new file mode 100644 index 000000000..538a196af --- /dev/null +++ b/applications/NumPdeSpring2015/Bhagya/Ex2/input/square_quad.neu @@ -0,0 +1,62 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +square_quad +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 16:26:49 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 25 4 1 1 2 2 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 -5.00000000000e-01 -5.00000000000e-01 + 2 5.00000000000e-01 -5.00000000000e-01 + 3 0.00000000000e+00 -5.00000000000e-01 + 4 -2.50000000000e-01 -5.00000000000e-01 + 5 2.50000000000e-01 -5.00000000000e-01 + 6 5.00000000000e-01 5.00000000000e-01 + 7 5.00000000000e-01 0.00000000000e+00 + 8 5.00000000000e-01 -2.50000000000e-01 + 9 5.00000000000e-01 2.50000000000e-01 + 10 -5.00000000000e-01 5.00000000000e-01 + 11 0.00000000000e+00 5.00000000000e-01 + 12 2.50000000000e-01 5.00000000000e-01 + 13 -2.50000000000e-01 5.00000000000e-01 + 14 -5.00000000000e-01 0.00000000000e+00 + 15 -5.00000000000e-01 2.50000000000e-01 + 16 -5.00000000000e-01 -2.50000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 + 18 0.00000000000e+00 -2.50000000000e-01 + 19 -2.50000000000e-01 0.00000000000e+00 + 20 -2.50000000000e-01 -2.50000000000e-01 + 21 2.50000000000e-01 0.00000000000e+00 + 22 2.50000000000e-01 -2.50000000000e-01 + 23 0.00000000000e+00 2.50000000000e-01 + 24 -2.50000000000e-01 2.50000000000e-01 + 25 2.50000000000e-01 2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 2 9 1 4 3 18 17 19 14 + 16 20 + 2 2 9 3 5 2 8 7 21 17 + 18 22 + 3 2 9 14 19 17 23 11 13 10 + 15 24 + 4 2 9 17 21 7 9 6 12 11 + 23 25 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 4 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 8 0 6 + 4 2 3 + 3 2 3 + 2 2 2 + 4 2 2 + 1 2 1 + 2 2 1 + 3 2 4 + 1 2 4 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Bhagya/Ex2/input/square_tri.neu b/applications/NumPdeSpring2015/Bhagya/Ex2/input/square_tri.neu new file mode 100644 index 000000000..ff582c704 --- /dev/null +++ b/applications/NumPdeSpring2015/Bhagya/Ex2/input/square_tri.neu @@ -0,0 +1,62 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +square_tri +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 16:32:41 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 25 8 1 1 2 2 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 -5.00000000000e-01 -5.00000000000e-01 + 2 5.00000000000e-01 -5.00000000000e-01 + 3 0.00000000000e+00 -5.00000000000e-01 + 4 -2.50000000000e-01 -5.00000000000e-01 + 5 2.50000000000e-01 -5.00000000000e-01 + 6 5.00000000000e-01 5.00000000000e-01 + 7 5.00000000000e-01 0.00000000000e+00 + 8 5.00000000000e-01 -2.50000000000e-01 + 9 5.00000000000e-01 2.50000000000e-01 + 10 -5.00000000000e-01 5.00000000000e-01 + 11 0.00000000000e+00 5.00000000000e-01 + 12 2.50000000000e-01 5.00000000000e-01 + 13 -2.50000000000e-01 5.00000000000e-01 + 14 -5.00000000000e-01 0.00000000000e+00 + 15 -5.00000000000e-01 2.50000000000e-01 + 16 -5.00000000000e-01 -2.50000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 + 18 0.00000000000e+00 -2.50000000000e-01 + 19 -2.50000000000e-01 0.00000000000e+00 + 20 -2.50000000000e-01 -2.50000000000e-01 + 21 2.50000000000e-01 0.00000000000e+00 + 22 2.50000000000e-01 -2.50000000000e-01 + 23 0.00000000000e+00 2.50000000000e-01 + 24 -2.50000000000e-01 2.50000000000e-01 + 25 2.50000000000e-01 2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 3 6 3 18 17 19 14 20 + 2 3 6 1 4 3 20 14 16 + 3 3 6 2 8 7 21 17 22 + 4 3 6 3 5 2 22 17 18 + 5 3 6 17 23 11 13 10 24 + 6 3 6 14 19 17 24 10 15 + 7 3 6 7 9 6 12 11 25 + 8 3 6 17 21 7 25 11 23 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 8 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 5 6 7 8 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 8 0 6 + 7 3 2 + 5 3 2 + 3 3 1 + 7 3 1 + 2 3 1 + 4 3 1 + 6 3 3 + 2 3 3 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Bhagya/Ex3/CMakeLists.txt b/applications/NumPdeSpring2015/Bhagya/Ex3/CMakeLists.txt new file mode 100644 index 000000000..78ece9e49 --- /dev/null +++ b/applications/NumPdeSpring2015/Bhagya/Ex3/CMakeLists.txt @@ -0,0 +1,9 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +SET (PROJECT_NAME "${MYNAME_FOLDER}${EXAMPLE_NUMBER}") +PROJECT(PROJECT_NAME) + +SET(MAIN_FILE "${EXAMPLE_NUMBER}") # the name of the source file with no extension +SET(EXEC_FILE "${MYNAME_FOLDER}${EXAMPLE_NUMBER}") # the name of the executable file + +femusMacroBuildApplication(${MAIN_FILE} ${EXEC_FILE}) diff --git a/applications/NumPdeSpring2015/Bhagya/Ex3/Ex3.cpp b/applications/NumPdeSpring2015/Bhagya/Ex3/Ex3.cpp new file mode 100644 index 000000000..cc59a3e31 --- /dev/null +++ b/applications/NumPdeSpring2015/Bhagya/Ex3/Ex3.cpp @@ -0,0 +1,255 @@ +/** tutorial/Ex2 + * This example shows how to set and solve the weak form of the Poisson problem + * $$ \Delta u = 1 \text{ on }\Omega, $$ + * $$ u=0 \text{ on } \Gamma, $$ + * on a square domain $\Omega$ with boundary $\Gamma$; + * all the coarse-level meshes are removed; + * a multilevel problem and an equation system are initialized; + * a direct solver is used to solve the problem. + **/ + +#include "FemusInit.hpp" +#include "MultiLevelProblem.hpp" +#include "NumericVector.hpp" +#include "VTKWriter.hpp" +#include "GMVWriter.hpp" +#include "LinearImplicitSystem.hpp" + +using namespace femus; + +bool SetBoundaryCondition(const double &x, const double &y, const double &z,const char name[], double &value, const int facename, const double time) { + bool dirichlet=1; //dirichlet + value=0.; + return dirichlet; +} + +void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix); + + +int main(int argc, char **args) { + + // init Petsc-MPI communicator + FemusInit mpinit(argc, args, MPI_COMM_WORLD); + + // define multilevel mesh + MultiLevelMesh mlMsh; + // read coarse level mesh and generate finers level meshes + double scalingFactor=1.; + mlMsh.ReadCoarseMesh("./input/square.neu","seventh",scalingFactor); + /* "seventh" is the order of accuracy that is used in the gauss integration scheme + probably in the furure it is not going to be an argument of this function */ + unsigned numberOfUniformLevels=2; + unsigned numberOfSelectiveLevels=0; + mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL); + + // erase all the coarse mesh levels + mlMsh.EraseCoarseLevels(numberOfUniformLevels-1); + + // print mesh info + mlMsh.PrintInfo(); + + // define the multilevel solution and attach the mlMsh object to it + MultiLevelSolution mlSol(&mlMsh); + + // add variables to mlSol + mlSol.AddSolution("u",LAGRANGE, FIRST); + mlSol.Initialize("All"); + + // attach the boundary condition function and generate boundary data + mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition); + mlSol.GenerateBdc("u"); + + // define the multilevel problem attach the mlSol object to it + MultiLevelProblem mlProb(&mlSol); + + // add system Poisson in mlProb as a Linear Implicit System + LinearImplicitSystem & system = mlProb.add_system < LinearImplicitSystem > ("Poisson"); + + // add solution "u" to system + system.AddSolutionToSystemPDE("u"); + + // attach the assembling function to system + system.SetAssembleFunction(AssemblePoissonProblem); + + // initilaize and solve the system + system.init(); + system.solve(); + + // print solutions + std::vector < std::string > variablesToBePrinted; + variablesToBePrinted.push_back("All"); + + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + + GMVWriter gmvIO(&mlSol); + gmvIO.SetDebugOutput(true); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + + return 0; +} + + +/** + * This function assemble the stiffnes matrix KK and the residual vector Res + * such that + * KK w = RES = F - KK u0, + * and consequently + * u = u0 + w satisfies KK u = F + **/ + +void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix) { + // ml_prob is the global object from/to where get/set all the data + // level is the level of the PDE system to be assembled + // levelMax is the Maximum level of the MultiLevelProblem + // assembleMatrix is a flag that tells if only the residual or also the matrix should be assembled + + // extract pointers to the several objects that we are going to use + Mesh* msh = ml_prob._ml_msh->GetLevel(level); // pointer to the mesh (level) object + elem* el = msh->el; // pointer to the elem object in msh (level) + + MultiLevelSolution* mlSol = ml_prob._ml_sol; // pointer to the multilevel solution object + Solution* sol = ml_prob._ml_sol->GetSolutionLevel(level); // pointer to the solution (level) object + + LinearImplicitSystem* mlPdeSys = &ml_prob.get_system("Poisson"); // pointer to the linear implicit system named "Poisson" + LinearEquationSolver* pdeSys = mlPdeSys->_LinSolver[level]; // pointer to the equation (level) object + SparseMatrix* KK = pdeSys->_KK; // pointer to the global stifness matrix object in pdeSys (level) + NumericVector* RES = pdeSys->_RES; // pointer to the global residual vector object in pdeSys (level) + + const unsigned dim = msh->GetDimension(); // get the domain dimension of the problem + unsigned iproc = msh->processor_id(); // get the process_id (for parallel computation) + + //solution variable + unsigned soluIndex; + soluIndex = mlSol->GetIndex("u"); // get the position of "u" in the ml_sol object + unsigned soluType = mlSol->GetSolutionType(soluIndex); // get the finite element type for "u" + + unsigned soluPdeIndex; + soluPdeIndex = mlPdeSys->GetSolPdeIndex("u"); // get the position of "u" in the pdeSys object + + vector < double > solu; // local solution + + vector < vector < double > > x(dim); // local coordinates + unsigned xType = 2; // get the finite element type for "x", it is always 2 (LAGRANGE QUADRATIC) + + vector< int > KKDof; // local to global pdeSys dofs + vector phi; // local test function + vector phi_x; // local test function first order partial derivatives + vector phi_xx; // local test function second order partial derivatives + double weight; // gauss point weight + + vector< double > Res; // local redidual vector + vector< double > K; // local stiffness matrix + + // reserve memory for the local standar vectors + const unsigned maxSize = static_cast< unsigned > (ceil(pow(3,dim))); // conservative: based on line3, quad9, hex27 + solu.reserve(maxSize); + for(unsigned i = 0; i < dim; i++) + x[i].reserve(maxSize); + KKDof.reserve(maxSize); + phi.reserve(maxSize); + phi_x.reserve(maxSize*dim); + unsigned dim2=(3*(dim-1)+!(dim-1)); // dim2 is the number of second order partial derivatives (1,3,6 depending on the dimension) + phi_xx.reserve(maxSize*dim2); + Res.reserve(maxSize); + K.reserve(maxSize*maxSize); + + if( assembleMatrix ) + KK->zero(); // Set to zero all the entries of the Global Matrix + + // element loop: each process loops only on the elements that owns + for (int iel=msh->IS_Mts2Gmt_elem_offset[iproc]; iel < msh->IS_Mts2Gmt_elem_offset[iproc+1]; iel++) { + + unsigned kel = msh->IS_Mts2Gmt_elem[iel]; // mapping between paralell dof and mesh dof + short unsigned kelGeom = el->GetElementType( kel ); // element geometry type + unsigned nDofs = el->GetElementDofNumber( kel, soluType); // number of solution element dofs + unsigned nDofs2 = el->GetElementDofNumber( kel, xType); // number of coordinate element dofs + + // resize local arrays + KKDof.resize(nDofs); + solu.resize(nDofs); + for(int i=0; iGetMeshDof(kel, i, soluType); // local to global solution node + unsigned solDof = msh->GetMetisDof(iNode, soluType); // global to global mapping between solution node and solution dof + solu[i] = (*sol->_Sol[soluIndex])(solDof); // global extraction and local storage for the solution + KKDof[i] = pdeSys->GetKKDof(soluIndex, soluPdeIndex, iNode); // global to global mapping between solution node and pdeSys dof + } + + // local storage of coordinates + for( unsigned i=0; iGetMeshDof(kel, i, xType); // local to global coordinates node + unsigned xDof = msh->GetMetisDof(iNode, xType); // global to global mapping between coordinates node and coordinate dof + for(unsigned jdim=0; jdim_coordinate->_Sol[jdim])(xDof); // global extraction and local storage for the element coordinates + } + } + + if( level == levelMax || !el->GetRefinedElementIndex(kel)) { // do not care about this if now (it is used for the AMR) + // *** Gauss point loop *** + for(unsigned ig=0; ig < msh->_finiteElement[kelGeom][soluType]->GetGaussPointNumber(); ig++) { + // *** get gauss point weight, test function and test function partial derivatives *** + msh->_finiteElement[kelGeom][soluType]->Jacobian(x,ig,weight,phi,phi_x,phi_xx); + + // evaluate the solution, the solution derivatives and the coordinates in the gauss point + double soluGauss = 0; + vector < double > soluGauss_x(dim,0.); + vector < double > xGauss(dim,0.); + + for(unsigned i=0; iadd_vector_blocked(Res,KKDof); + if(assembleMatrix) KK->add_matrix_blocked(K,KKDof,KKDof); + } //end element loop for each process + + RES->close(); + if( assembleMatrix ) KK->close(); + // ***************** END ASSEMBLY ******************* + + +} + + diff --git a/applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/square.dbs b/applications/NumPdeSpring2015/Bhagya/Ex3/input/gambit/square.dbs similarity index 100% rename from applications/NumPdeSpring2015/Bhagya/Ex2/input/gambit/square.dbs rename to applications/NumPdeSpring2015/Bhagya/Ex3/input/gambit/square.dbs diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/square.neu b/applications/NumPdeSpring2015/Bhagya/Ex3/input/square.neu similarity index 100% rename from applications/NumPdeSpring2015/Eugenio/Ex2/input/square.neu rename to applications/NumPdeSpring2015/Bhagya/Ex3/input/square.neu diff --git a/applications/NumPdeSpring2015/Eugenio/Ex1/Ex1.cpp b/applications/NumPdeSpring2015/Eugenio/Ex1/Ex1.cpp index 0c5eaf37d..04b5866c5 100644 --- a/applications/NumPdeSpring2015/Eugenio/Ex1/Ex1.cpp +++ b/applications/NumPdeSpring2015/Eugenio/Ex1/Ex1.cpp @@ -69,13 +69,13 @@ int main(int argc, char **args) { variablesToBePrinted.push_back("P"); variablesToBePrinted.push_back("T"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); + GMVWriter gmvIO(&mlSol); variablesToBePrinted.push_back("all"); gmvIO.SetDebugOutput(false); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); return 0; } diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/Ex2.cpp b/applications/NumPdeSpring2015/Eugenio/Ex2/Ex2.cpp index ac0b0e406..27fdbe0f1 100644 --- a/applications/NumPdeSpring2015/Eugenio/Ex2/Ex2.cpp +++ b/applications/NumPdeSpring2015/Eugenio/Ex2/Ex2.cpp @@ -18,78 +18,176 @@ using namespace femus; bool SetBoundaryCondition(const double &x, const double &y, const double &z,const char name[], double &value, const int facename, const double time) { - bool dirichlet=1; //dirichlet + bool dirichlet = true; //dirichlet value=0.; + if(facename == 2) dirichlet = false; return dirichlet; } void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix); +std::pair < double, double > GetErrorNorm(MultiLevelSolution *mlSol); int main(int argc, char **args) { // init Petsc-MPI communicator FemusInit mpinit(argc, args, MPI_COMM_WORLD); - - // define multilevel mesh + + + // define multilevel mesh MultiLevelMesh mlMsh; // read coarse level mesh and generate finers level meshes double scalingFactor=1.; - mlMsh.ReadCoarseMesh("./input/square.neu","seventh",scalingFactor); + mlMsh.ReadCoarseMesh("./input/cube_tet.neu","seventh",scalingFactor); /* "seventh" is the order of accuracy that is used in the gauss integration scheme - probably in the furure it is not going to be an argument of this function */ - unsigned numberOfUniformLevels=2; - unsigned numberOfSelectiveLevels=0; - mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL); + probably in the furure it is not going to be an argument of this function */ + unsigned dim = mlMsh.GetDimension(); + unsigned maxNumberOfMeshes; - // erase all the coarse mesh levels - mlMsh.EraseCoarseLevels(numberOfUniformLevels-1); + if(dim==2){ + maxNumberOfMeshes = 7; + } + else{ + maxNumberOfMeshes = 5; + } - // print mesh info - mlMsh.PrintInfo(); + vector < vector < double > > l2Norm; + l2Norm.resize(maxNumberOfMeshes); - // define the multilevel solution and attach the mlMsh object to it - MultiLevelSolution mlSol(&mlMsh); + vector < vector < double > > semiNorm; + semiNorm.resize(maxNumberOfMeshes); - // add variables to mlSol - mlSol.AddSolution("u",LAGRANGE, FIRST); - mlSol.Initialize("All"); + for(unsigned i = 0; i < maxNumberOfMeshes; i++){ // loop on the mesh level + + unsigned numberOfUniformLevels = i+1; + unsigned numberOfSelectiveLevels = 0; + mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL); - // attach the boundary condition function and generate boundary data - mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition); - mlSol.GenerateBdc("u"); + // erase all the coarse mesh levels + mlMsh.EraseCoarseLevels(numberOfUniformLevels-1); + + // print mesh info + mlMsh.PrintInfo(); + + FEOrder feOrder[3] = {FIRST, SERENDIPITY, SECOND}; + l2Norm[i].resize(3); + semiNorm[i].resize(3); + + for(unsigned j=0; j<3; j++){ // loop on the FE Order + // define the multilevel solution and attach the mlMsh object to it + MultiLevelSolution mlSol(&mlMsh); + + // add variables to mlSol + mlSol.AddSolution("u",LAGRANGE, feOrder[j]); + mlSol.Initialize("All"); - // define the multilevel problem attach the mlSol object to it - MultiLevelProblem mlProb(&mlSol); + // attach the boundary condition function and generate boundary data + mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition); + mlSol.GenerateBdc("u"); - // add system Poisson in mlProb as a Linear Implicit System - LinearImplicitSystem & system = mlProb.add_system < LinearImplicitSystem > ("Poisson"); + // define the multilevel problem attach the mlSol object to it + MultiLevelProblem mlProb(&mlSol); + + // add system Poisson in mlProb as a Linear Implicit System + LinearImplicitSystem & system = mlProb.add_system < LinearImplicitSystem > ("Poisson"); - // add solution "u" to system - system.AddSolutionToSystemPDE("u"); + // add solution "u" to system + system.AddSolutionToSystemPDE("u"); - // attach the assembling function to system - system.SetAssembleFunction(AssemblePoissonProblem); + // attach the assembling function to system + system.SetAssembleFunction(AssemblePoissonProblem); - // initilaize and solve the system - system.init(); - system.solve(); + // initilaize and solve the system + system.init(); + system.solve(); - // print solutions - std::vector < std::string > variablesToBePrinted; - variablesToBePrinted.push_back("All"); + std::pair< double , double > norm = GetErrorNorm(&mlSol); + l2Norm[i][j] =norm.first; + semiNorm[i][j]=norm.second; + // print solutions + std::vector < std::string > variablesToBePrinted; + variablesToBePrinted.push_back("All"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); - gmvIO.SetDebugOutput(true); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - + GMVWriter gmvIO(&mlSol); + gmvIO.SetDebugOutput(true); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + } + } + + // print the seminorm of the error and the order of convergence between different levels + std::cout< &x){ + double pi=acos(-1.); + return cos(pi*x[0])*cos(pi*x[1]); +}; + + +void GetExactSolutionGradient(const vector < double > &x, vector < double > &solGrad){ + double pi=acos(-1.); + solGrad[0] = -pi*sin(pi*x[0])*cos(pi*x[1]); + solGrad[1] = -pi*cos(pi*x[0])*sin(pi*x[1]); +}; + + +double GetExactSolutionLaplace(const vector < double > &x){ + double pi=acos(-1.); + return -pi*pi*cos(pi*x[0])*cos(pi*x[1]) - pi*pi*cos(pi*x[0])*cos(pi*x[1]); +}; + /** * This function assemble the stiffnes matrix KK and the residual vector Res * such that @@ -97,7 +195,6 @@ int main(int argc, char **args) { * and consequently * u = u0 + w satisfies KK u = F **/ - void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix) { // ml_prob is the global object from/to where get/set all the data // level is the level of the PDE system to be assembled @@ -221,7 +318,7 @@ void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const un for(unsigned jdim=0; jdim GetErrorNorm(MultiLevelSolution *mlSol){ + unsigned level = mlSol->_ml_msh->GetNumberOfLevels()-1u; + // extract pointers to the several objects that we are going to use + Mesh* msh = mlSol->_ml_msh->GetLevel(level); // pointer to the mesh (level) object + elem* el = msh->el; // pointer to the elem object in msh (level) + Solution* sol = mlSol->GetSolutionLevel(level); // pointer to the solution (level) object + + const unsigned dim = msh->GetDimension(); // get the domain dimension of the problem + unsigned iproc = msh->processor_id(); // get the process_id (for parallel computation) + + //solution variable + unsigned soluIndex; + soluIndex = mlSol->GetIndex("u"); // get the position of "u" in the ml_sol object + unsigned soluType = mlSol->GetSolutionType(soluIndex); // get the finite element type for "u" + + vector < double > solu; // local solution + + vector < vector < double > > x(dim); // local coordinates + unsigned xType = 2; // get the finite element type for "x", it is always 2 (LAGRANGE QUADRATIC) + vector phi; // local test function + vector phi_x; // local test function first order partial derivatives + vector phi_xx; // local test function second order partial derivatives + double weight; // gauss point weight + + // reserve memory for the local standar vectors + const unsigned maxSize = static_cast< unsigned > (ceil(pow(3,dim))); // conservative: based on line3, quad9, hex27 + solu.reserve(maxSize); + for(unsigned i = 0; i < dim; i++) + x[i].reserve(maxSize); + phi.reserve(maxSize); + phi_x.reserve(maxSize*dim); + unsigned dim2=(3*(dim-1)+!(dim-1)); // dim2 is the number of second order partial derivatives (1,3,6 depending on the dimension) + phi_xx.reserve(maxSize*dim2); + + double seminorm = 0.; + double l2norm = 0.; + + // element loop: each process loops only on the elements that owns + for (int iel=msh->IS_Mts2Gmt_elem_offset[iproc]; iel < msh->IS_Mts2Gmt_elem_offset[iproc+1]; iel++) { + + unsigned kel = msh->IS_Mts2Gmt_elem[iel]; // mapping between paralell dof and mesh dof + short unsigned kelGeom = el->GetElementType( kel ); // element geometry type + unsigned nDofs = el->GetElementDofNumber( kel, soluType); // number of solution element dofs + unsigned nDofs2 = el->GetElementDofNumber( kel, xType); // number of coordinate element dofs + + // resize local arrays + solu.resize(nDofs); + for(int i=0; iGetMeshDof(kel, i, soluType); // local to global solution node + unsigned solDof = msh->GetMetisDof(iNode, soluType); // global to global mapping between solution node and solution dof + solu[i] = (*sol->_Sol[soluIndex])(solDof); // global extraction and local storage for the solution + } + + // local storage of coordinates + for( unsigned i=0; iGetMeshDof(kel, i, xType); // local to global coordinates node + unsigned xDof = msh->GetMetisDof(iNode, xType); // global to global mapping between coordinates node and coordinate dof + for(unsigned jdim=0; jdim_coordinate->_Sol[jdim])(xDof); // global extraction and local storage for the element coordinates + } + } + + // *** Gauss point loop *** + for(unsigned ig=0; ig < msh->_finiteElement[kelGeom][soluType]->GetGaussPointNumber(); ig++) { + // *** get gauss point weight, test function and test function partial derivatives *** + msh->_finiteElement[kelGeom][soluType]->Jacobian(x,ig,weight,phi,phi_x,phi_xx); + + // evaluate the solution, the solution derivatives and the coordinates in the gauss point + double soluGauss = 0; + vector < double > soluGauss_x(dim,0.); + vector < double > xGauss(dim,0.); + + for(unsigned i=0; i solGrad(dim); + GetExactSolutionGradient(xGauss, solGrad); + + for (unsigned j=0;j init(msh->n_processors(), 1 , false, AUTOMATIC); + + norm_vec->set(iproc, l2norm); + norm_vec->close(); + l2norm=norm_vec->l1_norm(); + + norm_vec->set(iproc, seminorm); + norm_vec->close(); + seminorm=norm_vec->l1_norm(); + + delete norm_vec; + + std::pair < double, double > norm; + norm.first = sqrt(l2norm); + norm.second = sqrt(seminorm); + + return norm; + +} diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/cube_hex.neu b/applications/NumPdeSpring2015/Eugenio/Ex2/input/cube_hex.neu new file mode 100644 index 000000000..7394da387 --- /dev/null +++ b/applications/NumPdeSpring2015/Eugenio/Ex2/input/cube_hex.neu @@ -0,0 +1,205 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +cube_hex +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 15:51:34 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 125 8 1 2 3 3 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 2 5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 3 5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 4 5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 5 5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 6 -5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 7 0.00000000000e+00 5.00000000000e-01 5.00000000000e-01 + 8 2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 9 -2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 10 -5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 11 -5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 12 -5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 13 -5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 14 0.00000000000e+00 -5.00000000000e-01 5.00000000000e-01 + 15 -2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 16 2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 5.00000000000e-01 + 18 2.50000000000e-01 0.00000000000e+00 5.00000000000e-01 + 19 0.00000000000e+00 -2.50000000000e-01 5.00000000000e-01 + 20 2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 21 0.00000000000e+00 2.50000000000e-01 5.00000000000e-01 + 22 2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 23 -2.50000000000e-01 0.00000000000e+00 5.00000000000e-01 + 24 -2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 25 -2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 26 5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 27 5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 28 5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 29 5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 30 5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 31 -5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 32 0.00000000000e+00 -5.00000000000e-01 -5.00000000000e-01 + 33 2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 34 -2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 35 -5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 36 -5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 37 -5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 38 -5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 39 0.00000000000e+00 5.00000000000e-01 -5.00000000000e-01 + 40 -2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 41 2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 42 0.00000000000e+00 0.00000000000e+00 -5.00000000000e-01 + 43 2.50000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 44 0.00000000000e+00 2.50000000000e-01 -5.00000000000e-01 + 45 2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 46 0.00000000000e+00 -2.50000000000e-01 -5.00000000000e-01 + 47 2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 48 -2.50000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 49 -2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 50 -2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 51 -5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 52 -5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 53 -5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 54 5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 55 5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 56 5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 57 0.00000000000e+00 -5.00000000000e-01 0.00000000000e+00 + 58 0.00000000000e+00 -5.00000000000e-01 2.50000000000e-01 + 59 2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 60 2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 61 -2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 62 -2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 63 0.00000000000e+00 -5.00000000000e-01 -2.50000000000e-01 + 64 2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 65 -2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 66 -5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 67 -5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 68 -5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 69 -5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 70 -5.00000000000e-01 0.00000000000e+00 2.50000000000e-01 + 71 -5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 72 -5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 73 -5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 74 -5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 75 -5.00000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 76 -5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 77 -5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 78 5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 79 5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 80 5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 81 0.00000000000e+00 5.00000000000e-01 0.00000000000e+00 + 82 0.00000000000e+00 5.00000000000e-01 2.50000000000e-01 + 83 -2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 84 -2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 85 2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 86 2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 87 0.00000000000e+00 5.00000000000e-01 -2.50000000000e-01 + 88 -2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 89 2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 90 5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 91 5.00000000000e-01 0.00000000000e+00 2.50000000000e-01 + 92 5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 93 5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 94 5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 95 5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 96 5.00000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 97 5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 98 5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 99 0.00000000000e+00 0.00000000000e+00 0.00000000000e+00 + 100 2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 101 0.00000000000e+00 0.00000000000e+00 2.50000000000e-01 + 102 0.00000000000e+00 -2.50000000000e-01 0.00000000000e+00 + 103 2.50000000000e-01 0.00000000000e+00 2.50000000000e-01 + 104 2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 105 0.00000000000e+00 -2.50000000000e-01 2.50000000000e-01 + 106 2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 107 0.00000000000e+00 2.50000000000e-01 0.00000000000e+00 + 108 2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 109 0.00000000000e+00 2.50000000000e-01 2.50000000000e-01 + 110 2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 111 0.00000000000e+00 0.00000000000e+00 -2.50000000000e-01 + 112 2.50000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 113 0.00000000000e+00 -2.50000000000e-01 -2.50000000000e-01 + 114 2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 115 0.00000000000e+00 2.50000000000e-01 -2.50000000000e-01 + 116 2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 117 -2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 118 -2.50000000000e-01 0.00000000000e+00 2.50000000000e-01 + 119 -2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 120 -2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 121 -2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 122 -2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 123 -2.50000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 124 -2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 125 -2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 4 27 1 4 3 55 95 91 54 + 94 90 16 20 18 60 106 + 103 59 104 100 14 19 17 + 58 105 101 57 102 99 + 2 4 27 3 5 2 91 93 79 90 + 92 78 18 22 8 103 110 + 86 100 108 85 17 21 7 + 101 109 82 99 107 81 + 3 4 27 54 94 90 56 98 96 27 + 30 28 59 104 100 64 114 + 112 33 47 43 57 102 99 + 63 113 111 32 46 42 + 4 4 27 90 92 78 96 97 80 28 + 29 26 100 108 85 112 116 + 89 43 45 41 99 107 81 + 111 115 87 42 44 39 + 5 4 27 14 19 17 58 105 101 57 + 102 99 15 24 23 62 120 + 118 61 119 117 10 13 11 + 52 72 70 51 71 69 + 6 4 27 17 21 7 101 109 82 99 + 107 81 23 25 9 118 122 + 84 117 121 83 11 12 6 + 70 74 67 69 73 66 + 7 4 27 57 102 99 63 113 111 32 + 46 42 61 119 117 65 124 + 123 34 50 48 51 71 69 + 53 76 75 31 37 36 + 8 4 27 99 107 81 111 115 87 42 + 44 39 117 121 83 123 125 + 88 48 49 40 69 73 66 + 75 77 68 36 38 35 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 8 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 5 6 7 8 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 16 0 6 + 1 4 4 + 5 4 4 + 3 4 4 + 7 4 4 + 5 4 6 + 6 4 6 + 7 4 6 + 8 4 6 + 6 4 2 + 2 4 2 + 8 4 2 + 4 4 2 + 2 4 5 + 1 4 5 + 4 4 5 + 3 4 5 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 2 1 8 0 6 + 4 4 3 + 3 4 3 + 8 4 3 + 7 4 3 + 1 4 1 + 2 4 1 + 5 4 1 + 6 4 1 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/cube_mixed.neu b/applications/NumPdeSpring2015/Eugenio/Ex2/input/cube_mixed.neu new file mode 100644 index 000000000..6f60c433a --- /dev/null +++ b/applications/NumPdeSpring2015/Eugenio/Ex2/input/cube_mixed.neu @@ -0,0 +1,226 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +cube_mixed +PROGRAM: Gambit VERSION: 2.3.16 +14 Mar 2015 09:46:45 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 125 16 1 2 3 3 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 2 5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 3 5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 4 5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 5 5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 6 5.00000000000e-01 -3.06161699787e-17 5.00000000000e-01 + 7 5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 8 5.00000000000e-01 -1.53080849893e-17 2.50000000000e-01 + 9 5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 10 0.00000000000e+00 0.00000000000e+00 0.00000000000e+00 + 11 -3.06161699787e-17 -3.06161699787e-17 5.00000000000e-01 + 12 -1.53080849893e-17 -1.53080849893e-17 2.50000000000e-01 + 13 2.50000000000e-01 -3.06161699787e-17 5.00000000000e-01 + 14 2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 15 2.50000000000e-01 -1.53080849893e-17 2.50000000000e-01 + 16 -3.06161699787e-17 5.00000000000e-01 5.00000000000e-01 + 17 -3.06161699787e-17 2.50000000000e-01 5.00000000000e-01 + 18 2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 19 2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 20 0.00000000000e+00 5.00000000000e-01 0.00000000000e+00 + 21 -1.53080849893e-17 5.00000000000e-01 2.50000000000e-01 + 22 2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 23 2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 24 0.00000000000e+00 2.50000000000e-01 0.00000000000e+00 + 25 2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 26 -1.53080849893e-17 2.50000000000e-01 2.50000000000e-01 + 27 2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 28 -5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 29 -2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 30 -5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 31 -5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 32 -2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 33 -2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 34 -5.00000000000e-01 -3.06161699787e-17 5.00000000000e-01 + 35 -5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 36 -2.50000000000e-01 -3.06161699787e-17 5.00000000000e-01 + 37 -2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 38 -5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 39 -2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 40 -5.00000000000e-01 -1.53080849893e-17 2.50000000000e-01 + 41 -2.50000000000e-01 -1.53080849893e-17 2.50000000000e-01 + 42 -5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 43 -2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 44 -5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 45 -2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 46 -3.06161699787e-17 -5.00000000000e-01 5.00000000000e-01 + 47 -3.06161699787e-17 -2.50000000000e-01 5.00000000000e-01 + 48 5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 49 2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 50 5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 51 2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 52 0.00000000000e+00 -5.00000000000e-01 0.00000000000e+00 + 53 0.00000000000e+00 -2.50000000000e-01 0.00000000000e+00 + 54 5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 55 2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 56 5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 57 2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 58 5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 59 5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 60 -1.53080849893e-17 -5.00000000000e-01 2.50000000000e-01 + 61 -1.53080849893e-17 -2.50000000000e-01 2.50000000000e-01 + 62 2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 63 2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 64 3.06161699787e-17 3.06161699787e-17 -5.00000000000e-01 + 65 1.53080849893e-17 1.53080849893e-17 -2.50000000000e-01 + 66 5.00000000000e-01 3.06161699787e-17 -5.00000000000e-01 + 67 2.50000000000e-01 3.06161699787e-17 -5.00000000000e-01 + 68 5.00000000000e-01 1.53080849893e-17 -2.50000000000e-01 + 69 2.50000000000e-01 1.53080849893e-17 -2.50000000000e-01 + 70 3.06161699787e-17 5.00000000000e-01 -5.00000000000e-01 + 71 1.53080849893e-17 5.00000000000e-01 -2.50000000000e-01 + 72 5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 73 5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 74 2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 75 2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 76 5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 77 5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 78 3.06161699787e-17 2.50000000000e-01 -5.00000000000e-01 + 79 1.53080849893e-17 2.50000000000e-01 -2.50000000000e-01 + 80 2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 81 2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 82 3.06161699787e-17 -5.00000000000e-01 -5.00000000000e-01 + 83 3.06161699787e-17 -2.50000000000e-01 -5.00000000000e-01 + 84 1.53080849893e-17 -5.00000000000e-01 -2.50000000000e-01 + 85 1.53080849893e-17 -2.50000000000e-01 -2.50000000000e-01 + 86 5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 87 5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 88 5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 89 5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 90 2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 91 2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 92 2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 93 2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 94 -5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 95 -2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 96 -5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 97 -2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 98 -5.00000000000e-01 3.06161699787e-17 -5.00000000000e-01 + 99 -5.00000000000e-01 1.53080849893e-17 -2.50000000000e-01 + 100 -2.50000000000e-01 3.06161699787e-17 -5.00000000000e-01 + 101 -2.50000000000e-01 1.53080849893e-17 -2.50000000000e-01 + 102 -5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 103 -2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 104 -5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 105 -2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 106 -5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 107 -5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 108 -2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 109 -2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 110 -5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 111 -5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 112 -2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 113 -2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 114 -5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 115 -2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 116 -5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 117 -2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 118 -5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 119 -2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 120 -5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 121 -2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 122 -5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 123 -2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 124 -5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 125 -2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 6 10 20 21 16 27 19 6 23 + 18 7 4 + 2 6 10 20 27 6 26 13 11 24 + 15 12 10 + 3 6 10 20 21 16 26 17 11 27 + 19 13 6 + 4 6 10 20 25 1 27 8 6 24 + 14 15 10 + 5 6 10 20 25 1 22 3 2 23 + 9 5 4 + 6 6 10 20 25 1 23 9 4 27 + 8 7 6 + 7 5 18 16 21 20 17 26 11 32 + 33 29 37 45 36 30 31 + 28 35 44 34 + 8 5 18 11 26 20 12 24 10 36 + 45 29 41 43 39 34 44 + 28 40 42 38 + 9 5 18 10 14 1 15 8 6 53 + 57 56 63 59 50 52 55 + 54 62 58 48 + 10 5 18 10 15 6 12 13 11 53 + 63 50 61 51 47 52 62 + 48 60 49 46 + 11 5 18 20 22 2 25 3 1 71 + 75 73 81 77 68 70 74 + 72 80 76 66 + 12 5 18 20 25 1 24 14 10 71 + 81 68 79 69 65 70 80 + 66 78 67 64 + 13 4 27 10 53 52 65 85 84 64 + 83 82 14 57 55 69 93 + 91 67 92 90 1 56 54 + 68 89 87 66 88 86 + 14 4 27 64 78 70 100 103 95 98 + 102 94 65 79 71 101 105 + 97 99 104 96 10 24 20 + 39 43 29 38 42 28 + 15 4 27 10 39 38 53 113 111 52 + 112 110 12 41 40 61 117 + 116 60 115 114 11 36 34 + 47 109 107 46 108 106 + 16 4 27 10 53 52 39 113 112 38 + 111 110 65 85 84 101 125 + 123 99 124 122 64 83 82 + 100 121 119 98 120 118 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 16 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 11 12 13 9 10 1 2 3 4 5 + 6 15 7 8 14 16 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 20 0 6 + 16 4 2 + 16 4 3 + 15 4 3 + 15 4 2 + 14 4 2 + 14 4 3 + 7 5 1 + 7 5 5 + 8 5 5 + 5 6 4 + 1 6 2 + 6 6 3 + 5 6 3 + 11 5 2 + 11 5 1 + 13 4 6 + 13 4 2 + 9 5 5 + 10 5 5 + 9 5 2 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 2 1 10 0 6 + 14 4 5 + 16 4 6 + 13 4 3 + 11 5 5 + 12 5 5 + 1 6 3 + 3 6 3 + 7 5 3 + 15 4 6 + 10 5 2 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/cube_tet.neu b/applications/NumPdeSpring2015/Eugenio/Ex2/input/cube_tet.neu new file mode 100644 index 000000000..e986d9fae --- /dev/null +++ b/applications/NumPdeSpring2015/Eugenio/Ex2/input/cube_tet.neu @@ -0,0 +1,75 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +cube_tet +PROGRAM: Gambit VERSION: 2.3.16 +14 Mar 2015 13:49:37 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 27 6 1 2 3 3 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 2 -5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 3 0.00000000000e+00 0.00000000000e+00 5.00000000000e-01 + 4 -5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 5 -5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 6 -5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 7 -5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 8 0.00000000000e+00 5.00000000000e-01 0.00000000000e+00 + 9 0.00000000000e+00 0.00000000000e+00 0.00000000000e+00 + 10 5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 11 0.00000000000e+00 -5.00000000000e-01 0.00000000000e+00 + 12 5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 13 0.00000000000e+00 0.00000000000e+00 -5.00000000000e-01 + 14 5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 15 0.00000000000e+00 5.00000000000e-01 5.00000000000e-01 + 16 5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 17 -5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 18 0.00000000000e+00 -5.00000000000e-01 5.00000000000e-01 + 19 5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 20 -5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 21 5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 22 5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 23 -5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 24 0.00000000000e+00 5.00000000000e-01 -5.00000000000e-01 + 25 5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 26 -5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 27 0.00000000000e+00 -5.00000000000e-01 -5.00000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 6 10 1 9 4 16 11 10 3 + 23 18 2 + 2 6 10 1 9 4 3 23 2 15 + 6 17 5 + 3 6 10 1 9 4 15 6 5 8 + 26 20 7 + 4 6 10 1 19 12 9 13 4 8 + 24 26 7 + 5 6 10 10 11 4 16 9 1 14 + 13 19 12 + 6 6 10 10 22 21 11 27 4 14 + 25 13 12 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 6 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 6 5 4 3 2 1 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 8 0 6 + 6 6 1 + 2 6 3 + 1 6 3 + 3 6 4 + 3 6 3 + 4 6 2 + 6 6 2 + 5 6 4 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 2 1 4 0 6 + 4 6 3 + 6 6 3 + 2 6 4 + 1 6 4 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/cube_wedge.neu b/applications/NumPdeSpring2015/Eugenio/Ex2/input/cube_wedge.neu new file mode 100644 index 000000000..bf416ccd2 --- /dev/null +++ b/applications/NumPdeSpring2015/Eugenio/Ex2/input/cube_wedge.neu @@ -0,0 +1,230 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +cube_wedge +PROGRAM: Gambit VERSION: 2.3.16 +14 Mar 2015 12:58:03 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 125 16 1 2 3 3 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 2 5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 3 5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 4 5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 5 5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 6 5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 7 5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 8 5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 9 5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 10 5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 11 5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 12 5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 13 5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 14 5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 15 5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 16 5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 17 5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 18 5.00000000000e-01 0.00000000000e+00 2.50000000000e-01 + 19 5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 20 5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 21 5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 22 5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 23 5.00000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 24 5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 25 5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 26 -5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 27 0.00000000000e+00 5.00000000000e-01 -5.00000000000e-01 + 28 -2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 29 2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 30 -5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 31 -5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 32 -5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 33 -5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 34 0.00000000000e+00 5.00000000000e-01 5.00000000000e-01 + 35 2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 36 -2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 37 0.00000000000e+00 5.00000000000e-01 0.00000000000e+00 + 38 0.00000000000e+00 5.00000000000e-01 -2.50000000000e-01 + 39 2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 40 2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 41 -2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 42 -2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 43 0.00000000000e+00 5.00000000000e-01 2.50000000000e-01 + 44 2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 45 -2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 46 -5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 47 -5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 48 -5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 49 -5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 50 0.00000000000e+00 -5.00000000000e-01 5.00000000000e-01 + 51 -2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 52 2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 53 0.00000000000e+00 0.00000000000e+00 5.00000000000e-01 + 54 0.00000000000e+00 -2.50000000000e-01 5.00000000000e-01 + 55 -2.50000000000e-01 0.00000000000e+00 5.00000000000e-01 + 56 -2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 57 2.50000000000e-01 0.00000000000e+00 5.00000000000e-01 + 58 2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 59 0.00000000000e+00 2.50000000000e-01 5.00000000000e-01 + 60 -2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 61 2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 62 -5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 63 0.00000000000e+00 -5.00000000000e-01 -5.00000000000e-01 + 64 2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 65 -2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 66 -5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 67 -5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 68 -5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 69 0.00000000000e+00 0.00000000000e+00 -5.00000000000e-01 + 70 -2.50000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 71 0.00000000000e+00 -2.50000000000e-01 -5.00000000000e-01 + 72 -2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 73 0.00000000000e+00 2.50000000000e-01 -5.00000000000e-01 + 74 -2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 75 2.50000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 76 2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 77 2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 78 -5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 79 -5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 80 -5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 81 0.00000000000e+00 -5.00000000000e-01 0.00000000000e+00 + 82 0.00000000000e+00 -5.00000000000e-01 -2.50000000000e-01 + 83 -2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 84 -2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 85 2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 86 2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 87 0.00000000000e+00 -5.00000000000e-01 2.50000000000e-01 + 88 -2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 89 2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 90 -5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 91 -5.00000000000e-01 0.00000000000e+00 2.50000000000e-01 + 92 -5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 93 -5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 94 -5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 95 -5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 96 -5.00000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 97 -5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 98 -5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 99 0.00000000000e+00 0.00000000000e+00 0.00000000000e+00 + 100 0.00000000000e+00 0.00000000000e+00 2.50000000000e-01 + 101 0.00000000000e+00 2.50000000000e-01 2.50000000000e-01 + 102 0.00000000000e+00 2.50000000000e-01 0.00000000000e+00 + 103 2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 104 2.50000000000e-01 0.00000000000e+00 2.50000000000e-01 + 105 2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 106 2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 107 -2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 108 -2.50000000000e-01 0.00000000000e+00 2.50000000000e-01 + 109 -2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 110 -2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 111 0.00000000000e+00 -2.50000000000e-01 2.50000000000e-01 + 112 0.00000000000e+00 -2.50000000000e-01 0.00000000000e+00 + 113 2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 114 2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 115 -2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 116 -2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 117 0.00000000000e+00 0.00000000000e+00 -2.50000000000e-01 + 118 0.00000000000e+00 2.50000000000e-01 -2.50000000000e-01 + 119 2.50000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 120 2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 121 -2.50000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 122 -2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 123 0.00000000000e+00 -2.50000000000e-01 -2.50000000000e-01 + 124 2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 125 -2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 5 18 17 18 14 19 20 11 103 + 104 57 106 105 39 99 100 + 53 102 101 37 + 2 5 18 99 100 53 102 101 37 107 + 108 55 110 109 41 90 91 + 47 93 92 31 + 3 5 18 14 16 10 20 12 11 57 + 61 35 105 44 39 53 59 + 34 101 43 37 + 4 5 18 53 59 34 101 43 37 55 + 60 36 109 45 41 47 48 + 30 92 32 31 + 5 5 18 3 4 1 21 22 17 85 + 89 52 114 113 103 81 87 + 50 112 111 99 + 6 5 18 81 87 50 112 111 99 83 + 88 51 116 115 107 78 79 + 46 95 94 90 + 7 5 18 1 15 14 22 18 17 52 + 58 57 113 104 103 50 54 + 53 111 100 99 + 8 5 18 50 54 53 111 100 99 51 + 56 55 115 108 107 46 49 + 47 94 91 90 + 9 5 18 7 23 17 8 24 6 75 + 119 103 77 120 29 69 117 + 99 73 118 27 + 10 5 18 69 117 99 73 118 27 70 + 121 107 74 122 28 66 96 + 90 68 97 26 + 11 5 18 17 19 11 24 13 6 103 + 106 39 120 40 29 99 102 + 37 118 38 27 + 12 5 18 99 102 37 118 38 27 107 + 110 41 122 42 28 90 93 + 31 97 33 26 + 13 5 18 2 5 3 9 25 7 64 + 86 85 76 124 75 63 82 + 81 71 123 69 + 14 5 18 63 82 81 71 123 69 65 + 84 83 72 125 70 62 80 + 78 67 98 66 + 15 5 18 3 21 17 25 23 7 85 + 114 103 124 119 75 81 112 + 99 123 117 69 + 16 5 18 81 112 99 123 117 69 83 + 116 107 125 121 70 78 95 + 90 98 96 66 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 16 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 5 6 7 8 9 10 + 11 12 13 14 15 16 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 24 0 6 + 14 5 1 + 13 5 1 + 6 5 1 + 5 5 1 + 2 5 5 + 4 5 5 + 6 5 5 + 8 5 5 + 10 5 5 + 12 5 5 + 14 5 5 + 16 5 5 + 11 5 2 + 12 5 2 + 3 5 2 + 4 5 2 + 1 5 4 + 3 5 4 + 5 5 4 + 7 5 4 + 9 5 4 + 11 5 4 + 13 5 4 + 15 5 4 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 2 1 8 0 6 + 14 5 3 + 10 5 3 + 13 5 3 + 9 5 3 + 8 5 1 + 7 5 1 + 4 5 1 + 3 5 1 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/cube_hex.dbs b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/cube_hex.dbs new file mode 100644 index 000000000..5e064f245 Binary files /dev/null and b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/cube_hex.dbs differ diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/cube_mixed.dbs b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/cube_mixed.dbs new file mode 100644 index 000000000..4d17a53bf Binary files /dev/null and b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/cube_mixed.dbs differ diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/cube_tet.dbs b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/cube_tet.dbs new file mode 100644 index 000000000..dd0049aae Binary files /dev/null and b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/cube_tet.dbs differ diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/cube_wedge.dbs b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/cube_wedge.dbs new file mode 100644 index 000000000..92e8b4afd Binary files /dev/null and b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/cube_wedge.dbs differ diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/default_id.dbs b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/default_id.dbs new file mode 100644 index 000000000..4b990b4a8 Binary files /dev/null and b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/default_id.dbs differ diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/square_mixed.dbs b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/square_mixed.dbs new file mode 100644 index 000000000..e890b28bc Binary files /dev/null and b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/square_mixed.dbs differ diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/square_quad.dbs b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/square_quad.dbs new file mode 100644 index 000000000..ba4d04b29 Binary files /dev/null and b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/square_quad.dbs differ diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/square_tri.dbs b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/square_tri.dbs new file mode 100644 index 000000000..41f2a376b Binary files /dev/null and b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/square_tri.dbs differ diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/tet.dbs b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/tet.dbs new file mode 100644 index 000000000..5b0b69410 Binary files /dev/null and b/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/tet.dbs differ diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/square_mixed.neu b/applications/NumPdeSpring2015/Eugenio/Ex2/input/square_mixed.neu new file mode 100644 index 000000000..4741f936d --- /dev/null +++ b/applications/NumPdeSpring2015/Eugenio/Ex2/input/square_mixed.neu @@ -0,0 +1,62 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +square_mixed +PROGRAM: Gambit VERSION: 2.3.16 +14 Mar 2015 10:14:23 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 25 6 1 1 2 2 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 5.00000000000e-01 0.00000000000e+00 + 2 -5.00000000000e-01 0.00000000000e+00 + 3 0.00000000000e+00 0.00000000000e+00 + 4 2.50000000000e-01 0.00000000000e+00 + 5 -2.50000000000e-01 0.00000000000e+00 + 6 -5.00000000000e-01 -5.00000000000e-01 + 7 -5.00000000000e-01 -2.50000000000e-01 + 8 5.00000000000e-01 -5.00000000000e-01 + 9 0.00000000000e+00 -5.00000000000e-01 + 10 -2.50000000000e-01 -5.00000000000e-01 + 11 2.50000000000e-01 -5.00000000000e-01 + 12 5.00000000000e-01 -2.50000000000e-01 + 13 0.00000000000e+00 -2.50000000000e-01 + 14 2.50000000000e-01 -2.50000000000e-01 + 15 -2.50000000000e-01 -2.50000000000e-01 + 16 5.00000000000e-01 5.00000000000e-01 + 17 5.00000000000e-01 2.50000000000e-01 + 18 -5.00000000000e-01 5.00000000000e-01 + 19 0.00000000000e+00 5.00000000000e-01 + 20 2.50000000000e-01 5.00000000000e-01 + 21 -2.50000000000e-01 5.00000000000e-01 + 22 -5.00000000000e-01 2.50000000000e-01 + 23 0.00000000000e+00 2.50000000000e-01 + 24 -2.50000000000e-01 2.50000000000e-01 + 25 2.50000000000e-01 2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 2 9 8 12 1 4 3 13 9 + 11 14 + 2 2 9 9 13 3 5 2 7 6 + 10 15 + 3 3 6 2 5 3 23 19 24 + 4 3 6 18 22 2 24 19 21 + 5 3 6 3 4 1 17 16 25 + 6 3 6 19 23 3 25 16 20 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 6 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 3 4 5 6 1 2 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 8 0 6 + 2 2 3 + 5 3 2 + 6 3 3 + 4 3 3 + 1 2 1 + 2 2 4 + 1 2 4 + 4 3 1 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/square_quad.neu b/applications/NumPdeSpring2015/Eugenio/Ex2/input/square_quad.neu new file mode 100644 index 000000000..b19922a5f --- /dev/null +++ b/applications/NumPdeSpring2015/Eugenio/Ex2/input/square_quad.neu @@ -0,0 +1,62 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +square_quad +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 15:25:47 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 25 4 1 1 2 2 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 -5.00000000000e-01 -5.00000000000e-01 + 2 5.00000000000e-01 -5.00000000000e-01 + 3 0.00000000000e+00 -5.00000000000e-01 + 4 -2.50000000000e-01 -5.00000000000e-01 + 5 2.50000000000e-01 -5.00000000000e-01 + 6 5.00000000000e-01 5.00000000000e-01 + 7 5.00000000000e-01 0.00000000000e+00 + 8 5.00000000000e-01 -2.50000000000e-01 + 9 5.00000000000e-01 2.50000000000e-01 + 10 -5.00000000000e-01 5.00000000000e-01 + 11 0.00000000000e+00 5.00000000000e-01 + 12 2.50000000000e-01 5.00000000000e-01 + 13 -2.50000000000e-01 5.00000000000e-01 + 14 -5.00000000000e-01 0.00000000000e+00 + 15 -5.00000000000e-01 2.50000000000e-01 + 16 -5.00000000000e-01 -2.50000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 + 18 0.00000000000e+00 -2.50000000000e-01 + 19 -2.50000000000e-01 0.00000000000e+00 + 20 -2.50000000000e-01 -2.50000000000e-01 + 21 2.50000000000e-01 0.00000000000e+00 + 22 2.50000000000e-01 -2.50000000000e-01 + 23 0.00000000000e+00 2.50000000000e-01 + 24 -2.50000000000e-01 2.50000000000e-01 + 25 2.50000000000e-01 2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 2 9 1 4 3 18 17 19 14 + 16 20 + 2 2 9 3 5 2 8 7 21 17 + 18 22 + 3 2 9 14 19 17 23 11 13 10 + 15 24 + 4 2 9 17 21 7 9 6 12 11 + 23 25 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 4 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 8 0 6 + 4 2 3 + 3 2 3 + 2 2 2 + 4 2 2 + 1 2 1 + 2 2 1 + 3 2 4 + 1 2 4 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/square_tri.neu b/applications/NumPdeSpring2015/Eugenio/Ex2/input/square_tri.neu new file mode 100644 index 000000000..089a3366c --- /dev/null +++ b/applications/NumPdeSpring2015/Eugenio/Ex2/input/square_tri.neu @@ -0,0 +1,62 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +square_tri +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 15:31:40 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 25 8 1 1 2 2 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 -5.00000000000e-01 -5.00000000000e-01 + 2 5.00000000000e-01 -5.00000000000e-01 + 3 0.00000000000e+00 -5.00000000000e-01 + 4 -2.50000000000e-01 -5.00000000000e-01 + 5 2.50000000000e-01 -5.00000000000e-01 + 6 5.00000000000e-01 5.00000000000e-01 + 7 5.00000000000e-01 0.00000000000e+00 + 8 5.00000000000e-01 -2.50000000000e-01 + 9 5.00000000000e-01 2.50000000000e-01 + 10 -5.00000000000e-01 5.00000000000e-01 + 11 0.00000000000e+00 5.00000000000e-01 + 12 2.50000000000e-01 5.00000000000e-01 + 13 -2.50000000000e-01 5.00000000000e-01 + 14 -5.00000000000e-01 0.00000000000e+00 + 15 -5.00000000000e-01 2.50000000000e-01 + 16 -5.00000000000e-01 -2.50000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 + 18 0.00000000000e+00 -2.50000000000e-01 + 19 -2.50000000000e-01 0.00000000000e+00 + 20 -2.50000000000e-01 -2.50000000000e-01 + 21 2.50000000000e-01 0.00000000000e+00 + 22 2.50000000000e-01 -2.50000000000e-01 + 23 0.00000000000e+00 2.50000000000e-01 + 24 -2.50000000000e-01 2.50000000000e-01 + 25 2.50000000000e-01 2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 3 6 3 18 17 19 14 20 + 2 3 6 1 4 3 20 14 16 + 3 3 6 2 8 7 21 17 22 + 4 3 6 3 5 2 22 17 18 + 5 3 6 17 23 11 13 10 24 + 6 3 6 14 19 17 24 10 15 + 7 3 6 7 9 6 12 11 25 + 8 3 6 17 21 7 25 11 23 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 8 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 5 6 7 8 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 8 0 6 + 7 3 2 + 5 3 2 + 3 3 1 + 7 3 1 + 2 3 1 + 4 3 1 + 6 3 3 + 2 3 3 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Giacomo/Ex1/Ex1.cpp b/applications/NumPdeSpring2015/Giacomo/Ex1/Ex1.cpp index 0c5eaf37d..04b5866c5 100644 --- a/applications/NumPdeSpring2015/Giacomo/Ex1/Ex1.cpp +++ b/applications/NumPdeSpring2015/Giacomo/Ex1/Ex1.cpp @@ -69,13 +69,13 @@ int main(int argc, char **args) { variablesToBePrinted.push_back("P"); variablesToBePrinted.push_back("T"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); + GMVWriter gmvIO(&mlSol); variablesToBePrinted.push_back("all"); gmvIO.SetDebugOutput(false); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); return 0; } diff --git a/applications/NumPdeSpring2015/Giacomo/Ex2/Ex2.cpp b/applications/NumPdeSpring2015/Giacomo/Ex2/Ex2.cpp index ac0b0e406..cc59a3e31 100644 --- a/applications/NumPdeSpring2015/Giacomo/Ex2/Ex2.cpp +++ b/applications/NumPdeSpring2015/Giacomo/Ex2/Ex2.cpp @@ -79,12 +79,12 @@ int main(int argc, char **args) { std::vector < std::string > variablesToBePrinted; variablesToBePrinted.push_back("All"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); + GMVWriter gmvIO(&mlSol); gmvIO.SetDebugOutput(true); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); return 0; } diff --git a/applications/NumPdeSpring2015/Guoyi/CMakeLists.txt b/applications/NumPdeSpring2015/Guoyi/CMakeLists.txt index 482fcd056..93239845e 100644 --- a/applications/NumPdeSpring2015/Guoyi/CMakeLists.txt +++ b/applications/NumPdeSpring2015/Guoyi/CMakeLists.txt @@ -6,4 +6,7 @@ ADD_SUBDIRECTORY(${EXAMPLE_NUMBER}) set(EXAMPLE_NUMBER Ex2) ADD_SUBDIRECTORY(${EXAMPLE_NUMBER}) +set(EXAMPLE_NUMBER Ex3) +ADD_SUBDIRECTORY(${EXAMPLE_NUMBER}) + unset(EXAMPLE_NUMBER) diff --git a/applications/NumPdeSpring2015/Guoyi/Ex1/Ex1.cpp b/applications/NumPdeSpring2015/Guoyi/Ex1/Ex1.cpp index 0c5eaf37d..04b5866c5 100644 --- a/applications/NumPdeSpring2015/Guoyi/Ex1/Ex1.cpp +++ b/applications/NumPdeSpring2015/Guoyi/Ex1/Ex1.cpp @@ -69,13 +69,13 @@ int main(int argc, char **args) { variablesToBePrinted.push_back("P"); variablesToBePrinted.push_back("T"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); + GMVWriter gmvIO(&mlSol); variablesToBePrinted.push_back("all"); gmvIO.SetDebugOutput(false); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); return 0; } diff --git a/applications/NumPdeSpring2015/Guoyi/Ex2/Ex2.cpp b/applications/NumPdeSpring2015/Guoyi/Ex2/Ex2.cpp index ac0b0e406..24a5e0be6 100644 --- a/applications/NumPdeSpring2015/Guoyi/Ex2/Ex2.cpp +++ b/applications/NumPdeSpring2015/Guoyi/Ex2/Ex2.cpp @@ -25,71 +25,128 @@ bool SetBoundaryCondition(const double &x, const double &y, const double &z,cons void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix); +double GetErrorNorm(MultiLevelSolution *mlSol); int main(int argc, char **args) { // init Petsc-MPI communicator FemusInit mpinit(argc, args, MPI_COMM_WORLD); - - // define multilevel mesh + + + // define multilevel mesh MultiLevelMesh mlMsh; // read coarse level mesh and generate finers level meshes double scalingFactor=1.; - mlMsh.ReadCoarseMesh("./input/square.neu","seventh",scalingFactor); + mlMsh.ReadCoarseMesh("./input/square_quad.neu","seventh",scalingFactor); /* "seventh" is the order of accuracy that is used in the gauss integration scheme - probably in the furure it is not going to be an argument of this function */ - unsigned numberOfUniformLevels=2; - unsigned numberOfSelectiveLevels=0; - mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL); + probably in the furure it is not going to be an argument of this function */ - // erase all the coarse mesh levels - mlMsh.EraseCoarseLevels(numberOfUniformLevels-1); + unsigned maxNumberOfMeshes = 7; + vector < vector < double > > semiNorm; + semiNorm.resize(maxNumberOfMeshes); - // print mesh info - mlMsh.PrintInfo(); + for(unsigned i = 0; i < maxNumberOfMeshes; i++){ // loop on the mesh level + + unsigned numberOfUniformLevels = i+1; + unsigned numberOfSelectiveLevels = 0; + mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL); - // define the multilevel solution and attach the mlMsh object to it - MultiLevelSolution mlSol(&mlMsh); + // erase all the coarse mesh levels + mlMsh.EraseCoarseLevels(numberOfUniformLevels-1); - // add variables to mlSol - mlSol.AddSolution("u",LAGRANGE, FIRST); - mlSol.Initialize("All"); + // print mesh info + mlMsh.PrintInfo(); - // attach the boundary condition function and generate boundary data - mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition); - mlSol.GenerateBdc("u"); + FEOrder feOrder[3] = {FIRST, SERENDIPITY, SECOND}; + semiNorm[i].resize(3); + + for(unsigned j=0; j<3; j++){ // loop on the FE Order + // define the multilevel solution and attach the mlMsh object to it + MultiLevelSolution mlSol(&mlMsh); + + // add variables to mlSol + mlSol.AddSolution("u",LAGRANGE, feOrder[j]); + mlSol.Initialize("All"); - // define the multilevel problem attach the mlSol object to it - MultiLevelProblem mlProb(&mlSol); + // attach the boundary condition function and generate boundary data + mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition); + mlSol.GenerateBdc("u"); - // add system Poisson in mlProb as a Linear Implicit System - LinearImplicitSystem & system = mlProb.add_system < LinearImplicitSystem > ("Poisson"); + // define the multilevel problem attach the mlSol object to it + MultiLevelProblem mlProb(&mlSol); + + // add system Poisson in mlProb as a Linear Implicit System + LinearImplicitSystem & system = mlProb.add_system < LinearImplicitSystem > ("Poisson"); - // add solution "u" to system - system.AddSolutionToSystemPDE("u"); + // add solution "u" to system + system.AddSolutionToSystemPDE("u"); - // attach the assembling function to system - system.SetAssembleFunction(AssemblePoissonProblem); + // attach the assembling function to system + system.SetAssembleFunction(AssemblePoissonProblem); - // initilaize and solve the system - system.init(); - system.solve(); + // initilaize and solve the system + system.init(); + system.solve(); - // print solutions - std::vector < std::string > variablesToBePrinted; - variablesToBePrinted.push_back("All"); + semiNorm[i][j] = GetErrorNorm(&mlSol); + // print solutions + std::vector < std::string > variablesToBePrinted; + variablesToBePrinted.push_back("All"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); - gmvIO.SetDebugOutput(true); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - + GMVWriter gmvIO(&mlSol); + gmvIO.SetDebugOutput(true); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + } + } + + // print the seminorm of the error and the order of convergence between different levels + std::cout< &x){ + double pi=acos(-1.); + return cos(pi*x[0])*cos(pi*x[1]); +}; + + +void GetSolutionGradient(const vector < double > &x, vector < double > &solGrad){ + double pi=acos(-1.); + solGrad[0] = -pi*sin(pi*x[0])*cos(pi*x[1]); + solGrad[1] = -pi*cos(pi*x[0])*sin(pi*x[1]); +}; + + +double GetSolutionLaplace(const vector < double > &x){ + double pi=acos(-1.); + return -pi*pi*cos(pi*x[0])*cos(pi*x[1]) - pi*pi*cos(pi*x[0])*cos(pi*x[1]); +}; + /** * This function assemble the stiffnes matrix KK and the residual vector Res * such that @@ -97,7 +154,6 @@ int main(int argc, char **args) { * and consequently * u = u0 + w satisfies KK u = F **/ - void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix) { // ml_prob is the global object from/to where get/set all the data // level is the level of the PDE system to be assembled @@ -221,7 +277,7 @@ void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const un for(unsigned jdim=0; jdim_ml_msh->GetNumberOfLevels()-1u; + // extract pointers to the several objects that we are going to use + Mesh* msh = mlSol->_ml_msh->GetLevel(level); // pointer to the mesh (level) object + elem* el = msh->el; // pointer to the elem object in msh (level) + Solution* sol = mlSol->GetSolutionLevel(level); // pointer to the solution (level) object + + const unsigned dim = msh->GetDimension(); // get the domain dimension of the problem + unsigned iproc = msh->processor_id(); // get the process_id (for parallel computation) + + //solution variable + unsigned soluIndex; + soluIndex = mlSol->GetIndex("u"); // get the position of "u" in the ml_sol object + unsigned soluType = mlSol->GetSolutionType(soluIndex); // get the finite element type for "u" + + vector < double > solu; // local solution + + vector < vector < double > > x(dim); // local coordinates + unsigned xType = 2; // get the finite element type for "x", it is always 2 (LAGRANGE QUADRATIC) + vector phi; // local test function + vector phi_x; // local test function first order partial derivatives + vector phi_xx; // local test function second order partial derivatives + double weight; // gauss point weight + + // reserve memory for the local standar vectors + const unsigned maxSize = static_cast< unsigned > (ceil(pow(3,dim))); // conservative: based on line3, quad9, hex27 + solu.reserve(maxSize); + for(unsigned i = 0; i < dim; i++) + x[i].reserve(maxSize); + phi.reserve(maxSize); + phi_x.reserve(maxSize*dim); + unsigned dim2=(3*(dim-1)+!(dim-1)); // dim2 is the number of second order partial derivatives (1,3,6 depending on the dimension) + phi_xx.reserve(maxSize*dim2); + + double seminorm = 0.; + double L2norm = 0; + // element loop: each process loops only on the elements that owns + for (int iel=msh->IS_Mts2Gmt_elem_offset[iproc]; iel < msh->IS_Mts2Gmt_elem_offset[iproc+1]; iel++) { + + unsigned kel = msh->IS_Mts2Gmt_elem[iel]; // mapping between paralell dof and mesh dof + short unsigned kelGeom = el->GetElementType( kel ); // element geometry type + unsigned nDofs = el->GetElementDofNumber( kel, soluType); // number of solution element dofs + unsigned nDofs2 = el->GetElementDofNumber( kel, xType); // number of coordinate element dofs + + // resize local arrays + solu.resize(nDofs); + for(int i=0; iGetMeshDof(kel, i, soluType); // local to global solution node + unsigned solDof = msh->GetMetisDof(iNode, soluType); // global to global mapping between solution node and solution dof + solu[i] = (*sol->_Sol[soluIndex])(solDof); // global extraction and local storage for the solution + } + + // local storage of coordinates + for( unsigned i=0; iGetMeshDof(kel, i, xType); // local to global coordinates node + unsigned xDof = msh->GetMetisDof(iNode, xType); // global to global mapping between coordinates node and coordinate dof + for(unsigned jdim=0; jdim_coordinate->_Sol[jdim])(xDof); // global extraction and local storage for the element coordinates + } + } + + // *** Gauss point loop *** + for(unsigned ig=0; ig < msh->_finiteElement[kelGeom][soluType]->GetGaussPointNumber(); ig++) { + // *** get gauss point weight, test function and test function partial derivatives *** + msh->_finiteElement[kelGeom][soluType]->Jacobian(x,ig,weight,phi,phi_x,phi_xx); + + // evaluate the solution, the solution derivatives and the coordinates in the gauss point + double soluGauss = 0; + vector < double > soluGauss_x(dim,0.); + vector < double > xGauss(dim,0.); + + for(unsigned i=0; i solGrad(dim); + GetSolutionGradient(xGauss, solGrad); + for (unsigned j=0;j n_processors()) { + seminorm_vec->init(msh->n_processors(), 1, false, SERIAL); + } + else { + seminorm_vec->init(msh->n_processors(), 1 , false, PARALLEL); + } + + seminorm_vec->set(iproc, seminorm); + seminorm_vec->close(); + seminorm=seminorm_vec->l1_norm(); + + delete seminorm_vec; + + //return sqrt(seminorm); + return(sqrt(L2norm)); + +} diff --git a/applications/NumPdeSpring2015/Guoyi/Ex2/input/cube_hex.neu b/applications/NumPdeSpring2015/Guoyi/Ex2/input/cube_hex.neu new file mode 100644 index 000000000..54d6ccea1 --- /dev/null +++ b/applications/NumPdeSpring2015/Guoyi/Ex2/input/cube_hex.neu @@ -0,0 +1,205 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +cube_hex +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 15:58:49 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 125 8 1 2 3 3 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 2 5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 3 5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 4 5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 5 5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 6 -5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 7 0.00000000000e+00 5.00000000000e-01 5.00000000000e-01 + 8 2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 9 -2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 10 -5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 11 -5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 12 -5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 13 -5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 14 0.00000000000e+00 -5.00000000000e-01 5.00000000000e-01 + 15 -2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 16 2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 5.00000000000e-01 + 18 2.50000000000e-01 0.00000000000e+00 5.00000000000e-01 + 19 0.00000000000e+00 -2.50000000000e-01 5.00000000000e-01 + 20 2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 21 0.00000000000e+00 2.50000000000e-01 5.00000000000e-01 + 22 2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 23 -2.50000000000e-01 0.00000000000e+00 5.00000000000e-01 + 24 -2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 25 -2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 26 5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 27 5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 28 5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 29 5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 30 5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 31 -5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 32 0.00000000000e+00 -5.00000000000e-01 -5.00000000000e-01 + 33 2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 34 -2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 35 -5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 36 -5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 37 -5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 38 -5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 39 0.00000000000e+00 5.00000000000e-01 -5.00000000000e-01 + 40 -2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 41 2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 42 0.00000000000e+00 0.00000000000e+00 -5.00000000000e-01 + 43 2.50000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 44 0.00000000000e+00 2.50000000000e-01 -5.00000000000e-01 + 45 2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 46 0.00000000000e+00 -2.50000000000e-01 -5.00000000000e-01 + 47 2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 48 -2.50000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 49 -2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 50 -2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 51 -5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 52 -5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 53 -5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 54 5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 55 5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 56 5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 57 0.00000000000e+00 -5.00000000000e-01 0.00000000000e+00 + 58 0.00000000000e+00 -5.00000000000e-01 2.50000000000e-01 + 59 2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 60 2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 61 -2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 62 -2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 63 0.00000000000e+00 -5.00000000000e-01 -2.50000000000e-01 + 64 2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 65 -2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 66 -5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 67 -5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 68 -5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 69 -5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 70 -5.00000000000e-01 0.00000000000e+00 2.50000000000e-01 + 71 -5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 72 -5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 73 -5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 74 -5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 75 -5.00000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 76 -5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 77 -5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 78 5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 79 5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 80 5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 81 0.00000000000e+00 5.00000000000e-01 0.00000000000e+00 + 82 0.00000000000e+00 5.00000000000e-01 2.50000000000e-01 + 83 -2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 84 -2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 85 2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 86 2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 87 0.00000000000e+00 5.00000000000e-01 -2.50000000000e-01 + 88 -2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 89 2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 90 5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 91 5.00000000000e-01 0.00000000000e+00 2.50000000000e-01 + 92 5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 93 5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 94 5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 95 5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 96 5.00000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 97 5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 98 5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 99 0.00000000000e+00 0.00000000000e+00 0.00000000000e+00 + 100 2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 101 0.00000000000e+00 0.00000000000e+00 2.50000000000e-01 + 102 0.00000000000e+00 -2.50000000000e-01 0.00000000000e+00 + 103 2.50000000000e-01 0.00000000000e+00 2.50000000000e-01 + 104 2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 105 0.00000000000e+00 -2.50000000000e-01 2.50000000000e-01 + 106 2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 107 0.00000000000e+00 2.50000000000e-01 0.00000000000e+00 + 108 2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 109 0.00000000000e+00 2.50000000000e-01 2.50000000000e-01 + 110 2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 111 0.00000000000e+00 0.00000000000e+00 -2.50000000000e-01 + 112 2.50000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 113 0.00000000000e+00 -2.50000000000e-01 -2.50000000000e-01 + 114 2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 115 0.00000000000e+00 2.50000000000e-01 -2.50000000000e-01 + 116 2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 117 -2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 118 -2.50000000000e-01 0.00000000000e+00 2.50000000000e-01 + 119 -2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 120 -2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 121 -2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 122 -2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 123 -2.50000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 124 -2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 125 -2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 4 27 1 4 3 55 95 91 54 + 94 90 16 20 18 60 106 + 103 59 104 100 14 19 17 + 58 105 101 57 102 99 + 2 4 27 3 5 2 91 93 79 90 + 92 78 18 22 8 103 110 + 86 100 108 85 17 21 7 + 101 109 82 99 107 81 + 3 4 27 54 94 90 56 98 96 27 + 30 28 59 104 100 64 114 + 112 33 47 43 57 102 99 + 63 113 111 32 46 42 + 4 4 27 90 92 78 96 97 80 28 + 29 26 100 108 85 112 116 + 89 43 45 41 99 107 81 + 111 115 87 42 44 39 + 5 4 27 14 19 17 58 105 101 57 + 102 99 15 24 23 62 120 + 118 61 119 117 10 13 11 + 52 72 70 51 71 69 + 6 4 27 17 21 7 101 109 82 99 + 107 81 23 25 9 118 122 + 84 117 121 83 11 12 6 + 70 74 67 69 73 66 + 7 4 27 57 102 99 63 113 111 32 + 46 42 61 119 117 65 124 + 123 34 50 48 51 71 69 + 53 76 75 31 37 36 + 8 4 27 99 107 81 111 115 87 42 + 44 39 117 121 83 123 125 + 88 48 49 40 69 73 66 + 75 77 68 36 38 35 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 8 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 5 6 7 8 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 16 0 6 + 1 4 4 + 5 4 4 + 3 4 4 + 7 4 4 + 5 4 6 + 6 4 6 + 7 4 6 + 8 4 6 + 6 4 2 + 2 4 2 + 8 4 2 + 4 4 2 + 2 4 5 + 1 4 5 + 4 4 5 + 3 4 5 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 2 1 8 0 6 + 4 4 3 + 3 4 3 + 8 4 3 + 7 4 3 + 1 4 1 + 2 4 1 + 5 4 1 + 6 4 1 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Guoyi/Ex2/input/cube_mixed.neu b/applications/NumPdeSpring2015/Guoyi/Ex2/input/cube_mixed.neu new file mode 100644 index 000000000..b2a2c91b3 --- /dev/null +++ b/applications/NumPdeSpring2015/Guoyi/Ex2/input/cube_mixed.neu @@ -0,0 +1,208 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +cube_mixed +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 16:36:18 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 125 16 2 2 3 3 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 2 5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 3 5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 4 5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 5 5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 6 5.00000000000e-01 -3.06161699787e-17 5.00000000000e-01 + 7 5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 8 5.00000000000e-01 -1.53080849893e-17 2.50000000000e-01 + 9 5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 10 0.00000000000e+00 0.00000000000e+00 0.00000000000e+00 + 11 -3.06161699787e-17 -3.06161699787e-17 5.00000000000e-01 + 12 -1.53080849893e-17 -1.53080849893e-17 2.50000000000e-01 + 13 2.50000000000e-01 -3.06161699787e-17 5.00000000000e-01 + 14 2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 15 2.50000000000e-01 -1.53080849893e-17 2.50000000000e-01 + 16 -3.06161699787e-17 5.00000000000e-01 5.00000000000e-01 + 17 -3.06161699787e-17 2.50000000000e-01 5.00000000000e-01 + 18 2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 19 2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 20 0.00000000000e+00 5.00000000000e-01 0.00000000000e+00 + 21 -1.53080849893e-17 5.00000000000e-01 2.50000000000e-01 + 22 2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 23 2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 24 0.00000000000e+00 2.50000000000e-01 0.00000000000e+00 + 25 2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 26 -1.53080849893e-17 2.50000000000e-01 2.50000000000e-01 + 27 2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 28 -5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 29 -2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 30 -5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 31 -5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 32 -2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 33 -2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 34 -5.00000000000e-01 -3.06161699787e-17 5.00000000000e-01 + 35 -5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 36 -2.50000000000e-01 -3.06161699787e-17 5.00000000000e-01 + 37 -2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 38 -5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 39 -2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 40 -5.00000000000e-01 -1.53080849893e-17 2.50000000000e-01 + 41 -2.50000000000e-01 -1.53080849893e-17 2.50000000000e-01 + 42 -5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 43 -2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 44 -5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 45 -2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 46 -3.06161699787e-17 -5.00000000000e-01 5.00000000000e-01 + 47 -3.06161699787e-17 -2.50000000000e-01 5.00000000000e-01 + 48 5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 49 2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 50 5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 51 2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 52 0.00000000000e+00 -5.00000000000e-01 0.00000000000e+00 + 53 0.00000000000e+00 -2.50000000000e-01 0.00000000000e+00 + 54 5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 55 2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 56 5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 57 2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 58 5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 59 5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 60 -1.53080849893e-17 -5.00000000000e-01 2.50000000000e-01 + 61 -1.53080849893e-17 -2.50000000000e-01 2.50000000000e-01 + 62 2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 63 2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 64 3.06161699787e-17 3.06161699787e-17 -5.00000000000e-01 + 65 1.53080849893e-17 1.53080849893e-17 -2.50000000000e-01 + 66 5.00000000000e-01 3.06161699787e-17 -5.00000000000e-01 + 67 5.00000000000e-01 1.53080849893e-17 -2.50000000000e-01 + 68 2.50000000000e-01 3.06161699787e-17 -5.00000000000e-01 + 69 2.50000000000e-01 1.53080849893e-17 -2.50000000000e-01 + 70 3.06161699787e-17 5.00000000000e-01 -5.00000000000e-01 + 71 1.53080849893e-17 5.00000000000e-01 -2.50000000000e-01 + 72 5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 73 5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 74 2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 75 2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 76 5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 77 5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 78 3.06161699787e-17 2.50000000000e-01 -5.00000000000e-01 + 79 1.53080849893e-17 2.50000000000e-01 -2.50000000000e-01 + 80 2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 81 2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 82 -5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 83 -5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 84 -2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 85 -2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 86 -5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 87 -5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 88 -2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 89 -2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 90 -5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 91 -2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 92 -5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 93 -2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 94 -5.00000000000e-01 3.06161699787e-17 -5.00000000000e-01 + 95 -2.50000000000e-01 3.06161699787e-17 -5.00000000000e-01 + 96 -5.00000000000e-01 1.53080849893e-17 -2.50000000000e-01 + 97 -2.50000000000e-01 1.53080849893e-17 -2.50000000000e-01 + 98 -5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 99 -2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 100 -5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 101 -2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 102 -5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 103 -2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 104 -5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 105 -2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 106 3.06161699787e-17 -5.00000000000e-01 -5.00000000000e-01 + 107 3.06161699787e-17 -2.50000000000e-01 -5.00000000000e-01 + 108 1.53080849893e-17 -5.00000000000e-01 -2.50000000000e-01 + 109 1.53080849893e-17 -2.50000000000e-01 -2.50000000000e-01 + 110 5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 111 5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 112 5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 113 5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 114 2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 115 2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 116 2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 117 2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 118 -5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 119 -5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 120 -2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 121 -2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 122 -5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 123 -2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 124 -5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 125 -2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 6 10 20 21 16 27 19 6 23 + 18 7 4 + 2 6 10 20 27 6 26 13 11 24 + 15 12 10 + 3 6 10 20 21 16 26 17 11 27 + 19 13 6 + 4 6 10 20 25 1 27 8 6 24 + 14 15 10 + 5 6 10 20 25 1 22 3 2 23 + 9 5 4 + 6 6 10 20 25 1 23 9 4 27 + 8 7 6 + 7 5 18 16 21 20 17 26 11 32 + 33 29 37 45 36 30 31 + 28 35 44 34 + 8 5 18 11 26 20 12 24 10 36 + 45 29 41 43 39 34 44 + 28 40 42 38 + 9 5 18 10 14 1 15 8 6 53 + 57 56 63 59 50 52 55 + 54 62 58 48 + 10 5 18 10 15 6 12 13 11 53 + 63 50 61 51 47 52 62 + 48 60 49 46 + 11 5 18 20 22 2 25 3 1 71 + 75 73 81 77 67 70 74 + 72 80 76 66 + 12 5 18 20 25 1 24 14 10 71 + 81 67 79 69 65 70 80 + 66 78 68 64 + 13 4 27 10 39 38 53 89 87 52 + 88 86 12 41 40 61 93 + 92 60 91 90 11 36 34 + 47 85 83 46 84 82 + 14 4 27 20 29 28 71 101 100 70 + 99 98 24 43 42 79 105 + 104 78 103 102 10 39 38 + 65 97 96 64 95 94 + 15 4 27 64 65 10 107 109 53 106 + 108 52 68 69 14 115 117 + 57 114 116 55 66 67 1 + 112 113 56 110 111 54 + 16 4 27 64 65 10 95 97 39 94 + 96 38 107 109 53 123 125 + 89 122 124 87 106 108 52 + 120 121 88 118 119 86 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 1 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 16 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 2 ELEMENTS: 15 MATERIAL: 2 NFLAGS: 1 + fluid + 0 + 15 11 12 9 10 1 2 3 4 5 + 6 13 7 8 14 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 4 0 6 + 16 4 6 + 14 4 2 + 14 4 5 + 15 4 6 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 2 1 2 0 6 + 14 4 3 + 10 5 2 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Guoyi/Ex2/input/gambit/cube_hex.dbs b/applications/NumPdeSpring2015/Guoyi/Ex2/input/gambit/cube_hex.dbs new file mode 100644 index 000000000..c28ae1819 Binary files /dev/null and b/applications/NumPdeSpring2015/Guoyi/Ex2/input/gambit/cube_hex.dbs differ diff --git a/applications/NumPdeSpring2015/Guoyi/Ex2/input/gambit/cube_mixed.dbs b/applications/NumPdeSpring2015/Guoyi/Ex2/input/gambit/cube_mixed.dbs new file mode 100644 index 000000000..25f265cd6 Binary files /dev/null and b/applications/NumPdeSpring2015/Guoyi/Ex2/input/gambit/cube_mixed.dbs differ diff --git a/applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/square.dbs b/applications/NumPdeSpring2015/Guoyi/Ex2/input/gambit/square_quad.dbs similarity index 52% rename from applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/square.dbs rename to applications/NumPdeSpring2015/Guoyi/Ex2/input/gambit/square_quad.dbs index ac2d8f225..0c6d78ccc 100644 Binary files a/applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/square.dbs and b/applications/NumPdeSpring2015/Guoyi/Ex2/input/gambit/square_quad.dbs differ diff --git a/applications/NumPdeSpring2015/Guoyi/Ex2/input/gambit/square_tri.dbs b/applications/NumPdeSpring2015/Guoyi/Ex2/input/gambit/square_tri.dbs new file mode 100644 index 000000000..8cd14a9f3 Binary files /dev/null and b/applications/NumPdeSpring2015/Guoyi/Ex2/input/gambit/square_tri.dbs differ diff --git a/applications/NumPdeSpring2015/Guoyi/Ex2/input/square_quad.neu b/applications/NumPdeSpring2015/Guoyi/Ex2/input/square_quad.neu new file mode 100644 index 000000000..973909493 --- /dev/null +++ b/applications/NumPdeSpring2015/Guoyi/Ex2/input/square_quad.neu @@ -0,0 +1,62 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +square_quad +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 15:29:39 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 25 4 1 1 2 2 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 -5.00000000000e-01 -5.00000000000e-01 + 2 5.00000000000e-01 -5.00000000000e-01 + 3 0.00000000000e+00 -5.00000000000e-01 + 4 -2.50000000000e-01 -5.00000000000e-01 + 5 2.50000000000e-01 -5.00000000000e-01 + 6 5.00000000000e-01 5.00000000000e-01 + 7 5.00000000000e-01 0.00000000000e+00 + 8 5.00000000000e-01 -2.50000000000e-01 + 9 5.00000000000e-01 2.50000000000e-01 + 10 -5.00000000000e-01 5.00000000000e-01 + 11 0.00000000000e+00 5.00000000000e-01 + 12 2.50000000000e-01 5.00000000000e-01 + 13 -2.50000000000e-01 5.00000000000e-01 + 14 -5.00000000000e-01 0.00000000000e+00 + 15 -5.00000000000e-01 2.50000000000e-01 + 16 -5.00000000000e-01 -2.50000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 + 18 0.00000000000e+00 2.50000000000e-01 + 19 2.50000000000e-01 0.00000000000e+00 + 20 2.50000000000e-01 2.50000000000e-01 + 21 -2.50000000000e-01 0.00000000000e+00 + 22 -2.50000000000e-01 2.50000000000e-01 + 23 0.00000000000e+00 -2.50000000000e-01 + 24 2.50000000000e-01 -2.50000000000e-01 + 25 -2.50000000000e-01 -2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 2 9 6 12 11 18 17 19 7 + 9 20 + 2 2 9 11 13 10 15 14 21 17 + 18 22 + 3 2 9 7 19 17 23 3 5 2 + 8 24 + 4 2 9 17 21 14 16 1 4 3 + 23 25 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 4 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 8 0 6 + 1 2 1 + 2 2 1 + 3 2 4 + 1 2 4 + 4 2 3 + 3 2 3 + 2 2 2 + 4 2 2 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Guoyi/Ex2/input/square_tri.neu b/applications/NumPdeSpring2015/Guoyi/Ex2/input/square_tri.neu new file mode 100644 index 000000000..f2dc29b8c --- /dev/null +++ b/applications/NumPdeSpring2015/Guoyi/Ex2/input/square_tri.neu @@ -0,0 +1,62 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +square_tri +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 15:33:24 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 25 8 1 1 2 2 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 -5.00000000000e-01 -5.00000000000e-01 + 2 5.00000000000e-01 -5.00000000000e-01 + 3 0.00000000000e+00 -5.00000000000e-01 + 4 -2.50000000000e-01 -5.00000000000e-01 + 5 2.50000000000e-01 -5.00000000000e-01 + 6 5.00000000000e-01 5.00000000000e-01 + 7 5.00000000000e-01 0.00000000000e+00 + 8 5.00000000000e-01 -2.50000000000e-01 + 9 5.00000000000e-01 2.50000000000e-01 + 10 -5.00000000000e-01 5.00000000000e-01 + 11 0.00000000000e+00 5.00000000000e-01 + 12 2.50000000000e-01 5.00000000000e-01 + 13 -2.50000000000e-01 5.00000000000e-01 + 14 -5.00000000000e-01 0.00000000000e+00 + 15 -5.00000000000e-01 2.50000000000e-01 + 16 -5.00000000000e-01 -2.50000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 + 18 0.00000000000e+00 -2.50000000000e-01 + 19 -2.50000000000e-01 0.00000000000e+00 + 20 -2.50000000000e-01 -2.50000000000e-01 + 21 2.50000000000e-01 0.00000000000e+00 + 22 2.50000000000e-01 -2.50000000000e-01 + 23 0.00000000000e+00 2.50000000000e-01 + 24 -2.50000000000e-01 2.50000000000e-01 + 25 2.50000000000e-01 2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 3 6 3 18 17 19 14 20 + 2 3 6 1 4 3 20 14 16 + 3 3 6 2 8 7 21 17 22 + 4 3 6 3 5 2 22 17 18 + 5 3 6 17 23 11 13 10 24 + 6 3 6 14 19 17 24 10 15 + 7 3 6 7 9 6 12 11 25 + 8 3 6 17 21 7 25 11 23 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 8 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 5 6 7 8 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 8 0 6 + 7 3 2 + 5 3 2 + 3 3 1 + 7 3 1 + 2 3 1 + 4 3 1 + 6 3 3 + 2 3 3 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Guoyi/Ex3/CMakeLists.txt b/applications/NumPdeSpring2015/Guoyi/Ex3/CMakeLists.txt new file mode 100644 index 000000000..78ece9e49 --- /dev/null +++ b/applications/NumPdeSpring2015/Guoyi/Ex3/CMakeLists.txt @@ -0,0 +1,9 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +SET (PROJECT_NAME "${MYNAME_FOLDER}${EXAMPLE_NUMBER}") +PROJECT(PROJECT_NAME) + +SET(MAIN_FILE "${EXAMPLE_NUMBER}") # the name of the source file with no extension +SET(EXEC_FILE "${MYNAME_FOLDER}${EXAMPLE_NUMBER}") # the name of the executable file + +femusMacroBuildApplication(${MAIN_FILE} ${EXEC_FILE}) diff --git a/applications/NumPdeSpring2015/Guoyi/Ex3/Ex3.cpp b/applications/NumPdeSpring2015/Guoyi/Ex3/Ex3.cpp new file mode 100644 index 000000000..cc59a3e31 --- /dev/null +++ b/applications/NumPdeSpring2015/Guoyi/Ex3/Ex3.cpp @@ -0,0 +1,255 @@ +/** tutorial/Ex2 + * This example shows how to set and solve the weak form of the Poisson problem + * $$ \Delta u = 1 \text{ on }\Omega, $$ + * $$ u=0 \text{ on } \Gamma, $$ + * on a square domain $\Omega$ with boundary $\Gamma$; + * all the coarse-level meshes are removed; + * a multilevel problem and an equation system are initialized; + * a direct solver is used to solve the problem. + **/ + +#include "FemusInit.hpp" +#include "MultiLevelProblem.hpp" +#include "NumericVector.hpp" +#include "VTKWriter.hpp" +#include "GMVWriter.hpp" +#include "LinearImplicitSystem.hpp" + +using namespace femus; + +bool SetBoundaryCondition(const double &x, const double &y, const double &z,const char name[], double &value, const int facename, const double time) { + bool dirichlet=1; //dirichlet + value=0.; + return dirichlet; +} + +void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix); + + +int main(int argc, char **args) { + + // init Petsc-MPI communicator + FemusInit mpinit(argc, args, MPI_COMM_WORLD); + + // define multilevel mesh + MultiLevelMesh mlMsh; + // read coarse level mesh and generate finers level meshes + double scalingFactor=1.; + mlMsh.ReadCoarseMesh("./input/square.neu","seventh",scalingFactor); + /* "seventh" is the order of accuracy that is used in the gauss integration scheme + probably in the furure it is not going to be an argument of this function */ + unsigned numberOfUniformLevels=2; + unsigned numberOfSelectiveLevels=0; + mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL); + + // erase all the coarse mesh levels + mlMsh.EraseCoarseLevels(numberOfUniformLevels-1); + + // print mesh info + mlMsh.PrintInfo(); + + // define the multilevel solution and attach the mlMsh object to it + MultiLevelSolution mlSol(&mlMsh); + + // add variables to mlSol + mlSol.AddSolution("u",LAGRANGE, FIRST); + mlSol.Initialize("All"); + + // attach the boundary condition function and generate boundary data + mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition); + mlSol.GenerateBdc("u"); + + // define the multilevel problem attach the mlSol object to it + MultiLevelProblem mlProb(&mlSol); + + // add system Poisson in mlProb as a Linear Implicit System + LinearImplicitSystem & system = mlProb.add_system < LinearImplicitSystem > ("Poisson"); + + // add solution "u" to system + system.AddSolutionToSystemPDE("u"); + + // attach the assembling function to system + system.SetAssembleFunction(AssemblePoissonProblem); + + // initilaize and solve the system + system.init(); + system.solve(); + + // print solutions + std::vector < std::string > variablesToBePrinted; + variablesToBePrinted.push_back("All"); + + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + + GMVWriter gmvIO(&mlSol); + gmvIO.SetDebugOutput(true); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + + return 0; +} + + +/** + * This function assemble the stiffnes matrix KK and the residual vector Res + * such that + * KK w = RES = F - KK u0, + * and consequently + * u = u0 + w satisfies KK u = F + **/ + +void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix) { + // ml_prob is the global object from/to where get/set all the data + // level is the level of the PDE system to be assembled + // levelMax is the Maximum level of the MultiLevelProblem + // assembleMatrix is a flag that tells if only the residual or also the matrix should be assembled + + // extract pointers to the several objects that we are going to use + Mesh* msh = ml_prob._ml_msh->GetLevel(level); // pointer to the mesh (level) object + elem* el = msh->el; // pointer to the elem object in msh (level) + + MultiLevelSolution* mlSol = ml_prob._ml_sol; // pointer to the multilevel solution object + Solution* sol = ml_prob._ml_sol->GetSolutionLevel(level); // pointer to the solution (level) object + + LinearImplicitSystem* mlPdeSys = &ml_prob.get_system("Poisson"); // pointer to the linear implicit system named "Poisson" + LinearEquationSolver* pdeSys = mlPdeSys->_LinSolver[level]; // pointer to the equation (level) object + SparseMatrix* KK = pdeSys->_KK; // pointer to the global stifness matrix object in pdeSys (level) + NumericVector* RES = pdeSys->_RES; // pointer to the global residual vector object in pdeSys (level) + + const unsigned dim = msh->GetDimension(); // get the domain dimension of the problem + unsigned iproc = msh->processor_id(); // get the process_id (for parallel computation) + + //solution variable + unsigned soluIndex; + soluIndex = mlSol->GetIndex("u"); // get the position of "u" in the ml_sol object + unsigned soluType = mlSol->GetSolutionType(soluIndex); // get the finite element type for "u" + + unsigned soluPdeIndex; + soluPdeIndex = mlPdeSys->GetSolPdeIndex("u"); // get the position of "u" in the pdeSys object + + vector < double > solu; // local solution + + vector < vector < double > > x(dim); // local coordinates + unsigned xType = 2; // get the finite element type for "x", it is always 2 (LAGRANGE QUADRATIC) + + vector< int > KKDof; // local to global pdeSys dofs + vector phi; // local test function + vector phi_x; // local test function first order partial derivatives + vector phi_xx; // local test function second order partial derivatives + double weight; // gauss point weight + + vector< double > Res; // local redidual vector + vector< double > K; // local stiffness matrix + + // reserve memory for the local standar vectors + const unsigned maxSize = static_cast< unsigned > (ceil(pow(3,dim))); // conservative: based on line3, quad9, hex27 + solu.reserve(maxSize); + for(unsigned i = 0; i < dim; i++) + x[i].reserve(maxSize); + KKDof.reserve(maxSize); + phi.reserve(maxSize); + phi_x.reserve(maxSize*dim); + unsigned dim2=(3*(dim-1)+!(dim-1)); // dim2 is the number of second order partial derivatives (1,3,6 depending on the dimension) + phi_xx.reserve(maxSize*dim2); + Res.reserve(maxSize); + K.reserve(maxSize*maxSize); + + if( assembleMatrix ) + KK->zero(); // Set to zero all the entries of the Global Matrix + + // element loop: each process loops only on the elements that owns + for (int iel=msh->IS_Mts2Gmt_elem_offset[iproc]; iel < msh->IS_Mts2Gmt_elem_offset[iproc+1]; iel++) { + + unsigned kel = msh->IS_Mts2Gmt_elem[iel]; // mapping between paralell dof and mesh dof + short unsigned kelGeom = el->GetElementType( kel ); // element geometry type + unsigned nDofs = el->GetElementDofNumber( kel, soluType); // number of solution element dofs + unsigned nDofs2 = el->GetElementDofNumber( kel, xType); // number of coordinate element dofs + + // resize local arrays + KKDof.resize(nDofs); + solu.resize(nDofs); + for(int i=0; iGetMeshDof(kel, i, soluType); // local to global solution node + unsigned solDof = msh->GetMetisDof(iNode, soluType); // global to global mapping between solution node and solution dof + solu[i] = (*sol->_Sol[soluIndex])(solDof); // global extraction and local storage for the solution + KKDof[i] = pdeSys->GetKKDof(soluIndex, soluPdeIndex, iNode); // global to global mapping between solution node and pdeSys dof + } + + // local storage of coordinates + for( unsigned i=0; iGetMeshDof(kel, i, xType); // local to global coordinates node + unsigned xDof = msh->GetMetisDof(iNode, xType); // global to global mapping between coordinates node and coordinate dof + for(unsigned jdim=0; jdim_coordinate->_Sol[jdim])(xDof); // global extraction and local storage for the element coordinates + } + } + + if( level == levelMax || !el->GetRefinedElementIndex(kel)) { // do not care about this if now (it is used for the AMR) + // *** Gauss point loop *** + for(unsigned ig=0; ig < msh->_finiteElement[kelGeom][soluType]->GetGaussPointNumber(); ig++) { + // *** get gauss point weight, test function and test function partial derivatives *** + msh->_finiteElement[kelGeom][soluType]->Jacobian(x,ig,weight,phi,phi_x,phi_xx); + + // evaluate the solution, the solution derivatives and the coordinates in the gauss point + double soluGauss = 0; + vector < double > soluGauss_x(dim,0.); + vector < double > xGauss(dim,0.); + + for(unsigned i=0; iadd_vector_blocked(Res,KKDof); + if(assembleMatrix) KK->add_matrix_blocked(K,KKDof,KKDof); + } //end element loop for each process + + RES->close(); + if( assembleMatrix ) KK->close(); + // ***************** END ASSEMBLY ******************* + + +} + + diff --git a/applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/square.dbs b/applications/NumPdeSpring2015/Guoyi/Ex3/input/gambit/square.dbs similarity index 100% rename from applications/NumPdeSpring2015/Eugenio/Ex2/input/gambit/square.dbs rename to applications/NumPdeSpring2015/Guoyi/Ex3/input/gambit/square.dbs diff --git a/applications/NumPdeSpring2015/Thanuja/Ex2/input/square.neu b/applications/NumPdeSpring2015/Guoyi/Ex3/input/square.neu similarity index 100% rename from applications/NumPdeSpring2015/Thanuja/Ex2/input/square.neu rename to applications/NumPdeSpring2015/Guoyi/Ex3/input/square.neu diff --git a/applications/NumPdeSpring2015/Sara/Ex1/Ex1.cpp b/applications/NumPdeSpring2015/Sara/Ex1/Ex1.cpp index 0c5eaf37d..04b5866c5 100644 --- a/applications/NumPdeSpring2015/Sara/Ex1/Ex1.cpp +++ b/applications/NumPdeSpring2015/Sara/Ex1/Ex1.cpp @@ -69,13 +69,13 @@ int main(int argc, char **args) { variablesToBePrinted.push_back("P"); variablesToBePrinted.push_back("T"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); + GMVWriter gmvIO(&mlSol); variablesToBePrinted.push_back("all"); gmvIO.SetDebugOutput(false); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); return 0; } diff --git a/applications/NumPdeSpring2015/Sara/Ex2/Ex2.cpp b/applications/NumPdeSpring2015/Sara/Ex2/Ex2.cpp index ac0b0e406..cc59a3e31 100644 --- a/applications/NumPdeSpring2015/Sara/Ex2/Ex2.cpp +++ b/applications/NumPdeSpring2015/Sara/Ex2/Ex2.cpp @@ -79,12 +79,12 @@ int main(int argc, char **args) { std::vector < std::string > variablesToBePrinted; variablesToBePrinted.push_back("All"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); + GMVWriter gmvIO(&mlSol); gmvIO.SetDebugOutput(true); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); return 0; } diff --git a/applications/NumPdeSpring2015/Thanuja/CMakeLists.txt b/applications/NumPdeSpring2015/Thanuja/CMakeLists.txt index 482fcd056..c6b4f3db3 100644 --- a/applications/NumPdeSpring2015/Thanuja/CMakeLists.txt +++ b/applications/NumPdeSpring2015/Thanuja/CMakeLists.txt @@ -3,7 +3,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) set(EXAMPLE_NUMBER Ex1) ADD_SUBDIRECTORY(${EXAMPLE_NUMBER}) + set(EXAMPLE_NUMBER Ex2) ADD_SUBDIRECTORY(${EXAMPLE_NUMBER}) +set(EXAMPLE_NUMBER Ex3) +ADD_SUBDIRECTORY(${EXAMPLE_NUMBER}) unset(EXAMPLE_NUMBER) diff --git a/applications/NumPdeSpring2015/Thanuja/Ex1/Ex1.cpp b/applications/NumPdeSpring2015/Thanuja/Ex1/Ex1.cpp index 0c5eaf37d..04b5866c5 100644 --- a/applications/NumPdeSpring2015/Thanuja/Ex1/Ex1.cpp +++ b/applications/NumPdeSpring2015/Thanuja/Ex1/Ex1.cpp @@ -69,13 +69,13 @@ int main(int argc, char **args) { variablesToBePrinted.push_back("P"); variablesToBePrinted.push_back("T"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); + GMVWriter gmvIO(&mlSol); variablesToBePrinted.push_back("all"); gmvIO.SetDebugOutput(false); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); return 0; } diff --git a/applications/NumPdeSpring2015/Thanuja/Ex2/Ex2.cpp b/applications/NumPdeSpring2015/Thanuja/Ex2/Ex2.cpp index ac0b0e406..5f3bab68e 100644 --- a/applications/NumPdeSpring2015/Thanuja/Ex2/Ex2.cpp +++ b/applications/NumPdeSpring2015/Thanuja/Ex2/Ex2.cpp @@ -25,71 +25,128 @@ bool SetBoundaryCondition(const double &x, const double &y, const double &z,cons void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix); +double GetErrorNorm(MultiLevelSolution *mlSol); int main(int argc, char **args) { // init Petsc-MPI communicator FemusInit mpinit(argc, args, MPI_COMM_WORLD); - - // define multilevel mesh + + + // define multilevel mesh MultiLevelMesh mlMsh; // read coarse level mesh and generate finers level meshes double scalingFactor=1.; - mlMsh.ReadCoarseMesh("./input/square.neu","seventh",scalingFactor); + mlMsh.ReadCoarseMesh("./input/square_tri.neu","seventh",scalingFactor); /* "seventh" is the order of accuracy that is used in the gauss integration scheme - probably in the furure it is not going to be an argument of this function */ - unsigned numberOfUniformLevels=2; - unsigned numberOfSelectiveLevels=0; - mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL); + probably in the furure it is not going to be an argument of this function */ - // erase all the coarse mesh levels - mlMsh.EraseCoarseLevels(numberOfUniformLevels-1); + unsigned maxNumberOfMeshes = 7; + vector < vector < double > > semiNorm; + semiNorm.resize(maxNumberOfMeshes); - // print mesh info - mlMsh.PrintInfo(); + for(unsigned i = 0; i < maxNumberOfMeshes; i++){ // loop on the mesh level + + unsigned numberOfUniformLevels = i+1; + unsigned numberOfSelectiveLevels = 0; + mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL); - // define the multilevel solution and attach the mlMsh object to it - MultiLevelSolution mlSol(&mlMsh); + // erase all the coarse mesh levels + mlMsh.EraseCoarseLevels(numberOfUniformLevels-1); - // add variables to mlSol - mlSol.AddSolution("u",LAGRANGE, FIRST); - mlSol.Initialize("All"); + // print mesh info + mlMsh.PrintInfo(); - // attach the boundary condition function and generate boundary data - mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition); - mlSol.GenerateBdc("u"); + FEOrder feOrder[3] = {FIRST, SERENDIPITY, SECOND}; + semiNorm[i].resize(3); + + for(unsigned j=0; j<3; j++){ // loop on the FE Order + // define the multilevel solution and attach the mlMsh object to it + MultiLevelSolution mlSol(&mlMsh); + + // add variables to mlSol + mlSol.AddSolution("u",LAGRANGE, feOrder[j]); + mlSol.Initialize("All"); - // define the multilevel problem attach the mlSol object to it - MultiLevelProblem mlProb(&mlSol); + // attach the boundary condition function and generate boundary data + mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition); + mlSol.GenerateBdc("u"); - // add system Poisson in mlProb as a Linear Implicit System - LinearImplicitSystem & system = mlProb.add_system < LinearImplicitSystem > ("Poisson"); + // define the multilevel problem attach the mlSol object to it + MultiLevelProblem mlProb(&mlSol); + + // add system Poisson in mlProb as a Linear Implicit System + LinearImplicitSystem & system = mlProb.add_system < LinearImplicitSystem > ("Poisson"); - // add solution "u" to system - system.AddSolutionToSystemPDE("u"); + // add solution "u" to system + system.AddSolutionToSystemPDE("u"); - // attach the assembling function to system - system.SetAssembleFunction(AssemblePoissonProblem); + // attach the assembling function to system + system.SetAssembleFunction(AssemblePoissonProblem); - // initilaize and solve the system - system.init(); - system.solve(); + // initilaize and solve the system + system.init(); + system.solve(); - // print solutions - std::vector < std::string > variablesToBePrinted; - variablesToBePrinted.push_back("All"); + semiNorm[i][j] = GetErrorNorm(&mlSol); + // print solutions + std::vector < std::string > variablesToBePrinted; + variablesToBePrinted.push_back("All"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); - gmvIO.SetDebugOutput(true); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - + GMVWriter gmvIO(&mlSol); + gmvIO.SetDebugOutput(true); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + } + } + + // print the seminorm of the error and the order of convergence between different levels + std::cout< &x){ + double pi=acos(-1.); + return cos(pi*x[0])*cos(pi*x[1]); +}; + + +void GetExactSolutionGradient(const vector < double > &x, vector < double > &solGrad){ + double pi=acos(-1.); + solGrad[0] = -pi*sin(pi*x[0])*cos(pi*x[1]); + solGrad[1] = -pi*cos(pi*x[0])*sin(pi*x[1]); +}; + + +double GetExactSolutionLaplace(const vector < double > &x){ + double pi=acos(-1.); + return -pi*pi*cos(pi*x[0])*cos(pi*x[1]) - pi*pi*cos(pi*x[0])*cos(pi*x[1]); +}; + /** * This function assemble the stiffnes matrix KK and the residual vector Res * such that @@ -97,7 +154,6 @@ int main(int argc, char **args) { * and consequently * u = u0 + w satisfies KK u = F **/ - void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix) { // ml_prob is the global object from/to where get/set all the data // level is the level of the PDE system to be assembled @@ -221,7 +277,7 @@ void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const un for(unsigned jdim=0; jdim_ml_msh->GetNumberOfLevels()-1u; + // extract pointers to the several objects that we are going to use + Mesh* msh = mlSol->_ml_msh->GetLevel(level); // pointer to the mesh (level) object + elem* el = msh->el; // pointer to the elem object in msh (level) + Solution* sol = mlSol->GetSolutionLevel(level); // pointer to the solution (level) object + + const unsigned dim = msh->GetDimension(); // get the domain dimension of the problem + unsigned iproc = msh->processor_id(); // get the process_id (for parallel computation) + + //solution variable + unsigned soluIndex; + soluIndex = mlSol->GetIndex("u"); // get the position of "u" in the ml_sol object + unsigned soluType = mlSol->GetSolutionType(soluIndex); // get the finite element type for "u" + + vector < double > solu; // local solution + + vector < vector < double > > x(dim); // local coordinates + unsigned xType = 2; // get the finite element type for "x", it is always 2 (LAGRANGE QUADRATIC) + + vector phi; // local test function + vector phi_x; // local test function first order partial derivatives + vector phi_xx; // local test function second order partial derivatives + double weight; // gauss point weight + + // reserve memory for the local standar vectors + const unsigned maxSize = static_cast< unsigned > (ceil(pow(3,dim))); // conservative: based on line3, quad9, hex27 + solu.reserve(maxSize); + for(unsigned i = 0; i < dim; i++) + x[i].reserve(maxSize); + phi.reserve(maxSize); + phi_x.reserve(maxSize*dim); + unsigned dim2=(3*(dim-1)+!(dim-1)); // dim2 is the number of second order partial derivatives (1,3,6 depending on the dimension) + phi_xx.reserve(maxSize*dim2); + + double seminorm = 0.; + double l2norm =0.; + // element loop: each process loops only on the elements that owns + for (int iel=msh->IS_Mts2Gmt_elem_offset[iproc]; iel < msh->IS_Mts2Gmt_elem_offset[iproc+1]; iel++) { + + unsigned kel = msh->IS_Mts2Gmt_elem[iel]; // mapping between paralell dof and mesh dof + short unsigned kelGeom = el->GetElementType( kel ); // element geometry type + unsigned nDofs = el->GetElementDofNumber( kel, soluType); // number of solution element dofs + unsigned nDofs2 = el->GetElementDofNumber( kel, xType); // number of coordinate element dofs + + // resize local arrays + solu.resize(nDofs); + for(int i=0; iGetMeshDof(kel, i, soluType); // local to global solution node + unsigned solDof = msh->GetMetisDof(iNode, soluType); // global to global mapping between solution node and solution dof + solu[i] = (*sol->_Sol[soluIndex])(solDof); // global extraction and local storage for the solution + } + + // local storage of coordinates + for( unsigned i=0; iGetMeshDof(kel, i, xType); // local to global coordinates node + unsigned xDof = msh->GetMetisDof(iNode, xType); // global to global mapping between coordinates node and coordinate dof + for(unsigned jdim=0; jdim_coordinate->_Sol[jdim])(xDof); // global extraction and local storage for the element coordinates + } + } + + // *** Gauss point loop *** + for(unsigned ig=0; ig < msh->_finiteElement[kelGeom][soluType]->GetGaussPointNumber(); ig++) { + // *** get gauss point weight, test function and test function partial derivatives *** + msh->_finiteElement[kelGeom][soluType]->Jacobian(x,ig,weight,phi,phi_x,phi_xx); + + // evaluate the solution, the solution derivatives and the coordinates in the gauss point + double soluGauss = 0; + vector < double > soluGauss_x(dim,0.); + vector < double > xGauss(dim,0.); + + for(unsigned i=0; i solGrad(dim); + GetExactSolutionGradient(xGauss, solGrad); + + double exactSol = GetExactSolutionValue(xGauss); + l2norm += (exactSol - soluGauss) * (exactSol - soluGauss)*weight; + + for (unsigned j=0;j n_processors()) { + seminorm_vec->init(msh->n_processors(), 1, false, SERIAL); + } + else { + seminorm_vec->init(msh->n_processors(), 1 , false, PARALLEL); + } + + seminorm_vec->set(iproc, seminorm); + seminorm_vec->close(); + seminorm=seminorm_vec->l1_norm(); + + delete seminorm_vec; + + //return sqrt(seminorm); + return sqrt(l2norm); + +} diff --git a/applications/NumPdeSpring2015/Thanuja/Ex2/input/cube_hex.neu b/applications/NumPdeSpring2015/Thanuja/Ex2/input/cube_hex.neu new file mode 100644 index 000000000..3d293a420 --- /dev/null +++ b/applications/NumPdeSpring2015/Thanuja/Ex2/input/cube_hex.neu @@ -0,0 +1,205 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +cube_hex +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 16:58:50 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 125 8 1 2 3 3 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 2 5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 3 5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 4 5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 5 5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 6 -5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 7 0.00000000000e+00 5.00000000000e-01 5.00000000000e-01 + 8 2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 9 -2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 10 -5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 11 -5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 12 -5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 13 -5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 14 0.00000000000e+00 -5.00000000000e-01 5.00000000000e-01 + 15 -2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 16 2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 5.00000000000e-01 + 18 -2.50000000000e-01 0.00000000000e+00 5.00000000000e-01 + 19 0.00000000000e+00 2.50000000000e-01 5.00000000000e-01 + 20 -2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 21 0.00000000000e+00 -2.50000000000e-01 5.00000000000e-01 + 22 -2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 23 2.50000000000e-01 0.00000000000e+00 5.00000000000e-01 + 24 2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 25 2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 26 5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 27 5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 28 5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 29 5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 30 5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 31 -5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 32 0.00000000000e+00 -5.00000000000e-01 -5.00000000000e-01 + 33 2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 34 -2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 35 -5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 36 -5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 37 -5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 38 -5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 39 0.00000000000e+00 5.00000000000e-01 -5.00000000000e-01 + 40 -2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 41 2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 42 0.00000000000e+00 0.00000000000e+00 -5.00000000000e-01 + 43 -2.50000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 44 0.00000000000e+00 -2.50000000000e-01 -5.00000000000e-01 + 45 -2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 46 0.00000000000e+00 2.50000000000e-01 -5.00000000000e-01 + 47 -2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 48 2.50000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 49 2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 50 2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 51 -5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 52 -5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 53 -5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 54 5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 55 5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 56 5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 57 0.00000000000e+00 -5.00000000000e-01 0.00000000000e+00 + 58 0.00000000000e+00 -5.00000000000e-01 2.50000000000e-01 + 59 2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 60 2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 61 -2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 62 -2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 63 0.00000000000e+00 -5.00000000000e-01 -2.50000000000e-01 + 64 2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 65 -2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 66 -5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 67 -5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 68 -5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 69 -5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 70 -5.00000000000e-01 0.00000000000e+00 2.50000000000e-01 + 71 -5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 72 -5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 73 -5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 74 -5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 75 -5.00000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 76 -5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 77 -5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 78 5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 79 5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 80 5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 81 0.00000000000e+00 5.00000000000e-01 0.00000000000e+00 + 82 0.00000000000e+00 5.00000000000e-01 2.50000000000e-01 + 83 -2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 84 -2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 85 2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 86 2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 87 0.00000000000e+00 5.00000000000e-01 -2.50000000000e-01 + 88 -2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 89 2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 90 5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 91 5.00000000000e-01 0.00000000000e+00 2.50000000000e-01 + 92 5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 93 5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 94 5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 95 5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 96 5.00000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 97 5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 98 5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 99 0.00000000000e+00 0.00000000000e+00 0.00000000000e+00 + 100 2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 101 0.00000000000e+00 0.00000000000e+00 2.50000000000e-01 + 102 0.00000000000e+00 -2.50000000000e-01 0.00000000000e+00 + 103 2.50000000000e-01 0.00000000000e+00 2.50000000000e-01 + 104 2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 105 0.00000000000e+00 -2.50000000000e-01 2.50000000000e-01 + 106 2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 107 0.00000000000e+00 2.50000000000e-01 0.00000000000e+00 + 108 2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 109 0.00000000000e+00 2.50000000000e-01 2.50000000000e-01 + 110 2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 111 0.00000000000e+00 0.00000000000e+00 -2.50000000000e-01 + 112 2.50000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 113 0.00000000000e+00 -2.50000000000e-01 -2.50000000000e-01 + 114 2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 115 0.00000000000e+00 2.50000000000e-01 -2.50000000000e-01 + 116 2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 117 -2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 118 -2.50000000000e-01 0.00000000000e+00 2.50000000000e-01 + 119 -2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 120 -2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 121 -2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 122 -2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 123 -2.50000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 124 -2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 125 -2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 4 27 1 4 3 55 95 91 54 + 94 90 16 25 23 60 106 + 103 59 104 100 14 21 17 + 58 105 101 57 102 99 + 2 4 27 3 5 2 91 93 79 90 + 92 78 23 24 8 103 110 + 86 100 108 85 17 19 7 + 101 109 82 99 107 81 + 3 4 27 54 94 90 56 98 96 27 + 30 28 59 104 100 64 114 + 112 33 49 48 57 102 99 + 63 113 111 32 44 42 + 4 4 27 90 92 78 96 97 80 28 + 29 26 100 108 85 112 116 + 89 48 50 41 99 107 81 + 111 115 87 42 46 39 + 5 4 27 14 21 17 58 105 101 57 + 102 99 15 22 18 62 120 + 118 61 119 117 10 13 11 + 52 72 70 51 71 69 + 6 4 27 17 19 7 101 109 82 99 + 107 81 18 20 9 118 122 + 84 117 121 83 11 12 6 + 70 74 67 69 73 66 + 7 4 27 57 102 99 63 113 111 32 + 44 42 61 119 117 65 124 + 123 34 45 43 51 71 69 + 53 76 75 31 37 36 + 8 4 27 99 107 81 111 115 87 42 + 46 39 117 121 83 123 125 + 88 43 47 40 69 73 66 + 75 77 68 36 38 35 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 8 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 5 6 7 8 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 16 0 6 + 2 4 5 + 1 4 5 + 4 4 5 + 3 4 5 + 5 4 6 + 6 4 6 + 7 4 6 + 8 4 6 + 6 4 2 + 2 4 2 + 8 4 2 + 4 4 2 + 1 4 4 + 5 4 4 + 3 4 4 + 7 4 4 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 2 1 8 0 6 + 6 4 1 + 5 4 1 + 2 4 1 + 1 4 1 + 7 4 3 + 8 4 3 + 3 4 3 + 4 4 3 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Thanuja/Ex2/input/cube_mixed.neu b/applications/NumPdeSpring2015/Thanuja/Ex2/input/cube_mixed.neu new file mode 100644 index 000000000..5c6073f9b --- /dev/null +++ b/applications/NumPdeSpring2015/Thanuja/Ex2/input/cube_mixed.neu @@ -0,0 +1,226 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +cube_mixed +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 17:44:57 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 132 21 2 2 3 3 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 0.00000000000e+00 0.00000000000e+00 0.00000000000e+00 + 2 0.00000000000e+00 -5.00000000000e-01 0.00000000000e+00 + 3 0.00000000000e+00 -2.50000000000e-01 0.00000000000e+00 + 4 3.06161699787e-17 3.06161699787e-17 -5.00000000000e-01 + 5 1.53080849893e-17 1.53080849893e-17 -2.50000000000e-01 + 6 3.06161699787e-17 -5.00000000000e-01 -5.00000000000e-01 + 7 3.06161699787e-17 -2.50000000000e-01 -5.00000000000e-01 + 8 1.53080849893e-17 -5.00000000000e-01 -2.50000000000e-01 + 9 1.53080849893e-17 -2.50000000000e-01 -2.50000000000e-01 + 10 -5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 11 -2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 12 -5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 13 -5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 14 -2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 15 -2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 16 -5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 17 -5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 18 -2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 19 -2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 20 -5.00000000000e-01 3.06161699787e-17 -5.00000000000e-01 + 21 -5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 22 -2.50000000000e-01 3.06161699787e-17 -5.00000000000e-01 + 23 -2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 24 -5.00000000000e-01 1.53080849893e-17 -2.50000000000e-01 + 25 -2.50000000000e-01 1.53080849893e-17 -2.50000000000e-01 + 26 -5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 27 5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 28 5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 29 5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 30 5.00000000000e-01 -3.06161699787e-17 5.00000000000e-01 + 31 5.00000000000e-01 -1.53080849893e-17 2.50000000000e-01 + 32 5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 33 5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 34 5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 35 5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 36 2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 37 2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 38 2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 39 -3.06161699787e-17 -5.00000000000e-01 5.00000000000e-01 + 40 -1.53080849893e-17 -5.00000000000e-01 2.50000000000e-01 + 41 2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 42 2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 43 -3.06161699787e-17 -3.06161699787e-17 5.00000000000e-01 + 44 -3.06161699787e-17 -2.50000000000e-01 5.00000000000e-01 + 45 2.50000000000e-01 -3.06161699787e-17 5.00000000000e-01 + 46 2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 47 -1.53080849893e-17 -1.53080849893e-17 2.50000000000e-01 + 48 2.50000000000e-01 -1.53080849893e-17 2.50000000000e-01 + 49 -1.53080849893e-17 -2.50000000000e-01 2.50000000000e-01 + 50 1.79900842690e-01 -2.49793642085e-01 2.51274024810e-01 + 51 8.99504213448e-02 -1.24896821042e-01 3.75637012405e-01 + 52 8.99504213448e-02 -3.74896821042e-01 1.25637012405e-01 + 53 8.99504213448e-02 -3.74896821042e-01 3.75637012405e-01 + 54 8.99504213448e-02 -1.24896821042e-01 1.25637012405e-01 + 55 3.39950421345e-01 -3.74896821042e-01 3.75637012405e-01 + 56 3.39950421345e-01 -1.24896821042e-01 3.75637012405e-01 + 57 3.39950421345e-01 -3.74896821042e-01 1.25637012405e-01 + 58 5.00000000000e-01 3.06161699787e-17 -5.00000000000e-01 + 59 2.50000000000e-01 3.06161699787e-17 -5.00000000000e-01 + 60 5.00000000000e-01 1.53080849893e-17 -2.50000000000e-01 + 61 2.50000000000e-01 1.53080849893e-17 -2.50000000000e-01 + 62 0.00000000000e+00 5.00000000000e-01 0.00000000000e+00 + 63 0.00000000000e+00 2.50000000000e-01 0.00000000000e+00 + 64 3.06161699787e-17 5.00000000000e-01 -5.00000000000e-01 + 65 1.53080849893e-17 5.00000000000e-01 -2.50000000000e-01 + 66 3.06161699787e-17 2.50000000000e-01 -5.00000000000e-01 + 67 1.53080849893e-17 2.50000000000e-01 -2.50000000000e-01 + 68 5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 69 5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 70 2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 71 2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 72 5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 73 5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 74 2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 75 2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 76 5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 77 2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 78 5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 79 2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 80 -5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 81 -5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 82 -2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 83 -2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 84 -5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 85 -2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 86 -5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 87 -2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 88 -5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 89 -2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 90 -5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 91 -2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 92 -2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 93 -3.06161699787e-17 5.00000000000e-01 5.00000000000e-01 + 94 -3.06161699787e-17 2.50000000000e-01 5.00000000000e-01 + 95 -1.53080849893e-17 5.00000000000e-01 2.50000000000e-01 + 96 -1.53080849893e-17 2.50000000000e-01 2.50000000000e-01 + 97 -5.00000000000e-01 -3.06161699787e-17 5.00000000000e-01 + 98 -5.00000000000e-01 -1.53080849893e-17 2.50000000000e-01 + 99 -2.50000000000e-01 -3.06161699787e-17 5.00000000000e-01 + 100 -2.50000000000e-01 -1.53080849893e-17 2.50000000000e-01 + 101 -5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 102 -5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 103 -2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 104 -2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 105 -5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 106 -5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 107 -2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 108 -2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 109 5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 110 5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 111 2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 112 2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 113 5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 114 5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 115 2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 116 2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 117 -5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 118 -5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 119 -2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 120 -2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 121 -5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 122 -2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 123 -5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 124 -2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 125 5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 126 2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 127 5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 128 2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 129 5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 130 5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 131 2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 132 2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 6 10 50 51 43 52 49 2 53 + 44 40 39 + 2 6 10 50 51 43 54 47 1 52 + 49 3 2 + 3 6 10 50 51 43 53 44 39 55 + 46 41 32 + 4 6 10 50 51 43 55 46 32 56 + 45 33 30 + 5 6 10 50 54 1 51 47 43 56 + 48 45 30 + 6 6 10 50 57 27 56 35 30 55 + 34 33 32 + 7 6 10 50 53 39 57 42 27 55 + 41 34 32 + 8 6 10 50 53 39 52 40 2 57 + 42 36 27 + 9 6 10 50 57 27 52 36 2 54 + 38 3 1 + 10 6 10 27 38 1 35 48 30 29 + 37 31 28 + 11 6 10 27 38 1 57 54 50 35 + 48 56 30 + 12 4 27 4 59 58 66 77 76 64 + 74 72 5 61 60 67 79 + 78 65 75 73 1 37 28 + 63 71 69 62 70 68 + 13 4 27 4 5 1 66 67 63 64 + 65 62 22 25 11 83 91 + 87 82 89 85 20 24 10 + 81 90 86 80 88 84 + 14 4 27 1 3 2 11 15 14 10 + 13 12 5 9 8 25 92 + 19 24 26 17 4 7 6 + 22 23 18 20 21 16 + 15 4 27 62 63 1 95 96 47 93 + 94 43 85 87 11 104 108 + 100 103 107 99 84 86 10 + 102 106 98 101 105 97 + 16 5 18 28 37 1 31 48 30 69 + 71 63 114 116 110 68 70 + 62 113 115 109 + 17 5 18 30 48 1 45 47 43 110 + 116 63 112 96 94 109 115 + 62 111 95 93 + 18 5 18 39 44 43 40 49 2 119 + 120 99 122 124 14 117 118 + 97 121 123 12 + 19 5 18 2 49 43 3 47 1 14 + 124 99 15 100 11 12 123 + 97 13 98 10 + 20 5 18 1 37 28 38 29 27 5 + 61 60 132 130 127 4 59 + 58 131 129 125 + 21 5 18 1 38 27 3 36 2 5 + 132 127 9 128 8 4 131 + 125 7 126 6 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 1 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 14 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 2 ELEMENTS: 20 MATERIAL: 2 NFLAGS: 1 + fluid + 0 + 12 20 21 1 2 3 4 5 6 7 + 8 9 10 11 16 17 18 19 15 13 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 4 0 6 + 20 5 2 + 13 4 6 + 12 4 3 + 21 5 2 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 2 1 3 0 6 + 4 6 3 + 3 6 3 + 12 4 5 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/cube_hex.dbs b/applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/cube_hex.dbs new file mode 100644 index 000000000..d621b27a3 Binary files /dev/null and b/applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/cube_hex.dbs differ diff --git a/applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/cube_mixed.dbs b/applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/cube_mixed.dbs new file mode 100644 index 000000000..c9f41b985 Binary files /dev/null and b/applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/cube_mixed.dbs differ diff --git a/applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/square_quad.dbs b/applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/square_quad.dbs new file mode 100644 index 000000000..2c3b4ba31 Binary files /dev/null and b/applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/square_quad.dbs differ diff --git a/applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/square.dbs b/applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/square_tri.dbs similarity index 52% rename from applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/square.dbs rename to applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/square_tri.dbs index ac2d8f225..26c81d0de 100644 Binary files a/applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/square.dbs and b/applications/NumPdeSpring2015/Thanuja/Ex2/input/gambit/square_tri.dbs differ diff --git a/applications/NumPdeSpring2015/Thanuja/Ex2/input/square_quad.neu b/applications/NumPdeSpring2015/Thanuja/Ex2/input/square_quad.neu new file mode 100644 index 000000000..fba100a3f --- /dev/null +++ b/applications/NumPdeSpring2015/Thanuja/Ex2/input/square_quad.neu @@ -0,0 +1,62 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +square_quad +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 16:28:18 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 25 4 1 1 2 2 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 -5.00000000000e-01 -5.00000000000e-01 + 2 5.00000000000e-01 -5.00000000000e-01 + 3 0.00000000000e+00 -5.00000000000e-01 + 4 -2.50000000000e-01 -5.00000000000e-01 + 5 2.50000000000e-01 -5.00000000000e-01 + 6 5.00000000000e-01 5.00000000000e-01 + 7 5.00000000000e-01 0.00000000000e+00 + 8 5.00000000000e-01 -2.50000000000e-01 + 9 5.00000000000e-01 2.50000000000e-01 + 10 -5.00000000000e-01 5.00000000000e-01 + 11 0.00000000000e+00 5.00000000000e-01 + 12 2.50000000000e-01 5.00000000000e-01 + 13 -2.50000000000e-01 5.00000000000e-01 + 14 -5.00000000000e-01 0.00000000000e+00 + 15 -5.00000000000e-01 2.50000000000e-01 + 16 -5.00000000000e-01 -2.50000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 + 18 0.00000000000e+00 -2.50000000000e-01 + 19 -2.50000000000e-01 0.00000000000e+00 + 20 -2.50000000000e-01 -2.50000000000e-01 + 21 2.50000000000e-01 0.00000000000e+00 + 22 2.50000000000e-01 -2.50000000000e-01 + 23 0.00000000000e+00 2.50000000000e-01 + 24 -2.50000000000e-01 2.50000000000e-01 + 25 2.50000000000e-01 2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 2 9 1 4 3 18 17 19 14 + 16 20 + 2 2 9 3 5 2 8 7 21 17 + 18 22 + 3 2 9 14 19 17 23 11 13 10 + 15 24 + 4 2 9 17 21 7 9 6 12 11 + 23 25 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 4 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 8 0 6 + 4 2 3 + 3 2 3 + 2 2 2 + 4 2 2 + 1 2 1 + 2 2 1 + 3 2 4 + 1 2 4 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Thanuja/Ex2/input/square_tri.neu b/applications/NumPdeSpring2015/Thanuja/Ex2/input/square_tri.neu new file mode 100644 index 000000000..643eba499 --- /dev/null +++ b/applications/NumPdeSpring2015/Thanuja/Ex2/input/square_tri.neu @@ -0,0 +1,62 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +square_tri +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 16:34:20 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 25 8 1 1 2 2 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 -5.00000000000e-01 -5.00000000000e-01 + 2 5.00000000000e-01 -5.00000000000e-01 + 3 0.00000000000e+00 -5.00000000000e-01 + 4 -2.50000000000e-01 -5.00000000000e-01 + 5 2.50000000000e-01 -5.00000000000e-01 + 6 5.00000000000e-01 5.00000000000e-01 + 7 5.00000000000e-01 0.00000000000e+00 + 8 5.00000000000e-01 -2.50000000000e-01 + 9 5.00000000000e-01 2.50000000000e-01 + 10 -5.00000000000e-01 5.00000000000e-01 + 11 0.00000000000e+00 5.00000000000e-01 + 12 2.50000000000e-01 5.00000000000e-01 + 13 -2.50000000000e-01 5.00000000000e-01 + 14 -5.00000000000e-01 0.00000000000e+00 + 15 -5.00000000000e-01 2.50000000000e-01 + 16 -5.00000000000e-01 -2.50000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 + 18 0.00000000000e+00 -2.50000000000e-01 + 19 -2.50000000000e-01 0.00000000000e+00 + 20 -2.50000000000e-01 -2.50000000000e-01 + 21 2.50000000000e-01 0.00000000000e+00 + 22 2.50000000000e-01 -2.50000000000e-01 + 23 0.00000000000e+00 2.50000000000e-01 + 24 -2.50000000000e-01 2.50000000000e-01 + 25 2.50000000000e-01 2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 3 6 3 18 17 19 14 20 + 2 3 6 1 4 3 20 14 16 + 3 3 6 2 8 7 21 17 22 + 4 3 6 3 5 2 22 17 18 + 5 3 6 17 23 11 13 10 24 + 6 3 6 14 19 17 24 10 15 + 7 3 6 7 9 6 12 11 25 + 8 3 6 17 21 7 25 11 23 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 8 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 5 6 7 8 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 8 0 6 + 7 3 2 + 5 3 2 + 3 3 1 + 7 3 1 + 2 3 1 + 4 3 1 + 6 3 3 + 2 3 3 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/Thanuja/Ex3/CMakeLists.txt b/applications/NumPdeSpring2015/Thanuja/Ex3/CMakeLists.txt new file mode 100644 index 000000000..78ece9e49 --- /dev/null +++ b/applications/NumPdeSpring2015/Thanuja/Ex3/CMakeLists.txt @@ -0,0 +1,9 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +SET (PROJECT_NAME "${MYNAME_FOLDER}${EXAMPLE_NUMBER}") +PROJECT(PROJECT_NAME) + +SET(MAIN_FILE "${EXAMPLE_NUMBER}") # the name of the source file with no extension +SET(EXEC_FILE "${MYNAME_FOLDER}${EXAMPLE_NUMBER}") # the name of the executable file + +femusMacroBuildApplication(${MAIN_FILE} ${EXEC_FILE}) diff --git a/applications/NumPdeSpring2015/Thanuja/Ex3/Ex3.cpp b/applications/NumPdeSpring2015/Thanuja/Ex3/Ex3.cpp new file mode 100644 index 000000000..cc59a3e31 --- /dev/null +++ b/applications/NumPdeSpring2015/Thanuja/Ex3/Ex3.cpp @@ -0,0 +1,255 @@ +/** tutorial/Ex2 + * This example shows how to set and solve the weak form of the Poisson problem + * $$ \Delta u = 1 \text{ on }\Omega, $$ + * $$ u=0 \text{ on } \Gamma, $$ + * on a square domain $\Omega$ with boundary $\Gamma$; + * all the coarse-level meshes are removed; + * a multilevel problem and an equation system are initialized; + * a direct solver is used to solve the problem. + **/ + +#include "FemusInit.hpp" +#include "MultiLevelProblem.hpp" +#include "NumericVector.hpp" +#include "VTKWriter.hpp" +#include "GMVWriter.hpp" +#include "LinearImplicitSystem.hpp" + +using namespace femus; + +bool SetBoundaryCondition(const double &x, const double &y, const double &z,const char name[], double &value, const int facename, const double time) { + bool dirichlet=1; //dirichlet + value=0.; + return dirichlet; +} + +void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix); + + +int main(int argc, char **args) { + + // init Petsc-MPI communicator + FemusInit mpinit(argc, args, MPI_COMM_WORLD); + + // define multilevel mesh + MultiLevelMesh mlMsh; + // read coarse level mesh and generate finers level meshes + double scalingFactor=1.; + mlMsh.ReadCoarseMesh("./input/square.neu","seventh",scalingFactor); + /* "seventh" is the order of accuracy that is used in the gauss integration scheme + probably in the furure it is not going to be an argument of this function */ + unsigned numberOfUniformLevels=2; + unsigned numberOfSelectiveLevels=0; + mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL); + + // erase all the coarse mesh levels + mlMsh.EraseCoarseLevels(numberOfUniformLevels-1); + + // print mesh info + mlMsh.PrintInfo(); + + // define the multilevel solution and attach the mlMsh object to it + MultiLevelSolution mlSol(&mlMsh); + + // add variables to mlSol + mlSol.AddSolution("u",LAGRANGE, FIRST); + mlSol.Initialize("All"); + + // attach the boundary condition function and generate boundary data + mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition); + mlSol.GenerateBdc("u"); + + // define the multilevel problem attach the mlSol object to it + MultiLevelProblem mlProb(&mlSol); + + // add system Poisson in mlProb as a Linear Implicit System + LinearImplicitSystem & system = mlProb.add_system < LinearImplicitSystem > ("Poisson"); + + // add solution "u" to system + system.AddSolutionToSystemPDE("u"); + + // attach the assembling function to system + system.SetAssembleFunction(AssemblePoissonProblem); + + // initilaize and solve the system + system.init(); + system.solve(); + + // print solutions + std::vector < std::string > variablesToBePrinted; + variablesToBePrinted.push_back("All"); + + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + + GMVWriter gmvIO(&mlSol); + gmvIO.SetDebugOutput(true); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + + return 0; +} + + +/** + * This function assemble the stiffnes matrix KK and the residual vector Res + * such that + * KK w = RES = F - KK u0, + * and consequently + * u = u0 + w satisfies KK u = F + **/ + +void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix) { + // ml_prob is the global object from/to where get/set all the data + // level is the level of the PDE system to be assembled + // levelMax is the Maximum level of the MultiLevelProblem + // assembleMatrix is a flag that tells if only the residual or also the matrix should be assembled + + // extract pointers to the several objects that we are going to use + Mesh* msh = ml_prob._ml_msh->GetLevel(level); // pointer to the mesh (level) object + elem* el = msh->el; // pointer to the elem object in msh (level) + + MultiLevelSolution* mlSol = ml_prob._ml_sol; // pointer to the multilevel solution object + Solution* sol = ml_prob._ml_sol->GetSolutionLevel(level); // pointer to the solution (level) object + + LinearImplicitSystem* mlPdeSys = &ml_prob.get_system("Poisson"); // pointer to the linear implicit system named "Poisson" + LinearEquationSolver* pdeSys = mlPdeSys->_LinSolver[level]; // pointer to the equation (level) object + SparseMatrix* KK = pdeSys->_KK; // pointer to the global stifness matrix object in pdeSys (level) + NumericVector* RES = pdeSys->_RES; // pointer to the global residual vector object in pdeSys (level) + + const unsigned dim = msh->GetDimension(); // get the domain dimension of the problem + unsigned iproc = msh->processor_id(); // get the process_id (for parallel computation) + + //solution variable + unsigned soluIndex; + soluIndex = mlSol->GetIndex("u"); // get the position of "u" in the ml_sol object + unsigned soluType = mlSol->GetSolutionType(soluIndex); // get the finite element type for "u" + + unsigned soluPdeIndex; + soluPdeIndex = mlPdeSys->GetSolPdeIndex("u"); // get the position of "u" in the pdeSys object + + vector < double > solu; // local solution + + vector < vector < double > > x(dim); // local coordinates + unsigned xType = 2; // get the finite element type for "x", it is always 2 (LAGRANGE QUADRATIC) + + vector< int > KKDof; // local to global pdeSys dofs + vector phi; // local test function + vector phi_x; // local test function first order partial derivatives + vector phi_xx; // local test function second order partial derivatives + double weight; // gauss point weight + + vector< double > Res; // local redidual vector + vector< double > K; // local stiffness matrix + + // reserve memory for the local standar vectors + const unsigned maxSize = static_cast< unsigned > (ceil(pow(3,dim))); // conservative: based on line3, quad9, hex27 + solu.reserve(maxSize); + for(unsigned i = 0; i < dim; i++) + x[i].reserve(maxSize); + KKDof.reserve(maxSize); + phi.reserve(maxSize); + phi_x.reserve(maxSize*dim); + unsigned dim2=(3*(dim-1)+!(dim-1)); // dim2 is the number of second order partial derivatives (1,3,6 depending on the dimension) + phi_xx.reserve(maxSize*dim2); + Res.reserve(maxSize); + K.reserve(maxSize*maxSize); + + if( assembleMatrix ) + KK->zero(); // Set to zero all the entries of the Global Matrix + + // element loop: each process loops only on the elements that owns + for (int iel=msh->IS_Mts2Gmt_elem_offset[iproc]; iel < msh->IS_Mts2Gmt_elem_offset[iproc+1]; iel++) { + + unsigned kel = msh->IS_Mts2Gmt_elem[iel]; // mapping between paralell dof and mesh dof + short unsigned kelGeom = el->GetElementType( kel ); // element geometry type + unsigned nDofs = el->GetElementDofNumber( kel, soluType); // number of solution element dofs + unsigned nDofs2 = el->GetElementDofNumber( kel, xType); // number of coordinate element dofs + + // resize local arrays + KKDof.resize(nDofs); + solu.resize(nDofs); + for(int i=0; iGetMeshDof(kel, i, soluType); // local to global solution node + unsigned solDof = msh->GetMetisDof(iNode, soluType); // global to global mapping between solution node and solution dof + solu[i] = (*sol->_Sol[soluIndex])(solDof); // global extraction and local storage for the solution + KKDof[i] = pdeSys->GetKKDof(soluIndex, soluPdeIndex, iNode); // global to global mapping between solution node and pdeSys dof + } + + // local storage of coordinates + for( unsigned i=0; iGetMeshDof(kel, i, xType); // local to global coordinates node + unsigned xDof = msh->GetMetisDof(iNode, xType); // global to global mapping between coordinates node and coordinate dof + for(unsigned jdim=0; jdim_coordinate->_Sol[jdim])(xDof); // global extraction and local storage for the element coordinates + } + } + + if( level == levelMax || !el->GetRefinedElementIndex(kel)) { // do not care about this if now (it is used for the AMR) + // *** Gauss point loop *** + for(unsigned ig=0; ig < msh->_finiteElement[kelGeom][soluType]->GetGaussPointNumber(); ig++) { + // *** get gauss point weight, test function and test function partial derivatives *** + msh->_finiteElement[kelGeom][soluType]->Jacobian(x,ig,weight,phi,phi_x,phi_xx); + + // evaluate the solution, the solution derivatives and the coordinates in the gauss point + double soluGauss = 0; + vector < double > soluGauss_x(dim,0.); + vector < double > xGauss(dim,0.); + + for(unsigned i=0; iadd_vector_blocked(Res,KKDof); + if(assembleMatrix) KK->add_matrix_blocked(K,KKDof,KKDof); + } //end element loop for each process + + RES->close(); + if( assembleMatrix ) KK->close(); + // ***************** END ASSEMBLY ******************* + + +} + + diff --git a/applications/NumPdeSpring2015/Giacomo/Ex2/input/gambit/square.dbs b/applications/NumPdeSpring2015/Thanuja/Ex3/input/gambit/square.dbs similarity index 100% rename from applications/NumPdeSpring2015/Giacomo/Ex2/input/gambit/square.dbs rename to applications/NumPdeSpring2015/Thanuja/Ex3/input/gambit/square.dbs diff --git a/applications/NumPdeSpring2015/tutorial/Ex2/input/square.neu b/applications/NumPdeSpring2015/Thanuja/Ex3/input/square.neu similarity index 100% rename from applications/NumPdeSpring2015/tutorial/Ex2/input/square.neu rename to applications/NumPdeSpring2015/Thanuja/Ex3/input/square.neu diff --git a/applications/NumPdeSpring2015/Thanuka/Ex1/Ex1.cpp b/applications/NumPdeSpring2015/Thanuka/Ex1/Ex1.cpp index 0c5eaf37d..04b5866c5 100644 --- a/applications/NumPdeSpring2015/Thanuka/Ex1/Ex1.cpp +++ b/applications/NumPdeSpring2015/Thanuka/Ex1/Ex1.cpp @@ -69,13 +69,13 @@ int main(int argc, char **args) { variablesToBePrinted.push_back("P"); variablesToBePrinted.push_back("T"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); + GMVWriter gmvIO(&mlSol); variablesToBePrinted.push_back("all"); gmvIO.SetDebugOutput(false); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); return 0; } diff --git a/applications/NumPdeSpring2015/Thanuka/Ex2/Ex2.cpp b/applications/NumPdeSpring2015/Thanuka/Ex2/Ex2.cpp index ac0b0e406..cc59a3e31 100644 --- a/applications/NumPdeSpring2015/Thanuka/Ex2/Ex2.cpp +++ b/applications/NumPdeSpring2015/Thanuka/Ex2/Ex2.cpp @@ -79,12 +79,12 @@ int main(int argc, char **args) { std::vector < std::string > variablesToBePrinted; variablesToBePrinted.push_back("All"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); + GMVWriter gmvIO(&mlSol); gmvIO.SetDebugOutput(true); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); return 0; } diff --git a/applications/NumPdeSpring2015/tutorial/Ex1/Ex1.cpp b/applications/NumPdeSpring2015/tutorial/Ex1/Ex1.cpp index 0c5eaf37d..04b5866c5 100644 --- a/applications/NumPdeSpring2015/tutorial/Ex1/Ex1.cpp +++ b/applications/NumPdeSpring2015/tutorial/Ex1/Ex1.cpp @@ -69,13 +69,13 @@ int main(int argc, char **args) { variablesToBePrinted.push_back("P"); variablesToBePrinted.push_back("T"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); + GMVWriter gmvIO(&mlSol); variablesToBePrinted.push_back("all"); gmvIO.SetDebugOutput(false); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); return 0; } diff --git a/applications/NumPdeSpring2015/tutorial/Ex2/Ex2.cpp b/applications/NumPdeSpring2015/tutorial/Ex2/Ex2.cpp index ac0b0e406..57162ea1a 100644 --- a/applications/NumPdeSpring2015/tutorial/Ex2/Ex2.cpp +++ b/applications/NumPdeSpring2015/tutorial/Ex2/Ex2.cpp @@ -19,77 +19,146 @@ using namespace femus; bool SetBoundaryCondition(const double &x, const double &y, const double &z,const char name[], double &value, const int facename, const double time) { bool dirichlet=1; //dirichlet + if(1 == facename){ + dirichlet=1; + } + else if(2 == facename){ + dirichlet=0; + } value=0.; return dirichlet; + } void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix); +double GetErrorNorm(MultiLevelSolution *mlSol); int main(int argc, char **args) { // init Petsc-MPI communicator FemusInit mpinit(argc, args, MPI_COMM_WORLD); - - // define multilevel mesh + + + // define multilevel mesh MultiLevelMesh mlMsh; // read coarse level mesh and generate finers level meshes double scalingFactor=1.; - mlMsh.ReadCoarseMesh("./input/square.neu","seventh",scalingFactor); + //mlMsh.ReadCoarseMesh("./input/square_quad.neu","seventh",scalingFactor); + //mlMsh.ReadCoarseMesh("./input/square_tri.neu","seventh",scalingFactor); + //mlMsh.ReadCoarseMesh("./input/cube_hex.neu","seventh",scalingFactor); + mlMsh.ReadCoarseMesh("./input/cube_all_shapes.neu","seventh",scalingFactor); /* "seventh" is the order of accuracy that is used in the gauss integration scheme - probably in the furure it is not going to be an argument of this function */ - unsigned numberOfUniformLevels=2; - unsigned numberOfSelectiveLevels=0; - mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL); + probably in the furure it is not going to be an argument of this function */ - // erase all the coarse mesh levels - mlMsh.EraseCoarseLevels(numberOfUniformLevels-1); + const unsigned dim = mlMsh.GetLevel(0)->GetDimension(); - // print mesh info - mlMsh.PrintInfo(); + unsigned maxNumberOfMeshes = (dim == 2)? 7 : 4; + vector < vector < double > > semiNorm; + semiNorm.resize(maxNumberOfMeshes); - // define the multilevel solution and attach the mlMsh object to it - MultiLevelSolution mlSol(&mlMsh); + for(unsigned i = 0; i < maxNumberOfMeshes; i++){ // loop on the mesh level + + unsigned numberOfUniformLevels = i+1; + unsigned numberOfSelectiveLevels = 0; + mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL); + + // erase all the coarse mesh levels + mlMsh.EraseCoarseLevels(numberOfUniformLevels-1); - // add variables to mlSol - mlSol.AddSolution("u",LAGRANGE, FIRST); - mlSol.Initialize("All"); + // print mesh info + mlMsh.PrintInfo(); - // attach the boundary condition function and generate boundary data - mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition); - mlSol.GenerateBdc("u"); + FEOrder feOrder[3] = {FIRST, SERENDIPITY, SECOND}; + semiNorm[i].resize(3); + + for(unsigned j=0; j<3; j++){ // loop on the FE Order + // define the multilevel solution and attach the mlMsh object to it + MultiLevelSolution mlSol(&mlMsh); + + // add variables to mlSol + mlSol.AddSolution("u",LAGRANGE, feOrder[j]); + mlSol.Initialize("All"); - // define the multilevel problem attach the mlSol object to it - MultiLevelProblem mlProb(&mlSol); + // attach the boundary condition function and generate boundary data + mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition); + mlSol.GenerateBdc("u"); - // add system Poisson in mlProb as a Linear Implicit System - LinearImplicitSystem & system = mlProb.add_system < LinearImplicitSystem > ("Poisson"); + // define the multilevel problem attach the mlSol object to it + MultiLevelProblem mlProb(&mlSol); + + // add system Poisson in mlProb as a Linear Implicit System + LinearImplicitSystem & system = mlProb.add_system < LinearImplicitSystem > ("Poisson"); - // add solution "u" to system - system.AddSolutionToSystemPDE("u"); + // add solution "u" to system + system.AddSolutionToSystemPDE("u"); - // attach the assembling function to system - system.SetAssembleFunction(AssemblePoissonProblem); + // attach the assembling function to system + system.SetAssembleFunction(AssemblePoissonProblem); - // initilaize and solve the system - system.init(); - system.solve(); + // initilaize and solve the system + system.init(); + system.solve(); - // print solutions - std::vector < std::string > variablesToBePrinted; - variablesToBePrinted.push_back("All"); + semiNorm[i][j] = GetErrorNorm(&mlSol); + // print solutions + std::vector < std::string > variablesToBePrinted; + variablesToBePrinted.push_back("All"); - VTKWriter vtkIO(mlSol); - vtkIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + VTKWriter vtkIO(&mlSol); + vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - GMVWriter gmvIO(mlSol); - gmvIO.SetDebugOutput(true); - gmvIO.write_system_solutions(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); - + GMVWriter gmvIO(&mlSol); + gmvIO.SetDebugOutput(true); + gmvIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted); + } + } + + // print the seminorm of the error and the order of convergence between different levels + std::cout< &x){ + double pi=acos(-1.); + return cos(pi*x[0])*cos(pi*x[1]); +}; + + +void GetSolutionGradient(const vector < double > &x, vector < double > &solGrad){ + double pi=acos(-1.); + solGrad[0] = -pi*sin(pi*x[0])*cos(pi*x[1]); + solGrad[1] = -pi*cos(pi*x[0])*sin(pi*x[1]); +}; + + +double GetSolutionLaplace(const vector < double > &x){ + double pi=acos(-1.); + return -pi*pi*cos(pi*x[0])*cos(pi*x[1]) - pi*pi*cos(pi*x[0])*cos(pi*x[1]); +}; + /** * This function assemble the stiffnes matrix KK and the residual vector Res * such that @@ -97,7 +166,6 @@ int main(int argc, char **args) { * and consequently * u = u0 + w satisfies KK u = F **/ - void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const unsigned &levelMax, const bool &assembleMatrix) { // ml_prob is the global object from/to where get/set all the data // level is the level of the PDE system to be assembled @@ -221,7 +289,7 @@ void AssemblePoissonProblem(MultiLevelProblem &ml_prob, unsigned level, const un for(unsigned jdim=0; jdim_ml_msh->GetNumberOfLevels()-1u; + // extract pointers to the several objects that we are going to use + Mesh* msh = mlSol->_ml_msh->GetLevel(level); // pointer to the mesh (level) object + elem* el = msh->el; // pointer to the elem object in msh (level) + Solution* sol = mlSol->GetSolutionLevel(level); // pointer to the solution (level) object + + const unsigned dim = msh->GetDimension(); // get the domain dimension of the problem + unsigned iproc = msh->processor_id(); // get the process_id (for parallel computation) + + //solution variable + unsigned soluIndex; + soluIndex = mlSol->GetIndex("u"); // get the position of "u" in the ml_sol object + unsigned soluType = mlSol->GetSolutionType(soluIndex); // get the finite element type for "u" + + vector < double > solu; // local solution + + vector < vector < double > > x(dim); // local coordinates + unsigned xType = 2; // get the finite element type for "x", it is always 2 (LAGRANGE QUADRATIC) + vector phi; // local test function + vector phi_x; // local test function first order partial derivatives + vector phi_xx; // local test function second order partial derivatives + double weight; // gauss point weight + + // reserve memory for the local standar vectors + const unsigned maxSize = static_cast< unsigned > (ceil(pow(3,dim))); // conservative: based on line3, quad9, hex27 + solu.reserve(maxSize); + for(unsigned i = 0; i < dim; i++) + x[i].reserve(maxSize); + phi.reserve(maxSize); + phi_x.reserve(maxSize*dim); + unsigned dim2=(3*(dim-1)+!(dim-1)); // dim2 is the number of second order partial derivatives (1,3,6 depending on the dimension) + phi_xx.reserve(maxSize*dim2); + + double seminorm = 0.; + // element loop: each process loops only on the elements that owns + for (int iel=msh->IS_Mts2Gmt_elem_offset[iproc]; iel < msh->IS_Mts2Gmt_elem_offset[iproc+1]; iel++) { + + unsigned kel = msh->IS_Mts2Gmt_elem[iel]; // mapping between paralell dof and mesh dof + short unsigned kelGeom = el->GetElementType( kel ); // element geometry type + unsigned nDofs = el->GetElementDofNumber( kel, soluType); // number of solution element dofs + unsigned nDofs2 = el->GetElementDofNumber( kel, xType); // number of coordinate element dofs + + // resize local arrays + solu.resize(nDofs); + for(int i=0; iGetMeshDof(kel, i, soluType); // local to global solution node + unsigned solDof = msh->GetMetisDof(iNode, soluType); // global to global mapping between solution node and solution dof + solu[i] = (*sol->_Sol[soluIndex])(solDof); // global extraction and local storage for the solution + } + + // local storage of coordinates + for( unsigned i=0; iGetMeshDof(kel, i, xType); // local to global coordinates node + unsigned xDof = msh->GetMetisDof(iNode, xType); // global to global mapping between coordinates node and coordinate dof + for(unsigned jdim=0; jdim_coordinate->_Sol[jdim])(xDof); // global extraction and local storage for the element coordinates + } + } + + // *** Gauss point loop *** + for(unsigned ig=0; ig < msh->_finiteElement[kelGeom][soluType]->GetGaussPointNumber(); ig++) { + // *** get gauss point weight, test function and test function partial derivatives *** + msh->_finiteElement[kelGeom][soluType]->Jacobian(x,ig,weight,phi,phi_x,phi_xx); + + // evaluate the solution, the solution derivatives and the coordinates in the gauss point + double soluGauss = 0; + vector < double > soluGauss_x(dim,0.); + vector < double > xGauss(dim,0.); + + for(unsigned i=0; i solGrad(dim); + GetSolutionGradient(xGauss, solGrad); + for (unsigned j=0;j n_processors()) { + seminorm_vec->init(msh->n_processors(), 1, false, SERIAL); + } + else { + seminorm_vec->init(msh->n_processors(), 1 , false, PARALLEL); + } + + seminorm_vec->set(iproc, seminorm); + seminorm_vec->close(); + seminorm=seminorm_vec->l1_norm(); + + delete seminorm_vec; + + return sqrt(seminorm); + +} diff --git a/applications/NumPdeSpring2015/tutorial/Ex2/input/cube_all_shapes.neu b/applications/NumPdeSpring2015/tutorial/Ex2/input/cube_all_shapes.neu new file mode 100644 index 000000000..948292db5 --- /dev/null +++ b/applications/NumPdeSpring2015/tutorial/Ex2/input/cube_all_shapes.neu @@ -0,0 +1,240 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +cube_all_shapes +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 13:26:17 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 131 20 1 2 3 3 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 2 0.00000000000e+00 0.00000000000e+00 5.00000000000e-01 + 3 2.50000000000e-01 0.00000000000e+00 5.00000000000e-01 + 4 0.00000000000e+00 0.00000000000e+00 0.00000000000e+00 + 5 0.00000000000e+00 0.00000000000e+00 2.50000000000e-01 + 6 5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 7 2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 8 5.00000000000e-01 0.00000000000e+00 2.50000000000e-01 + 9 5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 10 0.00000000000e+00 -5.00000000000e-01 -5.00000000000e-01 + 11 2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 12 -5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 13 -5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 14 -5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 15 5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 16 5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 17 5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 18 -5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 19 0.00000000000e+00 5.00000000000e-01 -5.00000000000e-01 + 20 -2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 21 -5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 22 -5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 23 -5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 24 5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 25 5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 26 5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 27 -5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 28 -5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 29 -5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 30 5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 31 5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 32 5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 33 0.00000000000e+00 -5.00000000000e-01 5.00000000000e-01 + 34 -2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 35 -5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 36 -5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 37 5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 38 0.00000000000e+00 5.00000000000e-01 5.00000000000e-01 + 39 2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 40 0.00000000000e+00 5.00000000000e-01 0.00000000000e+00 + 41 0.00000000000e+00 5.00000000000e-01 -2.50000000000e-01 + 42 0.00000000000e+00 2.50000000000e-01 0.00000000000e+00 + 43 2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 44 0.00000000000e+00 0.00000000000e+00 -5.00000000000e-01 + 45 0.00000000000e+00 0.00000000000e+00 -2.50000000000e-01 + 46 0.00000000000e+00 -5.00000000000e-01 0.00000000000e+00 + 47 0.00000000000e+00 -2.50000000000e-01 0.00000000000e+00 + 48 -5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 49 -2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 50 5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 51 5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 52 2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 53 0.00000000000e+00 2.50000000000e-01 -5.00000000000e-01 + 54 0.00000000000e+00 5.00000000000e-01 2.50000000000e-01 + 55 5.00000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 56 0.00000000000e+00 2.50000000000e-01 5.00000000000e-01 + 57 5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 58 -2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 59 -5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 60 -5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 61 -2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 62 -5.00000000000e-01 0.00000000000e+00 2.50000000000e-01 + 63 -5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 64 -2.50000000000e-01 0.00000000000e+00 5.00000000000e-01 + 65 5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 66 2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 67 5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 68 0.00000000000e+00 -5.00000000000e-01 2.50000000000e-01 + 69 2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 70 0.00000000000e+00 -2.50000000000e-01 5.00000000000e-01 + 71 -2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 72 0.00000000000e+00 -2.50000000000e-01 -5.00000000000e-01 + 73 -2.50000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 74 -5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 75 -5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 76 0.00000000000e+00 -5.00000000000e-01 -2.50000000000e-01 + 77 -5.00000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 78 -2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 79 -5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 80 5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 81 2.50000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 82 2.50000000000e-01 0.00000000000e+00 2.50000000000e-01 + 83 0.00000000000e+00 2.50000000000e-01 2.50000000000e-01 + 84 2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 85 2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 86 5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 87 2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 88 3.22697570998e-01 2.51015938588e-01 2.50660192370e-01 + 89 4.11348785499e-01 1.25507969294e-01 3.75330096185e-01 + 90 4.11348785499e-01 3.75507969294e-01 1.25330096185e-01 + 91 4.11348785499e-01 3.75507969294e-01 3.75330096185e-01 + 92 4.11348785499e-01 1.25507969294e-01 1.25330096185e-01 + 93 1.61348785499e-01 3.75507969294e-01 1.25330096185e-01 + 94 1.61348785499e-01 1.25507969294e-01 3.75330096185e-01 + 95 2.50000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 96 5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 97 0.00000000000e+00 2.50000000000e-01 -2.50000000000e-01 + 98 2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 99 2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 100 2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 101 -2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 102 -2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 103 -2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 104 -2.50000000000e-01 0.00000000000e+00 2.50000000000e-01 + 105 -5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 106 -2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 107 -2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 108 0.00000000000e+00 -2.50000000000e-01 2.50000000000e-01 + 109 -5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 110 -2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 111 -2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 112 -2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 113 5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 114 2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 115 0.00000000000e+00 -2.50000000000e-01 -2.50000000000e-01 + 116 2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 117 2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 118 2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 119 -2.50000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 120 -5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 121 -2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 122 -2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 123 -2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 124 -2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 125 -2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 126 -5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 127 -2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 128 2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 129 5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 130 2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 131 2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 6 10 88 89 1 90 86 31 91 + 57 32 30 + 2 6 10 88 89 1 92 8 6 90 + 86 51 31 + 3 6 10 88 93 40 91 85 30 90 + 52 32 31 + 4 6 10 88 93 40 90 52 31 92 + 87 51 6 + 5 6 10 88 89 1 94 3 2 92 + 8 82 6 + 6 6 10 88 94 2 89 3 1 91 + 84 57 30 + 7 6 10 40 87 6 83 82 2 42 + 7 5 4 + 8 6 10 40 93 88 83 94 2 87 + 92 82 6 + 9 6 10 40 83 2 85 84 30 54 + 56 39 38 + 10 6 10 40 93 88 85 91 30 83 + 94 84 2 + 11 5 18 6 7 4 87 42 40 55 + 95 45 100 97 41 16 81 + 44 99 53 19 + 12 5 18 6 87 40 51 52 31 55 + 100 41 96 98 50 16 99 + 19 17 43 15 + 13 5 18 4 5 2 42 83 40 49 + 104 64 103 106 61 48 62 + 35 60 105 28 + 14 5 18 2 56 38 83 54 40 64 + 102 58 106 101 61 35 36 + 27 105 29 28 + 15 4 27 46 47 4 78 107 49 22 + 79 48 68 108 5 110 112 + 104 23 109 62 33 70 2 + 34 111 64 21 63 35 + 16 4 27 6 67 25 7 116 66 4 + 47 46 55 113 65 95 118 + 117 45 115 76 16 80 9 + 81 114 11 44 72 10 + 17 4 27 46 76 10 78 121 71 22 + 75 12 47 115 72 107 123 + 122 79 120 14 4 45 44 + 49 119 73 48 77 13 + 18 4 27 40 42 4 61 103 49 28 + 60 48 41 97 45 124 127 + 119 59 126 77 19 53 44 + 20 125 73 18 74 13 + 19 5 18 4 7 6 5 82 2 47 + 116 67 108 131 70 46 66 + 25 68 130 33 + 20 5 18 6 8 1 82 3 2 67 + 129 37 131 128 70 25 26 + 24 130 69 33 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 20 MATERIAL: 2 NFLAGS: 1 + 7 + 0 + 18 11 12 15 17 16 19 20 13 14 + 1 2 3 4 5 6 7 8 9 10 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 20 0 6 + 17 4 3 + 17 4 5 + 15 4 3 + 15 4 4 + 20 5 1 + 19 5 5 + 20 5 5 + 16 4 2 + 16 4 1 + 1 6 3 + 2 6 3 + 3 6 3 + 9 6 4 + 12 5 3 + 12 5 2 + 14 5 2 + 18 4 4 + 18 4 3 + 13 5 5 + 14 5 5 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 2 1 10 0 6 + 18 4 6 + 11 5 5 + 12 5 5 + 16 4 6 + 17 4 2 + 15 4 6 + 20 5 2 + 14 5 1 + 9 6 3 + 6 6 3 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/tutorial/Ex2/input/cube_hex.neu b/applications/NumPdeSpring2015/tutorial/Ex2/input/cube_hex.neu new file mode 100644 index 000000000..618bfd4ff --- /dev/null +++ b/applications/NumPdeSpring2015/tutorial/Ex2/input/cube_hex.neu @@ -0,0 +1,205 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +cube_hex +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 13:42:57 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 125 8 1 2 3 3 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 2 5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 3 5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 4 0.00000000000e+00 5.00000000000e-01 0.00000000000e+00 + 5 2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 6 0.00000000000e+00 0.00000000000e+00 0.00000000000e+00 + 7 0.00000000000e+00 2.50000000000e-01 0.00000000000e+00 + 8 2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 9 2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 10 5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 11 5.00000000000e-01 0.00000000000e+00 2.50000000000e-01 + 12 5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 13 5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 14 5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 15 5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 16 0.00000000000e+00 0.00000000000e+00 5.00000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 2.50000000000e-01 + 18 2.50000000000e-01 0.00000000000e+00 5.00000000000e-01 + 19 2.50000000000e-01 0.00000000000e+00 2.50000000000e-01 + 20 0.00000000000e+00 5.00000000000e-01 5.00000000000e-01 + 21 0.00000000000e+00 5.00000000000e-01 2.50000000000e-01 + 22 0.00000000000e+00 2.50000000000e-01 5.00000000000e-01 + 23 0.00000000000e+00 2.50000000000e-01 2.50000000000e-01 + 24 2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 25 2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 26 2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 27 2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 28 -5.00000000000e-01 5.00000000000e-01 0.00000000000e+00 + 29 -2.50000000000e-01 5.00000000000e-01 0.00000000000e+00 + 30 -5.00000000000e-01 0.00000000000e+00 0.00000000000e+00 + 31 -5.00000000000e-01 2.50000000000e-01 0.00000000000e+00 + 32 -2.50000000000e-01 0.00000000000e+00 0.00000000000e+00 + 33 -2.50000000000e-01 2.50000000000e-01 0.00000000000e+00 + 34 -5.00000000000e-01 0.00000000000e+00 5.00000000000e-01 + 35 -5.00000000000e-01 0.00000000000e+00 2.50000000000e-01 + 36 -2.50000000000e-01 0.00000000000e+00 5.00000000000e-01 + 37 -2.50000000000e-01 0.00000000000e+00 2.50000000000e-01 + 38 -5.00000000000e-01 5.00000000000e-01 5.00000000000e-01 + 39 -5.00000000000e-01 5.00000000000e-01 2.50000000000e-01 + 40 -2.50000000000e-01 5.00000000000e-01 5.00000000000e-01 + 41 -2.50000000000e-01 5.00000000000e-01 2.50000000000e-01 + 42 -5.00000000000e-01 2.50000000000e-01 5.00000000000e-01 + 43 -2.50000000000e-01 2.50000000000e-01 5.00000000000e-01 + 44 -5.00000000000e-01 2.50000000000e-01 2.50000000000e-01 + 45 -2.50000000000e-01 2.50000000000e-01 2.50000000000e-01 + 46 5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 47 5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 48 5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 49 5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 50 5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 51 5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 52 0.00000000000e+00 -5.00000000000e-01 5.00000000000e-01 + 53 0.00000000000e+00 -2.50000000000e-01 5.00000000000e-01 + 54 0.00000000000e+00 -5.00000000000e-01 0.00000000000e+00 + 55 0.00000000000e+00 -5.00000000000e-01 2.50000000000e-01 + 56 0.00000000000e+00 -2.50000000000e-01 0.00000000000e+00 + 57 0.00000000000e+00 -2.50000000000e-01 2.50000000000e-01 + 58 2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 59 2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 60 2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 61 2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 62 2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 63 2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 64 5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 65 5.00000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 66 5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 67 5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 68 5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 69 5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 70 0.00000000000e+00 -5.00000000000e-01 -5.00000000000e-01 + 71 0.00000000000e+00 -5.00000000000e-01 -2.50000000000e-01 + 72 0.00000000000e+00 0.00000000000e+00 -5.00000000000e-01 + 73 0.00000000000e+00 0.00000000000e+00 -2.50000000000e-01 + 74 0.00000000000e+00 -2.50000000000e-01 -5.00000000000e-01 + 75 0.00000000000e+00 -2.50000000000e-01 -2.50000000000e-01 + 76 2.50000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 77 2.50000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 78 2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 79 2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 80 2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 81 2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 82 -5.00000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 83 -2.50000000000e-01 -5.00000000000e-01 0.00000000000e+00 + 84 -5.00000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 85 -2.50000000000e-01 -2.50000000000e-01 0.00000000000e+00 + 86 -5.00000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 87 -5.00000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 88 -2.50000000000e-01 0.00000000000e+00 -5.00000000000e-01 + 89 -2.50000000000e-01 0.00000000000e+00 -2.50000000000e-01 + 90 -5.00000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 91 -5.00000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 92 -2.50000000000e-01 -5.00000000000e-01 -5.00000000000e-01 + 93 -2.50000000000e-01 -5.00000000000e-01 -2.50000000000e-01 + 94 -5.00000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 95 -2.50000000000e-01 -2.50000000000e-01 -5.00000000000e-01 + 96 -5.00000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 97 -2.50000000000e-01 -2.50000000000e-01 -2.50000000000e-01 + 98 -5.00000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 99 -5.00000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 100 -5.00000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 101 -5.00000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 102 -2.50000000000e-01 -5.00000000000e-01 5.00000000000e-01 + 103 -2.50000000000e-01 -5.00000000000e-01 2.50000000000e-01 + 104 -2.50000000000e-01 -2.50000000000e-01 5.00000000000e-01 + 105 -2.50000000000e-01 -2.50000000000e-01 2.50000000000e-01 + 106 0.00000000000e+00 5.00000000000e-01 -5.00000000000e-01 + 107 0.00000000000e+00 5.00000000000e-01 -2.50000000000e-01 + 108 0.00000000000e+00 2.50000000000e-01 -5.00000000000e-01 + 109 0.00000000000e+00 2.50000000000e-01 -2.50000000000e-01 + 110 5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 111 5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 112 5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 113 5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 114 2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 115 2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 116 2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 117 2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 118 -5.00000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 119 -2.50000000000e-01 5.00000000000e-01 -5.00000000000e-01 + 120 -5.00000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 121 -2.50000000000e-01 5.00000000000e-01 -2.50000000000e-01 + 122 -5.00000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 123 -2.50000000000e-01 2.50000000000e-01 -5.00000000000e-01 + 124 -5.00000000000e-01 2.50000000000e-01 -2.50000000000e-01 + 125 -2.50000000000e-01 2.50000000000e-01 -2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 4 27 1 3 2 13 15 11 12 + 14 10 5 9 8 25 27 + 19 24 26 18 4 7 6 + 21 23 17 20 22 16 + 2 4 27 6 7 4 32 33 29 30 + 31 28 17 23 21 37 45 + 41 35 44 39 16 22 20 + 36 43 40 34 42 38 + 3 4 27 2 8 6 47 59 56 46 + 58 54 11 19 17 51 63 + 57 50 62 55 10 18 16 + 49 61 53 48 60 52 + 4 4 27 2 8 6 65 77 73 64 + 76 72 47 59 56 69 81 + 75 68 80 74 46 58 54 + 67 79 71 66 78 70 + 5 4 27 54 71 70 83 93 92 82 + 91 90 56 75 74 85 97 + 95 84 96 94 6 73 72 + 32 89 88 30 87 86 + 6 4 27 54 83 82 55 103 99 52 + 102 98 56 85 84 57 105 + 101 53 104 100 6 32 30 + 17 37 35 16 36 34 + 7 4 27 4 7 6 107 109 73 106 + 108 72 5 9 8 116 117 + 77 114 115 76 1 3 2 + 112 113 65 110 111 64 + 8 4 27 4 7 6 29 33 32 28 + 31 30 107 109 73 121 125 + 89 120 124 87 106 108 72 + 119 123 88 118 122 86 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 8 MATERIAL: 2 NFLAGS: 1 + 7 + 0 + 8 7 6 5 4 3 2 1 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 16 0 6 + 5 4 3 + 5 4 5 + 6 4 2 + 6 4 5 + 3 4 4 + 3 4 3 + 4 4 6 + 4 4 4 + 1 4 5 + 1 4 4 + 7 4 6 + 7 4 4 + 2 4 2 + 8 4 4 + 8 4 3 + 2 4 3 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 2 1 8 0 6 + 8 4 6 + 7 4 3 + 4 4 3 + 5 4 2 + 6 4 3 + 3 4 6 + 2 4 6 + 1 4 3 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/cube_all_shapes.dbs b/applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/cube_all_shapes.dbs new file mode 100644 index 000000000..3067a82e0 Binary files /dev/null and b/applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/cube_all_shapes.dbs differ diff --git a/applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/cube_hex.dbs b/applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/cube_hex.dbs new file mode 100644 index 000000000..5dc7ebc9a Binary files /dev/null and b/applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/cube_hex.dbs differ diff --git a/applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/square_quad.dbs b/applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/square_quad.dbs new file mode 100644 index 000000000..2d20b855d Binary files /dev/null and b/applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/square_quad.dbs differ diff --git a/applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/square_tri.dbs b/applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/square_tri.dbs new file mode 100644 index 000000000..510ebfa53 Binary files /dev/null and b/applications/NumPdeSpring2015/tutorial/Ex2/input/gambit/square_tri.dbs differ diff --git a/applications/NumPdeSpring2015/tutorial/Ex2/input/square_quad.neu b/applications/NumPdeSpring2015/tutorial/Ex2/input/square_quad.neu new file mode 100644 index 000000000..3a4385711 --- /dev/null +++ b/applications/NumPdeSpring2015/tutorial/Ex2/input/square_quad.neu @@ -0,0 +1,62 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +square_quad +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 13:54:34 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 25 4 1 1 2 2 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 -5.00000000000e-01 -5.00000000000e-01 + 2 5.00000000000e-01 -5.00000000000e-01 + 3 0.00000000000e+00 -5.00000000000e-01 + 4 -2.50000000000e-01 -5.00000000000e-01 + 5 2.50000000000e-01 -5.00000000000e-01 + 6 5.00000000000e-01 5.00000000000e-01 + 7 5.00000000000e-01 0.00000000000e+00 + 8 5.00000000000e-01 -2.50000000000e-01 + 9 5.00000000000e-01 2.50000000000e-01 + 10 -5.00000000000e-01 5.00000000000e-01 + 11 0.00000000000e+00 5.00000000000e-01 + 12 2.50000000000e-01 5.00000000000e-01 + 13 -2.50000000000e-01 5.00000000000e-01 + 14 -5.00000000000e-01 0.00000000000e+00 + 15 -5.00000000000e-01 2.50000000000e-01 + 16 -5.00000000000e-01 -2.50000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 + 18 0.00000000000e+00 -2.50000000000e-01 + 19 -2.50000000000e-01 0.00000000000e+00 + 20 -2.50000000000e-01 -2.50000000000e-01 + 21 2.50000000000e-01 0.00000000000e+00 + 22 2.50000000000e-01 -2.50000000000e-01 + 23 0.00000000000e+00 2.50000000000e-01 + 24 -2.50000000000e-01 2.50000000000e-01 + 25 2.50000000000e-01 2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 2 9 1 4 3 18 17 19 14 + 16 20 + 2 2 9 3 5 2 8 7 21 17 + 18 22 + 3 2 9 14 19 17 23 11 13 10 + 15 24 + 4 2 9 17 21 7 9 6 12 11 + 23 25 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 4 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 8 0 6 + 4 2 3 + 3 2 3 + 2 2 2 + 4 2 2 + 1 2 1 + 2 2 1 + 3 2 4 + 1 2 4 +ENDOFSECTION diff --git a/applications/NumPdeSpring2015/tutorial/Ex2/input/square_tri.neu b/applications/NumPdeSpring2015/tutorial/Ex2/input/square_tri.neu new file mode 100644 index 000000000..c198885a0 --- /dev/null +++ b/applications/NumPdeSpring2015/tutorial/Ex2/input/square_tri.neu @@ -0,0 +1,62 @@ + CONTROL INFO 2.3.16 +** GAMBIT NEUTRAL FILE +square_tri +PROGRAM: Gambit VERSION: 2.3.16 +13 Mar 2015 13:53:34 + NUMNP NELEM NGRPS NBSETS NDFCD NDFVL + 25 8 1 1 2 2 +ENDOFSECTION + NODAL COORDINATES 2.3.16 + 1 -5.00000000000e-01 -5.00000000000e-01 + 2 5.00000000000e-01 -5.00000000000e-01 + 3 0.00000000000e+00 -5.00000000000e-01 + 4 -2.50000000000e-01 -5.00000000000e-01 + 5 2.50000000000e-01 -5.00000000000e-01 + 6 5.00000000000e-01 5.00000000000e-01 + 7 5.00000000000e-01 0.00000000000e+00 + 8 5.00000000000e-01 -2.50000000000e-01 + 9 5.00000000000e-01 2.50000000000e-01 + 10 -5.00000000000e-01 5.00000000000e-01 + 11 0.00000000000e+00 5.00000000000e-01 + 12 2.50000000000e-01 5.00000000000e-01 + 13 -2.50000000000e-01 5.00000000000e-01 + 14 -5.00000000000e-01 0.00000000000e+00 + 15 -5.00000000000e-01 2.50000000000e-01 + 16 -5.00000000000e-01 -2.50000000000e-01 + 17 0.00000000000e+00 0.00000000000e+00 + 18 0.00000000000e+00 -2.50000000000e-01 + 19 -2.50000000000e-01 0.00000000000e+00 + 20 -2.50000000000e-01 -2.50000000000e-01 + 21 2.50000000000e-01 0.00000000000e+00 + 22 2.50000000000e-01 -2.50000000000e-01 + 23 0.00000000000e+00 2.50000000000e-01 + 24 -2.50000000000e-01 2.50000000000e-01 + 25 2.50000000000e-01 2.50000000000e-01 +ENDOFSECTION + ELEMENTS/CELLS 2.3.16 + 1 3 6 3 18 17 19 14 20 + 2 3 6 1 4 3 20 14 16 + 3 3 6 2 8 7 21 17 22 + 4 3 6 3 5 2 22 17 18 + 5 3 6 17 23 11 13 10 24 + 6 3 6 14 19 17 24 10 15 + 7 3 6 7 9 6 12 11 25 + 8 3 6 17 21 7 25 11 23 +ENDOFSECTION + ELEMENT GROUP 2.3.16 +GROUP: 1 ELEMENTS: 8 MATERIAL: 2 NFLAGS: 1 + 5 + 0 + 1 2 3 4 5 6 7 8 +ENDOFSECTION + BOUNDARY CONDITIONS 2.3.16 + 1 1 8 0 6 + 7 3 2 + 5 3 2 + 3 3 1 + 7 3 1 + 2 3 1 + 4 3 1 + 6 3 3 + 2 3 3 +ENDOFSECTION diff --git a/applications/OptimalControl/fe_test/EqnT.cpp b/applications/OptimalControl/fe_test/EqnT.cpp index 9c4baea89..3522d6282 100644 --- a/applications/OptimalControl/fe_test/EqnT.cpp +++ b/applications/OptimalControl/fe_test/EqnT.cpp @@ -13,6 +13,7 @@ #include "FETypeEnum.hpp" #include "NormTangEnum.hpp" #include "VBTypeEnum.hpp" +#include "GeomElTypeEnum.hpp" #include "QTYnumEnum.hpp" #include "Domain.hpp" #include "TimeLoop.hpp" @@ -32,20 +33,20 @@ const double time = 0.; -//========== PROCESSOR INDEX - const uint myproc = ml_prob.GetMeshTwo()._iproc; - -//========= BCHandling ========= - const double penalty_val = ml_prob.GetMeshTwo().GetRuntimeMap().get("penalty_val"); - //======== ELEMENT MAPPING ======= - const uint space_dim = ml_prob.GetMeshTwo().get_dim(); - const uint meshql = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("meshql"); - const uint mesh_ord = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("mesh_ord"); + const uint space_dim = ml_prob._ml_msh->GetDimension(); - my_system._A[Level]->zero(); - my_system._b[Level]->zero(); + my_system._LinSolver[Level]->_KK->zero(); + my_system._LinSolver[Level]->_RESC->zero(); +// ========================================== + Mesh *mymsh = ml_prob._ml_msh->GetLevel(Level); + elem *myel = mymsh->el; + const unsigned myproc = mymsh->processor_id(); + +// ========================================== +// ========================================== + {//BEGIN VOLUME //==== AUXILIARY ============== @@ -65,7 +66,7 @@ for (uint iel=0; iel < (nel_e - nel_b); iel++) { CurrentElem currelem(Level,VV,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); - + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); //=========INTERNAL QUANTITIES (unknowns of the equation) ========= @@ -74,31 +75,31 @@ Tempold.VectWithQtyFillBasic(); Tempold.Allocate(); -//=========INTERNAL QUANTITIES (unknowns of the equation) ========= - CurrentQuantity Temp2(currgp); - Temp2._qtyptr = my_system.GetUnknownQuantitiesVector()[1]; - Temp2.VectWithQtyFillBasic(); - Temp2.Allocate(); +// //=========INTERNAL QUANTITIES (unknowns of the equation) ========= +// CurrentQuantity Temp2(currgp); +// Temp2._qtyptr = my_system.GetUnknownQuantitiesVector()[1]; +// Temp2.VectWithQtyFillBasic(); +// Temp2.Allocate(); //=========INTERNAL QUANTITIES (unknowns of the equation) ========= - CurrentQuantity Temp3(currgp); - Temp3._qtyptr = my_system.GetUnknownQuantitiesVector()[2]; - Temp3.VectWithQtyFillBasic(); - Temp3.Allocate(); +// CurrentQuantity Temp3(currgp); +// Temp3._qtyptr = my_system.GetUnknownQuantitiesVector()[2]; +// Temp3.VectWithQtyFillBasic(); +// Temp3.Allocate(); //=========EXTERNAL QUANTITIES (couplings) ===== //========= //DOMAIN MAPPING CurrentQuantity xyz(currgp); //no quantity xyz._dim = space_dim; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //==================Quadratic domain, auxiliary, must be QUADRATIC!!! ========== CurrentQuantity xyz_refbox(currgp); //no quantity xyz_refbox._dim = space_dim; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER;; + xyz_refbox._ndof = myel->GetElementDofNumber(ZERO_ELEM,BIQUADR_FE); xyz_refbox.Allocate(); @@ -109,7 +110,7 @@ currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); //MY EQUATION @@ -122,8 +123,8 @@ currelem.SetElDofsBc(); Tempold.GetElemDofs(); - Temp2.GetElemDofs(); - Temp3.GetElemDofs(); +// Temp2.GetElemDofs(); +// Temp3.GetElemDofs(); // =============== // Now the point is this: there are several functions of space @@ -158,8 +159,8 @@ for (uint fe = 0; fe < QL; fe++) { //======= end of the "COMMON SHAPE PART"================== Tempold.val_g(); - Temp2.val_g(); - Temp3.val_g(); +// Temp2.val_g(); +// Temp3.val_g(); // always remember to get the dofs for the variables you use! // The point is that you fill the dofs with different functions... @@ -169,8 +170,8 @@ for (uint fe = 0; fe < QL; fe++) { for (uint i=0; i < Tempold._ndof/*the maximum number is for biquadratic*/; i++) { const double phii_g = currgp._phi_ndsQLVB_g[Tempold._FEord][i]; - const double phii_gLL = currgp._phi_ndsQLVB_g[Temp2._FEord][i]; - const double phii_gKK = currgp._phi_ndsQLVB_g[Temp3._FEord][i]; +// const double phii_gLL = currgp._phi_ndsQLVB_g[Temp2._FEord][i]; +// const double phii_gKK = currgp._phi_ndsQLVB_g[Temp3._FEord][i]; for (uint idim = 0; idim < space_dim; idim++) dphiidx_g[idim] = currgp._dphidxyz_ndsQLVB_g[Tempold._FEord][i+idim*Tempold._ndof]; @@ -184,41 +185,41 @@ for (uint fe = 0; fe < QL; fe++) { currelem.Mat()(i,i) += (1-currelem.GetBCDofFlag()[i])*detb; //========= SECOND ROW ===================== - int ip1 = i + Tempold._ndof; - - if (i < currelem.GetElemType(Temp2._FEord)->GetNDofs() ) { - currelem.Rhs()(ip1) += - currelem.GetBCDofFlag()[ip1]*dtxJxW_g*( - 0.07*phii_gLL - ) - + (1-currelem.GetBCDofFlag()[ip1])*detb*(Temp2._val_dofs[i]); - - currelem.Mat()(ip1,ip1) += (1-currelem.GetBCDofFlag()[ip1])*detb; - } +// int ip1 = i + Tempold._ndof; +// +// if (i < currelem.GetElemType(Temp2._FEord)->GetNDofs() ) { +// currelem.Rhs()(ip1) += +// currelem.GetBCDofFlag()[ip1]*dtxJxW_g*( +// 0.07*phii_gLL +// ) +// + (1-currelem.GetBCDofFlag()[ip1])*detb*(Temp2._val_dofs[i]); +// +// currelem.Mat()(ip1,ip1) += (1-currelem.GetBCDofFlag()[ip1])*detb; +// } -//======= THIRD ROW =================================== - int ip2 = i + Tempold._ndof + Temp2._ndof; - - if (i < currelem.GetElemType(Temp3._FEord)->GetNDofs() ) { - currelem.Rhs()(ip2) += - currelem.GetBCDofFlag()[ip2]*dtxJxW_g*( - 0.07*phii_gKK - ) - + (1-currelem.GetBCDofFlag()[ip2])*detb*(Temp3._val_dofs[i]); - - currelem.Mat()(ip2,ip2) += (1-currelem.GetBCDofFlag()[ip2])*detb; - } +// //======= THIRD ROW =================================== +// int ip2 = i + Tempold._ndof + Temp2._ndof; +// +// if (i < currelem.GetElemType(Temp3._FEord)->GetNDofs() ) { +// currelem.Rhs()(ip2) += +// currelem.GetBCDofFlag()[ip2]*dtxJxW_g*( +// 0.07*phii_gKK +// ) +// + (1-currelem.GetBCDofFlag()[ip2])*detb*(Temp3._val_dofs[i]); +// +// currelem.Mat()(ip2,ip2) += (1-currelem.GetBCDofFlag()[ip2])*detb; +// } // Matrix Assemblying --------------------------- for (uint j=0; jGetNDofs() ) { - if ( j < currelem.GetElemType(Temp2._FEord)->GetNDofs() ) { - currelem.Mat()(ip1,jp1) += - currelem.GetBCDofFlag()[ip1]* - dtxJxW_g*( -// phij_gLL*phii_gLL - + Lap_gLL - ); - } - } +// if ( i < currelem.GetElemType(Temp2._FEord)->GetNDofs() ) { +// if ( j < currelem.GetElemType(Temp2._FEord)->GetNDofs() ) { +// currelem.Mat()(ip1,jp1) += +// currelem.GetBCDofFlag()[ip1]* +// dtxJxW_g*( +// // phij_gLL*phii_gLL +// + Lap_gLL +// ); +// } +// } //============= THIRD ROW ============= //======= DIAGONAL ================== - if ( i < currelem.GetElemType(Temp3._FEord)->GetNDofs() ) { - if ( j < currelem.GetElemType(Temp3._FEord)->GetNDofs() ) { - currelem.Mat()(ip2,jp2) += - currelem.GetBCDofFlag()[ip2]* - dtxJxW_g*( - phij_gKK*phii_gKK - + Lap_gKK - ); - } - } +// if ( i < currelem.GetElemType(Temp3._FEord)->GetNDofs() ) { +// if ( j < currelem.GetElemType(Temp3._FEord)->GetNDofs() ) { +// currelem.Mat()(ip2,jp2) += +// currelem.GetBCDofFlag()[ip2]* +// dtxJxW_g*( +// phij_gKK*phii_gKK +// + Lap_gKK +// ); +// } +// } @@ -272,8 +273,8 @@ for (uint fe = 0; fe < QL; fe++) { currelem.Mat().print_scientific(std::cout); - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); } // end of element loop // ***************************************************************** @@ -286,12 +287,12 @@ for (uint fe = 0; fe < QL; fe++) { }//END VOLUME - my_system._A[Level]->close(); - my_system._b[Level]->close(); + my_system._LinSolver[Level]->_KK->close(); + my_system._LinSolver[Level]->_RESC->close(); #ifdef DEFAULT_PRINT_INFO std::cout << " Matrix and RHS assembled for equation " << my_system.name() - << " Level "<< Level << " dofs " << my_system._A[Level]->n() << std::endl; + << " Level "<< Level << " dofs " << my_system._LinSolver[Level]->_KK->n() << std::endl; #endif return; diff --git a/applications/OptimalControl/fe_test/TempQuantities.cpp b/applications/OptimalControl/fe_test/TempQuantities.cpp index 730e33973..5417eb89b 100644 --- a/applications/OptimalControl/fe_test/TempQuantities.cpp +++ b/applications/OptimalControl/fe_test/TempQuantities.cpp @@ -66,7 +66,7 @@ void Temperature::heatflux_txyz(const double /*t*/, const double* /*xyz*/, doubl // T' and its adjoint must be Dirichlet homogeneous everywhere on the boundary, by definition. - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box= static_cast(_qtymap.GetMeshTwo()->GetDomain()); diff --git a/applications/OptimalControl/fe_test/input/femus_conf.in b/applications/OptimalControl/fe_test/input/femus_conf.in index addb94e79..e7a648d38 100644 --- a/applications/OptimalControl/fe_test/input/femus_conf.in +++ b/applications/OptimalControl/fe_test/input/femus_conf.in @@ -1,21 +1,4 @@ - -# double # mesh file consistency - -nolevels 3 -meshql 1 # ------------- # for THE APP # =MESH CONSISTENCY=== # ==== in library routines # depends on the kind of Mesh that is used# depends basically on the Boundary Mesh# 0=QUADRATIC Mapping 1=LINEAR Mapping -mesh_ord 0 # ==== both for the App and for Gencase ====== # ==== DO IT ONLY FOR Gencase ====== # GAMBIT mesh should provide this info# 0=QUADRATIC GeomElements (Quad8,Quad9,Hex27,...)# 1=LINEAR GeomElements (Quad4,Hex8,...) -geomel_type 3 # ==== DO IT ONLY FOR Gencase ====== # GAMBIT mesh should provide this info -dimension 2 -bdry_toll 0.0000001 # ==== not in library routines, but library-type - - -# --------------------- -penalty_val 1.e10 # ==== not in library routines, but library-type - - - - # double # mesh file consistency diff --git a/applications/OptimalControl/fe_test/main.cpp b/applications/OptimalControl/fe_test/main.cpp index 313a313de..2be1a06b3 100644 --- a/applications/OptimalControl/fe_test/main.cpp +++ b/applications/OptimalControl/fe_test/main.cpp @@ -58,13 +58,16 @@ const double Lref = physics_map.get("Lref"); // reference L // ======= Mesh ===== - FemusInputParser mesh_map("Mesh",files.GetOutputPath()); + const unsigned NoLevels = 3; + const unsigned dim = 2; + const GeomElType geomel_type = QUAD; - GenCase mesh(mesh_map,""); + GenCase mesh(NoLevels,dim,geomel_type,""); mesh.SetLref(1.); // ======= MyDomainShape (optional, implemented as child of Domain) ==================== FemusInputParser box_map("Box",files.GetOutputPath()); + Box mybox(mesh.get_dim(),box_map); mybox.InitAndNondimensionalize(mesh.get_Lref()); @@ -90,16 +93,18 @@ //======================================================== Temperature temperature("Qty_Temperature",qty_map,1,0/*biquadratic*/); qty_map.AddQuantity(&temperature); - Temperature temperature2("Qty_Temperature2",qty_map,1,1/*linear*/); qty_map.AddQuantity(&temperature2); - Temperature temperature3("Qty_Temperature3",qty_map,1,2/*constant*/); qty_map.AddQuantity(&temperature3); +// Temperature temperature2("Qty_Temperature2",qty_map,1,1/*linear*/); qty_map.AddQuantity(&temperature2); +// Temperature temperature3("Qty_Temperature3",qty_map,1,2/*constant*/); qty_map.AddQuantity(&temperature3); // ===== end QuantityMap ========================================= // ====== Start new main ================================= MultiLevelMesh ml_msh; ml_msh.GenerateCoarseBoxMesh(8,8,0,0,1,0,1,0,1,QUAD9,"fifth"); // ml_msh.GenerateCoarseBoxMesh(numelemx,numelemy,numelemz,xa,xb,ya,yb,za,zb,elemtype,"seventh"); - ml_msh.RefineMesh(mesh_map.get("nolevels"),mesh_map.get("nolevels"),NULL); + ml_msh.RefineMesh(NoLevels,NoLevels,NULL); ml_msh.PrintInfo(); + ml_msh.SetDomain(&mybox); + MultiLevelSolution ml_sol(&ml_msh); ml_sol.AddSolution("FAKE",LAGRANGE,SECOND,0); @@ -117,8 +122,8 @@ SystemTwo & eqnT = ml_prob.add_system("Eqn_T"); eqnT.AddSolutionToSystemPDE("FAKE"); eqnT.AddUnknownToSystemPDE(&temperature); - eqnT.AddUnknownToSystemPDE(&temperature2); - eqnT.AddUnknownToSystemPDE(&temperature3); +// eqnT.AddUnknownToSystemPDE(&temperature2); +// eqnT.AddUnknownToSystemPDE(&temperature3); eqnT.SetAssembleFunction(GenMatRhsT); //================================ @@ -135,11 +140,11 @@ SystemTwo* sys = static_cast(eqn->second); // //===================== - sys -> init(); + sys -> init_two(); sys -> _LinSolver[0]->set_solver_type(GMRES); //if I keep PREONLY it doesn't run //===================== - sys -> init_sys(); + sys -> init_unknown_vars(); //===================== sys -> _dofmap.ComputeMeshToDof(); //===================== @@ -149,7 +154,7 @@ //===================== sys -> _bcond.GenerateBdc(); //===================== - sys -> ReadMGOps(files.GetOutputPath()); + GenCase::ReadMGOps(files.GetOutputPath(),sys); } diff --git a/applications/OptimalControl/mhdopt/EqnMHD.cpp b/applications/OptimalControl/mhdopt/EqnMHD.cpp index 30272e20d..c6f85721a 100644 --- a/applications/OptimalControl/mhdopt/EqnMHD.cpp +++ b/applications/OptimalControl/mhdopt/EqnMHD.cpp @@ -11,6 +11,7 @@ #include "Quantity.hpp" #include "MultiLevelProblem.hpp" #include "FETypeEnum.hpp" +#include "GeomElTypeEnum.hpp" #include "NormTangEnum.hpp" #include "QTYnumEnum.hpp" #include "TimeLoop.hpp" @@ -47,29 +48,31 @@ void GenMatRhsMHD(MultiLevelProblem &ml_prob, unsigned Level, const unsigned &gr const int NonStatMHD = (int) ml_prob.GetInputParser().get("NonStatMHD"); const double dt = 1.; //ml_prob._timeloop._timemap.get("dt"); -//========= BCHandling ========= - const double penalty_val = ml_prob.GetMeshTwo().GetRuntimeMap().get("penalty_val"); - //======== GEOMETRICAL ELEMENT ======= - const uint space_dim = ml_prob.GetMeshTwo().get_dim(); - const uint mesh_ord = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("mesh_ord"); - const uint meshql = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("meshql"); //======== ELEMENT MAPPING ======= + const uint space_dim = ml_prob._ml_msh->GetDimension(); + + my_system._LinSolver[Level]->_KK->zero(); + my_system._LinSolver[Level]->_RESC->zero(); + +// ========================================== + Mesh *mymsh = ml_prob._ml_msh->GetLevel(Level); + elem *myel = mymsh->el; + const unsigned myproc = mymsh->processor_id(); + +// ========================================== +// ========================================== - my_system._A[Level]->zero(); - my_system._b[Level]->zero(); - {//BEGIN VOLUME -//====================== -//====================== + const uint mesh_vb = VV; - const uint nel_e = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*ml_prob.GetMeshTwo()._iproc+Level+1]; - const uint nel_b = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*ml_prob.GetMeshTwo()._iproc+Level]; + const uint nel_e = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*myproc+Level+1]; + const uint nel_b = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*myproc+Level]; for (uint iel=0; iel < (nel_e - nel_b); iel++) { CurrentElem currelem(Level,VV,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); - + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); //=========INTERNAL QUANTITIES (unknowns of the equation) ================== @@ -121,15 +124,15 @@ void GenMatRhsMHD(MultiLevelProblem &ml_prob, unsigned Level, const unsigned &gr //========= //DOMAIN MAPPING CurrentQuantity xyz(currgp); xyz._dim = DIMENSION; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //================== Quadratic domain, auxiliary CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = DIMENSION; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = myel->GetElementDofNumber(ZERO_ELEM,BIQUADR_FE); xyz_refbox.Allocate(); CurrentQuantity Bext(currgp); @@ -152,11 +155,11 @@ void GenMatRhsMHD(MultiLevelProblem &ml_prob, unsigned Level, const unsigned &gr currelem.Mat().zero(); currelem.Rhs().zero(); - currelem.SetDofobjConnCoords(ml_prob.GetMeshTwo()._iproc,iel); + currelem.SetDofobjConnCoords(myproc,iel); currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); currelem.SetElDofsBc(); @@ -332,8 +335,8 @@ for (uint fe = 0; fe < QL; fe++) { // end element gaussian integration loop /// Add element matrix and rhs to the global ones. - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); } // end of element loop @@ -357,7 +360,7 @@ for (uint fe = 0; fe < QL; fe++) { for (uint iel=0;iel < (nel_e - nel_b) ; iel++) { CurrentElem currelem(Level,BB,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); - + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); //=========INTERNAL QUANTITIES (unknowns of the equation) ================== @@ -409,15 +412,15 @@ for (uint fe = 0; fe < QL; fe++) { //========= //DOMAIN MAPPING CurrentQuantity xyz(currgp); xyz._dim = DIMENSION; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //================== Quadratic domain, auxiliary CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = DIMENSION; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = myel->GetElementFaceDofNumber(ZERO_ELEM,ZERO_FACE,BIQUADR_FE); xyz_refbox.Allocate(); CurrentQuantity Bext(currgp); @@ -450,7 +453,7 @@ for (uint fe = 0; fe < QL; fe++) { currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); currelem.SetElDofsBc(); @@ -529,8 +532,8 @@ for (uint fe = 0; fe < QL; fe++) { } // end BDRYelement gaussian integration loop - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); } @@ -540,12 +543,12 @@ for (uint fe = 0; fe < QL; fe++) { // END BOUNDARY // ***************************************************************** - my_system._A[Level]->close(); - my_system._b[Level]->close(); + my_system._LinSolver[Level]->_KK->close(); + my_system._LinSolver[Level]->_RESC->close(); #ifdef DEFAULT_PRINT_INFO std::cout << " GenMatRhs " << my_system.name() << ": assembled Level " << Level - << " with " << my_system._A[Level]->m() << " dofs " << std::endl; + << " with " << my_system._LinSolver[Level]->_KK->m() << " dofs " << std::endl; #endif diff --git a/applications/OptimalControl/mhdopt/EqnMHDAD.cpp b/applications/OptimalControl/mhdopt/EqnMHDAD.cpp index c3e5296ba..308837d42 100644 --- a/applications/OptimalControl/mhdopt/EqnMHDAD.cpp +++ b/applications/OptimalControl/mhdopt/EqnMHDAD.cpp @@ -12,6 +12,7 @@ #include "MultiLevelMeshTwo.hpp" #include "MultiLevelProblem.hpp" #include "FETypeEnum.hpp" +#include "GeomElTypeEnum.hpp" #include "NormTangEnum.hpp" #include "QTYnumEnum.hpp" #include "TimeLoop.hpp" @@ -44,26 +45,30 @@ const int NonStatMHDAD = (int) ml_prob.GetInputParser().get("NonStatMHDAD"); const double dt = 1.; //ml_prob._timeloop._timemap.get("dt"); //======== GEOMETRICAL ELEMENT ======= - const uint space_dim = ml_prob.GetMeshTwo().get_dim(); - const uint mesh_ord = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("mesh_ord"); - const uint meshql = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("meshql"); //======== ELEMENT MAPPING ======= + const uint space_dim = ml_prob._ml_msh->GetDimension(); -//========= BCHandling ========= - const double penalty_val = ml_prob.GetMeshTwo().GetRuntimeMap().get("penalty_val"); - - my_system._A[Level]->zero(); - my_system._b[Level]->zero(); + my_system._LinSolver[Level]->_KK->zero(); + my_system._LinSolver[Level]->_RESC->zero(); +// ========================================== + Mesh *mymsh = ml_prob._ml_msh->GetLevel(Level); + elem *myel = mymsh->el; + const unsigned myproc = mymsh->processor_id(); + +// ========================================== +// ========================================== + {//BEGIN VOLUME const uint mesh_vb = VV; - const uint nel_e = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*ml_prob.GetMeshTwo()._iproc+Level+1]; - const uint nel_b = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*ml_prob.GetMeshTwo()._iproc+Level]; + const uint nel_e = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*myproc+Level+1]; + const uint nel_b = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*myproc+Level]; for (uint iel=0; iel < (nel_e - nel_b); iel++) { CurrentElem currelem(Level,VV,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); //=========INTERNAL QUANTITIES (unknowns of the equation) ================== @@ -85,15 +90,15 @@ const int NonStatMHDAD = (int) ml_prob.GetInputParser().get("NonStatMHDAD"); //========= DOMAIN MAPPING CurrentQuantity xyz(currgp); xyz._dim = DIMENSION; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //========== Quadratic domain, auxiliary CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = DIMENSION; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = myel->GetElementDofNumber(ZERO_ELEM,BIQUADR_FE); xyz_refbox.Allocate(); //========== @@ -139,7 +144,7 @@ const int NonStatMHDAD = (int) ml_prob.GetInputParser().get("NonStatMHDAD"); currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); currelem.SetElDofsBc(); @@ -295,8 +300,8 @@ for (uint fe = 0; fe < QL; fe++) { // end element gaussian integration loop /// Add element matrix and rhs to the global ones. - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); } // end of element loop @@ -317,6 +322,7 @@ for (uint fe = 0; fe < QL; fe++) { for (uint iel=0;iel < (nel_e - nel_b) ; iel++) { CurrentElem currelem(Level,BB,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); //=========INTERNAL QUANTITIES (unknowns of the equation) ================== @@ -338,15 +344,15 @@ for (uint fe = 0; fe < QL; fe++) { //========= DOMAIN MAPPING CurrentQuantity xyz(currgp); xyz._dim = DIMENSION; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //========== Quadratic domain, auxiliary CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = DIMENSION; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = myel->GetElementFaceDofNumber(ZERO_ELEM,ZERO_FACE,BIQUADR_FE); xyz_refbox.Allocate(); //========= END EXTERNAL QUANTITIES ================= @@ -362,7 +368,7 @@ for (uint fe = 0; fe < QL; fe++) { currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); currelem.SetElDofsBc(); @@ -414,20 +420,20 @@ for (uint fe = 0; fe < QL; fe++) { } //gauss - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); }//elem loop }//END BOUNDARY ************************ - my_system._A[Level]->close(); - my_system._b[Level]->close(); + my_system._LinSolver[Level]->_KK->close(); + my_system._LinSolver[Level]->_RESC->close(); #ifdef DEFAULT_PRINT_INFO std::cout << " GenMatRhs " << my_system.name() << ": assembled Level " << Level - << " with " << my_system._A[Level]->m() << " dofs " << std::endl; + << " with " << my_system._LinSolver[Level]->_KK->m() << " dofs " << std::endl; #endif return; diff --git a/applications/OptimalControl/mhdopt/EqnMHDCONT.cpp b/applications/OptimalControl/mhdopt/EqnMHDCONT.cpp index 46ad2dcda..3493736eb 100644 --- a/applications/OptimalControl/mhdopt/EqnMHDCONT.cpp +++ b/applications/OptimalControl/mhdopt/EqnMHDCONT.cpp @@ -13,6 +13,7 @@ #include "MultiLevelProblem.hpp" #include "FETypeEnum.hpp" #include "NormTangEnum.hpp" +#include "GeomElTypeEnum.hpp" #include "Quantity.hpp" #include "QTYnumEnum.hpp" #include "TimeLoop.hpp" @@ -37,14 +38,8 @@ using namespace femus; const double dt = 1.; //ml_prob._timeloop._timemap.get("dt"); //======== GEOMETRICAL ELEMENT ======= - const uint space_dim = ml_prob.GetMeshTwo().get_dim(); - const uint mesh_ord = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("mesh_ord"); - const uint meshql = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("meshql"); //======== ELEMENT MAPPING ======= + const uint space_dim = ml_prob._ml_msh->GetDimension(); - //========= BCHandling ========= - const double penalty_val = ml_prob.GetMeshTwo().GetRuntimeMap().get("penalty_val"); - //========= reference values ========= - //====== Physics double IRem = 1./ml_prob.GetInputParser().get("Rem"); double S = ml_prob.GetInputParser().get("S"); @@ -62,19 +57,28 @@ using namespace femus; double Lapxi_g[DIMENSION]; //=========================== - my_system._A[Level]->zero(); - my_system._b[Level]->zero(); + my_system._LinSolver[Level]->_KK->zero(); + my_system._LinSolver[Level]->_RESC->zero(); +// ========================================== + Mesh *mymsh = ml_prob._ml_msh->GetLevel(Level); + elem *myel = mymsh->el; + const unsigned myproc = mymsh->processor_id(); + +// ========================================== +// ========================================== + {//BEGIN VOLUME const uint mesh_vb = VV; - const uint nel_e = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*ml_prob.GetMeshTwo()._iproc+Level+1]; - const uint nel_b = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*ml_prob.GetMeshTwo()._iproc+Level]; + const uint nel_e = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*myproc+Level+1]; + const uint nel_b = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*myproc+Level]; for (uint iel=0; iel < (nel_e - nel_b); iel++) { CurrentElem currelem(Level,VV,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); //=========INTERNAL QUANTITIES (unknowns of the equation) ================== @@ -93,15 +97,15 @@ using namespace femus; //========= //DOMAIN MAPPING CurrentQuantity xyz(currgp); xyz._dim = DIMENSION; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //==================Quadratic domain, auxiliary CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = DIMENSION; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = myel->GetElementDofNumber(ZERO_ELEM,BIQUADR_FE); xyz_refbox.Allocate(); #if VELOCITY_QTY==1 @@ -138,7 +142,7 @@ using namespace femus; currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); currelem.SetElDofsBc(); @@ -347,8 +351,8 @@ for (uint fe = 0; fe < QL; fe++) { //============================================================== /// Add element matrix and rhs to the global ones. - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); } // end of element loop @@ -370,7 +374,7 @@ for (uint fe = 0; fe < QL; fe++) { for (uint iel=0;iel < (nel_e - nel_b) ; iel++) { CurrentElem currelem(Level,BB,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); - + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); //=========INTERNAL QUANTITIES (unknowns of the equation) ================== @@ -389,15 +393,15 @@ for (uint fe = 0; fe < QL; fe++) { //========= //DOMAIN MAPPING7 CurrentQuantity xyz(currgp); xyz._dim = DIMENSION; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //==================Quadratic domain, auxiliary CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = DIMENSION; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = myel->GetElementFaceDofNumber(ZERO_ELEM,ZERO_FACE,BIQUADR_FE); xyz_refbox.Allocate(); //=========END EXTERNAL QUANTITIES (couplings) ===== @@ -410,7 +414,7 @@ for (uint fe = 0; fe < QL; fe++) { currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); currelem.SetElDofsBc(); @@ -469,8 +473,8 @@ const double phii_g = currgp._phi_ndsQLVB_g[BeOld._FEord][i]; //================== END GAUSS LOOP (qp loop) ====================== //================================================================== - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); } //end bdry element loop @@ -480,12 +484,12 @@ const double phii_g = currgp._phi_ndsQLVB_g[BeOld._FEord][i]; // END BOUNDARY // ************************** - my_system._A[Level]->close(); - my_system._b[Level]->close(); + my_system._LinSolver[Level]->_KK->close(); + my_system._LinSolver[Level]->_RESC->close(); #ifdef DEFAULT_PRINT_INFO std::cout << " GenMatRhs " << my_system.name() << ": assembled Level " << Level - << " with " << my_system._A[Level]->m() << " dofs " << std::endl; + << " with " << my_system._LinSolver[Level]->_KK->m() << " dofs " << std::endl; #endif return; diff --git a/applications/OptimalControl/mhdopt/EqnNS.cpp b/applications/OptimalControl/mhdopt/EqnNS.cpp index 6c5f193c1..8cf5db62b 100644 --- a/applications/OptimalControl/mhdopt/EqnNS.cpp +++ b/applications/OptimalControl/mhdopt/EqnNS.cpp @@ -13,6 +13,7 @@ #include "FETypeEnum.hpp" #include "NormTangEnum.hpp" #include "VBTypeEnum.hpp" +#include "GeomElTypeEnum.hpp" #include "QTYnumEnum.hpp" #include "Domain.hpp" #include "TimeLoop.hpp" @@ -74,12 +75,6 @@ Viscosity* viscosity_ptr = static_cast(ml_prob.GetQtyMap().GetQuanti const double time = 0.; //ml_prob._timeloop._curr_time; -//========== PROCESSOR INDEX -//every routine we use here should depend directly on this one and not implicitly -//through the class _iproc. This should be a sort of "function argument", -//like the Level - const uint myproc = ml_prob.GetMeshTwo()._iproc; - //==========FLAG FOR STATIONARITY OR NOT //FLAG for the TIME DISCRETIZATION //every Equation may have a TimeDiscretization @@ -140,16 +135,18 @@ const int NonStatNS = (int) ml_prob.GetInputParser().get("NonStatNS"); //========== GEOMETRIC ELEMENT ======== - const uint space_dim = ml_prob.GetMeshTwo().get_dim(); - const uint mesh_ord = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("mesh_ord"); - const uint meshql = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("meshql"); //======== ELEMENT MAPPING ======= + const uint space_dim = ml_prob._ml_msh->GetDimension(); -//========= BCHandling ========= - const double penalty_val = ml_prob.GetMeshTwo().GetRuntimeMap().get("penalty_val"); - - my_system._A[Level]->zero(); - my_system._b[Level]->zero(); + my_system._LinSolver[Level]->_KK->zero(); + my_system._LinSolver[Level]->_RESC->zero(); +// ========================================== + Mesh *mymsh = ml_prob._ml_msh->GetLevel(Level); + elem *myel = mymsh->el; + const unsigned myproc = mymsh->processor_id(); + +// ========================================== +// ========================================== {//BEGIN VOLUME //=============================== @@ -163,7 +160,7 @@ const int NonStatNS = (int) ml_prob.GetInputParser().get("NonStatNS"); for (uint iel=0; iel < (nel_e - nel_b); iel++) { CurrentElem currelem(Level,VV,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); - + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); //=========INTERNAL QUANTITIES (unknowns of the equation) ================== @@ -194,15 +191,15 @@ const int NonStatNS = (int) ml_prob.GetInputParser().get("NonStatNS"); //========= //DOMAIN MAPPING CurrentQuantity xyz(currgp); xyz._dim = DIMENSION; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //==================Quadratic domain, auxiliary, must be QUADRATIC!!! ========== CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = DIMENSION; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = myel->GetElementDofNumber(ZERO_ELEM,BIQUADR_FE); xyz_refbox.Allocate(); //============================ MAG WORLD ======================================= @@ -257,7 +254,7 @@ const int NonStatNS = (int) ml_prob.GetInputParser().get("NonStatNS"); currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); //=======RETRIEVE the DOFS of the UNKNOWN QUANTITIES,i.e. MY EQUATION currelem.SetElDofsBc(); @@ -528,8 +525,8 @@ for (uint fe = 0; fe < QL; fe++) { //============================================================== /// Add element matrix and rhs to the global ones. - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); } // end of element loop @@ -551,7 +548,7 @@ for (uint fe = 0; fe < QL; fe++) { for (uint iel=0; iel < (nel_e - nel_b) ; iel++) { CurrentElem currelem(Level,BB,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); - + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); //=========INTERNAL QUANTITIES (unknowns of the equation) ================== @@ -582,15 +579,15 @@ for (uint fe = 0; fe < QL; fe++) { //========= //DOMAIN MAPPING CurrentQuantity xyz(currgp); xyz._dim = DIMENSION; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //==================Quadratic domain, auxiliary, must be QUADRATIC!!! ========== CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = DIMENSION; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = myel->GetElementFaceDofNumber(ZERO_ELEM,ZERO_FACE,BIQUADR_FE); xyz_refbox.Allocate(); //======================= @@ -608,7 +605,7 @@ for (uint fe = 0; fe < QL; fe++) { currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); currelem.SetElDofsBc(); @@ -669,8 +666,8 @@ for (uint fe = 0; fe < QL; fe++) { //================== END GAUSS LOOP (qp loop) ====================== //================================================================== - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); } @@ -680,12 +677,12 @@ for (uint fe = 0; fe < QL; fe++) { } // END BOUNDARY ****************************** - my_system._A[Level]->close(); - my_system._b[Level]->close(); + my_system._LinSolver[Level]->_KK->close(); + my_system._LinSolver[Level]->_RESC->close(); #ifdef DEFAULT_PRINT_INFO std::cout << " GenMatRhs " << my_system.name() << ": assembled Level " << Level - << " with " << my_system._A[Level]->m() << " dofs" << std::endl; + << " with " << my_system._LinSolver[Level]->_KK->m() << " dofs" << std::endl; #endif return; diff --git a/applications/OptimalControl/mhdopt/EqnNSAD.cpp b/applications/OptimalControl/mhdopt/EqnNSAD.cpp index 7bfe63c7c..3dbc7dd2d 100644 --- a/applications/OptimalControl/mhdopt/EqnNSAD.cpp +++ b/applications/OptimalControl/mhdopt/EqnNSAD.cpp @@ -10,6 +10,7 @@ #include "Domain.hpp" #include "MultiLevelProblem.hpp" #include "FETypeEnum.hpp" +#include "GeomElTypeEnum.hpp" #include "NormTangEnum.hpp" #include "Quantity.hpp" #include "QTYnumEnum.hpp" @@ -44,27 +45,29 @@ const int NonStatNSAD = (int) ml_prob.GetInputParser().get("NonStatNSAD"); const double dt = 1.; //ml_prob._timeloop._timemap.get("dt"); // //======== GEOMETRICAL ELEMENT ======= - const uint space_dim = ml_prob.GetMeshTwo().get_dim(); - const uint mesh_ord = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("mesh_ord"); - const uint meshql = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("meshql"); //======== ELEMENT MAPPING ======= + const uint space_dim = ml_prob._ml_msh->GetDimension(); + my_system._LinSolver[Level]->_KK->zero(); + my_system._LinSolver[Level]->_RESC->zero(); -//========= BCHandling ========= - const double penalty_val = ml_prob.GetMeshTwo().GetRuntimeMap().get("penalty_val"); - - my_system._A[Level]->zero(); - my_system._b[Level]->zero(); - +// ========================================== + Mesh *mymsh = ml_prob._ml_msh->GetLevel(Level); + elem *myel = mymsh->el; + const unsigned myproc = mymsh->processor_id(); + +// ========================================== +// ========================================== {//BEGIN VOLUME const uint mesh_vb = VV; - const uint nel_e = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*ml_prob.GetMeshTwo()._iproc+Level+1]; - const uint nel_b = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*ml_prob.GetMeshTwo()._iproc+Level]; + const uint nel_e = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*myproc+Level+1]; + const uint nel_b = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*myproc+Level]; for (uint iel=0; iel < (nel_e - nel_b); iel++) { CurrentElem currelem(Level,VV,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); //=========INTERNAL QUANTITIES (unknowns of the equation) ================== @@ -86,15 +89,15 @@ const int NonStatNSAD = (int) ml_prob.GetInputParser().get("NonStatNSAD"); //========= DOMAIN MAPPING CurrentQuantity xyz(currgp); xyz._dim = space_dim; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //========== Quadratic domain, auxiliary CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = space_dim; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = myel->GetElementDofNumber(ZERO_ELEM,BIQUADR_FE); xyz_refbox.Allocate(); CurrentQuantity Vel(currgp); @@ -136,11 +139,11 @@ const int NonStatNSAD = (int) ml_prob.GetInputParser().get("NonStatNSAD"); currelem.Mat().zero(); currelem.Rhs().zero(); - currelem.SetDofobjConnCoords(ml_prob.GetMeshTwo()._iproc,iel); + currelem.SetDofobjConnCoords(myproc,iel); currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); currelem.SetElDofsBc(); @@ -173,7 +176,7 @@ const int NonStatNSAD = (int) ml_prob.GetInputParser().get("NonStatNSAD"); //======= ///optimal control xyz_refbox.SetElemAverage(); - int el_flagdom = ElFlagControl(xyz_refbox._el_average,&ml_prob.GetMeshTwo()); + int el_flagdom = ElFlagControl(xyz_refbox._el_average,ml_prob._ml_msh); //======= @@ -183,7 +186,8 @@ const int NonStatNSAD = (int) ml_prob.GetInputParser().get("NonStatNSAD"); //=======here starts the "COMMON SHAPE PART"================== for (uint fe = 0; fe < QL; fe++) { currgp.SetPhiElDofsFEVB_g (fe,qp); - currgp.SetDPhiDxezetaElDofsFEVB_g (fe,qp); } + currgp.SetDPhiDxezetaElDofsFEVB_g (fe,qp); +} const double det = dt*currgp.JacVectVV_g(xyz); //InvJac: is the same for both QQ and LL! const double dtxJxW_g = det*ml_prob.GetQrule(currelem.GetDim()).GetGaussWeight(qp); @@ -301,8 +305,8 @@ for (uint fe = 0; fe < QL; fe++) { // end element gaussian integration loop /// Add element matrix and rhs to the global ones. - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); } // end of element loop @@ -318,13 +322,13 @@ for (uint fe = 0; fe < QL; fe++) { const uint mesh_vb = BB; - const uint nel_e = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*ml_prob.GetMeshTwo()._iproc+Level+1]; - const uint nel_b = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*ml_prob.GetMeshTwo()._iproc+Level]; + const uint nel_e = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*myproc+Level+1]; + const uint nel_b = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*myproc+Level]; for (uint iel=0;iel < (nel_e - nel_b) ; iel++) { CurrentElem currelem(Level,BB,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); - + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); //=========INTERNAL QUANTITIES (unknowns of the equation) ================== @@ -346,15 +350,15 @@ for (uint fe = 0; fe < QL; fe++) { //========= DOMAIN MAPPING CurrentQuantity xyz(currgp); xyz._dim = space_dim; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //========== Quadratic domain, auxiliary CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = space_dim; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = myel->GetElementFaceDofNumber(ZERO_ELEM,ZERO_FACE,BIQUADR_FE); xyz_refbox.Allocate(); //========= END EXTERNAL QUANTITIES ================= @@ -363,11 +367,11 @@ for (uint fe = 0; fe < QL; fe++) { currelem.Mat().zero(); currelem.Rhs().zero(); - currelem.SetDofobjConnCoords(ml_prob.GetMeshTwo()._iproc,iel); + currelem.SetDofobjConnCoords(myproc,iel); currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); currelem.SetElDofsBc(); @@ -423,19 +427,19 @@ for (uint fe = 0; fe < QL; fe++) { } //gauss - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); }//elem loop }//END BOUNDARY ************************ - my_system._A[Level]->close(); - my_system._b[Level]->close(); + my_system._LinSolver[Level]->_KK->close(); + my_system._LinSolver[Level]->_RESC->close(); #ifdef DEFAULT_PRINT_INFO std::cout << " GenMatRhs " << my_system.name() << ": assembled Level " << Level - << " with " << my_system._A[Level]->m() << " dofs" << std::endl; + << " with " << my_system._LinSolver[Level]->_KK->m() << " dofs" << std::endl; #endif return; diff --git a/applications/OptimalControl/mhdopt/OptLoop.cpp b/applications/OptimalControl/mhdopt/OptLoop.cpp index 8152bdc64..0e49ee6ab 100644 --- a/applications/OptimalControl/mhdopt/OptLoop.cpp +++ b/applications/OptimalControl/mhdopt/OptLoop.cpp @@ -74,7 +74,7 @@ namespace femus { //now it is an optimization loop //question:how do I see the NONLINEAR LOOPS alone? //you call transient_loop() instead of optimization_loop() -//x_old and _x_oold will be used +//x_old and _xoold will be used //either for OPTIMIZATION iterations or for NONLINEAR iterations, //depending on what you need @@ -82,11 +82,7 @@ namespace femus { OptLoop::~OptLoop() { - for (uint Level = 0; Level < _x_oldopt.size(); Level++) { - delete _x_oldopt[Level]; - } - - _x_oldopt.clear(); + delete _x_oldopt; } @@ -163,7 +159,7 @@ double lin_deltax_MHDCONT = 0.; #endif //nitialize Becont - _x_oldopt[NoLevels - 1]->zero(); //initialize Boldopt=0; + _x_oldopt->zero(); //initialize Boldopt=0; //OPTIMIZATION LOOP @@ -181,43 +177,46 @@ for (uint opt_step = _t_idx_in + 1; opt_step <= _t_idx_final; opt_step++) { //xold there was a good value //xoold there was still the value multiplied // omega = 1.; //"omega=1" and "no if" is equal to the old loop - eqnMHDCONT._x_oold[NoLevels - 1]->close(); - std::cout << "Linfty norm of Becont _x_oold " << eqnMHDCONT._x_oold [NoLevels - 1]->linfty_norm() << std::endl; - - eqnMHDCONT._x_old[NoLevels - 1]->close(); - std::cout << "Linfty norm of Becont _x_old " << eqnMHDCONT._x_old [NoLevels - 1]->linfty_norm() << std::endl; - - _x_oldopt[NoLevels - 1]->close(); - std::cout << "Linfty norm of Becont _x_oldopt " << _x_oldopt [NoLevels - 1]->linfty_norm() << std::endl; + +// // // eqnMHDCONT._x_oold->close(); +// // // std::cout << "Linfty norm of Becont _xoold " << eqnMHDCONT._x_oold->linfty_norm() << std::endl; +// // // +// // // eqnMHDCONT._x_old[NoLevels - 1]->close(); +// // // std::cout << "Linfty norm of Becont _x_old " << eqnMHDCONT._x_old [NoLevels - 1]->linfty_norm() << std::endl; +// // // +// // // _x_oldopt->close(); +// // // std::cout << "Linfty norm of Becont _x_oldopt " << _x_oldopt->linfty_norm() << std::endl; ////////////////// + NumericVector* _x_tmp2 = NumericVector::build().release(); + _x_tmp2->init(eqnMHDCONT._dofmap._Dim[eqnMHDCONT.GetGridn()-1],false, SERIAL); - eqnMHDCONT._x_tmp[NoLevels-1]->zero(); - *(eqnMHDCONT._x_tmp[NoLevels-1]) = *(eqnMHDCONT._x_old[NoLevels-1]); - eqnMHDCONT._bcond.Bc_ScaleDofVec(eqnMHDCONT._x_tmp[NoLevels - 1], omega ); - eqnMHDCONT._x_tmp[NoLevels - 1]->close(); + _x_tmp2->zero(); + *(_x_tmp2) = *(eqnMHDCONT._LinSolver[NoLevels-1]->_EPSC); + eqnMHDCONT._bcond.Bc_ScaleDofVec(_x_tmp2, omega ); + _x_tmp2->close(); std::cout << "Omega " << omega << std::endl; std::cout << "Linfty norm of Becont _x_old*omega " - << eqnMHDCONT._x_tmp [NoLevels - 1]->linfty_norm() << std::endl; + << _x_tmp2->linfty_norm() << std::endl; - eqnMHDCONT._x_oold[NoLevels - 1]->close(); - std::cout << "Linfty norm of Becont _x_oold " - << eqnMHDCONT._x_oold [NoLevels - 1]->linfty_norm() << std::endl; +// // // eqnMHDCONT._x_oold->close(); +// // // std::cout << "Linfty norm of Becont _xoold " +// // // << eqnMHDCONT._x_oold->linfty_norm() << std::endl; - _x_oldopt[NoLevels - 1]->close(); + _x_oldopt->close(); std::cout << "Linfty norm of Becont _x_oldopt " - << _x_oldopt [NoLevels - 1]->linfty_norm() << std::endl; + << _x_oldopt->linfty_norm() << std::endl; - eqnMHDCONT._bcond.Bc_AddScaleDofVec(_x_oldopt[NoLevels - 1],eqnMHDCONT._x_tmp [NoLevels - 1],1.- omega); - eqnMHDCONT._x_tmp[NoLevels - 1]->close(); + eqnMHDCONT._bcond.Bc_AddScaleDofVec(_x_oldopt,_x_tmp2,1.- omega); + _x_tmp2->close(); std::cout << "Linfty norm of Becont x_old*omega + (1-omega)*xoold " - << eqnMHDCONT._x_tmp [NoLevels - 1]->linfty_norm() << std::endl; + << _x_tmp2->linfty_norm() << std::endl; - *(eqnMHDCONT._x_old[NoLevels-1]) = *(eqnMHDCONT._x_tmp[NoLevels-1]); + *(eqnMHDCONT._LinSolver[NoLevels-1]->_EPSC) = *(_x_tmp2); - eqnMHDCONT._x_old[NoLevels - 1]->close(); + eqnMHDCONT._LinSolver[NoLevels-1]->_EPSC->close(); std::cout << "Linfty norm of Becont _x_old updated " - << eqnMHDCONT._x_old [NoLevels - 1]->linfty_norm() << std::endl; + << eqnMHDCONT._LinSolver[NoLevels-1]->_EPSC->linfty_norm() << std::endl; // eqnMHDCONT.x[NoLevels - 1]->close(); @@ -321,7 +320,7 @@ if ( fabs(J - Jold) > epsJ /*|| 1*/ ) { //******* update Jold //you must update it only here, because here it is the good point to restart from Jold = J; #ifdef MHDCONT_EQUATIONS - *(_x_oldopt[NoLevels-1]) = *(eqnMHDCONT._x_old[NoLevels-1]); + *(_x_oldopt) = *(eqnMHDCONT._LinSolver[NoLevels-1]->_EPSC); #endif //this will be the new _x_oldopt? @@ -456,7 +455,9 @@ while(lin_deltax_MHDCONT > eps_MHDCONT && k_MHDCONT < MaxIterMHDCONT ); const uint delta_opt_step = opt_step - _t_idx_in; if (delta_opt_step%print_step == 0) XDMFWriter::PrintSolLinear(_files.GetOutputPath(),opt_step,pseudo_opttimeval,e_map_in); //print sol.N.h5 and sol.N.xmf - + + delete _x_tmp2; //delete vector + } @@ -467,15 +468,10 @@ const uint delta_opt_step = opt_step - _t_idx_in; void OptLoop::init_equation_data(const SystemTwo* eqn) { -//======equation-specific vectors ===================== - _x_oldopt.resize(eqn->GetGridn()); - - for(uint Level = 0; Level < _x_oldopt.size(); Level++) { - uint n_glob = eqn->_dofmap._Dim[Level]; //is it already filled? Now yes!!!!!!!!! - _x_oldopt[Level] = NumericVector::build().release(); _x_oldopt[Level]->init(n_glob,false, SERIAL); - } - - + uint n_glob = eqn->_dofmap._Dim[eqn->GetGridn()-1]; + _x_oldopt = NumericVector::build().release(); + _x_oldopt->init(n_glob,false, SERIAL); + return; } @@ -514,30 +510,29 @@ double ComputeIntegral (const uint Level, const MultiLevelMeshTwo* mesh, const S const uint mesh_vb = VV; + Mesh *mymsh = eqn->GetMLProb()._ml_msh->GetLevel(Level); CurrentElem currelem(Level,VV,eqn,*mesh,eqn->GetMLProb().GetElemType()); + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,eqn->GetMLProb().GetQrule(currelem.GetDim())); // processor index const uint myproc = mesh->_iproc; // geometry ----- const uint space_dim = mesh->get_dim(); - const uint mesh_ord = (int) mesh->GetRuntimeMap().get("mesh_ord"); - const uint meshql = (int) mesh->GetRuntimeMap().get("meshql"); //======== ELEMENT MAPPING ======= - -//======Functions in the integrand ============ + //========= DOMAIN MAPPING CurrentQuantity xyz(currgp); xyz._dim = DIMENSION; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //========== Quadratic domain, auxiliary CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = DIMENSION; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ mesh->_geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = mymsh->el->GetElementDofNumber(ZERO_ELEM,BIQUADR_FE); xyz_refbox.Allocate(); //========== @@ -570,7 +565,7 @@ double ComputeIntegral (const uint Level, const MultiLevelMeshTwo* mesh, const S //======= xyz_refbox.SetElemAverage(); - int el_flagdom = ElFlagControl(xyz_refbox._el_average,mesh); + int el_flagdom = ElFlagControl(xyz_refbox._el_average,eqn->GetMLProb()._ml_msh); //======= if ( Vel._eqnptr != NULL ) Vel.GetElemDofs(); @@ -616,22 +611,22 @@ for (uint j=0; j el_xm, const MultiLevelMeshTwo* mesh) { + int ElFlagControl(const std::vector el_xm, const MultiLevelMesh* mesh) { Box* box= static_cast(mesh->GetDomain()); int el_flagdom=0; -///optimal control - #if DIMENSION==2 + if (mesh->GetDimension() == 2) { //flag on the controlled region 2D if ( el_xm[0] > 0.25*(box->_le[0] - box->_lb[0]) && el_xm[0] < 0.75*(box->_le[0] - box->_lb[0]) && el_xm[1] > 0.75*(box->_le[1] - box->_lb[1]) ) { el_flagdom=1; } - #else + } + else if (mesh->GetDimension() == 3) { //flag on the controlled region 3D if ( el_xm[0] > 0.25*(box->_le[0] - box->_lb[0]) && el_xm[0] < 0.75*(box->_le[0] - box->_lb[0]) @@ -640,7 +635,7 @@ for (uint j=0; j_le[2] - box->_lb[2]) ) { el_flagdom=1; } - #endif + } return el_flagdom; } diff --git a/applications/OptimalControl/mhdopt/OptLoop.hpp b/applications/OptimalControl/mhdopt/OptLoop.hpp index 1f0d954c0..f77eff3b2 100644 --- a/applications/OptimalControl/mhdopt/OptLoop.hpp +++ b/applications/OptimalControl/mhdopt/OptLoop.hpp @@ -28,7 +28,7 @@ class OptLoop : public TimeLoop { void init_equation_data(const SystemTwo* eqn); //====data - std::vector _x_oldopt; //old optimization step + NumericVector * _x_oldopt; //old optimization step }; @@ -37,7 +37,7 @@ class OptLoop : public TimeLoop { //prototypes that can even stay outside of a class double ComputeIntegral (const uint Level, const MultiLevelMeshTwo* mesh, const SystemTwo* eqn); - int ElFlagControl(const std::vector el_xm, const MultiLevelMeshTwo* mesh); + int ElFlagControl(const std::vector el_xm, const MultiLevelMesh* mesh); diff --git a/applications/OptimalControl/mhdopt/OptQuantities.cpp b/applications/OptimalControl/mhdopt/OptQuantities.cpp index dd185d91c..fc6d81aa9 100644 --- a/applications/OptimalControl/mhdopt/OptQuantities.cpp +++ b/applications/OptimalControl/mhdopt/OptQuantities.cpp @@ -636,7 +636,7 @@ void MagnFieldHomAdj::Function_txyz(const double t, const double* xp,double* fun void Velocity::bc_flag_txyz(const double t, const double* xp, std::vector & bc_flag) const { - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -729,7 +729,7 @@ Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); void Pressure::bc_flag_txyz(const double t, const double* xp, std::vector & bc_flag) const { - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -807,7 +807,7 @@ Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); void MagnFieldHom::bc_flag_txyz(const double t, const double* xp, std::vector & bc_flag) const { - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -900,7 +900,7 @@ Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); void MagnFieldHomAdj::bc_flag_txyz(const double t, const double* xp, std::vector & bc_flag) const { - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -992,7 +992,7 @@ if ( x_rotshift[2] > -bdry_toll && x_rotshift[2] < bdry_toll ) { //current void MagnFieldHomLagMult::bc_flag_txyz(const double t, const double* xp, std::vector & bc_flag) const { - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -1066,7 +1066,7 @@ Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); void MagnFieldHomLagMultAdj::bc_flag_txyz(const double t, const double* xp, std::vector & bc_flag) const { - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -1140,7 +1140,7 @@ if ( x_rotshift[2] > -bdry_toll && x_rotshift[2] < bdry_toll ) { //current void VelocityAdj::bc_flag_txyz(const double t, const double* xp, std::vector & bc_flag) const { - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -1231,7 +1231,7 @@ Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); void PressureAdj::bc_flag_txyz(const double t, const double* xp, std::vector & bc_flag) const { - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -1307,7 +1307,7 @@ if (( x_rotshift[1]) > -bdry_toll && ( x_rotshift[1]) < bdry_toll) { //bottom void MagnFieldExt::bc_flag_txyz(const double t, const double* xp, std::vector & bc_flag) const { - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -1407,7 +1407,7 @@ Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); void MagnFieldExtLagMult::bc_flag_txyz(const double t, const double* xp, std::vector & bc_flag) const { - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -1487,7 +1487,7 @@ void Velocity::initialize_xyz(const double* xp, std::vector< double >& value) co const double pref = _qtymap.GetInputParser()->get("pref"); const double udes = _qtymap.GetInputParser()->get("udes"); - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); diff --git a/applications/OptimalControl/mhdopt/input/femus_conf.in b/applications/OptimalControl/mhdopt/input/femus_conf.in index 998b5de99..a16338c19 100644 --- a/applications/OptimalControl/mhdopt/input/femus_conf.in +++ b/applications/OptimalControl/mhdopt/input/femus_conf.in @@ -1,21 +1,4 @@ - -# double - -nolevels 1 -meshql 1 # ------------- # for THE APP # =MESH CONSISTENCY=== # ==== in library routines # USER must provide this info explicitly # depends on the kind of Mesh that is used# depends basically on the Boundary Mesh# 0=QUADRATIC Mapping 1=LINEAR Mapping -mesh_ord 0 # =MESH CONSISTENCY=== # ==== in library routines # the mesh file should provide this info# 0=BIQUADRATIC # 1=LINEAR -geomel_type 0 # =MESH CONSISTENCY=== # the mesh file should provide this info -dimension 3 # =MESH CONSISTENCY=== -bdry_toll 0.0000001 # ==== - -# --------------------- -penalty_val 1.e10 # ==== not in library routines, but library-type - - - - - # double diff --git a/applications/OptimalControl/mhdopt/main.cpp b/applications/OptimalControl/mhdopt/main.cpp index d190e29e6..3c58aa99e 100644 --- a/applications/OptimalControl/mhdopt/main.cpp +++ b/applications/OptimalControl/mhdopt/main.cpp @@ -84,8 +84,10 @@ int main(int argc, char** argv) { const double _We = (Uref*Uref*Lref*rhof)/sigma; physics_map.set("We",_We); // ======= Mesh ===== - FemusInputParser mesh_map("Mesh",files.GetOutputPath()); - GenCase mesh(mesh_map,"straightQ3D2x2x2ZERO.gam"); + const unsigned NoLevels = 1; + const unsigned dim = 3; + const GeomElType geomel_type = HEX; + GenCase mesh(NoLevels,dim,geomel_type,"straightQ3D2x2x2ZERO.gam"); mesh.SetLref(1.); // ======= MyDomainShape (optional, implemented as child of Domain) ==================== @@ -151,9 +153,11 @@ int main(int argc, char** argv) { MultiLevelMesh ml_msh; ml_msh.GenerateCoarseBoxMesh(8,8,8,0,1,0,1,0,1,HEX27,"fifth"); // ml_msh.GenerateCoarseBoxMesh(numelemx,numelemy,numelemz,xa,xb,ya,yb,za,zb,elemtype,"seventh"); - ml_msh.RefineMesh(mesh_map.get("nolevels"),mesh_map.get("nolevels"),NULL); + ml_msh.RefineMesh(NoLevels,NoLevels,NULL); ml_msh.PrintInfo(); + ml_msh.SetDomain(&mybox); + MultiLevelSolution ml_sol(&ml_msh); ml_sol.AddSolution("FAKE",LAGRANGE,SECOND,0); @@ -218,11 +222,11 @@ int main(int argc, char** argv) { SystemTwo* sys = static_cast(eqn->second); // //===================== - sys -> init(); + sys -> init_two(); sys -> _LinSolver[0]->set_solver_type(GMRES); //if I keep PREONLY it doesn't run //===================== - sys -> init_sys(); + sys -> init_unknown_vars(); //===================== sys -> _dofmap.ComputeMeshToDof(); //===================== @@ -232,7 +236,7 @@ int main(int argc, char** argv) { //===================== sys -> _bcond.GenerateBdc(); //===================== - sys -> ReadMGOps(files.GetOutputPath()); + GenCase::ReadMGOps(files.GetOutputPath(),sys); } diff --git a/applications/OptimalControl/tempopt/EqnNS.cpp b/applications/OptimalControl/tempopt/EqnNS.cpp index f1c754022..807bbc29d 100644 --- a/applications/OptimalControl/tempopt/EqnNS.cpp +++ b/applications/OptimalControl/tempopt/EqnNS.cpp @@ -13,6 +13,7 @@ #include "FETypeEnum.hpp" #include "NormTangEnum.hpp" #include "VBTypeEnum.hpp" +#include "GeomElTypeEnum.hpp" #include "QTYnumEnum.hpp" #include "Domain.hpp" #include "CurrentGaussPoint.hpp" @@ -38,21 +39,12 @@ const double time = 0.;//ml_prob._timeloop._curr_time; -//========== PROCESSOR INDEX - const uint myproc = ml_prob.GetMeshTwo()._iproc; - //==========FLAG FOR STATIONARITY OR NOT const int NonStatNS = (int) ml_prob.GetInputParser().get("NonStatNS"); const double dt = 1.; -//========= BCHandling ========= - const double penalty_val = ml_prob.GetMeshTwo().GetRuntimeMap().get("penalty_val"); - //========== GEOMETRIC ELEMENT ======== - const uint space_dim = ml_prob.GetMeshTwo().get_dim(); - const uint mesh_ord = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("mesh_ord"); - const uint meshql = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("meshql"); //======== ELEMENT MAPPING ======= - + const uint space_dim = ml_prob._ml_msh->GetDimension(); //=======density and viscosity=================== const double rhof = ml_prob.GetInputParser().get("rho0"); @@ -70,9 +62,16 @@ std::vector AdvRhs_g(space_dim); //Operator: Adv(u,u,phi) //================================================ - my_system._A[Level]->zero(); - my_system._b[Level]->zero(); + my_system._LinSolver[Level]->_KK->zero(); + my_system._LinSolver[Level]->_RESC->zero(); +// ========================================== + Mesh *mymsh = ml_prob._ml_msh->GetLevel(Level); + elem *myel = mymsh->el; + const unsigned myproc = mymsh->processor_id(); + +// ========================================== +// ========================================== {//BEGIN VOLUME //======================== @@ -85,7 +84,7 @@ for (int iel=0; iel < (nel_e - nel_b); iel++) { CurrentElem currelem(Level,VV,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); - + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); @@ -117,15 +116,15 @@ //========= //DOMAIN MAPPING CurrentQuantity xyz(currgp); //domain xyz._dim = space_dim; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //==================Quadratic domain, auxiliary, must be QUADRATIC!!! ========== CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = space_dim; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = myel->GetElementDofNumber(ZERO_ELEM,BIQUADR_FE); xyz_refbox.Allocate(); //other Physical constant Quantities @@ -148,7 +147,7 @@ currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); //=======RETRIEVE the DOFS of the UNKNOWN QUANTITIES,i.e. MY EQUATION currelem.SetElDofsBc(); @@ -356,8 +355,8 @@ for (uint fe = 0; fe < QL; fe++) { //============================================================== /// Add element matrix and rhs to the global ones. - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); } @@ -380,6 +379,7 @@ for (uint fe = 0; fe < QL; fe++) { for (uint iel=0; iel < (nel_e - nel_b) ; iel++) { CurrentElem currelem(Level,BB,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); @@ -411,15 +411,15 @@ for (uint fe = 0; fe < QL; fe++) { //========= //DOMAIN MAPPING CurrentQuantity xyz(currgp); //domain xyz._dim = space_dim; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //==================Quadratic domain, auxiliary, must be QUADRATIC!!! ========== CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = space_dim; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = myel->GetElementFaceDofNumber(ZERO_ELEM,ZERO_FACE,BIQUADR_FE); xyz_refbox.Allocate(); //=== auxiliary Operators at the boundary @@ -433,7 +433,7 @@ for (uint fe = 0; fe < QL; fe++) { currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); currelem.SetElDofsBc(); @@ -501,8 +501,8 @@ for (uint fe = 0; fe < QL; fe++) { //================== END GAUSS LOOP (qp loop) ====================== //================================================================== - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); } @@ -512,13 +512,13 @@ for (uint fe = 0; fe < QL; fe++) { } // END BOUNDARY ****************************** - my_system._A[Level]->close(); - my_system._b[Level]->close(); + my_system._LinSolver[Level]->_KK->close(); + my_system._LinSolver[Level]->_RESC->close(); #ifdef DEFAULT_PRINT_INFO std::cout << " GenMatRhs " << my_system.name() << ": assembled Level " << Level - << " with " << my_system._A[Level]->m() << " dofs" << std::endl; + << " with " << my_system._LinSolver[Level]->_KK->m() << " dofs" << std::endl; #endif return; diff --git a/applications/OptimalControl/tempopt/EqnT.cpp b/applications/OptimalControl/tempopt/EqnT.cpp index 61fe7fe6b..643b0b4b0 100644 --- a/applications/OptimalControl/tempopt/EqnT.cpp +++ b/applications/OptimalControl/tempopt/EqnT.cpp @@ -18,6 +18,7 @@ #include "FETypeEnum.hpp" #include "NormTangEnum.hpp" #include "VBTypeEnum.hpp" +#include "GeomElTypeEnum.hpp" #include "QTYnumEnum.hpp" #include "Domain.hpp" #include "TimeLoop.hpp" @@ -28,6 +29,7 @@ // application #include "TempQuantities.hpp" +#include "../../../src/equations/CurrentElem.hpp" // The question is: WHERE is the ORDER of the VARIABLES established? @@ -76,24 +78,20 @@ void GenMatRhsT(MultiLevelProblem &ml_prob, unsigned Level, const unsigned &gri //if we are just a function not inside a class, we have to retrieve ourselves... SystemTwo & my_system = ml_prob.get_system("Eqn_T"); - +// ========================================== + Mesh *mymsh = ml_prob._ml_msh->GetLevel(Level); + elem *myel = mymsh->el; + const unsigned myproc = mymsh->processor_id(); + const double time = 0.; // ml_prob._timeloop._curr_time; -//========== PROCESSOR INDEX - const uint myproc = ml_prob.GetMeshTwo()._iproc; - //==========FLAG FOR STATIONARITY OR NOT const double dt = 1.; //ml_prob._timeloop._timemap.get("dt"); const uint Nonstat = ml_prob.GetInputParser().get("NonStatTEMP"); -//========= BCHandling ========= - const double penalty_val = ml_prob.GetMeshTwo().GetRuntimeMap().get("penalty_val"); - //======== ELEMENT MAPPING ======= - const uint space_dim = ml_prob.GetMeshTwo().get_dim(); - const uint meshql = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("meshql"); - const uint mesh_ord = (int) ml_prob.GetMeshTwo().GetRuntimeMap().get("mesh_ord"); + const uint space_dim = ml_prob._ml_msh->GetDimension(); //====== reference values ======================== const double IRe = 1./ml_prob.GetInputParser().get("Re"); @@ -110,9 +108,9 @@ void GenMatRhsT(MultiLevelProblem &ml_prob, unsigned Level, const unsigned &gri // QfluxDOTn>0: energy flows outside (cooling) QfluxDOTn<0: energy flows inside (heating) std::vector Qflux_g(space_dim); - my_system._A[Level]->zero(); - my_system._b[Level]->zero(); - + my_system._LinSolver[Level]->_KK->zero(); + my_system._LinSolver[Level]->_RESC->zero(); + // ========================================== // ========================================== {//BEGIN VOLUME @@ -125,6 +123,7 @@ void GenMatRhsT(MultiLevelProblem &ml_prob, unsigned Level, const unsigned &gri for (uint iel=0; iel < (nel_e - nel_b); iel++) { CurrentElem currelem(Level,VV,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); @@ -145,27 +144,20 @@ void GenMatRhsT(MultiLevelProblem &ml_prob, unsigned Level, const unsigned &gri TAdj._qtyptr = ml_prob.GetQtyMap().GetQuantity("Qty_TempAdj");//_UnknownQuantitiesVector[2]; TAdj.VectWithQtyFillBasic(); TAdj.Allocate(); - -#if FOURTH_ROW==1 - CurrentQuantity Press2(currgp); - Press2._qtyptr = ml_prob.GetQtyMap().GetQuantity("Qty_Pressure_2"); - Press2.VectWithQtyFillBasic(); - Press2.Allocate(); -#endif - + //=========EXTERNAL QUANTITIES (couplings) ===== //========= //DOMAIN MAPPING CurrentQuantity xyz(currgp); //no quantity xyz._dim = space_dim; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //==================Quadratic domain, auxiliary, must be QUADRATIC!!! ========== CurrentQuantity xyz_refbox(currgp); //no quantity xyz_refbox._dim = space_dim; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = myel->GetElementDofNumber(ZERO_ELEM,BIQUADR_FE); xyz_refbox.Allocate(); //================== @@ -191,7 +183,7 @@ void GenMatRhsT(MultiLevelProblem &ml_prob, unsigned Level, const unsigned &gri currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); //MY EQUATION //the elements are, for every level: @@ -217,7 +209,7 @@ void GenMatRhsT(MultiLevelProblem &ml_prob, unsigned Level, const unsigned &gri xyz_refbox.SetElemAverage(); -int domain_flag = ElFlagControl(xyz_refbox._el_average,&ml_prob.GetMeshTwo()); +int domain_flag = ElFlagControl(xyz_refbox._el_average,ml_prob._ml_msh); //==================== //===== FILL the DOFS of the EXTERNAL QUANTITIES: you must assure that for every Vect the quantity is set correctly @@ -302,12 +294,6 @@ for (uint fe = 0; fe < QL; fe++) { currelem.Mat()(ip2,ip2) += (1-currelem.GetBCDofFlag()[ip2])*detb; -#if FOURTH_ROW==1 - int ip3 = i + 3 * Tempold._ndof; //suppose that T' T_0 T_adj have the same order - - if (i < currelem.GetElemType(Press2._FEord)->GetNDofs()) { currelem.Rhs()(ip3) += currelem.GetBCDofFlag()[ip3]*dtxJxW_g*(currgp._phi_ndsQLVB_g[Press2._FEord][i]) + (1-currelem.GetBCDofFlag()[ip3])*detb*1300.; - currelem.Mat()(ip3,ip3) += ( 1-currelem.GetBCDofFlag()[ip3] )*detb; } -#endif // Matrix Assemblying --------------------------- for (uint j=0; jGetNDofs() ) currelem.Mat()(ip3,ip3) += currelem.GetBCDofFlag()[ip3]*dtxJxW_g*(currgp._phi_ndsQLVB_g[ Press2._FEord ][/*j*/i]*currgp._phi_ndsQLVB_g[ Press2._FEord ][i]); -#endif - } //end j (col) } //end i (row) } // end of the quadrature point qp-loop - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); } // end of element loop // ***************************************************************** @@ -433,6 +413,7 @@ for (uint fe = 0; fe < QL; fe++) { CurrentElem currelem(Level,BB,&my_system,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); @@ -458,15 +439,15 @@ for (uint fe = 0; fe < QL; fe++) { //========= //DOMAIN MAPPING CurrentQuantity xyz(currgp); //no quantity xyz._dim = space_dim; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //==================Quadratic domain, auxiliary, must be QUADRATIC!!! ========== CurrentQuantity xyz_refbox(currgp); //no quantity xyz_refbox._dim = space_dim; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ ml_prob.GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = myel->GetElementFaceDofNumber(ZERO_ELEM,ZERO_FACE,BIQUADR_FE); xyz_refbox.Allocate(); //===============Tdes===================== @@ -485,7 +466,7 @@ for (uint fe = 0; fe < QL; fe++) { currelem.SetMidpoint(); currelem.ConvertElemCoordsToMappingOrd(xyz); - currelem.TransformElemNodesToRef(ml_prob.GetMeshTwo().GetDomain(),&xyz_refbox._val_dofs[0]); + currelem.TransformElemNodesToRef(ml_prob._ml_msh->GetDomain(),&xyz_refbox._val_dofs[0]); currelem.SetElDofsBc(); @@ -539,8 +520,8 @@ int el_Neum_flag=0; } // end BDRYelement gaussian integration loop - my_system._A[Level]->add_matrix(currelem.Mat(),currelem.GetDofIndices()); - my_system._b[Level]->add_vector(currelem.Rhs(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_KK->add_matrix(currelem.Mat(),currelem.GetDofIndices()); + my_system._LinSolver[Level]->_RESC->add_vector(currelem.Rhs(),currelem.GetDofIndices()); } // end of BDRYelement loop @@ -548,13 +529,13 @@ int el_Neum_flag=0; }//END BOUNDARY - my_system._A[Level]->close(); - my_system._b[Level]->close(); + my_system._LinSolver[Level]->_KK->close(); + my_system._LinSolver[Level]->_RESC->close(); #ifdef DEFAULT_PRINT_INFO std::cout << " Matrix and RHS assembled for equation " << my_system.name() - << " Level "<< Level << " dofs " << my_system._A[Level]->n() << std::endl; + << " Level "<< Level << " dofs " << my_system._LinSolver[Level]->_KK->n() << std::endl; #endif return; diff --git a/applications/OptimalControl/tempopt/OptLoop.cpp b/applications/OptimalControl/tempopt/OptLoop.cpp index bf82cf514..76e8d41a1 100644 --- a/applications/OptimalControl/tempopt/OptLoop.cpp +++ b/applications/OptimalControl/tempopt/OptLoop.cpp @@ -18,7 +18,7 @@ namespace femus { OptLoop::OptLoop(Files& files_in, const FemusInputParser & map_in): TimeLoop(files_in, map_in) { } //================= - void OptLoop::optimization_loop(MultiLevelProblem & eqmap_in) { + void OptLoop::optimization_loop(MultiLevelProblem & ml_prob) { // parameters int print_step = _timemap.get("printstep"); @@ -43,14 +43,14 @@ namespace femus { const uint delta_t_step = curr_step - _t_idx_in; // time step for each system, without printing (good) - OneTimestepEqnLoop(delta_t_step,eqmap_in); + OneTimestepEqnLoop(delta_t_step,ml_prob); #if DEFAULT_PRINT_TIME==1 std::clock_t end_time=std::clock(); #endif // print solution - if (delta_t_step%print_step == 0) XDMFWriter::PrintSolLinear(_files.GetOutputPath(),curr_step,curr_time,eqmap_in); //print sol.N.h5 and sol.N.xmf + if (delta_t_step%print_step == 0) XDMFWriter::PrintSolLinear(_files.GetOutputPath(),curr_step,curr_time,ml_prob); //print sol.N.h5 and sol.N.xmf #if DEFAULT_PRINT_TIME==1 @@ -61,13 +61,13 @@ namespace femus { #endif //=====functional evaluations======= - SystemTwo & eqnT = eqmap_in.get_system("Eqn_T"); + SystemTwo & eqnT = ml_prob.get_system("Eqn_T"); double J = 0.; -J = ComputeIntegral ( eqmap_in.GetMeshTwo()._NoLevels - 1,&eqmap_in.GetMeshTwo(),&eqnT,_files.GetOutputTime()); -J = ComputeNormControl ( eqmap_in.GetMeshTwo()._NoLevels - 1,&eqmap_in.GetMeshTwo(),&eqnT,0 ); -J = ComputeNormControl ( eqmap_in.GetMeshTwo()._NoLevels - 1,&eqmap_in.GetMeshTwo(),&eqnT,1 ); +J = ComputeIntegral ( ml_prob.GetMeshTwo()._NoLevels - 1,&ml_prob.GetMeshTwo(),&eqnT,_files.GetOutputTime()); +J = ComputeNormControl ( ml_prob.GetMeshTwo()._NoLevels - 1,&ml_prob.GetMeshTwo(),&eqnT,0 ); +J = ComputeNormControl ( ml_prob.GetMeshTwo()._NoLevels - 1,&ml_prob.GetMeshTwo(),&eqnT,1 ); //=====functional evaluations ======= @@ -82,15 +82,15 @@ J = ComputeNormControl ( eqmap_in.GetMeshTwo()._NoLevels - 1,&eqmap_in.GetMeshTw double ComputeIntegral (const uint Level, const MultiLevelMeshTwo* mesh, const SystemTwo* eqn, const std::string output_time) { + Mesh *mymsh = eqn->GetMLProb()._ml_msh->GetLevel(Level); //====== processor index const uint myproc = mesh->_iproc; const uint space_dim = mesh->get_dim(); - const uint mesh_ord = (int) mesh->GetRuntimeMap().get("mesh_ord"); - const uint meshql = (int) mesh->GetRuntimeMap().get("meshql"); //======== ELEMENT MAPPING ======= const uint mesh_vb = VV; CurrentElem currelem(Level,VV,eqn,*mesh,eqn->GetMLProb().GetElemType()); + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,eqn->GetMLProb().GetQrule(currelem.GetDim())); //========== @@ -114,15 +114,15 @@ double ComputeIntegral (const uint Level, const MultiLevelMeshTwo* mesh, const S //========= DOMAIN MAPPING CurrentQuantity xyz(currgp); xyz._dim = space_dim; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //========== Quadratic domain, auxiliary CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = space_dim; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ mesh->_geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = mymsh->el->GetElementDofNumber(ZERO_ELEM,BIQUADR_FE); xyz_refbox.Allocate(); @@ -144,7 +144,7 @@ double ComputeIntegral (const uint Level, const MultiLevelMeshTwo* mesh, const S // =============== xyz_refbox.SetElemAverage(); - int el_flagdom = ElFlagControl(xyz_refbox._el_average,mesh); + int el_flagdom = ElFlagControl(xyz_refbox._el_average,eqn->GetMLProb()._ml_msh); //==================== if ( Tempold._eqnptr != NULL ) Tempold.GetElemDofs(); @@ -223,12 +223,13 @@ double ComputeNormControl (const uint Level, const MultiLevelMeshTwo* mesh, cons // processor index const uint myproc = mesh->_iproc; const uint space_dim = mesh->get_dim(); - const uint mesh_ord = (int) mesh->GetRuntimeMap().get("mesh_ord"); - const uint meshql = (int) mesh->GetRuntimeMap().get("meshql"); //======== ELEMENT MAPPING ======= const uint mesh_vb = VV; + Mesh *mymsh = eqn->GetMLProb()._ml_msh->GetLevel(Level); + CurrentElem currelem(Level,VV,eqn,*mesh,eqn->GetMLProb().GetElemType()); + currelem.SetMesh(mymsh); CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,eqn->GetMLProb().GetQrule(currelem.GetDim())); //======Functions in the integrand ============ @@ -242,15 +243,15 @@ double ComputeNormControl (const uint Level, const MultiLevelMeshTwo* mesh, cons //========= DOMAIN MAPPING CurrentQuantity xyz(currgp); xyz._dim = space_dim; - xyz._FEord = meshql; + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); //========== Quadratic domain, auxiliary CurrentQuantity xyz_refbox(currgp); xyz_refbox._dim = space_dim; - xyz_refbox._FEord = mesh_ord; //this must be QUADRATIC!!! - xyz_refbox._ndof = NVE[ mesh->_geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + xyz_refbox._FEord = MESH_ORDER; + xyz_refbox._ndof = mymsh->el->GetElementDofNumber(ZERO_ELEM,BIQUADR_FE); xyz_refbox.Allocate(); @@ -320,13 +321,13 @@ double ComputeNormControl (const uint Level, const MultiLevelMeshTwo* mesh, cons ///AAA questa funzione NON lavora se tu fai solo DUE SUDDIVISIONI PER LATO e nolevels=1 !!! - int ElFlagControl(const std::vector el_xm, const MultiLevelMeshTwo* mesh) { + int ElFlagControl(const std::vector el_xm, const MultiLevelMesh* mesh) { Box* box= static_cast(mesh->GetDomain()); int el_flagdom=0; - if (mesh->get_dim() == 2) { + if (mesh->GetDimension() == 2) { //============== OUTFLOW // if ( el_xm[0] > 0.25*(box->_le[0] - box->_lb[0]) // && el_xm[0] < 0.75*(box->_le[0] - box->_lb[0]) @@ -356,7 +357,7 @@ double ComputeNormControl (const uint Level, const MultiLevelMeshTwo* mesh, cons // } } - else if (mesh->get_dim() == 3) { + else if (mesh->GetDimension() == 3) { if ( el_xm[0] > 0.25*(box->_le[0] - box->_lb[0]) && el_xm[0] < 0.75*(box->_le[0] - box->_lb[0]) diff --git a/applications/OptimalControl/tempopt/OptLoop.hpp b/applications/OptimalControl/tempopt/OptLoop.hpp index 6cc1a708a..368b9dfa9 100644 --- a/applications/OptimalControl/tempopt/OptLoop.hpp +++ b/applications/OptimalControl/tempopt/OptLoop.hpp @@ -30,11 +30,11 @@ void optimization_loop( MultiLevelProblem & e_map_in ); }; - double ComputeIntegral (const uint Level,const MultiLevelMeshTwo* mesh, const SystemTwo* eqn, const std::string output_time); + double ComputeIntegral (const uint Level, const MultiLevelMeshTwo* mesh, const SystemTwo* eqn, const std::string output_time); double ComputeNormControl (const uint Level, const MultiLevelMeshTwo* mesh, const SystemTwo* eqn, const uint reg_ord ); - int ElFlagControl(const std::vector el_xm, const MultiLevelMeshTwo* mesh); + int ElFlagControl(const std::vector el_xm, const MultiLevelMesh* mesh); } //end namespace femus @@ -46,8 +46,5 @@ void optimization_loop( MultiLevelProblem & e_map_in ); // #define DIMENSION 3 // ************************************** -#define FOURTH_ROW 1 - - #endif \ No newline at end of file diff --git a/applications/OptimalControl/tempopt/TempQuantities.cpp b/applications/OptimalControl/tempopt/TempQuantities.cpp index 5b76ff3fc..7b88164c5 100644 --- a/applications/OptimalControl/tempopt/TempQuantities.cpp +++ b/applications/OptimalControl/tempopt/TempQuantities.cpp @@ -48,14 +48,6 @@ Velocity::Velocity(std::string name_in, QuantityMap& qtymap_in, uint dim_in, uin for (uint i=0;iget("Uref"); } - -//======================== -Pressure2::Pressure2(std::string name_in, QuantityMap& qtymap_in, uint dim_in, uint FEord_in) -: Quantity(name_in,qtymap_in,dim_in,FEord_in) { - - for (uint i=0;iget("pref"); -} - //=================== END CONSTRUCTORS ================================ // ================================================================== // ================================================================== @@ -288,20 +280,11 @@ void Temperature::heatflux_txyz(const double /*t*/, const double* /*xyz*/, doubl return; } -// ================================================= -void Pressure2::Function_txyz(const double/* t*/, const double* xp,double* value) const { - value[0] = 1.; - - return; - - } - - void Velocity::bc_flag_txyz(const double t, const double* xp, std::vector & bc_flag) const { - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -400,7 +383,7 @@ if (_qtymap.GetMeshTwo()->get_dim() == 2) { void Pressure::bc_flag_txyz(const double t, const double* xp, std::vector & bc_flag) const { - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -466,7 +449,7 @@ Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); // T' and its adjoint must be Dirichlet homogeneous everywhere on the boundary, by definition. - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box= static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -523,7 +506,7 @@ Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); // T' and its adjoint must be Dirichlet homogeneous everywhere on the boundary, by definition. - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box= static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -588,7 +571,7 @@ Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); void TempAdj::bc_flag_txyz(const double t, const double* xp, std::vector & bc_flag) const { - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box= static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -658,37 +641,6 @@ Box* box = static_cast(_qtymap.GetMeshTwo()->GetDomain()); } - void Pressure2::bc_flag_txyz(const double t, const double* xp, std::vector & bc_flag) const { - - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); - - - Box* box= static_cast(_qtymap.GetMeshTwo()->GetDomain()); - - std::vector lb(_qtymap.GetMeshTwo()->get_dim()); - std::vector le(_qtymap.GetMeshTwo()->get_dim()); - lb[0] = box->_lb[0]; //already nondimensionalized - le[0] = box->_le[0]; - lb[1] = box->_lb[1]; - le[1] = box->_le[1]; - if (_qtymap.GetMeshTwo()->get_dim() == 3) { - lb[2] = box->_lb[2]; - le[2] = box->_le[2]; - } - - std::vector x_rotshift(_qtymap.GetMeshTwo()->get_dim()); - _qtymap.GetMeshTwo()->_domain->TransformPointToRef(xp,&x_rotshift[0]); - - - if ( (x_rotshift[0]) > -bdry_toll && ( x_rotshift[0]) < bdry_toll ) { //left of the RefBox - bc_flag[0]=0; - } - - - return; -} - - // ====================== INITIALIZE functions =================================== void Temperature::initialize_xyz(const double* xp, std::vector< double >& value) const { @@ -708,7 +660,7 @@ void TempAdj::initialize_xyz(const double* xp, std::vector< double >& value) con void TempLift::initialize_xyz(const double* xp, std::vector< double >& value) const { - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box= static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -728,7 +680,7 @@ void Velocity::initialize_xyz(const double* xp, std::vector< double >& value) co //====== Physics const double Uref = _qtymap.GetInputParser()->get("Uref"); - const double bdry_toll = _qtymap.GetMeshTwo()->GetRuntimeMap().get("bdry_toll"); + const double bdry_toll = DEFAULT_BDRY_TOLL; Box* box= static_cast(_qtymap.GetMeshTwo()->GetDomain()); @@ -812,10 +764,3 @@ void Pressure::initialize_xyz(const double* xp, std::vector< double >& value) co return; } - -void Pressure2::initialize_xyz(const double* xp, std::vector< double >& value) const { - - value[0] = 72.*(xp[0]); - - return; -} diff --git a/applications/OptimalControl/tempopt/TempQuantities.hpp b/applications/OptimalControl/tempopt/TempQuantities.hpp index b49353a14..66ce30698 100644 --- a/applications/OptimalControl/tempopt/TempQuantities.hpp +++ b/applications/OptimalControl/tempopt/TempQuantities.hpp @@ -108,17 +108,4 @@ class Velocity : public Quantity { }; -class Pressure2 : public Quantity { - - public: - Pressure2(std::string name_in, QuantityMap& qtymap_in, uint dim_in, uint FEord_in); - ~Pressure2(){}; - - void Function_txyz(const double t, const double* xp,double* temp) const; - void bc_flag_txyz(const double t, const double* xp, std::vector & flag) const; - void initialize_xyz(const double* xp, std::vector & value) const; - -}; - - #endif \ No newline at end of file diff --git a/applications/OptimalControl/tempopt/input/femus_conf.in b/applications/OptimalControl/tempopt/input/femus_conf.in index 45b3de3bb..bd5b66a6e 100644 --- a/applications/OptimalControl/tempopt/input/femus_conf.in +++ b/applications/OptimalControl/tempopt/input/femus_conf.in @@ -1,20 +1,4 @@ - -# double # mesh file consistency - -nolevels 3 -meshql 1 # ------------- # for THE APP # =MESH CONSISTENCY=== # ==== in library routines # depends on the kind of Mesh that is used# depends basically on the Boundary Mesh# 0=QUADRATIC Mapping 1=LINEAR Mapping -mesh_ord 0 # ==== both for the App and for Gencase ====== # ==== DO IT ONLY FOR Gencase ====== # GAMBIT mesh should provide this info# 0=QUADRATIC GeomElements (Quad8,Quad9,Hex27,...)# 1=LINEAR GeomElements (Quad4,Hex8,...) -geomel_type 3 # ==== DO IT ONLY FOR Gencase ====== # GAMBIT mesh should provide this info -dimension 2 -bdry_toll 0.0000001 # ==== not in library routines, but library-type - - -# --------------------- -penalty_val 1.e10 # ==== not in library routines, but library-type - - - # double # mesh file consistency diff --git a/applications/OptimalControl/tempopt/main.cpp b/applications/OptimalControl/tempopt/main.cpp index 05f2512bc..a5a70ccc4 100644 --- a/applications/OptimalControl/tempopt/main.cpp +++ b/applications/OptimalControl/tempopt/main.cpp @@ -71,8 +71,10 @@ void GenMatRhsNS(MultiLevelProblem &ml_prob, unsigned Level, const unsigned &gr const double _Pr = muf/rhof; physics_map.set("Pr",_Pr); // ======= Mesh ===== - FemusInputParser mesh_map("Mesh",files.GetOutputPath()); - GenCase mesh(mesh_map,"inclQ2D2x2.gam"); + const unsigned NoLevels = 3; + const unsigned dim = 2; + const GeomElType geomel_type = QUAD; + GenCase mesh(NoLevels,dim,geomel_type,"inclQ2D2x2.gam"); mesh.SetLref(1.); // ======= MyDomainShape (optional, implemented as child of Domain) ==================== @@ -118,18 +120,20 @@ void GenMatRhsNS(MultiLevelProblem &ml_prob, unsigned Level, const unsigned &gr Pressure pressure("Qty_Pressure",qty_map,1,LL); qty_map.AddQuantity(&pressure); Velocity velocity("Qty_Velocity",qty_map,mesh.get_dim(),QQ); qty_map.AddQuantity(&velocity); -#if FOURTH_ROW==1 - Pressure2 pressure_2("Qty_Pressure_2",qty_map,1,KK); qty_map.AddQuantity(&pressure_2); -#endif - // ===== end QuantityMap ========================================= // ====== Start new main ================================= + MultiLevelMesh ml_msh; - ml_msh.GenerateCoarseBoxMesh(8,8,0,0,1,0,1,0,0,QUAD9,"fifth"); // ml_msh.GenerateCoarseBoxMesh(numelemx,numelemy,numelemz,xa,xb,ya,yb,za,zb,elemtype,"seventh"); - ml_msh.RefineMesh(mesh_map.get("nolevels"),mesh_map.get("nolevels"),NULL); + ml_msh.GenerateCoarseBoxMesh(8,8,0,0,1,0,2,0,0,QUAD9,"fifth"); // ml_msh.GenerateCoarseBoxMesh(numelemx,numelemy,numelemz,xa,xb,ya,yb,za,zb,elemtype,"fifth"); + ml_msh.RefineMesh(NoLevels,NoLevels,NULL); ml_msh.PrintInfo(); + ml_msh.SetWriter(XDMF); + ml_msh.GetWriter()->write(files.GetOutputPath(),"biquadratic"); + + ml_msh.SetDomain(&mybox); + MultiLevelSolution ml_sol(&ml_msh); ml_sol.AddSolution("FAKE",LAGRANGE,SECOND,0); @@ -155,10 +159,7 @@ void GenMatRhsNS(MultiLevelProblem &ml_prob, unsigned Level, const unsigned &gr eqnT.AddSolutionToSystemPDE("FAKE"); eqnT.AddUnknownToSystemPDE(&temperature); eqnT.AddUnknownToSystemPDE(&templift); - eqnT.AddUnknownToSystemPDE(&tempadj); -#if FOURTH_ROW==1 - eqnT.AddUnknownToSystemPDE(&pressure_2); //the order in which you add defines the order in the matrix as well, so it is in tune with the assemble function -#endif + eqnT.AddUnknownToSystemPDE(&tempadj);//the order in which you add defines the order in the matrix as well, so it is in tune with the assemble function eqnT.SetAssembleFunction(GenMatRhsT); //================================ @@ -178,21 +179,21 @@ void GenMatRhsNS(MultiLevelProblem &ml_prob, unsigned Level, const unsigned &gr SystemTwo* sys = static_cast(eqn->second); //===================== - sys -> init(); //the dof map is built here based on all the solutions associated with that system + sys -> init_two(); //the dof map is built here based on all the solutions associated with that system sys -> _LinSolver[0]->set_solver_type(GMRES); //if I keep PREONLY it doesn't run //===================== - sys -> init_sys(); + sys -> init_unknown_vars(); //===================== sys -> _dofmap.ComputeMeshToDof(); //===================== sys -> initVectors(); //===================== - sys -> Initialize(); //why do they do this BEFORE the dofmap? + sys -> Initialize(); ///===================== - sys -> _bcond.GenerateBdc(); //why do they do this BEFORE the dofmap? + sys -> _bcond.GenerateBdc(); //===================== - sys -> ReadMGOps(files.GetOutputPath()); + GenCase::ReadMGOps(files.GetOutputPath(),sys); } diff --git a/applications/Poisson/main.cpp b/applications/Poisson/main.cpp index 80b197d0c..e97b4c36e 100644 --- a/applications/Poisson/main.cpp +++ b/applications/Poisson/main.cpp @@ -81,9 +81,9 @@ int main(int argc,char **argv) { /// Init Petsc-MPI communicator FemusInit mpinit(argc,argv,MPI_COMM_WORLD); - Files files; - files.CheckIODirectories(); - files.RedirectCout(); + //Files files; + //files.CheckIODirectories(); + //files.RedirectCout(); // input parser pointer std::auto_ptr inputparser = InputParser::build(path); @@ -254,14 +254,15 @@ int main(int argc,char **argv) { std::vector print_vars; print_vars.push_back("Sol"); - VTKWriter vtkio(ml_sol); - vtkio.write_system_solutions(files.GetOutputPath(),"biquadratic",print_vars); - - GMVWriter gmvio(ml_sol); - gmvio.write_system_solutions(files.GetOutputPath(),"biquadratic",print_vars); - // - // XDMFWriter xdmfio(ml_sol); - // xdmfio.write_system_solutions(files.GetOutputPath(),"biquadratic",print_vars); + VTKWriter vtkio(&ml_sol); + vtkio.write(DEFAULT_OUTPUTDIR,"biquadratic",print_vars); + + + GMVWriter gmvio(&ml_sol); + gmvio.Pwrite(DEFAULT_OUTPUTDIR,"biquadratic",print_vars); + + //XDMFWriter xdmfio(&ml_sol); + //xdmfio.Pwrite(DEFAULT_OUTPUTDIR,"biquadratic",print_vars); //Destroy all the new systems ml_prob.clear(); @@ -288,7 +289,7 @@ void AssemblePoissonMatrixandRhs(MultiLevelProblem &ml_prob, unsigned level, con //data const unsigned dim = mymsh->GetDimension(); unsigned nel = mymsh->GetNumberOfElements(); - unsigned igrid = mymsh->GetGridNumber(); + unsigned igrid = mymsh->GetLevel(); unsigned iproc = mymsh->processor_id(); //solution variable diff --git a/applications/Poisson_AMR/main.cpp b/applications/Poisson_AMR/main.cpp index 32486043b..18e940053 100644 --- a/applications/Poisson_AMR/main.cpp +++ b/applications/Poisson_AMR/main.cpp @@ -299,9 +299,9 @@ int main(int argc,char **argv) { /// Init Petsc-MPI communicator FemusInit mpinit(argc,argv,MPI_COMM_WORLD); - Files files; - files.CheckIODirectories(); - files.RedirectCout(); + //Files files; + //files.CheckIODirectories(); + //files.RedirectCout(); /// INIT MESH ================================= @@ -421,15 +421,21 @@ int main(int argc,char **argv) { std::vector print_vars; print_vars.push_back("Sol"); - VTKWriter vtkio(ml_sol); - vtkio.write_system_solutions(files.GetOutputPath(),"biquadratic",print_vars); + //VTKWriter vtkio(&ml_sol); + //vtkio.ParallelWrite(files.GetOutputPath(),"biquadratic",print_vars); - GMVWriter gmvio(ml_sol); - gmvio.write_system_solutions(files.GetOutputPath(),"biquadratic",print_vars); + //GMVWriter gmvio(&ml_sol); + //gmvio.ParallelWrite(files.GetOutputPath(),"biquadratic",print_vars); + VTKWriter vtkio(&ml_sol); + vtkio.write(DEFAULT_OUTPUTDIR,"biquadratic",print_vars); + + //GMVWriter gmvio(&ml_sol); + //gmvio.ParallelWrite(DEFAULT_OUTPUTDIR,"biquadratic",print_vars); + // // XDMFWriter xdmfio(ml_sol); - // xdmfio.write_system_solutions("biquadratic",print_vars); + // xdmfio.write("biquadratic",print_vars); int iproc; MPI_Comm_rank(MPI_COMM_WORLD, &iproc); @@ -554,7 +560,7 @@ void AssemblePoissonMatrixandRhs(MultiLevelProblem &ml_prob, unsigned level, con //data const unsigned dim = mymsh->GetDimension(); unsigned nel = mymsh->GetNumberOfElements(); - unsigned igrid = mymsh->GetGridNumber(); + unsigned igrid = mymsh->GetLevel(); unsigned iproc = mymsh->processor_id(); //solution variable diff --git a/doc/devel_rules.txt b/doc/devel_rules.txt index f10481394..83eed58d6 100644 --- a/doc/devel_rules.txt +++ b/doc/devel_rules.txt @@ -86,3 +86,14 @@ git config --global user.email "name.surname@example.com" - Using the manual never hurts... +- To contribute: + Create a personal github account + Create a fork of the femus repository in your github account + Clone your fork in your computer + Work in your computer (do branches, commit changes, ...) + Push your branches back to your fork + Send a pull request to the main femus repository + The maintainers will decide what to do with the pull request and possibly it will be merged to master + Periodically, sync the master in the fork with the master in the main femus repository + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5744f965f..c29bdd68c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -75,6 +75,7 @@ mesh/Mesh.cpp mesh/MultiLevelMesh.cpp mesh/MeshGeneration.cpp mesh/GambitIO.cpp +mesh/SalomeIO.cpp mesh/MeshRefinement.cpp mesh/MeshMetisPartitioning.cpp mesh/MeshPartitioning.cpp diff --git a/src/algebra/AsmPetscLinearEquationSolver.cpp b/src/algebra/AsmPetscLinearEquationSolver.cpp index cb611b5b4..ca645313d 100644 --- a/src/algebra/AsmPetscLinearEquationSolver.cpp +++ b/src/algebra/AsmPetscLinearEquationSolver.cpp @@ -151,10 +151,7 @@ namespace femus { vector < unsigned > indexb(DofOffsetSize,DofOffsetSize); vector owned(DofOffsetSize,false); - map mymap; - //map mymap_u; - //map mymap_p; - + map mymap; unsigned ElemOffset = _msh->MetisOffset[3][iproc]; unsigned ElemOffsetp1 = _msh->MetisOffset[3][iproc+1]; @@ -166,9 +163,7 @@ namespace femus { MeshASMPartitioning meshasmpartitioning(*_msh); meshasmpartitioning.DoPartition(_element_block_number, block_elements, _block_type_range); - //_msh->GenerateVankaPartitions_FSI1(_element_block_number, block_elements, _block_type_range); - - + vector ThisVaribaleIsNonSchur(_SolPdeIndex.size(),true); for (unsigned iind=variable_to_be_solved.size()-_NSchurVar; iindIS_Mts2Gmt_elem_offset[iproc] + vb_index*_element_block_number; - // for (int iel_mts=gel; iel_mtsIS_Mts2Gmt_elem_offset[iproc+1]; iel_mts++) { - for(int kel=0;kelIS_Mts2Gmt_elem[iel_mts]; - //unsigned iel = _msh->IS_Mts2Gmt_elem[block_elements[vb_index][kel]]; - for (unsigned i=0; i<_msh->el->GetElementDofNumber(iel,0); i++) { unsigned inode=_msh->el->GetElementVertexIndex(iel,i)-1u; unsigned nvei=_msh->el->GetVertexElementNumber(inode); @@ -229,39 +205,35 @@ namespace femus { indexc[jel_Metis-ElemOffset]=Csize++; //---------------------------------------------------------------------------------- //add non-schur node to be solved - - //for (unsigned iind=0; iindel->GetElementVertexAddress(jel,0); unsigned nvej=_msh->el->GetElementDofNumber(jel,SolType); for (unsigned jj=0; jjGetMetisDof(jnode,SolType); - unsigned kkdof=GetKKDof(SolPdeIndex, indexSol, jnode); - if(jnode_Metis >= _msh->MetisOffset[SolType][iproc] && - jnode_Metis < _msh->MetisOffset[SolType][iproc+1]){ - //unsigned kkdof=GetKKDof(SolPdeIndex, indexSol, jnode); - if(indexa[kkdof- DofOffset]==DofOffsetSize && owned[kkdof- DofOffset]==false) { - owned[kkdof- DofOffset]=true; - _is_loc_idx[vb_index][PAsize]=kkdof; - indexa[kkdof-DofOffset]=PAsize++; + unsigned jnode=_msh->el->GetMeshDof(jel,jj,SolType); + +// bool solidmark = _msh->el->GetNodeRegion(jnode); +// if( vb_index < _block_type_range[0] || !solidmark ){ + unsigned jnode_Metis = _msh->GetMetisDof(jnode,SolType); + unsigned kkdof=GetKKDof(SolPdeIndex, indexSol, jnode); + if(jnode_Metis >= _msh->MetisOffset[SolType][iproc] && + jnode_Metis < _msh->MetisOffset[SolType][iproc+1]){ + if(indexa[kkdof- DofOffset]==DofOffsetSize && owned[kkdof- DofOffset]==false) { + owned[kkdof- DofOffset]=true; + _is_loc_idx[vb_index][PAsize]=kkdof; + indexa[kkdof-DofOffset]=PAsize++; + } + if(indexb[kkdof- DofOffset]==DofOffsetSize) { + _is_ovl_idx[vb_index][PBsize]=kkdof; + indexb[kkdof-DofOffset]=PBsize++; + } } - if(indexb[kkdof- DofOffset]==DofOffsetSize) { - _is_ovl_idx[vb_index][PBsize]=kkdof; - indexb[kkdof-DofOffset]=PBsize++; - //_is_ovl_u_idx[vb_index][PBsize_u]=kkdof; - //PBsize_u++; + else { + mymap[kkdof]=true; } } - else { - mymap[kkdof]=true; - //mymap_u[kkdof]=true; - } - } +// } } } } @@ -271,16 +243,13 @@ namespace femus { //----------------------------------------------------------------------------------------- //Add Schur nodes (generally pressure) to be solved { - //for (unsigned iind=variable_to_be_solved.size()-_NSchurVar; iindel->GetElementVertexAddress(iel,0); unsigned nvei=_msh->el->GetElementDofNumber(iel,SolType); for (unsigned ii=0; iiel->GetMeshDof(iel,ii,SolType); unsigned inode_Metis = _msh->GetMetisDof(inode,SolType); unsigned kkdof=GetKKDof(SolPdeIndex, indexSol, inode); if(inode_Metis >= _msh->MetisOffset[SolType][iproc] && @@ -293,13 +262,10 @@ namespace femus { if(indexb[kkdof- DofOffset]==DofOffsetSize ) { _is_ovl_idx[vb_index][PBsize]=kkdof; indexb[kkdof-DofOffset]=PBsize++; - //_is_ovl_p_idx[vb_index][PBsize_p]=kkdof; - //PBsize_p++; } } else{ mymap[kkdof]=true; - //mymap_p[kkdof]=true; } } } @@ -307,7 +273,6 @@ namespace femus { } //----------------------------------------------------------------------------------------- } - // if(gel+_element_block_number <_msh->IS_Mts2Gmt_elem_offset[iproc+1] ) test_end=0; // *** re-initialize indeces(a,c,d) for (PetscInt i=0; ifirst; } - /*_is_ovl_u_idx[vb_index].resize(PBsize_u+mymap_u.size()); - i=0; - for (std::map::iterator it=mymap_u.begin(); it!=mymap_u.end(); ++it,++i){ - _is_ovl_u_idx[vb_index][PBsize_u+i]= it->first; - } - - _is_ovl_p_idx[vb_index].resize(PBsize_p+mymap_p.size()); - i=0; - for (std::map::iterator it=mymap_p.begin(); it!=mymap_p.end(); ++it,++i){ - _is_ovl_p_idx[vb_index][PBsize_p+i]= it->first; - }*/ - - - - - std::sort(_is_loc_idx[vb_index].begin(), _is_loc_idx[vb_index].end()); std::sort(_is_ovl_idx[vb_index].begin(), _is_ovl_idx[vb_index].end()); -// std::sort(_is_ovl_u_idx[vb_index].begin(), _is_ovl_u_idx[vb_index].end()); -// std::sort(_is_ovl_p_idx[vb_index].begin(), _is_ovl_p_idx[vb_index].end()); } //BEGIN Generate std::vector for vanka solve *********** _is_loc.resize(_is_loc_idx.size()); _is_ovl.resize(_is_ovl_idx.size()); - //_is_ovl_u.resize(_is_ovl_u_idx.size()); - //_is_ovl_p.resize(_is_ovl_p_idx.size()); + for(unsigned vb_index=0;vb_index<_is_loc_idx.size();vb_index++){ PetscErrorCode ierr; ierr=ISCreateGeneral(MPI_COMM_SELF,_is_loc_idx[vb_index].size(),&_is_loc_idx[vb_index][0],PETSC_USE_POINTER,&_is_loc[vb_index]); CHKERRABORT(MPI_COMM_SELF,ierr); ierr=ISCreateGeneral(MPI_COMM_SELF,_is_ovl_idx[vb_index].size(),&_is_ovl_idx[vb_index][0],PETSC_USE_POINTER,&_is_ovl[vb_index]); CHKERRABORT(MPI_COMM_SELF,ierr); - //ierr=ISCreateGeneral(MPI_COMM_SELF,_is_ovl_u_idx[vb_index].size(),&_is_ovl_u_idx[vb_index][0],PETSC_USE_POINTER,&_is_ovl_u[vb_index]); - //CHKERRABORT(MPI_COMM_SELF,ierr); - //ierr=ISCreateGeneral(MPI_COMM_SELF,_is_ovl_p_idx[vb_index].size(),&_is_ovl_p_idx[vb_index][0],PETSC_USE_POINTER,&_is_ovl_p[vb_index]); - //CHKERRABORT(MPI_COMM_SELF,ierr); } //END Generate std::vector for vanka solve *********** @@ -448,7 +388,7 @@ namespace femus { // *** Computational info *** #ifndef NDEBUG - cout << "ASM Grid: " << _msh->GetGridNumber()<< " SOLVER TIME: " << std::setw(11) << std::setprecision(6) << std::fixed << + cout << "ASM Grid: " << _msh->GetLevel()<< " SOLVER TIME: " << std::setw(11) << std::setprecision(6) << std::fixed << static_cast( SearchTime + AssemblyTime + SolveTime + UpdateTime)/ CLOCKS_PER_SEC<< " ITS: " << _maxits << "\t ksp_clean = "<< ksp_clean<GetGridNumber()!=0) + if(_msh->GetLevel()!=0) KSPSetInitialGuessKnoll(_ksp, PETSC_TRUE); - if(_msh->GetGridNumber()!=0) + if(_msh->GetLevel()!=0) KSPSetNormType(_ksp,KSP_NORM_NONE); ierr = KSPSetFromOptions(_ksp); CHKERRABORT(MPI_COMM_WORLD,ierr); @@ -587,7 +527,7 @@ namespace femus { ierr = KSPSetType(_ksp, (char*) KSPCGS); CHKERRABORT(MPI_COMM_WORLD,ierr); return; case BICG: - ierr = KSPSetType(_ksp, (char*) KSPBICG); CHKERRABORT(MPI_COMM_WORLD,ierr); + ierr = KSPSetType(_ksp, (char*) KSPBICG); CHKERRABORT(MPI_COMM_WORLD,ierr); return; case TCQMR: ierr = KSPSetType(_ksp, (char*) KSPTCQMR); CHKERRABORT(MPI_COMM_WORLD,ierr); @@ -596,10 +536,10 @@ namespace femus { ierr = KSPSetType(_ksp, (char*) KSPTFQMR); CHKERRABORT(MPI_COMM_WORLD,ierr); return; case LSQR: - ierr = KSPSetType(_ksp, (char*) KSPLSQR); CHKERRABORT(MPI_COMM_WORLD,ierr); + ierr = KSPSetType(_ksp, (char*) KSPLSQR); CHKERRABORT(MPI_COMM_WORLD,ierr); return; case BICGSTAB: - ierr = KSPSetType(_ksp, (char*) KSPBCGS); CHKERRABORT(MPI_COMM_WORLD,ierr); + ierr = KSPSetType(_ksp, (char*) KSPBCGS); CHKERRABORT(MPI_COMM_WORLD,ierr); return; case MINRES: ierr = KSPSetType(_ksp, (char*) KSPMINRES); CHKERRABORT(MPI_COMM_WORLD,ierr); diff --git a/src/algebra/GmresPetscLinearEquationSolver.cpp b/src/algebra/GmresPetscLinearEquationSolver.cpp index 9efbae620..ce66ef94c 100644 --- a/src/algebra/GmresPetscLinearEquationSolver.cpp +++ b/src/algebra/GmresPetscLinearEquationSolver.cpp @@ -229,7 +229,7 @@ namespace femus { // *** Computational info *** #ifndef NDEBUG - cout << "GMRES Grid: " << _msh->GetGridNumber()<< " SOLVER TIME: " << std::setw(11) << std::setprecision(6) << std::fixed << + cout << "GMRES Grid: " << _msh->GetLevel()<< " SOLVER TIME: " << std::setw(11) << std::setprecision(6) << std::fixed << static_cast( SearchTime + AssemblyTime + SolveTime + UpdateTime)/ CLOCKS_PER_SEC<< " ITS: " << _maxits << "\t ksp_clean = "<< ksp_clean<GetGridNumber()!=0) + if(_msh->GetLevel()!=0) KSPSetInitialGuessKnoll(_ksp, PETSC_TRUE); - if(_msh->GetGridNumber()!=0) + if(_msh->GetLevel()!=0) KSPSetNormType(_ksp,KSP_NORM_NONE); // Set the options from user-input @@ -433,7 +433,7 @@ std::pair GmresPetscLinearEquationSolver::solve(SparseMatr } - // DEPRECATED ======================================================== + // @deprecated ======================================================== PetscErrorCode __libmesh_petsc_preconditioner_setup(PC pc) { void *ctx; PetscErrorCode ierr = PCShellGetContext(pc,&ctx); @@ -444,7 +444,7 @@ PetscErrorCode __libmesh_petsc_preconditioner_setup(PC pc) { } -// DEPRECATED ======================================================== +// @deprecated ======================================================== PetscErrorCode __libmesh_petsc_preconditioner_apply(PC pc, Vec x, Vec y) { void *ctx; PetscErrorCode ierr = PCShellGetContext(pc,&ctx); @@ -457,7 +457,7 @@ PetscErrorCode __libmesh_petsc_preconditioner_apply(PC pc, Vec x, Vec y) { } - // DEPRECATED ======================================================== + // @deprecated ======================================================== void GmresPetscLinearEquationSolver::init(SparseMatrix* matrix) { PetscMatrix* matrix_two = libmeshM_cast_ptr(matrix); diff --git a/src/algebra/GmresPetscLinearEquationSolver.hpp b/src/algebra/GmresPetscLinearEquationSolver.hpp index 5d6c59d81..085006b2a 100644 --- a/src/algebra/GmresPetscLinearEquationSolver.hpp +++ b/src/algebra/GmresPetscLinearEquationSolver.hpp @@ -71,12 +71,12 @@ class GmresPetscLinearEquationSolver : public LinearEquationSolver { clock_t BuildIndex(const vector &variable_to_be_solved); - /** DEPRECATED, remove soon */ + /** @deprecated, remove soon */ std::pair solve(SparseMatrix& matrix_in, SparseMatrix& precond_in, NumericVector& solution_in, NumericVector& rhs_in, const double tol, const unsigned int m_its); - /** DEPRECATED, remove soon */ + /** @deprecated, remove soon */ void init(SparseMatrix* matrix); private: diff --git a/src/algebra/LinearEquation.cpp b/src/algebra/LinearEquation.cpp index 4c3f1b7e6..afaface63 100644 --- a/src/algebra/LinearEquation.cpp +++ b/src/algebra/LinearEquation.cpp @@ -176,7 +176,7 @@ void LinearEquation::InitPde(const vector &SolPdeIndex_other, const _KK = SparseMatrix::build().release(); //_KK->init(KK_size,KK_size,KK_local_size,KK_local_size,KK_UNIT_SIZE_*KKIndex.size(),KK_UNIT_SIZE_*KKIndex.size()); _KK->init(KK_size,KK_size,KK_local_size,KK_local_size,d_nnz,o_nnz); - unsigned igrid=_msh->GetGridNumber()+1; + unsigned igrid=_msh->GetLevel()+1; if(igrid>=_gridr && igrid<_gridn){ _CC = SparseMatrix::build().release(); _CC->init(KK_size,KK_size,KK_local_size,KK_local_size,d_nnz,o_nnz); @@ -194,7 +194,7 @@ void LinearEquation::AddLevel(){ int KK_size=KKIndex[KKIndex.size()-1u]; int KK_local_size =KKoffset[KKIndex.size()-1][processor_id()] - KKoffset[0][processor_id()]; - unsigned igrid=_msh->GetGridNumber()+1; + unsigned igrid=_msh->GetLevel()+1; if(igrid>=_gridr && igrid<_gridn){ _CC = SparseMatrix::build().release(); _CC->init(KK_size,KK_size,KK_local_size,KK_local_size,d_nnz,o_nnz); @@ -231,14 +231,14 @@ void LinearEquation::DeletePde() { if(_KK) delete _KK; - unsigned igrid=_msh->GetGridNumber()+1; + unsigned igrid=_msh->GetLevel()+1; if(igrid>=_gridr && igrid<_gridn){ if(_CC) delete _CC; } - if (_msh->GetGridNumber()>0) { + if (_msh->GetLevel()>0) { if(_PP) delete _PP; if(_RR) @@ -288,7 +288,7 @@ void LinearEquation::DeletePde() { // mesh and procs int nel = _msh->GetNumberOfElements(); - int igrid = _msh->GetGridNumber(); + int igrid = _msh->GetLevel(); int this_proc = _msh->processor_id(); int nprocs= _msh->n_processors(); diff --git a/src/algebra/LinearEquationSolver.hpp b/src/algebra/LinearEquationSolver.hpp index 756858c0c..30872e6fc 100644 --- a/src/algebra/LinearEquationSolver.hpp +++ b/src/algebra/LinearEquationSolver.hpp @@ -124,7 +124,7 @@ class LinearEquationSolver : public LinearEquation { /** Call the smoother-solver using the PetscLibrary. */ virtual void solve(const vector &VankaIndex, const bool &ksp_clean) = 0; - /** DEPRECATED Old solver with algebra objects passed as arguments TODO think of removing */ + /** @deprecated Old solver with algebra objects passed as arguments TODO think of removing */ virtual std::pair solve (SparseMatrix&, // System Matrix SparseMatrix&, // prec NumericVector&, // Solution vector diff --git a/src/algebra/PetscMatrix.hpp b/src/algebra/PetscMatrix.hpp index 014741b02..d4d55ed12 100644 --- a/src/algebra/PetscMatrix.hpp +++ b/src/algebra/PetscMatrix.hpp @@ -121,9 +121,11 @@ class PetscMatrix : public SparseMatrix { int MatGetRowM(const int i_val,int cols[]=PETSC_NULL , double vals[]=PETSC_NULL ); // Setting ------------------------------------- - // update pattern - void update_sparsity_pattern_old (const Graph & sparsity_pattern); //TODO remove it soon + /** @deprecated */ + void update_sparsity_pattern_old (const Graph & sparsity_pattern); + void update_sparsity_pattern(const Graph &sparsity_pattern); ///< sparsity patter update (Graph) + void update_sparsity_pattern(int m,int n,int m_l,int n_l, ///< sparsity patter update (petsc) const std::vector n_oz,const std::vector n_nz); // set values diff --git a/src/algebra/PetscVector.cpp b/src/algebra/PetscVector.cpp index b53a3f663..a854c348b 100644 --- a/src/algebra/PetscVector.cpp +++ b/src/algebra/PetscVector.cpp @@ -185,6 +185,7 @@ void PetscVector::matrix_mult(const NumericVector &vec_in,const SparseMatrix &ma A->close(); ierr = MatMult(const_cast(A)->mat(),v->_vec,_vec); CHKERRABORT(MPI_COMM_WORLD,ierr); + this->close(); return; } @@ -200,6 +201,7 @@ void PetscVector::matrix_mult_transpose(const NumericVector &vec_in,const Sparse A->close(); ierr = MatMultTranspose(const_cast(A)->mat(),v->_vec,_vec); CHKERRABORT(MPI_COMM_WORLD,ierr); + this->close(); return; } diff --git a/src/algebra/SparseMatrix.hpp b/src/algebra/SparseMatrix.hpp index a78734e0f..2c43de31b 100644 --- a/src/algebra/SparseMatrix.hpp +++ b/src/algebra/SparseMatrix.hpp @@ -121,11 +121,10 @@ class SparseMatrix { /** Close flag */ virtual bool closed() const = 0; - // Updates the matrix sparsity pattern - /** Full sparsity update */ + /** @deprecated */ virtual void update_sparsity_pattern_old (const Graph &) =0; - /** To be Added */ + /** Full sparsity update */ virtual void update_sparsity_pattern (const Graph &) =0; /** Partial sparsity update */ @@ -216,7 +215,7 @@ class SparseMatrix { /** Print to the text file */ virtual void print_personal(std::ostream& os=std::cout) const = 0; - /** print to hdf5 files */ + /** @deprecated print to hdf5 files */ virtual void print_hdf5(const std::string name="NULL") const=0; // Read @@ -224,14 +223,14 @@ class SparseMatrix { void read(const std::string& name); /** Read from hdf5 files */ - /** Read lengths */ + /** @deprecated Read lengths */ virtual void read_len_hdf5(const std::string namefile,const int mode, int len_row[],int leng_off_row[]); - /** Read pos */ + /** @deprecated Read pos */ virtual void read_pos_hdf5(const std::string namefile, const int mode, int pos[]); - /** Read dimensions */ + /** @deprecated Read dimensions */ virtual void read_dim_hdf5(const std::string namefile, int dim[]); // Submatrices ------------------------------------------------------ diff --git a/src/algebra/VankaPetscLinearEquationSolver.cpp b/src/algebra/VankaPetscLinearEquationSolver.cpp index 01bdaf2a6..f1ae55db4 100644 --- a/src/algebra/VankaPetscLinearEquationSolver.cpp +++ b/src/algebra/VankaPetscLinearEquationSolver.cpp @@ -381,7 +381,7 @@ namespace femus { #ifndef NDEBUG // *** Computational info *** - cout << "VANKA Grid: "<<_msh->GetGridNumber()<< " SOLVER TIME: " << std::setw(11) << std::setprecision(6) << std::fixed << + cout << "VANKA Grid: "<<_msh->GetLevel()<< " SOLVER TIME: " << std::setw(11) << std::setprecision(6) << std::fixed << static_cast(SearchTime + AssemblyTime + SolveTime + UpdateTime)/ CLOCKS_PER_SEC<< " ITS: " << _maxits << endl; #endif @@ -431,10 +431,10 @@ namespace femus { // tolerance for the relative residual & leave the others at default values. ierr = KSPSetTolerances(ksp,_rtol,_abstol,_dtol,_maxits); CHKERRABORT(MPI_COMM_WORLD,ierr); - if(_msh->GetGridNumber()!=0) + if(_msh->GetLevel()!=0) KSPSetInitialGuessKnoll(ksp, PETSC_TRUE); - if(_msh->GetGridNumber()!=0) + if(_msh->GetLevel()!=0) KSPSetNormType(ksp,KSP_NORM_NONE); // Set the options from user-input @@ -529,7 +529,7 @@ namespace femus { // // if (!this->initialized()) { // this->_is_initialized = true; // int ierr=0; -// int grid=_msh->GetGridNumber(); +// int grid=_msh->GetLevel(); // // // Since the matrix is sequential for us, we use as communicator MPI_COMM_WORLD (serial) // // instead of PETSC_COMM_WORLD (parallel) diff --git a/src/enums/FETypeEnum.hpp b/src/enums/FETypeEnum.hpp index 8a262ac67..e95386c7e 100644 --- a/src/enums/FETypeEnum.hpp +++ b/src/enums/FETypeEnum.hpp @@ -14,4 +14,7 @@ enum FEType {QQ=0, LL, KK }; #define NFE_FAMS 5 +#define MESH_MAPPING_FE 1 //linear +#define MESH_ORDER 0 //biq + #endif \ No newline at end of file diff --git a/src/enums/GeomElTypeEnum.hpp b/src/enums/GeomElTypeEnum.hpp index 4754dbc5a..d39a6da17 100644 --- a/src/enums/GeomElTypeEnum.hpp +++ b/src/enums/GeomElTypeEnum.hpp @@ -15,5 +15,8 @@ enum GeomElType { HEX=0, #define LEV_PICK 0 +#define ZERO_ELEM 0 + +#define ZERO_FACE 0 #endif \ No newline at end of file diff --git a/src/equations/BoundaryConditions.cpp b/src/equations/BoundaryConditions.cpp index 95a832375..1d120fb15 100644 --- a/src/equations/BoundaryConditions.cpp +++ b/src/equations/BoundaryConditions.cpp @@ -30,10 +30,10 @@ namespace femus { }; -//TODO every processor does ALL because bc is SERIAL +//=== every processor does ALL because bc is SERIAL //Now here we have to think how to impose the boundary conditions for KK //Now, the bc_read function orders the boundary condition flags of a QUADRATIC or LINEAR DOF OBJECT. - //TODO The point is that you already have to know the ORDER in which the UNKNOWNS are settled in your system, + //=== The point is that you already have to know the ORDER in which the UNKNOWNS are settled in your system, // FIRST QUADRATIC, THEN LINEAR, THEN CONSTANT. // as a matter of fact, the bc_field should be ordered like a DOF vector, //so have first quadratic, then linear, then constant variables. @@ -46,7 +46,7 @@ namespace femus { // climbing back from Boundary to Volume (we know how to do that) // In order to pick the boundary element, we pick its MIDDLE POINT. - //TODO why don't we better impose the boundary conditions + //=== why don't we better impose the boundary conditions // based on QUANTITIES and then SCALAR COMPONENTS of QUANTITIES? // Then depending on the type of dof you would have to // loop over the DOF OBJECTS generating those dofs! @@ -79,7 +79,7 @@ namespace femus { // it is obvious that I have to use two separate functions //Then the problem is when you try to switch one Quantity from a NODE BASED FE Family to an ELEM BASED FE FAMILY //You have to change the way you ENFORCE the BOUNDARY CONDITIONS. - //TODO the problem is that here we should write things better. + //=== the problem is that here we should write things better. // We should write things in such a way that if we set an equation WITHOUT VARIABLES the code still runs. // Here this does not happen. // if you allocate bc_flag with zero components, then you pass the pointer to the bc_read function which will set the components. @@ -106,13 +106,13 @@ namespace femus { //Now that routine is done in such a way that you have to order FIRST QQ, THEN LL, THEN KK; //In this way you will read correctly -//TODO one thing that may be optimized here is that there are computations that could be avoided when you DO NOT HAVE QQ variables, or LL variables, or KK variables. +//=== one thing that may be optimized here is that there are computations that could be avoided when you DO NOT HAVE QQ variables, or LL variables, or KK variables. // The good thing here would be to have a unique bc array at EACH LEVEL. // The distinction between level is especially good for the elements, because the elements //only belong to ONE level, it's not like the nodes... -//TODO now i am looping over elements first, and nodes inside each element next. +//=== now i am looping over elements first, and nodes inside each element next. //therefore, if an element puts a zero and a following element puts a one, the one wins. //so we must find a way which is independent of the element order //if you loop over the nodes you involve them only once... @@ -128,7 +128,7 @@ namespace femus { //not to superimpose the ones on the zeros? //just put a check before checking -//TODO ricorda che i bc sono praticamente dei dof fields, +//=== ricorda che i bc sono praticamente dei dof fields, // quindi in principio possono essere fatti in PARALLELO! // anche x_old e' un vettore di dof. Alla fine non sono cose //molto diverse in fondo! @@ -222,8 +222,10 @@ void BoundaryConditions::GenerateBdc() { for (uint Level=0; Level <_dofmap->_mesh._NoLevels;Level++) { //loop over the levels + Mesh *mymsh = _dofmap->_eqn->GetMLProb()._ml_msh->GetLevel(Level); CurrentElem currelem(Level,BB,_dofmap->_eqn,_dofmap->_mesh,_dofmap->_eqn->GetMLProb().GetElemType()); - const uint el_nnodes_b = NVE[ _dofmap->_mesh._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; + currelem.SetMesh(mymsh); + const uint el_nnodes_b = mymsh->el->GetElementFaceDofNumber(ZERO_ELEM,ZERO_FACE,BIQUADR_FE); for (uint isubd=0; isubd<_dofmap->_mesh._NoSubdom; ++isubd) { uint iel_b = _dofmap->_mesh._off_el[BB][ _dofmap->_mesh._NoLevels*isubd + Level]; @@ -367,6 +369,7 @@ void BoundaryConditions::GenerateBdc() { // // // // // void BoundaryConditions::GenerateBdcElem() { // // // // // // // // // // CurrentElem currelem(BB,_dofmap->_eqn,_dofmap->_mesh,_dofmap->_eqn->GetMLProb().GetElemType()); +// // // // // currelem.SetMesh(mymsh); // // // // // // // // // // uint space_dim = _dofmap->_mesh.get_dim(); // // // // // @@ -859,7 +862,7 @@ return; // // // // // void BoundaryConditions::elem_bc_read(const double el_xm[],int& surf_id, double value[],int el_flag[]) const { // // // // // //el_xm[] is the NON-DIMENSIONAL node coordinate // lb,le are NONDIMENSIONALIZED // // // // // -// // // // // const double bdry_toll = _dofmap->_mesh.GetRuntimeMap().get("bdry_toll"); +// // // // // const double bdry_toll = DEFAULT_BDRY_TOLL; // // // // // // // // // // // // // // // diff --git a/src/equations/CurrentElem.cpp b/src/equations/CurrentElem.cpp index 88e6917a9..0ce609e57 100644 --- a/src/equations/CurrentElem.cpp +++ b/src/equations/CurrentElem.cpp @@ -37,7 +37,7 @@ namespace femus { { //========== Current "Geometric Element" ======================== - uint elnodes = NVE[ _mesh._geomelem_flag[_dim-1] ][BIQUADR_FE]; + uint elnodes = NVE[ _mesh._geomelem_flag[_dim-1] ][BIQUADR_FE];// mymsh->el->GetElementDofNumber(ZERO_ELEM,BIQUADR_FE); _el_conn.resize(elnodes); _el_conn_new.resize(elnodes); _xx_nds.resize(_mesh.get_dim()*elnodes); @@ -58,7 +58,7 @@ namespace femus { } - CurrentElem::~CurrentElem() {} + void CurrentElem::SetMesh(const Mesh * mesh_in) { _mesh_new = mesh_in; return; } @@ -142,7 +142,7 @@ for (uint ivar=0; ivar < _eqn->_dofmap._nvars[fe]; ivar++) { void CurrentElem::PrintOrientation() const { const uint mesh_dim = _mesh.get_dim(); - const uint el_nnodes = NVE[ _mesh._geomelem_flag[_dim-1] ][BIQUADR_FE]; + const uint el_nnodes = _el_conn.size(); std::vector xi(mesh_dim,0.); std::vector eta(mesh_dim,0.); @@ -210,7 +210,7 @@ void CurrentElem::PrintOrientation() const { void CurrentElem::SetMidpoint() { const uint mesh_dim = _mesh.get_dim(); - const uint el_nnodes = NVE[ _mesh._geomelem_flag[_dim-1] ][BIQUADR_FE]; + const uint el_nnodes = _el_conn.size(); for (uint idim=0; idim< mesh_dim; idim++) _el_xm[idim]=0.; @@ -230,7 +230,7 @@ void CurrentElem::PrintOrientation() const { void CurrentElem::SetDofobjConnCoords(const uint isubd_in,const uint iel) { const uint mydim = _mesh.get_dim(); - const uint el_nnodes = NVE[ _mesh._geomelem_flag[_dim-1] ][BIQUADR_FE]; + const uint el_nnodes = _el_conn.size(); for (uint n=0; n offset) {std::cout << "Quadratic transformation over linear mesh " << std::endl;abort();} /*);*/ diff --git a/src/equations/CurrentElem.hpp b/src/equations/CurrentElem.hpp index 8f16f3a6d..5da41c98b 100644 --- a/src/equations/CurrentElem.hpp +++ b/src/equations/CurrentElem.hpp @@ -37,7 +37,6 @@ class CurrentQuantity; public: CurrentElem(const uint level, const uint vb, const SystemTwo*, const MultiLevelMeshTwo& mesh, const std::vector< std::vector > & elem_type); - ~CurrentElem(); inline const uint GetVb() const { return _mesh.get_dim() - _dim; @@ -105,11 +104,13 @@ class CurrentQuantity; const uint GetLevel() const {return _Level;} - //TODO make these private + //TODO make these private //========== Equation-related ======================== const SystemTwo * _eqn; //con questo puoi accedere a dati e funzioni DEL PADRE, NON al FIGLIO const MultiLevelMeshTwo & _mesh; - + const Mesh * _mesh_new; + void SetMesh(const Mesh * mesh_in); + private: const std::vector & _elem_type; @@ -119,15 +120,15 @@ class CurrentQuantity; DenseMatrix _KeM; DenseVector _FeM; uint _el_n_dofs; - std::vector _el_dof_indices; - std::vector _bc_eldofs; //So the element must be aware of the BC of the equation + std::vector _el_dof_indices; // this must become a vect of vect + std::vector _bc_eldofs; // this must become a vect of vect // ======================================================================================== //========== Current Geometric Element: needs the MESH ======================== std::vector _el_conn; /// vector of the global nodes for that element [NNDS]; - std::vector _el_conn_new; /// vector of the global nodes for that element [NNDS]; + std::vector _el_conn_new; uint _vol_iel_DofObj; /// i need to put the element also. - std::vector _xx_nds; /// vector of the node coordinates for that element [_spacedimension*NNDS]; + std::vector _xx_nds; /// vector of the node coordinates for that element [_spacedimension*NNDS]; // this must become a vect of vect std::vector _el_xm; /// element center point [_spacedimension]; const uint _dim; //spatial dimension of the current element (can be different from the mesh dimension!) const uint _mesh_vb; //index for the mesh diff --git a/src/equations/CurrentQuantity.cpp b/src/equations/CurrentQuantity.cpp index e0b36b5c6..384fc5e9b 100644 --- a/src/equations/CurrentQuantity.cpp +++ b/src/equations/CurrentQuantity.cpp @@ -281,7 +281,7 @@ void CurrentQuantity::GetElemDofs() { const uint dofkivar = _eqnptr->_dofmap.GetDofPosIn(Lev_pick_dof,DofObj + ivar*length_nodedof[vect_ord] + off_total); - if (vect_ord < KK ) { _val_dofs[indx] = ( *(_eqnptr->_x_old[Lev_pick_dof]) )(dofkivar); } + if (vect_ord < KK ) { _val_dofs[indx] = ( *( _eqnptr->_LinSolver[Lev_pick_dof]->_EPSC ) )(dofkivar); } } } diff --git a/src/equations/DofMap.cpp b/src/equations/DofMap.cpp index 1911a150d..fac532a9f 100644 --- a/src/equations/DofMap.cpp +++ b/src/equations/DofMap.cpp @@ -43,9 +43,7 @@ void DofMap::initNVars() { } -//CHECK LINEAR MESH WITH QUADRATIC SHAPES - const uint mesh_ord = (int) _mesh.GetRuntimeMap().get("mesh_ord"); - if (mesh_ord == 1 && _nvars[QQ]>0) { + if (MESH_ORDER == 1 && _nvars[QQ]>0) { std::cout << "Can't handle linear mesh with quadratic variables, do a quadratic mesh" << std::endl; abort(); } diff --git a/src/equations/ExplicitSystem.hpp b/src/equations/ExplicitSystem.hpp index c1a18c8d9..ae2ecf78f 100644 --- a/src/equations/ExplicitSystem.hpp +++ b/src/equations/ExplicitSystem.hpp @@ -54,6 +54,9 @@ class ExplicitSystem : public System { /** Init the system PDE structures */ virtual void init(); + + /** @deprecated Init the system PDE structures */ + virtual void init_two(){}; /** * @returns \p "Explicit". Helps in identifying diff --git a/src/equations/ImplicitSystem.hpp b/src/equations/ImplicitSystem.hpp index 3ea56734b..704b2bb2b 100644 --- a/src/equations/ImplicitSystem.hpp +++ b/src/equations/ImplicitSystem.hpp @@ -54,6 +54,9 @@ class ImplicitSystem : public ExplicitSystem { /** Init the system PDE structures */ virtual void init(); + /** @deprecated Init the system PDE structures */ + virtual void init_two() {}; + /** * @returns \p "Implicit". Helps in identifying * the system type in an equation system file. diff --git a/src/equations/LinearImplicitSystem.cpp b/src/equations/LinearImplicitSystem.cpp index 50abd59b1..b3b5e4351 100644 --- a/src/equations/LinearImplicitSystem.cpp +++ b/src/equations/LinearImplicitSystem.cpp @@ -55,7 +55,10 @@ void LinearImplicitSystem::clear() { for (unsigned ig=0; ig<_gridn; ig++) { _LinSolver[ig]->DeletePde(); delete _LinSolver[ig]; - } + if(_PP[ig]) delete _PP[ig]; + if(_RR[ig]) delete _RR[ig]; + } + _NSchurVar_test=0; _numblock_test=0; _numblock_all_test=0; @@ -87,7 +90,13 @@ void LinearImplicitSystem::init() { _LinSolver[i]->InitPde(_SolSystemPdeIndex,_ml_sol->GetSolType(), _ml_sol->GetSolName(),&_solution[i]->_Bdc,_gridr,_gridn,_SparsityPattern); } - + + _PP.resize(_gridn); + _RR.resize(_gridn); + for(unsigned i=0;i<_gridn;i++){ + _PP[i]=NULL; + _RR[i]=NULL; + } for (unsigned ig=1; ig<_gridn; ig++) { BuildProlongatorMatrix(ig); } @@ -100,6 +109,35 @@ void LinearImplicitSystem::init() { AddVariableToBeSolved("All"); } +/// @deprecated +// this function is like init but it doesn't call InitPDE +void LinearImplicitSystem::init_two() { + + _LinSolver.resize(_gridn); + + _LinSolver[0]=LinearEquationSolver::build(0,_msh[0],GMRES_SMOOTHER).release(); + for(unsigned i=1;i<_gridn;i++){ + _LinSolver[i]=LinearEquationSolver::build(i,_msh[i],_SmootherType).release(); + } + +// for (unsigned i=0; i<_gridn; i++) { +// _LinSolver[i]->InitPde(_SolSystemPdeIndex,_ml_sol->GetSolType(), +// _ml_sol->GetSolName(),&_solution[i]->_Bdc,_gridr,_gridn,_SparsityPattern); +// } +// +// for (unsigned ig=1; ig<_gridn; ig++) { +// BuildProlongatorMatrix(ig); +// } + + _NSchurVar_test=0; + _numblock_test=0; + _numblock_all_test=0; + // By default we solved for all the PDE variables + ClearVariablesToBeSolved(); + AddVariableToBeSolved("All"); +} + + void LinearImplicitSystem::AddSystemLevel() { @@ -365,24 +403,24 @@ void LinearImplicitSystem::Restrictor(const unsigned &gridf, const unsigned &gri if (gridf>=_gridr) { //_gridr if (!_LinSolver[gridf-1]->_CC_flag) { _LinSolver[gridf-1]->_CC_flag=1; - _LinSolver[gridf-1]->_CC->matrix_PtAP(*_LinSolver[gridf]->_PP,*_LinSolver[gridf]->_KK,!matrix_reuse); + _LinSolver[gridf-1]->_CC->matrix_PtAP(*_PP[gridf],*_LinSolver[gridf]->_KK,!matrix_reuse); } else{ - _LinSolver[gridf-1]->_CC->matrix_PtAP(*_LinSolver[gridf]->_PP,*_LinSolver[gridf]->_KK,matrix_reuse); + _LinSolver[gridf-1]->_CC->matrix_PtAP(*_PP[gridf],*_LinSolver[gridf]->_KK,matrix_reuse); } _LinSolver[gridf-1u]->_KK->matrix_add(1.,*_LinSolver[gridf-1u]->_CC,"different_nonzero_pattern"); } else { //Projection of the Matrix on the lower level if (non_linear_iteration==0 && ( full_cycle*(gridf==gridn-1u) || !full_cycle )) { - _LinSolver[gridf-1]->_KK->matrix_PtAP(*_LinSolver[gridf]->_PP,*_LinSolver[gridf]->_KK,!matrix_reuse); + _LinSolver[gridf-1]->_KK->matrix_PtAP(*_PP[gridf],*_LinSolver[gridf]->_KK,!matrix_reuse); } else{ - _LinSolver[gridf-1]->_KK->matrix_PtAP(*_LinSolver[gridf]->_PP,*_LinSolver[gridf]->_KK,matrix_reuse); + _LinSolver[gridf-1]->_KK->matrix_PtAP(*_PP[gridf],*_LinSolver[gridf]->_KK,matrix_reuse); } } } - _LinSolver[gridf-1u]->_RESC->matrix_mult_transpose(*_LinSolver[gridf]->_RES, *_LinSolver[gridf]->_PP); + _LinSolver[gridf-1u]->_RESC->matrix_mult_transpose(*_LinSolver[gridf]->_RES, *_PP[gridf]); *_LinSolver[gridf-1u]->_RES += *_LinSolver[gridf-1u]->_RESC; } @@ -390,7 +428,7 @@ void LinearImplicitSystem::Restrictor(const unsigned &gridf, const unsigned &gri // ******************************************************* void LinearImplicitSystem::Prolongator(const unsigned &gridf) { - _LinSolver[gridf]->_EPSC->matrix_mult(*_LinSolver[gridf-1]->_EPS,*_LinSolver[gridf]->_PP); + _LinSolver[gridf]->_EPSC->matrix_mult(*_LinSolver[gridf-1]->_EPS,*_PP[gridf]); _LinSolver[gridf]->UpdateResidual(); _LinSolver[gridf]->SumEpsCToEps(); } @@ -400,10 +438,11 @@ void LinearImplicitSystem::ProlongatorSol(unsigned gridf) { for (unsigned k=0; k<_SolSystemPdeIndex.size(); k++) { - unsigned SolIndex=_SolSystemPdeIndex[k]; - unsigned Typeindex=_ml_sol->GetSolutionType(SolIndex); + unsigned SolIndex = _SolSystemPdeIndex[k]; + unsigned solType = _ml_sol->GetSolutionType(SolIndex); - _solution[gridf]->_Sol[SolIndex]->matrix_mult(*_solution[gridf-1]->_Sol[SolIndex],*_solution[gridf]->_ProjMat[Typeindex]); + _solution[gridf]->_Sol[SolIndex]->matrix_mult(*_solution[gridf-1]->_Sol[SolIndex], + *_msh[gridf]->GetCoarseToFineProjection(solType)); _solution[gridf]->_Sol[SolIndex]->close(); } } @@ -448,7 +487,7 @@ void LinearImplicitSystem::BuildProlongatorMatrix(unsigned gridf) { unsigned iel = mshc->IS_Mts2Gmt_elem[iel_mts]; if(mshc->el->GetRefinedElementIndex(iel)){ //only if the coarse element has been refined short unsigned ielt=mshc->el->GetElementType(iel); - _equation_systems._ml_msh->_finiteElement[ielt][SolType]->GetSparsityPatternSize(*LinSolf,*LinSolc,iel,NNZ_d, NNZ_o,SolIndex,k); + mshc->_finiteElement[ielt][SolType]->GetSparsityPatternSize(*LinSolf,*LinSolc,iel,NNZ_d, NNZ_o,SolIndex,k); } } } @@ -468,8 +507,8 @@ void LinearImplicitSystem::BuildProlongatorMatrix(unsigned gridf) { delete NNZ_d; delete NNZ_o; - LinSolf->_PP = SparseMatrix::build().release(); - LinSolf->_PP->init(nf,nc,nf_loc,nc_loc,nnz_d,nnz_o); + _PP[gridf] = SparseMatrix::build().release(); + _PP[gridf]->init(nf,nc,nf_loc,nc_loc,nnz_d,nnz_o); for (unsigned k=0; k<_SolSystemPdeIndex.size(); k++) { unsigned SolIndex = _SolSystemPdeIndex[k]; @@ -480,12 +519,12 @@ void LinearImplicitSystem::BuildProlongatorMatrix(unsigned gridf) { unsigned iel = mshc->IS_Mts2Gmt_elem[iel_mts]; if(mshc->el->GetRefinedElementIndex(iel)){ //only if the coarse element has been refined short unsigned ielt=mshc->el->GetElementType(iel); - _equation_systems._ml_msh->_finiteElement[ielt][SolType]->BuildProlongation(*LinSolf,*LinSolc,iel,LinSolf->_PP,SolIndex,k); + mshc->_finiteElement[ielt][SolType]->BuildProlongation(*LinSolf,*LinSolc,iel,_PP[gridf],SolIndex,k); } } } } - LinSolf->_PP->close(); + _PP[gridf]->close(); } @@ -602,6 +641,246 @@ void LinearImplicitSystem::SetNumberOfSchurVariables(const unsigned short &NSchu } +// ================================================================= +// std::vector _b; //// LinearEquation (each level) _RESC +// std::vector _res; //// LinearEquation (each level) _RES +// std::vector _x; //// LinearEquation (each level) _EPS +// std::vector _x_old; //// LinearEquation (each level) _EPSC + +//if the residual norm is small enough,exit the cycle, and so also the MGSolve +//this is also the check for the single level solver +//what is the meaning of having multiple cycles for single-grid solver? +//they are all like just a single linear solver loop, where convergence has already been reached, +// and you do another check after the previous one in the linear solver loop +//the big question is: +///@todo why dont you do "res_fine < Eps1" +// instead of "res_fine < Eps1*(1.+ bNorm_fine)" ??? +//because one is for the absolute error and another one is for the relative error +/// This function solves the discrete problem with multigrid solver +void LinearImplicitSystem::MGSolve(double Eps1, // tolerance for the linear solver + int MaxIter, // n iterations + const uint Gamma, // Control V W cycle + const uint Nc_pre, // n pre-smoothing cycles + const uint Nc_coarse, // n coarse cycles + const uint Nc_post // n post-smoothing cycles + ) { + +#ifdef DEFAULT_PRINT_INFO + std::cout << "######### BEGIN MG SOLVE ########" << std::endl; +#endif + double res_fine; + + _LinSolver[GetGridn()-1]->_RESC->close(); + double bNorm_fine = _LinSolver[GetGridn()-1]->_RESC->l2_norm(); + _LinSolver[GetGridn()-1]->_EPSC->close(); + double x_old_fine = _LinSolver[GetGridn()-1]->_EPSC->l2_norm(); + +#ifdef DEFAULT_PRINT_INFO + std::cout << " bNorm_fine l2 " << bNorm_fine << std::endl; + std::cout << " bNorm_fine linfty " << _LinSolver[GetGridn()-1]->_RESC->linfty_norm() << std::endl; + std::cout << " xold_fine l2 " << x_old_fine << std::endl; +#endif + + // FAS Multigrid (Nested) --------- + bool NestedMG=false; + if (NestedMG) { + _LinSolver[0]->_EPS->zero(); + MGStep(0,1.e-20,MaxIter,Gamma,Nc_pre,Nc_coarse,Nc_post); + + //smooth on the coarse level WITH PHYSICAL b ! + //and compute the residual + + for (uint Level = 1; Level < GetGridn(); Level++) { + + _LinSolver[Level]->_EPS->matrix_mult(*_LinSolver[Level-1]->_EPS,*_PP[Level]); //**** project the solution + + res_fine = MGStep(Level,Eps1,MaxIter,Gamma,Nc_pre,Nc_coarse,Nc_post); + + } + } // NestedMG + + // V or W cycle + int cycle = 0; + bool exit_mg = false; + + while (!exit_mg && cycle rest; + + if (Level == 0) { +/// std::cout << "************ REACHED THE BOTTOM *****************"<< std::endl; + +#ifdef DEFAULT_PRINT_CONV + _LinSolver[Level]->_EPS->close(); + double xNorm0=_LinSolver[Level]->_EPS->linfty_norm(); + _LinSolver[Level]->_RESC->close(); + double bNorm0=_LinSolver[Level]->_RESC->linfty_norm(); + _LinSolver[Level]->_KK->close(); + double ANorm0=_LinSolver[Level]->_KK->l1_norm(); + std::cout << "Level " << Level << " ANorm l1 " << ANorm0 << " bNorm linfty " << bNorm0 << " xNormINITIAL linfty " << xNorm0 << std::endl; +#endif + + rest = _LinSolver[Level]->solve(*_LinSolver[Level]->_KK,*_LinSolver[Level]->_KK,*_LinSolver[Level]->_EPS,*_LinSolver[Level]->_RESC,DEFAULT_EPS_LSOLV_C,Nc_coarse); //****** smooth on the coarsest level + +#ifdef DEFAULT_PRINT_CONV + std::cout << " Coarse sol : res-norm: " << rest.second << " n-its: " << rest.first << std::endl; + _LinSolver[Level]->_EPS->close(); + std::cout << " Norm of x after the coarse solution " << _LinSolver[Level]->_EPS->linfty_norm() << std::endl; +#endif + + _LinSolver[Level]->_RES->resid(*_LinSolver[Level]->_RESC,*_LinSolver[Level]->_EPS,*_LinSolver[Level]->_KK); //************ compute the coarse residual + + _LinSolver[Level]->_RES->close(); + std::cout << "COARSE Level " << Level << " res linfty " << _LinSolver[Level]->_RES->linfty_norm() << " res l2 " << _LinSolver[Level]->_RES->l2_norm() << std::endl; + + } + + else { + +/// std::cout << "************ BEGIN ONE PRE-SMOOTHING *****************"<< std::endl; +#ifdef DEFAULT_PRINT_TIME + std::clock_t start_time=std::clock(); +#endif +#ifdef DEFAULT_PRINT_CONV + _LinSolver[Level]->_EPS->close(); + double xNormpre=_LinSolver[Level]->_EPS->linfty_norm(); + _LinSolver[Level]->_RESC->close(); + double bNormpre=_LinSolver[Level]->_RESC->linfty_norm(); + _LinSolver[Level]->_KK->close(); + double ANormpre=_LinSolver[Level]->_KK->l1_norm(); + std::cout << "Level " << Level << " ANorm l1 " << ANormpre << " bNorm linfty " << bNormpre << " xNormINITIAL linfty " << xNormpre << std::endl; +#endif + + rest = _LinSolver[Level]->solve(*_LinSolver[Level]->_KK,*_LinSolver[Level]->_KK,*_LinSolver[Level]->_EPS,*_LinSolver[Level]->_RESC,DEFAULT_EPS_PREPOST, Nc_pre); //****** smooth on the finer level + +#ifdef DEFAULT_PRINT_CONV + std::cout << " Pre Lev: " << Level << ", res-norm: " << rest.second << " n-its: " << rest.first << std::endl; +#endif +#ifdef DEFAULT_PRINT_TIME + std::clock_t end_time=std::clock(); + std::cout << " time ="<< double(end_time- start_time) / CLOCKS_PER_SEC << std::endl; +#endif + + _LinSolver[Level]->_RES->resid(*_LinSolver[Level]->_RESC,*_LinSolver[Level]->_EPS,*_LinSolver[Level]->_KK);//********** compute the residual + +/// std::cout << "************ END ONE PRE-SMOOTHING *****************"<< std::endl; + +/// std::cout << ">>>>>>>> BEGIN ONE DESCENT >>>>>>>>>>"<< std::endl; + + _LinSolver[Level-1]->_RESC->matrix_mult(*_LinSolver[Level]->_RES,*_RR[Level-1]);//****** restrict the residual from the finer grid ( new rhs ) + _LinSolver[Level-1]->_EPS->close(); //initial value of x for the presmoothing iterations + _LinSolver[Level-1]->_EPS->zero(); //initial value of x for the presmoothing iterations + + for (uint g=1; g <= Gamma; g++) + MGStep(Level-1,Eps1,MaxIter,Gamma,Nc_pre,Nc_coarse,Nc_post); //***** call MGStep for another possible descent + +//at this point you have certainly reached the COARSE level + +/// std::cout << ">>>>>>>> BEGIN ONE ASCENT >>>>>>>>"<< std::endl; +#ifdef DEFAULT_PRINT_CONV + _LinSolver[Level-1]->_RES->close(); + std::cout << "BEFORE PROL Level " << Level << " res linfty " << _LinSolver[Level-1]->_RES->linfty_norm() << " res l2 " << _LinSolver[Level-1]->_RES->l2_norm() << std::endl; +#endif + + _LinSolver[Level]->_RES->matrix_mult(*_LinSolver[Level-1]->_EPS,*_PP[Level]);//******** project the dx from the coarser grid +#ifdef DEFAULT_PRINT_CONV + _LinSolver[Level]->_RES->close(); + //here, the _res contains the prolongation of dx, so the new x is x_old + P dx + std::cout << "AFTER PROL Level " << Level << " res linfty " << _LinSolver[Level]->_RES->linfty_norm() << " res l2 " << _LinSolver[Level]->_RES->l2_norm() << std::endl; +#endif + _LinSolver[Level]->_EPS->add(*_LinSolver[Level]->_RES);// adding the coarser residual to x + //initial value of x for the post-smoothing iterations + //_b is the same as before +/// std::cout << "************ BEGIN ONE POST-SMOOTHING *****************"<< std::endl; + // postsmooting (Nc_post) +#ifdef DEFAULT_PRINT_TIME + start_time=std::clock(); +#endif +#ifdef DEFAULT_PRINT_CONV + _LinSolver[Level]->_EPS->close(); + double xNormpost=_LinSolver[Level]->_EPS->linfty_norm(); + _LinSolver[Level]->_RESC->close(); + double bNormpost=_LinSolver[Level]->_RESC->linfty_norm(); + _LinSolver[Level]->_KK->close(); + double ANormpost=_LinSolver[Level]->_KK->l1_norm(); + std::cout << "Level " << Level << " ANorm l1 " << ANormpost << " bNorm linfty " << bNormpost << " xNormINITIAL linfty " << xNormpost << std::endl; +#endif + + rest = _LinSolver[Level]->solve(*_LinSolver[Level]->_KK,*_LinSolver[Level]->_KK,*_LinSolver[Level]->_EPS,*_LinSolver[Level]->_RESC,DEFAULT_EPS_PREPOST,Nc_post); //***** smooth on the coarser level + +#ifdef DEFAULT_PRINT_CONV + std::cout<<" Post Lev: " << Level << ", res-norm: " << rest.second << " n-its: " << rest.first << std::endl; +#endif +#ifdef DEFAULT_PRINT_TIME + end_time=std::clock(); + std::cout<< " time ="<< double(end_time- start_time) / CLOCKS_PER_SEC << std::endl; +#endif + + _LinSolver[Level]->_RES->resid(*_LinSolver[Level]->_RESC,*_LinSolver[Level]->_EPS,*_LinSolver[Level]->_KK); //******* compute the residual + +/// std::cout << "************ END ONE POST-SMOOTHING *****************"<< std::endl; + + } + + _LinSolver[Level]->_RES->close(); + + return rest.second; //it returns the residual norm of whatever level you are in + // if this is the l2_norm then also the nonlinear solver is computed in the l2 norm + //WHAT NORM is THIS?!? l2, but PRECONDITIONED!!! + +} + + } //end namespace femus diff --git a/src/equations/LinearImplicitSystem.hpp b/src/equations/LinearImplicitSystem.hpp index 0b10f4d6d..af5ea8fd5 100644 --- a/src/equations/LinearImplicitSystem.hpp +++ b/src/equations/LinearImplicitSystem.hpp @@ -24,7 +24,7 @@ #include "MgTypeEnum.hpp" #include "DirichletBCTypeEnum.hpp" #include "MgSmootherEnum.hpp" - +#include "FemusDefault.hpp" namespace femus { @@ -55,6 +55,16 @@ class LinearImplicitSystem : public ImplicitSystem { /** Init the system PDE structures */ virtual void init(); + /** @deprecated Init the system PDE structures */ + virtual void init_two(); + + /** @deprecated Multigrid routine */ + void MGSolve(double Eps,int MaxIter, const uint Gamma=DEFAULT_MG_GAMMA, const uint Nc_pre=DEFAULT_NC_PRE,const uint Nc_coarse=DEFAULT_NC_COARSE,const uint Nc_post=DEFAULT_NC_POST); + + /** @deprecated Multigrid step routine */ + double MGStep(int Level,double Eps1,int MaxIter, const uint Gamma, const uint Nc_pre,const uint Nc_coarse,const uint Nc_post); + + /** Add a system level */ void AddSystemLevel(); /** @@ -71,8 +81,8 @@ class LinearImplicitSystem : public ImplicitSystem { * details of interfacing with various linear algebra packages * like PETSc or LASPACK. Up to now also for the nonlinear case we use linear_solvers, in future we will add the nonlinear solver */ - vector _LinSolver; - + vector < LinearEquationSolver*> _LinSolver; + /** Set the max number of linear iterationsfor solving Ax=b */ void SetMaxNumberOfLinearIterations(unsigned int max_lin_it) { _n_max_linear_iterations = max_lin_it; @@ -160,6 +170,7 @@ class LinearImplicitSystem : public ImplicitSystem { protected: + vector < SparseMatrix* > _PP, _RR; /** Create the Prolongator matrix for the Multigrid solver */ void Prolongator(const unsigned &gridf); diff --git a/src/equations/MonolithicFSINonLinearImplicitSystem.cpp b/src/equations/MonolithicFSINonLinearImplicitSystem.cpp index 8f0cbce2d..21ac2ff9d 100644 --- a/src/equations/MonolithicFSINonLinearImplicitSystem.cpp +++ b/src/equations/MonolithicFSINonLinearImplicitSystem.cpp @@ -65,24 +65,24 @@ void MonolithicFSINonLinearImplicitSystem::Restrictor(const unsigned &gridf, con if (gridf>=_gridr) { //_gridr if (!LinSolc->_CC_flag) { LinSolc->_CC_flag=1; - LinSolc->_CC->matrix_ABC(*LinSolf->_RR,*LinSolf->_KK,*LinSolf->_PP,!matrix_reuse); + LinSolc->_CC->matrix_ABC(*_RR[gridf],*LinSolf->_KK,*_PP[gridf],!matrix_reuse); } else{ - LinSolc->_CC->matrix_ABC(*LinSolf->_RR,*LinSolf->_KK,*LinSolf->_PP,matrix_reuse); + LinSolc->_CC->matrix_ABC(*_RR[gridf],*LinSolf->_KK,*_PP[gridf],matrix_reuse); } LinSolc->_KK->matrix_add(1.,*LinSolc->_CC,"different_nonzero_pattern"); } else { //Projection of the Matrix on the lower level if (non_linear_iteration==0 && ( full_cycle*(gridf==gridn-1u) || !full_cycle )) { - LinSolc->_KK->matrix_ABC(*LinSolf->_RR,*LinSolf->_KK,*LinSolf->_PP,!matrix_reuse); + LinSolc->_KK->matrix_ABC(*_RR[gridf],*LinSolf->_KK,*_PP[gridf],!matrix_reuse); } else{ - LinSolc->_KK->matrix_ABC(*LinSolf->_RR,*LinSolf->_KK,*LinSolf->_PP,matrix_reuse); + LinSolc->_KK->matrix_ABC(*_RR[gridf],*LinSolf->_KK,*_PP[gridf],matrix_reuse); } } } - LinSolc->_RESC->matrix_mult(*LinSolf->_RES, *LinSolf->_RR); + LinSolc->_RESC->matrix_mult(*LinSolf->_RES, *_RR[gridf]); *LinSolc->_RES += *LinSolc->_RESC; } @@ -125,7 +125,7 @@ void MonolithicFSINonLinearImplicitSystem::BuildProlongatorMatrix(unsigned gridf unsigned iel = mshc->IS_Mts2Gmt_elem[iel_mts]; if(mshc->el->GetRefinedElementIndex(iel)){ //only if the coarse element has been refined short unsigned ielt=mshc->el->GetElementType(iel); - _equation_systems._ml_msh->_finiteElement[ielt][SolType]->GetSparsityPatternSize(*LinSolf,*LinSolc,iel,NNZ_d, NNZ_o,SolIndex,k); + mshc->_finiteElement[ielt][SolType]->GetSparsityPatternSize(*LinSolf,*LinSolc,iel,NNZ_d, NNZ_o,SolIndex,k); } } } @@ -145,8 +145,8 @@ void MonolithicFSINonLinearImplicitSystem::BuildProlongatorMatrix(unsigned gridf delete NNZ_d; delete NNZ_o; - LinSolf->_PP = SparseMatrix::build().release(); - LinSolf->_PP->init(nf,nc,nf_loc,nc_loc,nnz_d, nnz_o); + _PP[gridf] = SparseMatrix::build().release(); + _PP[gridf]->init(nf,nc,nf_loc,nc_loc,nnz_d, nnz_o); SparseMatrix *RRt; RRt = SparseMatrix::build().release(); @@ -154,11 +154,15 @@ void MonolithicFSINonLinearImplicitSystem::BuildProlongatorMatrix(unsigned gridf for (unsigned k=0; k<_SolSystemPdeIndex.size(); k++) { unsigned SolIndex=_SolSystemPdeIndex[k]; - unsigned SolType = _ml_sol->GetSolutionType(SolIndex); + unsigned solPairIndex=_ml_sol->GetSolutionPairIndex(k); + unsigned SolType = _ml_sol->GetSolutionType(SolIndex); + unsigned solPairPdeIndex = GetSolPdeIndex( _ml_sol->GetSolutionName(solPairIndex) ); + + //bool TestDisp=0; //if(_ml_sol->TestIfSolutionIsDisplacemenet(SolIndex) ) TestDisp=1; - bool TestDisp=1; - if(_ml_sol->TestIfSolutionIsPressure(SolIndex) ) TestDisp=0; + bool testIfPressure=0; + if(_ml_sol->TestIfSolutionIsPressure(SolIndex) ) testIfPressure=1; // loop on the coarse grid @@ -169,23 +173,23 @@ void MonolithicFSINonLinearImplicitSystem::BuildProlongatorMatrix(unsigned gridf if(mshc->el->GetRefinedElementIndex(iel)){ //only if the coarse element has been refined short unsigned ielt=mshc->el->GetElementType(iel); - if(TestDisp){ - _equation_systems._ml_msh->_finiteElement[ielt][SolType]->BuildRestrictionTranspose(*LinSolf,*LinSolc,iel,RRt,SolIndex,k,TestDisp); + if(!testIfPressure){ + mshc->_finiteElement[ielt][SolType]->BuildRestrictionTranspose(*LinSolf,*LinSolc,iel,RRt,SolIndex,k,solPairIndex,solPairPdeIndex); } else{ - _equation_systems._ml_msh->_finiteElement[ielt][SolType]->BuildProlongation(*LinSolf,*LinSolc,iel, RRt,SolIndex,k); + mshc->_finiteElement[ielt][SolType]->BuildProlongation(*LinSolf,*LinSolc,iel, RRt,SolIndex,k); } - _equation_systems._ml_msh->_finiteElement[ielt][SolType]->BuildProlongation(*LinSolf,*LinSolc,iel, LinSolf->_PP,SolIndex,k); + mshc->_finiteElement[ielt][SolType]->BuildProlongation(*LinSolf,*LinSolc,iel, _PP[gridf],SolIndex,k); } } } } - LinSolf->_PP->close(); + _PP[gridf]->close(); RRt->close(); - LinSolf->_RR = SparseMatrix::build().release(); - RRt->get_transpose( *LinSolf->_RR); + _RR[gridf] = SparseMatrix::build().release(); + RRt->get_transpose( *_RR[gridf]); delete RRt; } diff --git a/src/equations/System.hpp b/src/equations/System.hpp index 10d41664f..97dd36513 100644 --- a/src/equations/System.hpp +++ b/src/equations/System.hpp @@ -82,6 +82,9 @@ class System { /** Init the system PDE structures */ virtual void init(); + /** @deprecated Init the system PDE structures */ + virtual void init_two(){}; + /** Get the index of the Solution "solname" for this system */ unsigned GetSolPdeIndex(const char solname[]); diff --git a/src/equations/SystemTwo.cpp b/src/equations/SystemTwo.cpp index f8696adbe..2e452fe47 100644 --- a/src/equations/SystemTwo.cpp +++ b/src/equations/SystemTwo.cpp @@ -57,51 +57,7 @@ SystemTwo::SystemTwo(MultiLevelProblem& e_map_in, const std::string & eqname_in, LinearImplicitSystem(e_map_in,eqname_in,number,smoother_type) { } -// =================================================== -/// This function is the SystemTwo destructor. -//the important thing is that these destructions occur AFTER -//the destructions of the levels inside -//these things were allocated and filled in various init functions -//either in the Base or in the DA -//here, we destroy them in the place where they belong -// pay attention to the fact that a lot of these delete are ok only if the respective function -// where the new is is called! -SystemTwo::~SystemTwo() { - - //========= MGOps =========================== - for (uint Level =0; Level< GetGridn(); Level++) { - delete _A[Level]; - if (Level < GetGridn() - 1) delete _Rst[Level]; - if (Level > 0) delete _Prl[Level]; - } - - _A.clear(); - _Rst.clear(); - _Prl.clear(); - - //======== Vectors ========================== - for (uint Level =0; Levelinit(_dofmap._Dim[Level],m_l,false,AUTOMATIC); - _res[Level] = NumericVector::build().release(); - _res[Level]->init(_dofmap._Dim[Level],m_l,false,AUTOMATIC); - _x[Level] = NumericVector::build().release(); - _x[Level]->init(_dofmap._Dim[Level],m_l,false,AUTOMATIC); - _x_old[Level] = NumericVector::build().release(); - _x_old[Level]->init(_dofmap._Dim[Level],false, SERIAL); - _x_oold[Level] = NumericVector::build().release(); - _x_oold[Level]->init(_dofmap._Dim[Level],false, SERIAL); - _x_tmp[Level] = NumericVector::build().release(); - _x_tmp[Level]->init(_dofmap._Dim[Level],false, SERIAL); + _LinSolver[Level]->_RESC = NumericVector::build().release(); + _LinSolver[Level]->_RESC->init(_dofmap._Dim[Level],m_l,false,AUTOMATIC); + _LinSolver[Level]->_RES = NumericVector::build().release(); + _LinSolver[Level]->_RES->init(_dofmap._Dim[Level],m_l,false,AUTOMATIC); + _LinSolver[Level]->_EPS = NumericVector::build().release(); + _LinSolver[Level]->_EPS->init(_dofmap._Dim[Level],m_l,false,AUTOMATIC); + _LinSolver[Level]->_EPSC = NumericVector::build().release(); + _LinSolver[Level]->_EPSC->init(_dofmap._Dim[Level],false, SERIAL); } //end level loop + return; } @@ -219,10 +165,10 @@ void SystemTwo::initVectors() { //scalar variables and to each of them give a NUMBER which represents the ORDER. // Of course it can only be up to the user to put the right function at the right place! -//TODO AAA: oh this is very interesting... the initial conditions are set IN PARALLEL, +//TTOODDOO AAA: oh this is very interesting... the initial conditions are set IN PARALLEL, // only by the current processor! -//TODO ok the point is this: we are looping over elements, and then over nodes in the element, +//TTOODDOO ok the point is this: we are looping over elements, and then over nodes in the element, //so when we pick the element values we pick them more than once actually... //but that's ok, we do like this so far, otherwise you would need two separate routines, // one for the NODE dofs and one for the ELEM dofs, and if you want to switch a quantity @@ -256,12 +202,12 @@ void SystemTwo::initVectors() { //Probably if you wanted to do Printing with PARALLEL file system // then you would need to give priority to processors first... -//TODO: so far we have a node_dof that is explored based on the FINEST LEVEL for the NODES, +//TTOODDOO: so far we have a node_dof that is explored based on the FINEST LEVEL for the NODES, // and based on EACH LEVEL for the elements. //So, if we want to make it more general, we just put the offsets to be dependent on LEVEL, // and for the nodes they are simply NOT DEPENDENT! -//TODO this function's goal is basically just to fill +//TTOODDOO this function's goal is basically just to fill // the x vector in parallel, and then put it into x_old. //Of course it does this in a GEOMETRIC WAY. // xold is a vector of DOFS, so what we need are the @@ -283,7 +229,9 @@ void SystemTwo::Initialize() { for (uint Level = 0; Level< GetGridn(); Level++) { + Mesh *mymsh = GetMLProb()._ml_msh->GetLevel(Level); CurrentElem currelem(Level,VV,this,GetMLProb().GetMeshTwo(),GetMLProb().GetElemType()); + currelem.SetMesh(mymsh); const uint el_dof_objs = NVE[ GetMLProb().GetMeshTwo()._geomelem_flag[currelem.GetDim()-1] ][BIQUADR_FE]; uint iel_b = GetMLProb().GetMeshTwo()._off_el[VV][ GetMLProb().GetMeshTwo()._iproc*GetGridn() + Level ]; @@ -312,7 +260,7 @@ void SystemTwo::Initialize() { _UnknownQuantitiesVector[q]->initialize_xyz(&xp[0],value); const int dof_pos_lev = _dofmap.GetDofQuantityComponent(Level,_UnknownQuantitiesVector[q],ivar,fine_node); - _x[Level]->set( dof_pos_lev, value[ivar] ); + _LinSolver[Level]->_EPS->set( dof_pos_lev, value[ivar] ); } //dof objects } @@ -333,7 +281,7 @@ void SystemTwo::Initialize() { const int elem_lev = iel + sum_elems_prev_sd_at_lev; const int dof_pos_lev = _dofmap.GetDofQuantityComponent(Level,_UnknownQuantitiesVector[q],ivar,elem_lev); - _x[Level]->set( dof_pos_lev, value[ivar] ); + _LinSolver[Level]->_EPS->set( dof_pos_lev, value[ivar] ); } //k } //ivar @@ -345,8 +293,8 @@ void SystemTwo::Initialize() { } // end of element loop - _x[Level]->localize(*_x_old[Level]); - _x_old[Level]->close(); + _LinSolver[Level]->_EPS->localize(*_LinSolver[Level]->_EPSC); + _LinSolver[Level]->_EPSC->close(); } //end Level @@ -359,1180 +307,7 @@ void SystemTwo::Initialize() { } -// ================================================================= -//if the residual norm is small enough,exit the cycle, and so also the MGSolve -//this is also the check for the single level solver -//what is the meaning of having multiple cycles for single-grid solver? -//they are all like just a single linear solver loop, where convergence has already been reached, -// and you do another check after the previous one in the linear solver loop -//the big question is: -//TODO why dont you do "res_fine < Eps1" -// instead of "res_fine < Eps1*(1.+ bNorm_fine)" ??? -//because one is for the absolute error and another one is for the relative error -/// This function solves the discrete problem with multigrid solver -void SystemTwo::MGSolve(double Eps1, // tolerance for the linear solver - int MaxIter, // n iterations - const uint Gamma, // Control V W cycle - const uint Nc_pre, // n pre-smoothing cycles - const uint Nc_coarse, // n coarse cycles - const uint Nc_post // n post-smoothing cycles - ) { - -#ifdef DEFAULT_PRINT_INFO - std::cout << "######### BEGIN MG SOLVE ########" << std::endl; -#endif - double res_fine; - - _b[GetGridn()-1]->close(); - double bNorm_fine = _b[GetGridn()-1]->l2_norm(); - _x_old[GetGridn()-1]->close(); - double x_old_fine = _x_old[GetGridn()-1]->l2_norm(); - -#ifdef DEFAULT_PRINT_INFO - std::cout << " bNorm_fine l2 " << bNorm_fine << std::endl; - std::cout << " bNorm_fine linfty " << _b[GetGridn()-1]->linfty_norm() << std::endl; - std::cout << " xold_fine l2 " << x_old_fine << std::endl; -#endif - - // FAS Multigrid (Nested) --------- - bool NestedMG=false; - if (NestedMG) { - _x[0]->zero(); - MGStep(0,1.e-20,MaxIter,Gamma,Nc_pre,Nc_coarse,Nc_post); - - //smooth on the coarse level WITH PHYSICAL b ! - //and compute the residual - - for (uint Level = 1; Level < GetGridn(); Level++) { - - _x[Level]->matrix_mult(*_x[Level-1],*_Prl[Level]); //**** project the solution - - res_fine = MGStep(Level,Eps1,MaxIter,Gamma,Nc_pre,Nc_coarse,Nc_post); - - } - } // NestedMG - - // V or W cycle - int cycle = 0; - bool exit_mg = false; - - while (!exit_mg && cycle rest; - - if (Level == 0) { -/// std::cout << "************ REACHED THE BOTTOM *****************"<< std::endl; - -#ifdef DEFAULT_PRINT_CONV - _x[Level]->close(); - double xNorm0=_x[Level]->linfty_norm(); - _b[Level]->close(); - double bNorm0=_b[Level]->linfty_norm(); - _A[Level]->close(); - double ANorm0=_A[Level]->l1_norm(); - std::cout << "Level " << Level << " ANorm l1 " << ANorm0 << " bNorm linfty " << bNorm0 << " xNormINITIAL linfty " << xNorm0 << std::endl; -#endif - - rest = _LinSolver[Level]->solve(*_A[Level],*_A[Level],*_x[Level],*_b[Level],DEFAULT_EPS_LSOLV_C,Nc_coarse); //****** smooth on the coarsest level - -#ifdef DEFAULT_PRINT_CONV - std::cout << " Coarse sol : res-norm: " << rest.second << " n-its: " << rest.first << std::endl; - _x[Level]->close(); - std::cout << " Norm of x after the coarse solution " << _x[Level]->linfty_norm() << std::endl; -#endif - - _res[Level]->resid(*_b[Level],*_x[Level],*_A[Level]); //************ compute the coarse residual - - _res[Level]->close(); - std::cout << "COARSE Level " << Level << " res linfty " << _res[Level]->linfty_norm() << " res l2 " << _res[Level]->l2_norm() << std::endl; - - } - - else { - -/// std::cout << "************ BEGIN ONE PRE-SMOOTHING *****************"<< std::endl; -#ifdef DEFAULT_PRINT_TIME - std::clock_t start_time=std::clock(); -#endif -#ifdef DEFAULT_PRINT_CONV - _x[Level]->close(); - double xNormpre=_x[Level]->linfty_norm(); - _b[Level]->close(); - double bNormpre=_b[Level]->linfty_norm(); - _A[Level]->close(); - double ANormpre=_A[Level]->l1_norm(); - std::cout << "Level " << Level << " ANorm l1 " << ANormpre << " bNorm linfty " << bNormpre << " xNormINITIAL linfty " << xNormpre << std::endl; -#endif - - rest = _LinSolver[Level]->solve(*_A[Level],*_A[Level],*_x[Level],*_b[Level],DEFAULT_EPS_PREPOST, Nc_pre); //****** smooth on the finer level - -#ifdef DEFAULT_PRINT_CONV - std::cout << " Pre Lev: " << Level << ", res-norm: " << rest.second << " n-its: " << rest.first << std::endl; -#endif -#ifdef DEFAULT_PRINT_TIME - std::clock_t end_time=std::clock(); - std::cout << " time ="<< double(end_time- start_time) / CLOCKS_PER_SEC << std::endl; -#endif - - _res[Level]->resid(*_b[Level],*_x[Level],*_A[Level]);//********** compute the residual - -/// std::cout << "************ END ONE PRE-SMOOTHING *****************"<< std::endl; - -/// std::cout << ">>>>>>>> BEGIN ONE DESCENT >>>>>>>>>>"<< std::endl; - - _b[Level-1]->matrix_mult(*_res[Level],*_Rst[Level-1]);//****** restrict the residual from the finer grid ( new rhs ) - _x[Level-1]->close(); //initial value of x for the presmoothing iterations - _x[Level-1]->zero(); //initial value of x for the presmoothing iterations - - for (uint g=1; g <= Gamma; g++) - MGStep(Level-1,Eps1,MaxIter,Gamma,Nc_pre,Nc_coarse,Nc_post); //***** call MGStep for another possible descent - -//at this point you have certainly reached the COARSE level - -/// std::cout << ">>>>>>>> BEGIN ONE ASCENT >>>>>>>>"<< std::endl; -#ifdef DEFAULT_PRINT_CONV - _res[Level-1]->close(); - std::cout << "BEFORE PROL Level " << Level << " res linfty " << _res[Level-1]->linfty_norm() << " res l2 " << _res[Level-1]->l2_norm() << std::endl; -#endif - - _res[Level]->matrix_mult(*_x[Level-1],*_Prl[Level]);//******** project the dx from the coarser grid -#ifdef DEFAULT_PRINT_CONV - _res[Level]->close(); - //here, the _res contains the prolongation of dx, so the new x is x_old + P dx - std::cout << "AFTER PROL Level " << Level << " res linfty " << _res[Level]->linfty_norm() << " res l2 " << _res[Level]->l2_norm() << std::endl; -#endif - _x[Level]->add(*_res[Level]);// adding the coarser residual to x - //initial value of x for the post-smoothing iterations - //_b is the same as before -/// std::cout << "************ BEGIN ONE POST-SMOOTHING *****************"<< std::endl; - // postsmooting (Nc_post) -#ifdef DEFAULT_PRINT_TIME - start_time=std::clock(); -#endif -#ifdef DEFAULT_PRINT_CONV - _x[Level]->close(); - double xNormpost=_x[Level]->linfty_norm(); - _b[Level]->close(); - double bNormpost=_b[Level]->linfty_norm(); - _A[Level]->close(); - double ANormpost=_A[Level]->l1_norm(); - std::cout << "Level " << Level << " ANorm l1 " << ANormpost << " bNorm linfty " << bNormpost << " xNormINITIAL linfty " << xNormpost << std::endl; -#endif - - rest = _LinSolver[Level]->solve(*_A[Level],*_A[Level],*_x[Level],*_b[Level],DEFAULT_EPS_PREPOST,Nc_post); //***** smooth on the coarser level - -#ifdef DEFAULT_PRINT_CONV - std::cout<<" Post Lev: " << Level << ", res-norm: " << rest.second << " n-its: " << rest.first << std::endl; -#endif -#ifdef DEFAULT_PRINT_TIME - end_time=std::clock(); - std::cout<< " time ="<< double(end_time- start_time) / CLOCKS_PER_SEC << std::endl; -#endif - - _res[Level]->resid(*_b[Level],*_x[Level],*_A[Level]); //******* compute the residual - -/// std::cout << "************ END ONE POST-SMOOTHING *****************"<< std::endl; - - } - - _res[Level]->close(); - - return rest.second; //it returns the residual norm of whatever level you are in - //TODO if this is the l2_norm then also the nonlinear solver is computed in the l2 norm - //WHAT NORM is THIS?!? l2, but PRECONDITIONED!!! - -} - -// ========================================= -void SystemTwo::ReadMGOps(const std::string output_path) { - - std::string f_matrix = DEFAULT_F_MATRIX; - std::string f_rest = DEFAULT_F_REST; - std::string f_prol = DEFAULT_F_PROL; - std::string ext_h5 = DEFAULT_EXT_H5; - - std::ostringstream filename; - std::string filename_base; - filename_base = output_path + "/"; - - filename.str(""); filename << filename_base << f_rest << ext_h5; - ReadRest(filename.str()); - - filename.str(""); filename << filename_base << f_matrix << ext_h5; - ReadMatrix(filename.str()); - - filename.str(""); filename << filename_base << f_prol << ext_h5; - ReadProl(filename.str()); - - return; -} - - - -//============================= -//This function depends on _iproc -//remember that a new does not vanish when inside a for loop, -//because the variable was declared outside -// it is NOT like a DECLARATION INSIDE - -//The point is that now we must be ready to READ the matrix, -//also the part with CONSTANT ELEMENTS. -//so we have to figure out how to put all the things together. -//basically we need to remember that we have a bunch of -// quantities that may be QQ, LL, KK, -// so eventually we'll have a certain number of QQ, LL and KK -//now, we simply have to decide HOW to ADD THEM in the MATRIX. -// so far, I think we can decide to put -//FIRST all the QQ, then LL, then KK. - -// The DofMap was already initialized much earlier than now. -// As a matter of fact, it was needed for setting the BC flags -// It would be nice not to have a lot of places where _Dim is recomputed... - -// initDofDim -// initDof -// initVectors - -//The GRAPH, or SPARSITY PATTERN, with PETSC functions can be filled JUST WITH ZEROS; -//but with LASPACK you need do put the DOF VALUES INSIDE. - -// so, I got an error that seems to tell me that I basically didn't fill the graph -//correctly. It seems like one processor fills it and the other ones do not, -//half of the lines seem to be unfilled. - -//TODO the std::cerr is not redirected to file, think of redirecting also it to file. -// The idea is that every output to terminal must be redirected to file. -// so printf must not be used - -// Every processor will call this function - -//Now, the dimension of "graph" is global, -// so it is the dimension of the whole - -//TODO: idea about SYNCHRONIZING OUTPUTS. -//I would really like all the outputs OF ALL THE LIBRARIES (HFD5, PETSC, MPI, LIBMESH) involved in FEMuS -//to be REDIRECTED to run_log, altogether. -//What is the best way to make it possible? -//I guess from shell, in principle. The point is how to generate the string for the time for the folder! -// I should use bash functions, make an environment variable, and let all the processes read that environment variable. -// And also, i would like to be able to choose whether to DUPLICATE them, -// so both to file and to std output, or only to file, or the other cases. - -//I need to have the TIME STRING. Bash has the date() function, I want to have it my way -//OK, THAT'S IT: date +%Y_%m_%d-%H_%M_%S - - - //TODO what is this mlinit used for?!? - // it is used to determine with WHAT DOF NUMBER the CURRENT PROCESSOR _iproc BEGINS. - // NOTICE THAT THE _NODE_DOF MAP IS FILLED COMPLETELY BY ALL PROCESSORS, - // BUT HERE IT IS READ IN PARALLEL BY EACH SEPARATE PROCESSOR !!! - //THEREFORE EACH PROCESSOR WILL START WITH ITS OWN INITIAL_DOF AND FINISH WITH ITS OWN FINAL_DOF. - //The difference between NODES and ELEMENTS is that for nodes - // we keep the offset as the FINEST NODES, because somehow - //we have to keep the correspondence with the NODES OF THE MESH, - //especially when we have to PRINT ON THE MESH - //as a matter of fact, we have to bring everything to the FINE MESH - //so we can view what happens on the FINE MESH - //every processor will fill QUADRATIC, LINEAR and CONSTANT DOFS - //being that these dofs belong to a given processor, they will be CONTIGUOUS in the matrix - // So you'll have - - // QQ LL KK || QQ LL KK || QQ LL KK - //< proc0 >||< proc1 >||< proc2 > - - // Now, consider the level to be FROZEN, we concentrate on the SUBDOMAINS - // Every processor will begin filling the rows at some point. - // Every processor has a range of rows, which is mrow_lev_proc_t - // Within this range you'll have to put QQ, LL and KK dofs - //so within this range you'll have a number of dofs for every fe given by mrow_lev_proc[r], - // of course each of them being multiplied by the number of variables of that type - // Now, you have to compare how you EXPLORE the NODE_DOF MAP and the MATRIX ROWS - //the node_dof map is basically separated into OFFSETS of GEOMETRICAL ENTITIES, - //so these ranges are BASED ON THE MESH GEOMETRICAL ENTITIES. - // every GEOMETRICAL ENTITY (NODE or ELEMENT) can have ONE OR MORE ASSOCIATED DOFS. - //NODES CAN HAVE QUADRATIC DOFS or LINEAR DOFS associated - //ELEMENTS CAN HAVE CONSTANT DOFS associated. - //so, the node dof is constructed by picking - // FIRST NODE QUADRATIC DOFS, for all the quadratic unknowns of the system - // THEN NODE LINEAR DOFS, for all the linear unknowns of the system - // THEN ELEMENT CONSTANT DOFS, for all the constant unknowns of the system - // so "QUADRATIC NODES" can be defined as "NODES to which QUADRATIC VARIABLES are associated", - // "LINEAR NODES" means "NODES to which LINEAR variables are associated" - // ELEMENTS are "GEOMETRICAL ENTITIES to which CONSTANT variables are associated" - // So the node dof is divided by - // "GEOMETRICAL ENTITIES for QUADRATIC DOFS" = "QUADRATIC NODES", the length of which must be multiplied by the "NUMBER OF QUADRATIC DOF VARIABLES" - // "GEOMETRICAL ENTITIES for LINEAR DOFS" = "LINEAR NODES", the length of which must be multiplied by the "NUMBER OF LINEAR DOF VARIABLES" - // "GEOMETRICAL ENTITIES for CONSTANT DOFS" = "ELEMENTS" the length of which must be multiplied by the "NUMBER OF CONSTANT DOF VARIABLES" - //This of course assumes that every GEOMETRICAL ENTITY has the SAME NUMBER of ASSOCIATED DOFS for every FE type. - //So you may say that the node_dof is ordered by GEOMETRICAL ENTITIES first, and WITHIN EACH GEOMETRICAL ENTITY you find ALL THE VARIABLES of THAT FE TYPE. - // This is because actually we have a ONE-TO-ONE CORRESPONDENCE between GEOMETRICAL ENTITY and ASSOCIATED DOF. - // In a sense, we start with a given DOF family, and, going backwards, we ask ourselves "WHAT IS THE SET OF GEOMETRICAL ENTITIES NATURALLY ASSOCIATED to THIS DOF FE Family?" - //For instance, we might have QUAD8 and QUAD9, and associate BOTH OF THEM to a "QUAD9 NODES".In that case we would have EMPTY points, - // and it is actually the same that happens when we have the LINEAR DOF FAMILY and we decide to associate the "QUADRATIC MESH NODES" to it for various reasons: multigrid, parallel computing, etc...) - //So our current situation is: - // QUADRATIC FE DOFS ---> QUADRATIC MESH NODES (at the FINE level) - // LINEAR FE DOFS ---> QUADRATIC MESH NODES (at the FINE level) - // CONSTANT FE DOFS ---> MESH ELEMENTS (at the CURRENT level) - //So, we see that for various reasons we may actually have EMPTY SPACES for two reasons: - // 1) BECAUSE we are at some level which is NOT THE FINE - // 2) even at the FINE Level, we have LINEAR FINE DOFS built on top of QUADRATIC FINE NODES - - //so, _nvars[QQ] is the number of QUADRATIC FE variables - - //NOW, THE POINT IS THIS: FOR EVERY SUBDOMAIN, Do we want to have ALL DOFS CONTIGUOUS or NOT? - //Yes, of course we want, so in the same subdomain we would have QUADRATIC DOFS, THEN LINEAR DOFS, THEN CONSTANT DOFS. - //Otherwise, we would have that dofs of the SAME SUBDOMAIN are DISJOINT. - //Keeping all the dofs of the same subdomain CONTIGUOUS, the equations do not change, they will be the same, - // but in this way we will have AS FEW OFF-PROCESSOR COLUMNS as POSSIBLE! - // So, we do need to BUILD the NODE-DOF MAP APPROPRIATELY for the PARALLEL CASE! - //Of course, in a SERIAL ENVIRONMENT everything works fine - -//======================= -//The dimension of the Graph is the total number of rows -// This Graph is the TOTAL GRAPH for ALL THE MATRIX -//The Graph is basically a std::VECTOR of std::VECTORS, -// therefore you can use the resize() function both on graph and on graph[]. -//Also, by the way, with std::vectors you have the overloading of the operator[] -//===================== - -// Now, the point is: What is mlinit[]? -// Now, based on the mesh Node and Element numbering, we built the node_dof map. -//Now we have to Read the ONE-VARIABLE-MATRICES for EVERY LEVEL, -//and USE THEM to BUILD THE WHOLE MATRIX WITH ALL THE VARIABLES and SO ON. -//Now, we already know how the dof map is. So we gave a number to every dof. -// So after doing the NODE ORDERING and ELEMENT ORDERING (VV and BB) in the GENCASE, -// now it is time to use those orderings consequently and have the -//DOF ORDERING. -//The node map was built in such a way that ALL the DOFS associated to DofObjects (Elems or Nodes) -//of a given subdomain be CONTIGUOUS in the DOF ROW INDEXING. -//Now, given this DOF ORDERING, every PROCESSOR WILL TAKE CARE of ITS OWN DOFS, -// which are contiguous by construction of the node_dof map; -// therefore every processor will pick that block of contiguous row numbers -// and to each of them it will associate the corresponding LENGTH and OFFLENGTH - -// Notice how GRAPH has GLOBAL dimension, but SINCE THIS READ MATRIX is PARALLEL, -//Then each processor will fill only PART OF IT. So, actually it makes no sense to make graph be GLOBAL -// and then have each processor only fill one part of it. - -//ReadMatrix NEEDS the NODE_DOF to be filled BEFORE - //Now, we have to understand these steps: - //1) How we GENERATE the SINGLE DOF VARIABLE sparsity pattern in Gencase; - //2) How we BUILD the NODE_DOF MAP in PARALLEL based on these SINGLE VARIABLE SPARSITY PATTERNS; - //3) How we READ the MATRIX SPARSITY PATTERNS and COMBINE THEM WITH the NODE_DOF. - - //Basically, you have to COMBINE the "DOFS" (Matrix.h5) with the "MESH" (mesh.h5). - -// The node_dof of course takes into account the NUMBER of VARIABLES for each FE type -// So, if the node_dof was not filled correctly, then when you - - -void SystemTwo::ReadMatrix(const std::string& namefile) { - - _A.resize(GetGridn()); - - for (uint Level = 0; Level< GetGridn(); Level++) { - - std::ostringstream groupname_lev; groupname_lev << "LEVEL" << Level; - - uint*** rowcln; //number of rows and columns for one variable couple - uint*** length_row; //for every FE row and FE column - uint*** length_offrow; - uint*** pos_row; - - rowcln = new uint**[QL]; - length_row = new uint**[QL]; - length_offrow = new uint**[QL]; - pos_row = new uint**[QL]; - - hid_t file = H5Fopen(namefile.c_str(),H5F_ACC_RDWR, H5P_DEFAULT); - - for (int r=0;rinit(_Dim[Level],_Dim[Level], mrow_lev_proc_t, mrow_lev_proc_t); //TODO BACK TO a REASONABLE INIT - - Graph graph; - graph.resize(mrow_glob_t); - graph._m = mrow_glob_t; - graph._n = ncol_glob_t; - graph._ml = mrow_lev_proc_t; - graph._nl = ncol_lev_proc_t; - graph._ml_start = _dofmap.GetStartDof(Level,off_proc); - // TODO is this used? I guess it is used by update_sparsity_pattern ! - // Every subdomain has a local set of dofs, and these dofs start at a specific point. - // Now, remember that GetMLProb().GetMeshTwo()._off_nd[QQ] should only be used for computing offsets, so differences. - // Here, it is used ALONE, because it gives you the NODE (in femus ordering) AT WHICH THE CURRENT SUBDOMAIN BEGINS, - //and then from _node_dof[Level] (which was already constructed) you get THE LOCAL DOF AT THE CURRENT LEVEL TO START FROM. - // Clearly, pay attention when you add elements, because in that case you would need to REDO the _node_dof map !!! - //TODO: also, what happens if you have a system with ONLY ELEMENT BASED DOFS?!? - - - int FELevel[QL]; - FELevel[QQ] = Level; - FELevel[LL] = (Level+GetGridn())%(GetGridn()+1); //This is the map for the level of the LINEAR DOFS - FELevel[KK] = Level; - - int off_onevar[QL]; - off_onevar[QQ] = GetMLProb().GetMeshTwo()._NoNodesXLev[GetGridn()-1]; - off_onevar[LL] = GetMLProb().GetMeshTwo()._NoNodesXLev[GetGridn()-1]; - off_onevar[KK] = GetMLProb().GetMeshTwo()._n_elements_vb_lev[VV][Level]; - - uint off_EachFEFromStart[QL]; - off_EachFEFromStart[QQ] = 0; - off_EachFEFromStart[LL] = _dofmap._nvars[QQ]*off_onevar[QQ]; - off_EachFEFromStart[KK] = _dofmap._nvars[QQ]*off_onevar[QQ] + _dofmap._nvars[LL]*off_onevar[LL]; - - //============== - for (int r=0;rupdate_sparsity_pattern_old(graph); //TODO see how it works - - // clean =============== - graph.clear(); - - for (int r=0;rinit(0,0,0,0); //TODO BACK TO A REASONABLE INIT - - // local matrix dimension - uint ml[QL]; uint nl[QL]; - for (int fe=0; feupdate_sparsity_pattern_old(pattern); //TODO shall we make the two operations of updating sparsity pattern and setting values together? - -//=========== VALUES =================== - DenseMatrix *valmat; - std::vector tmp(1); - for (int fe=0; fe ind(pattern[irow].size()-1); - for (uint j=0; jadd_matrix(*valmat,tmp,ind); - delete valmat; - } - } - } //end fe - - - for (int fe=0;feclose(); //TODO do we need this? -// if (GetMLProb().GetMeshTwo()._iproc==0) _Prl[ Lev_f ]->print_personal(); -// _Prl[ Lev_f ]->print_graphic(false); //TODO should pass this true or false as a parameter - } //end levels - -#ifdef DEFAULT_PRINT_INFO - std::cout << " ReadProl(B): read Op " << name.c_str() << std::endl; -#endif - - return; -} - - - -// ================================================================= -//This function depends on _iproc -//TODO AAA This operator here DEPENDS on the BOUNDARY CONDITIONS -// while the prolongator does not depend on the bc's... CHECK THAT -//Also notice that the Matrix, Restriction and Prolongation sparsity patterns -//are assembled by looping over NODES. -// Then, the values are set with NODE LOOPS for Rest and Prol, -// and with ELEMENT LOOP for the MATRIX (the Assemble Function) -//Level goes from 0 to < GetGridn() - 1 ==> Level is COARSE here - -// uint Lev_c = Level; -// uint Lev_f = Level+1; - //with these you explore arrays that go from 0 to GetGridn() - 1 - //so where the distinction between QQ and LL is already made - // with the EXTENDED levels you explore things that have an additional level, - // and so can work both with QQ and with LL - //the point is: there are parts where you cannot use extended levels, and parts where you can - //for instance, in this routine the FINE LEVELS and the FINE EXTENDED LEVELS will both be ok, - //so we can use them in both cases, but we cannot say the same for the COARSE levels and ext levels - - //AAA fai molta attenzione: per esplorare la node_dof devi usare Lev_c e Lev_f, - //perche' sono legati ai DOF (devi pensare che la questione del mesh e' gia' risolta) -void SystemTwo::ReadRest(const std::string& name) { - - _Rst.resize(GetGridn()); //TODO why do it bigger? - - for (uint Level = 0; Level< GetGridn() - 1; Level++) { - - uint Lev_c = Level; - uint Lev_f = Level+1; - - std::ostringstream groupname_lev; groupname_lev << "LEVEL" << Lev_f << "_" << Lev_c; - - int** rowcln; - int** len; - int** lenoff; - int** Rest_pos; - double** Rest_val; - - rowcln = new int*[QL]; - len = new int*[QL]; - lenoff = new int*[QL]; - Rest_pos = new int*[QL]; - Rest_val = new double*[QL]; - - hid_t file = H5Fopen(name.c_str(),H5F_ACC_RDWR, H5P_DEFAULT); - - for (int fe=0;feinit(0,0,0,0); //TODO BACK TO A REASONABLE INIT //we have to do this before appropriately!!! - - int nrowt=0;int nclnt=0; - for (int fe=0;feupdate_sparsity_pattern_old(pattern); //TODO see -// _Rst[Lev_c]->close(); -// if (GetMLProb().GetMeshTwo()._iproc==0) _Rst[Lev_c]->print_personal(); //there is no print function for rectangular matrices, and print_personal doesnt seem to be working... -// la print stampa il contenuto, ma io voglio solo stampare lo sparsity pattern! - //Allora cosa faccio: riempio di zeri e poi la stampo! No, di zeri no!!! devi riempirla con qualcos'altro! -//TODO how can I print the sparsity pattern in Petsc BEFORE FILLING the MATRIX ?!?! - //============================== -//========= SET VALUES ========= -//============================== - - DenseMatrix *valmat; - std::vector tmp(1); - for (int fe=0;fe ind(pattern[irow].size()-1); -// std::cout << "\n ==== " << irow << ": "; - for (uint i1=0;i1add_matrix(*valmat,tmp,ind); - delete valmat; - }// end dof loop - } // end var loop - } //end fe - - for (int fe=0;feclose(); //TODO Do we really need this? -// if (GetMLProb().GetMeshTwo()._iproc==0) _Rst[Lev_c]->print_personal(std::cout); -// _Rst[Lev_c]->print_graphic(false); // TODO should pass this true or false as a parameter - - } //end levels - -#ifdef DEFAULT_PRINT_INFO - std::cout << " ReadRest(B): read Op " << name.c_str() << std::endl; -#endif - return; -} - - - - - - - - - - - - -// // // // void SystemTwo::func_xyz() { - -// // // // // double xyz[dimension]; -// // // // double xez[dimension]; -// // // // -// // // // //Give the point xyz in the 'dimensional' domain -// // // // -// // // // //NONdimensionalize THE COORDINATES, -// // // // //but i think here they are already dimensionalized -// // // // //do a code that depends EXPLICITLY from what was done before. -// // // // //A good practice would be to check if something had been done before... -// // // // -// // // // -// // // // // find in which element my point is -// // // // -// // // // //get the dofs of that element, in some order -// // // // -// // // // //compute the coordinate transformation -// // // // //as we have to transform the real coordinates into canonical ones, -// // // // //we have to invert x = x(\xi) -// // // // //so we have to compute \xi as a function of x -// // // // -// // // // -// // // // xez[0]=0.16; -// // // // xez[1]=0.4867; -// // // // -// // // // double* lin_shapes = new double[_eldof[0][1]]; -// // // // -// // // // //void FE::shapes_xez(const uint ql, const uint el_ndof,const double* xez, double* shapes) { -// // // // //for now i'll take the linear from the quadratics... -// // // // _fe[0]->shapes_xez(1,_eldof[0][1],xez,lin_shapes); -// // // // -// // // // -// // // // //transform the nondimensional physical coordinates to the -// // // // //coordinates in the reference element (\xi \eta) -// // // // -// // // // //compute the shape functions at that reference elements -// // // // //first the domain was linear, now pick the quadratic shapes for velocity i.e. -// // // // double* quad_shapes = new double[_eldof[0][0]]; -// // // // -// // // // _fe[0]->shapes_xez(0,_eldof[0][0],xez,quad_shapes); -// // // // -// // // // double* quad_dofs = new double[_eldof[0][0]]; -// // // // for (uint i=0;i<_eldof[0][0];i++ ) quad_dofs[i]= 87.; -// // // // //clearly the order in which these dofs are given must be the same as the connectivity order! -// // // // // -// // // // -// // // // //do the sum and you get the value... -// // // // //scalar product in R^n, not R^dim -// // // // -// // // // double resu = _utils.dotN(quad_shapes,quad_dofs,_eldof[0][0]); -// // // // -// // // // std::cout << "The final result is " << resu << std::endl; -// // // // -// // // // //given the computed vector of dofs -// // // // //given the real point xyz -// // // // //compute the function at that point -// // // // //find which element I am in -// // // // //retrieve from the global dof only the dofs of THAT element -// // // // // for every dof, transform to the canonical element -// // // // //retrieve the shape fncs for every local dof -// // // // //translate the global coordinate into the local coordinate -// // // // //compute all the functions at the local coordinate -// // // // //multiply and you're done -// // // // //to test things you may first do them ALL INSIDE A FUNCTION, -// // // // // without calling from outside, then you put it in a -// // // // //MODULAR FASHION. -// // // // - - - - - -// return; -// // // // } diff --git a/src/equations/SystemTwo.hpp b/src/equations/SystemTwo.hpp index aec4a9ad0..72ec658ca 100644 --- a/src/equations/SystemTwo.hpp +++ b/src/equations/SystemTwo.hpp @@ -55,56 +55,19 @@ class SystemTwo : public LinearImplicitSystem { //======================================================================= SystemTwo(MultiLevelProblem & equations_map, const std::string & eq_name_in, const unsigned int number, const MgSmoother & smoother_type); //System// - virtual ~SystemTwo(); //System// - - DofMap _dofmap; //// LinearEquation (each level) BoundaryConditions _bcond; -//======================================================================= -//======== MG Ops ============ (procs,levels) ==== -//======================================================================= - std::vector _A; // LinearEquation (each level) - std::vector _Rst; // LinearEquation (each level) - std::vector _Prl; // LinearEquation (each level) - - void ReadMGOps(const std::string output_path); // LinearEquation (each level) - void ReadMatrix(const std::string& name); // LinearEquation (each level) - void ReadProl(const std::string& name); // LinearEquation (each level) - void ReadRest(const std::string& name); // LinearEquation (each level) - void ComputeMatrix(); // LinearEquation (each level) - void ComputeProl(); // LinearEquation (each level) - void ComputeRest(); // LinearEquation (each level) - -//======================================================================= -//======== Vectors =============== (procs,levels) == -//======================================================================= - - std::vector _b; //// LinearEquation (each level) - std::vector _x; //// LinearEquation (each level) - std::vector _res; //// LinearEquation (each level) - - std::vector _x_old; //// LinearEquation (each level) - - std::vector _x_oold; //this is used by MGTimeStep and also by the OptLoop - std::vector _x_tmp; //this is used by MGTimeStep and also by the OptLoop - - void initVectors(); ///initialize vectors //System// - -//=================== - void MGSolve(double Eps,int MaxIter, const uint Gamma=DEFAULT_MG_GAMMA, const uint Nc_pre=DEFAULT_NC_PRE,const uint Nc_coarse=DEFAULT_NC_COARSE,const uint Nc_post=DEFAULT_NC_POST); //LinearImplicitSystem// - double MGStep(int Level,double Eps1,int MaxIter, const uint Gamma, const uint Nc_pre,const uint Nc_coarse,const uint Nc_post); //LinearImplicitSystem// + void initVectors(); ///initialize vectors //System// //======================================================================= //======= Quantities ========= //======================================================================= - inline const std::vector & GetUnknownQuantitiesVector() const { //MultilevelSolution// - return _UnknownQuantitiesVector; - } + inline const std::vector & GetUnknownQuantitiesVector() const { return _UnknownQuantitiesVector; }//MultilevelSolution// - void AddUnknownToSystemPDE( Quantity* qty_in) { //System// + void AddUnknownToSystemPDE( Quantity* qty_in) { //System// unsigned n = _UnknownQuantitiesVector.size(); _UnknownQuantitiesVector.resize(n+1); @@ -122,7 +85,7 @@ class SystemTwo : public LinearImplicitSystem { std::vector _refvalue; //MultilevelSolution// void initRefValues(); //MultilevelSolution// - void init_sys(); //System// //MultilevelSolution// + void init_unknown_vars(); //System// //MultilevelSolution// // ============ INITIAL CONDITIONS of the equation ====== (procs,levels) == void Initialize(); //MultilevelSolution //this uses x and fills in x_old at all levels diff --git a/src/equations/TimeLoop.cpp b/src/equations/TimeLoop.cpp index 3ea8a8052..8aaa54943 100644 --- a/src/equations/TimeLoop.cpp +++ b/src/equations/TimeLoop.cpp @@ -103,8 +103,14 @@ double TimeLoop::MGTimeStep(const uint iter, SystemTwo * eqn_in) const { std::cout << std::endl << " Solving " << eqn_in->name() << " , step " << iter << std::endl; + std::auto_ptr _x_oold = NumericVector::build(); + _x_oold->init(eqn_in->_dofmap._Dim[eqn_in->GetGridn()-1],false, SERIAL); + std::auto_ptr _x_tmp = NumericVector::build(); + _x_tmp->init(eqn_in->_dofmap._Dim[eqn_in->GetGridn()-1],false, SERIAL); + + ///A0) Put x_old into x_oold - *(eqn_in->_x_oold[eqn_in->GetGridn()-1]) = *(eqn_in->_x_old[eqn_in->GetGridn()-1]); + *(_x_oold) = *( eqn_in->_LinSolver[eqn_in->GetGridn()-1]->_EPSC ); /// A) Assemblying #if DEFAULT_PRINT_TIME==1 @@ -116,10 +122,10 @@ double TimeLoop::MGTimeStep(const uint iter, SystemTwo * eqn_in) const { eqn_in-> GetAssembleFunction()(eqn_in->GetMLProb(),Level,0,true); #ifdef DEFAULT_PRINT_INFO - eqn_in->_A[Level]->close(); - double ANorm = eqn_in->_A[Level]->l1_norm(); + eqn_in->_LinSolver[Level]->_KK->close(); + double ANorm = eqn_in->_LinSolver[Level]->_KK->l1_norm(); -// _A[Level]->print_graphic(true); TODO should pass this true or false as a parameter +// _LinSolver[Level]->_KK->print_graphic(true); TODO should pass this true or false as a parameter std::cout << " ANorm l1 " << Level << " " << ANorm << std::endl; #endif @@ -143,10 +149,6 @@ double TimeLoop::MGTimeStep(const uint iter, SystemTwo * eqn_in) const { eqn_in->MGSolve(DEFAULT_EPS_LSOLV, DEFAULT_MAXITS_LSOLV); -// // for (uint Level = 0 ; Level < GetGridn(); Level++) { -// // _solver[Level]->solve(*_A[Level],*_x[Level],*_b[Level],1.e-6,40); -// // _x[Level]->localize(*_x_old[Level]); // x_old = x -// // } #if DEFAULT_PRINT_TIME==1 std::clock_t end_time_sol = std::clock(); @@ -158,24 +160,24 @@ double TimeLoop::MGTimeStep(const uint iter, SystemTwo * eqn_in) const { /// std::cout << "$$$$$$$$$ Computed the x with the MG method $$$$$$$" << std::endl; /// E) Update of the old solution at the top Level - eqn_in->_x[eqn_in->GetGridn()-1]->localize(*(eqn_in->_x_old[eqn_in->GetGridn()-1])); // x_old = x + eqn_in->_LinSolver[eqn_in->GetGridn()-1]->_EPS->localize(*(eqn_in->_LinSolver[eqn_in->GetGridn()-1]->_EPSC)); // x_old = x #ifdef DEFAULT_PRINT_INFO std::cout << "$$$$$$$$$ Updated the x_old solution $$$$$$$$$" << std::endl; #endif /// std::cout << "$$$$$$$$$ Check the convergence $$$$$$$" << std::endl; - eqn_in->_x_tmp[eqn_in->GetGridn()-1]->zero(); - eqn_in->_x_tmp[eqn_in->GetGridn()-1]->add(+1.,*(eqn_in->_x_oold[eqn_in->GetGridn()-1])); - eqn_in->_x_tmp[eqn_in->GetGridn()-1]->add(-1.,*(eqn_in->_x_old[eqn_in->GetGridn()-1])); + _x_tmp->zero(); + _x_tmp->add(+1.,*(_x_oold)); + _x_tmp->add(-1.,*(eqn_in->_LinSolver[eqn_in->GetGridn()-1]->_EPSC)); // x_oold -x_old =actually= (x_old - x) //(x must not be touched, as you print from it) //x_oold must not be touched ! Because it's used later for UPDATING Becont! //so you must create a temporary vector necessarily. - eqn_in->_x_tmp[eqn_in->GetGridn()-1]->close(); - double deltax_norm = eqn_in->_x_tmp[eqn_in->GetGridn()-1]->l2_norm(); + _x_tmp->close(); + double deltax_norm = _x_tmp->l2_norm(); std::cout << " $$$$$$ " << eqn_in->name() << " error l2 " << deltax_norm << std::endl; - std::cout << " $$$$$$ " << eqn_in->name() << " error linfty " << eqn_in->_x_tmp[eqn_in->GetGridn()-1]->linfty_norm() << std::endl; + std::cout << " $$$$$$ " << eqn_in->name() << " error linfty " << _x_tmp->linfty_norm() << std::endl; //AAA when the vectors have nan's, the norm becomes zero! //when the residual norm in pre and post smoothing is too big, //then it doesnt do any iterations, the solver doesnt solve anymore, so the solution remains frozen diff --git a/src/fe/ElemType.cpp b/src/fe/ElemType.cpp index ffaeb43a4..dca4f9b79 100644 --- a/src/fe/ElemType.cpp +++ b/src/fe/ElemType.cpp @@ -198,7 +198,9 @@ void elem_type::GetSparsityPatternSize(const LinearEquation &lspdef,const Linear } void elem_type::BuildRestrictionTranspose(const LinearEquation &lspdef,const LinearEquation &lspdec, const int& ielc, SparseMatrix* Projmat, - const unsigned &index_sol, const unsigned &kkindex_sol, const bool &TestDisp) const { + const unsigned &index_sol, const unsigned &kkindex_sol, + const unsigned &index_pair_sol, const unsigned &kkindex_pair_sol) const{ + vector cols(27); bool fluid_region = (2==lspdec._msh->el->GetElementMaterial(ielc))?1:0; @@ -220,12 +222,20 @@ void elem_type::BuildRestrictionTranspose(const LinearEquation &lspdef,const Lin for (int k=0; kel->GetMeshDof(ielc,j,_SolType); - int jcolumn=lspdec.GetKKDof(index_sol,kkindex_sol,jadd); - cols[k]=jcolumn; - bool jsolidmark=lspdef._msh->el->GetNodeRegion(jadd); + if(isolidmark == jsolidmark){ + int jcolumn=lspdec.GetKKDof(index_sol,kkindex_sol,jadd); + cols[k]=jcolumn; + copy_prol_val[k]=_prol_val[i][k]; + } + else { + int jcolumn=lspdec.GetKKDof(index_pair_sol,kkindex_pair_sol,jadd); + cols[k]=jcolumn; + copy_prol_val[k]=(index_sol != index_pair_sol) ? _prol_val[i][k]:0.; + } + - copy_prol_val[k]=(!TestDisp || !fluid_region || isolidmark==jsolidmark)?_prol_val[i][k]:0.; + //copy_prol_val[k]=(!fluid_region || isolidmark==jsolidmark)?_prol_val[i][k]:0.; } Projmat->insert_row(irow,ncols,cols,©_prol_val[0]); } diff --git a/src/fe/ElemType.hpp b/src/fe/ElemType.hpp index 1e89f95c9..4ff09e4c9 100644 --- a/src/fe/ElemType.hpp +++ b/src/fe/ElemType.hpp @@ -56,7 +56,8 @@ class elem_type { /** To be Added */ void BuildRestrictionTranspose(const LinearEquation &lspdef,const LinearEquation &lspdec, const int& ielc, SparseMatrix* Projmat, - const unsigned &index_sol, const unsigned &kkindex_sol, const bool &TestDisp) const; + const unsigned &index_sol, const unsigned &kkindex_sol, + const unsigned &index_pair_sol, const unsigned &kkindex_pair_sol) const; /** To be Added */ void BuildProlongation(const Mesh &meshf, const Mesh &meshc, const int& ielc, SparseMatrix* Projmat) const; @@ -98,19 +99,19 @@ class elem_type { // void GetArea(const double *vt,const double *vty, const double *vtz, const unsigned &ig, // double &Weight, double *other_phi) const; - /** DEPRECATED Function pointer for DPhiDXEZ */ + /** @deprecated Function pointer for DPhiDXEZ */ typedef double* (elem_type::*_FunctionPointer)(const unsigned & ig) const; //you need "elem_type::" for some reason std::vector<_FunctionPointer> _DPhiXiEtaZetaPtr; - /** DEPRECATED Evaluate shape functions at all quadrature points */ + /** @deprecated Evaluate shape functions at all quadrature points */ virtual void EvaluateShapeAtQP(const std::string geomel_id_in,const std::string fe_in); - /** DEPRECATED Get shape functions */ + /** @deprecated Get shape functions */ inline const double GetPhi(const uint qp, const uint dof ) const { return _phi_mapGD[qp][dof]; } - /** DEPRECATED Get shape function first derivatives */ + /** @deprecated Get shape function first derivatives */ inline const double GetDPhiDxez(const uint qp, const uint dof ) const { return _dphidxez_mapGD[qp][dof]; } @@ -173,7 +174,7 @@ class elem_type { // Gauss const Gauss _gauss; - /** DEPRECATED */ + /** @deprecated */ double** _phi_mapGD; double** _dphidxez_mapGD; diff --git a/src/mesh/GambitIO.cpp b/src/mesh/GambitIO.cpp index 5b975f67b..a0a297887 100644 --- a/src/mesh/GambitIO.cpp +++ b/src/mesh/GambitIO.cpp @@ -70,7 +70,7 @@ void GambitIO::read(const std::string& name, vector < vector < double> > &coords unsigned nvt; unsigned nel; - mesh.SetGridNumber(0); + mesh.SetLevel(0); // read control data ******************** A inf.open(name.c_str()); if (!inf) { diff --git a/src/mesh/Mesh.cpp b/src/mesh/Mesh.cpp index 9db94cbc1..c21d65239 100644 --- a/src/mesh/Mesh.cpp +++ b/src/mesh/Mesh.cpp @@ -20,6 +20,7 @@ #include "MeshGeneration.hpp" #include "MeshMetisPartitioning.hpp" #include "GambitIO.hpp" +#include "SalomeIO.hpp" #include "NumericVector.hpp" // C++ includes @@ -46,19 +47,48 @@ unsigned Mesh::_ref_index=4; // 8*DIM[2]+4*DIM[1]+2*DIM[0]; unsigned Mesh::_face_index=2; // 4*DIM[2]+2*DIM[1]+1*DIM[0]; //------------------------------------------------------------------------------------------------------ + Mesh::Mesh(){ + + _coarseMsh = NULL; + + for(int i=0;i<5;i++){ + _ProjCoarseToFine[i]=NULL; + } + + for (int itype=0; itype<3; itype++) { + for (int jtype=0; jtype<3; jtype++) { + _ProjQitoQj[itype][jtype] = NULL; + } + } + } -Mesh::~Mesh(){ + + Mesh::~Mesh(){ delete el; _coordinate->FreeSolutionVectors(); delete _coordinate; - delete [] epart; - delete [] npart; -} + + for (int itype=0; itype<3; itype++) { + for (int jtype=0; jtype<3; jtype++) { + if(_ProjQitoQj[itype][jtype]){ + delete _ProjQitoQj[itype][jtype]; + _ProjQitoQj[itype][jtype] = NULL; + } + } + } + + for (unsigned i=0; i<5; i++) { + if (_ProjCoarseToFine[i]) { + delete _ProjCoarseToFine[i]; + _ProjCoarseToFine[i]=NULL; + } + } + } /// print Mesh info void Mesh::PrintInfo() { - std::cout << " Mesh Level : " << _grid << std::endl; + std::cout << " Mesh Level : " << _level << std::endl; std::cout << " Number of elements: " << _nelem << std::endl; std::cout << " Number of nodes : " << _nnodes << std::endl; @@ -71,12 +101,15 @@ void Mesh::ReadCoarseMesh(const std::string& name, const double Lref, std::vecto vector > coords(3); - _grid=0; + _level = 0; if(name.rfind(".neu") < name.size()) { GambitIO(*this).read(name,coords,Lref,type_elem_flag); } + else if(name.rfind(".med") < name.size()) { + SalomeIO(*this).read(name,coords,Lref,type_elem_flag); + } else { std::cerr << " ERROR: Unrecognized file extension: " << name @@ -85,7 +118,7 @@ void Mesh::ReadCoarseMesh(const std::string& name, const double Lref, std::vecto << std::endl; } - RenumberNodes(coords); + ReorderMeshDofs(coords); BuildAdjVtx(); @@ -93,7 +126,6 @@ void Mesh::ReadCoarseMesh(const std::string& name, const double Lref, std::vecto MeshMetisPartitioning meshmetispartitioning(*this); meshmetispartitioning.DoPartition(); - //GenerateMetisMeshPartition(); FillISvector(); @@ -115,15 +147,9 @@ void Mesh::ReadCoarseMesh(const std::string& name, const double Lref, std::vecto _coordinate->ResizeSolutionVector("Y"); _coordinate->ResizeSolutionVector("Z"); - //_coordinate->SetCoarseCoordinates(coords); _coordinate->GetSolutionName("X") = coords[0]; _coordinate->GetSolutionName("Y") = coords[1]; _coordinate->GetSolutionName("Z") = coords[2]; -// *ppi = coords[0]; - -// = coords[0]; -// _coordinate->GetSolutionName("Y") = coords[1]; -// _coordinate->GetSolutionName("Z") = coords[2]; _coordinate->AddSolution("AMR",DISCONTINOUS_POLYNOMIAL,ZERO,1,0); @@ -141,13 +167,13 @@ void Mesh::GenerateCoarseBoxMesh( const double zmin, const double zmax, const ElemType type, std::vector &type_elem_flag) { - vector > coords(3); + vector > coords(3); - _grid=0; + _level = 0; MeshTools::Generation::BuildBox(*this,coords,nx,ny,nz,xmin,xmax,ymin,ymax,zmin,zmax,type,type_elem_flag); - RenumberNodes(coords); + ReorderMeshDofs(coords); BuildAdjVtx(); @@ -155,7 +181,6 @@ void Mesh::GenerateCoarseBoxMesh( MeshMetisPartitioning meshmetispartitioning(*this); meshmetispartitioning.DoPartition(); - //GenerateMetisMeshPartition(); FillISvector(); @@ -189,7 +214,7 @@ void Mesh::GenerateCoarseBoxMesh( //------------------------------------------------------------------------------------------------------ -void Mesh::RenumberNodes(vector < vector < double> > &coords) { +void Mesh::ReorderMeshDofs(vector < vector < double> > &coords) { vector dof_index; dof_index.resize(_nnodes); @@ -284,9 +309,6 @@ void Mesh::BuildAdjVtx() { } } - - - /** * This function stores the element adiacent to the element face (iel,iface) * and stores it in kel[iel][iface] @@ -307,16 +329,13 @@ void Mesh::Buildkel() { unsigned j2=el->GetFaceVertexIndex(jel,jface,1); unsigned j3=el->GetFaceVertexIndex(jel,jface,2); unsigned j4=el->GetFaceVertexIndex(jel,jface,3); -// if((DIM[2]==1 && if ((Mesh::_dimension==3 && (i1==j1 || i1==j2 || i1==j3 || i1==j4 )&& (i2==j1 || i2==j2 || i2==j3 || i2==j4 )&& (i3==j1 || i3==j2 || i3==j3 || i3==j4 ))|| -// (DIM[1]==1 && (Mesh::_dimension==2 && (i1==j1 || i1==j2 )&& (i2==j1 || i2==j2 ))|| -// (DIM[0]==1 && (Mesh::_dimension==1 && (i1==j1)) ) { @@ -359,15 +378,6 @@ unsigned Mesh::GetDofNumber(const unsigned type) const { } -/** - * This function copies the refined element index vector in other_vector - **/ -void Mesh::copy_elr(vector &other_vec) const { - for (unsigned i=0; i<_nelem; i++) - other_vec[i]=el->GetRefinedElementIndex(i); -} - - void Mesh::AllocateAndMarkStructureNode() { el->AllocateNodeRegion(); for (unsigned iel=0; iel<_nelem; iel++) { @@ -382,16 +392,10 @@ void Mesh::AllocateAndMarkStructureNode() { } } } - return; } -/** - * This function generates a finer Mesh level, $l_i$, from a coarser Mesh level $l_{i-1}$, $i>0$ - **/ - void Mesh::SetFiniteElementPtr(const elem_type * OtherFiniteElement[6][5]){ - for(int i=0;i<6;i++) for(int j=0;j<5;j++) _finiteElement[i][j] = OtherFiniteElement[i][j]; @@ -399,9 +403,6 @@ void Mesh::SetFiniteElementPtr(const elem_type * OtherFiniteElement[6][5]){ - - - void Mesh::FillISvector() { //dof map: piecewise liner 0, quadratic 1, biquadratic 2, piecewise constant 3, picewise discontinous linear 4 @@ -416,10 +417,10 @@ void Mesh::FillISvector() { // I for(unsigned i=0;i<_nnodes;i++) { - npart[i]=nsubdom; + npart[i] = nsubdom; } - IS_Mts2Gmt_elem_offset[0]=0; + IS_Mts2Gmt_elem_offset[0] = 0; vector IS_Gmt2Mts_dof_counter(5,0); for(int k=0;k<5;k++) { @@ -427,7 +428,6 @@ void Mesh::FillISvector() { //TODO for domain decomposition pourposes! the non existing dofs point to the last dof!!!!!! } - IS_Gmt2Mts_dof_counter[3]=0; IS_Gmt2Mts_dof_counter[4]=0; @@ -435,8 +435,8 @@ void Mesh::FillISvector() { for(unsigned iel=0;iel<_nelem;iel++){ if(epart[iel]==isdom){ //filling the piecewise IS_Mts2Gmt_elem metis->gambit - IS_Mts2Gmt_elem[ IS_Gmt2Mts_dof_counter[3] ]=iel; - IS_Gmt2Mts_dof[3][iel]=IS_Gmt2Mts_dof_counter[3]; + IS_Mts2Gmt_elem[ IS_Gmt2Mts_dof_counter[3] ] = iel; + IS_Gmt2Mts_dof[3][iel] = IS_Gmt2Mts_dof_counter[3]; IS_Gmt2Mts_dof_counter[3]++; IS_Mts2Gmt_elem_offset[isdom+1]=IS_Gmt2Mts_dof_counter[3]; // linear+quadratic+biquadratic @@ -516,8 +516,7 @@ void Mesh::FillISvector() { } } - - for (unsigned inode=el->GetElementDofNumber(iel,0); inodeGetElementDofNumber(iel,1); inode++) { + for (unsigned inode=el->GetElementDofNumber(iel,0); inodeGetElementDofNumber(iel,1); inode++) { unsigned ii=el->GetElementVertexIndex(iel,inode)-1; if(node_count[ii]init(ni, ni_loc, false, SERIAL); + NNZ_o->init(ni, ni_loc, false, SERIAL); + } + else{ + NNZ_d->init(ni, ni_loc, false, PARALLEL); + NNZ_o->init(ni, ni_loc, false, PARALLEL); + } + NNZ_d->zero(); + NNZ_o->zero(); + + for(unsigned isdom = _iproc; isdom < _iproc+1; isdom++) { + for (unsigned iel_mts = IS_Mts2Gmt_elem_offset[isdom]; iel_mts < IS_Mts2Gmt_elem_offset[isdom+1]; iel_mts++){ + unsigned iel = IS_Mts2Gmt_elem[iel_mts]; + short unsigned ielt = el->GetElementType(iel); + _finiteElement[ielt][jtype]->GetSparsityPatternSize(*this, iel, NNZ_d, NNZ_o, itype); + } + } + + NNZ_d->close(); + NNZ_o->close(); + + unsigned offset = MetisOffset[itype][_iproc]; + + vector < int > nnz_d(ni_loc); + vector < int > nnz_o(ni_loc); + for(unsigned i = 0; i < ni_loc; i++){ + nnz_d[i] = static_cast < int > ((*NNZ_d)(offset+i)); + nnz_o[i] = static_cast < int > ((*NNZ_o)(offset+i)); + } + + delete NNZ_d; + delete NNZ_o; + + _ProjQitoQj[itype][jtype] = SparseMatrix::build().release(); + _ProjQitoQj[itype][jtype]->init(ni, nj, own_size[itype][_iproc], own_size[jtype][_iproc], nnz_d, nnz_o); + for(unsigned isdom = _iproc; isdom < _iproc+1; isdom++) { + for (unsigned iel_mts = IS_Mts2Gmt_elem_offset[isdom]; iel_mts < IS_Mts2Gmt_elem_offset[isdom+1]; iel_mts++){ + unsigned iel = IS_Mts2Gmt_elem[iel_mts]; + short unsigned ielt = el->GetElementType(iel); + _finiteElement[ielt][jtype]->BuildProlongation(*this, iel, _ProjQitoQj[itype][jtype], itype); + } + } + _ProjQitoQj[itype][jtype]->close(); +} + + + +SparseMatrix* Mesh::GetCoarseToFineProjection(const unsigned& solType){ + + if( solType > 4 ){ + std::cout<<"Wrong argument range in function \"GetCoarseToFineProjection\": " + <<"solType is greater then SolTypeMax"<MetisOffset[solType][_nprocs]; + int nf_loc = own_size[solType][_iproc]; + int nc_loc = _coarseMsh->own_size[solType][_iproc]; + + //build matrix sparsity pattern size + NumericVector *NNZ_d = NumericVector::build().release(); + if(n_processors()==1) { // IF SERIAL + NNZ_d->init(nf, nf_loc, false, SERIAL); + } + else { // IF PARALLEL + if(solType<3) { + if(ghost_size[solType][processor_id()]!=0) { + NNZ_d->init(nf, nf_loc, ghost_nd_mts[solType][processor_id()], false, GHOSTED); + } + else { + std::vector < int > fake_ghost(1,nf_loc); + NNZ_d->init(nf, nf_loc, fake_ghost, false, GHOSTED); + } + } + else { //discontinuous pressure has no ghost nodes + NNZ_d->init(nf, nf_loc, false, PARALLEL); + } + } + NNZ_d->zero(); + + NumericVector *NNZ_o = NumericVector::build().release(); + NNZ_o->init(*NNZ_d); + NNZ_o->zero(); + + for(int isdom=_iproc; isdom<_iproc+1; isdom++) { + for (int iel_mts=_coarseMsh->IS_Mts2Gmt_elem_offset[isdom];iel_mts < _coarseMsh->IS_Mts2Gmt_elem_offset[isdom+1]; iel_mts++) { + unsigned iel = _coarseMsh->IS_Mts2Gmt_elem[iel_mts]; + if(_coarseMsh->el->GetRefinedElementIndex(iel)){ //only if the coarse element has been refined + short unsigned ielt=_coarseMsh->el->GetElementType(iel); + _finiteElement[ielt][solType]->GetSparsityPatternSize( *this, *_coarseMsh, iel, NNZ_d, NNZ_o); + } + } + } + NNZ_d->close(); + NNZ_o->close(); + + unsigned offset = MetisOffset[solType][_iproc]; + vector nnz_d(nf_loc); + vector nnz_o(nf_loc); + for(int i=0; i ((*NNZ_d)(offset+i)); + nnz_o[i]=static_cast ((*NNZ_o)(offset+i)); + } + delete NNZ_d; + delete NNZ_o; + + //build matrix + _ProjCoarseToFine[solType] = SparseMatrix::build().release(); + _ProjCoarseToFine[solType]->init(nf,nc,nf_loc,nc_loc,nnz_d,nnz_o); + + // loop on the coarse grid + for(int isdom=_iproc; isdom<_iproc+1; isdom++) { + for (int iel_mts=_coarseMsh->IS_Mts2Gmt_elem_offset[isdom]; + iel_mts < _coarseMsh->IS_Mts2Gmt_elem_offset[isdom+1]; iel_mts++) { + unsigned iel = _coarseMsh->IS_Mts2Gmt_elem[iel_mts]; + if(_coarseMsh->el->GetRefinedElementIndex(iel)){ //only if the coarse element has been refined + short unsigned ielt=_coarseMsh->el->GetElementType(iel); + _finiteElement[ielt][solType]->BuildProlongation(*this, *_coarseMsh,iel, _ProjCoarseToFine[solType]); + } + } + } + _ProjCoarseToFine[solType]->close(); + } } + + + + + + + } //end namespace femus diff --git a/src/mesh/Mesh.hpp b/src/mesh/Mesh.hpp index 4048135f9..37bcfa782 100644 --- a/src/mesh/Mesh.hpp +++ b/src/mesh/Mesh.hpp @@ -45,7 +45,7 @@ class Mesh : public ParallelObject { /** Constructor */ explicit - Mesh() {}; + Mesh(); /** destructor */ ~Mesh(); @@ -77,13 +77,13 @@ class Mesh : public ParallelObject { } /** Set the grid number */ - void SetGridNumber(const unsigned i) { - _grid=i; + void SetLevel(const unsigned i) { + _level=i; }; /** Get the grid number */ - unsigned GetGridNumber() const { - return _grid; + unsigned GetLevel() const { + return _level; } /** Set the dimension of the problem (1D, 2D, 3D) */ @@ -149,42 +149,64 @@ class Mesh : public ParallelObject { // member data Solution* _coordinate; const elem_type *_finiteElement[6][5]; - vector IS_Mts2Gmt_elem_offset; - vector IS_Mts2Gmt_elem; - vector own_size[5]; - vector > MetisOffset; - vector< vector > ghost_nd[5]; - vector< vector > ghost_nd_mts[5]; - vector ghost_size[5]; - elem *el; //< elements - int *epart; - int *npart; + + vector < unsigned > IS_Mts2Gmt_elem_offset; + vector < unsigned > IS_Mts2Gmt_elem; + vector < unsigned > own_size[5]; + vector > MetisOffset; + vector< vector < unsigned > > ghost_nd[5]; + vector< vector < int > > ghost_nd_mts[5]; + vector < unsigned > ghost_size[5]; + elem *el; // topology object + vector < int > epart; + vector < int > npart; int nsubdom; static bool (* _SetRefinementFlag)(const double &x, const double &y, const double &z, const int &ElemGroupNumber,const int &level); static bool _TestSetRefinementFlag; std::map _boundaryinfo; - + /** Get the projection matrix between Lagrange FEM at the same level mesh*/ + SparseMatrix* GetQitoQjProjection(const unsigned& itype, const unsigned& jtype); + + /** Get the coarse to the fine projection matrix*/ + SparseMatrix* GetCoarseToFineProjection(const unsigned& solType); + + /** Set the coarser mesh from which this mesh is generated */ + void SetCoarseMesh( Mesh* otherCoarseMsh ){ + _coarseMsh = otherCoarseMsh; + }; + + private: - - /** To be added */ - void copy_elr(vector &other_vec) const; - - /** Renumber nodes in the following order: vertices, face, center */ - void RenumberNodes(vector < vector < double> > &coords); + /** Coarser mesh from which this mesh is generated, it equals NULL if _level = 0 */ + Mesh* _coarseMsh; + + /** The projection matrix between Lagrange FEM at the same level mesh */ + SparseMatrix* _ProjQitoQj[3][3]; + + /** The coarse to the fine projection matrix */ + SparseMatrix* _ProjCoarseToFine[5]; + + /** Build the projection matrix between Lagrange FEM at the same level mesh*/ + void BuildQitoQjProjection(const unsigned& itype, const unsigned& jtype); + + /** Build the coarse to the fine projection matrix */ + void BuildCoarseToFineProjection(const unsigned& solType); + + /** Reorder mesh dofs in the following order: vertices, face, center */ + void ReorderMeshDofs(vector < vector < double> > &coords); //member-data - int _nelem; //< number of elements - unsigned _nnodes; //< number of nodes - unsigned _grid; //< level of mesh in the multilevel hierarchy + int _nelem; //< number of elements + unsigned _nnodes; //< number of nodes + unsigned _level; //< level of mesh in the multilevel hierarchy static unsigned _dimension; //< dimension of the problem static unsigned _ref_index; static unsigned _face_index; vector IS_Gmt2Mts_dof[5]; //< dof map vector IS_Gmt2Mts_dof_offset[5]; //< map offset static const unsigned _END_IND[5]; - }; } //end namespace femus diff --git a/src/mesh/MeshMetisPartitioning.cpp b/src/mesh/MeshMetisPartitioning.cpp index 932bd7799..33efb10b3 100644 --- a/src/mesh/MeshMetisPartitioning.cpp +++ b/src/mesh/MeshMetisPartitioning.cpp @@ -92,13 +92,13 @@ void MeshMetisPartitioning::DoPartition() { int ncommon = _mesh.GetDimension()+1; _mesh.nsubdom = _nprocs; - _mesh.epart = new int [nelem]; - _mesh.npart = new int [nnodes]; + _mesh.epart.resize(nelem); + _mesh.npart.resize(nnodes); if(_mesh.nsubdom!=1) { //I call the Mesh partioning function of Metis library (output is epart(own elem) and npart (own nodes)) - int err = METIS_PartMeshDual(&nelem, &nnodes, eptr, eind, NULL, NULL, &ncommon, &_mesh.nsubdom, NULL, options, &objval, _mesh.epart, _mesh.npart); + int err = METIS_PartMeshDual(&nelem, &nnodes, eptr, eind, NULL, NULL, &ncommon, &_mesh.nsubdom, NULL, options, &objval, &_mesh.epart[0], &_mesh.npart[0]); if(err==METIS_OK) { //std::cout << " METIS PARTITIONING IS OK " << std::endl; diff --git a/src/mesh/MeshRefinement.cpp b/src/mesh/MeshRefinement.cpp index 2e652fed6..c6dadd540 100644 --- a/src/mesh/MeshRefinement.cpp +++ b/src/mesh/MeshRefinement.cpp @@ -79,7 +79,7 @@ void MeshRefinement::FlagElementsToBeRefinedByUserDefinedFunction() { vty/=nve; vtz/=nve; if(!_mesh.el->GetRefinedElementIndex(iel)){ - if (_mesh._SetRefinementFlag(vtx,vty,vtz,_mesh.el->GetElementGroup(iel),_mesh.GetGridNumber())) { + if (_mesh._SetRefinementFlag(vtx,vty,vtz,_mesh.el->GetElementGroup(iel),_mesh.GetLevel())) { _mesh.el->SetRefinedElementIndex(iel,1); _mesh.el->AddToRefinedElementNumber(1); short unsigned elt=_mesh.el->GetElementType(iel); @@ -113,7 +113,7 @@ void MeshRefinement::FlagElementsToBeRefinedByAMR() { vty/=nve; vtz/=nve; if( (*_mesh._coordinate->_Sol[3])(iel_metis) < 0.5 && - _mesh._SetRefinementFlag(vtx,vty,vtz,_mesh.el->GetElementGroup(kel),_mesh.GetGridNumber()) ) { + _mesh._SetRefinementFlag(vtx,vty,vtz,_mesh.el->GetElementGroup(kel),_mesh.GetLevel()) ) { _mesh._coordinate->_Sol[3]->set(iel_metis,1.); } } @@ -157,11 +157,13 @@ void MeshRefinement::FlagOnlyEvenElementsToBeRefined() { //--------------------------------------------------------------------------------------------------------------- void MeshRefinement::RefineMesh(const unsigned & igrid, Mesh *mshc, const elem_type *otherFiniteElement[6][5]) { + _mesh.SetCoarseMesh(mshc); + _mesh.SetFiniteElementPtr(otherFiniteElement); elem *elc=mshc->el; - _mesh.SetGridNumber(igrid); + _mesh.SetLevel(igrid); //_grid=igrid; @@ -297,70 +299,12 @@ void MeshRefinement::RefineMesh(const unsigned & igrid, Mesh *mshc, const elem_t _mesh._coordinate->AddSolution("AMR",DISCONTINOUS_POLYNOMIAL,ZERO,1,0); _mesh._coordinate->ResizeSolutionVector("AMR"); + + unsigned solType=2; - //build projection Matrix - unsigned thisSolType=2; - if(_mesh._coordinate->_ProjMatFlag[thisSolType]==0){ - _mesh._coordinate->_ProjMatFlag[thisSolType]=1; - - int nf = _mesh.MetisOffset[thisSolType][_nprocs]; - int nc = mshc->MetisOffset[thisSolType][_nprocs]; - int nf_loc = _mesh.own_size[thisSolType][_iproc]; - int nc_loc = mshc->own_size[thisSolType][_iproc]; - - //build matrix sparsity pattern size for efficient storage - - NumericVector *NNZ_d = NumericVector::build().release(); - NNZ_d->init(*_mesh._coordinate->_Sol[0]); - NNZ_d->zero(); - - NumericVector *NNZ_o = NumericVector::build().release(); - NNZ_o->init(*_mesh._coordinate->_Sol[0]); - NNZ_o->zero(); - - for(int isdom=_iproc; isdom<_iproc+1; isdom++) { - for (int iel_mts=mshc->IS_Mts2Gmt_elem_offset[isdom];iel_mts < mshc->IS_Mts2Gmt_elem_offset[isdom+1]; iel_mts++) { - unsigned iel = mshc->IS_Mts2Gmt_elem[iel_mts]; - if(mshc->el->GetRefinedElementIndex(iel)){ //only if the coarse element has been refined - short unsigned ielt=mshc->el->GetElementType(iel); - _mesh._finiteElement[ielt][thisSolType]->GetSparsityPatternSize(_mesh, *mshc, iel, NNZ_d, NNZ_o); - } - } - } - NNZ_d->close(); - NNZ_o->close(); - - unsigned offset = _mesh.MetisOffset[thisSolType][_iproc]; - vector nnz_d(nf_loc); - vector nnz_o(nf_loc); - for(int i=0; i ((*NNZ_d)(offset+i)); - nnz_o[i]=static_cast ((*NNZ_o)(offset+i)); - } - - delete NNZ_d; - delete NNZ_o; - - //build matrix - _mesh._coordinate->_ProjMat[thisSolType] = SparseMatrix::build().release(); - _mesh._coordinate->_ProjMat[thisSolType]->init(nf,nc,nf_loc,nc_loc,nnz_d,nnz_o); - // loop on the coarse grid - for(int isdom=_iproc; isdom<_iproc+1; isdom++) { - for (int iel_mts=mshc->IS_Mts2Gmt_elem_offset[isdom]; - iel_mts < mshc->IS_Mts2Gmt_elem_offset[isdom+1]; iel_mts++) { - unsigned iel = mshc->IS_Mts2Gmt_elem[iel_mts]; - if( mshc->el->GetRefinedElementIndex(iel)){ //only if the coarse element has been refined - short unsigned ielt= mshc->el->GetElementType(iel); - _mesh._finiteElement[ielt][thisSolType]->BuildProlongation(_mesh,*mshc,iel,_mesh._coordinate->_ProjMat[thisSolType]); - } - } - } - _mesh._coordinate->_ProjMat[thisSolType]->close(); - } - - _mesh._coordinate->_Sol[0]->matrix_mult(*mshc->_coordinate->_Sol[0],*_mesh._coordinate->_ProjMat[thisSolType]); - _mesh._coordinate->_Sol[1]->matrix_mult(*mshc->_coordinate->_Sol[1],*_mesh._coordinate->_ProjMat[thisSolType]); - _mesh._coordinate->_Sol[2]->matrix_mult(*mshc->_coordinate->_Sol[2],*_mesh._coordinate->_ProjMat[thisSolType]); + _mesh._coordinate->_Sol[0]->matrix_mult(*mshc->_coordinate->_Sol[0],*_mesh.GetCoarseToFineProjection(solType)); + _mesh._coordinate->_Sol[1]->matrix_mult(*mshc->_coordinate->_Sol[1],*_mesh.GetCoarseToFineProjection(solType)); + _mesh._coordinate->_Sol[2]->matrix_mult(*mshc->_coordinate->_Sol[2],*_mesh.GetCoarseToFineProjection(solType)); _mesh._coordinate->_Sol[0]->close(); _mesh._coordinate->_Sol[1]->close(); _mesh._coordinate->_Sol[2]->close(); diff --git a/src/mesh/MultiLevelMesh.cpp b/src/mesh/MultiLevelMesh.cpp index 616089ef6..0b0722090 100644 --- a/src/mesh/MultiLevelMesh.cpp +++ b/src/mesh/MultiLevelMesh.cpp @@ -2,7 +2,7 @@ Program: FEMUS Module: MultiLevelMesh - Authors: Simone Bnà, Eugenio Aulisa + Authors: Simone Bnà, Eugenio Aulisa, Giorgio Bornia Copyright (c) FEMTTU All rights reserved. @@ -23,6 +23,7 @@ #include "NumericVector.hpp" #include "FemusConfig.hpp" #include "MeshRefinement.hpp" +#include "Domain.hpp" //C++ include @@ -35,21 +36,24 @@ using std::cout; using std::endl; MultiLevelMesh::~MultiLevelMesh() { - for (unsigned i=0; i<_gridn0; i++) { + + for (unsigned i=0; i<_level0.size(); i++) { delete _level0[i]; } + for(unsigned i=0;i<6;i++){ - if(i==5 || _finiteElementGeometryFlag[i]) + if( _finiteElementGeometryFlag[i]) for(unsigned j=0;j<5;j++){ delete _finiteElement[i][j]; } } -}; + +} //--------------------------------------------------------------------------------------------------- -MultiLevelMesh::MultiLevelMesh() { +MultiLevelMesh::MultiLevelMesh(): _gridn0(0),_gridr0(0) { - _finiteElementGeometryFlag.resize(5,false); + _finiteElementGeometryFlag.resize(6,false); for(int i=0; i<6; i++) { for(int j=0; j<5; j++) { @@ -96,23 +100,25 @@ MultiLevelMesh::MultiLevelMesh() { _finiteElement[4][3]=new const elem_type_2D("tri","constant",GaussOrder); _finiteElement[4][4]=new const elem_type_2D("tri","disc_linear",GaussOrder); } - + _finiteElementGeometryFlag[5]=1; _finiteElement[5][0]=new const elem_type_1D("line","linear",GaussOrder); _finiteElement[5][1]=new const elem_type_1D("line","quadratic",GaussOrder); _finiteElement[5][2]=new const elem_type_1D("line","biquadratic",GaussOrder); _finiteElement[5][3]=new const elem_type_1D("line","constant",GaussOrder); _finiteElement[5][4]=new const elem_type_1D("line","disc_linear",GaussOrder); - _level0[0]->SetFiniteElementPtr(_finiteElement); + _level0[0]->SetFiniteElementPtr(_finiteElement); } //--------------------------------------------------------------------------------------------------- -MultiLevelMesh::MultiLevelMesh(const unsigned short &igridn,const unsigned short &igridr, const char mesh_file[], const char GaussOrder[], - const double Lref, bool (* SetRefinementFlag)(const double &x, const double &y, const double &z, - const int &ElemGroupNumber,const int &level)): +MultiLevelMesh::MultiLevelMesh(const unsigned short &igridn,const unsigned short &igridr, + const char mesh_file[], const char GaussOrder[], const double Lref, + bool (* SetRefinementFlag)(const double &x, const double &y, const double &z, + const int &ElemGroupNumber,const int &level) ): _gridn0(igridn), _gridr0(igridr) { + _level0.resize(_gridn0); _finiteElementGeometryFlag.resize(5,false); @@ -121,7 +127,7 @@ MultiLevelMesh::MultiLevelMesh(const unsigned short &igridn,const unsigned short std::cout << " Reading corse mesh from file: " << mesh_file << std::endl; _level0[0]->ReadCoarseMesh(mesh_file, Lref,_finiteElementGeometryFlag); - BuildElemType(GaussOrder); + BuildElemType(GaussOrder); //totally refined meshes for (unsigned i=1; i<_gridr0; i++) { @@ -212,9 +218,9 @@ void MultiLevelMesh::GenerateCoarseBoxMesh( std::cout << " Building brick mesh using the built-in mesh generator" << std::endl; _level0[0]->GenerateCoarseBoxMesh(nx,ny,nz,xmin,xmax,ymin,ymax,zmin,zmax,type,_finiteElementGeometryFlag); - + BuildElemType(GaussOrder); - + _gridn=_gridn0; _gridr=_gridr0; _level.resize(_gridn); @@ -297,12 +303,10 @@ void MultiLevelMesh::AddMeshLevel() MeshRefinement meshcoarser(*_level0[_gridn0-1u]); meshcoarser.FlagElementsToBeRefinedByUserDefinedFunction(); - //_level0[_gridn0-1u]->FlagElementsToBeRefinedByUserDefinedFunction(); _level0[_gridn0] = new Mesh(); MeshRefinement meshfiner(*_level0[_gridn0]); meshfiner.RefineMesh(_gridn0,_level0[_gridn0-1u],_finiteElement); - //_level0[_gridn0]->RefineMesh(_gridn0,_level0[_gridn0-1u],_finiteElement); _level.resize(_gridn+1u); _level[_gridn]=_level0[_gridn0]; @@ -319,12 +323,10 @@ void MultiLevelMesh::AddAMRMeshLevel() MeshRefinement meshcoarser(*_level0[_gridn0-1u]); meshcoarser.FlagElementsToBeRefinedByAMR(); - //_level0[_gridn0-1u]->FlagElementsToBeRefinedByAMR(); _level0[_gridn0] = new Mesh(); MeshRefinement meshfiner(*_level0[_gridn0]); meshfiner.RefineMesh(_gridn0,_level0[_gridn0-1u],_finiteElement); - //_level0[_gridn0]->RefineMesh(_gridn0,_level0[_gridn0-1u],_finiteElement); _level.resize(_gridn+1u); _level[_gridn]=_level0[_gridn0]; @@ -344,8 +346,8 @@ void MultiLevelMesh::EraseCoarseLevels(unsigned levels_to_be_erased) { _gridr -= levels_to_be_erased; _gridn -= levels_to_be_erased; for(int i=0; i<_gridn; i++) { - _level[i]=_level0[i+levels_to_be_erased]; - _level[i]->SetGridNumber(i); + _level[i]=_level0[i+levels_to_be_erased]; + _level[i]->SetLevel(i); } } @@ -361,11 +363,30 @@ void MultiLevelMesh::MarkStructureNode() { void MultiLevelMesh::PrintInfo() { std::cout << " Number of uniform mesh refinement: " << _gridn << std::endl; for(int i=0; i<_gridn; i++) { - _level[i]->PrintInfo(); + _level[i]->PrintInfo(); } } - + /** Get the dimension of the problem (1D, 2D, 3D) from one Mesh (level 0 always exists, after initialization) */ + const unsigned MultiLevelMesh::GetDimension() const { + return _level0[LEV_PICK]->GetDimension(); + } + +// ======================================================== + void MultiLevelMesh::SetDomain(Domain* domain_in) { + + _domain = domain_in; + + return; + } + + // ======================================================== + Domain* MultiLevelMesh::GetDomain() const { + + return _domain; + + } + } //end namespace femus diff --git a/src/mesh/MultiLevelMesh.hpp b/src/mesh/MultiLevelMesh.hpp index e97257741..553c33311 100644 --- a/src/mesh/MultiLevelMesh.hpp +++ b/src/mesh/MultiLevelMesh.hpp @@ -2,7 +2,7 @@ Program: FEMUS Module: MultiLevelMesh -Authors: Eugenio Aulisa, Simone Bnà +Authors: Eugenio Aulisa, Simone Bnà, Giorgio Bornia Copyright (c) FEMUS All rights reserved. @@ -17,8 +17,11 @@ PURPOSE. See the above copyright notice for more information. #define __femus_mesh_MultiLevelMesh_hpp__ -#include "ElemTypeEnum.hpp" #include +#include "ElemTypeEnum.hpp" +#include "GeomElTypeEnum.hpp" +#include "WriterEnum.hpp" +#include "Writer.hpp" namespace femus { @@ -28,7 +31,7 @@ namespace femus { //------------------------------------------------------------------------------ class elem_type; class Mesh; - +class Domain; /** * This class is a black box container to handle multilevel mesh. @@ -38,7 +41,7 @@ class MultiLevelMesh { public: - /** Constructors */ + /** Constructor */ MultiLevelMesh(); MultiLevelMesh(const unsigned short &igridn,const unsigned short &igridr, @@ -100,21 +103,43 @@ class MultiLevelMesh { // data const elem_type *_finiteElement[6][5]; + + /** To be Added */ + const Writer* GetWriter() const {return _writer; } + /** To be Added */ + void SetWriter(const WriterEnum format) { _writer = Writer::build(format,this).release(); } + + /** Get the dimension of the problem (1D, 2D, 3D) */ + const unsigned GetDimension() const; + + /** Domain (optional) */ + Domain* GetDomain() const; + + /** Domain (optional) */ + void SetDomain(Domain* ); + protected: private: - + void BuildElemType(const char GaussOrder[]); - // data + /** */ unsigned short _gridn0, _gridr0; unsigned short _gridn, _gridr; + /** Array of mesh */ std::vector _level0; std::vector _level; - std::vector _finiteElementGeometryFlag; + std::vector _finiteElementGeometryFlag; + + /** MultilevelMesh writer */ + Writer* _writer; + + /** Domain (optional) */ + Domain* _domain; }; diff --git a/src/mesh/SalomeIO.cpp b/src/mesh/SalomeIO.cpp new file mode 100644 index 000000000..09ad633c1 --- /dev/null +++ b/src/mesh/SalomeIO.cpp @@ -0,0 +1,470 @@ +/*========================================================================= + + Program: FEMUS + Module: SalomeIO + Authors: Sureka Pathmanathan, Giorgio Bornia + + Copyright (c) FEMTTU + All rights reserved. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + +=========================================================================*/ + +//local include +#include "SalomeIO.hpp" +#include "Mesh.hpp" + +//C++ include +#include +#include +#include + + +namespace femus { + + const std::string SalomeIO::group_name_begin = "FAS"; + const std::string SalomeIO::group_name_end = "ELEME"; + const std::string SalomeIO::mesh_ensemble = "ENS_MAA"; + const std::string SalomeIO::aux_zeroone = "-0000000000000000001-0000000000000000001"; + const std::string SalomeIO::connectivity = "MAI"; + const std::string SalomeIO::node_coord = "NOE/COO"; + const uint SalomeIO::max_length = 100; ///@todo this length of the menu string is conservative enough... + + + + const unsigned SalomeIO::SalomeToFemusVertexIndex[6][27]= + { + { + 4,16,0,15,23,11,7,19,3, + 12,20,8,25,26,24,14,22,10, + 5,17,1,13,21,9,6,18,2 + }, + { + 0,4,1,6,5, + 2,7,8,9,3 + }, + { + 3, 11,5, 9, 10,4, + 12,17,14,15,16,13, + 0, 8, 2, 6, 7, 1 + }, + {0,4,1,5,2,6,3,7,8}, + {0,3,1,4,2,5}, + {0,2,1} + }; + + +const unsigned SalomeIO::SalomeToFemusFaceIndex[6][6]= + { + {0,4,2,5,3,1}, + {0,1,2,3}, + {2,1,0,4,3}, + {0,1,2,3}, + {0,1,2}, + {0,1} + }; + + /// @todo extend to Wegdes (aka Prisms) +void SalomeIO::read(const std::string& name, vector < vector < double> > &coords, const double Lref, std::vector &type_elem_flag) { + + Mesh& mesh = GetMesh(); + mesh.SetLevel(0); + + hsize_t dims[2]; + + hid_t file_id = H5Fopen(name.c_str(),H5F_ACC_RDWR, H5P_DEFAULT); + + hid_t gid = H5Gopen(file_id,mesh_ensemble.c_str(),H5P_DEFAULT); + + hsize_t n_menus; + hid_t status= H5Gget_num_objs(gid, &n_menus); // number of menus + if(status !=0) { std::cout << "Number of mesh menus not found"; abort(); } + + std::vector itype_vol; + itype_vol.resize(n_menus); + menu_names.resize(n_menus); + for (unsigned j=0; jSetElementGroup(iel,1); + unsigned nve = Node_el; /// @todo this is only one element type + if (nve==27) { + type_elem_flag[0]=type_elem_flag[3]=true; + mesh.el->AddToElementNumber(1,"Hex"); + mesh.el->SetElementType(iel,0); + } else if (nve==10) { + type_elem_flag[1]=type_elem_flag[4]=true; + mesh.el->AddToElementNumber(1,"Tet"); + mesh.el->SetElementType(iel,1); + } else if (nve==18) { + type_elem_flag[2]=type_elem_flag[3]=type_elem_flag[4]=true; + mesh.el->AddToElementNumber(1,"Wedge"); + mesh.el->SetElementType(iel,2); + } else if (nve==9) { + type_elem_flag[3]=true; + mesh.el->AddToElementNumber(1,"Quad"); + mesh.el->SetElementType(iel,3); + } + else if (nve==6 && mesh.GetDimension()==2) { + type_elem_flag[4]=true; + mesh.el->AddToElementNumber(1,"Triangle"); + mesh.el->SetElementType(iel,4); + } + else if (nve==3 && mesh.GetDimension()==1) { + mesh.el->AddToElementNumber(1,"Line"); + mesh.el->SetElementType(iel,5); + } else { + std::cout<<"Error! Invalid element type in reading File!"<GetElementType(iel)][i]; + mesh.el->SetElementVertexIndex(iel,inode,conn_map5[iel+i*n_elements]); + } + } + +// // // // // // // Adding Connectivity to mesh structure (Libmesh) +// // // // // mesh.reserve_elem(n_elements); +// // // // // // read the elements +// // // // // for(int iel=0; iel<(int)n_elements; ++iel) { +// // // // // // add the elements to the mesh +// // // // // Elem* elem = mesh.add_elem(Elem::build(eletype.type).release()); +// // // // // // add node pointers to the elements +// // // // // for(int i=0; iset_node(eletype.nodes[i])= mesh.node_ptr(conn_map[Node_el*iel+i]); +// // // // // elem->set_node(eletype.nodes[i])= mesh.node_ptr(conn_map5[iel+i*n_elements]-1); +// // // // // } +// // // // // } + + // // end read ELEMENT/CELL **************** B + + + + +// // read GROUP **************** E + +// // end read GROUP **************** E + + +// // read boundary **************** D + +// // end read boundary **************** D + + + // clean + delete [] conn_map5; + + } + +//end menu names ********************************************************** +//end menu names ********************************************************** +//end menu names ********************************************************** + + + for (unsigned j=0; jSetElementGroupNumber(ngroup); +// for (unsigned k=0; k> str2; +// inf >> str2 >> str2 >> ngel >> str2 >> mat >>str2 >> str2 >>name>> str2; +// for (int i=0; i> iel; +// mesh.el->SetElementGroup(iel-1,name); +// mesh.el->SetElementMaterial(iel-1,mat); +// } +// inf >> str2; +// if (str2.compare("ENDOFSECTION") != 0) { +// std::cout<<"error group data mesh"<> str2; +// inf >> str2; +// int value; +// unsigned nface; +// inf >>value>>str2>>nface>>str2>>str2; +// value=-value-1; +// for (unsigned i=0; i>iel>>str2>>iface; +// iel--; +// iface=SalomeIO::GambitToFemusFaceIndex[mesh.el->GetElementType(iel)][iface-1u]; +// mesh.el->SetFaceElementIndex(iel,iface,value); +// } +// inf >> str2; +// if (str2.compare("ENDOFSECTION") != 0) { +// std::cout<<"error boundary data mesh"< fem_type_vol;// Salome fem table name (vol) + fem_type_vol["HE8"] = 5; fem_type_vol["H20"] = 20; fem_type_vol["H27"] = 12; + fem_type_vol["TE4"] = 4; fem_type_vol["T10"] = 11; + fem_type_vol["QU4"] = 3; fem_type_vol["QU8"] = 19; fem_type_vol["QU9"] = 10; + fem_type_vol["TR3"] = 2; fem_type_vol["TR6"] = 9; + fem_type_vol["SE2"] = 0; fem_type_vol["SE3"] = 0; // not valid in 3D + if(mesh.GetDimension()==3) { // not valid in 3D as boundary + fem_type_vol["QU4"] = 0; fem_type_vol["QU8"] = 0; fem_type_vol["QU9"] = 0; + fem_type_vol["TR3"] = 0; fem_type_vol["TR6"] = 0; + } + std::map< std::string, int > fem_type_bd; // Salome fem table name (surface) + fem_type_bd["HE8"] = 0; fem_type_bd["H20"] = 0; fem_type_bd["H27"] = 0; + fem_type_bd["TE4"] = 0; fem_type_bd["T10"] = 0; // not valid in 2D + fem_type_bd["QU4"] = 3; fem_type_bd["QU8"] = 19; fem_type_bd["QU9"] = 10; + fem_type_bd["TR3"] = 2; fem_type_bd["TR6"] = 9; + fem_type_bd["SE2"] = 1; fem_type_bd["SE3"] = 8; + if(mesh.GetDimension()==3) { // not valid in 3D as boundary + fem_type_bd["SE2"] = 0; fem_type_bd["SE3"] = 0; + } + + + // Get the element name from MESH_NAME_DIR in the file med (el_name) + char **el_fem_type = new char*[n_fem_type]; + int index_vol=0; int index_bd=0; + for(int i=0; i<(int)n_fem_type; i++) { + el_fem_type[i]=new char[4]; + H5Lget_name_by_idx(file_id,my_mesh_name_dir.c_str(), H5_INDEX_NAME, H5_ITER_INC,i,el_fem_type[i],4, H5P_DEFAULT); + if(fem_type_vol[el_fem_type[i]]!=0) index_vol=i; + if(fem_type_bd[el_fem_type[i]]!=0) index_bd=i; + } + + // LIBMESH volume fem type (itype_vol) and MEDfem (el_fem_type_vol-el_fem_type_bd) + int itype_vol= fem_type_vol[el_fem_type[index_vol]]; assert(itype_vol!=0); + el_fem_type_vol=el_fem_type[index_vol]; + el_fem_type_bd=el_fem_type[index_bd]; + // clean + for(int i=0; i<(int)n_fem_type; i++) delete[] el_fem_type[i]; + delete[] el_fem_type; + fem_type_vol.clear(); + fem_type_bd.clear(); + + return itype_vol; +} + + +void SalomeIO::FindDimension(hid_t gid, const std::string menu_name, hsize_t n_fem_type) { + + + Mesh& mesh = GetMesh(); + uint mydim = 1; //this is the initial value, then it will be updated below + mesh.SetDimension(mydim); + + + std::vector elem_list; elem_list.resize(n_fem_type); + for (unsigned j=0; j < elem_list.size(); j++) { + elem_list[j] = new char[max_length]; + H5Gget_objname_by_idx(gid,j,elem_list[j],max_length); ///@deprecated see the HDF doc to replace this + std::string tempj(elem_list[j]); + + if ( tempj.compare("HE8") == 0 || + tempj.compare("H20") == 0 || + tempj.compare("H27") == 0 || + tempj.compare("TE4") == 0 || + tempj.compare("T10") == 0 ) { mydim = 3; } + else if ( tempj.compare("QU4") == 0 || + tempj.compare("QU8") == 0 || + tempj.compare("QU9") == 0 || + tempj.compare("TR3") == 0 || + tempj.compare("TR6") == 0 ) { mydim = 2; } + + if ( mydim > mesh.GetDimension() ) mesh.SetDimension(mydim); + + } //end for + + + return; +} + + + + + + +} //end namespace femus + diff --git a/src/mesh/SalomeIO.hpp b/src/mesh/SalomeIO.hpp new file mode 100644 index 000000000..97410af89 --- /dev/null +++ b/src/mesh/SalomeIO.hpp @@ -0,0 +1,91 @@ +/*========================================================================= + + Program: FEMUS + Module: SalomeIO + Authors: Sureka Pathmanathan, Giorgio Bornia + + Copyright (c) FEMTTU + All rights reserved. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + +=========================================================================*/ + +#ifndef __femus_mesh_SalomeIO_hpp__ +#define __femus_mesh_SalomeIO_hpp__ + + +// Local includes +#include "MeshInput.hpp" +#ifdef HAVE_HDF5 + #include "hdf5.h" +#endif + +namespace femus +{ + +// Forward declarations +class Mesh; + +/** + * This class implements writing meshes in the Gmsh format. + */ + +// ------------------------------------------------------------ +// GMVIO class definition +class SalomeIO : public MeshInput +{ + public: + + /** + * Constructor. Takes a non-const Mesh reference which it + * will fill up with elements via the read() command. + */ + explicit + SalomeIO (Mesh& mesh); + + /** + * Reads in a mesh in the neutral gambit *.neu format + * from the ASCII file given by name. + * + */ + virtual void read (const std::string& name, vector < vector < double> > &coords, const double Lref, std::vector &type_elem_flag); + + private: + + /** Map from Salome vertex index to Femus vertex index */ + static const unsigned SalomeToFemusVertexIndex[6][27]; + + /** Map from Salome face index to Femus face index */ + static const unsigned SalomeToFemusFaceIndex[6][6]; + + /** Determine mesh dimension from mesh file */ + void FindDimension(hid_t gid, const std::string menu_name,hsize_t n_fem_type); + + /** Read FE type */ + int ReadFE(hid_t file_id, std::string & el_fem_type_vol, std::string & el_fem_type_bd, const std::string menu_name); + + std::vector menu_names; + static const std::string group_name_begin; //FAS + static const std::string group_name_end; //ELEME + static const std::string mesh_ensemble; // ENS_MAA + static const std::string aux_zeroone; // -0000000000000000001-0000000000000000001 + static const std::string connectivity; // MAI + static const std::string node_coord; //NOE/COO + static const uint max_length; + +}; + + +inline +SalomeIO::SalomeIO (Mesh& mesh) : + MeshInput (mesh) +{ +} + + +} // namespace femus + +#endif \ No newline at end of file diff --git a/src/meshGencase/GenCase.cpp b/src/meshGencase/GenCase.cpp index cf64849e0..60d437b17 100644 --- a/src/meshGencase/GenCase.cpp +++ b/src/meshGencase/GenCase.cpp @@ -34,8 +34,8 @@ using namespace libMesh; namespace femus { // ======================================================== -GenCase::GenCase(const FemusInputParser & map_in, const std::string mesh_file_in) - : MultiLevelMeshTwo(map_in,mesh_file_in) +GenCase::GenCase(const unsigned nolevels, const unsigned dim, const GeomElType geomel_type, const std::string mesh_file_in) + : MultiLevelMeshTwo(nolevels,dim,geomel_type,mesh_file_in) { _feelems.resize(QL); @@ -130,7 +130,7 @@ void GenCase::GenerateCoarseMesh() const { std::clock_t start_timeA=std::clock(); #endif - std::string config_dir = DEFAULT_CONFIGDIR; + std::string config_dir = DEFAULT_INPUTDIR; std::string f_mesh_read = _mesh_file; std::ostringstream mesh_infile; @@ -2114,6 +2114,830 @@ void GenCase::ComputeMaxElXNode() { } +// ========================================= +void GenCase::ReadMGOps(const std::string output_path, const SystemTwo * mysys) { + + std::string f_matrix = DEFAULT_F_MATRIX; + std::string f_rest = DEFAULT_F_REST; + std::string f_prol = DEFAULT_F_PROL; + std::string ext_h5 = DEFAULT_EXT_H5; + + std::ostringstream filename; + std::string filename_base; + filename_base = output_path + "/"; + + filename.str(""); filename << filename_base << f_rest << ext_h5; + ReadRest(filename.str(),mysys); + + filename.str(""); filename << filename_base << f_matrix << ext_h5; + ReadMatrix(filename.str(),mysys); + + filename.str(""); filename << filename_base << f_prol << ext_h5; + ReadProl(filename.str(),mysys); + + return; +} + + + +//============================= +//This function depends on _iproc +//remember that a new does not vanish when inside a for loop, +//because the variable was declared outside +// it is NOT like a DECLARATION INSIDE + +//The point is that now we must be ready to READ the matrix, +//also the part with CONSTANT ELEMENTS. +//so we have to figure out how to put all the things together. +//basically we need to remember that we have a bunch of +// quantities that may be QQ, LL, KK, +// so eventually we'll have a certain number of QQ, LL and KK +//now, we simply have to decide HOW to ADD THEM in the MATRIX. +// so far, I think we can decide to put +//FIRST all the QQ, then LL, then KK. + +// The DofMap was already initialized much earlier than now. +// As a matter of fact, it was needed for setting the BC flags +// It would be nice not to have a lot of places where _Dim is recomputed... + +// initDofDim +// initDof +// initVectors + +//The GRAPH, or SPARSITY PATTERN, with PETSC functions can be filled JUST WITH ZEROS; +//but with LASPACK you need do put the DOF VALUES INSIDE. + +// so, I got an error that seems to tell me that I basically didn't fill the graph +//correctly. It seems like one processor fills it and the other ones do not, +//half of the lines seem to be unfilled. + +///@todo the std::cerr is not redirected to file, think of redirecting it also to file. +// The idea is that every output to terminal must be redirected to file. +// so printf must not be used + +// Every processor will call this function + +//Now, the dimension of "graph" is global, +// so it is the dimension of the whole + +//TODO: idea about SYNCHRONIZING OUTPUTS. +//I would really like all the outputs OF ALL THE LIBRARIES (HFD5, PETSC, MPI, LIBMESH) involved in FEMuS +//to be REDIRECTED to run_log, altogether. +//What is the best way to make it possible? +//I guess from shell, in principle. The point is how to generate the string for the time for the folder! +// I should use bash functions, make an environment variable, and let all the processes read that environment variable. +// And also, i would like to be able to choose whether to DUPLICATE them, +// so both to file and to std output, or only to file, or the other cases. + +//I need to have the TIME STRING. Bash has the date() function, I want to have it my way +//OK, THAT'S IT: date +%Y_%m_%d-%H_%M_%S + + + //TODO what is this mlinit used for?!? + // it is used to determine with WHAT DOF NUMBER the CURRENT PROCESSOR _iproc BEGINS. + // NOTICE THAT THE _NODE_DOF MAP IS FILLED COMPLETELY BY ALL PROCESSORS, + // BUT HERE IT IS READ IN PARALLEL BY EACH SEPARATE PROCESSOR !!! + //THEREFORE EACH PROCESSOR WILL START WITH ITS OWN INITIAL_DOF AND FINISH WITH ITS OWN FINAL_DOF. + //The difference between NODES and ELEMENTS is that for nodes + // we keep the offset as the FINEST NODES, because somehow + //we have to keep the correspondence with the NODES OF THE MESH, + //especially when we have to PRINT ON THE MESH + //as a matter of fact, we have to bring everything to the FINE MESH + //so we can view what happens on the FINE MESH + //every processor will fill QUADRATIC, LINEAR and CONSTANT DOFS + //being that these dofs belong to a given processor, they will be CONTIGUOUS in the matrix + // So you'll have + + // QQ LL KK || QQ LL KK || QQ LL KK + //< proc0 >||< proc1 >||< proc2 > + + // Now, consider the level to be FROZEN, we concentrate on the SUBDOMAINS + // Every processor will begin filling the rows at some point. + // Every processor has a range of rows, which is mrow_lev_proc_t + // Within this range you'll have to put QQ, LL and KK dofs + //so within this range you'll have a number of dofs for every fe given by mrow_lev_proc[r], + // of course each of them being multiplied by the number of variables of that type + // Now, you have to compare how you EXPLORE the NODE_DOF MAP and the MATRIX ROWS + //the node_dof map is basically separated into OFFSETS of GEOMETRICAL ENTITIES, + //so these ranges are BASED ON THE MESH GEOMETRICAL ENTITIES. + // every GEOMETRICAL ENTITY (NODE or ELEMENT) can have ONE OR MORE ASSOCIATED DOFS. + //NODES CAN HAVE QUADRATIC DOFS or LINEAR DOFS associated + //ELEMENTS CAN HAVE CONSTANT DOFS associated. + //so, the node dof is constructed by picking + // FIRST NODE QUADRATIC DOFS, for all the quadratic unknowns of the system + // THEN NODE LINEAR DOFS, for all the linear unknowns of the system + // THEN ELEMENT CONSTANT DOFS, for all the constant unknowns of the system + // so "QUADRATIC NODES" can be defined as "NODES to which QUADRATIC VARIABLES are associated", + // "LINEAR NODES" means "NODES to which LINEAR variables are associated" + // ELEMENTS are "GEOMETRICAL ENTITIES to which CONSTANT variables are associated" + // So the node dof is divided by + // "GEOMETRICAL ENTITIES for QUADRATIC DOFS" = "QUADRATIC NODES", the length of which must be multiplied by the "NUMBER OF QUADRATIC DOF VARIABLES" + // "GEOMETRICAL ENTITIES for LINEAR DOFS" = "LINEAR NODES", the length of which must be multiplied by the "NUMBER OF LINEAR DOF VARIABLES" + // "GEOMETRICAL ENTITIES for CONSTANT DOFS" = "ELEMENTS" the length of which must be multiplied by the "NUMBER OF CONSTANT DOF VARIABLES" + //This of course assumes that every GEOMETRICAL ENTITY has the SAME NUMBER of ASSOCIATED DOFS for every FE type. + //So you may say that the node_dof is ordered by GEOMETRICAL ENTITIES first, and WITHIN EACH GEOMETRICAL ENTITY you find ALL THE VARIABLES of THAT FE TYPE. + // This is because actually we have a ONE-TO-ONE CORRESPONDENCE between GEOMETRICAL ENTITY and ASSOCIATED DOF. + // In a sense, we start with a given DOF family, and, going backwards, we ask ourselves "WHAT IS THE SET OF GEOMETRICAL ENTITIES NATURALLY ASSOCIATED to THIS DOF FE Family?" + //For instance, we might have QUAD8 and QUAD9, and associate BOTH OF THEM to a "QUAD9 NODES".In that case we would have EMPTY points, + // and it is actually the same that happens when we have the LINEAR DOF FAMILY and we decide to associate the "QUADRATIC MESH NODES" to it for various reasons: multigrid, parallel computing, etc...) + //So our current situation is: + // QUADRATIC FE DOFS ---> QUADRATIC MESH NODES (at the FINE level) + // LINEAR FE DOFS ---> QUADRATIC MESH NODES (at the FINE level) + // CONSTANT FE DOFS ---> MESH ELEMENTS (at the CURRENT level) + //So, we see that for various reasons we may actually have EMPTY SPACES for two reasons: + // 1) BECAUSE we are at some level which is NOT THE FINE + // 2) even at the FINE Level, we have LINEAR FINE DOFS built on top of QUADRATIC FINE NODES + + //so, _nvars[QQ] is the number of QUADRATIC FE variables + + //NOW, THE POINT IS THIS: FOR EVERY SUBDOMAIN, Do we want to have ALL DOFS CONTIGUOUS or NOT? + //Yes, of course we want, so in the same subdomain we would have QUADRATIC DOFS, THEN LINEAR DOFS, THEN CONSTANT DOFS. + //Otherwise, we would have that dofs of the SAME SUBDOMAIN are DISJOINT. + //Keeping all the dofs of the same subdomain CONTIGUOUS, the equations do not change, they will be the same, + // but in this way we will have AS FEW OFF-PROCESSOR COLUMNS as POSSIBLE! + // So, we do need to BUILD the NODE-DOF MAP APPROPRIATELY for the PARALLEL CASE! + //Of course, in a SERIAL ENVIRONMENT everything works fine + +//======================= +//The dimension of the Graph is the total number of rows +// This Graph is the TOTAL GRAPH for ALL THE MATRIX +//The Graph is basically a std::VECTOR of std::VECTORS, +// therefore you can use the resize() function both on graph and on graph[]. +//Also, by the way, with std::vectors you have the overloading of the operator[] +//===================== + +// Now, the point is: What is mlinit[]? +// Now, based on the mesh Node and Element numbering, we built the node_dof map. +//Now we have to Read the ONE-VARIABLE-MATRICES for EVERY LEVEL, +//and USE THEM to BUILD THE WHOLE MATRIX WITH ALL THE VARIABLES and SO ON. +//Now, we already know how the dof map is. So we gave a number to every dof. +// So after doing the NODE ORDERING and ELEMENT ORDERING (VV and BB) in the GENCASE, +// now it is time to use those orderings consequently and have the +//DOF ORDERING. +//The node map was built in such a way that ALL the DOFS associated to DofObjects (Elems or Nodes) +//of a given subdomain be CONTIGUOUS in the DOF ROW INDEXING. +//Now, given this DOF ORDERING, every PROCESSOR WILL TAKE CARE of ITS OWN DOFS, +// which are contiguous by construction of the node_dof map; +// therefore every processor will pick that block of contiguous row numbers +// and to each of them it will associate the corresponding LENGTH and OFFLENGTH + +// Notice how GRAPH has GLOBAL dimension, but SINCE THIS READ MATRIX is PARALLEL, +//Then each processor will fill only PART OF IT. So, actually it makes no sense to make graph be GLOBAL +// and then have each processor only fill one part of it. + +//ReadMatrix NEEDS the NODE_DOF to be filled BEFORE + //Now, we have to understand these steps: + //1) How we GENERATE the SINGLE DOF VARIABLE sparsity pattern in Gencase; + //2) How we BUILD the NODE_DOF MAP in PARALLEL based on these SINGLE VARIABLE SPARSITY PATTERNS; + //3) How we READ the MATRIX SPARSITY PATTERNS and COMBINE THEM WITH the NODE_DOF. + + //Basically, you have to COMBINE the "DOFS" (Matrix.h5) with the "MESH" (mesh.h5). + +// The node_dof of course takes into account the NUMBER of VARIABLES for each FE type +// So, if the node_dof was not filled correctly, then when you + + +void GenCase::ReadMatrix(const std::string& namefile, const SystemTwo * mysys) { + + for (uint Level = 0; Level< mysys->GetGridn(); Level++) { + + std::ostringstream groupname_lev; groupname_lev << "LEVEL" << Level; + + uint*** rowcln; //number of rows and columns for one variable couple + uint*** length_row; //for every FE row and FE column + uint*** length_offrow; + uint*** pos_row; + + rowcln = new uint**[QL]; + length_row = new uint**[QL]; + length_offrow = new uint**[QL]; + pos_row = new uint**[QL]; + + hid_t file = H5Fopen(namefile.c_str(),H5F_ACC_RDWR, H5P_DEFAULT); + + for (int r=0;rGetMLProb().GetMeshTwo()._NoLevels; + uint off_proc = NoLevels*mysys->GetMLProb().GetMeshTwo()._iproc; + + uint mrow_glob_t = 0; + for (int fe=0; fe_dofmap._nvars[fe]*rowcln[fe][fe][0]; + uint ncol_glob_t = mrow_glob_t; + + uint mrow_lev_proc_t = 0; + for (int fe=0; fe_dofmap._DofLocLevProcFE[Level][mysys->GetMLProb().GetMeshTwo()._iproc][fe]*mysys->_dofmap._nvars[fe]; + uint ncol_lev_proc_t = mrow_lev_proc_t; + + uint DofObjInit_lev_PrevProcs[QL]; // what is this? it is the ROW INDEX at which to begin for every processor + + for (int r=0; rGetMLProb().GetMeshTwo()._iproc; isubd++) { + DofObjInit_lev_PrevProcs[QQ] += mysys->_dofmap._DofLocLevProcFE[Level][isubd][QQ]; + DofObjInit_lev_PrevProcs[LL] += mysys->_dofmap._DofLocLevProcFE[Level][isubd][LL]; + DofObjInit_lev_PrevProcs[KK] += mysys->_dofmap._DofLocLevProcFE[Level][isubd][KK]; + } + + + mysys->_LinSolver[Level]->_KK = SparseMatrix::build().release(); +// // mysys->_LinSolver[Level]->_KK->init(_Dim[Level],_Dim[Level], mrow_lev_proc_t, mrow_lev_proc_t); ///@todo BACK TO a REASONABLE INIT + + Graph graph; + graph.resize(mrow_glob_t); + graph._m = mrow_glob_t; + graph._n = ncol_glob_t; + graph._ml = mrow_lev_proc_t; + graph._nl = ncol_lev_proc_t; + graph._ml_start = mysys->_dofmap.GetStartDof(Level,off_proc); + // TODO is this used? I guess it is used by update_sparsity_pattern ! + // Every subdomain has a local set of dofs, and these dofs start at a specific point. + // Now, remember that mysys->GetMLProb().GetMeshTwo()._off_nd[QQ] should only be used for computing offsets, so differences. + // Here, it is used ALONE, because it gives you the NODE (in femus ordering) AT WHICH THE CURRENT SUBDOMAIN BEGINS, + //and then from _node_dof[Level] (which was already constructed) you get THE LOCAL DOF AT THE CURRENT LEVEL TO START FROM. + // Clearly, pay attention when you add elements, because in that case you would need to REDO the _node_dof map !!! + //TODO: also, what happens if you have a system with ONLY ELEMENT BASED DOFS?!? + + + int FELevel[QL]; + FELevel[QQ] = Level; + FELevel[LL] = (Level+mysys->GetGridn())%(mysys->GetGridn()+1); //This is the map for the level of the LINEAR DOFS + FELevel[KK] = Level; + + int off_onevar[QL]; + off_onevar[QQ] = mysys->GetMLProb().GetMeshTwo()._NoNodesXLev[mysys->GetGridn()-1]; + off_onevar[LL] = mysys->GetMLProb().GetMeshTwo()._NoNodesXLev[mysys->GetGridn()-1]; + off_onevar[KK] = mysys->GetMLProb().GetMeshTwo()._n_elements_vb_lev[VV][Level]; + + uint off_EachFEFromStart[QL]; + off_EachFEFromStart[QQ] = 0; + off_EachFEFromStart[LL] = mysys->_dofmap._nvars[QQ]*off_onevar[QQ]; + off_EachFEFromStart[KK] = mysys->_dofmap._nvars[QQ]*off_onevar[QQ] + mysys->_dofmap._nvars[LL]*off_onevar[LL]; + + //============== + for (int r=0;r_dofmap._nvars[r]; ivar++) { + + for (uint DofObj_lev = DofObjInit_lev_PrevProcs[r]; DofObj_lev < DofObjInit_lev_PrevProcs[r] + mysys->_dofmap._DofLocLevProcFE[Level][mysys->GetMLProb().GetMeshTwo()._iproc][r]; DofObj_lev++) { + + int dof_pos, irow; + if (rGetMLProb().GetMeshTwo()._Qnode_lev_Qnode_fine[FELevel[r]][ DofObj_lev ]; } + else if (r==KK) { dof_pos = DofObj_lev; } + irow = mysys->_dofmap.GetDof(Level,r,ivar,dof_pos); + + int len[QL]; for (int c=0;c_dofmap._nvars[c]*len[c]; + graph[irow].resize(rowsize + 1); //There is a +1 because in the last position you memorize the number of offset dofs in that row + + int lenoff[QL]; for (int c=0;c_dofmap._nvars[c]*lenoff[c]; + graph[irow][rowsize] = lenoff_size; // last stored value is the number of in-matrix nonzero off-diagonal values + + } + } + } //end r + +//=========================== + std::cout << " Matrix \n"; + graph.print(); +//=========================== + + mysys->_LinSolver[Level]->_KK->update_sparsity_pattern_old(graph); + + // clean =============== + graph.clear(); + + for (int r=0;rGetGridn(); Level++) { + + uint Lev_c = Level-1; + uint Lev_f = Level; + + int FEXLevel_c[QL]; + FEXLevel_c[QQ] = Level-1; //COARSE Level for QUADRATIC + FEXLevel_c[LL] = (Level-1+mysys->GetGridn())%(mysys->GetGridn()+1); + FEXLevel_c[KK] = Level-1; //COARSE Level for CONSTANT //TODO is this used? + int FEXLevel_f[QL]; + FEXLevel_f[QQ] = Level; //FINE Level for QUADRATIC + FEXLevel_f[LL] = Level-1; // AAA look at the symmetry, this is exactly (_n_levels + Level1 + 1)%(_n_levels + 1); ! //FINE Level for LINEAR: Level1=0 means coarse linear, a finer linear is the first coarse quadratic, and so on and so on + FEXLevel_f[KK] = Level; //FINE Level for CONSTANT //TODO is this used? + + std::ostringstream groupname_lev; groupname_lev << "LEVEL" << Lev_c << "_" << Lev_f; + + int** rowcln; + int** len; + int** lenoff; + int** Prol_pos; + double** Prol_val; + + rowcln = new int*[QL]; + len = new int*[QL]; + lenoff = new int*[QL]; + Prol_pos = new int*[QL]; + Prol_val = new double*[QL]; + + hid_t file = H5Fopen(name.c_str(),H5F_ACC_RDWR, H5P_DEFAULT); //TODO do I need to open it here for every level?!? + + for (int fe=0; feGetMLProb().GetMeshTwo()._iproc*mysys->GetGridn(); + + mysys->_LinSolver[Lev_f]->_PP = SparseMatrix::build().release(); +// // // _Prl[ Lev_f ]->init(0,0,0,0); //TODO BACK TO A REASONABLE INIT + + // local matrix dimension + uint ml[QL]; uint nl[QL]; + for (int fe=0; feGetMLProb().GetMeshTwo()._off_nd[fe][off_proc + Lev_f +1] - mysys->GetMLProb().GetMeshTwo()._off_nd[fe][off_proc]; // local quadratic //COARSE (rows) + nl[fe] = mysys->GetMLProb().GetMeshTwo()._off_nd[fe][off_proc + Lev_c +1] - mysys->GetMLProb().GetMeshTwo()._off_nd[fe][off_proc]; // global quadratic //FINE QUADRATIC (cols) + } + else if (fe == KK) { + ml[fe] = mysys->GetMLProb().GetMeshTwo()._off_el[VV][off_proc + Lev_f +1] - mysys->GetMLProb().GetMeshTwo()._off_el[VV][off_proc + Lev_f]; + nl[fe] = mysys->GetMLProb().GetMeshTwo()._off_el[VV][off_proc + Lev_c +1] - mysys->GetMLProb().GetMeshTwo()._off_el[VV][off_proc + Lev_c]; + } + } + // pattern dimension + int nrowt=0;int nclnt=0; + for (int fe=0;fe_dofmap._nvars[fe]*rowcln[fe][0]; + nclnt += mysys->_dofmap._nvars[fe]*rowcln[fe][1]; + } + + Graph pattern; + pattern.resize(nrowt); + pattern._m=nrowt; + pattern._n=nclnt; + pattern._ml = 0; + pattern._nl = 0; + for (int fe=0;fe_dofmap._nvars[fe]*ml[fe]; // local _m + pattern._nl += mysys->_dofmap._nvars[fe]*nl[fe]; // local _n + } + uint ml_start = mysys->_dofmap.GetStartDof(Level,off_proc); + pattern._ml_start = ml_start; + + uint ml_init[QL]; //up to the current processor + for (int fe=0;feGetMLProb().GetMeshTwo()._iproc; isubd++) { + if (fe < KK) ml_init[fe] += mysys->GetMLProb().GetMeshTwo()._off_nd[fe][isubd*mysys->GetGridn() + Lev_f +1] - mysys->GetMLProb().GetMeshTwo()._off_nd[fe][isubd*mysys->GetGridn()]; + else if (fe == KK) ml_init[fe] += mysys->GetMLProb().GetMeshTwo()._off_el[VV][isubd*mysys->GetGridn() + Lev_f +1] - mysys->GetMLProb().GetMeshTwo()._off_el[VV][isubd*mysys->GetGridn() + Lev_f]; + } + } + + //============= POSITION ========= + for (int fe=0;fe_dofmap._nvars[fe];ivar++) { + for (unsigned int i = ml_init[fe]; i < ml_init[fe]+ml[fe]; i++) { + int dof_pos_f; + if (fe < KK) dof_pos_f = mysys->GetMLProb().GetMeshTwo()._Qnode_lev_Qnode_fine[ FEXLevel_f[fe] ][ i ]; //end fe < ql + else if (fe == KK) dof_pos_f = i; + + int irow = mysys->_dofmap.GetDof(Lev_f,fe,ivar,dof_pos_f); + + uint ncol = len[fe][i+1] - len[fe][i]; + uint noff = lenoff[fe][i+1] - lenoff[fe][i]; + pattern[irow].resize(ncol+1); + pattern[irow][ncol] = noff; +// #ifdef FEMUS_HAVE_LASPACK + for (uint j=0; jGetMLProb().GetMeshTwo()._Qnode_lev_Qnode_fine[ FEXLevel_c[fe] ][ dof_pos_lev_c ]; + else if (fe == KK) dof_pos_c = dof_pos_lev_c; + + pattern[irow][j] = mysys->_dofmap.GetDof(Lev_c,fe,ivar,dof_pos_c); + } +// #endif + + } + }//end fe < KK + } //end fe + + + std::cout << "Printing Prolongator ===========" << std::endl; + pattern.print(); + mysys->_LinSolver[Lev_f]->_PP->update_sparsity_pattern_old(pattern); + +//=========== VALUES =================== + DenseMatrix *valmat; + std::vector tmp(1); + for (int fe=0; fe_dofmap._nvars[fe];ivar++) { + for (unsigned int i=ml_init[fe]; iGetMLProb().GetMeshTwo()._Qnode_lev_Qnode_fine[ FEXLevel_f[fe] ][ i ]; //end fe < ql + else if (fe == KK) dof_pos_f = i; + + int irow = mysys->_dofmap.GetDof(Lev_f,fe,ivar,dof_pos_f); + + uint ncol = len[fe][i+1]-len[fe][i]; + tmp[0] = irow; + std::vector< uint> ind(pattern[irow].size()-1); + for (uint j=0; j_LinSolver[Lev_f]->_PP->add_matrix(*valmat,tmp,ind); + delete valmat; + } + } + } //end fe + + + for (int fe=0;fe_LinSolver[Lev_f]->_PP->close(); +// if (mysys->GetMLProb().GetMeshTwo()._iproc==0) _Prl[ Lev_f ]->print_personal(); +// _Prl[ Lev_f ]->print_graphic(false); //TODO should pass this true or false as a parameter + } //end levels + +#ifdef DEFAULT_PRINT_INFO + std::cout << " ReadProl(B): read Op " << name.c_str() << std::endl; +#endif + + return; +} + + + +// ================================================================= +//This function depends on _iproc +//TODO AAA This operator here DEPENDS on the BOUNDARY CONDITIONS +// while the prolongator does not depend on the bc's... CHECK THAT +//Also notice that the Matrix, Restriction and Prolongation sparsity patterns +//are assembled by looping over NODES. +// Then, the values are set with NODE LOOPS for Rest and Prol, +// and with ELEMENT LOOP for the MATRIX (the Assemble Function) +//Level goes from 0 to < GetGridn() - 1 ==> Level is COARSE here + +// uint Lev_c = Level; +// uint Lev_f = Level+1; + //with these you explore arrays that go from 0 to GetGridn() - 1 + //so where the distinction between QQ and LL is already made + // with the EXTENDED levels you explore things that have an additional level, + // and so can work both with QQ and with LL + //the point is: there are parts where you cannot use extended levels, and parts where you can + //for instance, in this routine the FINE LEVELS and the FINE EXTENDED LEVELS will both be ok, + //so we can use them in both cases, but we cannot say the same for the COARSE levels and ext levels + + //AAA fai molta attenzione: per esplorare la node_dof devi usare Lev_c e Lev_f, + //perche' sono legati ai DOF (devi pensare che la questione del mesh e' gia' risolta) +void GenCase::ReadRest(const std::string& name, const SystemTwo * mysys) { + + + for (uint Level = 0; Level< mysys->GetGridn() - 1; Level++) { + + uint Lev_c = Level; + uint Lev_f = Level+1; + + std::ostringstream groupname_lev; groupname_lev << "LEVEL" << Lev_f << "_" << Lev_c; + + int** rowcln; + int** len; + int** lenoff; + int** Rest_pos; + double** Rest_val; + + rowcln = new int*[QL]; + len = new int*[QL]; + lenoff = new int*[QL]; + Rest_pos = new int*[QL]; + Rest_val = new double*[QL]; + + hid_t file = H5Fopen(name.c_str(),H5F_ACC_RDWR, H5P_DEFAULT); + + for (int fe=0;feGetGridn()-1) ! + + int FEXLevel_c[QL]; + FEXLevel_c[QQ] = Level; //COARSE Level for QUADRATIC + FEXLevel_c[LL] = (mysys->GetGridn() + Level)%(mysys->GetGridn() + 1); //COARSE Level for LINEAR: Level1=0 means coarse linear, a finer linear is the first coarse quadratic, and so on and so on + FEXLevel_c[KK] = Level; //COARSE Level for CONSTANT + int FEXLevel_f[QL]; + FEXLevel_f[QQ] = Level+1; //FINE Level for QUADRATIC + FEXLevel_f[LL] = Level; // AAA look at the symmetry, this is exactly (_n_levels + Level1 + 1)%(_n_levels + 1); ! //FINE Level for LINEAR: Level1=0 means coarse linear, a finer linear is the first coarse quadratic, and so on and so on + FEXLevel_f[KK] = Level+1; //FINE Level for CONSTANT + + uint off_proc=mysys->GetGridn()*mysys->GetMLProb().GetMeshTwo()._iproc; + + mysys->_LinSolver[Lev_c]->_RR = SparseMatrix::build().release(); +// // // _Rst[Lev_c]->init(0,0,0,0); //TODO BACK TO A REASONABLE INIT //we have to do this before appropriately!!! + + int nrowt=0;int nclnt=0; + for (int fe=0;fe_dofmap._nvars[fe]*rowcln[fe][0]; + nclnt += mysys->_dofmap._nvars[fe]*rowcln[fe][1]; + } + + + Graph pattern; + pattern.resize(nrowt); + pattern._m = nrowt; + pattern._n = nclnt; // global dim _m x _n + pattern._ml = 0; // local _m + pattern._nl = 0; // local _n + for (int fe=0;fe_dofmap._nvars[fe]*mysys->_dofmap._DofLocLevProcFE[Lev_c][mysys->GetMLProb().GetMeshTwo()._iproc][fe]; + pattern._nl += mysys->_dofmap._nvars[fe]*mysys->_dofmap._DofLocLevProcFE[Lev_f][mysys->GetMLProb().GetMeshTwo()._iproc][fe]; + } + + // starting indices for local matrix + uint ml_start = mysys->_dofmap.GetStartDof(Lev_c,off_proc); // offset proc nodes + pattern._ml_start = ml_start; + uint DofObjInit_lev_PrevProcs_c[QL]; + for (int fe=0;feGetMLProb().GetMeshTwo()._iproc; isubd++) { //up to the current processor + if (fe < KK) /*mlinit*/ DofObjInit_lev_PrevProcs_c[fe] += mysys->GetMLProb().GetMeshTwo()._off_nd[fe][ isubd*mysys->GetGridn() + Lev_c +1 ] - mysys->GetMLProb().GetMeshTwo()._off_nd[fe][isubd*mysys->GetGridn()]; + else if (fe == KK) /*mlinit*/ DofObjInit_lev_PrevProcs_c[fe] += mysys->GetMLProb().GetMeshTwo()._off_el[VV][ isubd*mysys->GetGridn() + Lev_c +1 ] - mysys->GetMLProb().GetMeshTwo()._off_el[VV][isubd*mysys->GetGridn() + Lev_c]; + } + } + + //============= POSITION ========= + for (int fe=0; fe_dofmap._nvars[fe];ivar++) { + for (unsigned int i = DofObjInit_lev_PrevProcs_c[fe]; i< DofObjInit_lev_PrevProcs_c[fe] + mysys->_dofmap._DofLocLevProcFE[Lev_c][mysys->GetMLProb().GetMeshTwo()._iproc][fe]; i++) { + int dof_pos_c; + if (fe < KK) dof_pos_c = mysys->GetMLProb().GetMeshTwo()._Qnode_lev_Qnode_fine[ FEXLevel_c[fe] ][ i ]; + else if (fe == KK) dof_pos_c = i; + + int irow = mysys->_dofmap.GetDof(Lev_c,fe,ivar,dof_pos_c); + + uint ncol = len[fe][i+1]-len[fe][i]; + uint noff = lenoff[fe][i+1] - lenoff[fe][i]; + pattern[irow].resize(ncol+1); //when you do resize, it puts a zero in all positions + pattern[irow][ncol] = noff; +// pattern structure (was for laspack only) + for (uint j=0; jGetMLProb().GetMeshTwo()._Qnode_lev_Qnode_fine[ FEXLevel_f[fe] ][ dof_pos_lev_f ]; + else if (fe == KK) dof_pos_f = dof_pos_lev_f; + pattern[irow][j] = mysys->_dofmap.GetDof(Lev_f,fe,ivar,dof_pos_f); + } + + } + } + } //end fe loop + + + std::cout << "Printing Restrictor ===========" << std::endl; + pattern.print(); + mysys->_LinSolver[Lev_c]->_RR->update_sparsity_pattern_old(pattern); //TODO see +// _Rst[Lev_c]->close(); +// if (mysys->GetMLProb().GetMeshTwo()._iproc==0) _Rst[Lev_c]->print_personal(); //there is no print function for rectangular matrices, and print_personal doesnt seem to be working... +// la print stampa il contenuto, ma io voglio solo stampare lo sparsity pattern! + //Allora cosa faccio: riempio di zeri e poi la stampo! No, di zeri no!!! devi riempirla con qualcos'altro! +//TODO how can I print the sparsity pattern in Petsc BEFORE FILLING the MATRIX ?!?! + //============================== +//========= SET VALUES ========= +//============================== + + DenseMatrix *valmat; + std::vector tmp(1); + for (int fe=0;fe_dofmap._nvars[fe];ivar++) { + for (unsigned int i = DofObjInit_lev_PrevProcs_c[fe]; i< DofObjInit_lev_PrevProcs_c[fe] + mysys->_dofmap._DofLocLevProcFE[Lev_c][mysys->GetMLProb().GetMeshTwo()._iproc][fe]; i++) { + int dof_pos_c; + if (fe < KK) dof_pos_c = mysys->GetMLProb().GetMeshTwo()._Qnode_lev_Qnode_fine[ FEXLevel_c[fe] ][ i ]; + else if (fe == KK) dof_pos_c = i; + int irow = mysys->_dofmap.GetDof(Lev_c,fe,ivar,dof_pos_c); + int irow_top = mysys->_dofmap.GetDof(mysys->GetGridn()-1,fe,ivar,dof_pos_c); + uint ncol = len[fe][i+1]-len[fe][i]; + tmp[0]=irow; + std::vector< uint> ind(pattern[irow].size()-1); +// std::cout << "\n ==== " << irow << ": "; + for (uint i1=0;i1_bcond._bc[irow_top]*Rest_val[fe][ j+len[fe][i] ]; + mysys->_LinSolver[Lev_c]->_RR->add_matrix(*valmat,tmp,ind); + delete valmat; + }// end dof loop + } // end var loop + } //end fe + + for (int fe=0;fe_LinSolver[Lev_c]->_RR->close(); +// if (mysys->GetMLProb().GetMeshTwo()._iproc==0) _Rst[Lev_c]->print_personal(std::cout); +// _Rst[Lev_c]->print_graphic(false); // TODO should pass this true or false as a parameter + + } //end levels + +#ifdef DEFAULT_PRINT_INFO + std::cout << " ReadRest(B): read Op " << name.c_str() << std::endl; +#endif + return; +} + + + + + + } //end namespace femus diff --git a/src/meshGencase/GenCase.hpp b/src/meshGencase/GenCase.hpp index f9b463756..d7ba36da4 100644 --- a/src/meshGencase/GenCase.hpp +++ b/src/meshGencase/GenCase.hpp @@ -15,6 +15,7 @@ #include "FemusInputParser.hpp" #include "ElemSto.hpp" #include "MultiLevelMeshTwo.hpp" +#include "SystemTwo.hpp" // libmesh #ifdef HAVE_LIBMESH @@ -32,7 +33,7 @@ class GenCase : public MultiLevelMeshTwo { public: - GenCase(const FemusInputParser & map_in, const std::string mesh_file); + GenCase(const unsigned nolevels, const unsigned dim, const GeomElType geomel_type, const std::string mesh_file); ~GenCase(); void ElemChildToFather(); @@ -45,6 +46,12 @@ class GenCase : public MultiLevelMeshTwo { void ComputeAndPrintMatrix(const std::string output_path); void ComputeAndPrintProl(const std::string output_path); void ComputeAndPrintRest(const std::string output_path); + + static void ReadMGOps(const std::string output_path, const SystemTwo * mysys); + static void ReadMatrix(const std::string& name, const SystemTwo * mysys); + static void ReadProl(const std::string& name, const SystemTwo * mysys); + static void ReadRest(const std::string& name, const SystemTwo * mysys); + void CreateMeshStructuresLevSubd(const std::string output_path); void Delete(); diff --git a/src/meshGencase/MultiLevelMeshTwo.cpp b/src/meshGencase/MultiLevelMeshTwo.cpp index b962a1be5..c6fb981d2 100644 --- a/src/meshGencase/MultiLevelMeshTwo.cpp +++ b/src/meshGencase/MultiLevelMeshTwo.cpp @@ -36,12 +36,10 @@ namespace femus { // ======================================================== -MultiLevelMeshTwo::MultiLevelMeshTwo (const FemusInputParser& map_in, const std::string mesh_file_in) : - _mesh_rtmap(map_in), - _dim(map_in.get("dimension")), - _mesh_order(map_in.get("mesh_ord")) { +MultiLevelMeshTwo::MultiLevelMeshTwo (const unsigned nolevels, const unsigned dim, const GeomElType geomel_type, const std::string mesh_file_in) : + _dim(dim) { - _eltype_flag[VV]= map_in.get("geomel_type"); + _eltype_flag[VV]= geomel_type; _mesh_file.assign(mesh_file_in); @@ -90,22 +88,21 @@ MultiLevelMeshTwo::MultiLevelMeshTwo (const FemusInputParser& map_in, co } else { std::cout << "Geom Elem not supported" << std::endl; abort(); } -if ( _dim == 3 && (map_in.get("geomel_type") != HEX && map_in.get("geomel_type") != TET && map_in.get("geomel_type") != WEDGE) ) +if ( _dim == 3 && (geomel_type != HEX && geomel_type != TET && geomel_type != WEDGE) ) { std::cout << "Inconsistent input file" << std::endl; abort(); } -if ( _dim == 2 && (map_in.get("geomel_type") != QUAD && map_in.get("geomel_type") != TRI ) ) +if ( _dim == 2 && (geomel_type != QUAD && geomel_type != TRI ) ) { std::cout << "Inconsistent input file" << std::endl; abort(); } -if ( _dim == 1 && (map_in.get("geomel_type") != LINE ) ) +if ( _dim == 1 && (geomel_type != LINE ) ) { std::cout << "Inconsistent input file" << std::endl; abort(); } _iproc = paral::get_rank(); _NoSubdom = paral::get_size(); - _NoLevels = GetRuntimeMap().get("nolevels"); + _NoLevels = nolevels; - const uint mesh_ord = (uint) map_in.get("mesh_ord"); - if (mesh_ord != 0) { + if (MESH_ORDER != QQ) { std::cout << "Linear mesh not yet implemented" << std::endl; abort(); } diff --git a/src/meshGencase/MultiLevelMeshTwo.hpp b/src/meshGencase/MultiLevelMeshTwo.hpp index 7154dc278..72da5fbba 100644 --- a/src/meshGencase/MultiLevelMeshTwo.hpp +++ b/src/meshGencase/MultiLevelMeshTwo.hpp @@ -32,6 +32,7 @@ #include "ElemSto.hpp" #include "VBTypeEnum.hpp" #include "FETypeEnum.hpp" +#include "GeomElTypeEnum.hpp" namespace femus { @@ -46,8 +47,7 @@ class MultiLevelMeshTwo { public: //===== Constructors/ Destructor =========== - MultiLevelMeshTwo (const FemusInputParser& map_in, const std::string mesh_file_in); -// ~MultiLevelMeshTwo (); + MultiLevelMeshTwo (const unsigned nolevels, const unsigned dim, const GeomElType geomel_type, const std::string mesh_file_in); void clear (); //======= mesh generation functions ==== @@ -62,7 +62,6 @@ class MultiLevelMeshTwo { //attributes ************************************ const uint _dim; ///< spatial dimension - const uint _mesh_order; // ==== PARALLEL === uint _iproc; /// current subdomain uint _NoSubdom; /// Number of subdomains (subdomain P) @@ -106,14 +105,13 @@ class MultiLevelMeshTwo { public: // ====== DOMAIN SHAPE ( optional => pointer) - Domain* _domain; //TODO You must remember to ALLOCATE this POINTER BEFORE USING IT! + Domain* _domain; Domain* GetDomain() const; void SetDomain(Domain* ); //get functions inline const double get_Lref() const {return _Lref;} inline const uint get_dim() const {return _dim;} - inline const FemusInputParser GetRuntimeMap() const { return _mesh_rtmap; } //set functions inline void SetLref(const double lref_in) { _Lref = lref_in; } @@ -127,7 +125,6 @@ class MultiLevelMeshTwo { protected: - const FemusInputParser & _mesh_rtmap; std::string _mesh_file; //mesh file name from the mesh generator private: diff --git a/src/solution/GMVWriter.cpp b/src/solution/GMVWriter.cpp index e82b57942..6ca328716 100644 --- a/src/solution/GMVWriter.cpp +++ b/src/solution/GMVWriter.cpp @@ -24,14 +24,20 @@ #include #include #include -#include +#include +#include "Files.hpp" namespace femus { -GMVWriter::GMVWriter(MultiLevelSolution & ml_probl): Writer(ml_probl) +GMVWriter::GMVWriter(MultiLevelSolution * ml_sol): Writer(ml_sol) +{ + _debugOutput = false; +} + +GMVWriter::GMVWriter(MultiLevelMesh * ml_mesh): Writer(ml_mesh) { _debugOutput = false; } @@ -41,8 +47,8 @@ GMVWriter::~GMVWriter() } -void GMVWriter::write_system_solutions(const std::string output_path, const char order[], std::vector& vars, const unsigned time_step) -{ +void GMVWriter::write(const std::string output_path, const char order[], const std::vector& vars, const unsigned time_step) const { + unsigned igridn = _gridn; // aggiunta da me if (igridn==0) igridn=_gridn; @@ -52,8 +58,13 @@ void GMVWriter::write_system_solutions(const std::string output_path, const char // ********** linear -> index==0 *** quadratic -> index==1 ********** unsigned index=(strcmp(order,"linear"))?1:0; + std::string filename_prefix; + if( _ml_sol != NULL ) filename_prefix = "sol"; + else filename_prefix = "mesh"; + std::ostringstream filename; - filename << output_path << "/sol.level" << _gridn << "." << time_step << "." << order << ".gmv"; + filename << output_path << "/" << filename_prefix << ".level" << _gridn << "." << time_step << "." << order << ".gmv"; + std::ofstream fout; if(_iproc!=0) { @@ -73,7 +84,7 @@ void GMVWriter::write_system_solutions(const std::string output_path, const char unsigned nvt=0; unsigned nvt_max=0; for (unsigned ig=igridr-1u; igGetLevel(ig)->MetisOffset[index][_nprocs]; + unsigned nvt_ig=_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs]; nvt_max=(nvt_max>nvt_ig)?nvt_max:nvt_ig; nvt+=nvt_ig; } @@ -82,7 +93,7 @@ void GMVWriter::write_system_solutions(const std::string output_path, const char vector Mysol(igridn); for(unsigned ig=igridr-1u; ig<_gridn; ig++) { Mysol[ig] = NumericVector::build().release(); - Mysol[ig]->init(_ml_sol._ml_msh->GetLevel(ig)->MetisOffset[index][_nprocs],_ml_sol._ml_msh->GetLevel(ig)->own_size[index][_iproc],true,AUTOMATIC); + Mysol[ig]->init(_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs],_ml_mesh->GetLevel(ig)->own_size[index][_iproc],true,AUTOMATIC); } // ********** Header ********** @@ -99,19 +110,21 @@ void GMVWriter::write_system_solutions(const std::string output_path, const char for (int i=0; i<3; i++) { for (unsigned ig=igridr-1u; igmatrix_mult(*_ml_sol._ml_msh->GetLevel(ig)->_coordinate->_Sol[i],*_ProlQitoQj[index][2][ig]); + Mysol[ig]->matrix_mult(*_ml_mesh->GetLevel(ig)->_coordinate->_Sol[i], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index,2) ); vector v_local; Mysol[ig]->localize_to_one(v_local,0); - unsigned nvt_ig=_ml_sol._ml_msh->GetLevel(ig)->MetisOffset[index][_nprocs]; + unsigned nvt_ig=_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs]; if(_iproc==0){ for (unsigned ii=0; iimatrix_mult(*_ml_sol.GetSolutionLevel(ig)->_Sol[indDXDYDZ],*_ProlQitoQj[index][_ml_sol.GetSolutionType(indDXDYDZ)][ig]); + if (_ml_sol != NULL && _moving_mesh && _ml_mesh->GetLevel(0)->GetDimension() > i) { + unsigned indDXDYDZ=_ml_sol->GetIndex(_moving_vars[i].c_str()); + Mysol[ig]->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Sol[indDXDYDZ], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index, _ml_sol->GetSolutionType(indDXDYDZ)) ); Mysol[ig]->localize_to_one(v_local,0); - unsigned nvt_ig=_ml_sol._ml_msh->GetLevel(ig)->MetisOffset[index][_nprocs]; + unsigned nvt_ig=_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs]; if(_iproc==0){ for (unsigned ii=0; iiGetLevel(ig)->GetNumberOfElements() - _ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementNumber()); - nel+=_ml_sol._ml_msh->GetLevel(igridn-1u)->GetNumberOfElements(); + nel+=( _ml_mesh->GetLevel(ig)->GetNumberOfElements() - _ml_mesh->GetLevel(ig)->el->GetRefinedElementNumber()); + nel+=_ml_mesh->GetLevel(igridn-1u)->GetNumberOfElements(); fout.write((char *)&nel,sizeof(unsigned)); unsigned topology[27]; unsigned offset=1; for (unsigned ig=igridr-1u; igGetLevel(ig)->GetNumberOfElements(); ii++) { - if ( ig==igridn-1u || 0==_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { - short unsigned ielt=_ml_sol._ml_msh->GetLevel(ig)->el->GetElementType(ii); + for (unsigned ii=0; ii<_ml_mesh->GetLevel(ig)->GetNumberOfElements(); ii++) { + if ( ig == igridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { + short unsigned ielt=_ml_mesh->GetLevel(ig)->el->GetElementType(ii); if (ielt==0) sprintf(det,"phex%d",eltp[index][0]); else if (ielt==1) sprintf(det,"ptet%d",eltp[index][1]); else if (ielt==2) sprintf(det,"pprism%d",eltp[index][2]); @@ -157,15 +170,15 @@ void GMVWriter::write_system_solutions(const std::string output_path, const char fout.write((char *)&NVE[ielt][index],sizeof(unsigned)); for(unsigned j=0;jGetLevel(ig)->el->GetElementVertexIndex(ii,j)-1u; - unsigned jnode_Metis = _ml_sol._ml_msh->GetLevel(ig)->GetMetisDof(jnode,index); + unsigned jnode=_ml_mesh->GetLevel(ig)->el->GetElementVertexIndex(ii,j)-1u; + unsigned jnode_Metis = _ml_mesh->GetLevel(ig)->GetMetisDof(jnode,index); topology[j]=jnode_Metis+offset; } fout.write((char *)topology,sizeof(unsigned)*NVE[ielt][index]); } } - offset+=_ml_sol._ml_msh->GetLevel(ig)->MetisOffset[index][_nprocs]; + offset+=_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs]; } // ********** End printing cell connectivity ********** @@ -184,9 +197,9 @@ void GMVWriter::write_system_solutions(const std::string output_path, const char int icount=0; for (unsigned ig=igridr-1u; igGetLevel(ig)->GetNumberOfElements(); ii++) { - if ( ig==igridn-1u || 0==_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { - var_el[icount]=_ml_sol._ml_msh->GetLevel(ig)->el->GetElementGroup(ii); + for (unsigned ii=0; ii<_ml_mesh->GetLevel(ig)->GetNumberOfElements(); ii++) { + if ( ig==igridn-1u || 0==_ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { + var_el[icount]=_ml_mesh->GetLevel(ig)->el->GetElementGroup(ii); icount++; } } @@ -200,9 +213,9 @@ void GMVWriter::write_system_solutions(const std::string output_path, const char int icount=0; for (unsigned ig=igridr-1u; igGetLevel(ig)->GetNumberOfElements(); ii++) { - if ( ig==igridn-1u || 0==_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { - var_el[icount]=_ml_sol._ml_msh->GetLevel(ig)->epart[ii]; + for (unsigned ii=0; ii<_ml_mesh->GetLevel(ig)->GetNumberOfElements(); ii++) { + if ( ig==igridn-1u || 0==_ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { + var_el[icount]=_ml_mesh->GetLevel(ig)->epart[ii]; icount++; } } @@ -213,43 +226,49 @@ void GMVWriter::write_system_solutions(const std::string output_path, const char // ********** End printing Regions ********** // ********** Start printing Solution ********** + if (_ml_sol != NULL) { + bool printAll = 0; for (unsigned ivar=0; ivar < vars.size(); ivar++){ printAll += !(vars[ivar].compare("All")) + !(vars[ivar].compare("all")) + !(vars[ivar].compare("ALL")); } - for (unsigned ivar=0; ivar< !printAll*vars.size() + printAll*_ml_sol.GetSolutionSize(); ivar++) { - unsigned i = ( printAll == 0 ) ? _ml_sol.GetIndex( vars[ivar].c_str()) : ivar; + for (unsigned ivar=0; ivar< !printAll*vars.size() + printAll*_ml_sol->GetSolutionSize(); ivar++) { + unsigned i = ( printAll == 0 ) ? _ml_sol->GetIndex( vars[ivar].c_str()) : ivar; for(int name=0;name<4;name++){ if (name==0){ - sprintf(det,"%s", _ml_sol.GetSolutionName(i)); + sprintf(det,"%s", _ml_sol->GetSolutionName(i)); } else if (name==1){ - sprintf(det,"%s %s","Bdc",_ml_sol.GetSolutionName(i)); + sprintf(det,"%s %s","Bdc",_ml_sol->GetSolutionName(i)); } else if (name==2){ - sprintf(det,"%s %s","Res",_ml_sol.GetSolutionName(i)); + sprintf(det,"%s %s","Res",_ml_sol->GetSolutionName(i)); } else{ - sprintf(det,"%s %s","Eps",_ml_sol.GetSolutionName(i)); + sprintf(det,"%s %s","Eps",_ml_sol->GetSolutionName(i)); } - if(name==0 || ( _debugOutput && _ml_sol.GetSolutionLevel(igridn-1u)->_ResEpsBdcFlag[i])){ - if (_ml_sol.GetSolutionType(i)<3) { // ********** on the nodes ********** + if(name==0 || ( _debugOutput && _ml_sol->GetSolutionLevel(igridn-1u)->_ResEpsBdcFlag[i])){ + if (_ml_sol->GetSolutionType(i)<3) { // ********** on the nodes ********** fout.write((char *)det,sizeof(char)*8); fout.write((char *)&one,sizeof(unsigned)); for (unsigned ig=igridr-1u; igmatrix_mult(*_ml_sol.GetSolutionLevel(ig)->_Sol[i],*_ProlQitoQj[index][_ml_sol.GetSolutionType(i)][ig]); + Mysol[ig]->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Sol[i], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index, _ml_sol->GetSolutionType(i)) ); } else if (name==1){ - Mysol[ig]->matrix_mult(*_ml_sol.GetSolutionLevel(ig)->_Bdc[i],*_ProlQitoQj[index][_ml_sol.GetSolutionType(i)][ig]); + Mysol[ig]->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Bdc[i], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index, _ml_sol->GetSolutionType(i)) ); } else if (name==2){ - Mysol[ig]->matrix_mult(*_ml_sol.GetSolutionLevel(ig)->_Res[i],*_ProlQitoQj[index][_ml_sol.GetSolutionType(i)][ig]); + Mysol[ig]->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Res[i], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index, _ml_sol->GetSolutionType(i)) ); } else{ - Mysol[ig]->matrix_mult(*_ml_sol.GetSolutionLevel(ig)->_Eps[i],*_ProlQitoQj[index][_ml_sol.GetSolutionType(i)][ig]); + Mysol[ig]->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Eps[i], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index, _ml_sol->GetSolutionType(i)) ); } std::vector v_local; Mysol[ig]->localize_to_one(v_local,0); @@ -263,20 +282,20 @@ void GMVWriter::write_system_solutions(const std::string output_path, const char for (unsigned ig=igridr-1u; ig v_local; if (name==0){ - _ml_sol.GetSolutionLevel(ig)->_Sol[i]->localize_to_one(v_local,0); + _ml_sol->GetSolutionLevel(ig)->_Sol[i]->localize_to_one(v_local,0); } else if (name==1){ - _ml_sol.GetSolutionLevel(ig)->_Bdc[i]->localize_to_one(v_local,0); + _ml_sol->GetSolutionLevel(ig)->_Bdc[i]->localize_to_one(v_local,0); } else if (name==2){ - _ml_sol.GetSolutionLevel(ig)->_Res[i]->localize_to_one(v_local,0); + _ml_sol->GetSolutionLevel(ig)->_Res[i]->localize_to_one(v_local,0); } else{ - _ml_sol.GetSolutionLevel(ig)->_Eps[i]->localize_to_one(v_local,0); + _ml_sol->GetSolutionLevel(ig)->_Eps[i]->localize_to_one(v_local,0); } - for (unsigned ii=0; ii<_ml_sol._ml_msh->GetLevel(ig)->GetNumberOfElements(); ii++) { - if ( ig==igridn-1u || 0==_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { - unsigned iel_Metis = _ml_sol._ml_msh->GetLevel(ig)->GetMetisDof(ii,_ml_sol.GetSolutionType(i)); + for (unsigned ii=0; ii<_ml_mesh->GetLevel(ig)->GetNumberOfElements(); ii++) { + if ( ig==igridn-1u || 0==_ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { + unsigned iel_Metis = _ml_mesh->GetLevel(ig)->GetMetisDof(ii,_ml_sol->GetSolutionType(i)); var_el[icount]=v_local[iel_Metis]; icount++; } @@ -287,6 +306,8 @@ void GMVWriter::write_system_solutions(const std::string output_path, const char } } } + + } //end _ml_sol // ********** End printing Solution ********** sprintf(det,"%s","endvars"); fout.write((char *)det,sizeof(char)*8); @@ -309,6 +330,452 @@ void GMVWriter::write_system_solutions(const std::string output_path, const char } +void GMVWriter::Pwrite(const std::string output_path, const char order[], const std::vector& vars, const unsigned time_step) const { + + if(_nprocs == 1){ + write( output_path, order, vars, time_step); + return; + } + + unsigned gridn = _gridn; // aggiunta da me + + if ( gridn == 0 ) gridn = _gridn; + + unsigned igridr=( _gridr <= gridn ) ? _gridr : gridn; + + // ********** linear -> index==0 *** quadratic -> index==1 ********** + unsigned index=( strcmp(order, "linear") ) ? 1 : 0; + + std::string dirnamePGMV = "GMVParallelFiles/"; + Files files; + files.CheckDir(output_path,dirnamePGMV); + + std::string filename_prefix; + if( _ml_sol != NULL ) filename_prefix = "sol"; + else filename_prefix = "mesh"; + + std::ostringstream filename; + filename << output_path << "/" << dirnamePGMV << filename_prefix << ".level" << _gridn << "." <<_iproc<<"."<< time_step << "." << order << ".gmv"; + + std::ofstream fout; + + fout.open(filename.str().c_str()); + if (!fout.is_open()) { + std::cout << std::endl << " The output file "<< filename.str() <<" cannot be opened.\n"; + abort(); + } + + //count the own node dofs on all levels + unsigned nvt = 0; + unsigned nvt_max = 0; + for (unsigned ig=igridr-1u; igGetLevel(ig)->own_size[index][_iproc]; + nvt_max=( nvt_max > nvt_ig ) ? nvt_max : nvt_ig; + nvt += nvt_ig; + } + + // count the ghost node dofs and the own element dofs element on all levels + unsigned ghost_counter = 0; + unsigned nel=0; + for (unsigned ig = igridr-1u; igGetLevel(ig)->MetisOffset[index][_iproc]; + for (int iel=_ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + nel++; + short unsigned ielt=_ml_mesh->GetLevel(ig)->el->GetElementType(kel); + for(unsigned j=0; jGetLevel(ig)->el->GetMeshDof(kel, j, index); + unsigned jnodeMetis = _ml_mesh->GetLevel(ig)->GetMetisDof(jnode, index); + if( jnodeMetis < offset_iprc ){ //Is this a ghost node? + ghost_counter++; + } + } + } + } + } + + nvt_max= ( nvt_max > ghost_counter )? nvt_max : ghost_counter; + unsigned nvt0 = nvt; + nvt += ghost_counter; // total node dofs (own + ghost) + + vector < double > var_nd; + var_nd.resize(nvt_max+1); //TO FIX Valgrind complaints! In reality it should be only nvt + vector < double > var_el; + var_el.resize(nel+1); //TO FIX Valgrind complaints! In reality it should be only nel + vector < NumericVector* > Mysol(gridn); + for(unsigned ig=igridr-1u; ig<_gridn; ig++) { + Mysol[ig] = NumericVector::build().release(); + + if(n_processors()==1) { // IF SERIAL + Mysol[ig]->init(_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs], + _ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs],false,SERIAL); + } + else{ // IF PARALLEL + Mysol[ig]->init(_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs], + _ml_mesh->GetLevel(ig)->own_size[index][_iproc], + _ml_mesh->GetLevel(ig)->ghost_nd_mts[index][_iproc],false,GHOSTED ); + } + } + + // ********** Header ********** + char *det= new char[10]; + sprintf(det,"%s","gmvinput"); + fout.write((char *)det,sizeof(char)*8); + sprintf(det,"%s","ieeei4r8"); + fout.write((char *)det,sizeof(char)*8); + + // ********** Start printing node coordinates ********** + sprintf(det,"%s","nodes"); + fout.write((char *)det,sizeof(char)*8); + fout.write((char *)&nvt,sizeof(unsigned)); + + for (int i=0; i<3; i++) { + for (unsigned ig=igridr-1u; igmatrix_mult(*_ml_mesh->GetLevel(ig)->_coordinate->_Sol[i], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index,2) ); + + unsigned offset_iprc = _ml_mesh->GetLevel(ig)->MetisOffset[index][_iproc]; + unsigned nvt_ig= _ml_mesh->GetLevel(ig)->own_size[index][_iproc]; + for (unsigned ii=0; iiGetLevel(0)->GetDimension() > i) { // if moving mesh + unsigned indDXDYDZ=_ml_sol->GetIndex(_moving_vars[i].c_str()); + Mysol[ig]->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Sol[indDXDYDZ], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index,_ml_sol->GetSolutionType(indDXDYDZ)) ); + for (unsigned ii=0; iiGetLevel(ig)->MetisOffset[index][_iproc]; + for (int iel=_ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + short unsigned ielt=_ml_mesh->GetLevel(ig)->el->GetElementType(kel); + for(unsigned j=0;jGetLevel(ig)->el->GetMeshDof(kel, j, index); + unsigned jnodeMetis = _ml_mesh->GetLevel(ig)->GetMetisDof(jnode, index); + if( jnodeMetis < offset_iprc ){ + var_nd[ghost_counter] = (*Mysol[ig])(jnodeMetis); + ghost_counter++; + ig_ghost_couter++; + } + } + } + } + if (_ml_sol != NULL && _moving_mesh && _ml_mesh->GetLevel(0)->GetDimension() > i) { // if moving mesh + ghost_counter -= ig_ghost_couter; + Mysol[ig]->matrix_mult(*_ml_mesh->GetLevel(ig)->_coordinate->_Sol[i], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index,2) ); + unsigned offset_iprc = _ml_mesh->GetLevel(ig)->MetisOffset[index][_iproc]; + for (int iel=_ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + short unsigned ielt=_ml_mesh->GetLevel(ig)->el->GetElementType(kel); + for(unsigned j=0;jGetLevel(ig)->el->GetMeshDof(kel, j, index); + unsigned jnodeMetis = _ml_mesh->GetLevel(ig)->GetMetisDof(jnode, index); + if( jnodeMetis < offset_iprc ){ + var_nd[ghost_counter] += (*Mysol[ig])(jnodeMetis); + ghost_counter++; + } + } + } + } + } + } + fout.write( (char *)&var_nd[0], ghost_counter*sizeof(double) ); + + } + // ********** End printing node coordinates ********** + + // ********** Start printing cell connectivity ********** + const int eltp[2][6]= {{8,4,6,4,3,2},{20,10,15,8,6,3}}; + sprintf(det,"%s","cells"); + fout.write((char *)det,sizeof(char)*8); + fout.write((char *)&nel,sizeof(unsigned)); + + unsigned topology[27]; + unsigned offset=1; + + ghost_counter = 0; + for (unsigned ig=igridr-1u; igGetLevel(ig)->MetisOffset[index][_iproc]; + unsigned nvt_ig= _ml_mesh->GetLevel(ig)->own_size[index][_iproc]; + for (int iel=_ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + short unsigned ielt=_ml_mesh->GetLevel(ig)->el->GetElementType(kel); + if (ielt==0) sprintf(det,"phex%d",eltp[index][0]); + else if (ielt==1) sprintf(det,"ptet%d",eltp[index][1]); + else if (ielt==2) sprintf(det,"pprism%d",eltp[index][2]); + else if (ielt==3) { + if (eltp[index][3]==8) sprintf(det,"%dquad",eltp[index][3]); + else sprintf(det,"quad"); + } + else if (ielt==4) { + if (eltp[index][4]==6) sprintf(det,"%dtri",eltp[index][4]); + else sprintf(det,"tri"); + } + else if (ielt==5) { + if (eltp[index][5]==3) sprintf(det,"%dline",eltp[index][5]); + else sprintf(det,"line"); + } + fout.write((char *)det,sizeof(char)*8); + fout.write((char *)&NVE[ielt][index],sizeof(unsigned)); + for(unsigned j=0;jGetLevel(ig)->el->GetMeshDof(kel, j, index); + unsigned jnodeMetis = _ml_mesh->GetLevel(ig)->GetMetisDof(jnode,index); + topology[j]=(jnodeMetis >= offset_iprc )? jnodeMetis - offset_iprc + offset : nvt0 + (++ghost_counter); + } + fout.write((char *)topology,sizeof(unsigned)*NVE[ielt][index]); + } + } + offset += nvt_ig;// _ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs]; + } + // ********** End printing cell connectivity ********** + + // ********** Start printing Variables ********** + const unsigned zero=0u; + const unsigned one=1u; + sprintf(det,"%s","variable"); + fout.write((char *)det,sizeof(char)*8); + + // ********** Start printing Regions ********** + strcpy(det,"Regions"); + fout.write((char *)det,sizeof(char)*8); + fout.write((char *)&zero,sizeof(unsigned)); + + int icount=0; + for (unsigned ig=igridr-1u; igGetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig==gridn-1u || 0==_ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + var_el[icount]=_ml_mesh->GetLevel(ig)->el->GetElementGroup(kel); + icount++; + } + } + } + fout.write((char *)&var_el[0],nel*sizeof(double)); + + if(_nprocs>=1){ + strcpy(det,"Reg_proc"); + fout.write((char *)det,sizeof(char)*8); + fout.write((char *)&zero,sizeof(unsigned)); + + int icount=0; + for (unsigned ig=igridr-1u; igGetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig==gridn-1u || 0==_ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + var_el[icount]=_ml_mesh->GetLevel(ig)->epart[kel]; + icount++; + } + } + } + fout.write((char *)&var_el[0],nel*sizeof(double)); + } + + // ********** End printing Regions ********** + + // ********** Start printing Solution ********** + if (_ml_sol != NULL) { + + bool printAll = 0; + for (unsigned ivar=0; ivar < vars.size(); ivar++){ + printAll += !(vars[ivar].compare("All")) + !(vars[ivar].compare("all")) + !(vars[ivar].compare("ALL")); + } + + for (unsigned ivar=0; ivar< !printAll*vars.size() + printAll*_ml_sol->GetSolutionSize(); ivar++) { + unsigned i = ( printAll == 0 ) ? _ml_sol->GetIndex( vars[ivar].c_str()) : ivar; + + for(int name=0;name<4;name++){ + if (name==0){ + sprintf(det,"%s", _ml_sol->GetSolutionName(i)); + } + else if (name==1){ + sprintf(det,"%s %s","Bdc",_ml_sol->GetSolutionName(i)); + } + else if (name==2){ + sprintf(det,"%s %s","Res",_ml_sol->GetSolutionName(i)); + } + else{ + sprintf(det,"%s %s","Eps",_ml_sol->GetSolutionName(i)); + } + if(name==0 || ( _debugOutput && _ml_sol->GetSolutionLevel(gridn-1u)->_ResEpsBdcFlag[i])){ + if (_ml_sol->GetSolutionType(i)<3) { // ********** on the nodes ********** + fout.write((char *)det,sizeof(char)*8); + fout.write((char *)&one,sizeof(unsigned)); + for (unsigned ig=igridr-1u; igmatrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Sol[i], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index, _ml_sol->GetSolutionType(i)) ); + } + else if (name==1){ + Mysol[ig]->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Bdc[i], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index, _ml_sol->GetSolutionType(i)) ); + } + else if (name==2){ + Mysol[ig]->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Res[i], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index, _ml_sol->GetSolutionType(i)) ); + } + else{ + Mysol[ig]->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Eps[i], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index, _ml_sol->GetSolutionType(i)) ); + } + unsigned offset_iprc = _ml_mesh->GetLevel(ig)->MetisOffset[index][_iproc]; + unsigned nvt_ig = _ml_mesh->GetLevel(ig)->own_size[index][_iproc]; + for (unsigned ii=0; iiGetLevel(ig)->MetisOffset[index][_iproc]; + for (int iel=_ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + short unsigned ielt = _ml_mesh->GetLevel(ig)->el->GetElementType(kel); + for(unsigned j=0; j < NVE[ielt][index]; j++){ + unsigned jnode = _ml_mesh->GetLevel(ig)->el->GetMeshDof(kel, j, index); + unsigned jnodeMetis = _ml_mesh->GetLevel(ig)->GetMetisDof(jnode, index); + if( jnodeMetis < offset_iprc ){ + var_nd[ghost_counter] = (*Mysol[ig])(jnodeMetis); + ghost_counter++; + } + } + } + } + } + fout.write( (char *)&var_nd[0], ghost_counter*sizeof(double) ); + + } + else { // ********** on the elements ********** + fout.write((char *)det,sizeof(char)*8); + fout.write((char *)&zero,sizeof(unsigned)); + int icount=0; + for (unsigned ig=igridr-1u; igGetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == _gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + unsigned iel_Metis = _ml_mesh->GetLevel(ig)->GetMetisDof(kel,_ml_sol->GetSolutionType(i)); + if ( ig==gridn-1u || 0==_ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + if (name==0){ + var_el[icount] = (*_ml_sol->GetSolutionLevel(ig)->_Sol[i])(iel_Metis); + } + else if (name==1){ + var_el[icount] = (*_ml_sol->GetSolutionLevel(ig)->_Bdc[i])(iel_Metis); + } + else if (name==2){ + var_el[icount] = (*_ml_sol->GetSolutionLevel(ig)->_Res[i])(iel_Metis); + } + else{ + var_el[icount] = (*_ml_sol->GetSolutionLevel(ig)->_Eps[i])(iel_Metis); + } + icount++; + } + } + } + } + fout.write((char *)&var_el[0],nel*sizeof(double)); + } + } + } + } + + } //end _ml_sol + // ********** End printing Solution ********** + sprintf(det,"%s","endvars"); + fout.write((char *)det,sizeof(char)*8); + + // ********** End printing Variables ********** + sprintf(det,"%s","endgmv"); + fout.write((char *)det,sizeof(char)*8); + fout.close(); + // ********** End printing file ********** + + // Free memory + for (unsigned ig=igridr-1u; ig Tools -> Play Test ... \n"; + } + else { + std::cout << std::endl << " The output file "<< Pfilename.str() <<" cannot be opened.\n"; + abort(); + } + } + + // *********** write pvtu header *********** + Pfout<< "" << std::endl; + Pfout<< "\n"; + for(int jproc=0;jproc<_nprocs;jproc++){ + Pfout<< " \n"; + Pfout<< " \n"; + } + + Pfout<< " \n"; + Pfout<< " \n"; + + Pfout<< " \n"; + + Pfout<< " \n"; + Pfout<< " \n"; + Pfout<< " \n"; + Pfout<< " \n"; + Pfout<< " \n"; + + Pfout<< " \n"; + Pfout<< " \n"; + + Pfout<< " \n"; + Pfout<< " \n"; + Pfout<< " \n"; + Pfout<< " \n"; + Pfout<< " \n"; + Pfout<< " \n"; + Pfout<< " \n"; + + Pfout<< " \n"; + Pfout<< " \n"; + + Pfout<< " \n"; + Pfout<< " \n"; + + Pfout<< "\n"; + Pfout.close(); + + + + return; +} + + } //end namespace femus + + diff --git a/src/solution/GMVWriter.hpp b/src/solution/GMVWriter.hpp index 1edb1ed56..927bb9cb3 100644 --- a/src/solution/GMVWriter.hpp +++ b/src/solution/GMVWriter.hpp @@ -37,20 +37,25 @@ namespace femus { public: /** Constructor. */ - GMVWriter(MultiLevelSolution & ml_sol); + GMVWriter(MultiLevelSolution * ml_sol); + + /** Constructor. */ + GMVWriter(MultiLevelMesh * ml_mesh); /** Destructor */ virtual ~GMVWriter(); /** write output function */ - virtual void write_system_solutions(const std::string output_path, const char order[], std::vector& vars, const unsigned time_step=0); + void write(const std::string output_path, const char order[], const std::vector < std::string > & vars = std::vector < std::string > (), const unsigned time_step=0) const; + void Pwrite(const std::string output_path, const char order[], const std::vector < std::string > & vars = std::vector < std::string > (), const unsigned time_step=0) const; + /** Set if to print or not to prind the debugging variables */ void SetDebugOutput( bool value ){ _debugOutput = value;} private: + bool _debugOutput; - }; diff --git a/src/solution/MultiLevelSolution.cpp b/src/solution/MultiLevelSolution.cpp index f4cc10a87..e5e52b5b9 100644 --- a/src/solution/MultiLevelSolution.cpp +++ b/src/solution/MultiLevelSolution.cpp @@ -77,7 +77,6 @@ void MultiLevelSolution::AddSolutionLevel(){ } for(unsigned i=0;i<_SolName.size();i++){ _solution[_gridn]->ResizeSolutionVector(_SolName[i]); - BuildProlongatorMatrix(_gridn,i); _solution[_gridn]->_Sol[i]->zero(); if (_SolTmorder[i]==2) { @@ -109,9 +108,9 @@ void MultiLevelSolution::AddSolution(const char name[], const FEFamily fefamily, _SolTmorder.resize(n+1u); _PdeType.resize(n+1u); _TestIfPressure.resize(n+1u); - _TestIfDisplacement.resize(n+1u); - - _TestIfDisplacement[n]=0; + _SolPairIndex.resize(n+1u); + + _TestIfPressure[n]=0; _family[n] = fefamily; _order[n] = order; @@ -121,7 +120,8 @@ void MultiLevelSolution::AddSolution(const char name[], const FEFamily fefamily, strcpy(_SolName[n],name); _SolTmorder[n]=tmorder; _PdeType[n]=PdeType; - + _SolPairIndex[n]=n; + cout << " Add variable " << std::setw(3) << _SolName[n] << " discretized with FE type " << std::setw(12) << order << " and time discretzation order " << tmorder << endl; @@ -135,10 +135,8 @@ void MultiLevelSolution::AddSolution(const char name[], const FEFamily fefamily, void MultiLevelSolution::AssociatePropertyToSolution(const char solution_name[], const char solution_property[]){ unsigned index=GetIndex(solution_name); if( !strcmp(solution_property,"pressure") || !strcmp(solution_property,"Pressure") ) _TestIfPressure[index]=1; - else if( !strcmp(solution_property,"displacement") || !strcmp(solution_property,"Displacement") ) _TestIfDisplacement[index]=1; else if( !strcmp(solution_property,"default") || !strcmp(solution_property,"Default") ) { _TestIfPressure[index]=0; - _TestIfDisplacement[index]=0; } else { cout<<"Error invalid property in function MultiLevelProblem::AssociatePropertyToSolution"<GetLevel(ig)->GetNumberOfElements(); _solution[ig]->ResizeSolutionVector(_SolName[i]); - if ( ig > 0 ) BuildProlongatorMatrix(ig,i); _solution[ig]->_Sol[i]->zero(); if(func){ double value; @@ -256,83 +264,6 @@ unsigned MultiLevelSolution::GetSolutionType(const char name[]) { return _SolType[index]; } -//--------------------------------------------------------------------------------------------------- -// This routine generates the matrix for the projection of the solution to finer grids -//--------------------------------------------------------------------------------------------------- - -void MultiLevelSolution::BuildProlongatorMatrix(unsigned gridf, unsigned SolIndex) { - - if (gridf<1) { - cout<<"Error! In function \"BuildProlongatorMatrix\" argument less then 1"<_ProjMatFlag[ThisSolType]==0){ - _solution[gridf]->_ProjMatFlag[ThisSolType]=1; - - Mesh* mshf = _ml_msh->GetLevel(gridf); - Mesh* mshc = _ml_msh->GetLevel(gridf-1); - - int nf = mshf->MetisOffset[ThisSolType][_nprocs]; - int nc = mshc->MetisOffset[ThisSolType][_nprocs]; - int nf_loc = mshf->own_size[ThisSolType][_iproc]; - int nc_loc = mshc->own_size[ThisSolType][_iproc]; - - //build matrix sparsity pattern size - - NumericVector *NNZ_d = NumericVector::build().release(); - NNZ_d->init(*_solution[gridf]->_Sol[SolIndex]); - NNZ_d->zero(); - - NumericVector *NNZ_o = NumericVector::build().release(); - NNZ_o->init(*_solution[gridf]->_Sol[SolIndex]); - NNZ_o->zero(); - - for(int isdom=_iproc; isdom<_iproc+1; isdom++) { - for (int iel_mts=mshc->IS_Mts2Gmt_elem_offset[isdom];iel_mts < mshc->IS_Mts2Gmt_elem_offset[isdom+1]; iel_mts++) { - unsigned iel = mshc->IS_Mts2Gmt_elem[iel_mts]; - if(mshc->el->GetRefinedElementIndex(iel)){ //only if the coarse element has been refined - short unsigned ielt=mshc->el->GetElementType(iel); - _ml_msh->_finiteElement[ielt][ThisSolType]->GetSparsityPatternSize(*mshf, *mshc, iel, NNZ_d, NNZ_o); - } - } - } - NNZ_d->close(); - NNZ_o->close(); - - unsigned offset = mshf->MetisOffset[ThisSolType][_iproc]; - vector nnz_d(nf_loc); - vector nnz_o(nf_loc); - for(int i=0; i ((*NNZ_d)(offset+i)); - nnz_o[i]=static_cast ((*NNZ_o)(offset+i)); - } - - delete NNZ_d; - delete NNZ_o; - - //build matrix - - _solution[gridf]->_ProjMat[ThisSolType] = SparseMatrix::build().release(); - _solution[gridf]->_ProjMat[ThisSolType]->init(nf,nc,nf_loc,nc_loc,nnz_d,nnz_o); - - // loop on the coarse grid - for(int isdom=_iproc; isdom<_iproc+1; isdom++) { - for (int iel_mts=mshc->IS_Mts2Gmt_elem_offset[isdom]; - iel_mts < mshc->IS_Mts2Gmt_elem_offset[isdom+1]; iel_mts++) { - unsigned iel = mshc->IS_Mts2Gmt_elem[iel_mts]; - if(mshc->el->GetRefinedElementIndex(iel)){ //only if the coarse element has been refined - short unsigned ielt=mshc->el->GetElementType(iel); - _ml_msh->_finiteElement[ielt][ThisSolType]->BuildProlongation(*mshf,*mshc,iel, _solution[gridf]->_ProjMat[ThisSolType]); - } - } - } - _solution[gridf]->_ProjMat[ThisSolType]->close(); - } -} - //--------------------------------------------------------------------------------------------------- void MultiLevelSolution::AttachSetBoundaryConditionFunction ( bool (* SetBoundaryConditionFunction) (const double &x, const double &y, const double &z,const char name[], double &value, const int FaceName, const double time) ) { diff --git a/src/solution/MultiLevelSolution.hpp b/src/solution/MultiLevelSolution.hpp index 7da12ff60..a32c61214 100644 --- a/src/solution/MultiLevelSolution.hpp +++ b/src/solution/MultiLevelSolution.hpp @@ -61,6 +61,9 @@ class MultiLevelSolution : public ParallelObject { /** To be Added */ void AssociatePropertyToSolution(const char solution_name[], const char solution_property[]); + /** To be Added */ + void PairSolution(const char solution_name[], const char solution_pair[]); + /** To be Added */ void ResizeSolutionVector( const char name[]); @@ -88,9 +91,6 @@ class MultiLevelSolution : public ParallelObject { return _SolType; }; - /** To be Added */ - void BuildProlongatorMatrix(unsigned gridf, unsigned SolIndex); - /** To be Added */ void AttachSetBoundaryConditionFunction ( bool (* SetBoundaryConditionFunction) (const double &x, const double &y, const double &z,const char name[], double &value, const int FaceName, const double time) ); @@ -157,9 +157,9 @@ class MultiLevelSolution : public ParallelObject { }; /** To be Added */ - bool TestIfSolutionIsDisplacemenet(unsigned i) { - return _TestIfDisplacement[i]; - }; + unsigned GetSolutionPairIndex(const unsigned& i) const{ + return _SolPairIndex[i]; + } // member data MultiLevelMesh* _ml_msh; //< Multilevel mesh @@ -209,7 +209,7 @@ class MultiLevelSolution : public ParallelObject { vector _SolTmorder; vector _PdeType; vector _TestIfPressure; - vector _TestIfDisplacement; + vector _SolPairIndex; /** Multilevel solution writer */ Writer* _writer; diff --git a/src/solution/Solution.cpp b/src/solution/Solution.cpp index 8ce90d81a..a39b03003 100644 --- a/src/solution/Solution.cpp +++ b/src/solution/Solution.cpp @@ -38,7 +38,6 @@ using std::endl; Solution::Solution(Mesh *other_msh){ _msh = other_msh; for(int i=0;i<5;i++){ - _ProjMatFlag[i]=0; _GradMat[i].resize(_msh->GetDimension()); _AMR_flag=0; } @@ -193,9 +192,6 @@ void Solution::FreeSolutionVectors() { delete _AMREps[i]; } for (unsigned i=0; i<5; i++) { - if (_ProjMatFlag[i]) { - delete _ProjMat[i]; - } for(int j=0;j<_msh->GetDimension();j++){ if(_GradMat[i][j]){ delete _GradMat[i][j]; diff --git a/src/solution/Solution.hpp b/src/solution/Solution.hpp index decdb5067..694cd2ea7 100644 --- a/src/solution/Solution.hpp +++ b/src/solution/Solution.hpp @@ -104,10 +104,6 @@ class Solution : public ParallelObject { vector _ResEpsBdcFlag; vector < vector > _GradVec; - - /** one for every type of variable */ - SparseMatrix* _ProjMat[5]; - bool _ProjMatFlag[5]; vector _GradMat[5]; // bool _GradMatFlag[5]; diff --git a/src/solution/VTKWriter.cpp b/src/solution/VTKWriter.cpp index 12e05c65f..6dc49290b 100644 --- a/src/solution/VTKWriter.cpp +++ b/src/solution/VTKWriter.cpp @@ -23,11 +23,11 @@ #include #include #include -#include "string.h" -#include "stdio.h" +#include +#include #include #include - +#include "Files.hpp" namespace femus { @@ -35,89 +35,109 @@ namespace femus { short unsigned int VTKWriter::femusToVtkCellType[3][6]= {{12,10,13,9,5,3},{25,24,26,23,22,21},{29,24,32,28,22,21}}; -VTKWriter::VTKWriter(MultiLevelSolution & ml_probl): Writer(ml_probl) -{ - -} +VTKWriter::VTKWriter(MultiLevelSolution * ml_sol): Writer(ml_sol) {} -VTKWriter::~VTKWriter() -{ - -} +VTKWriter::VTKWriter(MultiLevelMesh * ml_mesh): Writer(ml_mesh) {} +VTKWriter::~VTKWriter() {} -void VTKWriter::write_system_solutions(const std::string output_path, const char order[], std::vector& vars, const unsigned time_step) -{ - bool print_all = 0; - for (unsigned ivar=0; ivar < vars.size(); ivar++){ - print_all += !(vars[ivar].compare("All")) + !(vars[ivar].compare("all")) + !(vars[ivar].compare("ALL")); - } + +void VTKWriter::Pwrite(const std::string output_path, const char order[], const std::vector < std::string > & vars, const unsigned time_step) const { + + // *********** open vtu files ************* + std::ofstream fout; + std::string dirnamePVTK = "VTKParallelFiles/"; + Files files; + files.CheckDir(output_path,dirnamePVTK); + int icount; unsigned index=0; - unsigned index_nd=0; - if (!strcmp(order,"linear")) { //linear - index=0; - index_nd=0; - } else if (!strcmp(order,"quadratic")) { //quadratic - index=1; - index_nd=1; - } else if (!strcmp(order,"biquadratic")) { //biquadratic - index=2; - index_nd=2; + if (!strcmp(order,"linear")) index=0; //linear + else if (!strcmp(order,"quadratic")) index=1; //quadratic + else if (!strcmp(order,"biquadratic")) index=2; //biquadratic + + std::string filename_prefix; + if( _ml_sol != NULL ) filename_prefix = "sol"; + else filename_prefix = "mesh"; + + std::ostringstream filename; + filename << output_path << "/"<" << std::endl; + fout<<"" << std::endl; + fout << " " << std::endl; - std::ostringstream filename; - filename << output_path << "/sol.level" << _gridn << "." << time_step << "." << order << ".vtu"; - std::ofstream fout; - + // *********** open pvtu file ************* + std::ofstream Pfout; if(_iproc!=0) { - fout.rdbuf(); //redirect to dev_null + Pfout.rdbuf(); //redirect to dev_null } else { - fout.open(filename.str().c_str()); - if (fout.is_open()) { - std::cout << std::endl << " The output is printed to file " << filename.str() << " in VTK-XML (64-based) format" << std::endl; + std::ostringstream Pfilename; + Pfilename << output_path << "/" << filename_prefix << ".level" << _gridn <<"."<< time_step << "." << order << ".pvtu"; + Pfout.open(Pfilename.str().c_str()); + if (Pfout.is_open()) { + std::cout << std::endl << " The output is printed to file " << Pfilename.str() << " in parallel VTK-XML (64-based) format" << std::endl; } else { - std::cout << std::endl << " The output file "<< filename.str() <<" cannot be opened.\n"; + std::cout << std::endl << " The output file "<< Pfilename.str() <<" cannot be opened.\n"; abort(); } } - // head ************************************************ - fout<<"" << std::endl; - fout<<"" << std::endl; - fout << " " << std::endl; - //----------------------------------------------------------------------------------------------------------- - - //---------------------------------------------------------------------------------------------------------- + // *********** write pvtu header *********** + Pfout<<"" << std::endl; + Pfout<<"" << std::endl; + Pfout<< " " << std::endl; + for(int jproc=0;jproc<_nprocs;jproc++){ + Pfout<<" " << std::endl; + } + // **************************************** - unsigned nvt=0; + + //count the own node dofs on all levels + unsigned nvt = 0; for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { - unsigned nvt_ig=_ml_sol._ml_msh->GetLevel(ig)->MetisOffset[index_nd][_nprocs]; - nvt+=nvt_ig; - } - - unsigned nel=0; + unsigned nvt_ig = _ml_mesh->GetLevel(ig)->own_size[index][_iproc]; + nvt += nvt_ig; + } + + // count the ghost node dofs and the own element dofs element on all levels + unsigned ghost_counter = 0; unsigned counter=0; - for (unsigned ig=_gridr-1u; ig<_gridn-1u; ig++) { - nel+=( _ml_sol._ml_msh->GetLevel(ig)->GetNumberOfElements() - _ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementNumber()); - counter+=(_ml_sol._ml_msh->GetLevel(ig)->el->GetElementNumber("Hex")-_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementNumber("Hex"))*NVE[0][index]; - counter+=(_ml_sol._ml_msh->GetLevel(ig)->el->GetElementNumber("Tet")-_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementNumber("Tet"))*NVE[1][index]; - counter+=(_ml_sol._ml_msh->GetLevel(ig)->el->GetElementNumber("Wedge")-_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementNumber("Wedge"))*NVE[2][index]; - counter+=(_ml_sol._ml_msh->GetLevel(ig)->el->GetElementNumber("Quad")-_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementNumber("Quad"))*NVE[3][index]; - counter+=(_ml_sol._ml_msh->GetLevel(ig)->el->GetElementNumber("Triangle")-_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementNumber("Triangle"))*NVE[4][index]; - counter+=(_ml_sol._ml_msh->GetLevel(ig)->el->GetElementNumber("Line")-_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementNumber("Line"))*NVE[5][index]; + unsigned nel=0; + for (unsigned ig = _gridr-1u; ig<_gridn; ig++) { + unsigned offset_iprc = _ml_mesh->GetLevel(ig)->MetisOffset[index][_iproc]; + for (int iel=_ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == _gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + nel++; + short unsigned ielt = _ml_mesh->GetLevel(ig)->el->GetElementType(kel); + for (unsigned j=0; j<_ml_mesh->GetLevel(ig)->el->GetElementDofNumber(kel,index); j++) { + counter++; + unsigned loc_vtk_conn = map_pr[j]; + unsigned jnode=_ml_mesh->GetLevel(ig)->el->GetMeshDof(kel, loc_vtk_conn, index); + unsigned jnodeMetis = _ml_mesh->GetLevel(ig)->GetMetisDof(jnode, index); + if( jnodeMetis < offset_iprc ){ // check if jnodeMetis is a ghost node + ghost_counter++; + } + } + } + } } - nel+=_ml_sol._ml_msh->GetLevel(_gridn-1u)->GetNumberOfElements(); - counter+=_ml_sol._ml_msh->GetLevel(_gridn-1u)->el->GetElementNumber("Hex")*NVE[0][index]; - counter+=_ml_sol._ml_msh->GetLevel(_gridn-1u)->el->GetElementNumber("Tet")*NVE[1][index]; - counter+=_ml_sol._ml_msh->GetLevel(_gridn-1u)->el->GetElementNumber("Wedge")*NVE[2][index]; - counter+=_ml_sol._ml_msh->GetLevel(_gridn-1u)->el->GetElementNumber("Quad")*NVE[3][index]; - counter+=_ml_sol._ml_msh->GetLevel(_gridn-1u)->el->GetElementNumber("Triangle")*NVE[4][index]; - counter+=_ml_sol._ml_msh->GetLevel(_gridn-1u)->el->GetElementNumber("Line")*NVE[5][index]; + + unsigned nvt0 = nvt; + nvt += ghost_counter; // total node dofs (own + ghost) const unsigned dim_array_coord [] = { nvt*3*sizeof(float) }; const unsigned dim_array_conn[] = { counter*sizeof(int) }; @@ -128,7 +148,7 @@ void VTKWriter::write_system_solutions(const std::string output_path, const char const unsigned dim_array_ndvar [] = { nvt*sizeof(float) }; // initialize common buffer_void memory - unsigned buffer_size=(dim_array_coord[0]>dim_array_conn[0])?dim_array_coord[0]:dim_array_conn[0]; + unsigned buffer_size=(dim_array_coord[0]>dim_array_conn[0])? dim_array_coord[0] : dim_array_conn[0]; void *buffer_void=new char [buffer_size]; char *buffer_char=static_cast (buffer_void); @@ -138,110 +158,153 @@ void VTKWriter::write_system_solutions(const std::string output_path, const char enc.resize(cch); char *pt_char; - fout << " " << std::endl; + fout << " " << std::endl; //----------------------------------------------------------------------------------------------- // print coordinates *********************************************Solu******************************************* - fout << " " << std::endl; - fout << " " << std::endl; + fout << " " << std::endl; + fout << " " << std::endl; + Pfout << " " << std::endl; + Pfout << " " << std::endl; - vector mysol(_gridn); + vector < NumericVector* > mysol(_gridn); for(unsigned ig=_gridr-1u; ig<_gridn; ig++) { mysol[ig] = NumericVector::build().release(); - mysol[ig]->init(_ml_sol._ml_msh->GetLevel(ig)->MetisOffset[index_nd][_nprocs],_ml_sol._ml_msh->GetLevel(ig)->own_size[index_nd][_iproc],true,AUTOMATIC); + + if(n_processors()==1) { // IF SERIAL + mysol[ig]->init(_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs], + _ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs],false,SERIAL); + } + else{ // IF PARALLEL + mysol[ig]->init(_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs], + _ml_mesh->GetLevel(ig)->own_size[index][_iproc], + _ml_mesh->GetLevel(ig)->ghost_nd_mts[index][_iproc],false,GHOSTED ); + } } - + // point pointer to common mamory area buffer of void type; float *var_coord= static_cast(buffer_void); - - unsigned offset_nvt3=0; - for(unsigned ig=_gridr-1u; ig<_gridn; ig++) { - std::vector v_local; - unsigned nvt_ig=_ml_sol._ml_msh->GetLevel(ig)->MetisOffset[index_nd][_nprocs]; - for(int kk=0;kk<3;kk++) { - mysol[ig]->matrix_mult(*_ml_sol._ml_msh->GetLevel(ig)->_coordinate->_Sol[kk],*_ProlQitoQj[index_nd][2][ig]); - mysol[ig]->localize_to_one(v_local,0); - if(_iproc==0) { - for (unsigned i=0; iGetLevel(ig)->MetisOffset[index][_iproc]; + unsigned nvt_ig = _ml_mesh->GetLevel(ig)->own_size[index][_iproc]; + for (int i = 0; i < 3; i++) { + mysol[ig]->matrix_mult(*_ml_mesh->GetLevel(ig)->_coordinate->_Sol[i], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index,2) ); + for (unsigned ii = 0; ii < nvt_ig; ii++) { + var_coord[ offset_ig + ii*3 + i] = (*mysol[ig])(ii + offset_iprc); + } + if (_ml_sol != NULL && _moving_mesh && _ml_mesh->GetLevel(0)->GetDimension() > i) { // if moving mesh + unsigned indDXDYDZ=_ml_sol->GetIndex(_moving_vars[i].c_str()); + mysol[ig]->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Sol[indDXDYDZ], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index,_ml_sol->GetSolutionType(indDXDYDZ)) ); + for (unsigned ii=0; iiGetLevel(0)->GetDimension() == 3) { - indDXDYDZ[2]=_ml_sol.GetIndex(_moving_vars[2].c_str()); - } - - for(unsigned ig=_gridr-1u; ig<_gridn; ig++){ - std::vector v_local; - unsigned nvt_ig=_ml_sol._ml_msh->GetLevel(ig)->MetisOffset[index_nd][_nprocs]; - for(int kk=0;kk<_ml_sol._ml_msh->GetLevel(0)->GetDimension();kk++) { - mysol[ig]->matrix_mult(*_ml_sol.GetSolutionLevel(ig)->_Sol[indDXDYDZ[kk]],*_ProlQitoQj[index_nd][_ml_sol.GetSolutionType(indDXDYDZ[kk])][ig]); - mysol[ig]->localize_to_one(v_local,0); - if(_iproc==0) { - for (unsigned i=0; iGetLevel(ig)->MetisOffset[index][_iproc]; + unsigned icounter; + for (int i=0; i<3; i++) { + mysol[ig]->matrix_mult(*_ml_mesh->GetLevel(ig)-> _coordinate->_Sol[i], + *_ml_mesh->GetLevel(ig)-> GetQitoQjProjection(index,2) ); + icounter=0; + for (int iel = _ml_mesh->GetLevel(ig)-> IS_Mts2Gmt_elem_offset[_iproc]; + iel < _ml_mesh->GetLevel(ig)-> IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == _gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + short unsigned ielt=_ml_mesh->GetLevel(ig)->el->GetElementType(kel); + for (unsigned j=0; j<_ml_mesh->GetLevel(ig)->el->GetElementDofNumber(kel,index); j++) { + unsigned loc_vtk_conn = map_pr[j]; + unsigned jnode=_ml_mesh->GetLevel(ig)->el->GetMeshDof(kel, loc_vtk_conn, index); + unsigned jnodeMetis = _ml_mesh->GetLevel(ig)->GetMetisDof(jnode, index); + if( jnodeMetis < offset_iprc ){ + var_coord[ offset_ig + icounter + i] = (*mysol[ig])(jnodeMetis); + icounter += 3; + } } - } //if iproc - } //loop over dimension - offset_nvt3+=3*nvt_ig; + } + } + if (_ml_sol != NULL && _moving_mesh && _ml_mesh->GetLevel(0)->GetDimension() > i) { // if moving mesh + unsigned indDXDYDZ=_ml_sol->GetIndex(_moving_vars[i].c_str()); + mysol[ig]->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Sol[indDXDYDZ], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index,_ml_sol->GetSolutionType(indDXDYDZ)) ); + icounter=0; + for (int iel = _ml_mesh->GetLevel(ig)-> IS_Mts2Gmt_elem_offset[_iproc]; + iel < _ml_mesh->GetLevel(ig)-> IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == _gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + short unsigned ielt=_ml_mesh->GetLevel(ig)->el->GetElementType(kel); + for (unsigned j=0; j<_ml_mesh->GetLevel(ig)->el->GetElementDofNumber(kel,index); j++) { + unsigned loc_vtk_conn = map_pr[j]; + unsigned jnode=_ml_mesh->GetLevel(ig)->el->GetMeshDof(kel, loc_vtk_conn, index); + unsigned jnodeMetis = _ml_mesh->GetLevel(ig)->GetMetisDof(jnode, index); + if( jnodeMetis < offset_iprc ){ + var_coord[ offset_ig + icounter + i] += (*mysol[ig])(jnodeMetis); + icounter += 3; + } + } + } + } + } } + offset_ig += icounter; } - if(_iproc==0) { - //print coordinates dimension - cch = b64::b64_encode(&dim_array_coord[0], sizeof(dim_array_coord), NULL, 0); - b64::b64_encode(&dim_array_coord[0], sizeof(dim_array_coord), &enc[0], cch); - pt_char=&enc[0]; - for( unsigned i =0; i" << std::endl; - fout << " " << std::endl; + //print coordinates array + cch = b64::b64_encode(&var_coord[0], dim_array_coord[0] , NULL, 0); + b64::b64_encode(&var_coord[0], dim_array_coord[0], &enc[0], cch); + pt_char=&enc[0]; + for( unsigned i =0; i" << std::endl; + fout << " " << std::endl; + Pfout << " " << std::endl; //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- // Printing of element connectivity - offset - format type * - fout << " " << std::endl; - + fout << " " << std::endl; + Pfout << " " << std::endl; //----------------------------------------------------------------------------------------------- //print connectivity - fout << " " << std::endl; + fout << " " << std::endl; + Pfout << " " << std::endl; // point pointer to common mamory area buffer of void type; int *var_conn = static_cast (buffer_void); icount = 0; + ghost_counter = 0; unsigned offset_nvt=0; for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { - for (unsigned iel=0; iel<_ml_sol._ml_msh->GetLevel(ig)->GetNumberOfElements(); iel++) { - if (ig==_gridn-1u || _ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementIndex(iel)==0) { - for (unsigned j=0; j<_ml_sol._ml_msh->GetLevel(ig)->el->GetElementDofNumber(iel,index); j++) { + unsigned offset_iprc = _ml_mesh->GetLevel(ig)->MetisOffset[index][_iproc]; + unsigned nvt_ig= _ml_mesh->GetLevel(ig)->own_size[index][_iproc]; + for (int iel=_ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == _gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + for (unsigned j=0; j<_ml_mesh->GetLevel(ig)->el->GetElementDofNumber(kel,index); j++) { unsigned loc_vtk_conn = map_pr[j]; - unsigned jnode=_ml_sol._ml_msh->GetLevel(ig)->el->GetElementVertexIndex(iel,loc_vtk_conn)-1u; - unsigned jnode_Metis = _ml_sol._ml_msh->GetLevel(ig)->GetMetisDof(jnode,index_nd); - var_conn[icount] = offset_nvt+jnode_Metis; + unsigned jnode=_ml_mesh->GetLevel(ig)->el->GetMeshDof(kel, loc_vtk_conn, index); + unsigned jnodeMetis = _ml_mesh->GetLevel(ig)->GetMetisDof(jnode, index); + var_conn[icount] = (jnodeMetis >= offset_iprc )? jnodeMetis - offset_iprc + offset_nvt : nvt0 + (ghost_counter++); icount++; } } } - offset_nvt+=_ml_sol._ml_msh->GetLevel(ig)->MetisOffset[index_nd][_nprocs]; + offset_nvt+= nvt_ig; } - + //print connectivity dimension cch = b64::b64_encode(&dim_array_conn[0], sizeof(dim_array_conn), NULL, 0); b64::b64_encode(&dim_array_conn[0], sizeof(dim_array_conn), &enc[0], cch); @@ -253,26 +316,28 @@ void VTKWriter::write_system_solutions(const std::string output_path, const char b64::b64_encode(&var_conn[0], dim_array_conn[0], &enc[0], cch); pt_char=&enc[0]; for( unsigned i =0; i" << std::endl; + fout << " " << std::endl; //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------- //printing offset - fout << " " << std::endl; + fout << " " << std::endl; + Pfout << " " << std::endl; + + // point pointer to common mamory area buffer of void type; int *var_off=static_cast (buffer_void); icount = 0; int offset_el=0; //print offset array + for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { - for (unsigned iel=0; iel<_ml_sol._ml_msh->GetLevel(ig)->GetNumberOfElements(); iel++) { - if ( ig==_gridn-1u || 0==_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementIndex(iel)) { - unsigned iel_Metis = _ml_sol._ml_msh->GetLevel(ig)->GetMetisDof(iel,3); - offset_el += _ml_sol._ml_msh->GetLevel(ig)->el->GetElementDofNumber(iel_Metis,index); + for (int iel=_ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == _gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + offset_el += _ml_mesh->GetLevel(ig)->el->GetElementDofNumber(kel,index); var_off[icount] = offset_el; icount++; } @@ -291,29 +356,30 @@ void VTKWriter::write_system_solutions(const std::string output_path, const char pt_char=&enc[0]; for( unsigned i =0; i" << std::endl; + fout << " " << std::endl; //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- //Element format type : 23:Serendipity(8-nodes) 28:Quad9-Biquadratic - fout << " " << std::endl; - + fout << " " << std::endl; + Pfout << " " << std::endl; + // point pointer to common mamory area buffer of void type; unsigned short *var_type = static_cast (buffer_void); icount=0; for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { - for (unsigned ii=0; ii<_ml_sol._ml_msh->GetLevel(ig)->GetNumberOfElements(); ii++) { - if (ig==_gridn-1u || _ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementIndex(ii)==0) { - unsigned iel_Metis = _ml_sol._ml_msh->GetLevel(ig)->GetMetisDof(ii,3); - short unsigned ielt= _ml_sol._ml_msh->GetLevel(ig)->el->GetElementType(iel_Metis); + for (int iel=_ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == _gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + short unsigned ielt= _ml_mesh->GetLevel(ig)->el->GetElementType(kel); var_type[icount] = femusToVtkCellType[index][ielt]; icount++; } } } - + //print element format dimension cch = b64::b64_encode(&dim_array_type[0], sizeof(dim_array_type), NULL, 0); b64::b64_encode(&dim_array_type[0], sizeof(dim_array_type), &enc[0], cch); @@ -326,28 +392,32 @@ void VTKWriter::write_system_solutions(const std::string output_path, const char pt_char=&enc[0]; for( unsigned i =0; i" << std::endl; + fout << std::endl; + fout << " " << std::endl; //---------------------------------------------------------------------------------------------------- - - fout << " " << std::endl; +// + fout << " " << std::endl; + Pfout << " " << std::endl; //-------------------------------------------------------------------------------------------------- // /Print Cell Data **************************************************************************** - fout << " " << std::endl; - + fout << " " << std::endl; + Pfout << " " << std::endl; //-------------------------------------------------------------------------------------------- // Print Regions - fout << " " << std::endl; + fout << " " << std::endl; + Pfout << " " << std::endl; + // point pointer to common mamory area buffer of void type; unsigned short* var_reg=static_cast (buffer_void); + icount=0; for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { - for (unsigned ii=0; ii<_ml_sol._ml_msh->GetLevel(ig)->GetNumberOfElements(); ii++) { - if ( ig==_gridn-1u || 0==_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { - unsigned iel_Metis = _ml_sol._ml_msh->GetLevel(ig)->GetMetisDof(ii,3); - var_reg[icount]= _ml_sol._ml_msh->GetLevel(ig)->el->GetElementGroup(ii); + for (int iel=_ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == _gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + var_reg[icount]= _ml_mesh->GetLevel(ig)->el->GetElementGroup(kel); icount++; } } @@ -366,20 +436,23 @@ void VTKWriter::write_system_solutions(const std::string output_path, const char pt_char=&enc[0]; for( unsigned i =0; i" << std::endl; + fout << std::endl; + fout << " " << std::endl; + //----------------------------------------------------------------------------------------------------- // Print Metis Partitioning - fout << " " << std::endl; + fout << " " << std::endl; + Pfout << " " << std::endl; // point pointer to common mamory area buffer of void type; unsigned short* var_proc=static_cast (buffer_void); + icount=0; for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { - for (unsigned ii=0; ii<_ml_sol._ml_msh->GetLevel(ig)->GetNumberOfElements(); ii++) { - if ( ig==_gridn-1u || 0==_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { - unsigned iel_Metis = _ml_sol._ml_msh->GetLevel(ig)->GetMetisDof(ii,3); - var_proc[icount]=(unsigned short)(_ml_sol._ml_msh->GetLevel(ig)->epart[ii]); + for (int iel=_ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == _gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + var_proc[icount]=(unsigned short)(_ml_mesh->GetLevel(ig)->epart[kel]); icount++; } } @@ -398,113 +471,622 @@ void VTKWriter::write_system_solutions(const std::string output_path, const char pt_char=&enc[0]; for( unsigned i =0; i" << std::endl; + fout << std::endl; + fout << " " << std::endl; + if (_ml_sol == NULL) { + delete [] var_proc; + } - - //Print Solution (on element) *************************************************************** - for (unsigned i=0; i<(!print_all)*vars.size() + print_all*_ml_sol.GetSolutionSize(); i++) { - unsigned indx=( print_all == 0 ) ? _ml_sol.GetIndex(vars[i].c_str()):i; - if (3 <= _ml_sol.GetSolutionType(indx)) { - fout << " " << std::endl; - // point pointer to common memory area buffer of void type; - float *var_el = static_cast< float*> (buffer_void); - icount=0; - for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { - vector sol_local; - _ml_sol.GetSolutionLevel(ig)->_Sol[indx]->localize_to_one(sol_local,0); - for (unsigned ii=0; ii<_ml_sol._ml_msh->GetLevel(ig)->GetNumberOfElements(); ii++) { - if (ig==_gridn-1u || 0==_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { - unsigned iel_Metis = _ml_sol._ml_msh->GetLevel(ig)->GetMetisDof(ii,_ml_sol.GetSolutionType(indx)); - var_el[icount]=sol_local[iel_Metis]; - icount++; + bool print_all = 0; + for (unsigned ivar=0; ivar < vars.size(); ivar++){ + print_all += !(vars[ivar].compare("All")) + !(vars[ivar].compare("all")) + !(vars[ivar].compare("ALL")); + } + if (_ml_sol != NULL) { + //Print Solution (on element) *************************************************************** + for (unsigned i=0; i<(!print_all)*vars.size() + print_all*_ml_sol->GetSolutionSize(); i++) { + unsigned solIndex=( print_all == 0 ) ? _ml_sol->GetIndex(vars[i].c_str()):i; + if (3 <= _ml_sol->GetSolutionType(solIndex)) { + fout << " GetSolutionName(solIndex) <<"\" format=\"binary\">" << std::endl; + Pfout << " GetSolutionName(solIndex) <<"\" format=\"binary\"/>" << std::endl; + // point pointer to common memory area buffer of void type; + float *var_el = static_cast< float*> (buffer_void); + icount=0; + for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { + for (unsigned iel=_ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc]; iel < _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == _gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + unsigned iel_Metis = _ml_mesh->GetLevel(ig)->GetMetisDof(kel,_ml_sol->GetSolutionType(i)); + var_el[icount] = (*_ml_sol->GetSolutionLevel(ig)->_Sol[i])(iel_Metis); + icount++; + } } } - } - - if(_iproc==0) { - //print solution on element dimension - cch = b64::b64_encode(&dim_array_elvar[0], sizeof(dim_array_elvar), NULL, 0); - b64::b64_encode(&dim_array_elvar[0], sizeof(dim_array_elvar), &enc[0], cch); - pt_char=&enc[0]; - for( unsigned i =0; i" << std::endl; + //print solution on element array + cch = b64::b64_encode(&var_el[0], dim_array_elvar[0] , NULL, 0); + b64::b64_encode(&var_el[0], dim_array_elvar[0], &enc[0], cch); + pt_char=&enc[0]; + for( unsigned i =0; i" << std::endl; + //---------------------------------------------------------------------------------------------------- } - //---------------------------------------------------------------------------------------------------- - } + } //end _ml_sol != NULL } - fout << " " << std::endl; + fout << " " << std::endl; + Pfout << " " << std::endl; // //------------------------------------------------------------------------------------------------ - // + + if (_ml_sol != NULL) { // //------------------------------------------------------------------------------------------------ // / Print Solution (on nodes) ******************************************************************** - fout<< " " << std::endl; + fout << " " << std::endl; + Pfout << " " << std::endl; //Loop on variables // point pointer to common memory area buffer of void type; float* var_nd = static_cast(buffer_void); - for (unsigned i=0; i<(!print_all)*vars.size()+ print_all*_ml_sol.GetSolutionSize(); i++) { - unsigned indx=( print_all == 0 )?_ml_sol.GetIndex(vars[i].c_str()):i; - if (_ml_sol.GetSolutionType(indx)<3) { - fout << " " << std::endl; + for (unsigned i=0; i< (!print_all)*vars.size() + print_all*_ml_sol->GetSolutionSize(); i++) { + unsigned solIndex=( print_all == 0 )?_ml_sol->GetIndex(vars[i].c_str()):i; + if (_ml_sol->GetSolutionType(solIndex)<3) { + fout << " GetSolutionName(solIndex) <<"\" format=\"binary\">" << std::endl; + Pfout << " GetSolutionName(solIndex) <<"\" format=\"binary\"/>" << std::endl; + //print solutions on nodes dimension cch = b64::b64_encode(&dim_array_ndvar[0], sizeof(dim_array_ndvar), NULL, 0); b64::b64_encode(&dim_array_ndvar[0], sizeof(dim_array_ndvar), &enc[0], cch); pt_char=&enc[0]; for( unsigned i =0; imatrix_mult(*_ml_sol.GetSolutionLevel(ig)->_Sol[indx],*_ProlQitoQj[index_nd][_ml_sol.GetSolutionType(indx)][ig]); - vector sol_local; - mysol[ig]->localize_to_one(sol_local,0); - unsigned nvt_ig=_ml_sol._ml_msh->GetLevel(ig)->MetisOffset[index_nd][_nprocs]; - for (unsigned ii=0; iiGetLevel(ig)->MetisOffset[index][_iproc]; + unsigned nvt_ig = _ml_mesh->GetLevel(ig)->own_size[index][_iproc]; + + mysol[ig]->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Sol[solIndex], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index,_ml_sol->GetSolutionType(solIndex)) ); + + for (unsigned ii = 0; ii < nvt_ig; ii++) { + var_nd[ offset_ig + ii ] = (*mysol[ig])(ii + offset_iprc); } - offset_nvt+=nvt_ig; + offset_ig += nvt_ig; } - - if(_iproc==0) { - cch = b64::b64_encode(&var_nd[0], dim_array_ndvar [0], NULL, 0); - b64::b64_encode(&var_nd[0], dim_array_ndvar [0], &enc[0], cch); - pt_char=&enc[0]; - for( unsigned i =0; i" << std::endl; + unsigned icounter = 0; + for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { + unsigned offset_iprc = _ml_mesh->GetLevel(ig)->MetisOffset[index][_iproc]; + for (int iel = _ml_mesh->GetLevel(ig)-> IS_Mts2Gmt_elem_offset[_iproc]; + iel < _ml_mesh->GetLevel(ig)-> IS_Mts2Gmt_elem_offset[_iproc+1]; iel++) { + unsigned kel = _ml_mesh->GetLevel(ig)->IS_Mts2Gmt_elem[iel]; + if ( ig == _gridn-1u || 0 == _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(kel)) { + short unsigned ielt=_ml_mesh->GetLevel(ig)->el->GetElementType(kel); + for (unsigned j=0; j<_ml_mesh->GetLevel(ig)->el->GetElementDofNumber(kel,index); j++) { + unsigned loc_vtk_conn = map_pr[j]; + unsigned jnode=_ml_mesh->GetLevel(ig)->el->GetMeshDof(kel, loc_vtk_conn, index); + unsigned jnodeMetis = _ml_mesh->GetLevel(ig)->GetMetisDof(jnode, index); + if( jnodeMetis < offset_iprc ){ + var_nd[ offset_ig + icounter] = (*mysol[ig])(jnodeMetis); + icounter++; + } + } + } + } } - } //endif - } // end for sol - fout << " " << std::endl; - + + cch = b64::b64_encode(&var_nd[0], dim_array_ndvar [0], NULL, 0); + b64::b64_encode(&var_nd[0], dim_array_ndvar [0], &enc[0], cch); + pt_char=&enc[0]; + for( unsigned i =0; i" << std::endl; + } //endif + } // end for sol + fout << " " << std::endl; + Pfout << " " << std::endl; + delete [] var_nd; + } //end _ml_sol != NULL + //------------------------------------------------------------------------------------------------ - fout << " " << std::endl; - fout << " " << std::endl; + fout << " " << std::endl; + fout << " " << std::endl; fout << "" << std::endl; fout.close(); + Pfout << " " << std::endl; + Pfout << "" << std::endl; + Pfout.close(); + + //----------------------------------------------------------------------------------------------------- //free memory for(unsigned ig=_gridr-1u; ig<_gridn; ig++) { delete mysol[ig]; } - - delete [] var_nd; //-------------------------------------------------------------------------------------------------------- return; } +// void VTKWriter::write(const std::string output_path, const char order[], const std::vector < std::string > & vars, const unsigned time_step) const { +// +// ParallelWrite(output_path, order, vars, time_step); +// bool print_all = 0; +// for (unsigned ivar=0; ivar < vars.size(); ivar++){ +// print_all += !(vars[ivar].compare("All")) + !(vars[ivar].compare("all")) + !(vars[ivar].compare("ALL")); +// } +// +// int icount; +// unsigned index=0; +// if (!strcmp(order,"linear")) index=0; //linear +// else if (!strcmp(order,"quadratic")) index=1; //quadratic +// else if (!strcmp(order,"biquadratic")) index=2; //biquadratic +// +// +// std::string filename_prefix; +// if( _ml_sol != NULL ) filename_prefix = "sol"; +// else filename_prefix = "mesh"; +// +// std::ostringstream filename; +// filename << output_path << "/" << filename_prefix << ".level" << _gridn << "." << time_step << "." << order << ".vtu"; +// +// std::ofstream fout; +// +// if(_iproc!=0) { +// fout.rdbuf(); //redirect to dev_null +// } +// else { +// fout.open(filename.str().c_str()); +// if (fout.is_open()) { +// std::cout << std::endl << " The output is printed to file " << filename.str() << " in VTK-XML (64-based) format" << std::endl; +// } +// else { +// std::cout << std::endl << " The output file "<< filename.str() <<" cannot be opened.\n"; +// abort(); +// } +// } +// +// // head ************************************************ +// fout<<"" << std::endl; +// fout<<"" << std::endl; +// fout << " " << std::endl; +// //----------------------------------------------------------------------------------------------------------- +// +// //---------------------------------------------------------------------------------------------------------- +// +// unsigned nvt=0; +// for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { +// unsigned nvt_ig=_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs]; +// nvt+=nvt_ig; +// } +// +// unsigned nel=0; +// unsigned counter=0; +// for (unsigned ig=_gridr-1u; ig<_gridn-1u; ig++) { +// nel+=( _ml_mesh->GetLevel(ig)->GetNumberOfElements() - _ml_mesh->GetLevel(ig)->el->GetRefinedElementNumber()); +// counter+=(_ml_mesh->GetLevel(ig)->el->GetElementNumber("Hex")-_ml_mesh->GetLevel(ig)->el->GetRefinedElementNumber("Hex"))*NVE[0][index]; +// counter+=(_ml_mesh->GetLevel(ig)->el->GetElementNumber("Tet")-_ml_mesh->GetLevel(ig)->el->GetRefinedElementNumber("Tet"))*NVE[1][index]; +// counter+=(_ml_mesh->GetLevel(ig)->el->GetElementNumber("Wedge")-_ml_mesh->GetLevel(ig)->el->GetRefinedElementNumber("Wedge"))*NVE[2][index]; +// counter+=(_ml_mesh->GetLevel(ig)->el->GetElementNumber("Quad")-_ml_mesh->GetLevel(ig)->el->GetRefinedElementNumber("Quad"))*NVE[3][index]; +// counter+=(_ml_mesh->GetLevel(ig)->el->GetElementNumber("Triangle")-_ml_mesh->GetLevel(ig)->el->GetRefinedElementNumber("Triangle"))*NVE[4][index]; +// counter+=(_ml_mesh->GetLevel(ig)->el->GetElementNumber("Line")-_ml_mesh->GetLevel(ig)->el->GetRefinedElementNumber("Line"))*NVE[5][index]; +// } +// nel+=_ml_mesh->GetLevel(_gridn-1u)->GetNumberOfElements(); +// counter+=_ml_mesh->GetLevel(_gridn-1u)->el->GetElementNumber("Hex")*NVE[0][index]; +// counter+=_ml_mesh->GetLevel(_gridn-1u)->el->GetElementNumber("Tet")*NVE[1][index]; +// counter+=_ml_mesh->GetLevel(_gridn-1u)->el->GetElementNumber("Wedge")*NVE[2][index]; +// counter+=_ml_mesh->GetLevel(_gridn-1u)->el->GetElementNumber("Quad")*NVE[3][index]; +// counter+=_ml_mesh->GetLevel(_gridn-1u)->el->GetElementNumber("Triangle")*NVE[4][index]; +// counter+=_ml_mesh->GetLevel(_gridn-1u)->el->GetElementNumber("Line")*NVE[5][index]; +// +// const unsigned dim_array_coord [] = { nvt*3*sizeof(float) }; +// const unsigned dim_array_conn[] = { counter*sizeof(int) }; +// const unsigned dim_array_off [] = { nel*sizeof(int) }; +// const unsigned dim_array_type [] = { nel*sizeof(short unsigned) }; +// const unsigned dim_array_reg [] = { nel*sizeof(short unsigned) }; +// const unsigned dim_array_elvar [] = { nel*sizeof(float) }; +// const unsigned dim_array_ndvar [] = { nvt*sizeof(float) }; +// +// // initialize common buffer_void memory +// unsigned buffer_size=(dim_array_coord[0]>dim_array_conn[0])?dim_array_coord[0]:dim_array_conn[0]; +// void *buffer_void=new char [buffer_size]; +// char *buffer_char=static_cast (buffer_void); +// +// size_t cch; +// cch = b64::b64_encode(&buffer_char[0], buffer_size , NULL, 0); +// vector enc; +// enc.resize(cch); +// char *pt_char; +// +// fout << " " << std::endl; +// +// //----------------------------------------------------------------------------------------------- +// // print coordinates *********************************************Solu******************************************* +// fout << " " << std::endl; +// fout << " " << std::endl; +// +// +// vector mysol(_gridn); +// for(unsigned ig=_gridr-1u; ig<_gridn; ig++) { +// mysol[ig] = NumericVector::build().release(); +// mysol[ig]->init(_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs],_ml_mesh->GetLevel(ig)->own_size[index][_iproc],true,AUTOMATIC); +// } +// +// // point pointer to common mamory area buffer of void type; +// float *var_coord= static_cast(buffer_void); +// +// unsigned offset_nvt3=0; +// for(unsigned ig=_gridr-1u; ig<_gridn; ig++) { +// std::vector v_local; +// unsigned nvt_ig=_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs]; +// for(int kk=0;kk<3;kk++) { +// mysol[ig]->matrix_mult(*_ml_mesh->GetLevel(ig)->_coordinate->_Sol[kk], +// *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index,2)); +// mysol[ig]->localize_to_one(v_local,0); +// if(_iproc==0) { +// for (unsigned i=0; iGetIndex(_moving_vars[0].c_str()); +// indDXDYDZ[1]=_ml_sol->GetIndex(_moving_vars[1].c_str()); +// if(_ml_mesh->GetLevel(0)->GetDimension() == 3) { +// indDXDYDZ[2]=_ml_sol->GetIndex(_moving_vars[2].c_str()); +// } +// +// for(unsigned ig=_gridr-1u; ig<_gridn; ig++){ +// std::vector v_local; +// unsigned nvt_ig=_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs]; +// for(int kk=0;kk<_ml_mesh->GetLevel(0)->GetDimension();kk++) { +// mysol[ig]->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Sol[indDXDYDZ[kk]], +// *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index,_ml_sol->GetSolutionType(indDXDYDZ[kk]))); +// mysol[ig]->localize_to_one(v_local,0); +// if(_iproc==0) { +// for (unsigned i=0; i" << std::endl; +// fout << " " << std::endl; +// //----------------------------------------------------------------------------------------------- +// +// //----------------------------------------------------------------------------------------------- +// // Printing of element connectivity - offset - format type * +// fout << " " << std::endl; +// +// //----------------------------------------------------------------------------------------------- +// //print connectivity +// fout << " " << std::endl; +// +// // point pointer to common mamory area buffer of void type; +// int *var_conn = static_cast (buffer_void); +// icount = 0; +// unsigned offset_nvt=0; +// for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { +// for (unsigned iel=0; iel<_ml_mesh->GetLevel(ig)->GetNumberOfElements(); iel++) { +// if (ig==_gridn-1u || _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(iel)==0) { +// for (unsigned j=0; j<_ml_mesh->GetLevel(ig)->el->GetElementDofNumber(iel,index); j++) { +// unsigned loc_vtk_conn = map_pr[j]; +// unsigned jnode=_ml_mesh->GetLevel(ig)->el->GetElementVertexIndex(iel,loc_vtk_conn)-1u; +// unsigned jnodeMetis = _ml_mesh->GetLevel(ig)->GetMetisDof(jnode,index); +// var_conn[icount] = offset_nvt + jnodeMetis; +// icount++; +// } +// } +// } +// offset_nvt+=_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs]; +// } +// +// //print connectivity dimension +// cch = b64::b64_encode(&dim_array_conn[0], sizeof(dim_array_conn), NULL, 0); +// b64::b64_encode(&dim_array_conn[0], sizeof(dim_array_conn), &enc[0], cch); +// pt_char=&enc[0]; +// for( unsigned i =0; i" << std::endl; +// //------------------------------------------------------------------------------------------------ +// +// //------------------------------------------------------------------------------------------------- +// //printing offset +// fout << " " << std::endl; +// +// // point pointer to common mamory area buffer of void type; +// int *var_off=static_cast (buffer_void); +// icount = 0; +// int offset_el=0; +// //print offset array +// for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { +// for (unsigned iel=0; iel<_ml_mesh->GetLevel(ig)->GetNumberOfElements(); iel++) { +// if ( ig==_gridn-1u || 0==_ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(iel)) { +// offset_el += _ml_mesh->GetLevel(ig)->el->GetElementDofNumber(iel,index); +// var_off[icount] = offset_el; +// icount++; +// } +// } +// } +// +// //print offset dimension +// cch = b64::b64_encode(&dim_array_off[0], sizeof(dim_array_off), NULL, 0); +// b64::b64_encode(&dim_array_off[0], sizeof(dim_array_off), &enc[0], cch); +// pt_char=&enc[0]; +// for( unsigned i =0; i" << std::endl; +// //-------------------------------------------------------------------------------------------------- +// +// //-------------------------------------------------------------------------------------------------- +// //Element format type : 23:Serendipity(8-nodes) 28:Quad9-Biquadratic +// fout << " " << std::endl; +// +// // point pointer to common mamory area buffer of void type; +// unsigned short *var_type = static_cast (buffer_void); +// icount=0; +// for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { +// for (unsigned ii=0; ii<_ml_mesh->GetLevel(ig)->GetNumberOfElements(); ii++) { +// if (ig==_gridn-1u || _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(ii)==0) { +// short unsigned ielt= _ml_mesh->GetLevel(ig)->el->GetElementType(ii); +// var_type[icount] = femusToVtkCellType[index][ielt]; +// icount++; +// } +// } +// } +// +// //print element format dimension +// cch = b64::b64_encode(&dim_array_type[0], sizeof(dim_array_type), NULL, 0); +// b64::b64_encode(&dim_array_type[0], sizeof(dim_array_type), &enc[0], cch); +// pt_char=&enc[0]; +// for( unsigned i =0; i" << std::endl; +// //---------------------------------------------------------------------------------------------------- +// +// fout << " " << std::endl; +// //-------------------------------------------------------------------------------------------------- +// +// // /Print Cell Data **************************************************************************** +// fout << " " << std::endl; +// +// //-------------------------------------------------------------------------------------------- +// // Print Regions +// fout << " " << std::endl; +// +// // point pointer to common mamory area buffer of void type; +// unsigned short* var_reg=static_cast (buffer_void); +// icount=0; +// for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { +// for (unsigned ii=0; ii<_ml_mesh->GetLevel(ig)->GetNumberOfElements(); ii++) { +// if ( ig==_gridn-1u || 0==_ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { +// var_reg[icount]= _ml_mesh->GetLevel(ig)->el->GetElementGroup(ii); +// icount++; +// } +// } +// } +// +// //print regions dimension +// cch = b64::b64_encode(&dim_array_reg[0], sizeof(dim_array_reg), NULL, 0); +// b64::b64_encode(&dim_array_reg[0], sizeof(dim_array_reg), &enc[0], cch); +// pt_char=&enc[0]; +// for( unsigned i =0; i" << std::endl; +// +// //----------------------------------------------------------------------------------------------------- +// // Print Metis Partitioning +// fout << " " << std::endl; +// +// // point pointer to common mamory area buffer of void type; +// unsigned short* var_proc=static_cast (buffer_void); +// icount=0; +// for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { +// for (unsigned ii=0; ii<_ml_mesh->GetLevel(ig)->GetNumberOfElements(); ii++) { +// if ( ig==_gridn-1u || 0==_ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { +// var_proc[icount]=(unsigned short)(_ml_mesh->GetLevel(ig)->epart[ii]); +// icount++; +// } +// } +// } +// +// //print regions dimension +// cch = b64::b64_encode(&dim_array_reg[0], sizeof(dim_array_reg), NULL, 0); +// b64::b64_encode(&dim_array_reg[0], sizeof(dim_array_reg), &enc[0], cch); +// pt_char=&enc[0]; +// for( unsigned i =0; i" << std::endl; +// +// if (_ml_sol != NULL) { +// +// //Print Solution (on element) *************************************************************** +// for (unsigned i=0; i<(!print_all)*vars.size() + print_all*_ml_sol->GetSolutionSize(); i++) { +// unsigned solIndex=( print_all == 0 ) ? _ml_sol->GetIndex(vars[i].c_str()):i; +// if (3 <= _ml_sol->GetSolutionType(solIndex)) { +// fout << " GetSolutionName(solIndex) <<"\" format=\"binary\">" << std::endl; +// // point pointer to common memory area buffer of void type; +// float *var_el = static_cast< float*> (buffer_void); +// icount=0; +// for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { +// vector sol_local; +// _ml_sol->GetSolutionLevel(ig)->_Sol[solIndex]->localize_to_one(sol_local,0); +// for (unsigned ii=0; ii<_ml_mesh->GetLevel(ig)->GetNumberOfElements(); ii++) { +// if (ig==_gridn-1u || 0==_ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { +// unsigned iel_Metis = _ml_mesh->GetLevel(ig)->GetMetisDof(ii,_ml_sol->GetSolutionType(solIndex)); +// var_el[icount]=sol_local[iel_Metis]; +// icount++; +// } +// } +// } +// +// if(_iproc==0) { +// //print solution on element dimension +// cch = b64::b64_encode(&dim_array_elvar[0], sizeof(dim_array_elvar), NULL, 0); +// b64::b64_encode(&dim_array_elvar[0], sizeof(dim_array_elvar), &enc[0], cch); +// pt_char=&enc[0]; +// for( unsigned i =0; i" << std::endl; +// } +// //---------------------------------------------------------------------------------------------------- +// } +// +// } //end mlsol +// +// } +// fout << " " << std::endl; +// // //------------------------------------------------------------------------------------------------ +// +// if (_ml_sol != NULL) { +// // //------------------------------------------------------------------------------------------------ +// // / Print Solution (on nodes) ******************************************************************** +// fout<< " " << std::endl; +// //Loop on variables +// +// // point pointer to common memory area buffer of void type; +// float* var_nd = static_cast(buffer_void); +// for (unsigned i=0; i<(!print_all)*vars.size()+ print_all*_ml_sol->GetSolutionSize(); i++) { +// unsigned solIndex=( print_all == 0 )?_ml_sol->GetIndex(vars[i].c_str()):i; +// if (_ml_sol->GetSolutionType(solIndex)<3) { +// fout << " GetSolutionName(solIndex) <<"\" format=\"binary\">" << std::endl; +// //print solutions on nodes dimension +// cch = b64::b64_encode(&dim_array_ndvar[0], sizeof(dim_array_ndvar), NULL, 0); +// b64::b64_encode(&dim_array_ndvar[0], sizeof(dim_array_ndvar), &enc[0], cch); +// pt_char=&enc[0]; +// for( unsigned i =0; imatrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Sol[solIndex], +// *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index,_ml_sol->GetSolutionType(solIndex)) ); +// vector sol_local; +// mysol[ig]->localize_to_one(sol_local,0); +// unsigned nvt_ig=_ml_mesh->GetLevel(ig)->MetisOffset[index][_nprocs]; +// for (unsigned ii=0; ii" << std::endl; +// } +// } //endif +// } // end for sol +// fout << " " << std::endl; +// +// delete [] var_nd; +// +// } //end _ml_sol != NULL +// +// //------------------------------------------------------------------------------------------------ +// +// fout << " " << std::endl; +// fout << " " << std::endl; +// fout << "" << std::endl; +// fout.close(); +// +// //----------------------------------------------------------------------------------------------------- +// //free memory +// for(unsigned ig=_gridr-1u; ig<_gridn; ig++) { +// delete mysol[ig]; +// } +// +// +// +// //-------------------------------------------------------------------------------------------------------- +// return; +//} + + + + + + } //end namespace femus diff --git a/src/solution/VTKWriter.hpp b/src/solution/VTKWriter.hpp index a9e30f9e8..4df507ef8 100644 --- a/src/solution/VTKWriter.hpp +++ b/src/solution/VTKWriter.hpp @@ -37,19 +37,23 @@ class VTKWriter : public Writer { public: /** Constructor. */ - VTKWriter(MultiLevelSolution & ml_sol); + VTKWriter(MultiLevelSolution * ml_sol); + + /** Constructor. */ + VTKWriter(MultiLevelMesh * ml_mesh); /** Destructor */ virtual ~VTKWriter(); /** write output function */ - virtual void write_system_solutions(const std::string output_path, const char order[], std::vector& vars, const unsigned time_step=0); - + void write(const std::string output_path, const char order[], const std::vector < std::string > & vars = std::vector < std::string > (), const unsigned time_step=0) const{ + Pwrite(output_path, order, vars, time_step); + }; + void Pwrite(const std::string output_path, const char order[], const std::vector < std::string > & vars = std::vector < std::string > (), const unsigned time_step=0) const; private: /** femus to vtk cell type map */ static short unsigned int femusToVtkCellType[3][6]; - }; /** diff --git a/src/solution/Writer.cpp b/src/solution/Writer.cpp index 278cdd951..bccccfd99 100644 --- a/src/solution/Writer.cpp +++ b/src/solution/Writer.cpp @@ -34,140 +34,71 @@ namespace femus { - -std::vector Writer::_ProlQitoQj[3][3]; - -Writer::Writer(MultiLevelSolution& ml_sol): - _ml_sol(ml_sol) -{ - _gridn = ml_sol._ml_msh->GetNumberOfLevels(); - _gridr = ml_sol._ml_msh->GetNumberOfGridTotallyRefined(); - - if(Writer::_ProlQitoQj[0][0].size() == 0) + Writer::Writer( MultiLevelSolution* ml_sol ): + _ml_sol(ml_sol), _ml_mesh(ml_sol->_ml_msh) { - BuildProlongatorMatrices(); - } - _moving_mesh = 0; -} - -Writer::~Writer() -{ - for (int igridn=0; igridn<_gridn; igridn++) { - for (int itype=0; itype<3; itype++) { - for (int jtype=0; jtype<3; jtype++) { - if(_ProlQitoQj[itype][jtype][igridn]) - { - delete _ProlQitoQj[itype][jtype][igridn]; - _ProlQitoQj[itype][jtype][igridn] = NULL; - } - } - } + _gridn = _ml_mesh->GetNumberOfLevels(); + _gridr = _ml_mesh->GetNumberOfGridTotallyRefined(); + _moving_mesh = 0; } + + Writer::Writer( MultiLevelMesh* ml_mesh ): + _ml_sol(NULL), _ml_mesh(ml_mesh) + { + _gridn = _ml_mesh->GetNumberOfLevels(); + _gridr = _ml_mesh->GetNumberOfGridTotallyRefined(); + _moving_mesh = 0; + } -} + Writer::~Writer() { } - std::auto_ptr Writer::build(const WriterEnum format, MultiLevelSolution * ml_sol) { + std::auto_ptr Writer::build(const WriterEnum format, MultiLevelSolution * ml_sol) { - switch (format) { - case VTK: { - std::auto_ptr ap(new VTKWriter(*ml_sol)); return ap; - } - case GMV: { - std::auto_ptr ap(new GMVWriter(*ml_sol)); return ap; - } - case XDMF: { - std::auto_ptr ap(new XDMFWriter(*ml_sol)); return ap; - } - default: { - std::cout << "Format not supported" << std::endl; - abort(); - } - - } //end switch - - - } - - -void Writer::SetMovingMesh(std::vector& movvars_in) -{ - _moving_mesh = 1; - _moving_vars = movvars_in; -} - - -void Writer::BuildProlongatorMatrices() { - - for(int i=0; i<3; i++){ - for(int j=0; j<3; j++){ - _ProlQitoQj[i][j].resize(_gridn); - } - } - - for (unsigned igridn=0; igridn<_gridn; igridn++){ - Mesh* msh = _ml_sol._ml_msh->GetLevel(igridn); - for(int itype=0;itype<3;itype++){ - int ni = msh->MetisOffset[itype][_nprocs]; - int ni_loc = msh->own_size[itype][_iproc]; - for (int jtype=0; jtype<3; jtype++) { - int nj = msh->MetisOffset[jtype][_nprocs]; - int nj_loc = msh->own_size[itype][_iproc]; - - NumericVector *NNZ_d = NumericVector::build().release(); - NumericVector *NNZ_o = NumericVector::build().release(); - if(_nprocs==1) { // IF SERIAL - NNZ_d->init(ni,ni_loc,false,SERIAL); - NNZ_o->init(ni,ni_loc,false,SERIAL); - } - else{ - NNZ_d->init(ni,ni_loc,false,PARALLEL); - NNZ_o->init(ni,ni_loc,false,PARALLEL); - } - NNZ_d->zero(); - NNZ_o->zero(); - - for(int isdom=_iproc; isdom<_iproc+1; isdom++) { - for (int iel_mts=msh->IS_Mts2Gmt_elem_offset[isdom];iel_mts < msh->IS_Mts2Gmt_elem_offset[isdom+1]; iel_mts++){ - unsigned iel = msh->IS_Mts2Gmt_elem[iel_mts]; - short unsigned ielt=msh->el->GetElementType(iel); - _ml_sol._ml_msh->_finiteElement[ielt][jtype]->GetSparsityPatternSize(*msh, iel, NNZ_d, NNZ_o, itype); - } - } - - NNZ_d->close(); - NNZ_o->close(); - - unsigned offset = msh->MetisOffset[itype][_iproc]; - - vector nnz_d(ni_loc); - vector nnz_o(ni_loc); - for(int i=0; i ((*NNZ_d)(offset+i)); - nnz_o[i]=static_cast ((*NNZ_o)(offset+i)); - } - - delete NNZ_d; - delete NNZ_o; - - _ProlQitoQj[itype][jtype][igridn] = SparseMatrix::build().release(); - _ProlQitoQj[itype][jtype][igridn]->init(ni,nj,msh->own_size[itype][_iproc],msh->own_size[jtype][_iproc],nnz_d,nnz_o); - for(int isdom=_iproc; isdom<_iproc+1; isdom++) { - for (int iel_mts=msh->IS_Mts2Gmt_elem_offset[isdom];iel_mts < msh->IS_Mts2Gmt_elem_offset[isdom+1]; iel_mts++){ - unsigned iel = msh->IS_Mts2Gmt_elem[iel_mts]; - short unsigned ielt=msh->el->GetElementType(iel); - _ml_sol._ml_msh->_finiteElement[ielt][jtype]->BuildProlongation(*msh, iel, _ProlQitoQj[itype][jtype][igridn], itype); - } - } - _ProlQitoQj[itype][jtype][igridn]->close(); + switch (format) { + case VTK: { + std::auto_ptr ap(new VTKWriter(ml_sol)); return ap; + } + case GMV: { + std::auto_ptr ap(new GMVWriter(ml_sol)); return ap; } - } + case XDMF: { + std::auto_ptr ap(new XDMFWriter(ml_sol)); return ap; + } + default: { + std::cout << "Format not supported" << std::endl; + abort(); + } + } //end switch + } -} - + std::auto_ptr Writer::build(const WriterEnum format, MultiLevelMesh * ml_mesh) { + + switch (format) { + case VTK: { + std::auto_ptr ap(new VTKWriter(ml_mesh)); return ap; + } + case GMV: { + std::auto_ptr ap(new GMVWriter(ml_mesh)); return ap; + } + case XDMF: { + std::auto_ptr ap(new XDMFWriter(ml_mesh)); return ap; + } + default: { + std::cout << "Format not supported" << std::endl; + abort(); + } + } //end switch + + } + void Writer::SetMovingMesh(std::vector& movvars_in){ + _moving_mesh = 1; + _moving_vars = movvars_in; + } + } //end namespace femus diff --git a/src/solution/Writer.hpp b/src/solution/Writer.hpp index 5abdce6cc..6e55b6961 100644 --- a/src/solution/Writer.hpp +++ b/src/solution/Writer.hpp @@ -27,39 +27,44 @@ namespace femus { -// map from our connectivity to vtk-connectivity for paraview visualization //TODO move this to the appropriate place -const unsigned map_pr[27] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,23,21,20,22,24,25,26}; + // map from our connectivity to vtk-connectivity for paraview visualization //TODO move this to the appropriate place + const unsigned map_pr[27] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,23,21,20,22,24,25,26}; -//------------------------------------------------------------------------------ -// Forward declarations -//------------------------------------------------------------------------------ -class MultiLevelSolution; -class SparseMatrix; -class Vector; + //------------------------------------------------------------------------------ + // Forward declarations + //------------------------------------------------------------------------------ + class MultiLevelMesh; + class MultiLevelSolution; + class SparseMatrix; + class Vector; -class Writer : public ParallelObject { + class Writer : public ParallelObject { -public: + public: /** Constructor. */ - Writer(MultiLevelSolution & ml_probl); + Writer(MultiLevelSolution * ml_sol); + + /** Constructor. */ + Writer(MultiLevelMesh * ml_mesh); /** Destructor */ virtual ~Writer(); /** write output function */ - virtual void write_system_solutions(const std::string output_path, const char order[], std::vector& vars, const unsigned time_step = 0) = 0; - + virtual void write(const std::string output_path, const char order[], const std::vector < std::string > & vars = std::vector < std::string > (), const unsigned time_step = 0) const = 0; + virtual void Pwrite(const std::string output_path, const char order[], const std::vector < std::string > & vars = std::vector < std::string > (), const unsigned time_step = 0) const = 0; /** set moving mesh */ void SetMovingMesh(std::vector& movvars_in); + /** runtime selection of writer for MLsol */ static std::auto_ptr build(const WriterEnum format, MultiLevelSolution * ml_sol); -protected: - - /** a set of matrix for the projection of the solution */ - static std::vector _ProlQitoQj[3][3]; + /** runtime selection of writer for MLmesh */ + static std::auto_ptr build(const WriterEnum format, MultiLevelMesh * ml_mesh); + + protected: /** a flag to move the output mesh */ int _moving_mesh; @@ -67,23 +72,21 @@ class Writer : public ParallelObject { /** the displacement variables for mesh moving */ std::vector _moving_vars; - /** the multilevelsolution reference */ - MultiLevelSolution& _ml_sol; + /** the multilevelsolution pointer */ + MultiLevelSolution* _ml_sol; + + /** the multilevel mesh */ + MultiLevelMesh* _ml_mesh; int _gridn; int _gridr; -private: - - /** This routine generates the matrices for the projection of the solutions from different FE spaces */ - void BuildProlongatorMatrices(); - -}; - - + private: + }; + } //end namespace femus diff --git a/src/solution/XDMFWriter.cpp b/src/solution/XDMFWriter.cpp index b77d7b904..10271d2e2 100644 --- a/src/solution/XDMFWriter.cpp +++ b/src/solution/XDMFWriter.cpp @@ -54,22 +54,20 @@ namespace femus { // _el_pid_name = "PID"; // _nd_map_FineToLev = "MAP"; -XDMFWriter::XDMFWriter(MultiLevelSolution& ml_probl): Writer(ml_probl) -{ - -} +XDMFWriter::XDMFWriter(MultiLevelSolution * ml_sol): Writer(ml_sol) {} -XDMFWriter::~XDMFWriter() -{ - -} +XDMFWriter::XDMFWriter(MultiLevelMesh * ml_mesh): Writer(ml_mesh) {} + +XDMFWriter::~XDMFWriter() {} -void XDMFWriter::write_system_solutions(const std::string output_path, const char order[], std::vector& vars, const unsigned time_step) -{ +void XDMFWriter::write(const std::string output_path, const char order[], const std::vector& vars, const unsigned time_step) const { #ifdef HAVE_HDF5 - bool test_all=!(vars[0].compare("All")); - + bool print_all = 0; + for (unsigned ivar=0; ivar < vars.size(); ivar++){ + print_all += !(vars[ivar].compare("All")) + !(vars[ivar].compare("all")) + !(vars[ivar].compare("ALL")); + } + unsigned index=0; unsigned index_nd=0; if(!strcmp(order,"linear")) { //linear @@ -85,59 +83,69 @@ void XDMFWriter::write_system_solutions(const std::string output_path, const cha index_nd=2; } - //I assume that the mesh is not mixed + /// @todo I assume that the mesh is not mixed std::string type_elem; - unsigned elemtype = _ml_sol._ml_msh->GetLevel(_gridn-1u)->el->GetElementType(0); + unsigned elemtype = _ml_mesh->GetLevel(_gridn-1u)->el->GetElementType(ZERO_ELEM); type_elem = XDMFWriter::type_el[index][elemtype]; if (type_elem.compare("Not_implemented") == 0) { std::cerr << "XDMF-Writer error: element type not supported!" << std::endl; - exit(1); + abort(); } unsigned nvt=0; for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { - unsigned nvt_ig=_ml_sol._ml_msh->GetLevel(ig)->GetDofNumber(index_nd); + unsigned nvt_ig=_ml_mesh->GetLevel(ig)->GetDofNumber(index_nd); nvt+=nvt_ig; } // Printing connectivity unsigned nel=0; - for(unsigned ig=0;ig<_gridn-1u;ig++) { - nel+=( _ml_sol._ml_msh->GetLevel(ig)->GetNumberOfElements() - _ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementNumber()); + for(unsigned ig=0; ig<_gridn-1u; ig++) { + nel+=( _ml_mesh->GetLevel(ig)->GetNumberOfElements() - _ml_mesh->GetLevel(ig)->el->GetRefinedElementNumber()); } - nel+=_ml_sol._ml_msh->GetLevel(_gridn-1u)->GetNumberOfElements(); + nel+=_ml_mesh->GetLevel(_gridn-1u)->GetNumberOfElements(); unsigned icount; - unsigned el_dof_number = _ml_sol._ml_msh->GetLevel(_gridn-1u)->el->GetElementDofNumber(0,index); - int *var_int = new int [nel*el_dof_number]; + unsigned el_dof_number = _ml_mesh->GetLevel(_gridn-1u)->el->GetElementDofNumber(0,index_nd); + int * var_conn = new int [nel*el_dof_number]; + std::vector< int > var_proc(nel); float *var_el_f = new float [nel]; float *var_nd_f = new float [nvt]; //-------------------------------------------------------------------------------------------------- + std::string filename_prefix; + if( _ml_sol != NULL ) filename_prefix = "sol"; + else filename_prefix = "mesh"; + // Print The Xdmf wrapper - std::ostringstream filename; - filename << output_path << "/sol.level" << _gridn << "." << time_step << "." << order << ".xmf"; + std::ostringstream xdmf_filename; + xdmf_filename << output_path << "/" << filename_prefix << ".level" << _gridn << "." << time_step << "." << order << ".xmf"; + std::ofstream fout; - - if(_iproc!=0) { + + if(_iproc != 0){ fout.rdbuf(); //redirect to dev_null } else { - fout.open(filename.str().c_str()); + fout.open(xdmf_filename.str().c_str()); if (fout.is_open()) { - std::cout << std::endl << " The output is printed to file " << filename.str() << " in XDMF-HDF5 format" << std::endl; + std::cout << std::endl << " The output is printed to file " << xdmf_filename.str() << " in XDMF-HDF5 format" << std::endl; } else { - std::cout << std::endl << " The output file "<< filename.str() <<" cannot be opened.\n"; + std::cout << std::endl << " The output file "<< xdmf_filename.str() <<" cannot be opened.\n"; abort(); } } // Print The HDF5 file - filename << output_path << "/sol.level" << _gridn << "." << time_step << "." << order << ".h5"; + std::ostringstream hdf5_filename; + std::ostringstream hdf5_filename2; + hdf5_filename2 << filename_prefix << ".level" << _gridn << "." << time_step << "." << order << ".h5"; + + hdf5_filename << output_path << "/" << hdf5_filename2.str(); // head ************************************************ fout<<"" << std::endl; fout<<""<< std::endl; @@ -145,52 +153,62 @@ void XDMFWriter::write_system_solutions(const std::string output_path, const cha fout<<""<"<"<"<"<" << std::endl; - fout << filename << ":CONNECTIVITY" << std::endl; + fout<<"" << std::endl; + fout << hdf5_filename2.str() << ":/CONNECTIVITY" << std::endl; fout <<"" << std::endl; fout << "" << std::endl; fout << "" << std::endl; //Node_X - fout<<"" << std::endl; - fout << filename << ":NODES_X1" << std::endl; + fout<<"" << std::endl; + fout << hdf5_filename2.str() << ":/NODES_X1" << std::endl; fout <<"" << std::endl; //Node_Y - fout<<"" << std::endl; - fout << filename << ":NODES_X2" << std::endl; + fout<<"" << std::endl; + fout << hdf5_filename2.str() << ":/NODES_X2" << std::endl; fout <<"" << std::endl; //Node_Z - fout<<"" << std::endl; - fout << filename << ":NODES_X3" << std::endl; + fout<<"" << std::endl; + fout << hdf5_filename2.str() << ":/NODES_X3" << std::endl; fout <<"" << std::endl; fout <<"" << std::endl; //Regions fout << "" << std::endl; - fout << "" << std::endl; - fout << filename << ":REGIONS" << std::endl; + fout << "" << std::endl; + fout << hdf5_filename2.str() << ":/REGIONS" << std::endl; fout << "" << std::endl; fout << "" << std::endl; + //Metis partitions + fout << "" << std::endl; + fout << "" << std::endl; + fout << hdf5_filename2.str() << ":/DOMAIN_PARTITIONS" << std::endl; + fout << "" << std::endl; + fout << "" << std::endl; + + if (_ml_sol != NULL) { // Solution Variables for (unsigned i=0; iGetIndex(vars[i].c_str()); //Printing biquadratic solution on the nodes - if(_ml_sol.GetSolutionType(indx)<3) { - fout << "" << std::endl; - fout << "" << std::endl; - fout << filename << ":" << _ml_sol.GetSolutionName(indx) << std::endl; + if(_ml_sol->GetSolutionType(indx)<3) { + fout << "GetSolutionName(indx)<<"\" AttributeType=\"Scalar\" Center=\"Node\">" << std::endl; + fout << "" << std::endl; + fout << hdf5_filename2.str() << ":/" << _ml_sol->GetSolutionName(indx) << std::endl; fout << "" << std::endl; fout << "" << std::endl; } - else if (_ml_sol.GetSolutionType(indx)>=3) { //Printing picewise constant solution on the element - fout << "" << std::endl; - fout << "" << std::endl; - fout << filename << ":" << _ml_sol.GetSolutionName(indx) << std::endl; + else if (_ml_sol->GetSolutionType(indx)>=3) { //Printing picewise constant solution on the element + fout << "GetSolutionName(indx)<<"\" AttributeType=\"Scalar\" Center=\"Cell\">" << std::endl; + fout << "" << std::endl; + fout << hdf5_filename2.str() << ":/" << _ml_sol->GetSolutionName(indx) << std::endl; fout << "" << std::endl; fout << "" << std::endl; } } - + + } //end ml_sol + fout <<"" << std::endl; fout <<"" << std::endl; fout <<"" << std::endl; @@ -199,8 +217,7 @@ void XDMFWriter::write_system_solutions(const std::string output_path, const cha //---------------------------------------------------------------------------------------------------------- hid_t file_id; - filename << output_path << "/sol.level" << _gridn << "." << time_step << "." << order << ".h5"; - file_id = H5Fcreate(filename.str().c_str(),H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT); + file_id = H5Fcreate(hdf5_filename.str().c_str(),H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT); hsize_t dimsf[2]; herr_t status; hid_t dataspace; @@ -209,37 +226,45 @@ void XDMFWriter::write_system_solutions(const std::string output_path, const cha //----------------------------------------------------------------------------------------------------------- // Printing nodes coordinates - PetscScalar *MYSOL[1]; //TODO - for (int i=0; i<3; i++) { - unsigned offset_nvt=0; for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { - NumericVector* mysol; - mysol = NumericVector::build().release(); - //mysol->init(_ml_sol._ml_msh->GetLevel(ig)->GetDofNumber(index_nd),_ml_sol._ml_msh->GetLevel(ig)->GetDofNumber(index_nd),true,AUTOMATIC); - mysol->init(_ml_sol._ml_msh->GetLevel(ig)->MetisOffset[index_nd][_nprocs],_ml_sol._ml_msh->GetLevel(ig)->own_size[index_nd][_iproc],true,AUTOMATIC); - mysol->matrix_mult(*_ml_sol._ml_msh->GetLevel(ig)->_coordinate->_Sol[i],*Writer::_ProlQitoQj[index_nd][2][ig]); - unsigned nvt_ig=_ml_sol._ml_msh->GetLevel(ig)->GetDofNumber(index_nd); - for (unsigned ii=0; iimatrix_mult(*_ml_sol.GetSolutionLevel(ig)->_Sol[varind_DXDYDZ],*Writer::_ProlQitoQj[index_nd][_ml_sol.GetSolutionType(varind_DXDYDZ)][ig]); - for (unsigned ii=0; iiGetLevel(ig)->MetisOffset[index_nd][_nprocs];//->GetDofNumber(index_nd); + NumericVector* mysol = NumericVector::build().release(); + + mysol->init(nvt_ig,_ml_mesh->GetLevel(ig)->own_size[index_nd][_iproc],true,AUTOMATIC); + mysol->matrix_mult(*_ml_mesh->GetLevel(ig)->_coordinate->_Sol[i], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index_nd,2) ); + + vector mysol_ser; + mysol->localize_to_one(mysol_ser, 0); + + if(_iproc == 0){ + for (unsigned ii=0; iiGetLevel(0)->GetDimension() > i) { + unsigned varind_DXDYDZ=_ml_sol->GetIndex(_moving_vars[i].c_str()); + mysol->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Sol[varind_DXDYDZ], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index_nd,_ml_sol->GetSolutionType(varind_DXDYDZ))); + mysol->localize_to_one(mysol_ser, 0); + if(_iproc == 0){ + for (unsigned ii=0; iiGetLevel(ig)->GetNumberOfElements(); iel++) { - if (_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementIndex(iel)==0 || ig==_gridn-1u) { - for (unsigned j=0; j<_ml_sol._ml_msh->GetLevel(ig)->el->GetElementDofNumber(iel,index); j++) { + for ( unsigned ig=_gridr-1u; ig<_gridn; ig++ ) { + for ( unsigned iel = 0; iel < _ml_mesh->GetLevel(ig)->GetNumberOfElements(); iel++ ) { + if ( ig == _gridn-1u || _ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(iel) == 0) { + int ndofs = _ml_mesh->GetLevel(ig)->el->GetElementDofNumber(iel,index_nd); + for (unsigned j = 0; j < ndofs; j++) { unsigned vtk_loc_conn = map_pr[j]; - unsigned jnode=_ml_sol._ml_msh->GetLevel(ig)->el->GetElementVertexIndex(iel,vtk_loc_conn)-1u; - unsigned jnode_Metis = _ml_sol._ml_msh->GetLevel(ig)->GetMetisDof(jnode,index_nd); - var_int[icount] = offset_conn + jnode_Metis; + unsigned jnode = _ml_mesh->GetLevel(ig)->el->GetElementVertexIndex(iel,vtk_loc_conn)-1u; + unsigned jnode_Metis = _ml_mesh->GetLevel(ig)->GetMetisDof(jnode,index_nd); + var_conn[icount] = offset_conn + jnode_Metis; icount++; } } } - offset_conn += _ml_sol._ml_msh->GetLevel(ig)->GetDofNumber(index_nd); + offset_conn += _ml_mesh->GetLevel(ig)->MetisOffset[index_nd][_nprocs];//GetLevel(ig)->GetDofNumber(index_nd); } - - dimsf[0] = nel*el_dof_number ; dimsf[1] = 1; - dataspace = H5Screate_simple(2,dimsf, NULL); - dataset = H5Dcreate(file_id,"/CONNECTIVITY",H5T_NATIVE_INT, - dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,H5P_DEFAULT,&var_int[0]); - H5Sclose(dataspace); - H5Dclose(dataset); + if(_iproc == 0){ + dimsf[0] = nel*el_dof_number ; dimsf[1] = 1; + dataspace = H5Screate_simple(2,dimsf, NULL); + dataset = H5Dcreate(file_id,"/CONNECTIVITY",H5T_NATIVE_INT, + dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,H5P_DEFAULT,&var_conn[0]); + H5Sclose(dataspace); + H5Dclose(dataset); + } //------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------- // print regions + icount=0; for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { - for (unsigned ii=0; ii<_ml_sol._ml_msh->GetLevel(ig)->GetNumberOfElements(); ii++) { - if (ig==_gridn-1u || 0==_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { - unsigned iel_Metis = _ml_sol._ml_msh->GetLevel(ig)->GetMetisDof(ii,3); - var_int[icount] = _ml_sol._ml_msh->GetLevel(ig)->el->GetElementGroup(iel_Metis); + + for (unsigned ii=0; ii<_ml_mesh->GetLevel(ig)->GetNumberOfElements(); ii++) { + if (ig==_gridn-1u || 0==_ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { + unsigned iel_Metis = _ml_mesh->GetLevel(ig)->GetMetisDof(ii,3); + var_conn[icount] = _ml_mesh->GetLevel(ig)->el->GetElementGroup(ii); icount++; } } } - - dimsf[0] = nel; dimsf[1] = 1; - dataspace = H5Screate_simple(2,dimsf, NULL); - dataset = H5Dcreate(file_id,"/REGIONS",H5T_NATIVE_INT, - dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,H5P_DEFAULT,&var_int[0]); - H5Sclose(dataspace); - H5Dclose(dataset); + if(_iproc == 0){ + dimsf[0] = nel; dimsf[1] = 1; + dataspace = H5Screate_simple(2,dimsf, NULL); + dataset = H5Dcreate(file_id,"/REGIONS",H5T_NATIVE_INT, + dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,H5P_DEFAULT,var_conn); + H5Sclose(dataspace); + H5Dclose(dataset); + } + + // end print regions + //------------------------------------------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------- + // print partitioning + icount=0; + for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { + + for (unsigned ii=0; ii<_ml_mesh->GetLevel(ig)->GetNumberOfElements(); ii++) { + if (ig==_gridn-1u || 0==_ml_mesh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { + unsigned iel_Metis = _ml_mesh->GetLevel(ig)->GetMetisDof(ii,3); + var_proc[icount] = _ml_mesh->GetLevel(ig)->epart[ii]; + icount++; + } + } + } + if(_iproc == 0){ + dimsf[0] = nel; dimsf[1] = 1; + dataspace = H5Screate_simple(2,dimsf, NULL); + dataset = H5Dcreate(file_id,"/DOMAIN_PARTITIONS",H5T_NATIVE_INT, + dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,H5P_DEFAULT,&var_proc[0]); + H5Sclose(dataspace); + H5Dclose(dataset); + } + // end print partitioning + //------------------------------------------------------------------------------------------------------- + + if (_ml_sol != NULL) { //------------------------------------------------------------------------------------------------------- // printing element variables - for (unsigned i=0; i<(1-test_all)*vars.size()+test_all*_ml_sol.GetSolutionSize(); i++) { - unsigned indx=(test_all==0)?_ml_sol.GetIndex(vars[i].c_str()):i; - if (_ml_sol.GetSolutionType(indx)>=3) { + for (unsigned i=0; i<(1-print_all)*vars.size()+print_all*_ml_sol->GetSolutionSize(); i++) { + unsigned indx=(print_all==0)?_ml_sol->GetIndex(vars[i].c_str()):i; + if (_ml_sol->GetSolutionType(indx)>=3) { icount=0; for (unsigned ig=_gridr-1u; ig<_gridn; ig++) { - for (unsigned ii=0; ii<_ml_sol._ml_msh->GetLevel(ig)->GetNumberOfElements(); ii++) { - if (ig==_gridn-1u || 0==_ml_sol._ml_msh->GetLevel(ig)->el->GetRefinedElementIndex(ii)) { - unsigned iel_Metis = _ml_sol._ml_msh->GetLevel(ig)->GetMetisDof(ii,_ml_sol.GetSolutionType(indx)); - var_el_f[icount]=(*_ml_sol.GetSolutionLevel(ig)->_Sol[indx])(iel_Metis); + unsigned nel_ig = _ml_mesh->GetLevel(ig)->GetNumberOfElements(); + unsigned sol_size = _ml_sol->GetSolutionLevel(ig)->_Sol[indx]->size(); + vector < double > mysol_ser; + for (unsigned ii=0; iiGetLevel(ig)->el->GetRefinedElementIndex(ii)) { + _ml_sol->GetSolutionLevel(ig)->_Sol[indx]->localize_to_one(mysol_ser, 0); + unsigned iel_Metis = _ml_mesh->GetLevel(ig)->GetMetisDof(ii,_ml_sol->GetSolutionType(indx)); + var_el_f[icount]=mysol_ser[iel_Metis]; icount++; } } } - - dimsf[0] = nel; dimsf[1] = 1; - dataspace = H5Screate_simple(2,dimsf, NULL); - dataset = H5Dcreate(file_id,_ml_sol.GetSolutionName(indx),H5T_NATIVE_FLOAT, - dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,H5P_DEFAULT,&var_el_f[0]); - H5Sclose(dataspace); - H5Dclose(dataset); - + if(_iproc == 0){ + dimsf[0] = nel; dimsf[1] = 1; + dataspace = H5Screate_simple(2,dimsf, NULL); + dataset = H5Dcreate(file_id,_ml_sol->GetSolutionName(indx),H5T_NATIVE_FLOAT, + dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + status = H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,H5P_DEFAULT,&var_el_f[0]); + H5Sclose(dataspace); + H5Dclose(dataset); + } } } //------------------------------------------------------------------------------------------------------- // printing nodes variables - for (unsigned i=0; i<(1-test_all)*vars.size()+test_all*_ml_sol.GetSolutionSize(); i++) { - unsigned indx=(test_all==0)?_ml_sol.GetIndex(vars[i].c_str()):i; - if (_ml_sol.GetSolutionType(indx) < 3) { - unsigned offset_nvt=0; + for (unsigned i=0; i<(1-print_all)*vars.size()+print_all*_ml_sol->GetSolutionSize(); i++) { + unsigned indx=(print_all==0)?_ml_sol->GetIndex(vars[i].c_str()):i; + if (_ml_sol->GetSolutionType(indx) < 3) { for(unsigned ig=_gridr-1u; ig<_gridn; ig++) { - NumericVector* mysol; - mysol = NumericVector::build().release(); - //mysol->init(_ml_sol._ml_msh->GetLevel(ig)->GetDofNumber(index_nd),_ml_sol._ml_msh->GetLevel(ig)->GetDofNumber(index_nd),true,AUTOMATIC); - mysol->init(_ml_sol._ml_msh->GetLevel(ig)->MetisOffset[index_nd][_nprocs],_ml_sol._ml_msh->GetLevel(ig)->own_size[index_nd][_iproc],true,AUTOMATIC); - mysol->matrix_mult(*_ml_sol.GetSolutionLevel(ig)->_Sol[indx],*_ProlQitoQj[index_nd][_ml_sol.GetSolutionType(indx)][ig]); - unsigned nvt_ig=_ml_sol._ml_msh->GetLevel(ig)->GetDofNumber(index_nd); - for (unsigned ii=0; iiGetLevel(ig)->MetisOffset[index_nd][_nprocs]; + NumericVector* mysol = NumericVector::build().release(); + mysol->init(nvt_ig,_ml_mesh->GetLevel(ig)->own_size[index_nd][_iproc],true,AUTOMATIC); + mysol->matrix_mult(*_ml_sol->GetSolutionLevel(ig)->_Sol[indx], + *_ml_mesh->GetLevel(ig)->GetQitoQjProjection(index_nd, _ml_sol->GetSolutionType(indx)) ); + vector < double > mysol_ser; + mysol->localize_to_one(mysol_ser, 0); + if(_iproc == 0){ + for (unsigned ii=0; iiGetSolutionName(indx),H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - status = H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,H5P_DEFAULT,&var_nd_f[0]); - H5Sclose(dataspace); - H5Dclose(dataset); + status = H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,H5P_DEFAULT,var_nd_f); + H5Sclose(dataspace); + H5Dclose(dataset); + } } } //------------------------------------------------------------------------------------------------------- - + } // // Close the file ------------- H5Fclose(file_id); //free memory - delete [] var_int; + delete [] var_conn; delete [] var_el_f; delete [] var_nd_f; @@ -748,17 +813,17 @@ void XDMFWriter::PrintXDMFGeometry(std::ofstream& outfstream, // pos_in_mesh_obj gives me the position of the GEomElObject: in fact the quadratic dofs are built on the quadratic GeomEls exactly in this order //here we are picking the NODES per subd and level, so we are sure don't pass MORE TIMES on the SAME NODE -// PRoblem with the linear variables in write_system_solutions and PrintBc. +// PRoblem with the linear variables in write and PrintBc. //There is one line that brings to mistake, but TWO different mistakes. // in PrintBc it seems to be related to HDF5; -// in write_system_solutions it seems to concern PETSC +// in write it seems to concern PETSC //so that is the wrong line, if i comment it everything seems to work for any processor. //with two and three processors it seems to give even different errors... //when there is an error related to HDF5, the stack has the _start thing... // with two procs there is an error related to Petsc, // with three procs there is an error related to HDF5... -//If I only use PrintBc and not write_system_solutions, +//If I only use PrintBc and not write, //both with 2 and 3 processors the errors are related to HDF5... this is so absolutely weird... //Now it seems like I am restricted to that line. That line is responsible for the error. @@ -880,7 +945,7 @@ void XDMFWriter::PrintXDMFGeometry(std::ofstream& outfstream, //except for the fine level where i print the true solution // This prints All Variables of One Equation -void XDMFWriter::write_system_solutions(const std::string namefile, const MultiLevelMeshTwo* mesh, const DofMap* dofmap, const SystemTwo* eqn) { +void XDMFWriter::write(const std::string namefile, const MultiLevelMeshTwo* mesh, const DofMap* dofmap, const SystemTwo* eqn) { std::vector fe_in(QL); for (int fe=0; fe_geomelem_id[mesh->get_dim()-1-VV].c_str(),fe); @@ -923,7 +988,7 @@ void XDMFWriter::write_system_solutions(const std::string namefile, const MultiL #ifndef NDEBUG if ( pos_on_Qnodes_lev >= (int) n_nodes_lev ) { std::cout << "^^^^^^^OUT OF THE ARRAY ^^^^^^" << std::endl; abort(); } #endif - sol_on_Qnodes[ pos_on_Qnodes_lev/* pos_in_mesh_obj*/ ] = (* eqn->_x_old[Level])(pos_in_sol_vec_lev) * eqn->_refvalue[ ivar + dofmap->_VarOff[QQ] ]; + sol_on_Qnodes[ pos_on_Qnodes_lev/* pos_in_mesh_obj*/ ] = (* eqn->_LinSolver[Level]->_EPSC )(pos_in_sol_vec_lev) * eqn->_refvalue[ ivar + dofmap->_VarOff[QQ] ]; pos_in_mesh_obj++; } } //end subd @@ -965,7 +1030,7 @@ void XDMFWriter::write_system_solutions(const std::string namefile, const MultiL if ( pos_on_Qnodes_lev >= (int) n_nodes_lev ) { std::cout << "^^^^^^^OUT OF THE ARRAY ^^^^^^" << std::endl; abort(); } #endif - sol_on_Qnodes[ pos_on_Qnodes_lev ] = (*eqn->_x_old[Level])(pos_in_sol_vec_lev) * eqn->_refvalue[ ivar + dofmap->_VarOff[LL] ]; + sol_on_Qnodes[ pos_on_Qnodes_lev ] = ( *eqn->_LinSolver[Level]->_EPSC )(pos_in_sol_vec_lev) * eqn->_refvalue[ ivar + dofmap->_VarOff[LL] ]; } } @@ -1033,7 +1098,7 @@ void XDMFWriter::write_system_solutions(const std::string namefile, const MultiL int elem_lev = iel + sum_elems_prev_sd_at_lev; int dof_pos_lev = dofmap->GetDof(Level,KK,ivar,elem_lev); for (uint is = 0; is < NRE[mesh->_eltype_flag[VV]]; is++) { - sol_on_cells[cel*NRE[mesh->_eltype_flag[VV]] + is] = (* eqn->_x_old[Level])(dof_pos_lev) * eqn->_refvalue[ ivar + dofmap->_VarOff[KK] ]; + sol_on_cells[cel*NRE[mesh->_eltype_flag[VV]] + is] = (* eqn->_LinSolver[Level]->_EPSC)(dof_pos_lev) * eqn->_refvalue[ ivar + dofmap->_VarOff[KK] ]; } cel++; } @@ -1086,17 +1151,17 @@ void XDMFWriter::read_system_solutions(const std::string namefile, const MultiLe double Irefval = 1./eqn->_refvalue[ivar]; // units // storing ivar variables (in parallell) - for (int iel=0;iel < mesh->_off_el[VV][mesh->_iproc*mesh->_NoLevels+mesh->_NoLevels] - -mesh->_off_el[VV][mesh->_iproc*mesh->_NoLevels+mesh->_NoLevels-1]; iel++) { + for (int iel=0; iel < mesh->_off_el[VV][mesh->_iproc*mesh->_NoLevels+mesh->_NoLevels] + -mesh->_off_el[VV][mesh->_iproc*mesh->_NoLevels+mesh->_NoLevels-1]; iel++) { uint elem_gidx=(iel+mesh->_off_el[VV][mesh->_iproc*mesh->_NoLevels+mesh->_NoLevels-1])*NVE[ mesh->_geomelem_flag[mesh->get_dim()-1] ][BIQUADR_FE]; for (uint i=0; i_el_map[VV][elem_gidx+i]; // the global node - eqn->_x[mesh->_NoLevels-1]->set(dofmap->GetDof(mesh->_NoLevels-1,QQ,ivar,k), sol[k]*Irefval); // set the field + eqn->_LinSolver[mesh->_NoLevels-1]->_EPS->set(dofmap->GetDof(mesh->_NoLevels-1,QQ,ivar,k), sol[k]*Irefval); // set the field } } } - eqn->_x[mesh->_NoLevels-1]->localize(* eqn->_x_old[mesh->_NoLevels-1]); + eqn->_LinSolver[mesh->_NoLevels-1]->_EPS->localize(* eqn->_LinSolver[mesh->_NoLevels-1]->_EPSC); // clean H5Fclose(file_id); delete []sol; @@ -1179,7 +1244,7 @@ void XDMFWriter::read_system_solutions(const std::string namefile, const MultiLe // e' quella FINE, ma noi ora dobbiamo prendere quella DI CIASCUN LIVELLO SEPARATAMENTE! -void XDMFWriter::write_system_solutions_bc(const std::string namefile, const MultiLevelMeshTwo* mesh, const DofMap* dofmap, const SystemTwo* eqn, const int* bc, int** bc_fe_kk ) { +void XDMFWriter::write_bc(const std::string namefile, const MultiLevelMeshTwo* mesh, const DofMap* dofmap, const SystemTwo* eqn, const int* bc, int** bc_fe_kk ) { std::vector fe_in(QL); for (int fe=0; fe_geomelem_id[mesh->get_dim()-1-VV].c_str(),fe); @@ -1875,7 +1940,7 @@ void XDMFWriter::ReadMeshAndNondimensionalizeBiquadraticHDF5(const std::string o //I'll put a check if (mesh._dim != topdata[0] ) {std::cout << "MultiLevelMeshTwo::read_c. Mismatch: the mesh dimension is " << mesh._dim - << " while the dimension in the configuration file is " << mesh.GetRuntimeMap().get("dimension") + << " while the dimension in the configuration file is " << mesh.get_dim() << ". Recompile either gencase or your application appropriately" << std::endl;abort();} //it seems like it doesn't print to file if I don't put the endline "<< std::endl". //Also, "\n" seems to have no effect, "<< std::endl" must be used @@ -2236,7 +2301,7 @@ void XDMFWriter::PrintMeshBiquadraticHDF5(const std::string output_path, const M // ======================================================================= -// For every matrix, compute "dimension", "position", "len", "offlen" +// For every matrix, compute dimension, position, len, offlen // this function concerns a COUPLE of finite element families, that's it // fe_row = rows // fe_col = columns @@ -2422,7 +2487,7 @@ void XDMFWriter::PrintSolHDF5Linear(const std::string output_path, const uint t_ MultiLevelProblem::const_system_iterator pos_e = ml_prob.end(); for (;pos!=pos_e;pos++) { SystemTwo* eqn = static_cast(pos->second); - XDMFWriter::write_system_solutions(filename.str(),& ml_prob.GetMeshTwo(),&(eqn->_dofmap),eqn); + XDMFWriter::write(filename.str(),& ml_prob.GetMeshTwo(),&(eqn->_dofmap),eqn); } } //end print iproc @@ -2592,8 +2657,8 @@ void XDMFWriter::PrintCaseHDF5Linear(const std::string output_path, const uint t MultiLevelProblem::const_system_iterator pos_e = ml_prob.end(); for (;pos!=pos_e;pos++) { SystemTwo* eqn = static_cast(pos->second); - XDMFWriter::write_system_solutions(filename.str(),& ml_prob.GetMeshTwo(),&(eqn->_dofmap),eqn); // initial solution - XDMFWriter::write_system_solutions_bc(filename.str(),& ml_prob.GetMeshTwo(),&(eqn->_dofmap),eqn,eqn->_bcond._bc,eqn->_bcond._bc_fe_kk); // boundary condition + XDMFWriter::write(filename.str(),& ml_prob.GetMeshTwo(),&(eqn->_dofmap),eqn); // initial solution + XDMFWriter::write_bc(filename.str(),& ml_prob.GetMeshTwo(),&(eqn->_dofmap),eqn,eqn->_bcond._bc,eqn->_bcond._bc_fe_kk); // boundary condition } } //end iproc diff --git a/src/solution/XDMFWriter.hpp b/src/solution/XDMFWriter.hpp index cebbd4671..819a018cb 100644 --- a/src/solution/XDMFWriter.hpp +++ b/src/solution/XDMFWriter.hpp @@ -36,22 +36,30 @@ class XDMFWriter : public Writer { public: /** Constructor. */ - XDMFWriter(MultiLevelSolution & ml_sol); + XDMFWriter(MultiLevelSolution * ml_sol); + + /** Constructor. */ + XDMFWriter(MultiLevelMesh * ml_mesh); /** Destructor */ virtual ~XDMFWriter(); /** write output function */ - virtual void write_system_solutions(const std::string output_path, const char order[], std::vector& vars, const unsigned time_step = 0); - + void write(const std::string output_path, const char order[], const std::vector < std::string > & vars = std::vector < std::string > (), const unsigned time_step = 0) const; + + void Pwrite(const std::string output_path, const char order[], const std::vector < std::string > & vars = std::vector < std::string > (), const unsigned time_step = 0) const { + std::cout<<"the paralell writing function has not been yet implemente for XDMF format \n switched to serial write\n"; + write(output_path, order, vars, time_step); + }; + /** write a wrapper file for paraview to open all the files of an history together */ void write_solution_wrapper(const std::string output_path, const char type[]) const; //================== static void transient_print_xmf(const std::string output_path, const uint t_idx_in,const uint t_idx_final, const int print_step, const uint nolevels_in); - static void write_system_solutions_bc(const std::string namefile, const MultiLevelMeshTwo* mesh, const DofMap* dofmap, const SystemTwo* eqn, const int* bc, int** bc_fe_kk); - static void write_system_solutions(const std::string namefile, const MultiLevelMeshTwo* mesh, const DofMap* dofmap, const SystemTwo* eqn); ///prints on a "Quadratic-Linearized" Mesh //TODO this should be PrintNumericVector of the equation //Writer// + static void write_bc(const std::string namefile, const MultiLevelMeshTwo* mesh, const DofMap* dofmap, const SystemTwo* eqn, const int* bc, int** bc_fe_kk); + static void write(const std::string namefile, const MultiLevelMeshTwo* mesh, const DofMap* dofmap, const SystemTwo* eqn); ///prints on a "Quadratic-Linearized" Mesh //TODO this should be PrintNumericVector of the equation //Writer// static void read_system_solutions(const std::string namefile, const MultiLevelMeshTwo* mesh, const DofMap* dofmap, const SystemTwo* eqn); ///read from a "Quadratic-Linearized" Mesh //Writer/Reader// //hdf5 ------------------------------------ diff --git a/src/utils/FemusDefault.hpp b/src/utils/FemusDefault.hpp index 54bed848f..0e0b06a31 100644 --- a/src/utils/FemusDefault.hpp +++ b/src/utils/FemusDefault.hpp @@ -35,7 +35,7 @@ #define DEFAULT_BASEPATH "./" -#define DEFAULT_CONFIGDIR "input/" +#define DEFAULT_INPUTDIR "input/" #define DEFAULT_OUTPUTDIR "output/" //we have to hardcode it here otherwise we cannot perform restart without logical inconsistencies #define DEFAULT_RUNTIMECONF "femus_conf.in" //********************************************* @@ -59,6 +59,7 @@ //********************************************* //********** BOUNDARY CONDITIONS ************** #define DEFAULT_BC_FLAG 1 //=0 if you put a function on the RHS //you also have to comment the bc_read +#define DEFAULT_BDRY_TOLL 0.0000001 //********************************************* //**************************************** @@ -75,7 +76,6 @@ #define DEFAULT_EPS_LSOLV_C 1.e-20//1.e-10 #define DEFAULT_EPS_PREPOST 1.e-20 #define DEFAULT_MAXITS_LSOLV 40 -// #define DEFAULT_MAXITS_LSOLV_C 40 //it's not there now!!! is it required a special one for the coarsest? #define DEFAULT_MG_GAMMA 1 #define DEFAULT_NC_PRE 8 //16 #define DEFAULT_NC_COARSE 40 @@ -84,6 +84,6 @@ //************************************************************************************** //************************************************************************************** -#define DEFAULT_NDIGITS 4 +#define DEFAULT_NDIGITS 4 //n of digits for the timestep printing #endif \ No newline at end of file diff --git a/src/utils/FemusInputParser.hpp b/src/utils/FemusInputParser.hpp index fabedd46f..8fdf02df3 100644 --- a/src/utils/FemusInputParser.hpp +++ b/src/utils/FemusInputParser.hpp @@ -92,7 +92,7 @@ template void FemusInputParser::read() { std::ostringstream filename; - filename << _basepath << "/" << DEFAULT_CONFIGDIR << "/" << DEFAULT_RUNTIMECONF; + filename << _basepath << "/" << DEFAULT_INPUTDIR << "/" << DEFAULT_RUNTIMECONF; std::ifstream fin(filename.str().c_str()); diff --git a/src/utils/Files.cpp b/src/utils/Files.cpp index d289cc0cc..6dade10b3 100644 --- a/src/utils/Files.cpp +++ b/src/utils/Files.cpp @@ -216,13 +216,13 @@ void Files::CheckDir(const std::string& dir_name_in, const std::string& my_name_ std::ifstream in; in.open(dirname.str().c_str()); if (!in.is_open()) { - std::cout << " No " << dirname.str() << " directory: I'll create it. " << std::endl; + std::cout << std::endl << " No " << dirname.str() << " directory: I'll create it. " << std::endl; int status = mkdir(dirname.str().c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); if (status != 0) {std::cout << "MKDIR error: " << status << std::endl; abort();} } - else {std::cout<< "That's alright, " << my_name_in << " is already there." << std::endl;} + else {std::cout << std::endl <<" That's alright, " << my_name_in << " is already there." << std::endl;} in.close(); @@ -435,11 +435,11 @@ void Files::CopyFile(std::string f_in,std::string f_out) const { std::cout << "TODO: MUST FIND A WAY TO COPY A WHOLE DIRECTORY AND NOT THE SINGLE FILES" << std::endl; -CheckDirOrMake(_output_path,DEFAULT_CONFIGDIR); +CheckDirOrMake(_output_path,DEFAULT_INPUTDIR); //copy configuration file - std::string op_in = _input_path + "/" + DEFAULT_CONFIGDIR + "/" + DEFAULT_RUNTIMECONF; - std::string op_out = _output_path + "/" + DEFAULT_CONFIGDIR + "/" + DEFAULT_RUNTIMECONF; + std::string op_in = _input_path + "/" + DEFAULT_INPUTDIR + "/" + DEFAULT_RUNTIMECONF; + std::string op_out = _output_path + "/" + DEFAULT_INPUTDIR + "/" + DEFAULT_RUNTIMECONF; /*(iproc==0)*/ CopyFile(op_in,op_out); //TODO here we should also copy the mesh file from the mesh generator... but we need to know the filename... @@ -512,7 +512,7 @@ void Files::CheckIODirectories() { //INPUT std::string abs_app = "./"; -/*all procs*/ CheckDirOrAbort(abs_app,DEFAULT_CONFIGDIR); //it must be there only to be COPIED (and we don't even need the check in restart case) +/*all procs*/ CheckDirOrAbort(abs_app,DEFAULT_INPUTDIR); //it must be there only to be COPIED (and we don't even need the check in restart case) /*all procs*/ CheckDir(abs_app,DEFAULT_OUTPUTDIR); diff --git a/src/utils/Files.hpp b/src/utils/Files.hpp index a0cae15a1..f170a299d 100644 --- a/src/utils/Files.hpp +++ b/src/utils/Files.hpp @@ -76,7 +76,9 @@ class Files { bool GetRestartFlag() const { return _restart_flag; } - + + static void CheckDir(const std::string& dir_name_in, const std::string& my_name_in); + private: static std::ofstream file_sbuf; //needed for I/O purposes @@ -90,7 +92,7 @@ class Files { // Directory management void ComposeOutdirName(); static void CheckDirOrMake(const std::string& dir_name_in, const std::string& my_name_in); - static void CheckDir(const std::string& dir_name_in, const std::string& my_name_in); +// static void CheckDir(const std::string& dir_name_in, const std::string& my_name_in); static void CheckDirOrAbort(const std::string& dir_name_in, const std::string& my_name_in); // Copy diff --git a/src/utils/Math.hpp b/src/utils/Math.hpp index f23763da5..43d7f1f88 100644 --- a/src/utils/Math.hpp +++ b/src/utils/Math.hpp @@ -96,35 +96,36 @@ inline void extend_nds(const uint el_ndofs,const double* a_nds, double* a_nds3D, //================================================================= -inline double FunctionIntegral (const uint vb, MultiLevelProblem & eqnmap_in, double (*pt2func)(double, const std::vector ) ) { +inline double FunctionIntegral (const uint vb, MultiLevelProblem & ml_prob, double (*pt2func)(double, const std::vector ) ) { const uint mesh_vb = vb; -const uint Level = eqnmap_in.GetMeshTwo()._NoLevels - 1; -const uint myproc = eqnmap_in.GetMeshTwo()._iproc; + +const uint Level = ml_prob.GetMeshTwo()._NoLevels - 1; +const uint myproc = ml_prob.GetMeshTwo()._iproc; double time = 0.; - CurrentElem currelem(Level,vb,NULL,eqnmap_in.GetMeshTwo(),eqnmap_in.GetElemType()); //element without equation - CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,eqnmap_in.GetQrule(currelem.GetDim())); + Mesh *mymsh = ml_prob._ml_msh->GetLevel(Level); + + CurrentElem currelem(Level,vb,NULL,ml_prob.GetMeshTwo(),ml_prob.GetElemType()); //element without equation + currelem.SetMesh(mymsh); + CurrentGaussPointBase & currgp = CurrentGaussPointBase::build(currelem,ml_prob.GetQrule(currelem.GetDim())); - //======== ELEMENT MAPPING ======= - const uint meshql = (int) eqnmap_in.GetMeshTwo().GetRuntimeMap().get("meshql"); - //========= DOMAIN MAPPING CurrentQuantity xyz(currgp); - xyz._dim = eqnmap_in.GetMeshTwo().get_dim(); - xyz._FEord = meshql; + xyz._dim = ml_prob.GetMeshTwo().get_dim(); + xyz._FEord = MESH_MAPPING_FE; xyz._ndof = currelem.GetElemType(xyz._FEord)->GetNDofs(); xyz.Allocate(); double integral = 0.; //loop over the geom el types - const uint el_ngauss = eqnmap_in.GetQrule(currelem.GetDim()).GetGaussPointsNumber(); + const uint el_ngauss = ml_prob.GetQrule(currelem.GetDim()).GetGaussPointsNumber(); //parallel sum - const uint nel_e = eqnmap_in.GetMeshTwo()._off_el[mesh_vb][eqnmap_in.GetMeshTwo()._NoLevels*myproc+Level+1]; - const uint nel_b = eqnmap_in.GetMeshTwo()._off_el[mesh_vb][eqnmap_in.GetMeshTwo()._NoLevels*myproc+Level]; + const uint nel_e = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*myproc+Level+1]; + const uint nel_b = ml_prob.GetMeshTwo()._off_el[mesh_vb][ml_prob.GetMeshTwo()._NoLevels*myproc+Level]; for (uint iel=0; iel < (nel_e - nel_b); iel++) { @@ -142,7 +143,7 @@ double Jac_g=0.; if (vb==0) Jac_g = currgp.JacVectVV_g(xyz); //not xyz_refbox! else if (vb==1) Jac_g = currgp.JacVectBB_g(xyz); //not xyz_refbox! - const double wgt_g = eqnmap_in.GetQrule(currelem.GetDim()).GetGaussWeight(qp); + const double wgt_g = ml_prob.GetQrule(currelem.GetDim()).GetGaussWeight(qp); for (uint fe = 0; fe < QL; fe++) { currgp.SetPhiElDofsFEVB_g (fe,qp); } @@ -160,7 +161,7 @@ double myval_g = pt2func(time,xyz._val_g); std::cout << std::endl << " ^^^^^^^^^^^^^^^^^L'integrale sul processore "<< myproc << " vale: " << integral << std::endl; double weights_sum = 0.; - for (uint qp = 0; qp < el_ngauss; qp++) weights_sum += eqnmap_in.GetQrule(currelem.GetDim()).GetGaussWeight(qp); + for (uint qp = 0; qp < el_ngauss; qp++) weights_sum += ml_prob.GetQrule(currelem.GetDim()).GetGaussWeight(qp); std::cout << std::endl << " ^^^^^^^^^^^^^^^^^ La somma dei pesi vale: " << weights_sum << std::endl; double J=0.; diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index b266729a5..9ecf0b06a 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -3,9 +3,7 @@ ############################################################################################# ADD_SUBDIRECTORY(testNSSteadyDD/) -# FILE(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/unittests/testNSSteadyDD/input/) -# FILE(COPY testNSSteadyDD/input/ DESTINATION ${PROJECT_BINARY_DIR}/unittests/testNSSteadyDD/input/) ADD_SUBDIRECTORY(testFSISteady/) -# FILE(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/unittests/testFSISteady/input/) -# FILE(COPY testFSISteady/input/ DESTINATION ${PROJECT_BINARY_DIR}/unittests/testFSISteady/input/) \ No newline at end of file + +ADD_SUBDIRECTORY(testSalomeIO/) diff --git a/unittests/testFSISteady/main.cpp b/unittests/testFSISteady/main.cpp index b18d180e4..905312e4b 100644 --- a/unittests/testFSISteady/main.cpp +++ b/unittests/testFSISteady/main.cpp @@ -58,10 +58,11 @@ int main(int argc,char **args) { //Start System Variables ml_sol.AddSolution("DX",LAGRANGE,SECOND,1); ml_sol.AddSolution("DY",LAGRANGE,SECOND,1); - ml_sol.AssociatePropertyToSolution("DX","Displacement"); // Add this line - ml_sol.AssociatePropertyToSolution("DY","Displacement"); // Add this line +// ml_sol.AssociatePropertyToSolution("DX","Displacement"); // Add this line +// ml_sol.AssociatePropertyToSolution("DY","Displacement"); // Add this line ml_sol.AddSolution("U",LAGRANGE,SECOND,1); ml_sol.AddSolution("V",LAGRANGE,SECOND,1); + // Since the Pressure is a Lagrange multiplier it is used as an implicit variable ml_sol.AddSolution("P",DISCONTINOUS_POLYNOMIAL,FIRST,1); ml_sol.AssociatePropertyToSolution("P","Pressure"); // Add this line @@ -128,7 +129,7 @@ int main(int argc,char **args) { std::vector mov_vars; mov_vars.push_back("DX"); mov_vars.push_back("DY"); - VTKWriter vtkio(ml_sol); + VTKWriter vtkio(&ml_sol); vtkio.SetMovingMesh(mov_vars); // Solving Fluid-Structure-Interaction system @@ -478,7 +479,7 @@ void AssembleMatrixResFSI(MultiLevelProblem &ml_prob, unsigned level, const unsi // mesh and procs unsigned nel = mymsh->GetNumberOfElements(); - unsigned igrid = mymsh->GetGridNumber(); + unsigned igrid = mymsh->GetLevel(); unsigned iproc = mymsh->processor_id(); //---------------------------------------------------------------------------------- diff --git a/unittests/testNSSteadyDD/main.cpp b/unittests/testNSSteadyDD/main.cpp index 432f98b84..ec1126cf0 100644 --- a/unittests/testNSSteadyDD/main.cpp +++ b/unittests/testNSSteadyDD/main.cpp @@ -247,7 +247,7 @@ int main(int argc,char **args) { // print_vars.push_back("T"); // GMVWriter gmvio(ml_sol); -// gmvio.write_system_solutions("biquadratic",print_vars); +// gmvio.write("biquadratic",print_vars); @@ -410,7 +410,7 @@ void AssembleMatrixResNS(MultiLevelProblem &ml_prob, unsigned level, const unsig //data const unsigned dim = mymsh->GetDimension(); unsigned nel= mymsh->GetNumberOfElements(); - unsigned igrid= mymsh->GetGridNumber(); + unsigned igrid= mymsh->GetLevel(); unsigned iproc = mymsh->processor_id(); double ILambda= 0; double IRe = ml_prob.parameters.get("Fluid").get_IReynolds_number(); @@ -732,7 +732,7 @@ void AssembleMatrixResT(MultiLevelProblem &ml_prob, unsigned level, const unsign //data const unsigned dim = mymsh->GetDimension(); unsigned nel = mymsh->GetNumberOfElements(); - unsigned igrid = mymsh->GetGridNumber(); + unsigned igrid = mymsh->GetLevel(); unsigned iproc = mymsh->processor_id(); double IPe = 1./(ml_prob.parameters.get("Fluid").get_Peclet_number()); diff --git a/unittests/testSalomeIO/CMakeLists.txt b/unittests/testSalomeIO/CMakeLists.txt new file mode 100644 index 000000000..f6fb0d3fc --- /dev/null +++ b/unittests/testSalomeIO/CMakeLists.txt @@ -0,0 +1,12 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +get_filename_component(APP_FOLDER_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) +set(THIS_APPLICATION ${APP_FOLDER_NAME}) + +PROJECT(${THIS_APPLICATION}) + +INCLUDE(CTest) + +ADD_TEST(NAME ${THIS_APPLICATION} COMMAND ${THIS_APPLICATION}) + +femusMacroBuildApplication(${THIS_APPLICATION} ${THIS_APPLICATION}) \ No newline at end of file diff --git a/unittests/testSalomeIO/input/OneHex27.med b/unittests/testSalomeIO/input/OneHex27.med new file mode 100644 index 000000000..1dc3ca571 Binary files /dev/null and b/unittests/testSalomeIO/input/OneHex27.med differ diff --git a/unittests/testSalomeIO/input/OneQuad9.med b/unittests/testSalomeIO/input/OneQuad9.med new file mode 100644 index 000000000..130be0df2 Binary files /dev/null and b/unittests/testSalomeIO/input/OneQuad9.med differ diff --git a/unittests/testSalomeIO/input/StudyHex27.hdf b/unittests/testSalomeIO/input/StudyHex27.hdf new file mode 100644 index 000000000..8e804e29b Binary files /dev/null and b/unittests/testSalomeIO/input/StudyHex27.hdf differ diff --git a/unittests/testSalomeIO/input/two_meshes.med b/unittests/testSalomeIO/input/two_meshes.med new file mode 100644 index 000000000..49bfe7fdc Binary files /dev/null and b/unittests/testSalomeIO/input/two_meshes.med differ diff --git a/unittests/testSalomeIO/testSalomeIO.cpp b/unittests/testSalomeIO/testSalomeIO.cpp new file mode 100644 index 000000000..7f348bff8 --- /dev/null +++ b/unittests/testSalomeIO/testSalomeIO.cpp @@ -0,0 +1,34 @@ +#include +#include "FemusDefault.hpp" +#include "FemusInit.hpp" +#include "MultiLevelMesh.hpp" +#include "WriterEnum.hpp" + +using namespace femus; + +// Test for SalomeIO reading + + +int main(int argc,char **args) { + + FemusInit init(argc,args,MPI_COMM_WORLD); + + std::string med_file = "OneQuad9.med"; + std::ostringstream mystream; mystream << "./" << DEFAULT_INPUTDIR << "/" << med_file; + const std::string infile = mystream.str(); + + //Adimensional + double Lref = 1.; + + MultiLevelMesh ml_msh; + ml_msh.ReadCoarseMesh(infile.c_str(),"seventh",Lref); + + ml_msh.SetWriter(XDMF); + ml_msh.GetWriter()->write(DEFAULT_OUTPUTDIR,"biquadratic"); + ml_msh.SetWriter(VTK); + ml_msh.GetWriter()->write(DEFAULT_OUTPUTDIR,"biquadratic"); + ml_msh.SetWriter(GMV); + ml_msh.GetWriter()->write(DEFAULT_OUTPUTDIR,"biquadratic"); + + return 0; +}