From: michael Date: Thu, 17 Dec 2020 10:52:44 +0000 (+0100) Subject: Renamed test source file X-Git-Tag: V9_7_0~81 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ee4ef4fc3319f5e0c202e935468109ff6ddcb643;p=tools%2Fsolverlab.git Renamed test source file --- diff --git a/CoreFlows/examples/C/CMakeLists.txt b/CoreFlows/examples/C/CMakeLists.txt index b966a6c..587e1d3 100755 --- a/CoreFlows/examples/C/CMakeLists.txt +++ b/CoreFlows/examples/C/CMakeLists.txt @@ -98,14 +98,14 @@ CreateTestExecAndInstall(StationaryDiffusionEquation_3DFV_StructuredTetrahedra.c CreateTestExecAndInstall(testEOS.cxx "${libs_for_tests}" ) - add_executable(WaveSystem_FV_SphericalExplosion_CDMATH.exe WaveSystem_2DFV_SphericalExplosion_CDMATH.cxx) + add_executable(WaveSystem_FV_SphericalExplosion_CDMATH.exe WaveSystem_FV_SphericalExplosion_CDMATH.cxx) target_link_libraries(WaveSystem_FV_SphericalExplosion_CDMATH.exe CoreFlowsLibs ) install(TARGETS WaveSystem_FV_SphericalExplosion_CDMATH.exe DESTINATION share/examples) add_test(NAME WaveSystem_2DFV_SphericalExplosion_CDMATH_SQUARE COMMAND "./WaveSystem_FV_SphericalExplosion_CDMATH.exe") add_test(NAME WaveSystem_3DFV_SphericalExplosion_CDMATH_CUBE COMMAND "./WaveSystem_FV_SphericalExplosion_CDMATH.exe" resources/meshCube.med) if( SOLVERLAB_WITH_MPI ) - add_executable(WaveSystem_2DFV_SphericalExplosion_MPI.exe WaveSystem_2DFV_SphericalExplosion_MPI.cxx) # compilation of the testxxx.exe + add_executable(WaveSystem_2DFV_SphericalExplosion_MPI.exe WaveSystem_FV_SphericalExplosion_MPI.cxx) # compilation of the testxxx.exe target_link_libraries(WaveSystem_2DFV_SphericalExplosion_MPI.exe CoreFlowsLibs ${MPI_LIBRARY}) # provide required lib for testxxx.exe install(TARGETS WaveSystem_2DFV_SphericalExplosion_MPI.exe DESTINATION share/examples) add_test(NAME WaveSystem_2DFV_SphericalExplosion_MPI_SEQ_SQUARE COMMAND "${MPIEXEC}" "-n" "1" "./WaveSystem_2DFV_SphericalExplosion_MPI.exe") diff --git a/CoreFlows/examples/C/WaveSystem_2DFV_SphericalExplosion_CDMATH.cxx b/CoreFlows/examples/C/WaveSystem_2DFV_SphericalExplosion_CDMATH.cxx deleted file mode 100755 index 0299ef2..0000000 --- a/CoreFlows/examples/C/WaveSystem_2DFV_SphericalExplosion_CDMATH.cxx +++ /dev/null @@ -1,298 +0,0 @@ -//============================================================================ -// Author : Michael NDJINGA -// Date : November 2020 -// Description : multiD linear wave system -//============================================================================ - -#include -#include -#include - -#include "Mesh.hxx" -#include "Cell.hxx" -#include "Face.hxx" -#include "Field.hxx" -#include "SparseMatrixPetsc.hxx" -#include "CdmathException.hxx" - -using namespace std; - -double p0 =155e5; //reference pressure in a pressurised nuclear vessel -double c0 =700.; //reference sound speed for water at 155 bars, 600K -double rho0=p0/c0*c0;//reference density -double precision=1e-5; - -void initial_conditions_shock(Mesh my_mesh,Field& pressure_field,Field& velocity_field) -{ - double rayon=0.35; - double xcentre=0.; - double ycentre=0; - double zcentre=0; - - double x, y, z; - double val, valX, valY, valZ; - - int dim =my_mesh.getMeshDimension(); - int nbCells=my_mesh.getNumberOfCells(); - - for (int j=0 ; j1) - { - y = my_mesh.getCell(j).y() ; - if(dim==3) - z = my_mesh.getCell(j).z() ; - } - - valX=(x-xcentre)*(x-xcentre); - if(dim==1) - val=sqrt(valX); - else if(dim==2) - { - valY=(y-ycentre)*(y-ycentre); - val=sqrt(valX+valY); - } - else if(dim==3) - { - valY=(y-ycentre)*(y-ycentre); - valZ=(z-zcentre)*(z-zcentre); - val=sqrt(valX+valY+valZ); - } - - for(int idim=0; idim=2) - Un[k + 2*nbCells] = rho0*velocity_field[k,1] ; - if(dim==3) - Un[k + 3*nbCells] = rho0*velocity_field[k,2]; - } - - /* - * MED output of the initial condition at t=0 and iter = 0 - */ - int it=0; - bool isStationary=false; - double time=0.; - double dt = cfl * dx_min / c0; - - cout << "Saving the solution at T=" << time << endl; - pressure_field.setTime(time,it); - pressure_field.writeVTK("WaveSystem"+to_string(dim)+"DUpwind"+meshName+"_pressure"); - velocity_field.setTime(time,it); - velocity_field.writeVTK("WaveSystem"+to_string(dim)+"DUpwind"+meshName+"_velocity"); - /* --------------------------------------------- */ - - SparseMatrixPetsc divMat=computeDivergenceMatrix(my_mesh,nbVoisinsMax,dt); - - /* Time loop */ - cout<< "Starting computation of the linear wave system with an explicit UPWIND scheme" << endl; - while (it=ntmax or isStationary or time >=tmax) - { - cout<<"-- Iteration: " << it << ", Time: " << time << ", dt: " << dt<1) - { - velocity_field[k,1]=Un[k*(dim+1)+2]/rho0; - if(dim>2) - velocity_field[k,2]=Un[k*(dim+1)+3]/rho0; - } - } - pressure_field.setTime(time,it); - pressure_field.writeVTK("WaveSystem"+to_string(dim)+"DUpwind"+meshName+"_pressure",false); - velocity_field.setTime(time,it); - velocity_field.writeVTK("WaveSystem"+to_string(dim)+"DUpwind"+meshName+"_velocity",false); - } - } - cout<<"End of calculation -- Iteration: " << it << ", Time: "<< time<< ", dt: " << dt<=ntmax) - cout<< "Nombre de pas de temps maximum ntmax= "<< ntmax<< " atteint"< -#include -#include - -#include "Mesh.hxx" -#include "Cell.hxx" -#include "Face.hxx" -#include "Field.hxx" -#include "CdmathException.hxx" - -#include - -using namespace std; - -double p0 =155e5; //reference pressure in a pressurised nuclear vessel -double c0 =700.; //reference sound speed for water at 155 bars, 600K -double rho0=p0/c0*c0;//reference density -double precision=1e-5; - -void initial_conditions_shock(Mesh my_mesh,Field& pressure_field,Field& velocity_field) -{ - double rayon=0.35; - double xcentre=0.; - double ycentre=0; - double zcentre=0; - - double x, y, z; - double val, valX, valY, valZ; - - int dim =my_mesh.getMeshDimension(); - int nbCells=my_mesh.getNumberOfCells(); - - for (int j=0 ; j1) - { - y = my_mesh.getCell(j).y() ; - if(dim==3) - z = my_mesh.getCell(j).z() ; - } - - valX=(x-xcentre)*(x-xcentre); - if(dim==1) - val=sqrt(valX); - else if(dim==2) - { - valY=(y-ycentre)*(y-ycentre); - val=sqrt(valX+valY); - } - else if(dim==3) - { - valY=(y-ycentre)*(y-ycentre); - valZ=(z-zcentre)*(z-zcentre); - val=sqrt(valX+valY+valZ); - } - - for(int idim=0; idim=ntmax or isStationary or time >=tmax ) - { - PetscPrintf(PETSC_COMM_WORLD,"-- Iteration: %d, Time: %f, dt: %f, saving results on processor 0 \n", it, time, dt); - VecScatterBegin(scat,Un,Un_seq,INSERT_VALUES,SCATTER_FORWARD); - VecScatterEnd( scat,Un,Un_seq,INSERT_VALUES,SCATTER_FORWARD); - - if(rank == 0) - { - for(int k=0; k=ntmax) - PetscPrintf(PETSC_COMM_WORLD, "Nombre de pas de temps maximum ntmax= %d atteint\n", ntmax); - else if(isStationary) - PetscPrintf(PETSC_COMM_WORLD, "Régime stationnaire atteint au pas de temps %d, t= %f\n", it, time); - else - PetscPrintf(PETSC_COMM_WORLD, "Temps maximum tmax= %f atteint\n", tmax); - - VecDestroy(&Un); - VecDestroy(&Un_seq); - VecDestroy(&dUn); - MatDestroy(&divMat); -} - -int main(int argc, char *argv[]) -{ - /* PETSc initialisation */ - PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL); - PetscMPIInt size; /* size of communicator */ - PetscMPIInt rank; /* processor rank */ - MPI_Comm_rank(PETSC_COMM_WORLD,&rank); - MPI_Comm_size(PETSC_COMM_WORLD,&size); - - // Problem data - double cfl=0.49; - double tmax=1.; - int ntmax=2000; - int freqSortie=10; - string fileOutPut="SphericalWave"; - Mesh myMesh; - string resultDirectory="./"; - - if(size>1) - PetscPrintf(PETSC_COMM_WORLD,"---- More than one processor detected : running a parallel simulation ----\n"); - PetscPrintf(PETSC_COMM_WORLD,"---- Limited parallelism : input and output remain sequential ----\n"); - PetscPrintf(PETSC_COMM_WORLD,"---- Only the matrix-vector products are done in parallel ----\n"); - PetscPrintf(PETSC_COMM_WORLD,"---- Processor 0 is in charge of building the mesh, saving the results, filling and then distributing the matrix to other processors.\n\n"); - - if(rank == 0) - { - cout << "-- Starting the RESOLUTION OF THE 2D WAVE SYSTEM on "<< size <<" processors"<2) - resultDirectory = argv[2]; - } - - WaveSystem(tmax,ntmax,cfl,freqSortie,myMesh,fileOutPut, rank, size, resultDirectory); - - if(rank == 0) - cout << "Simulation complete." << endl; - - PetscFinalize(); - return 0; -} diff --git a/CoreFlows/examples/C/WaveSystem_FV_SphericalExplosion_CDMATH.cxx b/CoreFlows/examples/C/WaveSystem_FV_SphericalExplosion_CDMATH.cxx new file mode 100755 index 0000000..0299ef2 --- /dev/null +++ b/CoreFlows/examples/C/WaveSystem_FV_SphericalExplosion_CDMATH.cxx @@ -0,0 +1,298 @@ +//============================================================================ +// Author : Michael NDJINGA +// Date : November 2020 +// Description : multiD linear wave system +//============================================================================ + +#include +#include +#include + +#include "Mesh.hxx" +#include "Cell.hxx" +#include "Face.hxx" +#include "Field.hxx" +#include "SparseMatrixPetsc.hxx" +#include "CdmathException.hxx" + +using namespace std; + +double p0 =155e5; //reference pressure in a pressurised nuclear vessel +double c0 =700.; //reference sound speed for water at 155 bars, 600K +double rho0=p0/c0*c0;//reference density +double precision=1e-5; + +void initial_conditions_shock(Mesh my_mesh,Field& pressure_field,Field& velocity_field) +{ + double rayon=0.35; + double xcentre=0.; + double ycentre=0; + double zcentre=0; + + double x, y, z; + double val, valX, valY, valZ; + + int dim =my_mesh.getMeshDimension(); + int nbCells=my_mesh.getNumberOfCells(); + + for (int j=0 ; j1) + { + y = my_mesh.getCell(j).y() ; + if(dim==3) + z = my_mesh.getCell(j).z() ; + } + + valX=(x-xcentre)*(x-xcentre); + if(dim==1) + val=sqrt(valX); + else if(dim==2) + { + valY=(y-ycentre)*(y-ycentre); + val=sqrt(valX+valY); + } + else if(dim==3) + { + valY=(y-ycentre)*(y-ycentre); + valZ=(z-zcentre)*(z-zcentre); + val=sqrt(valX+valY+valZ); + } + + for(int idim=0; idim=2) + Un[k + 2*nbCells] = rho0*velocity_field[k,1] ; + if(dim==3) + Un[k + 3*nbCells] = rho0*velocity_field[k,2]; + } + + /* + * MED output of the initial condition at t=0 and iter = 0 + */ + int it=0; + bool isStationary=false; + double time=0.; + double dt = cfl * dx_min / c0; + + cout << "Saving the solution at T=" << time << endl; + pressure_field.setTime(time,it); + pressure_field.writeVTK("WaveSystem"+to_string(dim)+"DUpwind"+meshName+"_pressure"); + velocity_field.setTime(time,it); + velocity_field.writeVTK("WaveSystem"+to_string(dim)+"DUpwind"+meshName+"_velocity"); + /* --------------------------------------------- */ + + SparseMatrixPetsc divMat=computeDivergenceMatrix(my_mesh,nbVoisinsMax,dt); + + /* Time loop */ + cout<< "Starting computation of the linear wave system with an explicit UPWIND scheme" << endl; + while (it=ntmax or isStationary or time >=tmax) + { + cout<<"-- Iteration: " << it << ", Time: " << time << ", dt: " << dt<1) + { + velocity_field[k,1]=Un[k*(dim+1)+2]/rho0; + if(dim>2) + velocity_field[k,2]=Un[k*(dim+1)+3]/rho0; + } + } + pressure_field.setTime(time,it); + pressure_field.writeVTK("WaveSystem"+to_string(dim)+"DUpwind"+meshName+"_pressure",false); + velocity_field.setTime(time,it); + velocity_field.writeVTK("WaveSystem"+to_string(dim)+"DUpwind"+meshName+"_velocity",false); + } + } + cout<<"End of calculation -- Iteration: " << it << ", Time: "<< time<< ", dt: " << dt<=ntmax) + cout<< "Nombre de pas de temps maximum ntmax= "<< ntmax<< " atteint"< +#include +#include + +#include "Mesh.hxx" +#include "Cell.hxx" +#include "Face.hxx" +#include "Field.hxx" +#include "CdmathException.hxx" + +#include + +using namespace std; + +double p0 =155e5; //reference pressure in a pressurised nuclear vessel +double c0 =700.; //reference sound speed for water at 155 bars, 600K +double rho0=p0/c0*c0;//reference density +double precision=1e-5; + +void initial_conditions_shock(Mesh my_mesh,Field& pressure_field,Field& velocity_field) +{ + double rayon=0.35; + double xcentre=0.; + double ycentre=0; + double zcentre=0; + + double x, y, z; + double val, valX, valY, valZ; + + int dim =my_mesh.getMeshDimension(); + int nbCells=my_mesh.getNumberOfCells(); + + for (int j=0 ; j1) + { + y = my_mesh.getCell(j).y() ; + if(dim==3) + z = my_mesh.getCell(j).z() ; + } + + valX=(x-xcentre)*(x-xcentre); + if(dim==1) + val=sqrt(valX); + else if(dim==2) + { + valY=(y-ycentre)*(y-ycentre); + val=sqrt(valX+valY); + } + else if(dim==3) + { + valY=(y-ycentre)*(y-ycentre); + valZ=(z-zcentre)*(z-zcentre); + val=sqrt(valX+valY+valZ); + } + + for(int idim=0; idim=ntmax or isStationary or time >=tmax ) + { + PetscPrintf(PETSC_COMM_WORLD,"-- Iteration: %d, Time: %f, dt: %f, saving results on processor 0 \n", it, time, dt); + VecScatterBegin(scat,Un,Un_seq,INSERT_VALUES,SCATTER_FORWARD); + VecScatterEnd( scat,Un,Un_seq,INSERT_VALUES,SCATTER_FORWARD); + + if(rank == 0) + { + for(int k=0; k=ntmax) + PetscPrintf(PETSC_COMM_WORLD, "Nombre de pas de temps maximum ntmax= %d atteint\n", ntmax); + else if(isStationary) + PetscPrintf(PETSC_COMM_WORLD, "Régime stationnaire atteint au pas de temps %d, t= %f\n", it, time); + else + PetscPrintf(PETSC_COMM_WORLD, "Temps maximum tmax= %f atteint\n", tmax); + + VecDestroy(&Un); + VecDestroy(&Un_seq); + VecDestroy(&dUn); + MatDestroy(&divMat); +} + +int main(int argc, char *argv[]) +{ + /* PETSc initialisation */ + PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL); + PetscMPIInt size; /* size of communicator */ + PetscMPIInt rank; /* processor rank */ + MPI_Comm_rank(PETSC_COMM_WORLD,&rank); + MPI_Comm_size(PETSC_COMM_WORLD,&size); + + // Problem data + double cfl=0.49; + double tmax=1.; + int ntmax=2000; + int freqSortie=10; + string fileOutPut="SphericalWave"; + Mesh myMesh; + string resultDirectory="./"; + + if(size>1) + PetscPrintf(PETSC_COMM_WORLD,"---- More than one processor detected : running a parallel simulation ----\n"); + PetscPrintf(PETSC_COMM_WORLD,"---- Limited parallelism : input and output remain sequential ----\n"); + PetscPrintf(PETSC_COMM_WORLD,"---- Only the matrix-vector products are done in parallel ----\n"); + PetscPrintf(PETSC_COMM_WORLD,"---- Processor 0 is in charge of building the mesh, saving the results, filling and then distributing the matrix to other processors.\n\n"); + + if(rank == 0) + { + cout << "-- Starting the RESOLUTION OF THE 2D WAVE SYSTEM on "<< size <<" processors"<2) + resultDirectory = argv[2]; + } + + WaveSystem(tmax,ntmax,cfl,freqSortie,myMesh,fileOutPut, rank, size, resultDirectory); + + if(rank == 0) + cout << "Simulation complete." << endl; + + PetscFinalize(); + return 0; +}