option (COREFLOWS_WITH_GUI "Compile Graphic user Interface for COREFLOWS." OFF)
option (COREFLOWS_WITH_PACKAGE "Generate RPM, Debian and tarball packages." OFF)
+#Path to installed libraries
+set (PETSC_DIR OFF CACHE STRING "PETSc library path" )
+set (SLEPC_DIR OFF CACHE STRING "SLEPc library path" )
+
enable_testing() #
# Debug mode activates testing and profiling --------------------------------------------------------------#
if (CMAKE_BUILD_TYPE STREQUAL Debug) #
# PETSC ----------------------------------------------------------------------------------------------------#
message ( STATUS "Checking variable PETSC_DIR : " $ENV{PETSC_DIR} )
-if ( NOT DEFINED ENV{PETSC_DIR} AND IS_DIRECTORY "/usr/include/petsc/" AND EXISTS "/usr/lib64/libpetsc.so") #Case fedora/redhat system install
+if ( NOT PETSC_DIR AND NOT DEFINED ENV{PETSC_DIR} AND IS_DIRECTORY "/usr/include/petsc/" AND EXISTS "/usr/lib64/libpetsc.so") #Case fedora/redhat system install
message ( STATUS "PETSC includes found in /usr/include/petsc/" )
message ( STATUS "PETSC library found in /usr/lib64" )
set(PETSC_DIR /usr/)
+ set(PETSC_ARCH lib64)
set(PETSC_INCLUDES /usr/include/petsc /usr/include/petsc/petsc/mpiuni)
set(PETSC_INCLUDES_PATH /usr/include/petsc:/usr/include/petsc/petsc/mpiuni)
set(PETSC_LIBRARIES /usr/lib64/libpetsc.so)
- set(PETSC_VERSION "3.7") #3.7 for fedora 25/26 , 3.9 for fedora 29
- set (CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}, petsc-devel (>= 3.4)") # This is not fully working yet.
+ set(PETSC_VERSION "3.7") #3.7 for fedora 25/26 , 3.9 for fedora 29 , 3.10 for fedora 30, , 3.12 for fedora 32
+ set(CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}, petsc-devel (>= 3.4)") # This is not fully working yet.
+
+ #Define and search slepc variables
+ if ( IS_DIRECTORY "/usr/include/slepc/" AND EXISTS "/usr/lib64/libslepc.so" )
+ message( STATUS "SLEPc includes found in /usr/include/slepc/" )
+ message( STATUS "SLEPc library found in /usr/lib64/slepc/" )
+ set(SLEPC_DIR /usr/)
+ set(SLEPC_INCLUDES ${SLEPC_DIR}/include)
+ set(SLEPC_LIBRARIES ${SLEPC_DIR}/lib/libslepc.so)
+ set (CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}, slepc-devel (>= 3.4)") # This is not fully working yet.
+ else ( IS_DIRECTORY "/usr/include/slepc/" AND EXISTS "/usr/lib64/libslepc.so" )
+ message( FATAL_ERROR "SLEPc not found in the system" )
+ endif( IS_DIRECTORY "/usr/include/slepc/" AND EXISTS "/usr/lib64/libslepc.so" )
#elseif ( IS_DIRECTORY "/usr/lib/petsc/") #Case ubuntu/debian system install
# message ( STATUS "PETSC found in /usr/lib/petsc/" )
# set(PETSC_DIR /usr/lib/petsc/)
+# set(PETSC_ARCH )
# find_package (PETSc 3.4 REQUIRED)
# petsc_get_version ()
# set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, petsc-dev (>= 3.4)") # This is not fully working yet.
#elseif ( IS_DIRECTORY "/usr/local/lib/python2.7/dist-packages/petsc") #Case ubuntu/debian system pip install
# message ( STATUS "PETSC found in /usr/local/lib/python2.7/dist-packages/petsc" )
-# set(PETSC_DIR /usr/local/lib/python2.7/dist-packages/petsc)
-# set(PETSC_INCLUDES /usr/local/lib/python2.7/dist-packages/petsc/include /usr/include/openmpi)
-# set(PETSC_INCLUDES_PATH /usr/local/lib/python2.7/dist-packages/petsc/include:/usr/include/openmpi)
-# set(PETSC_LIBRARIES /usr/local/lib/python2.7/dist-packages/petsc/lib/libpetsc.so)
+# set(PETSC_DIR /usr/local/lib/python2.7/dist-packages/petsc/)
+# set(PETSC_ARCH lib)
+# set(PETSC_INCLUDES $PETSC_DIR/include /usr/include/openmpi)
+# set(PETSC_INCLUDES_PATH $PETSC_DIR/include:/usr/include/openmpi)
+# set(PETSC_LIBRARIES $PETSC_DIR/lib/libpetsc.so)
# set(PETSC_VERSION "3.8") #value for Ubuntu 16.04
-else ()
+else ( NOT PETSC_DIR AND NOT DEFINED ENV{PETSC_DIR} AND IS_DIRECTORY "/usr/include/petsc/" AND EXISTS "/usr/lib64/libpetsc.so")
+ if(NOT PETSC_DIR)
+ set(PETSC_DIR $ENV{PETSC_DIR})
+ endif(NOT PETSC_DIR)
+
find_package (PETSc 3.4 REQUIRED)
petsc_get_version ()
string(REPLACE ";" ":" PETSC_INCLUDES_PATH "${PETSC_INCLUDES}")# use colon instead of semicolon in environment file env_CoreFlows.sh
-endif ()
+
+ #Define and search slepc variables
+ if ( NOT SLEPC_DIR )
+ if ( DEFINED ENV{SLEPC_DIR} )
+ set(SLEPC_DIR $ENV{SLEPC_DIR})
+ else ( DEFINED ENV{SLEPC_DIR} )
+ set(SLEPC_DIR ${PETSC_DIR}/${PETSC_ARCH})
+ endif( DEFINED ENV{SLEPC_DIR} )
+ endif( NOT SLEPC_DIR)
+
+ message ( STATUS "Checking variable SLEPC_DIR" )
+ if ( IS_DIRECTORY ${SLEPC_DIR}/include AND EXISTS ${SLEPC_DIR}/lib/libslepc.so)
+ set(SLEPC_INCLUDES ${SLEPC_DIR}/include)
+ set(SLEPC_LIBRARIES ${SLEPC_DIR}/lib/libslepc.so)
+ message( STATUS "SLEPc found at ${SLEPC_DIR}" )
+ else()
+ message( FATAL_ERROR "SLEPc not found at ${SLEPC_DIR}" )
+ endif()
+
+endif( NOT PETSC_DIR AND NOT DEFINED ENV{PETSC_DIR} AND IS_DIRECTORY "/usr/include/petsc/" AND EXISTS "/usr/lib64/libpetsc.so")
if (${PETSC_VERSION} VERSION_GREATER 3.5)
add_definitions(-DPETSC_VERSION_GREATER_3_5)
#
#-----------------------------------------------------------------------------------------------------------#
-
# Base directories
set (CoreFlows_SRC ${CoreFlows_SOURCE_DIR}/Models )
set (CoreFlows_EXAMPLES ${CoreFlows_SOURCE_DIR}/examples)
+
+set( CoreFlows_INCLUDES
+ ${CDMATH_INCLUDES} #
+ ${MED_INCLUDES} #
+ ${MEDCOUPLING_INCLUDES} #
+ ${PETSC_INCLUDES} #
+ ${CoreFlows_SRC}/inc #
+ ) #
+
add_subdirectory (${CoreFlows_SRC})
add_subdirectory (${CoreFlows_EXAMPLES})
if (COREFLOWS_WITH_PYTHON) #
add_subdirectory (${CoreFlows_SWIG_DIR}) #
endif () #
-
-
# Documentation --------------------------------------------------------------------------------------------#
#
if (COREFLOWS_WITH_DOCUMENTATION) #
#--------------------- COMPILATION MAIN --------------------------------------------------------------------#
#
INCLUDE_DIRECTORIES( #
- #
- ${PETSC_INCLUDES} #
- ${CDMATH_INCLUDES} #
- ${CDMATH_INCLUDES}/med #
- ${CDMATH_INCLUDES}/medcoupling #
- ${CoreFlows_SRC}/inc #
+ ${CoreFlows_INCLUDES} #
) #
#
SET(CoreFlowsMain_SOURCES #
${CoreFlows_SRC}/src/Fluide.cxx #
${CoreFlows_SRC}/src/DiffusionEquation.cxx #
- ${CoreFlows_SRC}/src/StationaryDiffusionEquation.cxx #
+ ${CoreFlows_SRC}/src/StationaryDiffusionEquation.cx #
${CoreFlows_SRC}/src/ProblemFluid.cxx #
${CoreFlows_SRC}/src/IsothermalTwoFluid.cxx #
${CoreFlows_SRC}/src/utilitaire_algebre.cxx #
using namespace std;
+//! enumeration BoundaryType
+/*! Boundary condition type */
+enum BoundaryTypeDiffusion { NeumannDiffusion, DirichletDiffusion, NoneBCDiffusion};
+
+/** \struct LimitField
+ * \brief value of some fields on the boundary */
+struct LimitFieldDiffusion{
+ LimitFieldDiffusion(){bcType=NoneBCDiffusion; T=0; normalFlux=0;}
+ LimitFieldDiffusion(BoundaryTypeDiffusion _bcType, double _T, double _normalFlux){
+ bcType=_bcType; T=_T; normalFlux=_normalFlux;
+ }
+
+ BoundaryTypeDiffusion bcType;
+ double T; //for Dirichlet
+ double normalFlux; //for Neumann
+};
+
class DiffusionEquation: public ProblemCoreFlows
{
void validateTimeStep();
/* Boundary conditions */
- void setBoundaryFields(map<string, LimitField> boundaryFields){
+ void setBoundaryFields(map<string, LimitFieldDiffusion> boundaryFields){
_limitField = boundaryFields;
};
/** \fn setDirichletBoundaryCondition
* \param [out] void
* */
void setDirichletBoundaryCondition(string groupName,double Temperature){
- _limitField[groupName]=LimitField(Dirichlet,-1,vector<double>(_Ndim,0),vector<double>(_Ndim,0),vector<double>(_Ndim,0),Temperature,-1,-1,-1);
+ _limitField[groupName]=LimitFieldDiffusion(DirichletDiffusion,Temperature,-1);
};
/** \fn setNeumannBoundaryCondition
* \brief adds a new boundary condition of type Neumann
* \param [in] string : the name of the boundary
* \param [out] void
* */
- void setNeumannBoundaryCondition(string groupName){
- _limitField[groupName]=LimitField(Neumann,-1, vector<double>(0),vector<double>(0),
- vector<double>(0),-1,-1,-1,-1);
+ void setNeumannBoundaryCondition(string groupName, double normalFlux=0){
+ _limitField[groupName]=LimitFieldDiffusion(NeumannDiffusion,-1, normalFlux);
};
void setRodDensity(double rho){
_fluidTemperatureField=coupledTemperatureField;
_fluidTemperatureFieldSet=true;
};
+
+ void setDiffusiontensor(Matrix DiffusionTensor){
+ _DiffusionTensor=DiffusionTensor;
+ };
+
void setFluidTemperature(double fluidTemperature){
_fluidTemperature=fluidTemperature;
}
+
+ //get output fields for postprocessing or coupling
+ vector<string> getOutputFieldsNames() ;//liste tous les champs que peut fournir le code pour le postraitement
+ Field& getOutputField(const string& nameField );//Renvoie un champs pour le postraitement
+
Field& getRodTemperatureField(){
return _VV;
}
Field& getFluidTemperatureField(){
return _fluidTemperatureField;
}
- void setDiffusiontensor(Matrix DiffusionTensor){
- _DiffusionTensor=DiffusionTensor;
- };
+
protected :
double computeDiffusionMatrix(bool & stop);
double computeDiffusionMatrixFV(bool & stop);
int unknownNodeIndex(int globalIndex, std::vector< int > dirichletNodes);
int globalNodeIndex(int unknownIndex, std::vector< int > dirichletNodes);
+ TimeScheme _timeScheme;
+ map<string, LimitFieldDiffusion> _limitField;
};
#endif /* DiffusionEquation_HXX_ */
--- /dev/null
+//============================================================================
+/**
+ * \file LinearElasticityModel.hxx
+ * \author Michael NDJINGA
+ * \version 1.0
+ * \date August 2020
+ * \brief Stationary linear elasticity model
+ * -div \sigma = f
+ * with the stress \sigma given by the Hooke's law
+ * \sigma=2\mu e(u)+\lambda Tr(e(u)) I_d
+ * solved with either finite elements or finite volume method
+ * Dirichlet (fixed boundary) or Neumann (free boundary) boundary conditions
+ * */
+//============================================================================
+
+/*! \class LinearElasticityModel LinearElasticityModel.hxx "LinearElasticityModel.hxx"
+ * \brief Linear Elasticity Model solved with either finite elements or finite volume method.
+ * -div \sigma = f
+ * \sigma=2\mu e(u)+\lambda Tr(e(u)) I_d
+ */
+#ifndef LinearElasticityModel_HXX_
+#define LinearElasticityModel_HXX_
+
+#include "ProblemCoreFlows.hxx"
+
+using namespace std;
+
+class LinearElasticityModel
+{
+
+public :
+ /** \fn LinearElasticityModel
+ * \brief Constructor for the linear elasticity in a solid
+ * \param [in] int : space dimension
+ * \param [in] double : numerical method
+ * \param [in] double : solid density
+ * \param [in] double : first Lamé coefficient
+ * \param [in] double : second Lamé coefficient
+ * */
+
+ LinearElasticityModel( int dim, bool FECalculation=true, double rho, double lambda, double mu);
+
+ void setConstantDensity(double rho) { _rho=rho; }
+ void setDensityField(Field densityField) { _densityField=densityField; _densityFieldSet=true;}
+ void setLameCoefficient(double lambda, double mu) { _lambda = lambda; _mu = mu;}
+ void setYoungAndPoissonModuli(double E, double nu) { _lambda = E*nu/(1+nu)/(1-2*nu); _mu = E/2/(1+nu);}
+ void setGravity(Vector gravite ) { _gravite=gravite; }
+
+ void setMesh(const Mesh &M);
+ void setFileName(string fileName){
+ _fileName = fileName;
+ }
+ bool solveStationaryProblem();
+ Field getOutputDisplacementField();
+
+ //Linear system and spectrum
+ void setLinearSolver(linearSolver kspType, preconditioner pcType);
+ double getConditionNumber(bool isSingular=false, double tol=1e-6) const;
+
+ //Gestion du calcul
+ void initialize();
+ void terminate();//vide la mémoire et enregistre le résultat final
+ double computeStiffnessMatrix(bool & stop);
+ bool solveLinearSystem();//return true if resolution successfull
+ void save();
+
+ /* Boundary conditions */
+ void setBoundaryFields(map<string, LimitField> boundaryFields){
+ _limitField = boundaryFields;
+ };
+ /** \fn setDirichletBoundaryCondition
+ * \brief adds a new boundary condition of type Dirichlet
+ * \details
+ * \param [in] string : the name of the boundary
+ * \param [in] double : the value of the temperature at the boundary
+ * \param [out] void
+ * */
+ void setDirichletBoundaryCondition(string groupName,double Temperature){
+ _limitField[groupName]=LimitField(Dirichlet,-1, vector<double>(_Ndim,0),vector<double>(_Ndim,0),
+ vector<double>(_Ndim,0),Temperature,-1,-1,-1);
+ };
+
+ /** \fn setNeumannBoundaryCondition
+ * \brief adds a new boundary condition of type Neumann
+ * \details
+ * \param [in] string : the name of the boundary
+ * \param [out] void
+ * */
+ void setNeumannBoundaryCondition(string groupName){
+ _limitField[groupName]=LimitField(Neumann,-1, vector<double>(0),vector<double>(0),
+ vector<double>(0),-1,-1,-1,-1);
+ };
+
+ void setDirichletValues(map< int, double> dirichletBoundaryValues);
+
+
+protected :
+ //Main unknown field
+ Field _VV;
+
+ int _Ndim;//space dimension
+ int _nVar;//Number of equations to solve=1
+
+ //Mesh data
+ Mesh _mesh;
+ bool _meshSet;
+ bool _initializedMemory;
+ int _Nmailles;//number of cells for FV calculation
+ int _neibMaxNbCells;//maximum number of cells around a cell
+
+ double _precision;
+ double _precision_Newton;
+ double _erreur_rel;//norme(Uk+1-Uk)
+ bool _computationCompletedSuccessfully;
+
+ //Linear solver and petsc
+ KSP _ksp;
+ KSPType _ksptype;
+ PC _pc;
+ PCType _pctype;
+ string _pc_hypre;
+ int _maxPetscIts;//nombre maximum d'iteration gmres autorisé au cours d'une resolution de système lineaire
+ int _PetscIts;//the number of iterations of the linear solver
+ Mat _A;//Linear system matrix
+ Vec _b;//Linear system right hand side
+ double _MaxIterLinearSolver;//nombre maximum d'iteration gmres obtenu au cours par les resolution de systemes lineaires au cours d'un pas de tmeps
+ bool _conditionNumber;//computes an estimate of the condition number
+
+ map<string, LimitField> _limitField;
+ bool _onlyNeumannBC;//if true then the linear system is singular and should be solved up to a constant vector
+
+ Vector _normale;
+ Vec _displacements;//unknown of the linear system
+
+ //Physical parameterss
+ double _lambda, _mu;//Lamé coefficients
+ double _rho;//constantDensity
+ Field _densityField;//For non constant density field
+ bool _densityFieldSet;
+ Vector _gravity;
+
+ //Display variables
+ bool _verbose, _system;
+ ofstream * _runLogFile;//for creation of a log file to save the history of the simulation
+ //saving parameters
+ string _fileName;//name of the calculation
+ string _path;//path to execution directory used for saving results
+ saveFormat _saveFormat;//file saving format : MED, VTK or CSV
+
+ double computeRHS(bool & stop);
+ double computeStiffnessMatrixFV(bool & stop);
+
+ /************ Data for FE calculation *************/
+ bool _FECalculation;
+ int _Nnodes;/* number of nodes for FE calculation */
+ int _neibMaxNbNodes;/* maximum number of nodes around a node */
+ int _NunknownNodes;/* number of unknown nodes for FE calculation */
+ int _NboundaryNodes;/* total number of boundary nodes */
+ int _NdirichletNodes;/* number of boundary nodes with Dirichlet BC for FE calculation */
+ std::vector< int > _boundaryNodeIds;/* List of boundary nodes */
+ std::vector< int > _dirichletNodeIds;/* List of boundary nodes with Dirichlet BC */
+
+ /*********** Functions for finite element method ***********/
+ Vector gradientNodal(Matrix M, vector< double > v);//gradient of nodal shape functions
+ double computeStiffnessMatrixFE(bool & stop);
+ int fact(int n);
+ int unknownNodeIndex(int globalIndex, std::vector< int > dirichletNodes);
+ int globalNodeIndex(int unknownIndex, std::vector< int > dirichletNodes);
+
+ /********* Possibility to set a boundary field as Dirichlet boundary condition *********/
+ bool _dirichletValuesSet;
+ std::map< int, double> _dirichletBoundaryValues;
+};
+
+#endif /* LinearElasticityModel_HXX_ */
// Author : M. Ndjinga
// Version :
// Copyright : CEA Saclay 2014
-// Description : Generic class for thermal hydraulics problems
+// Description : Generic class for PDEs problems
//============================================================================
/* A ProblemCoreFlows class */
#include <map>
#include <petsc.h>
+#include <slepceps.h>
+#include <slepcsvd.h>
#include "Field.hxx"
#include "Mesh.hxx"
using namespace std;
-//! enumeration TimeScheme
-/*! The numerical method can be Explicit or Implicit */
-enum TimeScheme
-{
- Explicit,/**< Explicit numerical scheme */
- Implicit/**< Implicit numerical scheme */
-};
-//! enumeration SpaceScheme
-/*! Several numerical schemes are available */
-enum SpaceScheme
-{
- upwind,/**< classical full upwinding scheme (first order in space) */
- centered,/**< centered scheme (second order in space) */
- pressureCorrection,/**< include a pressure correction in the upwind scheme to increase precision at low Mach numbers */
- lowMach,/**< include an upwinding proportional to the Mach numer scheme to increase precision at low Mach numbers */
- staggered,/**< scheme inspired by staggered discretisations */
-};
-
-//! enumeration pressureEstimate
-/*! the pressure estimate needed to fit physical parameters */
-enum pressureEstimate
-{
- around1bar300K,/**< pressure is around 1 bar and temperature around 300K (for TransportEquation, SinglePhase and IsothermalTwoFluid) or 373 K (saturation for DriftModel and FiveEqsTwoFluid) */
- around155bars600K/**< pressure is around 155 bars and temperature around 618 K (saturation) */
-};
-
-//! enumeration BoundaryType
-/*! Boundary condition type */
-enum BoundaryType {Wall, InnerWall, Inlet, InletPressure, InletRotationVelocity, InletEnthalpy, Outlet, Neumann, Dirichlet, NoTypeSpecified};
-//! enumeration Fluid
-/*! The fluid type can be Gas or water */
-enum phaseType
-{
- Liquid,/**< Fluid considered is water */
- Gas/**< Fluid considered is Gas */
-};
-
//! enumeration linearSolver
/*! the linearSolver can be GMRES or BiCGStab (see Petsc documentation) */
enum linearSolver
CSV/**< CSV format is used */
};
-/** \struct LimitField
- * \brief value of some fields on the boundary */
-struct LimitField{
- LimitField(){bcType=NoTypeSpecified; p=0; v_x=vector<double> (0,0); v_y=vector<double> (0,0); v_z=vector<double> (0,0); T=0; h=0; alpha=0; conc=0;}
- LimitField(BoundaryType _bcType, double _p, vector<double> _v_x, vector<double> _v_y, vector<double> _v_z,
- double _T, double _h, double _alpha, double _conc){
- bcType=_bcType; p=_p; v_x=_v_x; v_y=_v_y; v_z=_v_z; T=_T; h=_h; alpha=_alpha; conc=_conc;
- }
-
- BoundaryType bcType;
- double p;//For outlet (fluid models)
- vector<double> v_x; vector<double> v_y; vector<double> v_z;//For wall and inlet (fluid models)
- double T; //for wall and inlet (DriftModel and FiveEqsTwoFluid) and for Dirichlet (DiffusionEquation)
- double h; //for inlet (TransportEquation)
- double alpha; //For inlet (IsothermalTwoFluid and FiveEqsTwoFluid)
- double conc;//For inlet (DriftModel)
+//! enumeration TimeScheme
+/*! The numerical method can be Explicit or Implicit */
+enum TimeScheme
+{
+ Explicit,/**< Explicit numerical scheme */
+ Implicit/**< Implicit numerical scheme */
};
class ProblemCoreFlows
virtual Field& getOutputField(const string& nameField )=0;//Renvoie un champs pour le postraitement
*/
- /** \fn setBoundaryFields
- * \brief met à jour _limitField ( le type de condition limite )
- * \details
- * \param [in] string
- * \param [out] void
- * */
- void setBoundaryFields(map<string, LimitField> boundaryFields){
- _limitField = boundaryFields;
- };
- /** \fn setNeumannBoundaryCondition
- * \brief adds a new boundary condition of type Neumann
- * \details
- * \param [in] string the name of the boundary
- * \param [out] void
- * */
- void setNeumannBoundaryCondition(string groupName){
- _limitField[groupName]=LimitField(Neumann,-1,vector<double>(_Ndim,0),vector<double>(_Ndim,0),vector<double>(_Ndim,0),-1,-1,-1,-1);
- };
-
//paramètres du calcul -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
/** \fn setPresentTime
* */
double getPrecision();
- /** \fn getSpaceScheme
- * \brief returns the space scheme name
- * \param [in] void
- * \param [out] enum SpaceScheme(upwind, centred, pressureCorrection, pressureCorrection, staggered)
- * */
- SpaceScheme getSpaceScheme();
-
- /** \fn getTimeScheme
- * \brief returns the time scheme name
- * \param [in] void
- * \param [out] enum TimeScheme (explicit or implicit)
- * */
- TimeScheme getTimeScheme();
-
/** \fn getMesh
* \brief renvoie _Mesh (le maillage du problème)
* \details
return _nVar;
};
- /** \fn setNumericalScheme
- * \brief sets the numerical method (upwind vs centered and explicit vs implicit
- * \details
- * \param [in] SpaceScheme
- * \param [in] TimeScheme
- * \param [out] void
- * */
- void setNumericalScheme(SpaceScheme scheme, TimeScheme method=Explicit);
-
/** \fn setWellBalancedCorrection
* \brief include a well balanced correction to treat stiff source terms
* @param boolean that is true if a well balanced correction should be applied
_system = system;
};
+ //Spectrum analysis
+ double getConditionNumber(bool isSingular=false, double tol=1e-6) const;
+ std::vector< double > getEigenvalues (int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6) const;
+ std::vector< Vector > getEigenvectors(int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6) const;
+ Field getEigenvectorsField(int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6) const;
+
// some supplementary functions
/** \fn displayMatrix
* */
void displayVector(double *vector, int size, string name);
+ /** \fn getTimeScheme
+ * \brief returns the time scheme name
+ * \param [in] void
+ * \param [out] enum TimeScheme (explicit or implicit)
+ * */
+ TimeScheme getTimeScheme();
+
+ /** \fn setNumericalScheme
+ * \brief sets the numerical method ( explicit vs implicit )
+ * \details
+ * \param [in] TimeScheme
+ * \param [out] void
+ * */
+ void setTimeScheme( TimeScheme method);
+
+
protected :
int _Ndim;//space dimension
double _cfl;
double _maxvp;//valeur propre max pour calcul cfl
double _minl;//minimum cell diameter
- map<string, LimitField> _limitField;
- TimeScheme _timeScheme;
- SpaceScheme _spaceScheme;
+ bool _FECalculation;
/** boolean used to specify that a well balanced correction should be used */
bool _wellBalancedCorrection;
+ TimeScheme _timeScheme;
//Linear solver and petsc
KSP _ksp;
bool _isStationary;
bool _initialDataSet;
bool _initializedMemory;
+ bool _restartWithNewTimeScheme;
+ bool _restartWithNewFileName;
double _timeMax,_time;
int _maxNbOfTimeStep,_nbTimeStep;
double _precision;
using namespace std;
+//! enumeration SpaceScheme
+/*! Several numerical schemes are available */
+enum SpaceScheme
+{
+ upwind,/**< classical full upwinding scheme (first order in space) */
+ centered,/**< centered scheme (second order in space) */
+ pressureCorrection,/**< include a pressure correction in the upwind scheme to increase precision at low Mach numbers */
+ lowMach,/**< include an upwinding proportional to the Mach numer scheme to increase precision at low Mach numbers */
+ staggered,/**< scheme inspired by staggered discretisations */
+};
+
+//! enumeration pressureEstimate
+/*! the pressure estimate needed to fit physical parameters */
+enum pressureEstimate
+{
+ around1bar300K,/**< pressure is around 1 bar and temperature around 300K (for TransportEquation, SinglePhase and IsothermalTwoFluid) or 373 K (saturation for DriftModel and FiveEqsTwoFluid) */
+ around155bars600K/**< pressure is around 155 bars and temperature around 618 K (saturation) */
+};
+
+//! enumeration phaseType
+/*! The fluid type can be Gas or water */
+enum phaseType
+{
+ Liquid,/**< Fluid considered is water */
+ Gas/**< Fluid considered is Gas */
+};
+
//! enumeration NonLinearFormulation
/*! the formulation used to compute the non viscous fluxes */
enum NonLinearFormulation
reducedRoe,/**< compacted formulation of Roe scheme without computation of the fluxes */
};
+//! enumeration BoundaryType
+/*! Boundary condition type */
+enum BoundaryType {Wall, InnerWall, Inlet, InletPressure, InletRotationVelocity, InletEnthalpy, Outlet, Neumann, NoTypeSpecified};
+/** \struct LimitField
+ * \brief value of some fields on the boundary */
+struct LimitField{
+ LimitField(){bcType=NoTypeSpecified; p=0; v_x=vector<double> (0,0); v_y=vector<double> (0,0); v_z=vector<double> (0,0); T=0; h=0; alpha=0; conc=0;}
+ LimitField(BoundaryType _bcType, double _p, vector<double> _v_x, vector<double> _v_y, vector<double> _v_z,
+ double _T, double _h, double _alpha, double _conc){
+ bcType=_bcType; p=_p; v_x=_v_x; v_y=_v_y; v_z=_v_z; T=_T; h=_h; alpha=_alpha; conc=_conc;
+ }
+
+ BoundaryType bcType;
+ double p;//For outlet (fluid models)
+ vector<double> v_x; vector<double> v_y; vector<double> v_z;//For wall and inlet (fluid models)
+ double T; //for wall and inlet (DriftModel and FiveEqsTwoFluid) and for Dirichlet (DiffusionEquation)
+ double h; //for inlet (TransportEquation)
+ double alpha; //For inlet (IsothermalTwoFluid and FiveEqsTwoFluid)
+ double conc;//For inlet (DriftModel)
+};
+
class ProblemFluid: public ProblemCoreFlows
{
* */
virtual void validateTimeStep();
+ /* Boundary conditions */
+ /** \fn setNeumannBoundaryCondition
+ * \brief adds a new boundary condition of type Neumann
+ * \details
+ * \param [in] string the name of the boundary
+ * \param [out] void
+ * */
+ void setNeumannBoundaryCondition(string groupName){
+ _limitField[groupName]=LimitField(Neumann,-1,vector<double>(_Ndim,0),vector<double>(_Ndim,0),vector<double>(_Ndim,0),-1,-1,-1,-1);
+ };
+
/** \fn setOutletBoundaryCondition
* \brief Adds a new boundary condition of type Outlet
* \details
_limitField[groupName]=LimitField(Outlet,referencePressure,vector<double>(_nbPhases,0),vector<double>(_nbPhases,0),vector<double>(_nbPhases,0),-1,-1,-1,-1);
};
+ /** \fn setBoundaryFields
+ * \brief met à jour _limitField ( le type de condition limite )
+ * \details
+ * \param [in] string
+ * \param [out] void
+ * */
+ void setBoundaryFields(map<string, LimitField> boundaryFields){
+ _limitField = boundaryFields;
+ };
+
/** \fn setViscosity
* \brief sets the vector of viscosity coefficients
* @param viscosite is a vector of size equal to the number of phases and containing the viscosity of each phase
_usePrimitiveVarsInNewton=usePrimitiveVarsInNewton;
}
+ /** \fn getSpaceScheme
+ * \brief returns the space scheme name
+ * \param [in] void
+ * \param [out] enum SpaceScheme(upwind, centred, pressureCorrection, pressureCorrection, staggered)
+ * */
+ SpaceScheme getSpaceScheme();
+
+ /** \fn setNumericalScheme
+ * \brief sets the numerical method (upwind vs centered and explicit vs implicit)
+ * \details
+ * \param [in] SpaceScheme
+ * \param [in] TimeScheme
+ * \param [out] void
+ * */
+ void setNumericalScheme(SpaceScheme scheme, TimeScheme method=Explicit);
+
//données initiales
/*
virtual vector<string> getInputFieldsNames()=0 ;//Renvoie les noms des champs dont le problème a besoin (données initiales)
Field _UU;
/** Field of interfacial states of the VFRoe scheme **/
Field _UUstar, _VVstar;
+
+ SpaceScheme _spaceScheme;
/** the formulation used to compute the non viscous fluxes **/
NonLinearFormulation _nonLinearFormulation;
+ map<string, LimitField> _limitField;
+
/** boolean used to specify that an entropic correction should be used **/
bool _entropicCorrection;
/** Vector containing the eigenvalue jumps for the entropic correction **/
* \param [in] bool : There are two possible equations of state for the fluid
* */
SinglePhase(phaseType fluid, pressureEstimate pEstimate,int dim,bool useDellacherieEOS=false);
+
+ /** \fn setViscosity
+ * \brief sets the viscosity
+ * @param viscosite : value of the dynamic viscosity
+ * * */
+ void setViscosityConstant( double viscosite ){
+ _fluides[0]->setViscosity(viscosite);
+ };
+
//! system initialisation
void initialize();
double getReferencePressure() { return _Pref; };
double getReferenceTemperature() { return _Tref; };
+
+ //get output fields for postprocessing or coupling
+ vector<string> getOutputFieldsNames() ;//liste tous les champs que peut fournir le code pour le postraitement
+ Field& getOutputField(const string& nameField );//Renvoie un champs pour le postraitement
+ Field& getPressureField();
+ Field& getVelocityField();
+ Field& getVelocityXField();
+ Field& getTemperatureField();
+ Field& getDensityField();
+ Field& getMomentumField();
+ Field& getTotalEnergyField();
+ Field& getEnthalpyField();
protected :
- Field _Vitesse;
double _drho_sur_dp, _drho_sur_dT;//derivatives of the density rho wrt cv, p, T
double _drhoE_sur_dp, _drhoE_sur_dT;//derivatives of the total energy rho E wrt cv, p, T
bool _useDellacherieEOS;
*/
void getDensityDerivatives( double pressure, double temperature, double v2);
-};
+ bool _saveAllFields;
+ Field _Enthalpy, _Pressure, _Density, _Temperature, _Momentum, _TotalEnergy, _Vitesse, _VitesseX, _VitesseY, _VitesseZ;
+
+ };
#endif /* SINGLEPHASE_HXX_*/
* \date June 2019
* \brief Stationary heat diffusion equation solved with either finite elements or finite volume method.
* -\lambda\Delta T=\Phi + \lambda_{sf} (T_{fluid}-T)
+ * Dirichlet (imposed temperature) or Neumann (imposed normal flux) boundary conditions
* */
//============================================================================
#define StationaryDiffusionEquation_HXX_
#include "ProblemCoreFlows.hxx"
-#include "Node.hxx"
+
+/* for the laplacian spectrum */
+#include <slepceps.h>
+#include <slepcsvd.h>
using namespace std;
+//! enumeration BoundaryType
+/*! Boundary condition type */
+enum BoundaryTypeStationaryDiffusion { NeumannStationaryDiffusion, DirichletStationaryDiffusion, NoneBCStationaryDiffusion};
+
+/** \struct LimitField
+ * \brief value of some fields on the boundary */
+struct LimitFieldStationaryDiffusion{
+ LimitFieldStationaryDiffusion(){bcType=NoneBCStationaryDiffusion; T=0; normalFlux=0;}
+ LimitFieldStationaryDiffusion(BoundaryTypeStationaryDiffusion _bcType, double _T, double _normalFlux){
+ bcType=_bcType; T=_T; normalFlux=_normalFlux;
+ }
+
+ BoundaryTypeStationaryDiffusion bcType;
+ double T; //for Dirichlet
+ double normalFlux; //for Neumann
+};
+
class StationaryDiffusionEquation
{
/** \fn StationaryDiffusionEquation
* \brief Constructor for the temperature diffusion in a solid
* \param [in] int : space dimension
- * \param [in] double : solid density
- * \param [in] double : solid specific heat at constant pressure
* \param [in] double : solid conductivity
* */
StationaryDiffusionEquation( int dim,bool FECalculation=true,double lambda=1);
void setMesh(const Mesh &M);
- void setLinearSolver(linearSolver kspType, preconditioner pcType);
void setFileName(string fileName){
_fileName = fileName;
}
bool solveStationaryProblem();
Field getOutputTemperatureField();
+ //Linear system and spectrum
+ void setLinearSolver(linearSolver kspType, preconditioner pcType);
+ double getConditionNumber(bool isSingular=false, double tol=1e-6) const;
+ std::vector< double > getEigenvalues (int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6) const;
+ std::vector< Vector > getEigenvectors(int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6) const;
+ Field getEigenvectorsField(int nev, EPSWhich which=EPS_SMALLEST_MAGNITUDE, double tol=1e-6) const;
+
//Gestion du calcul
void initialize();
void terminate();//vide la mémoire et enregistre le résultat final
void save();
/* Boundary conditions */
- void setBoundaryFields(map<string, LimitField> boundaryFields){
+ void setBoundaryFields(map<string, LimitFieldStationaryDiffusion> boundaryFields){
_limitField = boundaryFields;
};
/** \fn setDirichletBoundaryCondition
* \param [out] void
* */
void setDirichletBoundaryCondition(string groupName,double Temperature){
- _limitField[groupName]=LimitField(Dirichlet,-1, vector<double>(_Ndim,0),vector<double>(_Ndim,0),
- vector<double>(_Ndim,0),Temperature,-1,-1,-1);
+ _limitField[groupName]=LimitFieldStationaryDiffusion(DirichletStationaryDiffusion,Temperature,-1);
};
/** \fn setNeumannBoundaryCondition
* \param [in] string : the name of the boundary
* \param [out] void
* */
- void setNeumannBoundaryCondition(string groupName){
- _limitField[groupName]=LimitField(Neumann,-1, vector<double>(0),vector<double>(0),
- vector<double>(0),-1,-1,-1,-1);
+ void setNeumannBoundaryCondition(string groupName, double normalFlux=0){
+ _limitField[groupName]=LimitFieldStationaryDiffusion(NeumannStationaryDiffusion,-1, normalFlux);
};
void setDirichletValues(map< int, double> dirichletBoundaryValues);
+ void setNeumannValues (map< int, double> neumannBoundaryValues);
void setConductivity(double conductivite){
_conductivity=conductivite;
double _MaxIterLinearSolver;//nombre maximum d'iteration gmres obtenu au cours par les resolution de systemes lineaires au cours d'un pas de tmeps
bool _conditionNumber;//computes an estimate of the condition number
- map<string, LimitField> _limitField;
+ map<string, LimitFieldStationaryDiffusion> _limitField;
bool _onlyNeumannBC;//if true then the linear system is singular and should be solved up to a constant vector
bool _diffusionMatrixSet;
Vector gradientNodal(Matrix M, vector< double > v);//gradient of nodal shape functions
double computeDiffusionMatrixFE(bool & stop);
int fact(int n);
- int unknownNodeIndex(int globalIndex, std::vector< int > dirichletNodes);
- int globalNodeIndex(int unknownIndex, std::vector< int > dirichletNodes);
+ int unknownNodeIndex(int globalIndex, std::vector< int > dirichletNodes) const;
+ int globalNodeIndex(int unknownIndex, std::vector< int > dirichletNodes) const;
- /********* Possibility to set a boundary field as Dirichlet boundary condition *********/
+ /********* Possibility to set a boundary field as DirichletNeumann boundary condition *********/
bool _dirichletValuesSet;
+ bool _neumannValuesSet;
std::map< int, double> _dirichletBoundaryValues;
+ std::map< int, double> _neumannBoundaryValues;
};
#endif /* StationaryDiffusionEquation_HXX_ */
using namespace std;
+
+//! enumeration phase
+/*! The fluid type can be LiquidPhase or water */
+enum phase
+{
+ LiquidPhase,/**< Fluid considered is GasPhase */
+ GasPhase/**< Fluid considered is Gas */
+};
+
+//! enumeration pressureEstimate
+/*! the pressure estimate needed to fit physical parameters */
+enum pressureMagnitude
+{
+ around1bar300KTransport,/**< pressure is around 1 bar and temperature around 300K (for TransportEquation, SinglePhase and IsothermalTwoFluid) or 373 K (saturation for DriftModel and FiveEqsTwoFluid) */
+ around155bars600KTransport/**< pressure is around 155 bars and temperature around 618 K (saturation) */
+};
+
+//! enumeration BoundaryType
+/*! Boundary condition type */
+enum BoundaryTypeTransport {InletTransport, OutletTransport, NeumannTransport, DirichletTransport, NoneBCTransport};//Actually Inlet=Dirichlet and Outlet=Neumann
+
+/** \struct LimitField
+ * \brief value of some fields on the boundary */
+struct LimitFieldTransport{
+ LimitFieldTransport(){bcType=NoneBCTransport; T=0; h=0; flux=0; }
+ LimitFieldTransport(BoundaryTypeTransport _bcType, double _T, double _h,double _flux ){
+ bcType=_bcType; T=_T; h=_h; flux=_flux;
+ }
+
+ BoundaryTypeTransport bcType;
+ double T; //for inlet or Dirichlet
+ double h; //for inlet or Dirichlet
+ double flux; //for Neumann or outlet
+};
+
class TransportEquation: public ProblemCoreFlows
{
public :
/** \fn TransportEquation
* \brief Constructor for the enthalpy transport in a fluid
- * \param [in] phaseType : \ref Liquid or \ref Gas
- * \param [in] pressureEstimate : \ref around1bar or \ref around155bars
+ * \param [in] phase : \ref Liquid or \ref Gas
+ * \param [in] pressureMagnitude : \ref around1bar or \ref around155bars
* \param [in] vector<double> : fluid velocity (assumed constant)
* */
- TransportEquation(phaseType fluid, pressureEstimate pEstimate,vector<double> vitesseTransport);
+ TransportEquation(phase fluid, pressureMagnitude pEstimate,vector<double> vitesseTransport);
//Gestion du calcul
virtual void initialize();
virtual void save();
virtual void validateTimeStep();
+ /* Boundary conditions */
/** \fn setIntletBoundaryCondition
* \brief adds a new boundary condition of type Inlet
* \details
* \param [out] void
* */
void setInletBoundaryCondition(string groupName,double enthalpy){
- _limitField[groupName]=LimitField(Inlet,-1,vector<double>(_Ndim,0),vector<double>(_Ndim,0),vector<double>(_Ndim,0),-1,enthalpy,-1,-1);
+ _limitField[groupName]=LimitFieldTransport(InletTransport,-1,enthalpy,-1);
+ };
+
+ /** \fn setNeumannBoundaryCondition
+ * \brief adds a new boundary condition of type Neumann
+ * \details
+ * \param [in] string the name of the boundary
+ * \param [out] void
+ * */
+ void setNeumannBoundaryCondition(string groupName, double flux=0){
+ _limitField[groupName]=LimitFieldTransport(NeumannTransport,-1,flux,-1);
+ };
+
+ /** \fn setBoundaryFields
+ * \brief met à jour _limitField ( le type de condition limite )
+ * \details
+ * \param [in] string
+ * \param [out] void
+ * */
+ void setBoundaryFields(map<string, LimitFieldTransport> boundaryFields){
+ _limitField = boundaryFields;
};
- /*Physical parameters*/
- Field& getFluidTemperatureField(){
- return _TT;
- }
+ /*Physical parameters*/
void setLiqSatEnthalpy(double hsatl){
_hsatl=hsatl;
};
void setTransportVelocity(Vector v){
_vitesseTransport=v;
};
+
+ //get output fields for postprocessing or coupling
+ vector<string> getOutputFieldsNames() ;//liste tous les champs que peut fournir le code pour le postraitement
+ Field& getOutputField(const string& nameField );//Renvoie un champs pour le postraitement
+
+ Field& getFluidTemperatureField(){
+ return _TT;
+ }
+
+ Field& getEnthalpyField(){
+ return _VV;
+ }
+
+ /** \fn getTimeScheme
+ * \brief returns the time scheme name
+ * \param [in] void
+ * \param [out] enum TimeScheme (explicit or implicit)
+ * */
+ TimeScheme getTimeScheme();
+
protected :
double computeTransportMatrix();
double computeRHS();
bool _transportMatrixSet;
Vec _Hn, _deltaH, _Hk, _Hkm1, _b0;
double _dt_transport, _dt_src;
+
+ map<string, LimitFieldTransport> _limitField;
};
#endif /* TransportEquation_HXX_ */
INCLUDE_DIRECTORIES(
- ${PETSC_INCLUDES}
- ${CDMATH_INCLUDES}
- ${CDMATH_INCLUDES}/med #
- ${CDMATH_INCLUDES}/medcoupling #
- ${CoreFlows_SRC}/inc
+ ${CoreFlows_INCLUDES} #
)
SET(src_models_CXX
)
ADD_LIBRARY(CoreFlows SHARED ${src_models_CXX})
-target_link_libraries(CoreFlows ${CDMATH_LIBRARIES} ${PETSC_LIBRARIES})
+target_link_libraries(CoreFlows ${CDMATH_LIBRARIES} ${PETSC_LIBRARIES} ${SLEPC_LIBRARIES})
INSTALL(TARGETS CoreFlows DESTINATION lib)
cout<<"!!!!! Warning : all nodes are boundary nodes !!!!!"<<endl;
for(int i=0; i<_NboundaryNodes; i++)
- if(_limitField[(_mesh.getNode(_boundaryNodeIds[i])).getGroupName()].bcType==Dirichlet)
+ if(_limitField[(_mesh.getNode(_boundaryNodeIds[i])).getGroupName()].bcType==DirichletDiffusion)
_dirichletNodeIds.push_back(_boundaryNodeIds[i]);
_NdirichletNodes=_dirichletNodeIds.size();
_NunknownNodes=_Nnodes - _NdirichletNodes;
}
nameOfGroup = Fj.getGroupName();
- if (_limitField[nameOfGroup].bcType==Neumann){//Nothing to do
+ if (_limitField[nameOfGroup].bcType==NeumannDiffusion){
+ VecSetValue(_b,idm, -dn*inv_dxi*_limitField[nameOfGroup].normalFlux, ADD_VALUES);
}
- else if(_limitField[nameOfGroup].bcType==Dirichlet){
+ else if(_limitField[nameOfGroup].bcType==DirichletDiffusion){
barycenterDistance=Cell1.getBarryCenter().distance(Fj.getBarryCenter());
MatSetValue(_A,idm,idm,dn*inv_dxi/barycenterDistance , ADD_VALUES);
VecSetValue(_b,idm, dn*inv_dxi/barycenterDistance*_limitField[nameOfGroup].T, ADD_VALUES);
stop=true ;
cout<<"!!!!!!!!!!!!!!!!! Error DiffusionEquation::computeDiffusionMatrixFV !!!!!!!!!!"<<endl;
cout<<"Boundary condition not accepted for boundary named "<<nameOfGroup<< ", _limitField[nameOfGroup].bcType= "<<_limitField[nameOfGroup].bcType<<endl;
- cout<<"Accepted boundary conditions are Neumann "<<Neumann<< " and Dirichlet "<<Dirichlet<<endl;
+ cout<<"Accepted boundary conditions are NeumannDiffusion "<<NeumannDiffusion<< " and DirichletDiffusion "<<DirichletDiffusion<<endl;
*_runLogFile<<"Boundary condition not accepted for boundary named "<<nameOfGroup<< ", _limitField[nameOfGroup].bcType= "<<_limitField[nameOfGroup].bcType<<endl;
throw CdmathException("Boundary condition not accepted");
}
_VV.setTime(_time,_nbTimeStep);
// create mesh and component info
- if (_nbTimeStep ==0){
+ if (_nbTimeStep ==0 || _restartWithNewFileName){
+ if (_restartWithNewFileName)
+ _restartWithNewFileName=false;
string suppress ="rm -rf "+resultFile+"_*";
system(suppress.c_str());//Nettoyage des précédents calculs identiques
MatDestroy(&_A);
}
+vector<string> DiffusionEquation::getOutputFieldsNames()
+{
+ vector<string> result(2);
+
+ result[0]="FluidTemperature";
+ result[1]="RodTemperature";
+
+ return result;
+}
+
+Field& DiffusionEquation::getOutputField(const string& nameField )
+{
+ if(nameField=="FluidTemperature" || nameField=="FLUIDTEMPERATURE" || nameField=="TemperatureFluide" || nameField=="TEMPERATUREFLUIDE" )
+ return getFluidTemperatureField();
+ else if(nameField=="RodTemperature" || nameField=="RODTEMPERATURE" || nameField=="TEMPERATURECOMBUSTIBLE" || nameField=="TemperatureCombustible" )
+ return getRodTemperatureField();
+ else
+ {
+ cout<<"Error : Field name "<< nameField << " does not exist, call getOutputFieldsNames first" << endl;
+ throw CdmathException("DiffusionEquation::getOutputField error : Unknown Field name");
+ }
+}
+
bool DriftModel::iterateTimeStep(bool &converged)
{
if(_timeScheme == Explicit || !_usePrimitiveVarsInNewton)
- ProblemFluid::iterateTimeStep(converged);
+ return ProblemFluid::iterateTimeStep(converged);
else
{
bool stop=false;
}
_VV.setTime(_time,_nbTimeStep);
// create mesh and component info
- if (_nbTimeStep ==0){
+ if (_nbTimeStep ==0 || _restartWithNewFileName){
+ if (_restartWithNewFileName)
+ _restartWithNewFileName=false;
string suppress_previous_runs ="rm -rf *"+_fileName+"_*";
system(suppress_previous_runs.c_str());//Nettoyage des précédents calculs identiques
_Vitesse(i,j)=0;
}
_Vitesse.setTime(_time,_nbTimeStep);
- if (_nbTimeStep ==0){
+ if (_nbTimeStep ==0 || _restartWithNewFileName){
_Vitesse.setInfoOnComponent(0,"Velocity_x_(m/s)");
_Vitesse.setInfoOnComponent(1,"Velocity_y_(m/s)");
_Vitesse.setInfoOnComponent(2,"Velocity_z_(m/s)");
if(_Ndim>2)
_VitesseZ.setTime(_time,_nbTimeStep);
}
- if (_nbTimeStep ==0){
+ if (_nbTimeStep ==0 || _restartWithNewFileName){
switch(_saveFormat)
{
case VTK :
}
}
}
+
+ if (_restartWithNewFileName)
+ _restartWithNewFileName=false;
}
void DriftModel::testConservation()
}
_VV.setTime(_time,_nbTimeStep+1);
- if (_nbTimeStep ==0){
+ if (_nbTimeStep ==0 || _restartWithNewFileName){
string prim_suppress ="rm -rf "+prim+"_*";
string cons_suppress ="rm -rf "+cons+"_*";
system(prim_suppress.c_str());//Nettoyage des précédents calculs identiques
}
_Vitesse1.setTime(_time,_nbTimeStep);
_Vitesse2.setTime(_time,_nbTimeStep);
- if (_nbTimeStep ==0){
+ if (_nbTimeStep ==0 || _restartWithNewFileName){
_Vitesse1.setInfoOnComponent(0,"Velocity_x_(m/s)");
_Vitesse1.setInfoOnComponent(1,"Velocity_y_(m/s)");
_Vitesse1.setInfoOnComponent(2,"Velocity_z_(m/s)");
}
}
}
+
+ if (_restartWithNewFileName)
+ _restartWithNewFileName=false;
}
_UU.setTime(_time,_nbTimeStep);
}
_VV.setTime(_time,_nbTimeStep);
- if (_nbTimeStep ==0){
+ if (_nbTimeStep ==0 || _restartWithNewFileName){
string prim_suppress ="rm -rf "+prim+"_*";
string cons_suppress ="rm -rf "+cons+"_*";
system(prim_suppress.c_str());//Nettoyage des précédents calculs identiques
}
_Vitesse1.setTime(_time,_nbTimeStep);
_Vitesse2.setTime(_time,_nbTimeStep);
- if (_nbTimeStep ==0){
+ if (_nbTimeStep ==0 || _restartWithNewFileName){
_Vitesse1.setInfoOnComponent(0,"Velocity_x_(m/s)");
_Vitesse1.setInfoOnComponent(1,"Velocity_y_(m/s)");
_Vitesse1.setInfoOnComponent(2,"Velocity_z_(m/s)");
}
}
}
+
+ if (_restartWithNewFileName)
+ _restartWithNewFileName=false;
}
--- /dev/null
+#include "LinearElasticityModel.hxx"
+#include "SparseMatrixPetsc.hxx"
+#include "Node.hxx"
+#include "math.h"
+#include <algorithm>
+#include <fstream>
+#include <sstream>
+
+using namespace std;
+
+int LinearElasticityModel::fact(int n)
+{
+ return (n == 1 || n == 0) ? 1 : fact(n - 1) * n;
+}
+int LinearElasticityModel::unknownNodeIndex(int globalIndex, std::vector< int > dirichletNodes)
+{//assumes Dirichlet node numbering is strictly increasing
+ int j=0;//indice de parcours des noeuds frontière avec CL Dirichlet
+ int boundarySize=dirichletNodes.size();
+ while(j<boundarySize and dirichletNodes[j]<globalIndex)
+ j++;
+ if(j==boundarySize)
+ return globalIndex-boundarySize;
+ else if (dirichletNodes[j]>globalIndex)
+ return globalIndex-j;
+ else
+ throw CdmathException("LinearElasticityModel::unknownNodeIndex : Error : node is a Dirichlet boundary node");
+}
+
+int LinearElasticityModel::globalNodeIndex(int unknownNodeIndex, std::vector< int > dirichletNodes)
+{//assumes Dirichlet boundary node numbering is strictly increasing
+ int boundarySize=dirichletNodes.size();
+ /* trivial case where all boundary nodes are Neumann BC */
+ if(boundarySize==0)
+ return unknownNodeIndex;
+
+ double unknownNodeMax=-1;//max unknown node number in the interval between jth and (j+1)th Dirichlet boundary nodes
+ int j=0;//indice de parcours des noeuds frontière
+ //On cherche l'intervale [j,j+1] qui contient le noeud de numéro interieur unknownNodeIndex
+ while(j+1<boundarySize and unknownNodeMax<unknownNodeIndex)
+ {
+ unknownNodeMax += dirichletNodes[j+1]-dirichletNodes[j]-1;
+ j++;
+ }
+
+ if(j+1==boundarySize)
+ return unknownNodeIndex+boundarySize;
+ else //unknownNodeMax>=unknownNodeIndex) hence our node global number is between dirichletNodes[j-1] and dirichletNodes[j]
+ return unknownNodeIndex - unknownNodeMax + dirichletNodes[j]-1;
+}
+
+LinearElasticityModel::LinearElasticityModel(int dim, bool FECalculation, double rho, double lambda, double mu){
+ PetscBool petscInitialized;
+ PetscInitialized(&petscInitialized);
+ if(!petscInitialized)
+ PetscInitialize(NULL,NULL,0,0);
+
+ if(lambda < 0.)
+ {
+ std::cout<<"First Lamé coefficient="<<lambda<<endl;
+ throw CdmathException("Error : First Lamé coefficient lambda cannot be negative");
+ }
+ if(2*mu+dim*lambda < 0.)
+ {
+ std::cout<<"First Lamé coefficient="<<lambda<<", second Lamé coefficient="<<mu<<", 2*mu+dim*lambda= "<<2*mu+dim*lambda<<endl;
+ throw CdmathException("Error : 2*mu+dim*lambda cannot be negative");
+ }
+ if(dim<=0)
+ {
+ std::cout<<"space dimension="<<dim<<endl;
+ throw CdmathException("Error : parameter dim cannot be negative");
+ }
+
+ _FECalculation=FECalculation;
+ _onlyNeumannBC=false;
+
+ _Ndim=dim;
+ _nVar=dim;
+ _initializedMemory=false;
+
+ //Mesh data
+ _neibMaxNbCells=0;
+ _meshSet=false;
+ _neibMaxNbNodes=0;
+
+ //Boundary conditions
+ _boundaryNodeIds=std::vector< int >(0);
+ _dirichletNodeIds=std::vector< int >(0);
+ _NboundaryNodes=0;
+ _NdirichletNodes=0;
+ _NunknownNodes=0;
+ _dirichletValuesSet=false;
+
+ //Linear solver data
+ _precision=1.e-6;
+ _precision_Newton=_precision;
+ _MaxIterLinearSolver=0;//During several newton iterations, stores the max petssc interations
+ _maxPetscIts=50;
+ int _PetscIts=0;//the number of iterations of the linear solver
+ _ksptype = (char*)&KSPGMRES;
+ _pctype = (char*)&PCLU;
+ _conditionNumber=false;
+ _erreur_rel= 0;
+
+ //parameters for monitoring simulation
+ _verbose = false;
+ _system = false;
+ _runLogFile=new ofstream;
+
+ //result save parameters
+ _fileName = "LinearElasticityProblem";
+ char result[ PATH_MAX ];//extracting current directory
+ getcwd(result, PATH_MAX );
+ _path=string( result );
+ _saveFormat=VTK;
+ _computationCompletedSuccessfully=false;
+
+ //heat transfer parameters
+ _lambda= lambda;
+ _mu = mu;
+ _rho = rho;
+ _densityFieldSet=false;
+}
+
+void LinearElasticityModel::initialize()
+{
+ _runLogFile->open((_fileName+".log").c_str(), ios::out | ios::trunc);;//for creation of a log file to save the history of the simulation
+
+ if(!_meshSet)
+ throw CdmathException("LinearElasticityModel::initialize() set mesh first");
+ else
+ {
+ cout<<"!!!! Initialisation of the computation of the elastic deformation of a solid using ";
+ *_runLogFile<<"!!!!! Initialisation of the computation of the elastic deformation of a solid using ";
+ if(!_FECalculation)
+ {
+ cout<< "Finite volumes method"<<endl<<endl;
+ *_runLogFile<< "Finite volumes method"<<endl<<endl;
+ }
+ else
+ {
+ cout<< "Finite elements method"<<endl<<endl;
+ *_runLogFile<< "Finite elements method"<<endl<<endl;
+ }
+ }
+ /**************** Field creation *********************/
+
+ if(!_densityFieldSet){
+ if(_FECalculation){
+ _densityField=Field("Density",NODES,_mesh,1);
+ for(int i =0; i<_Nnodes; i++)
+ _densityField(i) = _rho;
+ }
+ else{
+ _densityField=Field("Density",CELLS,_mesh,1);
+ for(int i =0; i<_Nmailles; i++)
+ _densityField(i) = _rho;
+ }
+ _densityFieldSet=true;
+ }
+
+ /* Détection des noeuds frontière avec une condition limite de Dirichlet */
+ if(_FECalculation)
+ {
+ if(_NboundaryNodes==_Nnodes)
+ cout<<"!!!!! Warning : all nodes are boundary nodes !!!!!"<<endl<<endl;
+
+ for(int i=0; i<_NboundaryNodes; i++)
+ {
+ std::map<int,double>::iterator it=_dirichletBoundaryValues.find(_boundaryNodeIds[i]);
+ if( it != _dirichletBoundaryValues.end() )
+ _dirichletNodeIds.push_back(_boundaryNodeIds[i]);
+ else if( _mesh.getNode(_boundaryNodeIds[i]).getGroupNames().size()==0 )
+ {
+ cout<<"!!! No boundary value set for boundary node" << _boundaryNodeIds[i]<< endl;
+ *_runLogFile<< "!!! No boundary value set for boundary node" << _boundaryNodeIds[i]<<endl;
+ _runLogFile->close();
+ throw CdmathException("Missing boundary value");
+ }
+ else if(_limitField[_mesh.getNode(_boundaryNodeIds[i]).getGroupName()].bcType==NoTypeSpecified)
+ {
+ cout<<"!!! No boundary condition set for boundary node " << _boundaryNodeIds[i]<< endl;
+ *_runLogFile<< "!!!No boundary condition set for boundary node " << _boundaryNodeIds[i]<<endl;
+ _runLogFile->close();
+ throw CdmathException("Missing boundary condition");
+ }
+ else if(_limitField[_mesh.getNode(_boundaryNodeIds[i]).getGroupName()].bcType==Dirichlet)
+ _dirichletNodeIds.push_back(_boundaryNodeIds[i]);
+ else if(_limitField[_mesh.getNode(_boundaryNodeIds[i]).getGroupName()].bcType!=Neumann)
+ {
+ cout<<"!!! Wrong boundary condition "<< _limitField[_mesh.getNode(_boundaryNodeIds[i]).getGroupName()].bcType<< " set for boundary node " << _boundaryNodeIds[i]<< endl;
+ cout<<"!!! Accepted boundary conditions are Dirichlet "<< Dirichlet <<" and Neumann "<< Neumann << endl;
+ *_runLogFile<< "Wrong boundary condition "<< _limitField[_mesh.getNode(_boundaryNodeIds[i]).getGroupName()].bcType<< " set for boundary node " << _boundaryNodeIds[i]<<endl;
+ *_runLogFile<< "Accepted boundary conditions are Dirichlet "<< Dirichlet <<" and Neumann "<< Neumann <<endl;
+ _runLogFile->close();
+ throw CdmathException("Wrong boundary condition");
+ }
+ }
+ _NdirichletNodes=_dirichletNodeIds.size();
+ _NunknownNodes=_Nnodes - _NdirichletNodes;
+ cout<<"Number of unknown nodes " << _NunknownNodes <<", Number of boundary nodes " << _NboundaryNodes<< ", Number of Dirichlet boundary nodes " << _NdirichletNodes <<endl<<endl;
+ *_runLogFile<<"Number of unknown nodes " << _NunknownNodes <<", Number of boundary nodes " << _NboundaryNodes<< ", Number of Dirichlet boundary nodes " << _NdirichletNodes <<endl<<endl;
+ }
+
+ //creation de la matrice
+ if(!_FECalculation)
+ MatCreateSeqAIJ(PETSC_COMM_SELF, _Nmailles*_nVar, _Nmailles*_nVar, (1+_neibMaxNbCells), PETSC_NULL, &_A);
+ else
+ MatCreateSeqAIJ(PETSC_COMM_SELF, _NunknownNodes*_nVar, _NunknownNodes*_nVar, (1+_neibMaxNbNodes), PETSC_NULL, &_A);
+
+ VecCreate(PETSC_COMM_SELF, &_displacments);
+
+ VecDuplicate(_displacements, &_b);//RHS of the linear system
+
+ //Linear solver
+ KSPCreate(PETSC_COMM_SELF, &_ksp);
+ KSPSetType(_ksp, _ksptype);
+ // if(_ksptype == KSPGMRES) KSPGMRESSetRestart(_ksp,10000);
+ KSPSetTolerances(_ksp,_precision,_precision,PETSC_DEFAULT,_maxPetscIts);
+ KSPGetPC(_ksp, &_pc);
+ PCSetType(_pc, _pctype);
+
+ //Checking whether all boundaries are Neumann boundaries
+ map<string, LimitField>::iterator it = _limitField.begin();
+ while(it != _limitField.end() and (it->second).bcType == Neumann)
+ it++;
+ _onlyNeumannBC = (it == _limitField.end() && _limitField.size()>0);
+ //If only Neumann BC, then matrix is singular and solution should be sought in space of mean zero vectors
+ if(_onlyNeumannBC)
+ {
+ std::cout<<"## Warning all boundary conditions are Neumann. System matrix is not invertible since constant vectors are in the kernel."<<std::endl;
+ std::cout<<"## As a consequence we seek a zero sum solution, and exact (LU and CHOLESKY) and incomplete factorisations (ILU and ICC) may fail."<<std::endl<<endl;
+ *_runLogFile<<"## Warning all boundary condition are Neumann. System matrix is not invertible since constant vectors are in the kernel."<<std::endl;
+ *_runLogFile<<"## As a consequence we seek a zero sum solution, and exact (LU and CHOLESKY) and incomplete factorisations (ILU and ICC) may fail."<<std::endl<<endl;
+
+ //Check that the matrix is symmetric
+ PetscBool isSymetric;
+ MatIsSymmetric(_A,_precision,&isSymetric);
+ if(!isSymetric)
+ {
+ cout<<"Singular matrix is not symmetric, tolerance= "<< _precision<<endl;
+ throw CdmathException("Singular matrix should be symmetric with kernel composed of constant vectors");
+ }
+ MatNullSpace nullsp;
+ MatNullSpaceCreate(PETSC_COMM_WORLD, PETSC_TRUE, 0, PETSC_NULL, &nullsp);
+ MatSetNullSpace(_A, nullsp);
+ MatSetTransposeNullSpace(_A, nullsp);
+ MatNullSpaceDestroy(&nullsp);
+ //PCFactorSetShiftType(_pc,MAT_SHIFT_NONZERO);
+ //PCFactorSetShiftAmount(_pc,1e-10);
+ }
+
+ _initializedMemory=true;
+
+}
+
+Vector LinearElasticityModel::gradientNodal(Matrix M, vector< double > values){
+ vector< Matrix > matrices(_Ndim);
+
+ for (int idim=0; idim<_Ndim;idim++){
+ matrices[idim]=M.deepCopy();
+ for (int jdim=0; jdim<_Ndim+1;jdim++)
+ matrices[idim](jdim,idim) = values[jdim] ;
+ }
+
+ Vector result(_Ndim);
+ for (int idim=0; idim<_Ndim;idim++)
+ result[idim] = matrices[idim].determinant();
+
+ return result;
+}
+
+double LinearElasticityModel::computeDiffusionMatrix(bool & stop)
+{
+ double result;
+
+ if(_FECalculation)
+ result=computeDiffusionMatrixFE(stop);
+ else
+ result=computeDiffusionMatrixFV(stop);
+
+ if(_verbose or _system)
+ MatView(_A,PETSC_VIEWER_STDOUT_SELF);
+
+ return result;
+}
+
+double LinearElasticityModel::computeDiffusionMatrixFE(bool & stop){
+ Cell Cj;
+ string nameOfGroup;
+ double dn;
+ MatZeroEntries(_A);
+ VecZeroEntries(_b);
+
+ Matrix M(_Ndim+1,_Ndim+1);//cell geometry matrix
+ std::vector< Vector > GradShapeFuncs(_Ndim+1);//shape functions of cell nodes
+ std::vector< int > nodeIds(_Ndim+1);//cell node Ids
+ std::vector< Node > nodes(_Ndim+1);//cell nodes
+ int i_int, j_int; //index of nodes j and k considered as unknown nodes
+ bool dirichletCell_treated;
+
+ std::vector< vector< double > > values(_Ndim+1,vector< double >(_Ndim+1,0));//values of shape functions on cell node
+ for (int idim=0; idim<_Ndim+1;idim++)
+ values[idim][idim]=1;
+
+ /* parameters for boundary treatment */
+ vector< Vector > valuesBorder(_Ndim+1);
+ Vector GradShapeFuncBorder(_Ndim+1);
+
+ for (int j=0; j<_Nmailles;j++)
+ {
+ Cj = _mesh.getCell(j);
+
+ for (int idim=0; idim<_Ndim+1;idim++){
+ nodeIds[idim]=Cj.getNodeId(idim);
+ nodes[idim]=_mesh.getNode(nodeIds[idim]);
+ for (int jdim=0; jdim<_Ndim;jdim++)
+ M(idim,jdim)=nodes[idim].getPoint()[jdim];
+ M(idim,_Ndim)=1;
+ }
+ for (int idim=0; idim<_Ndim+1;idim++)
+ GradShapeFuncs[idim]=gradientNodal(M,values[idim])/fact(_Ndim);
+
+ /* Loop on the edges of the cell */
+ for (int idim=0; idim<_Ndim+1;idim++)
+ {
+ if(find(_dirichletNodeIds.begin(),_dirichletNodeIds.end(),nodeIds[idim])==_dirichletNodeIds.end())//!_mesh.isBorderNode(nodeIds[idim])
+ {//First node of the edge is not Dirichlet node
+ i_int=unknownNodeIndex(nodeIds[idim], _dirichletNodeIds);//assumes Dirichlet boundary node numbering is strictly increasing
+ dirichletCell_treated=false;
+ for (int jdim=0; jdim<_Ndim+1;jdim++)
+ {
+ if(find(_dirichletNodeIds.begin(),_dirichletNodeIds.end(),nodeIds[jdim])==_dirichletNodeIds.end())//!_mesh.isBorderNode(nodeIds[jdim])
+ {//Second node of the edge is not Dirichlet node
+ j_int= unknownNodeIndex(nodeIds[jdim], _dirichletNodeIds);//assumes Dirichlet boundary node numbering is strictly increasing
+ MatSetValue(_A,i_int,j_int,_conductivity*(_DiffusionTensor*GradShapeFuncs[idim])*GradShapeFuncs[jdim]/Cj.getMeasure(), ADD_VALUES);
+ }
+ else if (!dirichletCell_treated)
+ {//Second node of the edge is a Dirichlet node
+ dirichletCell_treated=true;
+ for (int kdim=0; kdim<_Ndim+1;kdim++)
+ {
+ std::map<int,double>::iterator it=_dirichletBoundaryValues.find(nodeIds[kdim]);
+ if( it != _dirichletBoundaryValues.end() )
+ {
+ if( _dirichletValuesSet )//New way of storing BC
+ valuesBorder[kdim]=_dirichletBoundaryValues[it->second];
+ else //old way of storing BC
+ valuesBorder[kdim]=_limitField[_mesh.getNode(nodeIds[kdim]).getGroupName()].Displacements;
+ }
+ else
+ valuesBorder[kdim]=Vector(_Ndim);
+ }
+ GradShapeFuncBorder=gradientNodal(M,valuesBorder)/fact(_Ndim);
+ double coeff =-_conductivity*(_DiffusionTensor*GradShapeFuncBorder)*GradShapeFuncs[idim]/Cj.getMeasure();
+ VecSetValue(_b,i_int,coeff, ADD_VALUES);
+ }
+ }
+ }
+ }
+ }
+
+ MatAssemblyBegin(_A, MAT_FINAL_ASSEMBLY);
+ MatAssemblyEnd(_A, MAT_FINAL_ASSEMBLY);
+ VecAssemblyBegin(_b);
+ VecAssemblyEnd(_b);
+
+ stop=false ;
+
+ return INFINITY;
+}
+
+double LinearElasticityModel::computeDiffusionMatrixFV(bool & stop){
+ long nbFaces = _mesh.getNumberOfFaces();
+ Face Fj;
+ Cell Cell1,Cell2;
+ string nameOfGroup;
+ double inv_dxi, inv_dxj;
+ double barycenterDistance;
+ Vector normale(_Ndim);
+ double dn;
+ PetscInt idm, idn;
+ std::vector< int > idCells;
+ MatZeroEntries(_A);
+ VecZeroEntries(_b);
+
+ for (int j=0; j<nbFaces;j++){
+ Fj = _mesh.getFace(j);
+
+ // compute the normal vector corresponding to face j : from idCells[0] to idCells[1]
+ idCells = Fj.getCellsId();
+ Cell1 = _mesh.getCell(idCells[0]);
+ idm = idCells[0];
+ for(int l=0; l<Cell1.getNumberOfFaces(); l++){
+ if (j == Cell1.getFacesId()[l]){
+ for (int idim = 0; idim < _Ndim; ++idim)
+ normale[idim] = Cell1.getNormalVector(l,idim);
+ break;
+ }
+ }
+
+ //Compute velocity at the face Fj
+ dn=_conductivity*(_DiffusionTensor*normale)*normale;
+
+ // compute 1/dxi = volume of Ci/area of Fj
+ inv_dxi = Fj.getMeasure()/Cell1.getMeasure();
+
+ // If Fj is on the boundary
+ if (Fj.getNumberOfCells()==1) {
+ if(_verbose )
+ {
+ cout << "face numero " << j << " cellule frontiere " << idCells[0] << " ; vecteur normal=(";
+ for(int p=0; p<_Ndim; p++)
+ cout << normale[p] << ",";
+ cout << ") "<<endl;
+ }
+
+ std::map<int,double>::iterator it=_dirichletBoundaryValues.find(j);
+ if( it != _dirichletBoundaryValues.end() )
+ {
+ barycenterDistance=Cell1.getBarryCenter().distance(Fj.getBarryCenter());
+ MatSetValue(_A,idm,idm,dn*inv_dxi/barycenterDistance , ADD_VALUES);
+ VecSetValue(_b,idm, dn*inv_dxi/barycenterDistance*it->second, ADD_VALUES);
+ }
+ else
+ {
+ nameOfGroup = Fj.getGroupName();
+
+ if (_limitField[nameOfGroup].bcType==Neumann){//Nothing to do
+ }
+ else if(_limitField[nameOfGroup].bcType==Dirichlet){
+ barycenterDistance=Cell1.getBarryCenter().distance(Fj.getBarryCenter());
+ MatSetValue(_A,idm,idm,dn*inv_dxi/barycenterDistance , ADD_VALUES);
+ VecSetValue(_b,idm, dn*inv_dxi/barycenterDistance*_limitField[nameOfGroup].T, ADD_VALUES);
+ }
+ else {
+ stop=true ;
+ cout<<"!!!!!!!!!!!!!!! Error LinearElasticityModel::computeDiffusionMatrixFV !!!!!!!!!!"<<endl;
+ cout<<"!!!!!! Boundary condition not accepted for boundary named !!!!!!!!!!"<<nameOfGroup<< ", _limitField[nameOfGroup].bcType= "<<_limitField[nameOfGroup].bcType<<endl;
+ cout<<"Accepted boundary conditions are Neumann "<<Neumann<< " and Dirichlet "<<Dirichlet<<endl;
+ *_runLogFile<<"!!!!!! Boundary condition not accepted for boundary named !!!!!!!!!!"<<nameOfGroup<< ", _limitField[nameOfGroup].bcType= "<<_limitField[nameOfGroup].bcType<<endl;
+ _runLogFile->close();
+ throw CdmathException("Boundary condition not accepted");
+ }
+ }
+ // if Fj is inside the domain
+ } else if (Fj.getNumberOfCells()==2 ){
+ if(_verbose )
+ {
+ cout << "face numero " << j << " cellule gauche " << idCells[0] << " cellule droite " << idCells[1];
+ cout << " ; vecteur normal=(";
+ for(int p=0; p<_Ndim; p++)
+ cout << normale[p] << ",";
+ cout << ") "<<endl;
+ }
+ Cell2 = _mesh.getCell(idCells[1]);
+ idn = idCells[1];
+ if (_Ndim > 1)
+ inv_dxj = Fj.getMeasure()/Cell2.getMeasure();
+ else
+ inv_dxj = 1/Cell2.getMeasure();
+
+ barycenterDistance=Cell1.getBarryCenter().distance(Cell2.getBarryCenter());
+
+ MatSetValue(_A,idm,idm, dn*inv_dxi/barycenterDistance, ADD_VALUES);
+ MatSetValue(_A,idm,idn,-dn*inv_dxi/barycenterDistance, ADD_VALUES);
+ MatSetValue(_A,idn,idn, dn*inv_dxj/barycenterDistance, ADD_VALUES);
+ MatSetValue(_A,idn,idm,-dn*inv_dxj/barycenterDistance, ADD_VALUES);
+ }
+ else
+ {
+ *_runLogFile<<"LinearElasticityModel::computeDiffusionMatrixFV(): incompatible number of cells around a face"<<endl;
+ throw CdmathException("LinearElasticityModel::computeDiffusionMatrixFV(): incompatible number of cells around a face");
+ }
+ }
+
+ MatAssemblyBegin(_A, MAT_FINAL_ASSEMBLY);
+ MatAssemblyEnd(_A, MAT_FINAL_ASSEMBLY);
+ VecAssemblyBegin(_b);
+ VecAssemblyEnd(_b);
+
+ stop=false ;
+
+ return INFINITY;
+}
+
+double LinearElasticityModel::computeRHS(bool & stop)//Contribution of the PDE RHS to the linear systemm RHS (boundary conditions do contribute to the system RHS via the function computeStiffnessMatrix)
+{
+ VecAssemblyBegin(_b);
+
+ if(!_FECalculation)
+ for (int i=0; i<_Nmailles;i++)
+ for (int j=0; j<_Ndim;j++)
+ VecSetValue(_b,i*nVar+j,_gravity(j)*_densityField(i),ADD_VALUES);
+ else
+ {
+ Cell Ci;
+ std::vector< int > nodesId;
+ for (int i=0; i<_Nmailles;i++)
+ {
+ Ci=_mesh.getCell(i);
+ nodesId=Ci.getNodesId();
+ for (int j=0; j<nodesId.size();j++)
+ if(!_mesh.isBorderNode(nodesId[j]))
+ for (int k=0; k<_Ndim; k++)
+ VecSetValue(_b,unknownNodeIndex(nodesId[j], _dirichletNodeIds)*nVar+k, _gravity(k)*_densityField(j)*Ci.getMeasure()/(_Ndim+1),ADD_VALUES);
+ }
+ }
+
+ VecAssemblyEnd(_b);
+
+ if(_verbose or _system)
+ VecView(_b,PETSC_VIEWER_STDOUT_SELF);
+
+ stop=false ;
+ return INFINITY;
+}
+
+bool LinearElasticityModel::solveLinearSystem()
+{
+ bool resolutionOK;
+
+ //Only implicit scheme considered
+ MatAssemblyBegin(_A, MAT_FINAL_ASSEMBLY);
+ MatAssemblyEnd( _A, MAT_FINAL_ASSEMBLY);
+
+#if PETSC_VERSION_GREATER_3_5
+ KSPSetOperators(_ksp, _A, _A);
+#else
+ KSPSetOperators(_ksp, _A, _A,SAME_NONZERO_PATTERN);
+#endif
+
+ if(_conditionNumber)
+ KSPSetComputeEigenvalues(_ksp,PETSC_TRUE);
+ KSPSolve(_ksp, _b, displacements);
+
+ KSPConvergedReason reason;
+ KSPGetConvergedReason(_ksp,&reason);
+ KSPGetIterationNumber(_ksp, &_PetscIts);
+ double residu;
+ KSPGetResidualNorm(_ksp,&residu);
+ if (reason!=2 and reason!=3)
+ {
+ cout<<"!!!!!!!!!!!!! Erreur système linéaire : pas de convergence de Petsc."<<endl;
+ cout<<"!!!!!!!!!!!!! Itérations maximales "<<_maxPetscIts<<" atteintes, résidu="<<residu<<", précision demandée= "<<_precision<<endl;
+ cout<<"Solver used "<< _ksptype<<", preconditioner "<<_pctype<<", Final number of iteration= "<<_PetscIts<<endl;
+ *_runLogFile<<"!!!!!!!!!!!!! Erreur système linéaire : pas de convergence de Petsc."<<endl;
+ *_runLogFile<<"!!!!!!!!!!!!! Itérations maximales "<<_maxPetscIts<<" atteintes, résidu="<<residu<<", précision demandée= "<<_precision<<endl;
+ *_runLogFile<<"Solver used "<< _ksptype<<", preconditioner "<<_pctype<<", Final number of iteration= "<<_PetscIts<<endl;
+ _runLogFile->close();
+
+ resolutionOK = false;
+ }
+ else{
+ if( _MaxIterLinearSolver < _PetscIts)
+ _MaxIterLinearSolver = _PetscIts;
+ cout<<"## Système linéaire résolu en "<<_PetscIts<<" itérations par le solveur "<< _ksptype<<" et le preconditioneur "<<_pctype<<", précision demandée= "<<_precision<<endl<<endl;
+ *_runLogFile<<"## Système linéaire résolu en "<<_PetscIts<<" itérations par le solveur "<< _ksptype<<" et le preconditioneur "<<_pctype<<", précision demandée= "<<_precision<<endl<<endl;
+
+ resolutionOK = true;
+ }
+
+ return resolutionOK;
+}
+
+void LinearElasticityModel::setMesh(const Mesh &M)
+{
+ if(_Ndim != M.getSpaceDimension() or _Ndim!=M.getMeshDimension())//for the moment we must have space dim=mesh dim
+ {
+ cout<< "Problem : dimension defined is "<<_Ndim<< " but mesh dimension= "<<M.getMeshDimension()<<", and space dimension is "<<M.getSpaceDimension()<<endl;
+ *_runLogFile<< "Problem : dim = "<<_Ndim<< " but mesh dim= "<<M.getMeshDimension()<<", mesh space dim= "<<M.getSpaceDimension()<<endl;
+ *_runLogFile<<"LinearElasticityModel::setMesh: mesh has incorrect dimension"<<endl;
+ _runLogFile->close();
+ throw CdmathException("LinearElasticityModel::setMesh: mesh has incorrect dimension");
+ }
+
+ _mesh=M;
+ _Nmailles = _mesh.getNumberOfCells();
+ _Nnodes = _mesh.getNumberOfNodes();
+
+ cout<<"Mesh has "<< _Nmailles << " cells and " << _Nnodes << " nodes"<<endl<<endl;;
+ *_runLogFile<<"Mesh has "<< _Nmailles << " cells and " << _Nnodes << " nodes"<<endl<<endl;
+
+ // find maximum nb of neibourghs
+ if(!_FECalculation)
+ {
+ _VV=Field ("Displacements", CELLS, _mesh, _Ndim);
+ _neibMaxNbCells=_mesh.getMaxNbNeighbours(CELLS);
+ }
+ else
+ {
+ if(_Ndim==1 )//The 1D cdmath mesh is necessarily made of segments
+ cout<<"1D Finite element method on segments"<<endl;
+ else if(_Ndim==2)
+ {
+ if( _mesh.isTriangular() )//Mesh dim=2
+ cout<<"2D Finite element method on triangles"<<endl;
+ else if (_mesh.getMeshDimension()==1)//Mesh dim=1
+ cout<<"1D Finite element method on a 2D network : space dimension is "<<_Ndim<< ", mesh dimension is "<<_mesh.getMeshDimension()<<endl;
+ else
+ {
+ cout<<"Error Finite element with Space dimension "<<_Ndim<< ", and mesh dimension "<<_mesh.getMeshDimension()<< ", mesh should be either triangular either 1D network"<<endl;
+ *_runLogFile<<"LinearElasticityModel::setMesh: mesh has incorrect dimension"<<endl;
+ _runLogFile->close();
+ throw CdmathException("LinearElasticityModel::setMesh: mesh has incorrect cell types");
+ }
+ }
+ else if(_Ndim==3)
+ {
+ if( _mesh.isTetrahedral() )//Mesh dim=3
+ cout<<"3D Finite element method on tetrahedra"<<endl;
+ else if (_mesh.getMeshDimension()==2 and _mesh.isTriangular())//Mesh dim=2
+ cout<<"2D Finite element method on a 3D surface : space dimension is "<<_Ndim<< ", mesh dimension is "<<_mesh.getMeshDimension()<<endl;
+ else if (_mesh.getMeshDimension()==1)//Mesh dim=1
+ cout<<"1D Finite element method on a 3D network : space dimension is "<<_Ndim<< ", mesh dimension is "<<_mesh.getMeshDimension()<<endl;
+ else
+ {
+ cout<<"Error Finite element with Space dimension "<<_Ndim<< ", and mesh dimension "<<_mesh.getMeshDimension()<< ", mesh should be either tetrahedral, either a triangularised surface or 1D network"<<endl;
+ *_runLogFile<<"LinearElasticityModel::setMesh: mesh has incorrect dimension"<<endl;
+ _runLogFile->close();
+ throw CdmathException("LinearElasticityModel::setMesh: mesh has incorrect cell types");
+ }
+ }
+
+ _VV=Field ("Temperature", NODES, _mesh, _Ndim);
+
+ _neibMaxNbNodes=_mesh.getMaxNbNeighbours(NODES);
+ _boundaryNodeIds = _mesh.getBoundaryNodeIds();
+ _NboundaryNodes=_boundaryNodeIds.size();
+ }
+
+ _meshSet=true;
+}
+
+void LinearElasticityModel::setLinearSolver(linearSolver kspType, preconditioner pcType)
+{
+ //_maxPetscIts=maxIterationsPetsc;
+ // set linear solver algorithm
+ if (kspType==GMRES)
+ _ksptype = (char*)&KSPGMRES;
+ else if (kspType==CG)
+ _ksptype = (char*)&KSPCG;
+ else if (kspType==BCGS)
+ _ksptype = (char*)&KSPBCGS;
+ else {
+ cout << "!!! Error : only 'GMRES', 'CG' or 'BCGS' is acceptable as a linear solver !!!" << endl;
+ *_runLogFile << "!!! Error : only 'GMRES', 'CG' or 'BCGS' is acceptable as a linear solver !!!" << endl;
+ _runLogFile->close();
+ throw CdmathException("!!! Error : only 'GMRES', 'CG' or 'BCGS' algorithm is acceptable !!!");
+ }
+ // set preconditioner
+ if (pcType == NONE)
+ _pctype = (char*)&PCNONE;
+ else if (pcType ==LU)
+ _pctype = (char*)&PCLU;
+ else if (pcType == ILU)
+ _pctype = (char*)&PCILU;
+ else if (pcType ==CHOLESKY)
+ _pctype = (char*)&PCCHOLESKY;
+ else if (pcType == ICC)
+ _pctype = (char*)&PCICC;
+ else {
+ cout << "!!! Error : only 'NONE', 'LU', 'ILU', 'CHOLESKY' or 'ICC' preconditioners are acceptable !!!" << endl;
+ *_runLogFile << "!!! Error : only 'NONE' or 'LU' or 'ILU' preconditioners are acceptable !!!" << endl;
+ _runLogFile->close();
+ throw CdmathException("!!! Error : only 'NONE' or 'LU' or 'ILU' preconditioners are acceptable !!!" );
+ }
+}
+
+bool LinearElasticityModel::solveStationaryProblem()
+{
+ if(!_initializedMemory)
+ {
+ *_runLogFile<< "ProblemCoreFlows::run() call initialize() first"<< _fileName<<endl;
+ _runLogFile->close();
+ throw CdmathException("ProblemCoreFlows::run() call initialize() first");
+ }
+ bool stop=false; // Does the Problem want to stop (error) ?
+
+ cout<< "!!! Running test case "<< _fileName << " using ";
+ *_runLogFile<< "!!! Running test case "<< _fileName<< " using ";
+
+ if(!_FECalculation)
+ {
+ cout<< "Finite volumes method"<<endl<<endl;
+ *_runLogFile<< "Finite volumes method"<<endl<<endl;
+ }
+ else
+ {
+ cout<< "Finite elements method"<<endl<<endl;
+ *_runLogFile<< "Finite elements method"<< endl<<endl;
+ }
+
+ computeDiffusionMatrix( stop);
+ if (stop){
+ cout << "Error : failed computing diffusion matrix, stopping calculation"<< endl;
+ *_runLogFile << "Error : failed computing diffusion matrix, stopping calculation"<< endl;
+ _runLogFile->close();
+ throw CdmathException("Failed computing diffusion matrix");
+ }
+ computeRHS(stop);
+ if (stop){
+ cout << "Error : failed computing right hand side, stopping calculation"<< endl;
+ *_runLogFile << "Error : failed computing right hand side, stopping calculation"<< endl;
+ throw CdmathException("Failed computing right hand side");
+ }
+ stop = !solveLinearSystem();
+ if (stop){
+ cout << "Error : failed solving linear system, stopping calculation"<< endl;
+ *_runLogFile << "Error : failed linear system, stopping calculation"<< endl;
+ _runLogFile->close();
+ throw CdmathException("Failed solving linear system");
+ }
+
+ _computationCompletedSuccessfully=true;
+ save();
+
+ *_runLogFile<< "!!!!!! Computation successful"<< endl;
+ _runLogFile->close();
+
+ return !stop;
+}
+
+void LinearElasticityModel::save(){
+ cout<< "Saving numerical results"<<endl<<endl;
+ *_runLogFile<< "Saving numerical results"<< endl<<endl;
+
+ string resultFile(_path+"/LinearElasticityModel");//Results
+
+ resultFile+="_";
+ resultFile+=_fileName;
+
+ // create mesh and component info
+ string suppress ="rm -rf "+resultFile+"_*";
+ system(suppress.c_str());//Nettoyage des précédents calculs identiques
+
+ if(_verbose or _system)
+ VecView(_displacements,PETSC_VIEWER_STDOUT_SELF);
+
+ double uk;
+ if(!_FECalculation)
+ for(int i=0; i<_Nmailles; i++)
+ {
+ for(int j=0; j<_nVar; j++)
+ {
+ int k=i*_nVar+j;
+ VecGetValues(_displacements, 1, &k, &uk);
+ _VV(i,j)=uk;
+ }
+ }
+ else
+ {
+ int globalIndex;
+ for(int i=0; i<_NunknownNodes; i++)
+ {
+ globalIndex = globalNodeIndex(i, _dirichletNodeIds);
+ for(int j=0; j<_nVar; j++)
+ {
+ int k=i*_nVar+j;
+ VecGetValues(_displacements, 1, &k, &uk);
+ _VV(globalIndex,j)=uk;
+ }
+ }
+
+ Node Ni;
+ string nameOfGroup;
+ for(int i=0; i<_NdirichletNodes; i++)
+ {
+ Ni=_mesh.getNode(_dirichletNodeIds[i]);
+ nameOfGroup = Ni.getGroupName();
+ for(int j=0; j<_nVar; j++)
+ _VV(_dirichletNodeIds[i])=_limitField[nameOfGroup].displacement[i];
+ }
+ }
+
+ switch(_saveFormat)
+ {
+ case VTK :
+ _VV.writeVTK(resultFile);
+ break;
+ case MED :
+ _VV.writeMED(resultFile);
+ break;
+ case CSV :
+ _VV.writeCSV(resultFile);
+ break;
+ }
+}
+Field
+LinearElasticityModel::getOutputDisplacementField()
+{
+ if(!_computationCompletedSuccessfully)
+ throw("Computation not performed yet or failed. No displacement field available");
+ else
+ return _VV;
+}
+
+void LinearElasticityModel::terminate()
+{
+ VecDestroy(&_displacements);
+ VecDestroy(&_b);
+ MatDestroy(&_A);
+}
+void
+LinearElasticityModel::setDirichletValues(map< int, double> dirichletBoundaryValues)
+{
+ _dirichletValuesSet=true;
+ _dirichletBoundaryValues=dirichletBoundaryValues;
+}
+
+double
+LinearElasticityModel::getConditionNumber(bool isSingular, double tol) const
+{
+ SparseMatrixPetsc A = SparseMatrixPetsc(_A);
+ return A.getConditionNumber( isSingular, tol);
+}
//============================================================================
#include "ProblemCoreFlows.hxx"
+#include "SparseMatrixPetsc.hxx"
+
#include <limits.h>
#include <unistd.h>
_freqSave = 1;
_initialDataSet=false;
_initializedMemory=false;
- _spaceScheme=upwind;
+ _restartWithNewTimeScheme=false;
+ _restartWithNewFileName=false;
_timeScheme=Explicit;
_wellBalancedCorrection=false;
+ _FECalculation=false;
_maxPetscIts=50;
_MaxIterLinearSolver=0;//During several newton iterations, stores the max petssc interations
_maxNewtonIts=50;
_saveFormat=VTK;
}
+TimeScheme ProblemCoreFlows::getTimeScheme()
+{
+ return _timeScheme;
+}
+
+void ProblemCoreFlows::setTimeScheme(TimeScheme timeScheme)
+{
+ if( _nbTimeStep>0 && timeScheme!=_timeScheme)//This is a change of time scheme during a simulation
+ _restartWithNewTimeScheme=true;
+ _timeScheme = timeScheme;
+}
+
bool ProblemCoreFlows::isStationary() const
{
return _isStationary;
{
_precision=precision;
}
-void ProblemCoreFlows::setNumericalScheme(SpaceScheme spaceScheme, TimeScheme timeScheme){
- _timeScheme = timeScheme;
- _spaceScheme = spaceScheme;
-}
-
void ProblemCoreFlows::setInitialField(const Field &VV)
{
{
return _precision;
}
-SpaceScheme ProblemCoreFlows::getSpaceScheme()
-{
- return _spaceScheme;
-}
-TimeScheme ProblemCoreFlows::getTimeScheme()
-{
- return _timeScheme;
-}
Mesh ProblemCoreFlows::getMesh()
{
return _mesh;
// Elle peut etre utilisee si le probleme n'est couple a aucun autre.
// (s'il n'a besoin d'aucun champ d'entree).
// Precondition: initialize
-// Seule la methode terminate peut etre appelee apres
+// Seule la methode terminate peut etre appelée apres
bool ProblemCoreFlows::run()
{
if(!_initializedMemory)
if (!ok) // The resolution failed, try with a new time interval.
{
- abortTimeStep();
if(_dt>_precision){
- cout << "Failed solving time step "<<_nbTimeStep<<", time = " << _time <<" _dt= "<<_dt<<", cfl= "<<_cfl<<", trying again with cfl/2"<< endl;
- *_runLogFile << "Failed solving time step "<<_nbTimeStep<<", time = " << _time <<" _dt= "<<_dt<<", cfl= "<<_cfl<<", trying again with cfl/2"<< endl;
- _dt*=0.5;
- _cfl*=0.5;
+ cout<<"ComputeTimeStep returned _dt="<<_dt<<endl;
+ cout << "Failed solving time step "<<_nbTimeStep<<", time = " << _time <<" _dt= "<<_dt<<", cfl= "<<_cfl<<", trying again with dt/2"<< endl;
+ *_runLogFile << "Failed solving time step "<<_nbTimeStep<<", time = " << _time <<" _dt= "<<_dt<<", cfl= "<<_cfl<<", trying again with dt/2"<< endl;
+ double dt=_dt/2;//We chose to divide the time step by 2
+ abortTimeStep();//Cancel the initTimeStep
+ _dt=dt;//new value of time step is previous time step divided by 2 (we do not call computeTimeStep
+ //_cfl*=0.5;//If we change the cfl, we must compute the new time step with computeTimeStep
+ //_dt=computeTimeStep(stop);
}
else{
cout << "Failed solving time step "<<_nbTimeStep<<", _time = " << _time<<" _dt= "<<_dt<<", cfl= "<<_cfl <<", stopping calculation"<< endl;
cout << endl;
}
void ProblemCoreFlows::setFileName(string fileName){
+ if( _nbTimeStep>0 && fileName!=_fileName)//This is a change of file name during a simulation
+ _restartWithNewFileName=true;
_fileName = fileName;
}
*/
delete _runLogFile;
}
+
+double
+ProblemCoreFlows::getConditionNumber(bool isSingular, double tol) const
+{
+ SparseMatrixPetsc A = SparseMatrixPetsc(_A);
+ return A.getConditionNumber( isSingular, tol);
+}
+std::vector< double >
+ProblemCoreFlows::getEigenvalues(int nev, EPSWhich which, double tol) const
+{
+ SparseMatrixPetsc A = SparseMatrixPetsc(_A);
+ return A.getEigenvalues( nev, which, tol);
+}
+std::vector< Vector >
+ProblemCoreFlows::getEigenvectors(int nev, EPSWhich which, double tol) const
+{
+ SparseMatrixPetsc A = SparseMatrixPetsc(_A);
+ return A.getEigenvectors( nev, which, tol);
+}
+Field
+ProblemCoreFlows::getEigenvectorsField(int nev, EPSWhich which, double tol) const
+{
+ SparseMatrixPetsc A = SparseMatrixPetsc(_A);
+ MEDCoupling::DataArrayDouble * d = A.getEigenvectorsDataArrayDouble( nev, which, tol);
+ Field my_eigenfield;
+
+ if(_FECalculation)
+ my_eigenfield = Field("Eigenvectors field", NODES, _mesh, nev);
+ else
+ my_eigenfield = Field("Eigenvectors field", CELLS, _mesh, nev);
+
+ my_eigenfield.setFieldByDataArrayDouble(d);
+
+ return my_eigenfield;
+}
_saveConservativeField=false;
_usePrimitiveVarsInNewton=false;
_saveInterfacialField=false;
- //Pour affichage donnees diphasiques dans IterateTimeStep
- _err_press_max=0; _part_imag_max=0; _nbMaillesNeg=0; _nbVpCplx=0;_minm1=1e30;_minm2=1e30;
+ _err_press_max=0; _part_imag_max=0; _nbMaillesNeg=0; _nbVpCplx=0;_minm1=1e30;_minm2=1e30;//Pour affichage paramètres diphasiques dans IterateTimeStep
_isScaling=false;
_entropicCorrection=false;
_pressureCorrectionOrder=2;
_nonLinearFormulation=Roe;
_maxvploc=0.;
+ _spaceScheme=upwind;
+}
+
+SpaceScheme ProblemFluid::getSpaceScheme()
+{
+ return _spaceScheme;
+}
+void ProblemFluid::setNumericalScheme(SpaceScheme spaceScheme, TimeScheme timeScheme)
+{
+ if( _nbTimeStep>0 && timeScheme!=_timeScheme)//This is a change of time scheme during a simulation
+ _restartWithNewTimeScheme=true;
+ _timeScheme = timeScheme;
+ _spaceScheme = spaceScheme;
}
void ProblemFluid::initialize()
bool ProblemFluid::initTimeStep(double dt){
_dt = dt;
- return _dt>0;
+ return _dt>0;//No need to call MatShift as the linear system matrix is filled at each Newton iteration (unlike linear problem)
}
bool ProblemFluid::iterateTimeStep(bool &converged)
if(_NEWTON_its>0){//Pas besoin de computeTimeStep à la première iteration de Newton
_maxvp=0.;
- computeTimeStep(stop);
+ computeTimeStep(stop);//This compute timestep is just to update the linear system. The time step was imposed befor starting the Newton iterations
}
if(stop){//Le compute time step ne s'est pas bien passé
cout<<"ComputeTimeStep failed"<<endl;
double ProblemFluid::computeTimeStep(bool & stop){
VecZeroEntries(_b);
+
+ if(_restartWithNewTimeScheme)//This is a change of time scheme during a simulation
+ {
+ if(_timeScheme == Implicit)
+ MatCreateSeqBAIJ(PETSC_COMM_SELF, _nVar, _nVar*_Nmailles, _nVar*_Nmailles, (1+_neibMaxNb), PETSC_NULL, &_A);
+ else
+ MatDestroy(&_A);
+ _restartWithNewTimeScheme=false;
+ }
if(_timeScheme == Implicit)
MatZeroEntries(_A);
_dragCoeffs=vector<double>(1,0);
_fluides.resize(1);
_useDellacherieEOS=useDellacherieEOS;
+ _saveAllFields=false;
if(pEstimate==around1bar300K){//EOS at 1 bar and 300K
_Tref=300;
_gravite[i+1]=_GravityField3d[i];
_GravityImplicitationMatrix = new PetscScalar[_nVar*_nVar];
- if(_saveVelocity)
+ if(_saveVelocity || _saveAllFields)
_Vitesse=Field("Velocity",CELLS,_mesh,3);//Forcement en dimension 3 pour le posttraitement des lignes de courant
+ if(_saveAllFields)
+ {
+ _Enthalpy=Field("Enthalpy",CELLS,_mesh,1);
+ _Pressure=Field("Pressure",CELLS,_mesh,1);
+ _Density=Field("Density",CELLS,_mesh,1);
+ _Temperature=Field("Temperature",CELLS,_mesh,1);
+ _VitesseX=Field("Velocity x",CELLS,_mesh,1);
+ if(_Ndim>1)
+ {
+ _VitesseY=Field("Velocity y",CELLS,_mesh,1);
+ if(_Ndim>2)
+ _VitesseZ=Field("Velocity z",CELLS,_mesh,1);
+ }
+ }
+
if(_entropicCorrection)
_entropicShift=vector<double>(3,0);//at most 3 distinct eigenvalues
bool SinglePhase::iterateTimeStep(bool &converged)
{
if(_timeScheme == Explicit || !_usePrimitiveVarsInNewton)
- ProblemFluid::iterateTimeStep(converged);
+ return ProblemFluid::iterateTimeStep(converged);
else
{
bool stop=false;
void SinglePhase::save(){
string prim(_path+"/SinglePhasePrim_");///Results
string cons(_path+"/SinglePhaseCons_");
+ string allFields(_path+"/");
prim+=_fileName;
cons+=_fileName;
+ allFields+=_fileName;
PetscInt Ii;
for (long i = 0; i < _Nmailles; i++){
_VV.setTime(_time,_nbTimeStep);
// create mesh and component info
- if (_nbTimeStep ==0){
+ if (_nbTimeStep ==0 || _restartWithNewFileName){
string prim_suppress ="rm -rf "+prim+"_*";
string cons_suppress ="rm -rf "+cons+"_*";
_VV.writeCSV(prim);
break;
}
+
}
// do not create mesh
else{
}
}
}
- if(_saveVelocity){
+ if(_saveVelocity || _saveAllFields){
for (long i = 0; i < _Nmailles; i++){
// j = 0 : pressure; j = _nVar - 1: temperature; j = 1,..,_nVar-2: velocity
for (int j = 0; j < _Ndim; j++)//On récupère les composantes de vitesse
_Vitesse(i,j)=0;
}
_Vitesse.setTime(_time,_nbTimeStep);
- if (_nbTimeStep ==0){
+ if (_nbTimeStep ==0 || _restartWithNewFileName){
_Vitesse.setInfoOnComponent(0,"Velocity_x_(m/s)");
_Vitesse.setInfoOnComponent(1,"Velocity_y_(m/s)");
_Vitesse.setInfoOnComponent(2,"Velocity_z_(m/s)");
}
}
}
+
+ if(_saveAllFields)
+ {
+ double p,T,rho, h, vx,vy,vz;
+ int Ii;
+ for (long i = 0; i < _Nmailles; i++){
+ Ii = i*_nVar;
+ VecGetValues(_conservativeVars,1,&Ii,&rho);
+ Ii = i*_nVar;
+ VecGetValues(_primitiveVars,1,&Ii,&p);
+ Ii = i*_nVar +_nVar-1;
+ VecGetValues(_primitiveVars,1,&Ii,&T);
+ Ii = i*_nVar + 1;
+ VecGetValues(_primitiveVars,1,&Ii,&vx);
+ if(_Ndim>1)
+ {
+ Ii = i*_nVar + 2;
+ VecGetValues(_primitiveVars,1,&Ii,&vy);
+ if(_Ndim>2){
+ Ii = i*_nVar + 3;
+ VecGetValues(_primitiveVars,1,&Ii,&vz);
+ }
+ }
+
+ h = _fluides[0]->getEnthalpy(T,rho);
+
+ _Enthalpy(i)=h;
+ _Density(i)=rho;
+ _Pressure(i)=p;
+ _Temperature(i)=T;
+ _VitesseX(i)=vx;
+ if(_Ndim>1)
+ {
+ _VitesseY(i)=vy;
+ if(_Ndim>2)
+ _VitesseZ(i)=vz;
+ }
+ }
+ _Enthalpy.setTime(_time,_nbTimeStep);
+ _Density.setTime(_time,_nbTimeStep);
+ _Pressure.setTime(_time,_nbTimeStep);
+ _Temperature.setTime(_time,_nbTimeStep);
+ _VitesseX.setTime(_time,_nbTimeStep);
+ if(_Ndim>1)
+ {
+ _VitesseY.setTime(_time,_nbTimeStep);
+ if(_Ndim>2)
+ _VitesseZ.setTime(_time,_nbTimeStep);
+ }
+ if (_nbTimeStep ==0 || _restartWithNewFileName){
+ switch(_saveFormat)
+ {
+ case VTK :
+ _Enthalpy.writeVTK(allFields+"_Enthalpy");
+ _Density.writeVTK(allFields+"_Density");
+ _Pressure.writeVTK(allFields+"_Pressure");
+ _Temperature.writeVTK(allFields+"_Temperature");
+ _VitesseX.writeVTK(allFields+"_VelocityX");
+ if(_Ndim>1)
+ {
+ _VitesseY.writeVTK(allFields+"_VelocityY");
+ if(_Ndim>2)
+ _VitesseZ.writeVTK(allFields+"_VelocityZ");
+ }
+ break;
+ case MED :
+ _Enthalpy.writeMED(allFields+"_Enthalpy");
+ _Density.writeMED(allFields+"_Density");
+ _Pressure.writeMED(allFields+"_Pressure");
+ _Temperature.writeMED(allFields+"_Temperature");
+ _VitesseX.writeMED(allFields+"_VelocityX");
+ if(_Ndim>1)
+ {
+ _VitesseY.writeMED(allFields+"_VelocityY");
+ if(_Ndim>2)
+ _VitesseZ.writeMED(allFields+"_VelocityZ");
+ }
+ break;
+ case CSV :
+ _Enthalpy.writeCSV(allFields+"_Enthalpy");
+ _Density.writeCSV(allFields+"_Density");
+ _Pressure.writeCSV(allFields+"_Pressure");
+ _Temperature.writeCSV(allFields+"_Temperature");
+ _VitesseX.writeCSV(allFields+"_VelocityX");
+ if(_Ndim>1)
+ {
+ _VitesseY.writeCSV(allFields+"_VelocityY");
+ if(_Ndim>2)
+ _VitesseZ.writeCSV(allFields+"_VelocityZ");
+ }
+ break;
+ }
+ }
+ else{
+ switch(_saveFormat)
+ {
+ case VTK :
+ _Enthalpy.writeVTK(allFields+"_Enthalpy",false);
+ _Density.writeVTK(allFields+"_Density",false);
+ _Pressure.writeVTK(allFields+"_Pressure",false);
+ _Temperature.writeVTK(allFields+"_Temperature",false);
+ _VitesseX.writeVTK(allFields+"_VelocityX",false);
+ if(_Ndim>1)
+ {
+ _VitesseY.writeVTK(allFields+"_VelocityY",false);
+ if(_Ndim>2)
+ _VitesseZ.writeVTK(allFields+"_VelocityZ",false);
+ }
+ break;
+ case MED :
+ _Enthalpy.writeMED(allFields+"_Enthalpy",false);
+ _Density.writeMED(allFields+"_Density",false);
+ _Pressure.writeMED(allFields+"_Pressure",false);
+ _Temperature.writeMED(allFields+"_Temperature",false);
+ _VitesseX.writeMED(allFields+"_VelocityX",false);
+ if(_Ndim>1)
+ {
+ _VitesseY.writeMED(allFields+"_VelocityY",false);
+ if(_Ndim>2)
+ _VitesseZ.writeMED(allFields+"_VelocityZ",false);
+ }
+ break;
+ case CSV :
+ _Enthalpy.writeCSV(allFields+"_Enthalpy");
+ _Density.writeCSV(allFields+"_Density");
+ _Pressure.writeCSV(allFields+"_Pressure");
+ _Temperature.writeCSV(allFields+"_Temperature");
+ _VitesseX.writeCSV(allFields+"_VelocityX");
+ if(_Ndim>1)
+ {
+ _VitesseY.writeCSV(allFields+"_VelocityY");
+ if(_Ndim>2)
+ _VitesseZ.writeCSV(allFields+"_VelocityZ");
+ }
+ break;
+ }
+ }
+ }
+
if(_isStationary)
{
prim+="_Stat";
}
}
- if(_saveVelocity){
+ if(_saveVelocity || _saveAllFields){
switch(_saveFormat)
{
case VTK :
}
}
}
+
+ if (_restartWithNewFileName)
+ _restartWithNewFileName=false;
+}
+
+Field& SinglePhase::getPressureField()
+{
+ if(!_saveAllFields)
+ {
+ _Pressure=Field("Pressure",CELLS,_mesh,1);
+ int Ii;
+ for (long i = 0; i < _Nmailles; i++){
+ Ii = i*_nVar;
+ VecGetValues(_primitiveVars,1,&Ii,&_Pressure(i));
+ }
+ _Pressure.setTime(_time,_nbTimeStep);
+ }
+ return _Pressure;
+}
+
+Field& SinglePhase::getTemperatureField()
+{
+ if(!_saveAllFields)
+ {
+ _Temperature=Field("Temperature",CELLS,_mesh,1);
+ int Ii;
+ for (long i = 0; i < _Nmailles; i++){
+ Ii = i*_nVar +_nVar-1;
+ VecGetValues(_primitiveVars,1,&Ii,&_Temperature(i));
+ }
+ _Temperature.setTime(_time,_nbTimeStep);
+ }
+ return _Temperature;
+}
+
+Field& SinglePhase::getVelocityField()
+{
+ if(!_saveAllFields )
+ {
+ _Vitesse=Field("Vitesse",CELLS,_mesh,3);
+ int Ii;
+ for (long i = 0; i < _Nmailles; i++)
+ {
+ for (int j = 0; j < _Ndim; j++)//On récupère les composantes de vitesse
+ {
+ int Ii = i*_nVar +1+j;
+ VecGetValues(_primitiveVars,1,&Ii,&_Vitesse(i,j));
+ }
+ for (int j = _Ndim; j < 3; j++)//On met à zero les composantes de vitesse si la dimension est <3
+ _Vitesse(i,j)=0;
+ }
+ _Vitesse.setTime(_time,_nbTimeStep);
+ _Vitesse.setInfoOnComponent(0,"Velocity_x_(m/s)");
+ _Vitesse.setInfoOnComponent(1,"Velocity_y_(m/s)");
+ _Vitesse.setInfoOnComponent(2,"Velocity_z_(m/s)");
+ }
+
+ return _Vitesse;
+}
+
+Field& SinglePhase::getVelocityXField()
+{
+ if(!_saveAllFields )
+ {
+ _VitesseX=Field("Velocity X",CELLS,_mesh,1);
+ int Ii;
+ for (long i = 0; i < _Nmailles; i++)
+ {
+ int Ii = i*_nVar +1;
+ VecGetValues(_primitiveVars,1,&Ii,&_VitesseX(i));
+ }
+ _VitesseX.setTime(_time,_nbTimeStep);
+ _VitesseX.setInfoOnComponent(0,"Velocity_x_(m/s)");
+ }
+
+ return _VitesseX;
+}
+
+Field& SinglePhase::getDensityField()
+{
+ if(!_saveAllFields )
+ {
+ _Density=Field("Density",CELLS,_mesh,1);
+ int Ii;
+ for (long i = 0; i < _Nmailles; i++){
+ Ii = i*_nVar;
+ VecGetValues(_conservativeVars,1,&Ii,&_Density(i));
+ }
+ _Density.setTime(_time,_nbTimeStep);
+ }
+ return _Density;
+}
+
+Field& SinglePhase::getMomentumField()//not yet managed by parameter _saveAllFields
+{
+ _Momentum=Field("Momentum",CELLS,_mesh,_Ndim);
+ int Ii;
+ for (long i = 0; i < _Nmailles; i++)
+ for (int j = 0; j < _Ndim; j++)//On récupère les composantes de qdm
+ {
+ int Ii = i*_nVar +1+j;
+ VecGetValues(_conservativeVars,1,&Ii,&_Momentum(i,j));
+ }
+ _Momentum.setTime(_time,_nbTimeStep);
+
+ return _Momentum;
+}
+
+Field& SinglePhase::getTotalEnergyField()//not yet managed by parameter _saveAllFields
+{
+ _TotalEnergy=Field("TotalEnergy",CELLS,_mesh,1);
+ int Ii;
+ for (long i = 0; i < _Nmailles; i++){
+ Ii = i*_nVar +_nVar-1;
+ VecGetValues(_conservativeVars,1,&Ii,&_TotalEnergy(i));
+ }
+ _TotalEnergy.setTime(_time,_nbTimeStep);
+
+ return _TotalEnergy;
+}
+
+Field& SinglePhase::getEnthalpyField()
+{
+ if(!_saveAllFields )
+ {
+ _Enthalpy=Field("Enthalpy",CELLS,_mesh,1);
+ int Ii;
+ double p,T,rho;
+ for (long i = 0; i < _Nmailles; i++){
+ Ii = i*_nVar;
+ VecGetValues(_primitiveVars,1,&Ii,&p);
+ Ii = i*_nVar +_nVar-1;
+ VecGetValues(_primitiveVars,1,&Ii,&T);
+
+ rho=_fluides[0]->getDensity(p,T);
+ _Enthalpy(i)=_fluides[0]->getEnthalpy(T,rho);
+ }
+ _Enthalpy.setTime(_time,_nbTimeStep);
+ }
+
+ return _Enthalpy;
+}
+
+vector<string> SinglePhase::getOutputFieldsNames()
+{
+ vector<string> result(8);
+
+ result[0]="Pressure";
+ result[1]="Velocity";
+ result[2]="Temperature";
+ result[3]="Density";
+ result[4]="Momentum";
+ result[5]="TotalEnergy";
+ result[6]="Enthalpy";
+ result[7]="VelocityX";
+
+ return result;
+}
+
+Field& SinglePhase::getOutputField(const string& nameField )
+{
+ if(nameField=="pressure" || nameField=="Pressure" || nameField=="PRESSURE" || nameField=="PRESSION" || nameField=="Pression" || nameField=="pression" )
+ return getPressureField();
+ else if(nameField=="velocity" || nameField=="Velocity" || nameField=="VELOCITY" || nameField=="Vitesse" || nameField=="VITESSE" || nameField=="vitesse" )
+ return getVelocityField();
+ else if(nameField=="velocityX" || nameField=="VelocityX" || nameField=="VELOCITYX" || nameField=="VitesseX" || nameField=="VITESSEX" || nameField=="vitesseX" )
+ return getVelocityXField();
+ else if(nameField=="temperature" || nameField=="Temperature" || nameField=="TEMPERATURE" || nameField=="temperature" )
+ return getTemperatureField();
+ else if(nameField=="density" || nameField=="Density" || nameField=="DENSITY" || nameField=="Densite" || nameField=="DENSITE" || nameField=="densite" )
+ return getDensityField();
+ else if(nameField=="momentum" || nameField=="Momentum" || nameField=="MOMENTUM" || nameField=="Qdm" || nameField=="QDM" || nameField=="qdm" )
+ return getMomentumField();
+ else if(nameField=="enthalpy" || nameField=="Enthalpy" || nameField=="ENTHALPY" || nameField=="Enthalpie" || nameField=="ENTHALPIE" || nameField=="enthalpie" )
+ return getEnthalpyField();
+ else if(nameField=="totalenergy" || nameField=="TotalEnergy" || nameField=="TOTALENERGY" || nameField=="ENERGIETOTALE" || nameField=="EnergieTotale" || nameField=="energietotale" )
+ return getTotalEnergyField();
+ else
+ {
+ cout<<"Error : Field name "<< nameField << " does not exist, call getOutputFieldsNames first" << endl;
+ throw CdmathException("SinglePhase::getOutputField error : Unknown Field name");
+ }
}
#include "StationaryDiffusionEquation.hxx"
+#include "Node.hxx"
+#include "SparseMatrixPetsc.hxx"
#include "math.h"
#include <algorithm>
#include <fstream>
{
return (n == 1 || n == 0) ? 1 : fact(n - 1) * n;
}
-int StationaryDiffusionEquation::unknownNodeIndex(int globalIndex, std::vector< int > dirichletNodes)
+int StationaryDiffusionEquation::unknownNodeIndex(int globalIndex, std::vector< int > dirichletNodes) const
{//assumes Dirichlet node numbering is strictly increasing
int j=0;//indice de parcours des noeuds frontière avec CL Dirichlet
int boundarySize=dirichletNodes.size();
throw CdmathException("StationaryDiffusionEquation::unknownNodeIndex : Error : node is a Dirichlet boundary node");
}
-int StationaryDiffusionEquation::globalNodeIndex(int unknownNodeIndex, std::vector< int > dirichletNodes)
+int StationaryDiffusionEquation::globalNodeIndex(int unknownNodeIndex, std::vector< int > dirichletNodes) const
{//assumes Dirichlet boundary node numbering is strictly increasing
int boundarySize=dirichletNodes.size();
/* trivial case where all boundary nodes are Neumann BC */
if(j+1==boundarySize)
return unknownNodeIndex+boundarySize;
- else //unknownNodeMax>=unknownNodeIndex) hence our node global number is between dirichletNodes[j-1] and dirichletNodes[j]
+ else //unknownNodeMax>=unknownNodeIndex, hence our node global number is between dirichletNodes[j-1] and dirichletNodes[j]
return unknownNodeIndex - unknownNodeMax + dirichletNodes[j]-1;
}
if(lambda < 0.)
{
- std::cout<<"conductivity="<<lambda<<endl;
+ std::cout<<"Conductivity="<<lambda<<endl;
throw CdmathException("Error : conductivity parameter lambda cannot be negative");
}
if(dim<=0)
{
- std::cout<<"space dimension="<<dim<<endl;
+ std::cout<<"Space dimension="<<dim<<endl;
throw CdmathException("Error : parameter dim cannot be negative");
}
_NdirichletNodes=0;
_NunknownNodes=0;
_dirichletValuesSet=false;
+ _neumannValuesSet=false;
//Linear solver data
_precision=1.e-6;
/* Détection des noeuds frontière avec une condition limite de Dirichlet */
if(_FECalculation)
{
- /*
- vector<int> _boundaryFaceIds = _mesh.getBoundaryFaceIds();
-
- cout <<"Total number of faces " <<_mesh.getNumberOfFaces()<<", Number of boundary faces " << _boundaryFaceIds.size()<<endl;
- for(int i=0; i<_boundaryFaceIds.size(); i++)
- cout<<", "<<_boundaryFaceIds[i];
- cout<<endl;
-
- cout <<"Total number of nodes " <<_mesh.getNumberOfNodes()<<", Number of boundary nodes " << _NboundaryNodes<<endl;
- for(int i=0; i<_NboundaryNodes; i++)
- cout<<", "<<_boundaryNodeIds[i];
- cout<<endl;
- */
if(_NboundaryNodes==_Nnodes)
cout<<"!!!!! Warning : all nodes are boundary nodes !!!!!"<<endl<<endl;
_dirichletNodeIds.push_back(_boundaryNodeIds[i]);
else if( _mesh.getNode(_boundaryNodeIds[i]).getGroupNames().size()==0 )
{
- cout<<"!!! No boundary value set for boundary node" << _boundaryNodeIds[i]<< endl;
- *_runLogFile<< "!!! No boundary value set for boundary node" << _boundaryNodeIds[i]<<endl;
+ cout<<"!!! No boundary group set for boundary node" << _boundaryNodeIds[i]<< endl;
+ *_runLogFile<< "!!! No boundary group set for boundary node" << _boundaryNodeIds[i]<<endl;
_runLogFile->close();
- throw CdmathException("Missing boundary value");
+ throw CdmathException("Missing boundary group");
}
- else if(_limitField[_mesh.getNode(_boundaryNodeIds[i]).getGroupName()].bcType==NoTypeSpecified)
+ else if(_limitField[_mesh.getNode(_boundaryNodeIds[i]).getGroupName()].bcType==NoneBCStationaryDiffusion)
{
cout<<"!!! No boundary condition set for boundary node " << _boundaryNodeIds[i]<< endl;
- *_runLogFile<< "!!!No boundary condition set for boundary node " << _boundaryNodeIds[i]<<endl;
+ cout<<"!!! Accepted boundary conditions are DirichletStationaryDiffusion "<< DirichletStationaryDiffusion <<" and NeumannStationaryDiffusion "<< NeumannStationaryDiffusion << endl;
+ *_runLogFile<< "!!! No boundary condition set for boundary node " << _boundaryNodeIds[i]<<endl;
+ *_runLogFile<< "!!! Accepted boundary conditions are DirichletStationaryDiffusion "<< DirichletStationaryDiffusion <<" and NeumannStationaryDiffusion "<< NeumannStationaryDiffusion <<endl;
_runLogFile->close();
throw CdmathException("Missing boundary condition");
}
- else if(_limitField[_mesh.getNode(_boundaryNodeIds[i]).getGroupName()].bcType==Dirichlet)
+ else if(_limitField[_mesh.getNode(_boundaryNodeIds[i]).getGroupName()].bcType==DirichletStationaryDiffusion)
_dirichletNodeIds.push_back(_boundaryNodeIds[i]);
- else if(_limitField[_mesh.getNode(_boundaryNodeIds[i]).getGroupName()].bcType!=Neumann)
+ else if(_limitField[_mesh.getNode(_boundaryNodeIds[i]).getGroupName()].bcType!=NeumannStationaryDiffusion)
{
cout<<"!!! Wrong boundary condition "<< _limitField[_mesh.getNode(_boundaryNodeIds[i]).getGroupName()].bcType<< " set for boundary node " << _boundaryNodeIds[i]<< endl;
- cout<<"!!! Accepted boundary conditions are Dirichlet "<< Dirichlet <<" and Neumann "<< Neumann << endl;
- *_runLogFile<< "Wrong boundary condition "<< _limitField[_mesh.getNode(_boundaryNodeIds[i]).getGroupName()].bcType<< " set for boundary node " << _boundaryNodeIds[i]<<endl;
- *_runLogFile<< "Accepted boundary conditions are Dirichlet "<< Dirichlet <<" and Neumann "<< Neumann <<endl;
+ cout<<"!!! Accepted boundary conditions are DirichletStationaryDiffusion "<< DirichletStationaryDiffusion <<" and NeumannStationaryDiffusion "<< NeumannStationaryDiffusion << endl;
+ *_runLogFile<< "!!! Wrong boundary condition "<< _limitField[_mesh.getNode(_boundaryNodeIds[i]).getGroupName()].bcType<< " set for boundary node " << _boundaryNodeIds[i]<<endl;
+ *_runLogFile<< "!!! Accepted boundary conditions are DirichletStationaryDiffusion "<< DirichletStationaryDiffusion <<" and NeumannStationaryDiffusion "<< NeumannStationaryDiffusion <<endl;
_runLogFile->close();
throw CdmathException("Wrong boundary condition");
}
KSPGetPC(_ksp, &_pc);
PCSetType(_pc, _pctype);
- //Checking whether all boundaries are Neumann boundaries
- map<string, LimitField>::iterator it = _limitField.begin();
- while(it != _limitField.end() and (it->second).bcType == Neumann)
- it++;
- _onlyNeumannBC = (it == _limitField.end() && _limitField.size()>0);
+ //Checking whether all boundary conditions are Neumann boundary condition
+ //if(_FECalculation) _onlyNeumannBC = _NdirichletNodes==0;
+ if(!_neumannValuesSet)//Boundary conditions set via LimitField structure
+ {
+ map<string, LimitFieldStationaryDiffusion>::iterator it = _limitField.begin();
+ while(it != _limitField.end() and (it->second).bcType == NeumannStationaryDiffusion)
+ it++;
+ _onlyNeumannBC = (it == _limitField.end() && _limitField.size()>0);//what if _limitField.size()==0 ???
+ }
+ else
+ if(_FECalculation)
+ _onlyNeumannBC = _neumannBoundaryValues.size()==_NboundaryNodes;
+ else
+ _onlyNeumannBC = _neumannBoundaryValues.size()==_mesh.getBoundaryFaceIds().size();
+
//If only Neumann BC, then matrix is singular and solution should be sought in space of mean zero vectors
if(_onlyNeumannBC)
{
- std::cout<<"## Warning all boundary conditions are Neumann. System matrix is not invertible since constant vectors are in the kernel."<<std::endl;
- std::cout<<"## As a consequence we seek a zero sum solution, and exact (LU and CHOLESKY) and incomplete factorisations (ILU and ICC) may fail."<<std::endl<<endl;
- *_runLogFile<<"## Warning all boundary condition are Neumann. System matrix is not invertible since constant vectors are in the kernel."<<std::endl;
- *_runLogFile<<"## As a consequence we seek a zero sum solution, and exact (LU and CHOLESKY) and incomplete factorisations (ILU and ICC) may fail."<<std::endl<<endl;
+ std::cout<<"### Warning : all boundary conditions are Neumann. System matrix is not invertible since constant vectors are in the kernel."<<std::endl;
+ std::cout<<"### Check the compatibility condition between the right hand side and the boundary data. For homogeneous Neumann BCs, the right hand side must have integral equal to zero."<<std::endl;
+ std::cout<<"### The system matrix being singular, we seek a zero sum solution, and exact (LU and CHOLESKY) and incomplete factorisations (ILU and ICC) may fail."<<std::endl<<endl;
+ *_runLogFile<<"### Warning : all boundary condition are Neumann. System matrix is not invertible since constant vectors are in the kernel."<<std::endl;
+ *_runLogFile<<"### The system matrix being singular, we seek a zero sum solution, and exact (LU and CHOLESKY) and incomplete factorisations (ILU and ICC) may fail."<<std::endl<<endl;
+ *_runLogFile<<"### Check the compatibility condition between the right hand side and the boundary data. For homogeneous Neumann BCs, the right hand side must have integral equal to zero."<<std::endl;
//Check that the matrix is symmetric
PetscBool isSymetric;
- MatIsSymmetric(_mat,_precision,&isSymetric);
+ MatIsSymmetric(_A,_precision,&isSymetric);
if(!isSymetric)
{
cout<<"Singular matrix is not symmetric, tolerance= "<< _precision<<endl;
double StationaryDiffusionEquation::computeDiffusionMatrixFE(bool & stop){
Cell Cj;
string nameOfGroup;
- double dn;
+ double dn, coeff;
MatZeroEntries(_A);
VecZeroEntries(_b);
valuesBorder[kdim]=0;
}
GradShapeFuncBorder=gradientNodal(M,valuesBorder)/fact(_Ndim);
- double coeff =-_conductivity*(_DiffusionTensor*GradShapeFuncBorder)*GradShapeFuncs[idim]/Cj.getMeasure();
+ coeff =-_conductivity*(_DiffusionTensor*GradShapeFuncBorder)*GradShapeFuncs[idim]/Cj.getMeasure();
VecSetValue(_b,i_int,coeff, ADD_VALUES);
}
}
}
}
+ //Calcul de la contribution de la condition limite de Neumann au second membre
+ if( _NdirichletNodes !=_NboundaryNodes)
+ {
+ vector< int > boundaryFaces = _mesh.getBoundaryFaceIds();
+ int NboundaryFaces=boundaryFaces.size();
+ for(int i = 0; i< NboundaryFaces ; i++)//On parcourt les faces du bord
+ {
+ Face Fi = _mesh.getFace(i);
+ for(int j = 0 ; j<_Ndim ; j++)//On parcourt les noeuds de la face
+ {
+ if(find(_dirichletNodeIds.begin(),_dirichletNodeIds.end(),Fi.getNodeId(j))==_dirichletNodeIds.end())//node j is an Neumann BC node (not a Dirichlet BC node)
+ {
+ j_int=unknownNodeIndex(Fi.getNodeId(j), _dirichletNodeIds);//indice du noeud j en tant que noeud inconnu
+ if( _neumannValuesSet )
+ coeff =Fi.getMeasure()/_Ndim*_neumannBoundaryValues[Fi.getNodeId(j)];
+ else
+ coeff =Fi.getMeasure()/_Ndim*_limitField[_mesh.getNode(Fi.getNodeId(j)).getGroupName()].normalFlux;
+ VecSetValue(_b, j_int, coeff, ADD_VALUES);
+ }
+ }
+ }
+ }
MatAssemblyBegin(_A, MAT_FINAL_ASSEMBLY);
MatAssemblyEnd(_A, MAT_FINAL_ASSEMBLY);
VecAssemblyBegin(_b);
{
nameOfGroup = Fj.getGroupName();
- if (_limitField[nameOfGroup].bcType==Neumann){//Nothing to do
+ if (_limitField[nameOfGroup].bcType==NeumannStationaryDiffusion){
+ VecSetValue(_b,idm, -dn*inv_dxi*_limitField[nameOfGroup].normalFlux, ADD_VALUES);
}
- else if(_limitField[nameOfGroup].bcType==Dirichlet){
+ else if(_limitField[nameOfGroup].bcType==DirichletStationaryDiffusion){
barycenterDistance=Cell1.getBarryCenter().distance(Fj.getBarryCenter());
MatSetValue(_A,idm,idm,dn*inv_dxi/barycenterDistance , ADD_VALUES);
VecSetValue(_b,idm, dn*inv_dxi/barycenterDistance*_limitField[nameOfGroup].T, ADD_VALUES);
stop=true ;
cout<<"!!!!!!!!!!!!!!! Error StationaryDiffusionEquation::computeDiffusionMatrixFV !!!!!!!!!!"<<endl;
cout<<"!!!!!! Boundary condition not accepted for boundary named !!!!!!!!!!"<<nameOfGroup<< ", _limitField[nameOfGroup].bcType= "<<_limitField[nameOfGroup].bcType<<endl;
- cout<<"Accepted boundary conditions are Neumann "<<Neumann<< " and Dirichlet "<<Dirichlet<<endl;
+ cout<<"Accepted boundary conditions are NeumannStationaryDiffusion "<<NeumannStationaryDiffusion<< " and DirichletStationaryDiffusion "<<DirichletStationaryDiffusion<<endl;
*_runLogFile<<"!!!!!! Boundary condition not accepted for boundary named !!!!!!!!!!"<<nameOfGroup<< ", _limitField[nameOfGroup].bcType= "<<_limitField[nameOfGroup].bcType<<endl;
_runLogFile->close();
throw CdmathException("Boundary condition not accepted");
return INFINITY;
}
-double StationaryDiffusionEquation::computeRHS(bool & stop)//Contribution of the PDE RHS to the linear systemm RHS (boundary conditions do contribute to the system RHS)
+double StationaryDiffusionEquation::computeRHS(bool & stop)//Contribution of the PDE RHS to the linear systemm RHS (boundary conditions do contribute to the system RHS via the function computeDiffusionMatrix)
{
VecAssemblyBegin(_b);
Ci=_mesh.getCell(i);
nodesId=Ci.getNodesId();
for (int j=0; j<nodesId.size();j++)
- if(!_mesh.isBorderNode(nodesId[j])) //or for better performance nodeIds[idim]>dirichletNodes.upper_bound()
+ if(!_mesh.isBorderNode(nodesId[j]))
{
double coeff = _heatTransfertCoeff*_fluidTemperatureField(nodesId[j]) + _heatPowerField(nodesId[j]);
- VecSetValue(_b,unknownNodeIndex(nodesId[j], _dirichletNodeIds), coeff*Ci.getMeasure()/(_Ndim+1),ADD_VALUES);//assumes node numbering starts with unknown nodes. otherwise unknownNodes.index(j)
+ VecSetValue(_b,unknownNodeIndex(nodesId[j], _dirichletNodeIds), coeff*Ci.getMeasure()/(_Ndim+1),ADD_VALUES);
}
}
}
}
*/
- *_runLogFile<< "!!!!!! Computation successful"<< endl;
+ *_runLogFile<< "!!!!!! Computation successful !!!!!!"<< endl;
_runLogFile->close();
return !stop;
{
VecGetValues(_Tk, 1, &i, &Ti);
globalIndex = globalNodeIndex(i, _dirichletNodeIds);
- _VV(globalIndex)=Ti;//Assumes node numbering starts with border nodes
+ _VV(globalIndex)=Ti;
}
Node Ni;
string nameOfGroup;
- for(int i=0; i<_NdirichletNodes; i++)//Assumes node numbering starts with border nodes
+ for(int i=0; i<_NdirichletNodes; i++)
{
Ni=_mesh.getNode(_dirichletNodeIds[i]);
nameOfGroup = Ni.getGroupName();
_dirichletBoundaryValues=dirichletBoundaryValues;
}
+void
+StationaryDiffusionEquation::setNeumannValues(map< int, double> neumannBoundaryValues)
+{
+ _neumannValuesSet=true;
+ _neumannBoundaryValues=neumannBoundaryValues;
+}
+
+double
+StationaryDiffusionEquation::getConditionNumber(bool isSingular, double tol) const
+{
+ SparseMatrixPetsc A = SparseMatrixPetsc(_A);
+ return A.getConditionNumber( isSingular, tol);
+}
+std::vector< double >
+StationaryDiffusionEquation::getEigenvalues(int nev, EPSWhich which, double tol) const
+{
+ SparseMatrixPetsc A = SparseMatrixPetsc(_A);
+
+ if(_FECalculation)//We need to scale the FE matrix, otherwise the eigenvalues go to zero as the mesh is refined
+ {
+ Vector nodal_volumes(_NunknownNodes);
+ int j_int;
+ for(int i = 0; i< _Nmailles ; i++)//On parcourt les cellules du maillage
+ {
+ Cell Ci = _mesh.getCell(i);
+ for(int j = 0 ; j<_Ndim+1 ; j++)//On parcourt les noeuds de la cellule
+ {
+ if(find(_dirichletNodeIds.begin(),_dirichletNodeIds.end(),Ci.getNodeId(j))==_dirichletNodeIds.end())//node j is an unknown node (not a Dirichlet node)
+ {
+ j_int=unknownNodeIndex(Ci.getNodeId(j), _dirichletNodeIds);//indice du noeud j en tant que noeud inconnu
+ nodal_volumes[j_int]+=Ci.getMeasure()/(_Ndim+1);
+ }
+ }
+ }
+ for( j_int = 0; j_int< _NunknownNodes ; j_int++)
+ nodal_volumes[j_int]=1/nodal_volumes[j_int];
+ A.leftDiagonalScale(nodal_volumes);
+ }
+
+ return A.getEigenvalues( nev, which, tol);
+}
+std::vector< Vector >
+StationaryDiffusionEquation::getEigenvectors(int nev, EPSWhich which, double tol) const
+{
+ SparseMatrixPetsc A = SparseMatrixPetsc(_A);
+ return A.getEigenvectors( nev, which, tol);
+}
+Field
+StationaryDiffusionEquation::getEigenvectorsField(int nev, EPSWhich which, double tol) const
+{
+ SparseMatrixPetsc A = SparseMatrixPetsc(_A);
+ MEDCoupling::DataArrayDouble * d = A.getEigenvectorsDataArrayDouble( nev, which, tol);
+ Field my_eigenfield;
+
+ if(_FECalculation)
+ my_eigenfield = Field("Eigenvectors field", NODES, _mesh, nev);
+ else
+ my_eigenfield = Field("Eigenvectors field", CELLS, _mesh, nev);
+
+ my_eigenfield.setFieldByDataArrayDouble(d);
+
+ return my_eigenfield;
+}
using namespace std;
-TransportEquation::TransportEquation(phaseType fluid, pressureEstimate pEstimate,vector<double> vitesseTransport){
- if(pEstimate==around1bar300K){
+TransportEquation::TransportEquation(phase fluid, pressureMagnitude pEstimate,vector<double> vitesseTransport){
+ if(pEstimate==around1bar300KTransport){
_Tref=300;
- if(fluid==Gas){//Nitrogen pressure 1 bar and temperature 27°C
+ if(fluid==GasPhase){//Nitrogen pressure 1 bar and temperature 27°C
_href=3.11e5; //nitrogen enthalpy at 1 bar and 300K
_cpref=1041;//nitrogen specific heat at constant pressure 1 bar and 300K
//saturation data for nitrogen at 1 bar and 77K
}
else{//around155bars600K
_Tref=618;//=Tsat
- if(fluid==Gas){
+ if(fluid==GasPhase){
_href=2.675e6; //Gas enthalpy at 155 bars and 618K
_cpref=14001;//Gas specific heat at 155 bar and 618K
}
}
nameOfGroup = Fj.getGroupName();
- if (_limitField[nameOfGroup].bcType==Neumann){
+ if (_limitField[nameOfGroup].bcType==NeumannTransport){
MatSetValue(_A,idm,idm,inv_dxi*un, ADD_VALUES);
}
- else if(_limitField[nameOfGroup].bcType==Inlet){
+ else if(_limitField[nameOfGroup].bcType==InletTransport){
if(un>0){
MatSetValue(_A,idm,idm,inv_dxi*un, ADD_VALUES);
}
else {
cout<<"!!!!!!!!!!!!!!! Error TransportEquation::computeTransportMatrix() !!!!!!!!!!"<<endl;
cout<<"!!!!!!!!! Boundary condition not treated for boundary named "<<nameOfGroup<< ", _limitField[nameOfGroup].bcType= "<<_limitField[nameOfGroup].bcType<<" !!!!!!!!!!!!!! "<<endl;
- cout<<"Accepted boundary conditions are Neumann "<<Neumann<< " and Inlet "<< Inlet <<endl;
+ cout<<"Accepted boundary conditions are NeumannTransport "<<NeumannTransport<< " and InletTransport "<< InletTransport <<endl;
throw CdmathException("Boundary condition not accepted");
}
// if Fj is inside the domain
_Rho.setTime(_time,_nbTimeStep);
// create mesh and component info
- if (_nbTimeStep ==0){
+ if (_nbTimeStep ==0 || _restartWithNewFileName){
+ if (_restartWithNewFileName)
+ _restartWithNewFileName=false;
string suppress ="rm -rf "+resultFile+"_*";
system(suppress.c_str());//Nettoyage des précédents calculs identiques
}
}
}
+
+vector<string> TransportEquation::getOutputFieldsNames()
+{
+ vector<string> result(2);
+
+ result[0]="Enthalpy";
+ result[1]="FluidTemperature";
+
+ return result;
+}
+
+Field& TransportEquation::getOutputField(const string& nameField )
+{
+ if(nameField=="FluidTemperature" || nameField=="FLUIDTEMPERATURE" )
+ return getFluidTemperatureField();
+ else if(nameField=="Enthalpy" || nameField=="ENTHALPY" || nameField=="Enthalpie" || nameField=="ENTHALPY" )
+ return getEnthalpyField();
+ else
+ {
+ cout<<"Error : Field name "<< nameField << " does not exist, call getOutputFieldsNames first" << endl;
+ throw CdmathException("TransportEquation::getOutputField error : Unknown Field name");
+ }
+}
+
In the following steps we assume that [PETSC](https://www.mcs.anl.gov/petsc/) (version 3.4 or more recent) has been installed with CDMATH with the process described above.
You need to set the following variables
-- `CDMATH_DIR`, the path to your CDMATH installation, for example `~/workspace/cdmath/cdmath_install//share/petsc-3.8.3 `
+- `CDMATH_INSTALL`, the path to your CDMATH installation, for example `~/workspace/cdmath/cdmath_install//share/petsc-3.8.3 `
- `PETSC_DIR`, the path to your PETSc installation. If [PETSC](https://www.mcs.anl.gov/petsc/) was installed by CDMATH then [CDMATH-Toolbox](https://github.com/ndjinga/CDMATH) can be defined as `~/workspace/cdmath/cdmath_install`
- `PETSC_ARCH`, the type of installation used (usually arch-linux2-c-opt or linux-gnu-c-opt)
- `cd CoreFlows_build `
Then run the command
-- `../CDMATH-CoreFlows-master/configure --prefix=../CDMATH-CoreFlows_install/ --with-petsc-dir=$PETSC_DIR --with-petsc-arch=$PETSC_ARCH --with-cdmath-dir=$CDMATH_DIR --with-python --with-doc`
+- `../CDMATH-CoreFlows-master/configure --prefix=../CDMATH-CoreFlows_install/ --with-petsc-dir=$PETSC_DIR --with-petsc-arch=$PETSC_ARCH --with-cdmath-dir=$CDMATH_INSTALL --with-python --with-doc`
- `make doc install`
You can add the following optional commands
if (NOT (IS_DIRECTORY ${CDMATH_INCLUDES}) )
message (SEND_ERROR "CDMATH_INCLUDES can not be used, ${CDMATH_INCLUDES} does not exist.")
endif ()
+set(MED_INCLUDES $ENV{MEDFILE_INCLUDE_DIRS})
+if (NOT (IS_DIRECTORY ${MED_INCLUDES}) )
+ message (SEND_ERROR "MED_INCLUDES can not be used, ${MED_INCLUDES} does not exist.")
+endif ()
+set(MEDCOUPLING_INCLUDES $ENV{MEDCOUPLING_INCLUDE_DIR})
+if (NOT (IS_DIRECTORY ${MEDCOUPLING_INCLUDES}) )
+ message (SEND_ERROR "MEDCOUPLING_INCLUDES can not be used, ${MEDCOUPLING_INCLUDES} does not exist.")
+endif ()
# CDMATH libraries against which to link
# This sets the variable ${CDMATH_LIBRARIES}.
if ( NOT (IS_DIRECTORY ${CDMATH_LIBDIR}) )
message (SEND_ERROR "CDMATH_LIBDIR can not be used, ${CDMATH_LIBDIR} does not exist.")
endif ()
-find_library (INTERPKERNEL_LIB NAMES interpkernel PATHS ${CDMATH_LIBDIR}/medcoupling)
-find_library (MEDC_LIB NAMES medC PATHS ${CDMATH_LIBDIR})
-find_library (MEDLOADER_LIB NAMES medloader PATHS ${CDMATH_LIBDIR}/medcoupling)
-find_library (MEDCOUPLING_LIB NAMES medcoupling PATHS ${CDMATH_LIBDIR}/medcoupling)
find_library (CDMATHBASE_LIB NAMES base PATHS ${CDMATH_LIBDIR})
find_library (CDMATHMESH_LIB NAMES mesh PATHS ${CDMATH_LIBDIR})
-#find_library (CDMATHLINEARSOLVER_LIB NAMES linearsolver PATHS ${CDMATH_LIBDIR})
+find_library (MEDC_LIB NAMES medC PATHS $ENV{MEDFILE_LIBRARIES})
+find_library (MEDLOADER_LIB NAMES medloader PATHS $ENV{MEDCOUPLING_LIBRARIES})
+find_library (MEDCOUPLING_LIB NAMES medcoupling PATHS $ENV{MEDCOUPLING_LIBRARIES})
+find_library (CDMATHLINEARSOLVER_LIB NAMES linearsolver PATHS ${CDMATH_LIBDIR})
set (CDMATH_LIBRARIES
- ${INTERPKERNEL_LIB}
${MEDC_LIB}
${MEDLOADER_LIB}
${MEDCOUPLING_LIB}
${CDMATHBASE_LIB}
${CDMATHMESH_LIB}
-# ${CDMATHLINEARSOLVER_LIB}
+ ${CDMATHLINEARSOLVER_LIB}
)
#RedHat paths
/usr/include/petsc
# Debian paths
- /usr/lib/petscdir/3.7.6 /usr/lib/petscdir/3.7
- /usr/lib/petscdir/3.6.2 /usr/lib/petscdir/3.6
+ /usr/lib/petscdir/3.12.4 /usr/lib/petscdir/3.12 #Ubuntu 20.04
+ /usr/lib/petscdir/3.7.6 /usr/lib/petscdir/3.7 #Ubuntu 18.04
+ /usr/lib/petscdir/3.6.2 /usr/lib/petscdir/3.6 #Ubuntu 16.04
/usr/lib/petscdir/3.5.1 /usr/lib/petscdir/3.5
/usr/lib/petscdir/3.4.2 /usr/lib/petscdir/3.4
/usr/lib/petscdir/3.3 /usr/lib/petscdir/3.2 /usr/lib/petscdir/3.1
if (PETSC_DIR AND NOT PETSC_ARCH)
set (_petsc_arches
$ENV{PETSC_ARCH} # If set, use environment variable first
- linux-gnu-c-debug linux-gnu-c-opt # Debian defaults (petsc compilation)
+ linux-gnu-c-debug linux-gnu-c-opt # old Debian defaults (petsc compilation)
+ arch-linux-c-opt or arch-linux-c-debug # new Debian defaults (petsc compilation)
x86_64-linux-gnu-real i686-linux-gnu-real # Debian defaults (petsc system installation)
- arch-linux2-c-opt or arch-linux2-c-debug # RedHat defaults (petsc compilation)
+ arch-linux2-c-opt or arch-linux2-c-debug # old RedHat defaults (petsc compilation)
x86_64-redhat-linux-gnu i686-redhat-linux-gnu # RedHat defaults (petsc apt installation)
x86_64-unknown-linux-gnu i386-unknown-linux-gnu)
set (petscconf "NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
IF(NOT PYTHON_ROOT_USER)
SET(PYTHON_ROOT_USER $ENV{PYTHONHOME})
ENDIF(NOT PYTHON_ROOT_USER)
+ IF(NOT PYTHON_ROOT_USER)
+ SET(PYTHON_ROOT_USER /usr)
+ ENDIF(NOT PYTHON_ROOT_USER)
ENDIF(PYTHON_STATUS)
# ------
export PETSC_DIR=@PETSC_DIR@
export PETSC_ARCH=@PETSC_ARCH@
export PETSC_INCLUDES=@PETSC_INCLUDES_PATH@
-export PETSC_LIBRARIES=@PETSC_LIBRARIES@
#-------------------------------------------------------------------------------------------------------------------
export CoreFlows=$CoreFlows_INSTALL/bin/Executable/CoreFlowsMainExe
-export LD_LIBRARY_PATH=$PETSC_DIR/$PETSC_ARCH/lib:${PETSC_DIR}/lib:/usr/lib64/:$CoreFlows_INSTALL/lib:$PETSC_LIBRARIES:${LD_LIBRARY_PATH}
-export PYTHONPATH=$CoreFlows_INSTALL/lib:$CoreFlows_INSTALL/lib/CoreFlows_Python:$CoreFlows_INSTALL/bin/CoreFlows_Python:$CoreFlows_INSTALL/lib/python2.7/site-packages/salome:${PYTHONPATH}
+export LD_LIBRARY_PATH=$CoreFlows_INSTALL/lib:$CDMATH_DIR/lib:${PETSC_DIR}/${PETSC_ARCH}/lib:${MEDCOUPLING_LIBRARIES}:${MEDFILE_C_LIBRARIES}:${LD_LIBRARY_PATH}
+export PYTHONPATH=$CoreFlows_INSTALL/lib:$CoreFlows_INSTALL/lib/CoreFlows_Python:$CoreFlows_INSTALL/bin/CoreFlows_Python:$CoreFlows_INSTALL/lib/python2.7/site-packages/salome:$CDMATH_DIR/lib/cdmath:$CDMATH_DIR/bin/cdmath:$CDMATH_DIR/bin/cdmath/postprocessing:${PETSC_DIR}/${PETSC_ARCH}/lib:${MEDCOUPLING_LIBRARIES}:${MEDFILE_C_LIBRARIES}:${PYTHONPATH}
export CoreFlowsGUI=$CoreFlows_INSTALL/bin/salome/CoreFlows_Standalone.py
--- /dev/null
+project(testC)
+
+INCLUDE_DIRECTORIES(
+ ${CoreFlows_INCLUDES} #
+)
+
+
+SET(_extra_lib_CoreFlows CoreFlows ${PETSC_LIBRARIES} ${CDMATH_LIBRARIES})
+
+
+if(CMAKE_COMPILER_IS_GNUCXX)
+ if (CMAKE_BUILD_TYPE STREQUAL Debug)
+ include(CodeCoverage)
+ setup_target_for_coverage(cov ctest coverage)
+ endif()
+endif()
+
+
+##################################### test generation with ctest
+
+# this function creates a target and a ctest test
+function(CreateTestExec SourceTestFile libList)
+ get_filename_component( FILE_BASENAME ${SourceTestFile} NAME_WE) # <path>/testxxx.c --> testxxx
+ set( EXECNAME "${FILE_BASENAME}.exe" ) # testxxx --> testxxx.exe
+ add_executable(${EXECNAME} ${SourceTestFile}) # compilation of the testxxx.exe
+ set_target_properties(${EXECNAME} PROPERTIES COMPILE_FLAGS "")
+ target_link_libraries(${EXECNAME} ${libList}) # provide required lib for testxxx.exe
+ add_test(${FILE_BASENAME} ${EXECNAME} "./${EXECNAME}") # adding a ctest Test
+endfunction(CreateTestExec)
+
+# this function creates a target and a ctest test
+# and also create install rules for copying the example
+# in the install dir
+function(CreateTestExecAndInstall SourceTestFile libList)
+ get_filename_component( FILE_BASENAME ${SourceTestFile} NAME_WE) # <path>/testxxx.c --> testxxx
+ set( EXECNAME "${FILE_BASENAME}.exe" ) # testxxx --> testxxx.exe
+ add_executable(${EXECNAME} ${SourceTestFile}) # compilation of the testxxx.exe
+ set_target_properties(${EXECNAME} PROPERTIES COMPILE_FLAGS "")
+ target_link_libraries(${EXECNAME} ${libList}) # provide required lib for testxxx.exe
+ add_test(NAME ${EXECNAME} COMMAND "./${EXECNAME}") # adding a ctest Test
+ install(TARGETS ${EXECNAME} DESTINATION share/examples)
+endfunction(CreateTestExecAndInstall)
+
+
+set( libs_for_tests ${_extra_lib_CoreFlows} )
+
+# copy tests resources (med files etc.) into the build directory
+file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../resources DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+
+CreateTestExecAndInstall(CoupledTransportDiffusionEquations_1DHeatedChannel.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(DiffusionEquation_1DHeatedRod.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(DiffusionEquation_1DHeatedRod_FE.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(DriftModel_1DBoilingAssembly.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(DriftModel_1DBoilingChannel.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(DriftModel_1DChannelGravity.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(DriftModel_1DDepressurisation.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(DriftModel_1DPorosityJump.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(DriftModel_1DPressureLoss.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(DriftModel_1DRiemannProblem.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(DriftModel_1DVidangeReservoir.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(DriftModel_2DInclinedBoilingChannel.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(DriftModel_2DInclinedChannelGravity.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(DriftModel_2DInclinedChannelGravityBarriers.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(DriftModel_3DCanalCloison.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(FiveEqsTwoFluid_1DBoilingChannel.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(FiveEqsTwoFluid_1DDepressurisation.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(FiveEqsTwoFluid_1DRiemannProblem.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(FiveEqsTwoFluid_2DInclinedBoilingChannel.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(FiveEqsTwoFluid_2DInclinedSedimentation.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(IsothermalTwoFluid_1DDepressurisation.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(IsothermalTwoFluid_1DRiemannProblem.cxx "${libs_for_tests}" )
+#CreateTestExecAndInstall(IsothermalTwoFluid_1DSedimentation.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(IsothermalTwoFluid_2DInclinedSedimentation.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(IsothermalTwoFluid_2DVidangeReservoir.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_1DDepressurisation.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_1DHeatedChannel.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_1DPorosityJump.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_1DRiemannProblem.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_2DHeatDrivenCavity.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_2DHeatDrivenCavity_unstructured.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_2DHeatedChannelInclined.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_2DLidDrivenCavity.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_2DLidDrivenCavity_unstructured.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_2DSphericalExplosion_unstructured.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_3DSphericalExplosion_unstructured.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_2DWallHeatedChannel_ChangeSect.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_2DWallHeatedChannel.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_3DHeatDrivenCavity.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(SinglePhase_HeatedWire_2Branches.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(TransportEquation_1DHeatedChannel.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(StationaryDiffusionEquation_2DEF_StructuredTriangles.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(StationaryDiffusionEquation_2DEF_StructuredTriangles_Neumann.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(StationaryDiffusionEquation_2DEF_UnstructuredTriangles.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(StationaryDiffusionEquation_2DFV_StructuredTriangles.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(StationaryDiffusionEquation_2DFV_StructuredTriangles_Neumann.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(StationaryDiffusionEquation_2DFV_StructuredSquares.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(StationaryDiffusionEquation_3DEF_StructuredTetrahedra.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(StationaryDiffusionEquation_3DFV_StructuredTetrahedra.cxx "${libs_for_tests}" )
+CreateTestExecAndInstall(testEOS.cxx "${libs_for_tests}" )
+
--- /dev/null
+#include "TransportEquation.hxx"\r
+#include "DiffusionEquation.hxx"\r
+\r
+using namespace std;\r
+\r
+#define PI 3.14159265\r
+\r
+void power_field_CoupledTransportDiffusionTest(Field & Phi){\r
+ double L=4.2;\r
+ double lambda=0.2;\r
+ double phi=1e5;\r
+ double x;\r
+ Mesh M = Phi.getMesh();\r
+ int nbCells = M.getNumberOfCells();\r
+ for (int j = 0; j < nbCells; j++) {\r
+ x=M.getCell(j).x();\r
+ Phi(j) = phi*cos(PI*(x-L/2)/(L+lambda));\r
+ }\r
+}\r
+\r
+int main(int argc, char** argv)\r
+{\r
+ //Preprocessing: mesh and group creation\r
+ double xinf=0.0;\r
+ double xsup=4.2;\r
+ int nx=100;\r
+ double eps=1.E-6;\r
+ cout << "Building of the diffusion mesh with "<<nx<<" cells" << endl;\r
+ Mesh diffusionMesh(xinf,xsup,nx);\r
+ diffusionMesh.setGroupAtPlan(xsup,0,eps,"Neumann");\r
+ diffusionMesh.setGroupAtPlan(xinf,0,eps,"Neumann");\r
+\r
+ cout << "Building of the transport mesh with "<<nx<<" cells" << endl;\r
+ Mesh transportMesh(xinf,xsup,nx);\r
+ transportMesh.setGroupAtPlan(xsup,0,eps,"Neumann");\r
+ transportMesh.setGroupAtPlan(xinf,0,eps,"Inlet");\r
+ int spaceDim = 1;\r
+\r
+ // Boundary conditions \r
+ map<string, LimitFieldDiffusion> boundaryFieldsDiffusion;\r
+ map<string, LimitFieldTransport> boundaryFieldsTransport;\r
+\r
+ // Boundary conditions for the solid\r
+ LimitFieldDiffusion limitNeumann;\r
+ limitNeumann.bcType=NeumannDiffusion;\r
+ boundaryFieldsDiffusion["Neumann"] = limitNeumann;\r
+\r
+ // Boundary conditions for the fluid\r
+ LimitFieldTransport limitInlet;\r
+ limitInlet.bcType=InletTransport;\r
+ limitInlet.h =1.3e6;//Inlet water enthalpy\r
+ boundaryFieldsTransport["Inlet"] = limitInlet;\r
+\r
+ //Set the fluid transport velocity\r
+ vector<double> transportVelocity(1,5);//Vitesse du fluide\r
+\r
+ //Solid parameters\r
+ double cp_ur=300;//Uranium specific heat\r
+ double rho_ur=10000;//Uranium density\r
+ double lambda_ur=5;\r
+\r
+ TransportEquation myTransportEquation(LiquidPhase, around155bars600KTransport,transportVelocity);\r
+ Field fluidEnthalpy("Enthalpie", CELLS, transportMesh, 1);\r
+ bool FECalculation=false;\r
+ DiffusionEquation myDiffusionEquation(spaceDim,FECalculation,rho_ur, cp_ur, lambda_ur);\r
+\r
+ Field solidTemp("Solid temperature", CELLS, diffusionMesh, 1);\r
+ Field fluidTemp("Fluid temperature", CELLS, transportMesh, 1);\r
+\r
+ double heatTransfertCoeff=10000;//fluid/solid heat exchange coefficient\r
+ myTransportEquation.setHeatTransfertCoeff(heatTransfertCoeff);\r
+ myDiffusionEquation.setHeatTransfertCoeff(heatTransfertCoeff);\r
+\r
+ //Set heat source in the solid\r
+ Field Phi("Heat power field", CELLS, diffusionMesh, 1);\r
+ power_field_CoupledTransportDiffusionTest(Phi);\r
+ myDiffusionEquation.setHeatPowerField(Phi);\r
+ Phi.writeVTK("1DheatPowerField");\r
+\r
+ //Initial field creation\r
+ Vector VV_Constant(1);\r
+ VV_Constant(0) = 623;//Rod clad temperature nucleaire\r
+\r
+ cout << "Construction de la condition initiale " << endl;\r
+ // generate initial condition\r
+ myDiffusionEquation.setInitialFieldConstant(diffusionMesh,VV_Constant);\r
+\r
+\r
+ VV_Constant(0) = 1.3e6;\r
+ myTransportEquation.setInitialFieldConstant(transportMesh,VV_Constant);\r
+\r
+ //set the boundary conditions\r
+ myTransportEquation.setBoundaryFields(boundaryFieldsTransport);//Neumann and Inlet BC will be used\r
+ myDiffusionEquation.setBoundaryFields(boundaryFieldsDiffusion);//Only Neumann BC will be used\r
+\r
+ // set the numerical method\r
+ myDiffusionEquation.setTimeScheme( Explicit);\r
+ myTransportEquation.setTimeScheme( Explicit);\r
+\r
+ // name result file\r
+ string fluidFileName = "1DFluidEnthalpy";\r
+ string solidFileName = "1DSolidTemperature";\r
+\r
+ // parameters calculation\r
+ unsigned MaxNbOfTimeStep =3;\r
+ int freqSave = 10;\r
+ double cfl = 0.5;\r
+ double maxTime = 1000000;\r
+ double precision = 1e-6;\r
+\r
+ myDiffusionEquation.setCFL(cfl);\r
+ myDiffusionEquation.setPrecision(precision);\r
+ myDiffusionEquation.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
+ myDiffusionEquation.setTimeMax(maxTime);\r
+ myDiffusionEquation.setFreqSave(freqSave);\r
+ myDiffusionEquation.setFileName(solidFileName);\r
+\r
+ myTransportEquation.setCFL(cfl);\r
+ myTransportEquation.setPrecision(precision);\r
+ myTransportEquation.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
+ myTransportEquation.setTimeMax(maxTime);\r
+ myTransportEquation.setFreqSave(freqSave);\r
+ myTransportEquation.setFileName(fluidFileName);\r
+\r
+ // loop on time steps\r
+ myDiffusionEquation.initialize();\r
+ myTransportEquation.initialize();\r
+\r
+ double time=0,dt=0;\r
+ int nbTimeStep=0;\r
+ bool stop=false, stop_transport=false, stop_diffusion=false; // Does the Problem want to stop (error) ?\r
+ bool ok; // Is the time interval successfully solved ?\r
+\r
+ // Time step loop\r
+ while(!stop && !(myDiffusionEquation.isStationary() && myTransportEquation.isStationary()) &&time<maxTime && nbTimeStep<MaxNbOfTimeStep)\r
+ {\r
+ ok=false; // Is the time interval successfully solved ?\r
+ fluidTemp=myTransportEquation.getFluidTemperatureField();\r
+ solidTemp=myDiffusionEquation.getRodTemperatureField();\r
+ myDiffusionEquation.setFluidTemperatureField(fluidTemp);\r
+ myTransportEquation.setRodTemperatureField(solidTemp);\r
+ // Guess the next time step length\r
+ dt=min(myDiffusionEquation.computeTimeStep(stop),myTransportEquation.computeTimeStep(stop));\r
+ if (stop){\r
+ cout << "Failed computing time step "<<nbTimeStep<<", time = " << time <<", dt= "<<dt<<", stopping calculation"<< endl;\r
+ break;\r
+ }\r
+ // Loop on the time interval tries\r
+ while (!ok && !stop )\r
+ {\r
+ stop_transport=!myTransportEquation.initTimeStep(dt);\r
+ stop_diffusion=!myDiffusionEquation.initTimeStep(dt);\r
+ stop=stop_diffusion && stop_transport;\r
+\r
+ // Prepare the next time step\r
+ if (stop){\r
+ cout << "Failed initializing time step "<<nbTimeStep<<", time = " << time <<", dt= "<<dt<<", stopping calculation"<< endl;\r
+ break;\r
+ }\r
+ // Solve the next time step\r
+ ok=myDiffusionEquation.solveTimeStep()&& myTransportEquation.solveTimeStep();\r
+\r
+ if (!ok) // The resolution failed, try with a new time interval.\r
+ {\r
+ myDiffusionEquation.abortTimeStep();\r
+ myTransportEquation.abortTimeStep();\r
+ cout << "Failed solving time step "<<nbTimeStep<<", time = " << time<<" dt= "<<dt<<", cfl= "<<cfl <<", stopping calculation"<< endl;\r
+ stop=true; // Impossible to solve the next time step, the Problem has given up\r
+ break;\r
+ }\r
+ else // The resolution was successful, validate and go to the next time step.\r
+ {\r
+ cout << "Time step = "<< nbTimeStep << ", dt = "<< dt <<", time = "<<time << endl;\r
+ myDiffusionEquation.validateTimeStep();\r
+ myTransportEquation.validateTimeStep();\r
+ time=myDiffusionEquation.presentTime();\r
+ nbTimeStep++;\r
+ }\r
+ }\r
+ }\r
+ if(myDiffusionEquation.isStationary() && myTransportEquation.isStationary())\r
+ cout << "Stationary state reached" <<endl;\r
+ else if(time>=maxTime)\r
+ cout<<"Maximum time "<<maxTime<<" reached"<<endl;\r
+ else if(nbTimeStep>=MaxNbOfTimeStep)\r
+ cout<<"Maximum number of time steps "<<MaxNbOfTimeStep<<" reached"<<endl;\r
+ else\r
+ cout<<"Error problem wants to stop!"<<endl;\r
+\r
+ cout << "End of calculation time t= " << time << " at time step number "<< nbTimeStep << endl;\r
+ if (ok)\r
+ cout << "Coupled simulation "<<fluidFileName<<" and "<<solidFileName<<" was successful !" << endl;\r
+ else\r
+ cout << "Coupled simulation "<<fluidFileName<<" and "<<solidFileName<<" failed ! " << endl;\r
+\r
+ cout << "------------ End of calculation -----------" << endl;\r
+ myDiffusionEquation.terminate();\r
+ myTransportEquation.terminate();\r
+\r
+ return EXIT_SUCCESS;\r
+}\r
--- /dev/null
+#include "DiffusionEquation.hxx"\r
+\r
+using namespace std;\r
+\r
+#define PI 3.14159265\r
+\r
+void power_field_diffusionTest(Field & Phi){\r
+ double L=4.2;\r
+ double lambda=0.2;\r
+ double phi=1e5;\r
+ double x;\r
+ Mesh M = Phi.getMesh();\r
+ int nbCells = M.getNumberOfCells();\r
+ for (int j = 0; j < nbCells; j++) {\r
+ x=M.getCell(j).x();\r
+ Phi(j) = phi*cos(PI*(x-L/2)/(L+lambda));\r
+ }\r
+}\r
+\r
+int main(int argc, char** argv)\r
+{\r
+ //Preprocessing: mesh and group creation\r
+ double xinf=0.0;\r
+ double xsup=4.2;\r
+ int nx=10;\r
+ cout << "Building of a 1D mesh with "<<nx<<" cells" << endl;\r
+ Mesh M(xinf,xsup,nx);\r
+ double eps=1.E-6;\r
+ M.setGroupAtPlan(xsup,0,eps,"Neumann");\r
+ M.setGroupAtPlan(xinf,0,eps,"Neumann");\r
+ int spaceDim = M.getSpaceDimension();\r
+\r
+\r
+ //Solid parameters\r
+ double cp_ur=300;//Uranium specific heat\r
+ double rho_ur=10000;//Uranium density\r
+ double lambda_ur=5;\r
+ \r
+ bool FEcalculation=false;\r
+ DiffusionEquation myProblem(spaceDim,FEcalculation,rho_ur,cp_ur,lambda_ur);\r
+ Field VV("Solid temperature", CELLS, M, 1);\r
+\r
+ //Set fluid temperature (temperature du fluide)\r
+ double fluidTemp=573;//fluid mean temperature\r
+ double heatTransfertCoeff=1000;//fluid/solid exchange coefficient\r
+ myProblem.setFluidTemperature(fluidTemp);\r
+ myProblem.setHeatTransfertCoeff(heatTransfertCoeff);\r
+ //Set heat source\r
+ Field Phi("Heat power field", CELLS, M, 1);\r
+ power_field_diffusionTest(Phi);\r
+ myProblem.setHeatPowerField(Phi);\r
+ Phi.writeVTK("1DheatPowerField");\r
+\r
+ //Initial field creation\r
+ Vector VV_Constant(1);\r
+ VV_Constant(0) = 623;//Rod clad temperature\r
+\r
+ cout << "Building initial data" << endl;\r
+ myProblem.setInitialFieldConstant(M,VV_Constant);\r
+\r
+ //set the boundary conditions\r
+ myProblem.setNeumannBoundaryCondition("Neumann");\r
+\r
+ // set the numerical method\r
+ myProblem.setTimeScheme( Explicit);\r
+\r
+ // name result file\r
+ string fileName = "1DRodTemperature_FV";\r
+\r
+ // parameters calculation\r
+ unsigned MaxNbOfTimeStep =3;\r
+ int freqSave = 1;\r
+ double cfl = 0.5;\r
+ double maxTime = 1000000;\r
+ double precision = 1e-6;\r
+\r
+ myProblem.setCFL(cfl);\r
+ myProblem.setPrecision(precision);\r
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
+ myProblem.setTimeMax(maxTime);\r
+ myProblem.setFreqSave(freqSave);\r
+ myProblem.setFileName(fileName);\r
+\r
+ // set display option to monitor the calculation\r
+ myProblem.setVerbose( true);\r
+ //set file saving format\r
+ myProblem.setSaveFileFormat(CSV);\r
+\r
+ // evolution\r
+ myProblem.initialize();\r
+ bool ok = myProblem.run();\r
+ if (ok)\r
+ cout << "Simulation "<<fileName<<" is successful !" << endl;\r
+ else\r
+ cout << "Simulation "<<fileName<<" failed ! " << endl;\r
+\r
+ cout << "------------ End of calculation -----------" << endl;\r
+ myProblem.terminate();\r
+\r
+ return EXIT_SUCCESS;\r
+}\r
--- /dev/null
+#include "DiffusionEquation.hxx"\r
+\r
+using namespace std;\r
+\r
+#define PI 3.14159265\r
+\r
+void power_field_diffusionTest(Field & Phi){\r
+ double L=4.2;\r
+ double lambda=0.2;\r
+ double phi=1e5;\r
+ double x;\r
+ Mesh M = Phi.getMesh();\r
+ int nbNodes = M.getNumberOfNodes();\r
+ for (int j = 0; j < nbNodes; j++) {\r
+ x=M.getNode(j).x();\r
+ Phi(j) = phi*cos(PI*(x-L/2)/(L+lambda));\r
+ }\r
+}\r
+\r
+int main(int argc, char** argv)\r
+{\r
+ //Preprocessing: mesh and group creation\r
+ double xinf=0.0;\r
+ double xsup=4.2;\r
+ int nx=10;\r
+ cout << "Building of a 1D mesh with "<<nx<<" cells" << endl;\r
+ Mesh M(xinf,xsup,nx);\r
+ double eps=1.E-6;\r
+ M.setGroupAtPlan(xsup,0,eps,"Neumann");\r
+ M.setGroupAtPlan(xinf,0,eps,"Neumann");\r
+ int spaceDim = M.getSpaceDimension();\r
+\r
+\r
+ //Solid parameters\r
+ double cp_ur=300;//Uranium specific heat\r
+ double rho_ur=10000;//Uranium density\r
+ double lambda_ur=5;\r
+ \r
+ bool FEcalculation=true;\r
+ DiffusionEquation myProblem(spaceDim,FEcalculation,rho_ur,cp_ur,lambda_ur);\r
+ Field VV("Solid temperature", NODES, M, 1);\r
+\r
+ //Set fluid temperature (temperature du fluide)\r
+ double fluidTemp=573;//fluid mean temperature\r
+ double heatTransfertCoeff=1000;//fluid/solid exchange coefficient\r
+ myProblem.setFluidTemperature(fluidTemp);\r
+ myProblem.setHeatTransfertCoeff(heatTransfertCoeff);\r
+ //Set heat source\r
+ Field Phi("Heat power field", NODES, M, 1);\r
+ power_field_diffusionTest(Phi);\r
+ myProblem.setHeatPowerField(Phi);\r
+ Phi.writeVTK("1DheatPowerField");\r
+\r
+ //Initial field creation\r
+ Vector VV_Constant(1);\r
+ VV_Constant(0) = 623;//Rod clad temperature\r
+\r
+ cout << "Building initial data" << endl;\r
+ myProblem.setInitialFieldConstant(M,VV_Constant);\r
+\r
+ //set the boundary conditions\r
+ myProblem.setNeumannBoundaryCondition("Neumann");\r
+\r
+ // set the numerical method\r
+ myProblem.setTimeScheme( Explicit);\r
+\r
+ // name result file\r
+ string fileName = "1DRodTemperature_FE";\r
+\r
+ // parameters calculation\r
+ unsigned MaxNbOfTimeStep =3;\r
+ int freqSave = 1;\r
+ double cfl = 0.5;\r
+ double maxTime = 1000000;\r
+ double precision = 1e-6;\r
+\r
+ myProblem.setCFL(cfl);\r
+ myProblem.setPrecision(precision);\r
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
+ myProblem.setTimeMax(maxTime);\r
+ myProblem.setFreqSave(freqSave);\r
+ myProblem.setFileName(fileName);\r
+\r
+ // set display option to monitor the calculation\r
+ myProblem.setVerbose( true);\r
+ //set file saving format\r
+ myProblem.setSaveFileFormat(CSV);\r
+\r
+ // evolution\r
+ myProblem.initialize();\r
+ bool ok = myProblem.run();\r
+ if (ok)\r
+ cout << "Simulation "<<fileName<<" is successful !" << endl;\r
+ else\r
+ cout << "Simulation "<<fileName<<" failed ! " << endl;\r
+\r
+ cout << "------------ End of calculation -----------" << endl;\r
+ myProblem.terminate();\r
+\r
+ return EXIT_SUCCESS;\r
+}\r
--- /dev/null
+#include "DriftModel.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //setting mesh and groups
+ cout << "Building a regular grid " << endl;
+ double xinf=0.0;
+ double xsup=4.2;
+ double xinfcore=1.4;
+ double xsupcore=2.8;
+
+ int nx=3;//50;
+ Mesh M(xinf,xsup,nx);
+ double eps=1.E-8;
+ M.setGroupAtPlan(xsup,0,eps,"Outlet");
+ M.setGroupAtPlan(xinf,0,eps,"Inlet");
+ int spaceDim = M.getSpaceDimension();
+
+ // setting boundary conditions
+ double inletConc=0;
+ double inletVelocityX=1;
+ double inletTemperature=565;
+ double outletPressure=155e5;
+
+ // setting physical parameters
+ Field heatPowerField=Field("heatPowerField",CELLS, M, 1);
+ int nbCells=M.getNumberOfCells();
+
+ for(int i=0;i<nbCells;i++){
+ double x=M.getCell(i).x();
+
+ if (x> xinfcore && x< xsupcore)
+ heatPowerField[i]=1e8;
+ else
+ heatPowerField[i]=0;
+ }
+ heatPowerField.writeVTK("heatPowerField",true);
+
+ DriftModel myProblem(around155bars600K,spaceDim);
+ int nbPhase = myProblem.getNumberOfPhases();
+ int nVar = myProblem.getNumberOfVariables();
+ Field VV("Primitive", CELLS, M, nVar);
+
+ // Prepare for the initial condition
+ Vector VV_Constant(nVar);
+ // constant vector
+ VV_Constant(0) = 0.;
+ VV_Constant(1) = 155e5;
+ for (int idim=0; idim<spaceDim;idim++)
+ VV_Constant(2+idim) = 1;
+ VV_Constant(nVar-1) = 565;
+
+ //Initial field creation
+ cout << "Building initial field " << endl;
+ myProblem.setInitialFieldConstant( M, VV_Constant);
+
+ //set the boundary conditions
+ myProblem.setInletBoundaryCondition("Inlet",inletTemperature,inletConc,inletVelocityX);
+ myProblem.setOutletBoundaryCondition("Outlet", outletPressure,vector<double>(1,xsup));
+
+ // physical parameters
+ myProblem.setHeatPowerField(heatPowerField);
+
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+ myProblem.setWellBalancedCorrection(true);
+
+ // name the result file
+ string fileName = "DriftModel1DBoilingAssembly";
+
+ // setting numerical parameters
+ unsigned MaxNbOfTimeStep =3 ;
+ int freqSave = 1;
+ double cfl = 0.5;
+ double maxTime = 1;
+ double precision = 1e-7;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveAllFields(true);
+ bool ok;
+
+ // evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "DriftModel.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //setting mesh and groups
+ cout << "Building a regular grid " << endl;
+ double xinf=0.0;
+ double xsup=4.2;
+ int nx=50;//50;
+ Mesh M(xinf,xsup,nx);
+ double eps=1.E-8;
+ M.setGroupAtPlan(xsup,0,eps,"Outlet");
+ M.setGroupAtPlan(xinf,0,eps,"Inlet");
+ int spaceDim = M.getSpaceDimension();
+
+ // setting boundary conditions
+ double inletConc=0;
+ double inletVelocityX=1;
+ double inletTemperature=565;
+ double outletPressure=155e5;
+
+ // setting physical parameters
+ double heatPower=1e8;
+
+ DriftModel myProblem(around155bars600K,spaceDim);
+ int nbPhase = myProblem.getNumberOfPhases();
+ int nVar = myProblem.getNumberOfVariables();
+
+ // Prepare for the initial condition
+ Vector VV_Constant(nVar);
+ // constant vector
+ VV_Constant(0) = 0.;
+ VV_Constant(1) = 155e5;
+ for (int idim=0; idim<spaceDim;idim++)
+ VV_Constant(2+idim) = 1;
+ VV_Constant(nVar-1) = 565;
+
+ //Initial field creation
+ cout << "Setting initial data " << endl;
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ //set the boundary conditions
+ myProblem.setInletBoundaryCondition("Inlet",inletTemperature,inletConc,inletVelocityX);
+ myProblem.setOutletBoundaryCondition("Outlet", outletPressure,vector<double>(1,xsup));
+
+ // physical parameters
+ myProblem.setHeatSource(heatPower);
+
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Implicit);
+ myProblem.setWellBalancedCorrection(true);
+ myProblem.setNonLinearFormulation(VFFC);
+
+ // name the result file
+ string fileName = "Driftmodel1DBoilingChannel";
+
+ // setting numerical parameters
+ unsigned MaxNbOfTimeStep =3 ;
+ int freqSave = 1;
+ double cfl = 100;
+ double maxTime = 1;
+ double precision = 1e-7;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.usePrimitiveVarsInNewton(true);
+ myProblem.saveAllFields(true);
+ myProblem.displayConditionNumber();
+ myProblem.setSaveFileFormat(CSV);
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "DriftModel.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //setting mesh and groups
+ cout << "Building a regular grid " << endl;
+ double xinf=0.0;
+ double xsup=4.2;
+ int nx=50;//50;
+ Mesh M(xinf,xsup,nx);
+ double eps=1.E-8;
+ M.setGroupAtPlan(xsup,0,eps,"Outlet");
+ M.setGroupAtPlan(xinf,0,eps,"Inlet");
+ int spaceDim = M.getSpaceDimension();
+
+ // setting boundary conditions
+ double inletConc=0;
+ double inletVelocityX=1;
+ double inletEnthalpy=1.3e6;
+ double outletPressure=155e5;
+
+ // setting physical parameters
+ vector<double> gravite(spaceDim,0.) ;
+ gravite[0]=-10;
+
+ DriftModel myProblem(around155bars600K,spaceDim);
+ int nbPhase = myProblem.getNumberOfPhases();
+ int nVar = myProblem.getNumberOfVariables();
+
+ // Prepare for the initial condition
+ Vector VV_Constant(nVar);
+ // constant vector
+ VV_Constant(0) = 0.;
+ VV_Constant(1) = 155e5;
+ for (int idim=0; idim<spaceDim;idim++)
+ VV_Constant(2+idim) = 1;
+ VV_Constant(nVar-1) = 578;
+
+ //Initial field creation
+ cout << "Setting initial data " << endl;
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ //set the boundary conditions
+ myProblem.setInletEnthalpyBoundaryCondition("Inlet",inletEnthalpy,inletConc,inletVelocityX);
+ myProblem.setOutletBoundaryCondition("Outlet", outletPressure,vector<double>(1,xsup));
+
+ // physical parameters
+ myProblem.setGravity(gravite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Implicit);
+ myProblem.setWellBalancedCorrection(true);
+ myProblem.setNonLinearFormulation(VFRoe);
+
+ // name the result file
+ string fileName = "Driftmodel_1DChannelGravity";
+
+ // setting numerical parameters
+ unsigned MaxNbOfTimeStep =3 ;
+ int freqSave = 1;
+ double cfl = 100;
+ double maxTime = 1;
+ double precision = 1e-7;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.usePrimitiveVarsInNewton(true);
+ myProblem.saveAllFields(true);
+ myProblem.displayConditionNumber();
+ myProblem.setSaveFileFormat(CSV);
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "DriftModel.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ cout << "Building regular mesh " << endl;
+ double xinf=0.0;
+ double xsup=4.2;
+ int nx=50;
+ int spaceDim = 1;
+
+ //Initial data
+ double initialConc=0;
+ double initialVelocityX =0;
+ double initialTemperature=600;
+ double initialPressure=155e5;
+
+ //Boundary data
+ double wallVelocityX=0;
+ double wallTemperature=563;
+ double outletPressure=50e5;
+
+ DriftModel myProblem(around155bars600K,spaceDim);
+ int nbPhase = myProblem.getNumberOfPhases();
+ int nVar = myProblem.getNumberOfVariables();
+
+ // Prepare the initial condition
+ vector<double> VV_Constant(nVar);
+ VV_Constant[1] = initialConc;
+ VV_Constant[1] = initialPressure;
+ VV_Constant[2] = initialVelocityX;
+ VV_Constant[3] = initialTemperature;
+
+ //Initial field creation
+ cout << "Building initial data " << endl;
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"wall","Outlet");
+
+ //set the boundary conditions
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX);
+ myProblem.setOutletBoundaryCondition("Outlet",outletPressure,vector<double>(1,xsup));
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+ myProblem.setEntropicCorrection(true);
+
+ // name file save
+ string fileName = "1DDepressurisation";
+
+ //Numerical parameters calculation
+ unsigned MaxNbOfTimeStep =3;
+ int freqSave = 1;
+ double cfl = 1;
+ double maxTime = 1;
+ double precision = 1e-7;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ bool ok;
+
+ // evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "DriftModel.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ cout << "Building cartesian mesh" << endl;
+ double xinf=0.0;
+ double xsup=4.2;
+ int nx=100;
+ Mesh M(xinf,xsup,nx);
+ double eps=1.E-8;
+ int spaceDim = M.getSpaceDimension();
+
+ //Initial data
+ double initialConc=0;
+ double initialVelocityX =1;
+ double initialTemperature=600;
+ double initialPressure=155e5;
+
+ // physical parameters
+ Field porosityField("Porosity", CELLS, M, 1);
+ for(int i=0;i<M.getNumberOfCells();i++){
+ double x=M.getCell(i).x();
+ if (x> (xsup-xinf)/3 && x< 2*(xsup-xinf)/3)
+ porosityField[i]=0.5;
+ else
+ porosityField[i]=1;
+ }
+ porosityField.writeVTK("PorosityField",true);
+
+
+ DriftModel myProblem(around155bars600K,spaceDim);
+ int nVar = myProblem.getNumberOfVariables();
+
+ // Prepare for the initial condition
+ vector<double> VV_Constant(nVar);
+ // constant vector
+ VV_Constant[1] = initialConc;
+ VV_Constant[1] = initialPressure;
+ VV_Constant[2] = initialVelocityX;
+ VV_Constant[3] = initialTemperature;
+
+ cout << "Building initial data " << endl;
+
+ // generate initial condition
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"Inlet","Outlet");
+
+ //set the boundary conditions
+ myProblem.setInletBoundaryCondition("Inlet",initialTemperature,initialConc,initialVelocityX);
+ myProblem.setOutletBoundaryCondition("Outlet",initialPressure,vector<double>(1,xsup));
+
+ // physical parameters
+ myProblem.setPorosityField(porosityField);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+ myProblem.setWellBalancedCorrection(true);
+ myProblem.setNonLinearFormulation(VFFC) ;
+
+ // name file save
+ string fileName = "1DPorosityJumpUpwindWB";
+
+
+ /* set numerical parameters */
+ unsigned MaxNbOfTimeStep =3;
+ int freqSave = 1;
+ double cfl = 0.95;
+ double maxTime = 5;
+ double precision = 1e-5;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ bool ok;
+
+ // evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
+
--- /dev/null
+#include "DriftModel.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ cout << "Building a regular grid " << endl;
+ int spaceDim=1;
+ double xinf=0.0;
+ double xsup=4.2;
+ int nx=50;
+
+ Mesh M(xinf,xsup,nx);
+ double eps=1.E-8;
+ M.setGroupAtPlan(xsup,0,eps,"Outlet");
+ M.setGroupAtPlan(xinf,0,eps,"Inlet");
+
+ double inletConc=0;
+ double inletVelocityX =1;
+ double inletTemperature=563;
+
+ double outletPressure=155e5;
+
+ // physical parameters
+ Field pressureLossField("pressureLoss", FACES, M, 1);
+ pressureLossField(nx/4)=50;
+ pressureLossField(nx/2)=100;
+ pressureLossField(3*nx/4)=150;
+
+ DriftModel myProblem(around155bars600K,spaceDim);
+ int nVar = myProblem.getNumberOfVariables();
+
+ // Prepare for the initial condition
+ vector<double> VV_Constant(nVar);
+ // constant vector
+ VV_Constant[0] = inletConc;
+ VV_Constant[1] = outletPressure;
+ VV_Constant[2] = inletVelocityX;
+ VV_Constant[3] = inletTemperature;
+
+ cout << "Building initial data " << endl;
+
+ // generate initial condition
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
+
+ //set the boundary conditions
+ myProblem.setInletBoundaryCondition("inlet",inletTemperature,inletConc,inletVelocityX);
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,vector<double>(1,xsup));
+
+ // physical parameters
+ myProblem.setPressureLossField(pressureLossField);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+ myProblem.setWellBalancedCorrection(true);
+
+ // name file save
+ string fileName = "1DPressureLossUpwindWB";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep =3;
+ int freqSave = 1;
+ double cfl = 0.95;
+ double maxTime = 5;
+ double precision = 1e-5;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "DriftModel.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ cout << "Building cartesian mesh" << endl;
+ double xinf=0.0;
+ double xsup=1.0;
+ int nx=10;
+ Mesh M(xinf,xsup,nx);
+ double eps=1.E-8;
+ M.setGroupAtPlan(xsup,0,eps,"Neumann");
+ M.setGroupAtPlan(xinf,0,eps,"Neumann");
+ int spaceDim = M.getSpaceDimension();
+
+ // set the limit field for each boundary
+ LimitField limitNeumann;
+ limitNeumann.bcType=Neumann;
+ map<string, LimitField> boundaryFields;
+ boundaryFields["Neumann"] = limitNeumann;
+
+ DriftModel myProblem(around155bars600K,spaceDim);
+ int nbPhase = myProblem.getNumberOfPhases();
+ int nVar = myProblem.getNumberOfVariables();
+ Field VV("Primitive", CELLS, M, nVar);//3+spaceDim*nbPhase
+
+ // Prepare for the initial condition
+ Vector VV_Left(nVar),VV_Right(nVar);
+ double discontinuity = (xinf+xsup)/2.;
+ VV_Left(0) = 0.5; VV_Right(0) = 0.2;
+ VV_Left(1) = 155e5; VV_Right(1) = 155e5;
+ for (int idim=0; idim<spaceDim;idim++){
+ VV_Left(2+idim) = 1;VV_Right(2+idim) = 1;
+ }
+ VV_Left(2+spaceDim) = 573;
+ VV_Right(2+spaceDim) = 618;
+
+ //Initial field creation
+ cout << "Building initial data" << endl;
+ myProblem.setInitialFieldStepFunction(M,VV_Left,VV_Right,discontinuity);
+
+ //set the boundary fields
+ myProblem.setBoundaryFields(boundaryFields);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+
+ // name file save
+ string fileName = "RiemannProblem";
+
+ //numerical parameters
+ unsigned MaxNbOfTimeStep =3 ;
+ int freqSave = 1;
+ double cfl = 0.95;
+ double maxTime = 1;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+
+ // set display option to monitor the calculation
+ myProblem.setVerbose( true);
+ myProblem.saveConservativeField(true);
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "DriftModel.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv) {
+ //setting mesh and groups
+ cout << "Building a regular grid " << endl;
+ double xinf = 0.0;
+ double xsup = 4.2;
+ int nx = 2; //50;
+ Mesh M(xinf, xsup, nx);
+ double eps = 1.E-8;
+ M.setGroupAtPlan(xinf, 0, eps, "Outlet");
+ M.setGroupAtPlan(xsup, 0, eps, "Inlet");
+ int spaceDim = M.getSpaceDimension();
+
+ // setting boundary conditions
+ double inletConc = 1;
+ double inletTemperature = 300;
+ double outletPressure = 1e5;
+
+ double initialConcTop = 1;
+ double initialConcBottom = 0.0001;
+ double initialVelocityX = 1;
+ double initialPressure = 1e5;
+ double initialTemperature = 300;
+
+ // setting physical parameters
+ vector<double> gravite(spaceDim, 0.);
+ gravite[0] = -10;
+
+ DriftModel myProblem(around1bar300K, spaceDim, false);
+ int nbPhase = myProblem.getNumberOfPhases();
+ int nVar = myProblem.getNumberOfVariables();
+
+ // Prepare for the initial condition
+ Vector VV_top(nVar), VV_bottom(nVar);
+
+// top and bottom vectors
+ VV_top[0] = initialConcTop;
+ VV_top[1] = initialPressure;
+ VV_top[2] = initialVelocityX;
+ VV_top[3] = initialTemperature;
+
+ VV_bottom[0] = initialConcBottom;
+ VV_bottom[1] = initialPressure;
+ VV_bottom[2] = initialVelocityX;
+ VV_bottom[3] = initialTemperature;
+
+ //Initial field creation
+ cout << "Setting initial data " << endl;
+ myProblem.setInitialFieldStepFunction(M, VV_bottom, VV_top, .8, 0);
+
+ //set the boundary conditions
+ myProblem.setInletPressureBoundaryCondition("Inlet", outletPressure,inletTemperature, inletConc, vector<double>(1, xinf));
+ myProblem.setOutletBoundaryCondition("Outlet", outletPressure,vector<double>(1, xsup));
+
+ // physical parameters
+ myProblem.setGravity(gravite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+ myProblem.setWellBalancedCorrection(true);
+ myProblem.setNonLinearFormulation(VFFC);
+
+ // name the result file
+ string fileName = "Driftmodel_1DVidangeReservoir";
+
+ // setting numerical parameters
+ unsigned MaxNbOfTimeStep = 1;
+ int freqSave = 1;
+ double cfl = 0.95;
+ double maxTime = 1;
+ double precision = 1e-5;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.usePrimitiveVarsInNewton(true);
+ myProblem.saveAllFields(true);
+ myProblem.setVerbose(true);
+ myProblem.displayConditionNumber();
+ myProblem.setSaveFileFormat(CSV);
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation " << fileName << " is successful !" << endl;
+ else
+ cout << "Simulation " << fileName << " failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "DriftModel.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ int spaceDim = 2;
+
+ // set the limit field for each boundary
+ double wallVelocityX=0;
+ double wallVelocityY=0;
+ double wallTemperature=563;
+
+ double inletConcentration=0;
+ double inletVelocityX=0;
+ double inletVelocityY=1;
+ double inletTemperature=563;
+
+ double outletPressure=155e5;
+
+ // physical constants
+ vector<double> gravite(spaceDim,0.) ;
+ gravite[1]=-7;
+ gravite[0]=7;
+ double heatPower=1e8;
+
+ DriftModel myProblem(around155bars600K,spaceDim);
+ int nVar = myProblem.getNumberOfVariables();
+
+ //Prepare for the mesh
+ double xinf=0.0;
+ double xsup=1.0;
+ double yinf=0.0;
+ double ysup=1.0;
+ int nx=20;
+ int ny=20;
+
+ // Prepare for the initial condition
+ vector<double> VV_Constant(nVar);
+ // constant vector
+ VV_Constant[0] = 0;
+ VV_Constant[1] = 155e5;
+ VV_Constant[2] = 0;
+ VV_Constant[3] = 1;
+ VV_Constant[4] = 563;
+
+ //Initial field creation
+ cout << "Building initial data" << endl;
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"wall","wall",yinf,ysup,ny,"inlet","outlet");
+
+ //set the boundary conditions
+ vector<double>pressure_reference_point(2);
+ pressure_reference_point[0]=xsup;
+ pressure_reference_point[1]=ysup;
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,pressure_reference_point);
+ myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ // set physical parameters
+ myProblem.setHeatSource(heatPower);
+ myProblem.setGravity(gravite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+ myProblem.setWellBalancedCorrection(true);
+
+ // name of result file
+ string fileName = "DriftModel_2DInclinedBoilingChannel";
+
+ // computation parameters
+ unsigned MaxNbOfTimeStep = 3 ;
+ int freqSave = 1;
+ double cfl = 0.5;
+ double maxTime = 5;
+ double precision = 1e-4;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveVelocity();
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "DriftModel.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ int spaceDim = 2;
+
+ //Prepare for the mesh
+ double xinf=0.0;
+ double xsup=1.0;
+ double yinf=0.0;
+ double ysup=4.0;
+ int nx=10;
+ int ny=40;
+
+ // set the limit field for each boundary
+ double wallVelocityX=0;
+ double wallVelocityY=0;
+ double wallTemperature=563;
+
+ double inletConcentration=0;
+ double inletVelocityX=0;
+ double inletVelocityY=1;
+ double inletTemperature=563;
+
+ double outletPressure=155e5;
+
+ // physical constants
+ vector<double> gravite(spaceDim,0.) ;
+ gravite[1]=-8.5;
+ gravite[0]=5;
+
+ DriftModel myProblem(around155bars600K,spaceDim);
+ int nVar = myProblem.getNumberOfVariables();
+
+ // Prepare for the initial condition
+ vector<double> VV_Constant(nVar);
+ // constant vector
+ VV_Constant[0] = 0;
+ VV_Constant[1] = 155e5;
+ VV_Constant[2] = 0;
+ VV_Constant[3] = 1;
+ VV_Constant[4] = 563;
+
+ //Initial field creation
+ cout << "Building initial data" << endl;
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"wall","wall",yinf,ysup,ny,"inlet","outlet");
+
+ //set the boundary conditions
+ vector<double>pressure_reference_point(2);
+ pressure_reference_point[0]=xsup;
+ pressure_reference_point[1]=ysup;
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,pressure_reference_point);
+ myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ // set physical parameters
+ myProblem.setGravity(gravite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+ myProblem.setWellBalancedCorrection(true);
+ myProblem.setNonLinearFormulation(VFFC);
+
+ // name of result file
+ string fileName = "2DInclinedChannelGravity";
+
+ // computation parameters
+ unsigned MaxNbOfTimeStep = 3 ;
+ int freqSave = 1;
+ double cfl = 0.5;
+ double maxTime = 5;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.usePrimitiveVarsInNewton(true);
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "DriftModel.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ int spaceDim = 2;
+
+ //Prepare for the mesh
+ double xinf=0.0;
+ double xsup=.6;
+ double yinf=0.0;
+ double ysup=2.0;
+ int nx=3;
+ int ny=100;
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny);
+
+ //Set the barriers
+ double xcloison1=xinf+(xsup-xinf)/3;
+ double xcloison2=xinf+2*(xsup-xinf)/3;
+ Field barrierField("Barrier Field", FACES, M, 1);
+ double eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"wall");
+ M.setGroupAtPlan(xinf,0,eps,"wall");
+ M.setGroupAtPlan(ysup,1,eps,"outlet");
+ M.setGroupAtPlan(yinf,1,eps,"inlet");
+ double dy=(ysup-yinf)/ny;
+ int ncloison=3*ny/4;
+ int i=0;
+ while( i<= ncloison+1)
+ {
+ M.setGroupAtFaceByCoords(xcloison1,yinf+((ysup-yinf)/4)+(i+0.5)*dy,0,eps,"wall");
+ M.setGroupAtFaceByCoords(xcloison2,yinf+((ysup-yinf)/4)+(i+0.5)*dy,0,eps,"wall");
+ i++;
+ }
+
+ int nbFaces=M.getNumberOfFaces();
+ for( i=0;i<nbFaces;i++)
+ {
+ double x=M.getFace(i).x();
+ double y=M.getFace(i).y();
+ if (((y> yinf+(ysup-yinf)/4) && (abs(x-xcloison1)< eps or abs(x-xcloison2)< eps) ) || abs(x-xinf)< eps || abs(x-xsup)< eps)
+ barrierField[i]=1;
+ else
+ barrierField[i]=0;
+ }
+
+ barrierField.writeVTK("barrierField",true);
+
+ // set the limit field for each boundary
+ double wallVelocityX=0;
+ double wallVelocityY=0;
+ double wallTemperature=563;
+
+ double inletConcentration=0;
+ double inletVelocityX=0;
+ double inletVelocityY=1;
+ double inletTemperature=563;
+
+ double outletPressure=155e5;
+
+ // physical constants
+ vector<double> gravite(spaceDim,0.) ;
+ gravite[1]=-7;
+ gravite[0]=7;
+
+ DriftModel myProblem(around155bars600K,spaceDim);
+ int nVar = myProblem.getNumberOfVariables();
+
+ // Prepare for the initial condition
+ vector<double> VV_Constant(nVar);
+ // constant vector
+ VV_Constant[0] = 0;
+ VV_Constant[1] = 155e5;
+ VV_Constant[2] = 0;
+ VV_Constant[3] = 1;
+ VV_Constant[4] = 563;
+
+ //Initial field creation
+ cout << "Building initial data" << endl;
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ //set the boundary conditions
+ vector<double>pressure_reference_point(2);
+ pressure_reference_point[0]=xsup;
+ pressure_reference_point[1]=ysup;
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,pressure_reference_point);
+ myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ // set physical parameters
+ myProblem.setGravity(gravite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+ myProblem.setWellBalancedCorrection(true);
+ myProblem.setNonLinearFormulation(VFFC);
+
+ // name of result file
+ string fileName = "2DInclinedChannelGravityBarriers";
+
+ // computation parameters
+ unsigned MaxNbOfTimeStep = 3 ;
+ int freqSave = 1;
+ double cfl = 0.5;
+ double maxTime = 500;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.usePrimitiveVarsInNewton(true);
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "DriftModel.hxx"\r
+\r
+using namespace std;\r
+\r
+int main(int argc, char** argv)\r
+{\r
+ int spaceDim = 3;\r
+ // Prepare for the mesh\r
+ cout << "Building cartesian mesh" << endl;\r
+ double xinf = 0 ;\r
+ double xsup=2.0;\r
+ double yinf=0.0;\r
+ double ysup=2.0;\r
+ double zinf=0.0;\r
+ double zsup=4.0;\r
+ int nx=10;\r
+ int ny=nx;\r
+ int nz=20;\r
+ double xcloison=(xinf+xsup)/2;\r
+ double ycloison=(yinf+ysup)/2;\r
+ double zcloisonmin=1;\r
+ double zcloisonmax=3;\r
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz);\r
+ // set the limit field for each boundary\r
+ double eps=1e-6;\r
+ M.setGroupAtPlan(xsup,0,eps,"wall");\r
+ M.setGroupAtPlan(xinf,0,eps,"wall");\r
+ M.setGroupAtPlan(ysup,1,eps,"wall");\r
+ M.setGroupAtPlan(yinf,1,eps,"wall");\r
+ M.setGroupAtPlan(zsup,2,eps,"outlet");\r
+ M.setGroupAtPlan(zinf,2,eps,"inlet");\r
+ double dx=(xsup-xinf)/nx;\r
+ double dy=(ysup-yinf)/ny;\r
+ double dz=(zsup-zinf)/nz;\r
+ int ncloison=nz*(zcloisonmax-zcloisonmin)/(zsup-zinf);\r
+ int i=0 ;\r
+ int j=0;\r
+ while( i< ncloison){\r
+ while(j< ny){\r
+ M.setGroupAtFaceByCoords(xcloison,(j+0.5)*dy,zcloisonmin+(i+0.5)*dz,eps,"wall");\r
+ M.setGroupAtFaceByCoords((j+0.5)*dx,ycloison,zcloisonmin+(i+0.5)*dz,eps,"wall");\r
+ j=j+1;\r
+ }\r
+ i=i+1;\r
+ }\r
+\r
+ // set the limit field for each boundary\r
+ double wallVelocityX=0;\r
+ double wallVelocityY=0;\r
+ double wallVelocityZ=0;\r
+ double wallTemperature=573;\r
+ double inletConc=0;\r
+ double inletVelocityX=0;\r
+ double inletVelocityY=0;\r
+ double inletVelocityZ=1;\r
+ double inletTemperature=563;\r
+ double outletPressure=155e5;\r
+\r
+ // physical constants\r
+ vector<double> gravite = vector<double>(spaceDim,0);\r
+\r
+ gravite[0]=0;\r
+ gravite[1]=0;\r
+ gravite[2]=-10;\r
+\r
+ double heatPower1=0;\r
+ double heatPower2=0.25e8;\r
+ double heatPower3=0.5e8;\r
+ double heatPower4=1e8;\r
+\r
+ DriftModel myProblem = DriftModel(around155bars600K,spaceDim);\r
+ int nVar =myProblem.getNumberOfVariables();\r
+ Field heatPowerField=Field("heatPowerField", CELLS, M, 1);\r
+\r
+ int nbCells=M.getNumberOfCells();\r
+\r
+ for (int i=0;i<nbCells;i++){\r
+ double x=M.getCell(i).x();\r
+ double y=M.getCell(i).y();\r
+ double z=M.getCell(i).z();\r
+ if (z> zcloisonmin && z< zcloisonmax)\r
+ if (y<ycloison && x<xcloison)\r
+ heatPowerField[i]=heatPower1;\r
+ if (y<ycloison && x>xcloison)\r
+ heatPowerField[i]=heatPower2;\r
+ if (y>ycloison && x<xcloison)\r
+ heatPowerField[i]=heatPower3;\r
+ if (y>ycloison && x>xcloison)\r
+ heatPowerField[i]=heatPower4;\r
+ else\r
+ heatPowerField[i]=0;\r
+ }\r
+ heatPowerField.writeVTK("heatPowerField",true);\r
+\r
+ //Prepare for the initial condition\r
+ Vector VV_Constant =Vector(nVar);\r
+\r
+ // constant vector\r
+ VV_Constant[0] = inletConc ;\r
+ VV_Constant[1] = outletPressure ;\r
+ VV_Constant[2] = inletVelocityX;\r
+ VV_Constant[3] = inletVelocityY;\r
+ VV_Constant[4] = inletVelocityZ;\r
+ VV_Constant[5] = inletTemperature ;\r
+\r
+ //Initial field creation\r
+ cout<<"Building initial data " <<endl;\r
+ myProblem.setInitialFieldConstant(M,VV_Constant);\r
+\r
+ // the boundary conditions\r
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure);\r
+ myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConc, inletVelocityX, inletVelocityY, inletVelocityZ);\r
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY,wallVelocityZ);\r
+\r
+ // set physical parameters\r
+ myProblem.setHeatPowerField(heatPowerField);\r
+ myProblem.setGravity(gravite);\r
+\r
+ // set the numerical method\r
+ myProblem.setNumericalScheme(upwind, Explicit);\r
+ myProblem.setWellBalancedCorrection(false);\r
+\r
+ // name file save\r
+ string fileName = "3DCanalCloison";\r
+\r
+ // parameters calculation\r
+ unsigned MaxNbOfTimeStep = 3;\r
+ int freqSave = 1;\r
+ double cfl = 0.3;\r
+ double maxTime = 5;\r
+ double precision = 1e-6;\r
+\r
+ myProblem.setCFL(cfl);\r
+ myProblem.setPrecision(precision);\r
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
+ myProblem.setTimeMax(maxTime);\r
+ myProblem.setFreqSave(freqSave);\r
+ myProblem.setFileName(fileName);\r
+ myProblem.setNewtonSolver(precision,20);\r
+ myProblem.saveVelocity();\r
+\r
+ // evolution\r
+ myProblem.initialize();\r
+\r
+ bool ok = myProblem.run();\r
+ if (ok)\r
+ cout << "Simulation "<<fileName<<" is successful !" << endl;\r
+ else\r
+ cout << "Simulation "<<fileName<<" failed ! " << endl;\r
+\r
+ cout << "------------ End of calculation !!! -----------" << endl;\r
+ myProblem.terminate();\r
+\r
+ return EXIT_SUCCESS;\r
+}\r
--- /dev/null
+#include "FiveEqsTwoFluid.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh data
+ cout << "Building cartesian mesh" << endl;
+ double xinf=0.0;
+ double xsup=4.2;
+ int nx=50;
+
+ int spaceDim=1;
+
+ double inletVoidFraction=0;
+ vector<double>inletVelocityX(2,2);
+ double inletTemperature=563;
+
+ double outletPressure=155e5;
+
+ // physical constants
+ double heatPower=1e8;
+ int nbPhase=2;
+
+ FiveEqsTwoFluid myProblem(around155bars600K,spaceDim);
+ int nVar = myProblem.getNumberOfVariables();
+
+ // Prepare for the initial condition
+ vector<double> VV_Constant(nVar);
+ // constant vector
+ VV_Constant[0] = inletVoidFraction;
+ VV_Constant[1] = outletPressure;
+ VV_Constant[2] = inletVelocityX[0];
+ VV_Constant[3] = inletVelocityX[1];
+ VV_Constant[2+spaceDim*nbPhase] = inletTemperature;
+
+ cout << "Building initial data" << endl;
+ // generate initial condition
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
+
+ //set the boundary conditions
+ myProblem.setInletBoundaryCondition("inlet",inletVoidFraction,inletTemperature,inletVelocityX);
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure);
+
+ // physical parameters
+ myProblem.setHeatSource(heatPower);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+ myProblem.setWellBalancedCorrection(true);
+ myProblem.setEntropicCorrection(true);
+
+ // name file save
+ string fileName = "1DBoilingChannel";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep =3;
+ int freqSave = 1;
+ double cfl = 0.5;
+ double maxTime = 5;
+ double precision = 1e-8;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "FiveEqsTwoFluid.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ cout << "Building cartesian mesh" << endl;
+ double xinf=0.0;
+ double xsup=4.2;
+ int nx=50;
+ Mesh M(xinf,xsup,nx);
+ double eps=1.E-8;
+ M.setGroupAtPlan(xsup,0,eps,"Outlet");//Neumann
+ M.setGroupAtPlan(xinf,0,eps,"Wall");//
+ int spaceDim = M.getSpaceDimension();
+
+ // set the limit field for each boundary
+ LimitField limitOutlet, limitWall;
+ map<string, LimitField> boundaryFields;
+ limitOutlet.bcType=Outlet;
+ limitOutlet.p = 100e5;
+ boundaryFields["Outlet"] = limitOutlet;
+
+ limitWall.bcType=Wall;
+ limitWall.T = 600;
+ limitWall.v_x = vector<double>(2,0);
+ boundaryFields["Wall"]= limitWall;
+
+ // physical constants
+ double latentHeat=1e6;
+ double satTemp=618;
+ double dHsatl_over_dp=0.05;
+ double Psat=85e5;
+
+ FiveEqsTwoFluid myProblem(around155bars600K,spaceDim);
+ int nbPhase = myProblem.getNumberOfPhases();
+ int nVar = myProblem.getNumberOfVariables();
+
+ //Initial field creation
+ Vector VV_Constant(nVar);
+ VV_Constant(0) = 0.;
+ VV_Constant(1) = 155e5;
+ for (int idim=0; idim<spaceDim;idim++){
+ VV_Constant(2+idim) = 0;
+ VV_Constant(2+idim +spaceDim) =0;
+ }
+ VV_Constant(2+spaceDim*nbPhase) = 600;
+
+ cout << "Number of Phases = " << nbPhase << endl;
+ cout << "Building initial data " << endl;
+
+ // generate initial condition
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ //set the boundary conditions
+ myProblem.setBoundaryFields(boundaryFields);
+ /* set physical parameters*/
+// myProblem.setLatentHeat(latentHeat);
+// myProblem.setSatPressure( Psat, dHsatl_over_dp);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+ myProblem.setEntropicCorrection(true);
+
+ // name file save
+ string fileName = "1DDepressurisation";
+
+ // set numerical parameters
+ unsigned MaxNbOfTimeStep =3;
+ int freqSave = 1;
+ double cfl = 0.5;
+ double maxTime = 5;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ bool ok;
+
+ // evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "FiveEqsTwoFluid.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ cout << "Building cartesian mesh " << endl;
+ double xinf=0.0;
+ double xsup=1.0;
+ int nx=10;
+ Mesh M(xinf,xsup,nx);
+ double eps=1.E-8;
+ M.setGroupAtPlan(xsup,0,eps,"Neumann");
+ M.setGroupAtPlan(xinf,0,eps,"Neumann");
+ int spaceDim = M.getSpaceDimension();
+
+ // set the limit field for each boundary
+ LimitField limitNeumann;
+ map<string, LimitField> boundaryFields;
+
+ limitNeumann.bcType=Neumann;
+ limitNeumann.T =0.;
+ limitNeumann.p = 155e5;
+ limitNeumann.alpha = 0;
+ limitNeumann.v_x = vector<double>(2,0);
+ limitNeumann.v_y = vector<double>(2,0);
+ limitNeumann.v_z = vector<double>(2,0);
+ boundaryFields["Neumann"] = limitNeumann;
+
+ FiveEqsTwoFluid myProblem(around155bars600K,spaceDim);
+ int nbPhase = myProblem.getNumberOfPhases();
+ int nVar = myProblem.getNumberOfVariables();
+ Field VV("Primitive", CELLS, M, nVar);
+
+ // Prepare for the initial condition
+ Vector VV_Left(nVar),VV_Right(nVar);
+ double discontinuity = (xinf+xsup)/2.;
+ // two vectors
+ VV_Left(0) = 0.5; VV_Right(0) = 0.2;
+ VV_Left(1) = 155e5; VV_Right(1) = 155e5;
+ for (int idim=0; idim<spaceDim;idim++){
+ VV_Left(2+idim) = 1;VV_Right(2+idim) = 1;
+ VV_Left(2+idim +spaceDim) =1;VV_Right(2+idim +spaceDim) = 1;
+ }
+ VV_Left(2+spaceDim*nbPhase) = 618;
+ VV_Right(2+spaceDim*nbPhase) = 618;
+
+ //Initial field creation
+ cout << "Building initial data" << endl;
+ myProblem.setInitialFieldStepFunction(M,VV_Left,VV_Right,discontinuity);
+
+ //set the boundary fields
+ myProblem.setBoundaryFields(boundaryFields);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+
+ // name of result file
+ string fileName = "RiemannProblem";
+
+ // simuulation parameters
+ unsigned MaxNbOfTimeStep =3;
+ int freqSave = 1;
+ double cfl = 0.95;
+ double maxTime = 1;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+
+ // set display options to monitor the calculation
+ myProblem.setVerbose( true);
+ myProblem.saveConservativeField(true);
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "FiveEqsTwoFluid.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ cout << "Building regular mesh " << endl;
+ double xinf=0.0;
+ double xsup=1.0;
+ double yinf=0.0;
+ double ysup=1.0;
+ int nx=20;
+ int ny=20;
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny);
+ double eps=1.E-6;
+ M.setGroupAtPlan(xsup,0,eps,"Wall");
+ M.setGroupAtPlan(xinf,0,eps,"Wall");
+ M.setGroupAtPlan(yinf,1,eps,"Inlet");
+ M.setGroupAtPlan(ysup,1,eps,"Outlet");
+ int spaceDim = M.getSpaceDimension();
+
+ // physical constants
+ vector<double> gravite(spaceDim,0.) ;
+ gravite[1]=-7;
+ gravite[0]=7;
+
+ // set the limit field for each boundary
+ LimitField limitWall;
+ map<string, LimitField> boundaryFields;
+ limitWall.bcType=Wall;
+ limitWall.T = 563;
+ limitWall.v_x = vector<double>(2,0);
+ limitWall.v_y = vector<double>(2,0);
+ boundaryFields["Wall"]= limitWall;
+
+ LimitField limitInlet;
+ limitInlet.bcType=Inlet;
+ limitInlet.T = 563;
+ limitInlet.alpha = 0;
+ limitInlet.v_x = vector<double>(2,0);
+ limitInlet.v_y = vector<double>(2,1);
+ boundaryFields["Inlet"]= limitInlet;
+
+ LimitField limitOutlet;
+ limitOutlet.bcType=Outlet;
+ limitOutlet.p = 155e5;
+ boundaryFields["Outlet"]= limitOutlet;
+
+ // physical constants
+ double heatPower=1e8;
+
+ FiveEqsTwoFluid myProblem(around155bars600K,spaceDim);
+ int nbPhase = myProblem.getNumberOfPhases();
+ int nVar = myProblem.getNumberOfVariables();
+ // Prepare for the initial condition
+ Vector VV_Constant(nVar);
+ // constant vector
+ VV_Constant(0) = 0;
+ VV_Constant(1) = 155e5;
+ VV_Constant(2) = 0;
+ VV_Constant(3) = 1;
+ VV_Constant(4) = 0;
+ VV_Constant(5) = 1;
+ VV_Constant(6) = 563;
+
+ //Initial field creation
+ cout << "Building initial data " << endl;
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ //set the boundary conditions
+ myProblem.setBoundaryFields(boundaryFields);
+
+ // set physical parameters
+ myProblem.setHeatSource(heatPower);
+ myProblem.setGravity(gravite);
+
+ // name file save
+ string fileName = "2DInclinedBoilingChannel";
+
+ //numerical parameters
+ myProblem.setNumericalScheme(upwind, Explicit);
+ unsigned MaxNbOfTimeStep = 3 ;
+ int freqSave = 5;
+ double cfl = 0.5;
+ double maxTime = 5;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveVelocity();
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "FiveEqsTwoFluid.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ cout << "Building Cartesian mesh " << endl;
+ double xinf=0.0;
+ double xsup=1.0;
+ double yinf=0.0;
+ double ysup=1.0;
+ int nx=50;
+ int ny=50;
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny);
+ double eps=1.E-6;
+ M.setGroupAtPlan(xsup,0,eps,"Wall");
+ M.setGroupAtPlan(xinf,0,eps,"Wall");
+ M.setGroupAtPlan(yinf,1,eps,"Wall");
+ M.setGroupAtPlan(ysup,1,eps,"Wall");
+ int spaceDim = M.getSpaceDimension();
+
+ // set the limit field for each boundary
+ vector<double> wallVelocityX(2,0);
+ vector<double> wallVelocityY(2,0);
+ double wallTemperature=300;
+
+ // physical constants
+ vector<double> gravite(spaceDim,0.) ;
+ gravite[1]=-7;
+ gravite[0]=7;
+
+ FiveEqsTwoFluid myProblem(around1bar300K,spaceDim);
+ int nbPhase = myProblem.getNumberOfPhases();
+ int nVar = myProblem.getNumberOfVariables();
+ // Prepare for the initial condition
+ Vector VV_Constant(nVar);
+ // constant vector
+ VV_Constant(0) = 0.5;
+ VV_Constant(1) = 1e5;
+ VV_Constant(2) = 0;
+ VV_Constant(3) = 0;
+ VV_Constant(4) = 0;
+ VV_Constant(5) = 0;
+ VV_Constant(6) = wallTemperature;
+
+ //Initial field creation
+ cout << "Building initial data" << endl;
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ //set the boundary conditions
+ myProblem.setWallBoundaryCondition("Wall",wallTemperature,wallVelocityX,wallVelocityY);
+
+ // set physical parameters
+ myProblem.setGravity(gravite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Implicit);
+
+ // name file save
+ string fileName = "2DInclinedSedimentation";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep = 3 ;
+ int freqSave = 1;
+ double cfl = 0.1;
+ double maxTime = 5;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveVelocity();
+ myProblem.displayConditionNumber();
+ myProblem.setSaveFileFormat(CSV);
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "IsothermalTwoFluid.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ cout << "Building cartesian mesh" << endl;
+ double xinf=0.0;
+ double xsup=1.0;
+ int nx=50;
+ Mesh M(xinf,xsup,nx);
+ double eps=1.E-6;
+ M.setGroupAtPlan(xsup,0,eps,"Outlet");
+ M.setGroupAtPlan(xinf,0,eps,"Wall");
+ int spaceDim = M.getSpaceDimension();
+
+ // physical constants
+ double dHsatl_over_dp=0.05;
+ double Psat=85e5;
+ double latentHeat=1e6;
+
+ // set the limit field for each boundary
+ LimitField limitOutlet, limitWall;
+ map<string, LimitField> boundaryFields;
+ limitOutlet.bcType=Outlet;
+ limitOutlet.p = 80e5;
+ boundaryFields["Outlet"] = limitOutlet;
+
+ limitWall.bcType=Wall;
+ limitWall.v_x = vector<double>(2,0);
+ boundaryFields["Wall"]= limitWall;
+ IsothermalTwoFluid myProblem(around155bars600K,spaceDim);
+ // Prepare for the initial condition
+ int nVar = myProblem.getNumberOfVariables();
+ Vector VV_Constant(nVar);
+ VV_Constant(0) = 0.;
+ VV_Constant(1) = 155e5;
+ VV_Constant(2) = 0;
+ VV_Constant(3) = 0;
+
+ //Initial field creation
+ cout << "Building initial data" << endl;
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ //set the boundary conditions
+ myProblem.setBoundaryFields(boundaryFields);
+
+ //set physical parameters
+// myProblem.setSatPressure( Psat, dHsatl_over_dp);
+// myProblem.setLatentHeat(latentHeat);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+ myProblem.setEntropicCorrection(true);
+
+ // name file save
+ string fileName = "1DDepressurisation";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep = 3;
+ int freqSave = 1;
+ double cfl = 0.95;
+ double maxTime = 5;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ bool ok;
+
+ // evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of simulation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "IsothermalTwoFluid.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ cout << "Building Cartesian mesh " << endl;
+ double xinf=0.0;
+ double xsup=1.0;
+ int nx=10;
+ Mesh M(xinf,xsup,nx);
+ double eps=1.E-8;
+ M.setGroupAtPlan(xsup,0,eps,"Neumann");
+ M.setGroupAtPlan(xinf,0,eps,"Neumann");
+ int spaceDim = M.getSpaceDimension();
+
+ // set the limit field for each boundary
+ LimitField limitNeumann;
+ limitNeumann.bcType=Neumann;
+ map<string, LimitField> boundaryFields;
+
+ limitNeumann.p = 155e5;
+ limitNeumann.alpha = 0;
+ limitNeumann.v_x = vector<double>(2,0);
+ limitNeumann.v_y = vector<double>(2,0);
+ limitNeumann.v_z = vector<double>(2,0);
+ boundaryFields["Neumann"] = limitNeumann;
+
+ IsothermalTwoFluid myProblem(around155bars600K,spaceDim);
+ int nbPhase = myProblem.getNumberOfPhases();
+ int nVar = myProblem.getNumberOfVariables();
+ Field VV("Primitive", CELLS, M, nVar);
+
+ // Prepare for the initial condition
+ Vector VV_Left(nVar),VV_Right(nVar);
+ double discontinuity = (xinf+xsup)/2.;
+ // two vectors
+ VV_Left(0) = 0.5; VV_Right(0) = 0.2;
+ VV_Left(1) = 155e5; VV_Right(1) = 155e5;
+ for (int idim=0; idim<spaceDim;idim++){
+ VV_Left(2+idim) = 1;VV_Right(2+idim) = 1;
+ VV_Left(2+idim +spaceDim) =2;VV_Right(2+idim +spaceDim) = 1;
+ }
+
+ //Initial field creation
+ cout << "Building initial data" << endl;
+
+ myProblem.setInitialFieldStepFunction(M,VV_Left,VV_Right,discontinuity);
+
+ //set the boundary fields
+ myProblem.setBoundaryFields(boundaryFields);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+
+ // name file save
+ string fileName = "RiemannProblem";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep =3 ;
+ int freqSave = 1;
+ double cfl = 0.95;
+ double maxTime = 1;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveConservativeField(true);
+ myProblem.setSaveFileFormat(MED);
+
+ /* set display option to monitor the calculation */
+ myProblem.setVerbose( true);
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "IsothermalTwoFluid.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ cout << "Building Cartesian mesh " << endl;
+ int spaceDim=1;
+ double xinf=0.0;
+ double xsup=1.0;
+ int nx=50;
+
+ vector<double> wallVelocityX(2,0);
+
+ // physical constants
+ vector<double> gravite(spaceDim,0.) ;
+ gravite[0]=-10;
+
+ IsothermalTwoFluid myProblem(around1bar300K,spaceDim);
+ int nVar = myProblem.getNumberOfVariables();
+
+ // Prepare for the initial condition
+ vector<double> VV_Constant(nVar,0.);
+ // constant vector
+ VV_Constant[0] = 0.5;
+ VV_Constant[1] = 1e5;
+ VV_Constant[2] = 0;
+ VV_Constant[3] = 0;
+
+ //Initial field creation
+ cout << "Building initial data " << endl;
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"wall","wall");
+ myProblem.setWallBoundaryCondition("wall",wallVelocityX);
+
+
+ // physical parameters
+ myProblem.setGravity(gravite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Implicit);
+ myProblem.setEntropicCorrection(true);
+
+ // name file save
+ string fileName = "1DSedimentation";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep = 3;
+ int freqSave = 1;
+ double cfl = 1;
+ double maxTime = 5;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.displayConditionNumber();
+ myProblem.setSaveFileFormat(CSV);
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of simulation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "IsothermalTwoFluid.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ cout << "Building Cartesian mesh " << endl;
+ double xinf=0.0;
+ double xsup=1.0;
+ double yinf=0.0;
+ double ysup=1.0;
+ int nx=50;
+ int ny=50;
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny);
+ double eps=1.E-6;
+ M.setGroupAtPlan(xsup,0,eps,"Wall");
+ M.setGroupAtPlan(xinf,0,eps,"Wall");
+ M.setGroupAtPlan(yinf,1,eps,"Wall");
+ M.setGroupAtPlan(ysup,1,eps,"Wall");
+ int spaceDim = M.getSpaceDimension();
+
+ // set the limit field for each boundary
+ vector<double> wallVelocityX(2,0);
+ vector<double> wallVelocityY(2,0);
+
+ // physical constants
+ vector<double> gravite(spaceDim,0.) ;
+ gravite[1]=-7;
+ gravite[0]=7;
+
+ IsothermalTwoFluid myProblem(around1bar300K,spaceDim);
+ int nbPhase = myProblem.getNumberOfPhases();
+ int nVar = myProblem.getNumberOfVariables();
+ // Prepare for the initial condition
+ Vector VV_Constant(nVar);
+ // constant vector
+ VV_Constant(0) = 0.5;
+ VV_Constant(1) = 1e5;
+ VV_Constant(2) = 0;
+ VV_Constant(3) = 0;
+ VV_Constant(4) = 0;
+ VV_Constant(5) = 0;
+
+ //Initial field creation
+ cout << "Building initial data" << endl;
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ //set the boundary conditions
+ myProblem.setWallBoundaryCondition("Wall",wallVelocityX,wallVelocityY);
+
+ // set physical parameters
+ myProblem.setGravity(gravite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+
+ // name file save
+ string fileName = "2DInclinedSedimentation";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep = 3 ;
+ int freqSave = 1;
+ double cfl = 0.25;
+ double maxTime = 5;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveVelocity();
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "IsothermalTwoFluid.hxx"\r
+\r
+#include <iostream>\r
+\r
+using namespace std;\r
+\r
+int main(int argc, char** argv)\r
+{\r
+ //Preprocessing: mesh and group creation\r
+ cout << "Building Cartesian mesh " << endl;\r
+ double xinf=0.0;\r
+ double xsup=1.0;\r
+ double yinf=0.0;\r
+ double ysup=1.0;\r
+ int nx=50;\r
+ int ny=50;\r
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny);\r
+ double eps=1.E-6;\r
+ M.setGroupAtPlan(xsup,0,eps,"Wall");\r
+ M.setGroupAtPlan(xinf,0,eps,"Wall");\r
+ M.setGroupAtPlan(yinf,1,eps,"Wall");\r
+ M.setGroupAtPlan(ysup,1,eps,"inlet");\r
+ int spaceDim = M.getSpaceDimension();\r
+\r
+ // set the limit field for each boundary\r
+ vector<double> wallVelocityX(2,0);\r
+ vector<double> wallVelocityY(2,0);\r
+ double inletAlpha=1;\r
+ double outletPressure=1e5;\r
+\r
+ // physical constants\r
+ vector<double> gravite(spaceDim,0.) ;\r
+ gravite[1]=-10;\r
+ gravite[0]=0;\r
+\r
+ IsothermalTwoFluid myProblem(around1bar300K,spaceDim);\r
+ int nbPhase = myProblem.getNumberOfPhases();\r
+ int nVar = myProblem.getNumberOfVariables();\r
+ // Prepare for the initial condition\r
+ Vector VV_Constant(nVar);\r
+ // constant vector\r
+ VV_Constant(0) = 0.;\r
+ VV_Constant(1) = 1e5;\r
+ VV_Constant(2) = 0;\r
+ VV_Constant(3) = 0;\r
+\r
+ //Initial field creation\r
+ cout << "Building initial data" << endl;\r
+ myProblem.setInitialFieldConstant(M,VV_Constant);\r
+\r
+ //set the boundary conditions\r
+ myProblem.setWallBoundaryCondition("Wall",wallVelocityX,wallVelocityY);\r
+ myProblem.setInletPressureBoundaryCondition("inlet", inletAlpha, outletPressure);\r
+\r
+ // set physical parameters\r
+ myProblem.setGravity(gravite);\r
+\r
+ // set the numerical method\r
+ myProblem.setNumericalScheme(upwind, Explicit);\r
+\r
+ // name file save\r
+ string fileName = "2DInclinedSedimentation";\r
+\r
+ // parameters calculation\r
+ unsigned MaxNbOfTimeStep = 3 ;\r
+ int freqSave = 1;\r
+ double cfl = 0.1;\r
+ double maxTime = 5;\r
+ double precision = 1e-6;\r
+\r
+ myProblem.setCFL(cfl);\r
+ myProblem.setPrecision(precision);\r
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
+ myProblem.setTimeMax(maxTime);\r
+ myProblem.setFreqSave(freqSave);\r
+ myProblem.setFileName(fileName);\r
+ myProblem.saveVelocity();\r
+\r
+ // evolution\r
+ myProblem.initialize();\r
+\r
+ bool ok = myProblem.run();\r
+ if (ok)\r
+ cout << "Simulation "<<fileName<<" is successful !" << endl;\r
+ else\r
+ cout << "Simulation "<<fileName<<" failed ! " << endl;\r
+\r
+ cout << "------------ End of calculation !!! -----------" << endl;\r
+ myProblem.terminate();\r
+\r
+ return EXIT_SUCCESS;\r
+}\r
--- /dev/null
+#include "SinglePhase.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ cout << "Building cartesian mesh" << endl;
+ double xinf=0.0;
+ double xsup=4.2;
+ int nx=50;
+ Mesh M(xinf,xsup,nx);
+ double eps=1.E-8;
+ M.setGroupAtPlan(xsup,0,eps,"Outlet");
+ M.setGroupAtPlan(xinf,0,eps,"Wall");
+ int spaceDim = M.getSpaceDimension();
+
+ // set the initial field
+ double initialPressure=155e5;
+ double initialVelocityX=0;
+ double initialTemperature=573;
+
+ //set the boundary data for each boundary
+ double outletPressure=80e5;
+ double wallVelocityX=0;
+ double wallTemperature=573;
+
+ SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
+ int nbPhase = myProblem.getNumberOfPhases();
+
+ // Prepare for the initial condition
+ int nVar = myProblem.getNumberOfVariables();
+ Vector VV_constant(nVar);
+ VV_constant(0) = initialPressure ;
+ VV_constant(1) = initialVelocityX;
+ VV_constant(2) = initialTemperature ;
+
+ cout << "Building initial data" << endl;
+ Field VV("Primitive", CELLS, M, nVar);
+
+ myProblem.setInitialFieldConstant(M,VV_constant);
+
+ //set the boundary conditions
+ myProblem.setWallBoundaryCondition("Wall", wallTemperature, wallVelocityX);
+ myProblem.setOutletBoundaryCondition("Outlet", outletPressure,vector<double>(1,xsup));
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+ myProblem.setEntropicCorrection(true);
+
+ // name file save
+ string fileName = "1DDepressurisation";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep = 3;
+ int freqSave = 1;
+ double cfl = 0.95;
+ double maxTime = 5;
+ double precision = 1e-8;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ bool ok;
+
+ // evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "SinglePhase.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ double xinf=0.0;
+ double xsup=4.2;
+ int nx=50;
+ cout << "Building a regular mesh of "<< nx<< " cells " << endl;
+ Mesh M(xinf,xsup,nx);
+ double eps=1.E-8;
+ M.setGroupAtPlan(xsup,0,eps,"Outlet");//Neumann
+ M.setGroupAtPlan(xinf,0,eps,"Inlet");//
+ int spaceDim = M.getSpaceDimension();
+
+ // set the limit field for each boundary
+ LimitField limitInlet, limitOutlet;
+ map<string, LimitField> boundaryFields;
+
+ limitInlet.T =573.;
+ limitInlet.bcType=Inlet;
+ limitInlet.v_x = vector<double>(1,5);
+ boundaryFields["Inlet"] = limitInlet;
+
+ limitOutlet.bcType=Outlet;
+ limitOutlet.p = 155e5;
+ boundaryFields["Outlet"] = limitOutlet;
+
+ SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
+ int nbPhase = myProblem.getNumberOfPhases();
+ int nVar = myProblem.getNumberOfVariables();
+ Field VV("Primitive", CELLS, M, nVar);//Field of primitive unknowns
+
+ // Prepare for the initial condition
+ Vector VV_Constant(nVar);
+ VV_Constant(0) = 155e5;//pression initiale
+ VV_Constant(1) = 5;//vitesse initiale
+ VV_Constant(2) = 573;//temperature initiale
+
+ cout << "Number of Phases = " << nbPhase << endl;
+ cout << "Construction de la condition initiale ... " << endl;
+ //set the initial field
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ //set the boundary conditions
+ myProblem.setBoundaryFields(boundaryFields);
+
+ //Physical parameters
+ double heatPower=1e8;
+ myProblem.setHeatSource(heatPower);
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+
+ // name file save
+ string fileName = "1DHeatedChannel";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep =3;
+ int freqSave = 1;
+ double cfl = 0.95;
+ double maxTime = 5;
+ double precision = 1e-7;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ bool ok;
+
+ // evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
+
--- /dev/null
+#include "SinglePhase.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ cout << "Building cartesian mesh" << endl;
+ double xinf=0.0;
+ double xsup=4.2;
+ int nx=100;
+ Mesh M(xinf,xsup,nx);
+ double eps=1.E-8;
+ int spaceDim = M.getSpaceDimension();
+
+ //Initial data
+ double initialVelocityX =1;
+ double initialTemperature=600;
+ double initialPressure=155e5;
+
+ // physical parameters
+ Field porosityField("Porosity", CELLS, M, 1);
+ for(int i=0;i<M.getNumberOfCells();i++){
+ double x=M.getCell(i).x();
+ if (x> (xsup-xinf)/3 && x< 2*(xsup-xinf)/3)
+ porosityField[i]=0.5;
+ else
+ porosityField[i]=1;
+ }
+ porosityField.writeVTK("PorosityField",true);
+
+
+ SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
+ int nVar = myProblem.getNumberOfVariables();
+
+ // Prepare for the initial condition
+ vector<double> VV_Constant(nVar);
+ // constant vector
+ VV_Constant[0] = initialPressure;
+ VV_Constant[1] = initialVelocityX;
+ VV_Constant[2] = initialTemperature;
+
+ cout << "Building initial data " << endl;
+
+ // generate initial condition
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"Inlet","Outlet");
+
+ //set the boundary conditions
+ myProblem.setInletBoundaryCondition("Inlet",initialTemperature,initialVelocityX);
+ myProblem.setOutletBoundaryCondition("Outlet",initialPressure,vector<double>(1,xsup));
+ // physical parameters
+ myProblem.setPorosityField(porosityField);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+ myProblem.setWellBalancedCorrection(true);
+ myProblem.setNonLinearFormulation(VFFC) ;
+
+ // name file save
+ string fileName = "1DPorosityJumpUpwindWB";
+
+
+ /* set numerical parameters */
+ unsigned MaxNbOfTimeStep =3;
+ int freqSave = 1;
+ double cfl = 0.95;
+ double maxTime = 5;
+ double precision = 1e-5;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ bool ok;
+
+ // evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
+
+
--- /dev/null
+#include "SinglePhase.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ cout << "Building Cartesian mesh " << endl;
+ double xinf=0.0;
+ double xsup=1.0;
+ int nx=10;
+ Mesh M(xinf,xsup,nx);
+ double eps=1.E-8;
+ M.setGroupAtPlan(xsup,0,eps,"LeftBoundary");
+ M.setGroupAtPlan(xinf,0,eps,"RightBoundary");
+ int spaceDim = M.getSpaceDimension();
+
+ //initial data
+ double initialVelocity_Left=1;
+ double initialTemperature_Left=565;
+ double initialPressure_Left=155e5;
+
+ //boundary data
+ double initialVelocity_Right=1;
+ double initialTemperature_Right=565;
+ double initialPressure_Right=155e5;
+
+ SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
+ // Prepare for the initial condition
+ int nVar = myProblem.getNumberOfVariables();
+ Vector VV_Left(nVar),VV_Right(nVar);
+ // left and right constant vectors
+ VV_Left[0] = initialPressure_Left;
+ VV_Left[1] = initialVelocity_Left;
+ VV_Left[2] = initialTemperature_Left ;
+
+ VV_Right[0] = initialPressure_Right;
+ VV_Right[1] = initialVelocity_Right;
+ VV_Right[2] = initialTemperature_Right ;
+
+ //Initial field creation
+ double discontinuity = (xinf+xsup)/2.;
+
+ cout << "Building initial data " << endl;
+ Field VV("Primitive", CELLS, M, nVar);
+
+ myProblem.setInitialFieldStepFunction(M,VV_Left,VV_Right,discontinuity);
+
+ //set the boundary conditions
+ myProblem.setNeumannBoundaryCondition("LeftBoundary");
+ myProblem.setNeumannBoundaryCondition("RightBoundary");
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+
+ // name file save
+ string fileName = "1DRiemannProblem";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep = 3;
+ int freqSave = 1;
+ double cfl = 0.95;
+ double maxTime = 5;
+ double precision = 1e-8;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveConservativeField(true);
+ myProblem.setSaveFileFormat(CSV);
+
+ // set display option to monitor the calculation
+ myProblem.setVerbose( true);
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "SinglePhase.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ /*Preprocessing: mesh and group creation*/
+ double xinf=0;
+ double xsup=1;
+ double yinf=0;
+ double ysup=1;
+ int nx=10;
+ int ny=10;
+ cout << "Building a regular mesh with "<<nx<<" times "<< ny<< " cells " << endl;
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny);
+ double eps=1.E-6;
+ M.setGroupAtPlan(xinf,0,eps,"coldWall");
+ M.setGroupAtPlan(xsup,0,eps,"hotWall");
+ M.setGroupAtPlan(yinf,1,eps,"coldWall");
+ M.setGroupAtPlan(ysup,1,eps,"hotWall");
+ int spaceDim = M.getSpaceDimension();
+
+ // physical constants
+ vector<double> viscosite(1), conductivite(1);
+ viscosite[0]= 8.85e-5;
+ conductivite[0]=1000;//transfert de chaleur du à l'ébullition en paroi.
+ vector<double> gravite(spaceDim,0.) ;
+ gravite[1]=-10;
+ gravite[0]=0;
+
+ // set the limit field for each boundary
+ LimitField limitColdWall, limitHotWall;
+ map<string, LimitField> boundaryFields;
+ limitColdWall.bcType=Wall;
+ limitColdWall.T = 590;//Temperature de la parois froide
+ limitColdWall.v_x = vector<double>(1,0);
+ limitColdWall.v_y = vector<double>(1,0);
+ boundaryFields["coldWall"]= limitColdWall;
+
+ limitHotWall.bcType=Wall;
+ limitHotWall.T = 560;//Temperature des parois chauffantes
+ limitHotWall.v_x = vector<double>(1,0);
+ limitHotWall.v_y = vector<double>(1,0);
+ boundaryFields["hotWall"]= limitHotWall;
+
+ SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
+ int nVar = myProblem.getNumberOfVariables();
+
+ //Initial field creation
+ cout << "Building initial data" << endl;
+ /* First case constant initial data */
+ Vector VV_Constant(nVar);
+ // constant vector
+ VV_Constant(0) = 155e5;
+ VV_Constant(1) = 0;
+ VV_Constant(2) = 0;
+ VV_Constant(3) = 573;
+
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ //set the boundary conditions
+ myProblem.setBoundaryFields(boundaryFields);
+
+ // physical parameters
+ myProblem.setViscosity(viscosite);
+ myProblem.setConductivity(conductivite);
+ myProblem.setGravity(gravite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Implicit);
+
+ // set the Petsc resolution
+ myProblem.setLinearSolver(GMRES,LU,false);
+
+ // name result file
+ string fileName = "2DHeatDrivenCavity";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep = 3;
+ int freqSave = 1;
+ double cfl = 10;
+ double maxTime = 50;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,50);
+ myProblem.saveVelocity();
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "SinglePhase.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ /*Preprocessing: mesh and group creation*/
+ double xinf=0;
+ double xsup=1;
+ double yinf=0;
+ double ysup=1;
+ cout << "Loading unstuctured mesh for test SinglePhase_2DHeatDrivenCavity_unstructured" << endl;
+ Mesh M("resources/BoxWithMeshWithTriangularCells.med");
+ double eps=1.E-6;
+ M.setGroupAtPlan(xinf,0,eps,"coldWall");
+ M.setGroupAtPlan(xsup,0,eps,"hotWall");
+ M.setGroupAtPlan(yinf,1,eps,"coldWall");
+ M.setGroupAtPlan(ysup,1,eps,"hotWall");
+ int spaceDim = M.getSpaceDimension();
+
+ // physical constants
+ vector<double> viscosite(1), conductivite(1);
+ viscosite[0]= 8.85e-5;
+ conductivite[0]=1000;//transfert de chaleur du à l'ébullition en paroi.
+ vector<double> gravite(spaceDim,0.) ;
+ gravite[1]=-10;
+ gravite[0]=0;
+
+ // set the limit field for each boundary
+ LimitField limitColdWall, limitHotWall;
+ map<string, LimitField> boundaryFields;
+ limitColdWall.bcType=Wall;
+ limitColdWall.T = 590;//Temperature de la parois froide
+ limitColdWall.v_x = vector<double>(1,0);
+ limitColdWall.v_y = vector<double>(1,0);
+ boundaryFields["coldWall"]= limitColdWall;
+
+ limitHotWall.bcType=Wall;
+ limitHotWall.T = 560;//Temperature des parois chauffantes
+ limitHotWall.v_x = vector<double>(1,0);
+ limitHotWall.v_y = vector<double>(1,0);
+ boundaryFields["hotWall"]= limitHotWall;
+
+ SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
+ int nVar = myProblem.getNumberOfVariables();
+
+ //Initial field creation
+ cout << "Construction de la condition initiale" << endl;
+ /* First case constant initial data */
+ Vector VV_Constant(nVar);
+ // constant vector
+ VV_Constant(0) = 155e5;
+ VV_Constant(1) = 0;
+ VV_Constant(2) = 0;
+ VV_Constant(3) = 573;
+
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ //set the boundary conditions
+ myProblem.setBoundaryFields(boundaryFields);
+
+ // physical parameters
+ myProblem.setViscosity(viscosite);
+ myProblem.setConductivity(conductivite);
+ myProblem.setGravity(gravite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Implicit);
+
+ // set the Petsc resolution
+ myProblem.setLinearSolver(GMRES,ILU,true);
+
+ // name result file
+ string fileName = "2DHeatDrivenCavity_unstructured";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep = 3;
+ int freqSave = 1;
+ double cfl = 1;
+ double maxTime = 50;
+ double precision = 1e-7;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,50);
+ myProblem.saveVelocity();
+
+ // evolution
+ myProblem.initialize();
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "SinglePhase.hxx"
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ int spaceDim = 2;
+
+ // Prepare for the mesh
+ double xinf = 0 ;
+ double xsup=3.0;
+ double yinf=0.0;
+ double ysup=5.0;
+ int nx=10;
+ int ny=10;
+
+ // set the limit field for each boundary
+ double wallVelocityX=0;
+ double wallVelocityY=0;
+ double wallTemperature=573;
+ double inletVelocityX=0;
+ double inletVelocityY=0.5;
+ double inletTemperature=563;
+ double outletPressure=155e5;
+
+ // physical constants
+ vector<double> gravite (spaceDim);
+
+ gravite[1]=-7;
+ gravite[0]=7;
+
+ double heatPower=1e8;
+
+ SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
+ int nVar =myProblem.getNumberOfVariables();
+
+ // Prepare for the initial condition
+ vector<double> VV_Constant (nVar);
+
+ // constant vector
+ VV_Constant[0] = outletPressure ;
+ VV_Constant[1] = inletVelocityX;
+ VV_Constant[2] = inletVelocityY;
+ VV_Constant[3] = inletTemperature ;
+
+ //Initial field creation
+ cout<<"Building initial data"<<endl;
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
+ xinf,xsup,nx,"wall","wall",
+ yinf,ysup,ny,"inlet","outlet",
+ 0.0,0.0, 0, "", "");
+
+ // the boundary conditions
+ vector<double>pressure_reference_point(2);
+ pressure_reference_point[0]=xsup;
+ pressure_reference_point[1]=ysup;
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,pressure_reference_point);
+ myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ // set physical parameters
+ myProblem.setHeatSource(heatPower);
+ myProblem.setGravity(gravite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(staggered, Implicit);
+ myProblem.setNonLinearFormulation(VFFC);
+
+ // name file save
+ string fileName = "2DInclinedHeatedChannel";
+
+ /* set numerical parameters */
+ unsigned MaxNbOfTimeStep =3;
+ int freqSave = 1;
+ double cfl = 0.95;
+ double maxTime = 5;
+ double precision = 1e-5;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.usePrimitiveVarsInNewton(true);
+ bool ok;
+
+ // evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
+
--- /dev/null
+#include "SinglePhase.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ cout << "Building cartesian mesh " << endl;
+ double xinf=0.0;
+ double xsup=1;
+ double yinf=0.0;
+ double ysup=1;
+ int nx=50;
+ int ny=50;
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny);
+ int spaceDim = M.getSpaceDimension();
+
+ // physical constants
+ vector<double> viscosite(1) ;
+ viscosite[0]= 0.025;
+
+ // set the limit field for each boundary
+ double fixedWallVelocityX=0;
+ double fixedWallVelocityY=0;
+ double fixedWallTemperature=273;
+
+ double movingWallVelocityX=1;
+ double movingWallVelocityY=0;
+ double movingWallTemperature=273;
+
+
+ SinglePhase myProblem(Gas,around1bar300K,spaceDim);
+ // Prepare for the initial condition
+ int nVar = myProblem.getNumberOfVariables();
+ vector<double> VV_Constant(nVar);
+ // constant vector
+ VV_Constant[0] = 1e5;
+ VV_Constant[1] = 0;
+ VV_Constant[2] = 0;
+ VV_Constant[3] = 273;
+
+ // name output file
+ string fileName = "2DLidDrivenCavityStructuredCentered1bar";
+
+ //Initial field creation
+ cout << "Building initial data" << endl;
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"fixedWall","fixedWall",yinf,ysup,ny,"fixedWall","movingWall");
+
+ //set the boundary conditions
+ myProblem.setWallBoundaryCondition("fixedWall", fixedWallTemperature, fixedWallVelocityX, fixedWallVelocityY);
+ myProblem.setWallBoundaryCondition("movingWall", movingWallTemperature, movingWallVelocityX, movingWallVelocityY);
+
+ // physical parameters
+ myProblem.setViscosity(viscosite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(staggered, Implicit);
+
+ // set the Petsc resolution
+ myProblem.setLinearSolver(GMRES,LU,true);
+
+ //Numerical parameters
+ unsigned MaxNbOfTimeStep = 3 ;
+ int freqSave = 1;
+ double cfl = 1;
+ double maxTime = 100000;
+ double precision = 1e-9;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision*1e8,20);
+ myProblem.saveVelocity();
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+
+}
--- /dev/null
+#include "SinglePhase.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ /* preprocessing: mesh and group creation */
+ cout << "Loading unstructured mesh for test SinglePhase_2DLidDrivenCavity_unstructured()" << endl;
+ double xinf=0.0;
+ double xsup=1.0;
+ double yinf=0.0;
+ double ysup=1.0;
+ Mesh M("resources/BoxWithMeshWithTriangularCells.med");
+ double eps=1.E-6;
+ M.setGroupAtPlan(xsup,0,eps,"wall");
+ M.setGroupAtPlan(xinf,0,eps,"wall");
+ M.setGroupAtPlan(yinf,1,eps,"wall");
+ M.setGroupAtPlan(ysup,1,eps,"MovingWall");
+ int spaceDim = M.getSpaceDimension();
+
+ // physical constants
+ vector<double> viscosite(1) ;
+ viscosite[0]= 0.025;
+
+ /* set the limit field for each boundary*/
+ LimitField limitWall;
+ map<string, LimitField> boundaryFields;
+ limitWall.bcType=Wall;
+ limitWall.T = 273;
+ limitWall.p = 1e5;
+ limitWall.v_x = vector<double>(1,0);
+ limitWall.v_y = vector<double>(1,0);
+ limitWall.v_z = vector<double>(1,0);
+ boundaryFields["wall"]= limitWall;
+
+ LimitField limitMovingWall;
+ limitMovingWall.bcType=Wall;
+ limitMovingWall.T = 273;
+ limitMovingWall.p = 1e5;
+ limitMovingWall.v_x = vector<double>(1,1);
+ limitMovingWall.v_y = vector<double>(1,0);
+ limitMovingWall.v_z = vector<double>(1,0);
+ boundaryFields["MovingWall"]= limitMovingWall;
+
+
+ SinglePhase myProblem(Liquid,around1bar300K,spaceDim);
+ int nbPhase = myProblem.getNumberOfPhases();
+ // Prepare for the initial condition
+ int nVar = myProblem.getNumberOfVariables();
+ Vector VV_Constant(nVar);
+ // constant vector
+ VV_Constant(0) = 1e5;
+ VV_Constant(1) = 0;
+ VV_Constant(2) = 0;
+ VV_Constant(3) = 273;
+
+ //Initial field creation
+ cout << "Setting initial data " << endl;
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ //set the boundary conditions
+ myProblem.setBoundaryFields(boundaryFields);
+
+ // physical parameters
+ myProblem.setViscosity(viscosite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Implicit);
+
+ // set the Petsc resolution
+ myProblem.setLinearSolver(GMRES,ILU,true);
+
+ // name file save
+ string fileName = "2DLidDrivenCavity_unstructured";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep = 3 ;
+ int freqSave = 1;
+ double cfl = 5;
+ double maxTime = 5;
+ double precision = 1e-8;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveVelocity();
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "SinglePhase.hxx"
+
+using namespace std;
+
+//Function that generates and save a spherical initial data
+/*void initialField(){
+ int spaceDim = 2;
+ int nVar=2+spaceDim;
+ double x,y;
+ cout << "Loading unstructured mesh " << endl;
+ Mesh M("../examples/resources/BoxWithMeshWithTriangularCells.med");
+ Field VV("Primitive variables for spherical explosion", CELLS, M, nVar);
+ vector<double>Vout(nVar), Vin(nVar);
+ Vin[0]=1.1;
+ Vin[1]=0;
+ Vin[2]=0;
+ Vin[3]=300;
+ Vout[0]=1;
+ Vout[1]=0;
+ Vout[2]=0;
+ Vout[3]=300;
+
+ for(int i=0;i<M.getNumberOfCells();i++){
+ x=M.getCell(i).x();
+ y=M.getCell(i).y();
+ if((x-0.5)*(x-0.5)+(y-0.5)*(y-0.5)<0.25*0.25)
+ for(int j=0;j<nVar;j++)
+ VV(i,j)=Vin[j];
+ else
+ for(int j=0;j<nVar;j++)
+ VV(i,j)=Vout[j];
+ }
+ //VV.writeMED("../examples/ressources/BoxWithMeshWithTriangularCells",false);
+}*/
+int main(int argc, char** argv)
+{
+ // preprocessing: mesh and group creation
+ cout << "Loading unstructured mesh and initial data for test SinglePhase_2DSphericalExplosion_unstructured()" << endl;
+ string inputfile="resources/BoxWithMeshWithTriangularCells";
+ string fieldName="Initial variables for spherical explosion";
+ int spaceDim=2;
+
+ SinglePhase myProblem(Gas,around1bar300K,spaceDim);
+
+ //Initial field creation
+ cout << "Loading unstructured mesh and initial data for test SinglePhase_2DSphericalExplosion_unstructured()" << endl;
+ myProblem.setInitialField(inputfile,fieldName,0);
+
+ //set the boundary conditions
+ double wallVelocityX=0;
+ double wallVelocityY=0;
+ double wallTemperature=563;
+ myProblem.setWallBoundaryCondition("GAUCHE", wallTemperature, wallVelocityX, wallVelocityY);
+ myProblem.setWallBoundaryCondition("DROITE", wallTemperature, wallVelocityX, wallVelocityY);
+ myProblem.setWallBoundaryCondition("HAUT", wallTemperature, wallVelocityX, wallVelocityY);
+ myProblem.setWallBoundaryCondition("BAS", wallTemperature, wallVelocityX, wallVelocityY);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+
+ // name file save
+ string fileName = "2DSphericalExplosion_unstructured";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep = 3 ;
+ int freqSave = 5;
+ double cfl = 0.5;
+ double maxTime = 5;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveVelocity();
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "SinglePhase.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group creation
+ double xinf=-0.005;
+ double xsup= 0.005;
+ double yinf=0.0;
+ double ysup=2.0;
+ int nx=50;
+ int ny=50;
+ cout << "Building a regular mesh with "<<nx<<" times "<< ny<< " cells " << endl;
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny);
+ double eps=1.E-6;
+ M.setGroupAtPlan(xsup,0,eps,"wall");
+ M.setGroupAtPlan(xinf,0,eps,"wall");
+ M.setGroupAtPlan(yinf,1,eps,"Neumann");//Inlet
+ M.setGroupAtPlan(ysup,1,eps,"Neumann");//Outlet
+ int spaceDim = M.getSpaceDimension();
+
+ // physical constants
+ vector<double> viscosite(1), conductivite(1);
+ viscosite[0]= 8.85e-5;
+ conductivite[0]=1000;//transfert de chaleur du à l'ébullition en paroi.
+
+ // set the limit field for each boundary
+ LimitField limitWall;
+ map<string, LimitField> boundaryFields;
+ limitWall.bcType=Wall;
+ limitWall.T = 623;//Temperature des parois chauffantes
+ limitWall.p = 155e5;
+ limitWall.v_x = vector<double>(1,0);
+ limitWall.v_y = vector<double>(1,0);
+ boundaryFields["wall"]= limitWall;
+
+ LimitField limitInlet;
+ limitInlet.bcType=Inlet;
+ limitInlet.T = 573;//Temperature d'entree du fluide
+ limitInlet.v_x = vector<double>(1,0);
+ limitInlet.v_y = vector<double>(1,5);//Vitesse d'entree du fluide
+ boundaryFields["Inlet"]= limitInlet;
+
+ LimitField limitOutlet;
+ limitOutlet.bcType=Outlet;
+ limitOutlet.p = 155e5;
+ boundaryFields["Outlet"]= limitOutlet;
+
+ LimitField limitNeumann;
+ limitNeumann.bcType=Neumann;
+ boundaryFields["Neumann"] = limitNeumann;
+
+ SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
+ int nVar = myProblem.getNumberOfVariables();
+
+ //Initial field creation
+ cout << "Construction de la condition initiale" << endl;
+ /* First case constant initial data */
+ Vector VV_Constant(nVar);
+ // constant vector
+ VV_Constant(0) = 155e5;
+ VV_Constant(1) = 0;
+ VV_Constant(2) = 5;
+ VV_Constant(3) = 573;
+ /* Second case restart from a previous calculation */
+/*
+ string inputfile = "SinglePhasePrim_2DChannelWithViscosityWithConduction";//nom du fichier (sans le .med)
+ int iter=50400;//numero du pas de temps a recuperer dans le fichier
+ Field VV1(inputfile,CELLS,"P,vx,vy,T",iter,0);//Chargement des valeurs du champ
+ for(int i=0;i<M.getNumberOfCells();i++)
+ for(int j=0;j<nVar;j++)
+ VV(i,j)=VV1(i,j);//recuperation des valeurs du champ
+*/
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ //set the boundary conditions
+ myProblem.setBoundaryFields(boundaryFields);
+
+ // physical parameters
+ myProblem.setViscosity(viscosite);
+ myProblem.setConductivity(conductivite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Implicit);
+
+ // set the Petsc resolution
+ myProblem.setLinearSolver(GMRES,ILU,true);
+
+ // name result file
+ string fileName = "2DHeatedWallChannel";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep = 3;
+ int freqSave = 1;
+ double cfl = 10;
+ double maxTime = 50;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,50);
+ myProblem.saveVelocity();
+
+ // evolution
+ myProblem.initialize();
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "SinglePhase.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ //Preprocessing: mesh and group importation
+ cout << "Reading a mesh with sudden cross-section change for test SinglePhase_2DWallHeatedChannel_ChangeSect()" << endl;
+ Mesh M("resources/VaryingSectionDuct.med");
+
+ // Conditions aux limites
+ //Bords externes
+ double xinf=0.0;
+ double xsup=0.01;
+ double yinf=0.0;
+ double ysup=0.01;
+ double eps=1.E-6;
+ M.setGroupAtPlan(xsup,0,eps,"Wall");
+ M.setGroupAtPlan(xinf,0,eps,"Wall");
+ M.setGroupAtPlan(yinf,1,eps,"Inlet");//
+ M.setGroupAtPlan(ysup,1,eps,"Outlet");//
+ //Bords internes
+ int nx=60, ny=60;//Nombre de cellules utilisees au depart dans Salome ou Alamos
+ double dx = (xsup-xinf)/nx, dy = (ysup-yinf)/ny;//taille d'une cellule
+ for(int i=0; i<ny/2;i++){
+ M.setGroupAtFaceByCoords((xsup-xinf)/4,(ysup-yinf)/4+(i+0.5)*dy,0,eps,"Wall");//Paroi verticale intérieure gauche
+ M.setGroupAtFaceByCoords((xsup-xinf)*3/4,(ysup-yinf)/4+(i+0.5)*dy,0,eps,"Wall");//Paroi verticale intérieure droitee
+ }
+ for(int i=0; i<nx/4;i++){
+ M.setGroupAtFaceByCoords((i+0.5)*dx,(ysup-yinf)/4,0,eps,"Wall");//paroi horizontale en bas à gauche
+ M.setGroupAtFaceByCoords((i+0.5)*dx,(ysup-yinf)*3/4,0,eps,"Wall");//paroi horizontale en haut à gauche
+ M.setGroupAtFaceByCoords((xsup-xinf)*3/4+(i+0.5)*dx,(ysup-yinf)/4,0,eps,"Wall");//paroi horizontale en bas à droite
+ M.setGroupAtFaceByCoords((xsup-xinf)*3/4+(i+0.5)*dx,(ysup-yinf)*3/4,0,eps,"Wall");//paroi horizontale en haut à droite
+ }
+
+ int spaceDim = M.getSpaceDimension();
+
+ // set the limit field for each boundary
+ LimitField limitWall;
+ map<string, LimitField> boundaryFields;
+ limitWall.bcType=Wall;
+ limitWall.T = 623;//Temperature des parois chauffantes
+ limitWall.p = 155e5;
+ limitWall.v_x = vector<double>(1,0);
+ limitWall.v_y = vector<double>(1,0);
+ boundaryFields["Wall"]= limitWall;
+
+ LimitField limitInlet;
+ limitInlet.bcType=Inlet;
+ limitInlet.T = 573;//Temperature d'entree du fluide
+ limitInlet.v_x = vector<double>(1,0);
+ limitInlet.v_y = vector<double>(1,2.5);//Vitesse d'entree du fluide
+ boundaryFields["Inlet"]= limitInlet;
+
+ LimitField limitOutlet;
+ limitOutlet.bcType=Outlet;
+ limitOutlet.p = 155e5;
+ boundaryFields["Outlet"]= limitOutlet;
+
+ SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
+ // Prepare for the initial condition
+ int nVar = myProblem.getNumberOfVariables();
+ Vector VV_Constant(nVar);
+ // constant vector
+ VV_Constant(0) = 155e5;
+ VV_Constant(1) = 0;
+ VV_Constant(2) = 2.5;
+ VV_Constant(3) = 573;
+
+ //Initial field creation
+ cout << "Building initial data" << endl;
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ // physical constants
+ vector<double> viscosite(1), conductivite(1);
+ viscosite[0]= 8.85e-5;
+ conductivite[0]=1000;//transfert de chaleur du à l'ébullition en paroi.
+
+ //Set boundary values
+ myProblem.setBoundaryFields(boundaryFields);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+
+ // name result file
+ string fileName = "2DWallHeatedChannel_ChangeSect";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep = 3;
+ int freqSave = 1;
+ double cfl =.5;
+ double maxTime = 500;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,50);
+ myProblem.saveVelocity();
+
+ // evolution
+ myProblem.initialize();
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "SinglePhase.hxx"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ int spaceDim = 3;
+ /*Preprocessing: mesh data*/
+ double xinf=0;
+ double xsup=1;
+ double yinf=0;
+ double ysup=1;
+ double zinf=0;
+ double zsup=1;
+ int nx=10;
+ int ny=10;
+ int nz=10;
+
+ /* set the limit field for each boundary*/
+ double coldWallVelocityX=0;
+ double coldWallVelocityY=0;
+ double coldWallVelocityZ=0;
+ double coldWallTemperature=563;
+
+ double hotWallVelocityX=0;
+ double hotWallVelocityY=0;
+ double hotWallVelocityZ=0;
+ double hotWallTemperature=613;
+
+ /* physical constants*/
+ vector<double> gravite(spaceDim,0.) ;
+ gravite[2]=-10;
+ gravite[1]=0;
+ gravite[0]=0;
+ vector<double> viscosite(1), conductivite(1);
+ viscosite[0]= 8.85e-5;
+ conductivite[0]=1000;//nucleate boiling heat transfert coefficient
+
+ SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
+ int nVar = myProblem.getNumberOfVariables();
+
+ //Initial field creation
+ cout << "Construction de la condition initiale" << endl;
+ vector<double> VV_Constant(nVar);
+ // constant vector
+ VV_Constant[0] = 155e5;
+ VV_Constant[1] = 0;
+ VV_Constant[2] = 0;
+ VV_Constant[3] = 0;
+ VV_Constant[4] = 573;
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"hotWall","hotWall",
+ yinf,ysup,ny,"hotWall","hotWall",
+ zinf,zsup,nz,"hotWall","coldWall");
+
+ //set the boundary conditions
+ myProblem.setWallBoundaryCondition("coldWall", coldWallTemperature, coldWallVelocityX, coldWallVelocityY, coldWallVelocityZ);
+ myProblem.setWallBoundaryCondition("hotWall", hotWallTemperature, hotWallVelocityX, hotWallVelocityY, hotWallVelocityZ);
+
+
+ // physical parameters
+ myProblem.setViscosity(viscosite);
+ myProblem.setConductivity(conductivite);
+ myProblem.setGravity(gravite);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Implicit);
+
+ // set the Petsc resolution
+ myProblem.setLinearSolver(GMRES,ILU,false);
+
+ // name result file
+ string fileName = "3DHeatDrivenCavity";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep = 3;
+ int freqSave = 1;
+ double cfl = 10;
+ double maxTime = 50;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,50);
+ myProblem.saveVelocity();
+
+ // evolution
+ myProblem.initialize();
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "SinglePhase.hxx"
+
+using namespace std;
+
+
+int main(int argc, char** argv)
+{
+ // preprocessing: mesh and group creation
+ cout << "Loading unstructured mesh for test SinglePhase_3DSphericalExplosion_unstructured()" << endl;
+ string inputfile="resources/meshCube.med";
+
+ double xinf=0;
+ double xsup=1;
+ double yinf=0;
+ double ysup=1;
+ double zinf=0;
+ double zsup=1;
+ Mesh M(inputfile);
+ double eps=1.E-6;
+ M.setGroupAtPlan(xinf,0,eps,"GAUCHE");
+ M.setGroupAtPlan(xsup,0,eps,"DROITE");
+ M.setGroupAtPlan(yinf,1,eps,"ARRIERE");
+ M.setGroupAtPlan(ysup,1,eps,"AVANT");
+ M.setGroupAtPlan(zinf,2,eps,"BAS");
+ M.setGroupAtPlan(zsup,2,eps,"HAUT");
+
+ /* Initial field data */
+ int spaceDim = 3;
+ int nVar=2+spaceDim;
+ double radius=0.5;
+ Vector Center(3);//default value is (0,0,0)
+ Vector Vout(nVar), Vin(nVar);
+ Vin[0]=1.1;
+ Vin[1]=0;
+ Vin[2]=0;
+ Vin[3]=0;
+ Vin[4]=300;
+ Vout[0]=1;
+ Vout[1]=0;
+ Vout[2]=0;
+ Vout[3]=0;
+ Vout[4]=300;
+
+
+ SinglePhase myProblem(Gas,around1bar300K,spaceDim);
+
+ /*Setting mesh and Initial */
+ cout << "Setting initial data " << endl;
+ myProblem.setInitialFieldSphericalStepFunction( M, Vout, Vin, radius, Center);
+
+ //set the boundary conditions
+ double wallVelocityX=0;
+ double wallVelocityY=0;
+ double wallVelocityZ=0;
+ double wallTemperature=563;
+ myProblem.setWallBoundaryCondition("GAUCHE", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
+ myProblem.setWallBoundaryCondition("DROITE", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
+ myProblem.setWallBoundaryCondition("HAUT", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
+ myProblem.setWallBoundaryCondition("BAS" , wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
+ myProblem.setWallBoundaryCondition("AVANT", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
+ myProblem.setWallBoundaryCondition("ARRIERE" , wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
+
+ // set the numerical method
+ myProblem.setNumericalScheme(upwind, Explicit);
+
+ // name file save
+ string fileName = "3DSphericalExplosion_unstructured";
+
+ // parameters calculation
+ unsigned MaxNbOfTimeStep = 3 ;
+ int freqSave = 1;
+ double cfl = 0.3;
+ double maxTime = 5;
+ double precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveVelocity();
+
+ // evolution
+ myProblem.initialize();
+
+ bool ok = myProblem.run();
+ if (ok)
+ cout << "Simulation "<<fileName<<" is successful !" << endl;
+ else
+ cout << "Simulation "<<fileName<<" failed ! " << endl;
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "SinglePhase.hxx"\r
+\r
+using namespace std;\r
+\r
+int main(int argc, char** argv)\r
+{\r
+ //Preprocessing: mesh and group creation\r
+ cout << "Reading mesh with two branches and two forks" << endl;\r
+ Mesh M("resources/BifurcatingFlow2BranchesEqualSections.med");\r
+ cout << "Reading power and coss sectional area fields " << endl;\r
+ Field Sections("resources/BifurcatingFlow2BranchesEqualSections", CELLS,"Section area");\r
+ Field heatPowerField("resources/BifurcatingFlow2BranchesEqualSections", CELLS,"Heat power");\r
+\r
+ heatPowerField.writeVTK("heatPowerField");\r
+ Sections.writeVTK("crossSectionPowerField");\r
+\r
+ M.getFace(0).setGroupName("Inlet");//z==0\r
+ M.getFace(31).setGroupName("Outlet");//z==4.2\r
+ cout<<"F0.isBorder() "<<M.getFace(0).isBorder()<<endl;\r
+ int meshDim = 1;//M.getSpaceDimension();\r
+\r
+ // set the limit values for each boundary\r
+ double inletTemperature =573.;\r
+ double inletVelocityX = 5;\r
+ double outletPressure = 155e5;\r
+\r
+ SinglePhase myProblem(Liquid,around155bars600K,meshDim);\r
+ int nVar = myProblem.getNumberOfVariables();\r
+\r
+ //Set heat source\r
+ myProblem.setHeatPowerField(heatPowerField);\r
+ //Set gravity force\r
+ vector<double> gravite(1,-10);\r
+ myProblem.setGravity(gravite);\r
+\r
+ //Set section field\r
+ myProblem.setSectionField(Sections);\r
+ // Prepare the initial condition\r
+ Vector VV_Constant(nVar);\r
+ VV_Constant(0) = 155e5;\r
+ VV_Constant(1) = 5;\r
+ VV_Constant(2) = 573;\r
+\r
+ cout << "Building initial data " << endl;\r
+\r
+ // generate initial condition\r
+ myProblem.setInitialFieldConstant(M,VV_Constant);\r
+\r
+ //set the boundary conditions\r
+ myProblem.setInletBoundaryCondition("Inlet",inletTemperature,inletVelocityX);\r
+ myProblem.setOutletBoundaryCondition("Outlet", outletPressure);\r
+\r
+ // set the numerical method\r
+ myProblem.setNumericalScheme(upwind, Explicit);\r
+ myProblem.setWellBalancedCorrection(true);\r
+\r
+ // name file save\r
+ string fileName = "2BranchesHeatedChannels";\r
+\r
+ // parameters calculation\r
+ unsigned MaxNbOfTimeStep =3;\r
+ int freqSave = 1;\r
+ double cfl = 0.5;\r
+ double maxTime = 5;\r
+ double precision = 1e-6;\r
+\r
+ myProblem.setCFL(cfl);\r
+ myProblem.setPrecision(precision);\r
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
+ myProblem.setTimeMax(maxTime);\r
+ myProblem.setFreqSave(freqSave);\r
+ myProblem.setFileName(fileName);\r
+ bool ok;\r
+\r
+ // evolution\r
+ myProblem.initialize();\r
+ ok = myProblem.run();\r
+ if (ok)\r
+ cout << "Simulation "<<fileName<<" is successful !" << endl;\r
+ else\r
+ cout << "Simulation "<<fileName<<" failed ! " << endl;\r
+\r
+ cout << "------------ End of calculation -----------" << endl;\r
+ myProblem.terminate();\r
+\r
+ return EXIT_SUCCESS;\r
+}\r
+\r
--- /dev/null
+#include "StationaryDiffusionEquation.hxx"
+#include "Node.hxx"
+#include "math.h"
+#include <assert.h>
+
+double pi = M_PI;
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ int spaceDim = 2;
+
+ /* Mesh data */
+ double xinf=0.0;
+ double xsup=1.0;
+ double yinf=0.0;
+ double ysup=1.0;
+ int nx=20;
+ int ny=20;
+
+ /* Mesh construction */
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny,0); //Regular triangular mesh
+
+ /* set the limit field for each boundary */
+ double eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1");
+ M.setGroupAtPlan(xinf,0,eps,"Bord2");
+ M.setGroupAtPlan(ysup,1,eps,"Bord3");
+ M.setGroupAtPlan(yinf,1,eps,"Bord4");
+
+ /* set the boundary values for each boundary */
+ double T1=0;
+ double T2=0;
+ double T3=0;
+ double T4=0;
+
+ cout<< "Built a regular triangular 2D mesh from a square mesh with "<< nx<<"x" <<ny<< " cells"<<endl;
+
+ /* Create the problem */
+ bool FEComputation=true;
+ StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ /* set the boundary conditions */
+ myProblem.setDirichletBoundaryCondition("Bord1",T1);
+ myProblem.setDirichletBoundaryCondition("Bord2",T2);
+ myProblem.setDirichletBoundaryCondition("Bord3",T3);
+ myProblem.setDirichletBoundaryCondition("Bord4",T4);
+
+ /* Set the right hand side function*/
+ Field my_RHSfield("RHS_field", NODES, M, 1);
+ Node Ni;
+ double x, y;
+ for(int i=0; i< M.getNumberOfNodes(); i++)
+ {
+ Ni= M.getNode(i);
+ x = Ni.x();
+ y = Ni.y();
+
+ my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y);//mettre la fonction definie au second membre de l'edp
+ }
+ myProblem.setHeatPowerField(my_RHSfield);
+ myProblem.setLinearSolver(GMRES,ILU);
+
+ /* name the result file */
+ string fileName = "StationnaryDiffusion_2DFV_StructuredTriangles";
+ myProblem.setFileName(fileName);
+
+ /* Run the computation */
+ myProblem.initialize();
+ bool ok = myProblem.solveStationaryProblem();
+ if (!ok)
+ cout << "Simulation of "<<fileName<<" failed !" << endl;
+ else
+ {
+ /********************** Postprocessing and measure od numerical error******************************/
+ Field my_ResultField = myProblem.getOutputTemperatureField();
+ /* The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi */
+ double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi);
+ double max_sol_num=my_ResultField.max();
+ double min_sol_num=my_ResultField.min();
+ double erreur_abs=0;
+ for(int i=0; i< M.getNumberOfNodes() ; i++)
+ if( erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) )
+ erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]);
+
+ cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
+ cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
+ cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
+
+ assert( erreur_abs/max_abs_sol_exacte <1.);
+
+ cout << "Simulation of "<<fileName<<" is successful ! " << endl;
+ }
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "StationaryDiffusionEquation.hxx"
+#include "Node.hxx"
+#include "math.h"
+#include <assert.h>
+
+double pi = M_PI;
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ int spaceDim = 2;
+
+ /* Mesh data */
+ double xinf=0.0;
+ double xsup=1.0;
+ double yinf=0.0;
+ double ysup=1.0;
+ int nx=20;
+ int ny=20;
+
+ /* Mesh construction */
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny,0); //Regular triangular mesh
+
+ /* set the limit field for each boundary */
+ double eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1");
+ M.setGroupAtPlan(xinf,0,eps,"Bord2");
+ M.setGroupAtPlan(ysup,1,eps,"Bord3");
+ M.setGroupAtPlan(yinf,1,eps,"Bord4");
+
+ /* set the boundary values for each boundary */
+ double T1=0;
+ double T2=0;
+ double T3=0;
+ double T4=0;
+
+ cout<< "Built a regular triangular 2D mesh from a square mesh with "<< nx<<"x" <<ny<< " cells"<<endl;
+
+ /* Create the problem */
+ bool FEComputation=true;
+ StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ /* set the boundary conditions */
+ myProblem.setNeumannBoundaryCondition("Bord1");
+ myProblem.setNeumannBoundaryCondition("Bord2");
+ myProblem.setNeumannBoundaryCondition("Bord3");
+ myProblem.setNeumannBoundaryCondition("Bord4");
+
+ /* Set the right hand side function*/
+ Field my_RHSfield("RHS_field", NODES, M, 1);
+ Node Ni;
+ double x, y;
+ for(int i=0; i< M.getNumberOfNodes(); i++)
+ {
+ Ni= M.getNode(i);
+ x = Ni.x();
+ y = Ni.y();
+
+ my_RHSfield[i]=2*pi*pi*cos(pi*x)*cos(pi*y);//mettre la fonction definie au second membre de l'edp
+ }
+ myProblem.setHeatPowerField(my_RHSfield);
+ myProblem.setLinearSolver(GMRES,ILU);
+
+ /* name the result file */
+ string fileName = "StationnaryDiffusion_2DFV_StructuredTriangles_Neumann";
+ myProblem.setFileName(fileName);
+
+ /* Run the computation */
+ myProblem.initialize();
+ bool ok = myProblem.solveStationaryProblem();
+ if (!ok)
+ cout << "Simulation of "<<fileName<<" failed !" << endl;
+ else
+ {
+ /********************** Postprocessing and measure od numerical error******************************/
+ Field my_ResultField = myProblem.getOutputTemperatureField();
+ /* The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi */
+ double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi);
+ double max_sol_num=my_ResultField.max();
+ double min_sol_num=my_ResultField.min();
+ double erreur_abs=0;
+ for(int i=0; i< M.getNumberOfNodes() ; i++)
+ if( erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) )
+ erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]);
+
+ cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
+ cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
+ cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
+
+ assert( erreur_abs/max_abs_sol_exacte <1.);
+
+ cout << "Simulation of "<<fileName<<" is successful ! " << endl;
+ }
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "StationaryDiffusionEquation.hxx"
+#include "Node.hxx"
+#include "math.h"
+#include <assert.h>
+
+double pi = M_PI;
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ int spaceDim = 2;
+
+ /* Square mesh and groups loading */
+ string filename="resources/squareWithTriangles.med";
+ cout << "Loading mesh and groups from file" << filename<<endl;
+ Mesh M(filename);//unstructured triangular mesh
+
+ /* set the limit field for each boundary */
+ double eps=1e-6;
+ M.setGroupAtPlan(0,0,eps,"Bord1");
+ M.setGroupAtPlan(1,0,eps,"Bord2");
+ M.setGroupAtPlan(0,1,eps,"Bord3");
+ M.setGroupAtPlan(1,1,eps,"Bord4");
+
+ cout<< "Loaded unstructured 2D mesh with "<< M.getNumberOfCells()<<" cells and " <<M.getNumberOfNodes()<< " nodes"<<endl;
+
+ /* set the boundary values for each boundary */
+ double T1=0;
+ double T2=0;
+ double T3=0;
+ double T4=0;
+
+ /* Create the problem */
+ bool FEComputation=true;
+ StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ /* set the boundary conditions */
+ myProblem.setDirichletBoundaryCondition("Bord1",T1);
+ myProblem.setDirichletBoundaryCondition("Bord2",T2);
+ myProblem.setDirichletBoundaryCondition("Bord3",T3);
+ myProblem.setDirichletBoundaryCondition("Bord4",T4);
+
+ /* Set the right hand side function*/
+ Field my_RHSfield("RHS_field", NODES, M, 1);
+ Node Ni;
+ double x, y;
+ for(int i=0; i< M.getNumberOfNodes(); i++)
+ {
+ Ni= M.getNode(i);
+ x = Ni.x();
+ y = Ni.y();
+
+ my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y);//mettre la fonction definie au second membre de l'edp
+ }
+ myProblem.setHeatPowerField(my_RHSfield);
+ myProblem.setLinearSolver(GMRES,ILU);
+
+ /* name the result file */
+ string fileName = "StationnaryDiffusion_2DEF_UnstructuredTriangles";
+ myProblem.setFileName(fileName);
+
+ /* Run the computation */
+ myProblem.initialize();
+ bool ok = myProblem.solveStationaryProblem();
+ if (!ok)
+ cout << "Simulation of "<<fileName<<" failed !" << endl;
+ else
+ {
+ /********************** Postprocessing and measure od numerical error******************************/
+ Field my_ResultField = myProblem.getOutputTemperatureField();
+ /* The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi */
+ double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi);
+ double max_sol_num=my_ResultField.max();
+ double min_sol_num=my_ResultField.min();
+ double erreur_abs=0;
+ for(int i=0; i< M.getNumberOfNodes() ; i++)
+ if( erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) )
+ erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]);
+
+ cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
+ cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
+ cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
+
+ assert( erreur_abs/max_abs_sol_exacte <1.);
+
+ cout << "Simulation of "<<fileName<<" is successful ! " << endl;
+ }
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "StationaryDiffusionEquation.hxx"
+#include "Node.hxx"
+#include "math.h"
+#include <assert.h>
+
+double pi = M_PI;
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ int spaceDim = 2;
+
+ /* Mesh data */
+ double xinf=0.0;
+ double xsup=1.0;
+ double yinf=0.0;
+ double ysup=1.0;
+ int nx=30;
+ int ny=30;
+
+ /* Mesh construction */
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny); //Regular square mesh
+
+ /* set the limit field for each boundary */
+ double eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1");
+ M.setGroupAtPlan(xinf,0,eps,"Bord2");
+ M.setGroupAtPlan(ysup,1,eps,"Bord3");
+ M.setGroupAtPlan(yinf,1,eps,"Bord4");
+
+ /* set the boundary values for each boundary */
+ double T1=0;
+ double T2=0;
+ double T3=0;
+ double T4=0;
+
+ cout<< "Built a regular square 2D mesh with "<< nx<<"x" <<ny<< " cells"<<endl;
+
+ /* Create the problem */
+ bool FEComputation=false;
+ StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ /* set the boundary conditions */
+ myProblem.setDirichletBoundaryCondition("Bord1",T1);
+ myProblem.setDirichletBoundaryCondition("Bord2",T2);
+ myProblem.setDirichletBoundaryCondition("Bord3",T3);
+ myProblem.setDirichletBoundaryCondition("Bord4",T4);
+
+ /* Set the right hand side function*/
+ Field my_RHSfield("RHS_field", CELLS, M, 1);
+ Cell Ci;
+ double x, y;
+ for(int i=0; i< M.getNumberOfCells(); i++)
+ {
+ Ci= M.getCell(i);
+ x = Ci.x();
+ y = Ci.y();
+
+ my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y);//mettre la fonction definie au second membre de l'edp
+ }
+ myProblem.setHeatPowerField(my_RHSfield);
+ myProblem.setLinearSolver(GMRES,ILU);
+
+ /* name the result file */
+ string fileName = "StationnaryDiffusion_2DFV_StructuredSquares";
+ myProblem.setFileName(fileName);
+
+ /* Run the computation */
+ myProblem.initialize();
+ bool ok = myProblem.solveStationaryProblem();
+ if (!ok)
+ cout << "Simulation of "<<fileName<<" failed !" << endl;
+ else
+ {
+ /********************** Postprocessing and measure od numerical error******************************/
+ Field my_ResultField = myProblem.getOutputTemperatureField();
+ /* The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi */
+ double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi);
+ double max_sol_num=my_ResultField.max();
+ double min_sol_num=my_ResultField.min();
+ double erreur_abs=0;
+ for(int i=0; i< M.getNumberOfCells() ; i++)
+ if( erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) )
+ erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]);
+
+ cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
+ cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
+ cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
+
+ assert( erreur_abs/max_abs_sol_exacte <1.);
+
+ cout << "Simulation of "<<fileName<<" is successful ! " << endl;
+ }
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "StationaryDiffusionEquation.hxx"
+#include "Node.hxx"
+#include "math.h"
+#include <assert.h>
+
+double pi = M_PI;
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ int spaceDim = 2;
+
+ /* Mesh data */
+ double xinf=0.0;
+ double xsup=1.0;
+ double yinf=0.0;
+ double ysup=1.0;
+ int nx=20;
+ int ny=20;
+
+ /* Mesh construction */
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny,0); //Regular triangular mesh
+
+ /* set the limit field for each boundary */
+ double eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1");
+ M.setGroupAtPlan(xinf,0,eps,"Bord2");
+ M.setGroupAtPlan(ysup,1,eps,"Bord3");
+ M.setGroupAtPlan(yinf,1,eps,"Bord4");
+
+ /* set the boundary values for each boundary */
+ double T1=0;
+ double T2=0;
+ double T3=0;
+ double T4=0;
+
+ cout<< "Building of a regular triangular 2D mesh from a square mesh with "<< nx<<"x" <<ny<< " cells"<<endl;
+
+ /* Create the problem */
+ bool FEComputation=false;
+ StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ /* set the boundary conditions */
+ myProblem.setDirichletBoundaryCondition("Bord1",T1);
+ myProblem.setDirichletBoundaryCondition("Bord2",T2);
+ myProblem.setDirichletBoundaryCondition("Bord3",T3);
+ myProblem.setDirichletBoundaryCondition("Bord4",T4);
+
+ /* Set the right hand side function*/
+ Field my_RHSfield("RHS_field", CELLS, M, 1);
+ Cell Ci;
+ double x, y;
+ for(int i=0; i< M.getNumberOfCells(); i++)
+ {
+ Ci= M.getCell(i);
+ x = Ci.x();
+ y = Ci.y();
+
+ my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y);//mettre la fonction definie au second membre de l'edp
+ }
+ myProblem.setHeatPowerField(my_RHSfield);
+ myProblem.setLinearSolver(GMRES,ILU);
+
+ /* name the result file */
+ string fileName = "StationnaryDiffusion_2DFV";
+ myProblem.setFileName(fileName);
+
+ /* Run the computation */
+ myProblem.initialize();
+ bool ok = myProblem.solveStationaryProblem();
+ if (!ok)
+ cout << "Simulation of "<<fileName<<" failed !" << endl;
+ else
+ {
+ /********************** Postprocessing and measure od numerical error******************************/
+ Field my_ResultField = myProblem.getOutputTemperatureField();
+ /* The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi */
+ double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi);
+ double max_sol_num=my_ResultField.max();
+ double min_sol_num=my_ResultField.min();
+ double erreur_abs=0;
+ for(int i=0; i< M.getNumberOfCells() ; i++)
+ if( erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) )
+ erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]);
+
+ cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
+ cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
+ cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
+
+ assert( erreur_abs/max_abs_sol_exacte <1.);
+
+ cout << "Simulation of "<<fileName<<" is successful ! " << endl;
+ }
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "StationaryDiffusionEquation.hxx"
+#include "Node.hxx"
+#include "math.h"
+#include <assert.h>
+
+double pi = M_PI;
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ int spaceDim = 2;
+
+ /* Mesh data */
+ double xinf=0.0;
+ double xsup=1.0;
+ double yinf=0.0;
+ double ysup=1.0;
+ int nx=20;
+ int ny=20;
+
+ /* Mesh construction */
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny,0); //Regular triangular mesh
+
+ /* set the limit field for each boundary */
+ double eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1");
+ M.setGroupAtPlan(xinf,0,eps,"Bord2");
+ M.setGroupAtPlan(ysup,1,eps,"Bord3");
+ M.setGroupAtPlan(yinf,1,eps,"Bord4");
+
+ /* set the boundary values for each boundary */
+ double T1=0;
+ double T2=0;
+ double T3=0;
+ double T4=0;
+
+ cout<< "Building of a regular triangular 2D mesh from a square mesh with "<< nx<<"x" <<ny<< " cells"<<endl;
+
+ /* Create the problem */
+ bool FEComputation=false;
+ StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ /* set the boundary conditions */
+ myProblem.setNeumannBoundaryCondition("Bord1");
+ myProblem.setNeumannBoundaryCondition("Bord2");
+ myProblem.setNeumannBoundaryCondition("Bord3");
+ myProblem.setNeumannBoundaryCondition("Bord4");
+
+ /* Set the right hand side function*/
+ Field my_RHSfield("RHS_field", CELLS, M, 1);
+ Cell Ci;
+ double x, y;
+ for(int i=0; i< M.getNumberOfCells(); i++)
+ {
+ Ci= M.getCell(i);
+ x = Ci.x();
+ y = Ci.y();
+
+ my_RHSfield[i]=2*pi*pi*cos(pi*x)*cos(pi*y);//mettre la fonction definie au second membre de l'edp
+ }
+ myProblem.setHeatPowerField(my_RHSfield);
+ myProblem.setLinearSolver(GMRES,ILU);
+
+ /* name the result file */
+ string fileName = "StationnaryDiffusion_2DFV_RegularTriangles_Neumann";
+ myProblem.setFileName(fileName);
+
+ /* Run the computation */
+ myProblem.initialize();
+ bool ok = myProblem.solveStationaryProblem();
+ if (!ok)
+ cout << "Simulation of "<<fileName<<" failed !" << endl;
+ else
+ {
+ /********************** Postprocessing and measure od numerical error******************************/
+ Field my_ResultField = myProblem.getOutputTemperatureField();
+ /* The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi */
+ double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi);
+ double max_sol_num=my_ResultField.max();
+ double min_sol_num=my_ResultField.min();
+ double erreur_abs=0;
+ for(int i=0; i< M.getNumberOfCells() ; i++)
+ if( erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) )
+ erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]);
+
+ cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
+ cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
+ cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
+
+ assert( erreur_abs/max_abs_sol_exacte <1.);
+
+ cout << "Simulation of "<<fileName<<" is successful ! " << endl;
+ }
+
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "StationaryDiffusionEquation.hxx"
+#include "Node.hxx"
+#include "math.h"
+#include <assert.h>
+
+double pi = M_PI;
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ int spaceDim = 3;
+
+ /* Mesh data */
+ double xinf=0.0;
+ double xsup=1.0;
+ double yinf=0.0;
+ double ysup=1.0;
+ double zinf=0.0;
+ double zsup=1.0;
+ int nx=2;
+ int ny=2;
+ int nz=2;
+
+ /* Mesh construction : splitting polity to 0 yield all nodes considered boundary nodes */
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz,0); //Regular tetrahadral mesh
+
+ /* set the limit field for each boundary */
+ double eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1");
+ M.setGroupAtPlan(xinf,0,eps,"Bord2");
+ M.setGroupAtPlan(ysup,1,eps,"Bord3");
+ M.setGroupAtPlan(yinf,1,eps,"Bord4");
+ M.setGroupAtPlan(zsup,2,eps,"Bord5");
+ M.setGroupAtPlan(zinf,2,eps,"Bord6");
+
+ /* set the boundary values for each boundary */
+ double T1=0;
+ double T2=0;
+ double T3=0;
+ double T4=0;
+ double T5=0;
+ double T6=0;
+
+ cout<< "Built a regular tetrahedral 3D mesh from a cube mesh with "<< nx<<"x" <<ny<<"x" <<nz<< " cells"<<endl;
+
+ /* Create the problem */
+ bool FEComputation=true;
+ StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ /* set the boundary conditions */
+ myProblem.setDirichletBoundaryCondition("Bord1",T1);
+ myProblem.setDirichletBoundaryCondition("Bord2",T2);
+ myProblem.setDirichletBoundaryCondition("Bord3",T3);
+ myProblem.setDirichletBoundaryCondition("Bord4",T4);
+ myProblem.setDirichletBoundaryCondition("Bord5",T5);
+ myProblem.setDirichletBoundaryCondition("Bord6",T6);
+
+ /* Set the right hand side function*/
+ Field my_RHSfield("RHS_field", NODES, M, 1);
+ Node Ni;
+ double x, y, z;
+ for(int i=0; i< M.getNumberOfNodes(); i++)
+ {
+ Ni= M.getNode(i);
+ x = Ni.x();
+ y = Ni.y();
+ z = Ni.z();
+
+ my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)*sin(pi*z);//mettre la fonction definie au second membre de l'edp
+ }
+ myProblem.setHeatPowerField(my_RHSfield);
+ myProblem.setLinearSolver(GMRES,ILU);
+
+ /* name the result file */
+ string fileName = "StationaryDiffusion_3DFE_StructuredTetrahedra";
+ myProblem.setFileName(fileName);
+
+ /* Run the computation */
+ myProblem.initialize();
+ bool ok = myProblem.solveStationaryProblem();
+ if (!ok)
+ cout << "Simulation of "<<fileName<<" failed !" << endl;
+ else
+ {
+ /********************** Postprocessing and measure od numerical error******************************/
+ Field my_ResultField = myProblem.getOutputTemperatureField();
+ /* The following formulas use the fact that the exact solution is equal the right hand side divided by 3*pi*pi */
+ double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(3*pi*pi);
+ double max_sol_num=my_ResultField.max();
+ double min_sol_num=my_ResultField.min();
+ double erreur_abs=0;
+ for(int i=0; i< M.getNumberOfNodes() ; i++)
+ if( erreur_abs < abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i]) )
+ erreur_abs = abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i]);
+
+ cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
+ cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
+ cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
+
+ assert( erreur_abs/max_abs_sol_exacte <1.);
+
+ cout << "Simulation of "<<fileName<<" is successful ! " << endl;
+ }
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "StationaryDiffusionEquation.hxx"
+#include "Node.hxx"
+#include "math.h"
+#include <assert.h>
+
+double pi = M_PI;
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ int spaceDim = 3;
+
+ /* Mesh data */
+ double xinf=0.0;
+ double xsup=1.0;
+ double yinf=0.0;
+ double ysup=1.0;
+ double zinf=0.0;
+ double zsup=1.0;
+ int nx=2;
+ int ny=2;
+ int nz=2;
+
+ /* Mesh construction : splitting polity to 0 yield all nodes considered boundary nodes */
+ Mesh M(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz,0); //Regular tetrahadral mesh
+
+ /* set the limit field for each boundary */
+ double eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1");
+ M.setGroupAtPlan(xinf,0,eps,"Bord2");
+ M.setGroupAtPlan(ysup,1,eps,"Bord3");
+ M.setGroupAtPlan(yinf,1,eps,"Bord4");
+ M.setGroupAtPlan(zsup,2,eps,"Bord5");
+ M.setGroupAtPlan(zinf,2,eps,"Bord6");
+
+ /* set the boundary values for each boundary */
+ double T1=0;
+ double T2=0;
+ double T3=0;
+ double T4=0;
+ double T5=0;
+ double T6=0;
+
+ cout<< "Built a regular tetrahedral 3D mesh from a cube mesh with "<< nx<<"x" <<ny<<"x" <<nz<< " cells"<<endl;
+
+ /* Create the problem */
+ bool FEComputation=false;
+ StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ /* set the boundary conditions */
+ myProblem.setDirichletBoundaryCondition("Bord1",T1);
+ myProblem.setDirichletBoundaryCondition("Bord2",T2);
+ myProblem.setDirichletBoundaryCondition("Bord3",T3);
+ myProblem.setDirichletBoundaryCondition("Bord4",T4);
+ myProblem.setDirichletBoundaryCondition("Bord5",T5);
+ myProblem.setDirichletBoundaryCondition("Bord6",T6);
+
+ /* Set the right hand side function*/
+ Field my_RHSfield("RHS_field", CELLS, M, 1);
+ Cell Ci;
+ double x, y, z;
+ for(int i=0; i< M.getNumberOfCells(); i++)
+ {
+ Ci= M.getCell(i);
+ x = Ci.x();
+ y = Ci.y();
+ z = Ci.z();
+
+ my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)*sin(pi*z);//mettre la fonction definie au second membre de l'edp
+ }
+ myProblem.setHeatPowerField(my_RHSfield);
+ myProblem.setLinearSolver(GMRES,ILU);
+
+ /* name the result file */
+ string fileName = "StationaryDiffusion_3DFV_StructuredTetrahedra";
+ myProblem.setFileName(fileName);
+
+ /* Run the computation */
+ myProblem.initialize();
+ bool ok = myProblem.solveStationaryProblem();
+ if (!ok)
+ cout << "Simulation of "<<fileName<<" failed !" << endl;
+ else
+ {
+ /********************** Postprocessing and measure od numerical error******************************/
+ Field my_ResultField = myProblem.getOutputTemperatureField();
+ /* The following formulas use the fact that the exact solution is equal the right hand side divided by 3*pi*pi */
+ double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(3*pi*pi);
+ double max_sol_num=my_ResultField.max();
+ double min_sol_num=my_ResultField.min();
+ double erreur_abs=0;
+ for(int i=0; i< M.getNumberOfNodes() ; i++)
+ if( erreur_abs < abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i]) )
+ erreur_abs = abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i]);
+
+ cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
+ cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
+ cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
+
+ assert( erreur_abs/max_abs_sol_exacte <1.);
+
+ cout << "Simulation of "<<fileName<<" is successful ! " << endl;
+ }
+ cout << "------------ End of calculation !!! -----------" << endl;
+ myProblem.terminate();
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+#include "TransportEquation.hxx"\r
+\r
+using namespace std;\r
+\r
+\r
+int main(int argc, char** argv)\r
+{\r
+ //Preprocessing: mesh and group creation\r
+ double xinf=0.0;\r
+ double xsup=4.2;\r
+ int nx=10;\r
+ cout << "Building a 1D mesh with "<<nx<<" cells" << endl;\r
+ Mesh M(xinf,xsup,nx);\r
+ double eps=1.E-8;\r
+ M.setGroupAtPlan(xsup,0,eps,"Neumann");\r
+ M.setGroupAtPlan(xinf,0,eps,"Inlet");\r
+ int spaceDim = M.getSpaceDimension();\r
+\r
+ // Boundary conditions\r
+ map<string, LimitFieldTransport> boundaryFields;\r
+\r
+ LimitFieldTransport limitNeumann;\r
+ limitNeumann.bcType=NeumannTransport;\r
+ boundaryFields["Neumann"] = limitNeumann;\r
+\r
+ LimitFieldTransport limitInlet;\r
+ limitInlet.bcType=InletTransport;\r
+ limitInlet.h =1.3e6;//Inlet water enthalpy\r
+ boundaryFields["Inlet"] = limitInlet;\r
+\r
+ //Set the fluid transport velocity\r
+ vector<double> transportVelocity(1,5);//fluid velocity vector\r
+\r
+ TransportEquation myProblem(LiquidPhase,around155bars600KTransport,transportVelocity);\r
+ Field VV("Enthalpy", CELLS, M, 1);\r
+\r
+ //Set rod temperature and heat exchamge coefficient\r
+ double rodTemp=623;//Rod clad temperature\r
+ double heatTransfertCoeff=1000;//fluid/solid exchange coefficient \r
+ myProblem.setRodTemperature(rodTemp);\r
+ myProblem.setHeatTransfertCoeff(heatTransfertCoeff);\r
+\r
+ //Initial field creation\r
+ Vector VV_Constant(1);//initial enthalpy\r
+ VV_Constant(0) = 1.3e6;\r
+\r
+ cout << "Building the initial data " << endl;\r
+\r
+ // generate initial condition\r
+ myProblem.setInitialFieldConstant(M,VV_Constant);\r
+\r
+ //set the boundary conditions\r
+ myProblem.setBoundaryFields(boundaryFields);\r
+\r
+ // set the numerical method\r
+ myProblem.setTimeScheme( Explicit);\r
+\r
+ // name result file\r
+ string fileName = "1DFluidEnthalpy";\r
+\r
+ // parameters calculation\r
+ unsigned MaxNbOfTimeStep =3;\r
+ int freqSave = 1;\r
+ double cfl = 0.95;\r
+ double maxTime = 5;\r
+ double precision = 1e-6;\r
+\r
+ myProblem.setCFL(cfl);\r
+ myProblem.setPrecision(precision);\r
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
+ myProblem.setTimeMax(maxTime);\r
+ myProblem.setFreqSave(freqSave);\r
+ myProblem.setFileName(fileName);\r
+\r
+ // set display option to monitor the calculation\r
+ bool computation=true;\r
+ bool system=true;\r
+ myProblem.setVerbose( computation, system);\r
+ myProblem.setSaveFileFormat(CSV);\r
+\r
+ // evolution\r
+ myProblem.initialize();\r
+ bool ok = myProblem.run();\r
+ if (ok)\r
+ cout << "Simulation "<<fileName<<" is successful !" << endl;\r
+ else\r
+ cout << "Simulation "<<fileName<<" failed ! " << endl;\r
+\r
+ cout << "------------ End of calculation -----------" << endl;\r
+ myProblem.terminate();\r
+\r
+ return EXIT_SUCCESS;\r
+}\r
--- /dev/null
+#include "SinglePhase_1DRiemannProblem.cxx"
+#include "SinglePhase_1DHeatedChannel.cxx"
+#include "SinglePhase_1DDepressurisation.cxx"
+#include "SinglePhase_2DWallHeatedChannel.cxx"
+#include "SinglePhase_2DWallHeatedChannel_ChangeSect.cxx"
+#include "SinglePhase_2DHeatedChannelInclined.cxx"
+#include "SinglePhase_HeatedWire_2Branches.cxx"
+#include "SinglePhase_2DLidDrivenCavity.cxx"
+#include "SinglePhase_2DLidDrivenCavity_unstructured.cxx"
+#include "SinglePhase_2DHeatDrivenCavity.cxx"
+#include "SinglePhase_2DHeatDrivenCavity_unstructured.cxx"
+#include "SinglePhase_2DSphericalExplosion_unstructured.cxx"
+#include "SinglePhase_3DHeatDrivenCavity.cxx"
+#include "DriftModel_1DBoilingChannel.cxx"
+#include "DriftModel_1DBoilingAssembly.cxx"
+#include "DriftModel_1DRiemannProblem.cxx"
+#include "DriftModel_1DPressureLoss.cxx"
+#include "DriftModel_1DDepressurisation.cxx"
+#include "DriftModel_2DInclinedBoilingChannel.cxx"
+#include "DriftModel_3DCanalCloison.cxx"
+#include "IsothermalTwoFluid_1DSedimentation.cxx"
+#include "IsothermalTwoFluid_1DRiemannProblem.cxx"
+#include "IsothermalTwoFluid_1DDepressurisation.cxx"
+#include "IsothermalTwoFluid_2DInclinedSedimentation.cxx"
+#include "IsothermalTwoFluid_2DVidangeReservoir.cxx"
+#include "FiveEqsTwoFluid_1DBoilingChannel.cxx"
+#include "FiveEqsTwoFluid_1DRiemannProblem.cxx"
+#include "FiveEqsTwoFluid_1DDepressurisation.cxx"
+#include "FiveEqsTwoFluid_2DInclinedBoilingChannel.cxx"
+#include "FiveEqsTwoFluid_2DInclinedSedimentation.cxx"
+#include "DiffusionEquation_1DHeatedRod.cxx"
+#include "TransportEquation_1DHeatedChannel.cxx"
+#include "CoupledTransportDiffusionEquations_1DHeatedChannel.cxx"
+
+using namespace std;
+
+
+int main(int argc,char **argv)
+{
+ if(!SinglePhase_1DRiemannProblem())
+ throw CdmathException("test SinglePhase_1DRiemannProblem failed");
+ else if(!SinglePhase_1DHeatedChannel())
+ throw CdmathException("test SinglePhase_1DHeatedChannel() failed");
+ else if(!SinglePhase_1DDepressurisation())
+ throw CdmathException("test SinglePhase_1DDepressurisation() failed");
+ else if (!SinglePhase_2DLidDrivenCavity())
+ throw CdmathException("test SinglePhase_2DLidDrivenCavity failed");
+ else if (!SinglePhase_2DLidDrivenCavity_unstructured())
+ throw CdmathException("test SinglePhase_2DLidDrivenCavity_unstructured failed");
+ else if (!SinglePhase_2DHeatDrivenCavity())
+ throw CdmathException("test SinglePhase_2DHeatDrivenCavity failed");
+ else if (!SinglePhase_2DHeatDrivenCavity_unstructured())
+ throw CdmathException("test SinglePhase_2DHeatDrivenCavity_unstructured failed");
+ else if(!SinglePhase_2DWallHeatedChannel())
+ throw CdmathException("test SinglePhase_2DWallHeatedChannel() failed");
+ else if(!SinglePhase_2DWallHeatedChannel_ChangeSect())
+ throw CdmathException("test SinglePhase_2DWallHeatedChannel_ChangeSect() failed");
+ else if(!SinglePhase_2DHeatedChannelInclined())
+ throw CdmathException("test SinglePhase_2DHeatedChannelInclined() failed");
+ else if(!SinglePhase_HeatedWire_2Branches())
+ throw CdmathException("test SinglePhase_HeatedWire_2Branches() failed");
+ else if (!SinglePhase_2DSphericalExplosion_unstructured())
+ throw CdmathException("test SinglePhase_2DSphericalExplosion_unstructured failed");
+ else if (!SinglePhase_3DHeatDrivenCavity())
+ throw CdmathException("test SinglePhase_3DHeatDrivenCavity failed");
+ else if(!DriftModel_1DRiemannProblem())
+ throw CdmathException("test DriftModel_1DRiemannProblem failed ");
+ else if(!DriftModel_1DPressureLoss())
+ throw CdmathException("test DriftModel_1DPressureLoss failed ");
+ else if(!DriftModel_1DBoilingChannel())
+ throw CdmathException("test DriftModel_1DBoilingChannel failed ");
+ else if(!DriftModel_1DBoilingAssembly())
+ throw CdmathException("test DriftModel_1DBoilingAssembly failed ");
+ else if(!DriftModel_1DDepressurisation())
+ throw CdmathException("test DriftModel_1DDepressurisation failed ");
+ else if(!DriftModel_2DInclinedBoilingChannel())
+ throw CdmathException("test DriftModel_2DInclinedBoilingChannel failed ");
+ else if(!DriftModel_3DCanalCloison())
+ throw CdmathException("test DriftModel_3DCanalCloison failed ");
+ else if(!IsothermalTwoFluid_1DRiemannProblem())
+ throw CdmathException("test IsothermalTwoFluid_1DRiemannProblem failed");
+ else if(!IsothermalTwoFluid_1DSedimentation())
+ throw CdmathException("test IsothermalTwoFluid_1DSedimentation failed");
+ else if(!IsothermalTwoFluid_1DDepressurisation())
+ throw CdmathException("test IsothermalTwoFluid_1DDepressurisation failed");
+ else if(!IsothermalTwoFluid_2DInclinedSedimentation())
+ throw CdmathException("test IsothermalTwoFluid_2DInclinedSedimentation failed");
+ else if(!IsothermalTwoFluid_2DVidangeReservoir())
+ throw CdmathException("test IsothermalTwoFluid_2DVidangeReservoir failed");
+ else if(!FiveEqsTwoFluid_1DRiemannProblem())
+ throw CdmathException("test FiveEqsTwoFluid_1DRiemannProblem failed");
+ else if(!FiveEqsTwoFluid_1DBoilingChannel())
+ throw CdmathException("test FiveEqsTwoFluid_1DBoilingChannel failed");
+ else if(!FiveEqsTwoFluid_1DDepressurisation())
+ throw CdmathException("test FiveEqsTwoFluid_1DDepressurisation failed");
+ else if(!FiveEqsTwoFluid_2DInclinedBoilingChannel())
+ throw CdmathException("test FiveEqsTwoFluid_2DInclinedBoilingChannel failed ");
+ else if(!FiveEqsTwoFluid_2DInclinedSedimentation())
+ throw CdmathException("test FiveEqsTwoFluid_2DInclinedSedimentation failed ");
+ else if(!TransportEquation_1DHeatedChannel())
+ throw CdmathException("test TransportEquation_1DHeatedChannel() failed");
+ else if(!DiffusionEquation_1DHeatedRod())
+ throw CdmathException("test DiffusionEquation_1DHeatedRod() failed");
+ else if(!CoupledTransportDiffusionEquations_1DHeatedChannel())
+ throw CdmathException("test CoupledTransportDiffusionEquations_1DHeatedChannel() failed");//choose correct physical parameters to obtain good physical results
+ else
+ cout<<"All C tests successful"<<endl;
+
+ return 1;
+}
--- /dev/null
+#include "Fluide.h"
+#include <cstdlib>
+
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv) {
+ double _Tsat = 656; //saturation temperature used in Dellacherie EOS
+ StiffenedGasDellacherie fluid1 = StiffenedGasDellacherie(1.43, 0,
+ 2.030255e6, 1040.14); //stiffened gas law for Gas from S. Dellacherie
+ StiffenedGasDellacherie fluid2 = StiffenedGasDellacherie(2.35, 1e9,
+ -1.167056e6, 1816.2); //stiffened gas law for water from S. Dellacherie
+
+ double P = 155e6;
+ double T = 500;
+ double h = 0;
+
+ double rho1 = fluid1.getDensity(P, T);
+ double Tvalid1 = fluid1.getTemperatureFromPressure(P, rho1);
+ double h1 = fluid1.getEnthalpy(T, rho1);
+
+ cout << endl;
+ cout << "density fluide 1 = " << rho1 << endl;
+ cout << "Tvalid1 fluide 1 = " << Tvalid1 << endl;
+ cout << "h1 fluide 1 = " << h1 << endl;
+
+ return EXIT_SUCCESS;
+}
project(test)
-INCLUDE_DIRECTORIES(
- ${PETSC_INCLUDES}
- ${CDMATH_INCLUDES}
- ${CDMATH_INCLUDES}/med #
- ${CDMATH_INCLUDES}/medcoupling #
- ${CoreFlows_SRC}/inc
-)
+file(GLOB MESHES_TO_INSTALL resources )
+install(DIRECTORY ${MESHES_TO_INSTALL} DESTINATION share/examples)
-
-SET(_extra_lib_CoreFlows CoreFlows ${PETSC_LIBRARIES} ${CDMATH_LIBRARIES})
-
-
-if(CMAKE_COMPILER_IS_GNUCXX)
- if (CMAKE_BUILD_TYPE STREQUAL Debug)
- include(CodeCoverage)
- setup_target_for_coverage(cov ctest coverage)
- endif()
-endif()
-
-
-file(GLOB NICE_EXAMPLES_TO_INSTALL resources )
-install(DIRECTORY ${NICE_EXAMPLES_TO_INSTALL} DESTINATION share/examples)
-
-##################################### test generation with ctest
-
-# this function creates a target and a ctest test
-function(CreateTestExec SourceTestFile libList)
- message("Setting cpp test ${EXECNAME}")
- get_filename_component( FILE_BASENAME ${SourceTestFile} NAME_WE) # <path>/testxxx.c --> testxxx
- set( EXECNAME "${FILE_BASENAME}.exe" ) # testxxx --> testxxx.exe
- add_executable(${EXECNAME} ${SourceTestFile}) # compilation of the testxxx.exe
- set_target_properties(${EXECNAME} PROPERTIES COMPILE_FLAGS "")
- target_link_libraries(${EXECNAME} ${libList}) # provide required lib for testxxx.exe
- add_test(${FILE_BASENAME} ${EXECNAME} "./${EXECNAME}") # adding a ctest Test
-endfunction(CreateTestExec)
-
-# this function creates a target and a ctest test
-# and also create install rules for copying the example
-# in the install dir
-function(CreateTestExecAndInstall SourceTestFile libList)
- message("Setting cpp test ${EXECNAME}")
- get_filename_component( FILE_BASENAME ${SourceTestFile} NAME_WE) # <path>/testxxx.c --> testxxx
- set( EXECNAME "${FILE_BASENAME}.exe" ) # testxxx --> testxxx.exe
- add_executable(${EXECNAME} ${SourceTestFile}) # compilation of the testxxx.exe
- set_target_properties(${EXECNAME} PROPERTIES COMPILE_FLAGS "")
- target_link_libraries(${EXECNAME} ${libList}) # provide required lib for testxxx.exe
- add_test(NAME ${EXECNAME} COMMAND "./${EXECNAME}") # adding a ctest Test
- install(TARGETS ${EXECNAME} DESTINATION share/examples)
-endfunction(CreateTestExecAndInstall)
-
-
-set( libs_for_tests ${_extra_lib_CoreFlows} )
-
-# copy tests resources (med files etc.) into the build directory
-file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/resources DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
-
-CreateTestExecAndInstall(CoupledTransportDiffusionEquations_1DHeatedChannel.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(DiffusionEquation_1DHeatedRod.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(DiffusionEquation_1DHeatedRod_FE.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(DriftModel_1DBoilingAssembly.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(DriftModel_1DBoilingChannel.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(DriftModel_1DChannelGravity.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(DriftModel_1DDepressurisation.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(DriftModel_1DPorosityJump.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(DriftModel_1DPressureLoss.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(DriftModel_1DRiemannProblem.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(DriftModel_1DVidangeReservoir.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(DriftModel_2DInclinedBoilingChannel.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(DriftModel_2DInclinedChannelGravity.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(DriftModel_2DInclinedChannelGravityBarriers.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(DriftModel_3DCanalCloison.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(FiveEqsTwoFluid_1DBoilingChannel.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(FiveEqsTwoFluid_1DDepressurisation.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(FiveEqsTwoFluid_1DRiemannProblem.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(FiveEqsTwoFluid_2DInclinedBoilingChannel.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(FiveEqsTwoFluid_2DInclinedSedimentation.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(IsothermalTwoFluid_1DDepressurisation.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(IsothermalTwoFluid_1DRiemannProblem.cxx "${libs_for_tests}" )
-#CreateTestExecAndInstall(IsothermalTwoFluid_1DSedimentation.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(IsothermalTwoFluid_2DInclinedSedimentation.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(IsothermalTwoFluid_2DVidangeReservoir.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_1DDepressurisation.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_1DHeatedChannel.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_1DPorosityJump.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_1DRiemannProblem.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_2DHeatDrivenCavity.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_2DHeatDrivenCavity_unstructured.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_2DHeatedChannelInclined.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_2DLidDrivenCavity.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_2DLidDrivenCavity_unstructured.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_2DSphericalExplosion_unstructured.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_3DSphericalExplosion_unstructured.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_2DWallHeatedChannel_ChangeSect.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_2DWallHeatedChannel.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_3DHeatDrivenCavity.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(SinglePhase_HeatedWire_2Branches.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(TransportEquation_1DHeatedChannel.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(StationaryDiffusionEquation_2DEF_StructuredTriangles.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(StationaryDiffusionEquation_2DEF_StructuredTriangles_Neumann.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(StationaryDiffusionEquation_2DEF_UnstructuredTriangles.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(StationaryDiffusionEquation_2DFV_StructuredTriangles.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(StationaryDiffusionEquation_2DFV_StructuredTriangles_Neumann.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(StationaryDiffusionEquation_2DFV_StructuredSquares.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(StationaryDiffusionEquation_3DEF_StructuredTetrahedra.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(StationaryDiffusionEquation_3DFV_StructuredTetrahedra.cxx "${libs_for_tests}" )
-CreateTestExecAndInstall(testEOS.cxx "${libs_for_tests}" )
-
-
-#TODO: install for tests and test data
+add_subdirectory (C)
if (COREFLOWS_WITH_PYTHON )
- add_subdirectory (${CoreFlows_EXAMPLES}/Python)
-
- file(GLOB PYTHON_EXAMPLES_TO_INSTALL Python )
- install(DIRECTORY ${PYTHON_EXAMPLES_TO_INSTALL} DESTINATION share/examples)
+ add_subdirectory (Python)
endif (COREFLOWS_WITH_PYTHON )
+add_custom_target (tests COMMAND ctest -O testsCoreFlows.log)
+
+add_custom_target (SinglePhase COMMAND ctest -R SinglePhase)# may be replace ctest -R with ctest -L
+add_custom_target (DriftModel COMMAND ctest -R DriftModel) # may be replace ctest -R with ctest -L
+add_custom_target (IsothermalTwoFluid COMMAND ctest -R IsothermalTwoFluid)# may be replace ctest -R with ctest -L
+add_custom_target ( FiveEqsTwoFluid COMMAND ctest -R FiveEqsTwoFluid)# may be replace ctest -R with ctest -L
+
+add_custom_target (DiffusionEquation COMMAND ctest -R DiffusionEquation -E StationaryDiffusionEquation)# may be replace ctest -R with ctest -L
+add_custom_target (diffusion COMMAND ctest -R DiffusionEquation)# may be replace ctest -R with ctest -L
+add_custom_target (TransportEquation COMMAND ctest -R TransportEquation)# may be replace ctest -R with ctest -L
+add_custom_target (transport COMMAND ctest -R TransportEquation)# may be replace ctest -R with ctest -L
+add_custom_target (StationaryDiffusionEquation COMMAND ctest -R StationaryDiffusionEquation)# may be replace ctest -R with ctest -L
+
+add_custom_target (convergence COMMAND ctest -R convergence)# may be replace ctest -R with ctest -L
+
+add_custom_target (fv COMMAND ctest -R FV)# may be replace ctest -R with ctest -L
+add_custom_target (FV COMMAND ctest -R FV)# may be replace ctest -R with ctest -L
+add_custom_target (fe COMMAND ctest -R FE)# may be replace ctest -R with ctest -L
+add_custom_target (FE COMMAND ctest -R FE)# may be replace ctest -R with ctest -L
+add_custom_target (1D COMMAND ctest -R 1D)# may be replace ctest -R with ctest -L
+add_custom_target (2D COMMAND ctest -R 2D)# may be replace ctest -R with ctest -L
+add_custom_target (3D COMMAND ctest -R 3D)# may be replace ctest -R with ctest -L
+add_custom_target (Dirichlet COMMAND ctest -R Dirichlet)# may be replace ctest -R with ctest -L
+add_custom_target (Neumann COMMAND ctest -R Neumann)# may be replace ctest -R with ctest -L
+++ /dev/null
-#include "TransportEquation.hxx"\r
-#include "DiffusionEquation.hxx"\r
-\r
-using namespace std;\r
-\r
-#define PI 3.14159265\r
-\r
-void power_field_CoupledTransportDiffusionTest(Field & Phi){\r
- double L=4.2;\r
- double lambda=0.2;\r
- double phi=1e5;\r
- double x;\r
- Mesh M = Phi.getMesh();\r
- int nbCells = M.getNumberOfCells();\r
- for (int j = 0; j < nbCells; j++) {\r
- x=M.getCell(j).x();\r
- Phi(j) = phi*cos(PI*(x-L/2)/(L+lambda));\r
- }\r
-}\r
-\r
-int main(int argc, char** argv)\r
-{\r
- //Preprocessing: mesh and group creation\r
- double xinf=0.0;\r
- double xsup=4.2;\r
- int nx=100;\r
- double eps=1.E-6;\r
- cout << "Building of the diffusion mesh with "<<nx<<" cells" << endl;\r
- Mesh diffusionMesh(xinf,xsup,nx);\r
- diffusionMesh.setGroupAtPlan(xsup,0,eps,"Neumann");\r
- diffusionMesh.setGroupAtPlan(xinf,0,eps,"Neumann");\r
-\r
- cout << "Building of the transport mesh with "<<nx<<" cells" << endl;\r
- Mesh transportMesh(xinf,xsup,nx);\r
- transportMesh.setGroupAtPlan(xsup,0,eps,"Neumann");\r
- transportMesh.setGroupAtPlan(xinf,0,eps,"Inlet");\r
- int spaceDim = 1;\r
-\r
- // Boundary conditions \r
- map<string, LimitField> boundaryFields;\r
-\r
- // Boundary conditions for the solid\r
- LimitField limitNeumann;\r
- limitNeumann.bcType=Neumann;\r
- boundaryFields["Neumann"] = limitNeumann;\r
-\r
- // Boundary conditions for the fluid\r
- LimitField limitInlet;\r
- limitInlet.bcType=Inlet;\r
- limitInlet.h =1.3e6;//Inlet water enthalpy\r
- boundaryFields["Inlet"] = limitInlet;\r
-\r
- //Set the fluid transport velocity\r
- vector<double> transportVelocity(1,5);//Vitesse du fluide\r
-\r
- //Solid parameters\r
- double cp_ur=300;//Uranium specific heat\r
- double rho_ur=10000;//Uranium density\r
- double lambda_ur=5;\r
-\r
- TransportEquation myTransportEquation(Liquid, around155bars600K,transportVelocity);\r
- Field fluidEnthalpy("Enthalpie", CELLS, transportMesh, 1);\r
- bool FECalculation=false;\r
- DiffusionEquation myDiffusionEquation(spaceDim,FECalculation,rho_ur, cp_ur, lambda_ur);\r
-\r
- Field solidTemp("Solid temperature", CELLS, diffusionMesh, 1);\r
- Field fluidTemp("Fluid temperature", CELLS, transportMesh, 1);\r
-\r
- double heatTransfertCoeff=10000;//fluid/solid heat exchange coefficient\r
- myTransportEquation.setHeatTransfertCoeff(heatTransfertCoeff);\r
- myDiffusionEquation.setHeatTransfertCoeff(heatTransfertCoeff);\r
-\r
- //Set heat source in the solid\r
- Field Phi("Heat power field", CELLS, diffusionMesh, 1);\r
- power_field_CoupledTransportDiffusionTest(Phi);\r
- myDiffusionEquation.setHeatPowerField(Phi);\r
- Phi.writeVTK("1DheatPowerField");\r
-\r
- //Initial field creation\r
- Vector VV_Constant(1);\r
- VV_Constant(0) = 623;//Rod clad temperature nucleaire\r
-\r
- cout << "Construction de la condition initiale " << endl;\r
- // generate initial condition\r
- myDiffusionEquation.setInitialFieldConstant(diffusionMesh,VV_Constant);\r
-\r
-\r
- VV_Constant(0) = 1.3e6;\r
- myTransportEquation.setInitialFieldConstant(transportMesh,VV_Constant);\r
-\r
- //set the boundary conditions\r
- myTransportEquation.setBoundaryFields(boundaryFields);//Neumann and Inlet BC will be used\r
- myDiffusionEquation.setBoundaryFields(boundaryFields);//Only Neumann BC will be used\r
-\r
- // set the numerical method\r
- myDiffusionEquation.setNumericalScheme(upwind, Explicit);\r
- myTransportEquation.setNumericalScheme(upwind, Explicit);\r
-\r
- // name result file\r
- string fluidFileName = "1DFluidEnthalpy";\r
- string solidFileName = "1DSolidTemperature";\r
-\r
- // parameters calculation\r
- unsigned MaxNbOfTimeStep =3;\r
- int freqSave = 10;\r
- double cfl = 0.5;\r
- double maxTime = 1000000;\r
- double precision = 1e-6;\r
-\r
- myDiffusionEquation.setCFL(cfl);\r
- myDiffusionEquation.setPrecision(precision);\r
- myDiffusionEquation.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
- myDiffusionEquation.setTimeMax(maxTime);\r
- myDiffusionEquation.setFreqSave(freqSave);\r
- myDiffusionEquation.setFileName(solidFileName);\r
-\r
- myTransportEquation.setCFL(cfl);\r
- myTransportEquation.setPrecision(precision);\r
- myTransportEquation.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
- myTransportEquation.setTimeMax(maxTime);\r
- myTransportEquation.setFreqSave(freqSave);\r
- myTransportEquation.setFileName(fluidFileName);\r
-\r
- // loop on time steps\r
- myDiffusionEquation.initialize();\r
- myTransportEquation.initialize();\r
-\r
- double time=0,dt=0;\r
- int nbTimeStep=0;\r
- bool stop=false, stop_transport=false, stop_diffusion=false; // Does the Problem want to stop (error) ?\r
- bool ok; // Is the time interval successfully solved ?\r
-\r
- // Time step loop\r
- while(!stop && !(myDiffusionEquation.isStationary() && myTransportEquation.isStationary()) &&time<maxTime && nbTimeStep<MaxNbOfTimeStep)\r
- {\r
- ok=false; // Is the time interval successfully solved ?\r
- fluidTemp=myTransportEquation.getFluidTemperatureField();\r
- solidTemp=myDiffusionEquation.getRodTemperatureField();\r
- myDiffusionEquation.setFluidTemperatureField(fluidTemp);\r
- myTransportEquation.setRodTemperatureField(solidTemp);\r
- // Guess the next time step length\r
- dt=min(myDiffusionEquation.computeTimeStep(stop),myTransportEquation.computeTimeStep(stop));\r
- if (stop){\r
- cout << "Failed computing time step "<<nbTimeStep<<", time = " << time <<", dt= "<<dt<<", stopping calculation"<< endl;\r
- break;\r
- }\r
- // Loop on the time interval tries\r
- while (!ok && !stop )\r
- {\r
- stop_transport=!myTransportEquation.initTimeStep(dt);\r
- stop_diffusion=!myDiffusionEquation.initTimeStep(dt);\r
- stop=stop_diffusion && stop_transport;\r
-\r
- // Prepare the next time step\r
- if (stop){\r
- cout << "Failed initializing time step "<<nbTimeStep<<", time = " << time <<", dt= "<<dt<<", stopping calculation"<< endl;\r
- break;\r
- }\r
- // Solve the next time step\r
- ok=myDiffusionEquation.solveTimeStep()&& myTransportEquation.solveTimeStep();\r
-\r
- if (!ok) // The resolution failed, try with a new time interval.\r
- {\r
- myDiffusionEquation.abortTimeStep();\r
- myTransportEquation.abortTimeStep();\r
- cout << "Failed solving time step "<<nbTimeStep<<", time = " << time<<" dt= "<<dt<<", cfl= "<<cfl <<", stopping calculation"<< endl;\r
- stop=true; // Impossible to solve the next time step, the Problem has given up\r
- break;\r
- }\r
- else // The resolution was successful, validate and go to the next time step.\r
- {\r
- cout << "Time step = "<< nbTimeStep << ", dt = "<< dt <<", time = "<<time << endl;\r
- myDiffusionEquation.validateTimeStep();\r
- myTransportEquation.validateTimeStep();\r
- time=myDiffusionEquation.presentTime();\r
- nbTimeStep++;\r
- }\r
- }\r
- }\r
- if(myDiffusionEquation.isStationary() && myTransportEquation.isStationary())\r
- cout << "Stationary state reached" <<endl;\r
- else if(time>=maxTime)\r
- cout<<"Maximum time "<<maxTime<<" reached"<<endl;\r
- else if(nbTimeStep>=MaxNbOfTimeStep)\r
- cout<<"Maximum number of time steps "<<MaxNbOfTimeStep<<" reached"<<endl;\r
- else\r
- cout<<"Error problem wants to stop!"<<endl;\r
-\r
- cout << "End of calculation time t= " << time << " at time step number "<< nbTimeStep << endl;\r
- if (ok)\r
- cout << "Coupled simulation "<<fluidFileName<<" and "<<solidFileName<<" was successful !" << endl;\r
- else\r
- cout << "Coupled simulation "<<fluidFileName<<" and "<<solidFileName<<" failed ! " << endl;\r
-\r
- cout << "------------ End of calculation -----------" << endl;\r
- myDiffusionEquation.terminate();\r
- myTransportEquation.terminate();\r
-\r
- return EXIT_SUCCESS;\r
-}\r
+++ /dev/null
-#include "DiffusionEquation.hxx"\r
-\r
-using namespace std;\r
-\r
-#define PI 3.14159265\r
-\r
-void power_field_diffusionTest(Field & Phi){\r
- double L=4.2;\r
- double lambda=0.2;\r
- double phi=1e5;\r
- double x;\r
- Mesh M = Phi.getMesh();\r
- int nbCells = M.getNumberOfCells();\r
- for (int j = 0; j < nbCells; j++) {\r
- x=M.getCell(j).x();\r
- Phi(j) = phi*cos(PI*(x-L/2)/(L+lambda));\r
- }\r
-}\r
-\r
-int main(int argc, char** argv)\r
-{\r
- //Preprocessing: mesh and group creation\r
- double xinf=0.0;\r
- double xsup=4.2;\r
- int nx=10;\r
- cout << "Building of a 1D mesh with "<<nx<<" cells" << endl;\r
- Mesh M(xinf,xsup,nx);\r
- double eps=1.E-6;\r
- M.setGroupAtPlan(xsup,0,eps,"Neumann");\r
- M.setGroupAtPlan(xinf,0,eps,"Neumann");\r
- int spaceDim = M.getSpaceDimension();\r
-\r
-\r
- //Solid parameters\r
- double cp_ur=300;//Uranium specific heat\r
- double rho_ur=10000;//Uranium density\r
- double lambda_ur=5;\r
- \r
- bool FEcalculation=false;\r
- DiffusionEquation myProblem(spaceDim,FEcalculation,rho_ur,cp_ur,lambda_ur);\r
- Field VV("Solid temperature", CELLS, M, 1);\r
-\r
- //Set fluid temperature (temperature du fluide)\r
- double fluidTemp=573;//fluid mean temperature\r
- double heatTransfertCoeff=1000;//fluid/solid exchange coefficient\r
- myProblem.setFluidTemperature(fluidTemp);\r
- myProblem.setHeatTransfertCoeff(heatTransfertCoeff);\r
- //Set heat source\r
- Field Phi("Heat power field", CELLS, M, 1);\r
- power_field_diffusionTest(Phi);\r
- myProblem.setHeatPowerField(Phi);\r
- Phi.writeVTK("1DheatPowerField");\r
-\r
- //Initial field creation\r
- Vector VV_Constant(1);\r
- VV_Constant(0) = 623;//Rod clad temperature\r
-\r
- cout << "Building initial data" << endl;\r
- myProblem.setInitialFieldConstant(M,VV_Constant);\r
-\r
- //set the boundary conditions\r
- myProblem.setNeumannBoundaryCondition("Neumann");\r
-\r
- // set the numerical method\r
- myProblem.setNumericalScheme(upwind, Explicit);\r
-\r
- // name result file\r
- string fileName = "1DRodTemperature_FV";\r
-\r
- // parameters calculation\r
- unsigned MaxNbOfTimeStep =3;\r
- int freqSave = 1;\r
- double cfl = 0.5;\r
- double maxTime = 1000000;\r
- double precision = 1e-6;\r
-\r
- myProblem.setCFL(cfl);\r
- myProblem.setPrecision(precision);\r
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
- myProblem.setTimeMax(maxTime);\r
- myProblem.setFreqSave(freqSave);\r
- myProblem.setFileName(fileName);\r
-\r
- // set display option to monitor the calculation\r
- myProblem.setVerbose( true);\r
- //set file saving format\r
- myProblem.setSaveFileFormat(CSV);\r
-\r
- // evolution\r
- myProblem.initialize();\r
- bool ok = myProblem.run();\r
- if (ok)\r
- cout << "Simulation "<<fileName<<" is successful !" << endl;\r
- else\r
- cout << "Simulation "<<fileName<<" failed ! " << endl;\r
-\r
- cout << "------------ End of calculation -----------" << endl;\r
- myProblem.terminate();\r
-\r
- return EXIT_SUCCESS;\r
-}\r
+++ /dev/null
-#include "DiffusionEquation.hxx"\r
-\r
-using namespace std;\r
-\r
-#define PI 3.14159265\r
-\r
-void power_field_diffusionTest(Field & Phi){\r
- double L=4.2;\r
- double lambda=0.2;\r
- double phi=1e5;\r
- double x;\r
- Mesh M = Phi.getMesh();\r
- int nbNodes = M.getNumberOfNodes();\r
- for (int j = 0; j < nbNodes; j++) {\r
- x=M.getNode(j).x();\r
- Phi(j) = phi*cos(PI*(x-L/2)/(L+lambda));\r
- }\r
-}\r
-\r
-int main(int argc, char** argv)\r
-{\r
- //Preprocessing: mesh and group creation\r
- double xinf=0.0;\r
- double xsup=4.2;\r
- int nx=10;\r
- cout << "Building of a 1D mesh with "<<nx<<" cells" << endl;\r
- Mesh M(xinf,xsup,nx);\r
- double eps=1.E-6;\r
- M.setGroupAtPlan(xsup,0,eps,"Neumann");\r
- M.setGroupAtPlan(xinf,0,eps,"Neumann");\r
- int spaceDim = M.getSpaceDimension();\r
-\r
-\r
- //Solid parameters\r
- double cp_ur=300;//Uranium specific heat\r
- double rho_ur=10000;//Uranium density\r
- double lambda_ur=5;\r
- \r
- bool FEcalculation=true;\r
- DiffusionEquation myProblem(spaceDim,FEcalculation,rho_ur,cp_ur,lambda_ur);\r
- Field VV("Solid temperature", NODES, M, 1);\r
-\r
- //Set fluid temperature (temperature du fluide)\r
- double fluidTemp=573;//fluid mean temperature\r
- double heatTransfertCoeff=1000;//fluid/solid exchange coefficient\r
- myProblem.setFluidTemperature(fluidTemp);\r
- myProblem.setHeatTransfertCoeff(heatTransfertCoeff);\r
- //Set heat source\r
- Field Phi("Heat power field", NODES, M, 1);\r
- power_field_diffusionTest(Phi);\r
- myProblem.setHeatPowerField(Phi);\r
- Phi.writeVTK("1DheatPowerField");\r
-\r
- //Initial field creation\r
- Vector VV_Constant(1);\r
- VV_Constant(0) = 623;//Rod clad temperature\r
-\r
- cout << "Building initial data" << endl;\r
- myProblem.setInitialFieldConstant(M,VV_Constant);\r
-\r
- //set the boundary conditions\r
- myProblem.setNeumannBoundaryCondition("Neumann");\r
-\r
- // set the numerical method\r
- myProblem.setNumericalScheme(upwind, Explicit);\r
-\r
- // name result file\r
- string fileName = "1DRodTemperature_FE";\r
-\r
- // parameters calculation\r
- unsigned MaxNbOfTimeStep =3;\r
- int freqSave = 1;\r
- double cfl = 0.5;\r
- double maxTime = 1000000;\r
- double precision = 1e-6;\r
-\r
- myProblem.setCFL(cfl);\r
- myProblem.setPrecision(precision);\r
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
- myProblem.setTimeMax(maxTime);\r
- myProblem.setFreqSave(freqSave);\r
- myProblem.setFileName(fileName);\r
-\r
- // set display option to monitor the calculation\r
- myProblem.setVerbose( true);\r
- //set file saving format\r
- myProblem.setSaveFileFormat(CSV);\r
-\r
- // evolution\r
- myProblem.initialize();\r
- bool ok = myProblem.run();\r
- if (ok)\r
- cout << "Simulation "<<fileName<<" is successful !" << endl;\r
- else\r
- cout << "Simulation "<<fileName<<" failed ! " << endl;\r
-\r
- cout << "------------ End of calculation -----------" << endl;\r
- myProblem.terminate();\r
-\r
- return EXIT_SUCCESS;\r
-}\r
+++ /dev/null
-#include "DriftModel.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //setting mesh and groups
- cout << "Building a regular grid " << endl;
- double xinf=0.0;
- double xsup=4.2;
- double xinfcore=1.4;
- double xsupcore=2.8;
-
- int nx=3;//50;
- Mesh M(xinf,xsup,nx);
- double eps=1.E-8;
- M.setGroupAtPlan(xsup,0,eps,"Outlet");
- M.setGroupAtPlan(xinf,0,eps,"Inlet");
- int spaceDim = M.getSpaceDimension();
-
- // setting boundary conditions
- double inletConc=0;
- double inletVelocityX=1;
- double inletTemperature=565;
- double outletPressure=155e5;
-
- // setting physical parameters
- Field heatPowerField=Field("heatPowerField",CELLS, M, 1);
- int nbCells=M.getNumberOfCells();
-
- for(int i=0;i<nbCells;i++){
- double x=M.getCell(i).x();
-
- if (x> xinfcore && x< xsupcore)
- heatPowerField[i]=1e8;
- else
- heatPowerField[i]=0;
- }
- heatPowerField.writeVTK("heatPowerField",true);
-
- DriftModel myProblem(around155bars600K,spaceDim);
- int nbPhase = myProblem.getNumberOfPhases();
- int nVar = myProblem.getNumberOfVariables();
- Field VV("Primitive", CELLS, M, nVar);
-
- // Prepare for the initial condition
- Vector VV_Constant(nVar);
- // constant vector
- VV_Constant(0) = 0.;
- VV_Constant(1) = 155e5;
- for (int idim=0; idim<spaceDim;idim++)
- VV_Constant(2+idim) = 1;
- VV_Constant(nVar-1) = 565;
-
- //Initial field creation
- cout << "Building initial field " << endl;
- myProblem.setInitialFieldConstant( M, VV_Constant);
-
- //set the boundary conditions
- myProblem.setInletBoundaryCondition("Inlet",inletTemperature,inletConc,inletVelocityX);
- myProblem.setOutletBoundaryCondition("Outlet", outletPressure,vector<double>(1,xsup));
-
- // physical parameters
- myProblem.setHeatPowerField(heatPowerField);
-
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
- myProblem.setWellBalancedCorrection(true);
-
- // name the result file
- string fileName = "DriftModel1DBoilingAssembly";
-
- // setting numerical parameters
- unsigned MaxNbOfTimeStep =3 ;
- int freqSave = 1;
- double cfl = 0.5;
- double maxTime = 1;
- double precision = 1e-7;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.saveAllFields(true);
- bool ok;
-
- // evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "DriftModel.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //setting mesh and groups
- cout << "Building a regular grid " << endl;
- double xinf=0.0;
- double xsup=4.2;
- int nx=50;//50;
- Mesh M(xinf,xsup,nx);
- double eps=1.E-8;
- M.setGroupAtPlan(xsup,0,eps,"Outlet");
- M.setGroupAtPlan(xinf,0,eps,"Inlet");
- int spaceDim = M.getSpaceDimension();
-
- // setting boundary conditions
- double inletConc=0;
- double inletVelocityX=1;
- double inletTemperature=565;
- double outletPressure=155e5;
-
- // setting physical parameters
- double heatPower=1e8;
-
- DriftModel myProblem(around155bars600K,spaceDim);
- int nbPhase = myProblem.getNumberOfPhases();
- int nVar = myProblem.getNumberOfVariables();
-
- // Prepare for the initial condition
- Vector VV_Constant(nVar);
- // constant vector
- VV_Constant(0) = 0.;
- VV_Constant(1) = 155e5;
- for (int idim=0; idim<spaceDim;idim++)
- VV_Constant(2+idim) = 1;
- VV_Constant(nVar-1) = 565;
-
- //Initial field creation
- cout << "Setting initial data " << endl;
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- //set the boundary conditions
- myProblem.setInletBoundaryCondition("Inlet",inletTemperature,inletConc,inletVelocityX);
- myProblem.setOutletBoundaryCondition("Outlet", outletPressure,vector<double>(1,xsup));
-
- // physical parameters
- myProblem.setHeatSource(heatPower);
-
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Implicit);
- myProblem.setWellBalancedCorrection(true);
- myProblem.setNonLinearFormulation(VFFC);
-
- // name the result file
- string fileName = "Driftmodel1DBoilingChannel";
-
- // setting numerical parameters
- unsigned MaxNbOfTimeStep =3 ;
- int freqSave = 1;
- double cfl = 100;
- double maxTime = 1;
- double precision = 1e-7;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.usePrimitiveVarsInNewton(true);
- myProblem.saveAllFields(true);
- myProblem.displayConditionNumber();
- myProblem.setSaveFileFormat(CSV);
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "DriftModel.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //setting mesh and groups
- cout << "Building a regular grid " << endl;
- double xinf=0.0;
- double xsup=4.2;
- int nx=50;//50;
- Mesh M(xinf,xsup,nx);
- double eps=1.E-8;
- M.setGroupAtPlan(xsup,0,eps,"Outlet");
- M.setGroupAtPlan(xinf,0,eps,"Inlet");
- int spaceDim = M.getSpaceDimension();
-
- // setting boundary conditions
- double inletConc=0;
- double inletVelocityX=1;
- double inletEnthalpy=1.3e6;
- double outletPressure=155e5;
-
- // setting physical parameters
- vector<double> gravite(spaceDim,0.) ;
- gravite[0]=-10;
-
- DriftModel myProblem(around155bars600K,spaceDim);
- int nbPhase = myProblem.getNumberOfPhases();
- int nVar = myProblem.getNumberOfVariables();
-
- // Prepare for the initial condition
- Vector VV_Constant(nVar);
- // constant vector
- VV_Constant(0) = 0.;
- VV_Constant(1) = 155e5;
- for (int idim=0; idim<spaceDim;idim++)
- VV_Constant(2+idim) = 1;
- VV_Constant(nVar-1) = 578;
-
- //Initial field creation
- cout << "Setting initial data " << endl;
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- //set the boundary conditions
- myProblem.setInletEnthalpyBoundaryCondition("Inlet",inletEnthalpy,inletConc,inletVelocityX);
- myProblem.setOutletBoundaryCondition("Outlet", outletPressure,vector<double>(1,xsup));
-
- // physical parameters
- myProblem.setGravity(gravite);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Implicit);
- myProblem.setWellBalancedCorrection(true);
- myProblem.setNonLinearFormulation(VFRoe);
-
- // name the result file
- string fileName = "Driftmodel_1DChannelGravity";
-
- // setting numerical parameters
- unsigned MaxNbOfTimeStep =3 ;
- int freqSave = 1;
- double cfl = 100;
- double maxTime = 1;
- double precision = 1e-7;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.usePrimitiveVarsInNewton(true);
- myProblem.saveAllFields(true);
- myProblem.displayConditionNumber();
- myProblem.setSaveFileFormat(CSV);
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "DriftModel.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- cout << "Building regular mesh " << endl;
- double xinf=0.0;
- double xsup=4.2;
- int nx=50;
- int spaceDim = 1;
-
- //Initial data
- double initialConc=0;
- double initialVelocityX =0;
- double initialTemperature=600;
- double initialPressure=155e5;
-
- //Boundary data
- double wallVelocityX=0;
- double wallTemperature=563;
- double outletPressure=50e5;
-
- DriftModel myProblem(around155bars600K,spaceDim);
- int nbPhase = myProblem.getNumberOfPhases();
- int nVar = myProblem.getNumberOfVariables();
-
- // Prepare the initial condition
- vector<double> VV_Constant(nVar);
- VV_Constant[1] = initialConc;
- VV_Constant[1] = initialPressure;
- VV_Constant[2] = initialVelocityX;
- VV_Constant[3] = initialTemperature;
-
- //Initial field creation
- cout << "Building initial data " << endl;
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"wall","Outlet");
-
- //set the boundary conditions
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX);
- myProblem.setOutletBoundaryCondition("Outlet",outletPressure,vector<double>(1,xsup));
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
- myProblem.setEntropicCorrection(true);
-
- // name file save
- string fileName = "1DDepressurisation";
-
- //Numerical parameters calculation
- unsigned MaxNbOfTimeStep =3;
- int freqSave = 1;
- double cfl = 1;
- double maxTime = 1;
- double precision = 1e-7;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- bool ok;
-
- // evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "DriftModel.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- cout << "Building cartesian mesh" << endl;
- double xinf=0.0;
- double xsup=4.2;
- int nx=100;
- Mesh M(xinf,xsup,nx);
- double eps=1.E-8;
- int spaceDim = M.getSpaceDimension();
-
- //Initial data
- double initialConc=0;
- double initialVelocityX =1;
- double initialTemperature=600;
- double initialPressure=155e5;
-
- // physical parameters
- Field porosityField("Porosity", CELLS, M, 1);
- for(int i=0;i<M.getNumberOfCells();i++){
- double x=M.getCell(i).x();
- if (x> (xsup-xinf)/3 && x< 2*(xsup-xinf)/3)
- porosityField[i]=0.5;
- else
- porosityField[i]=1;
- }
- porosityField.writeVTK("PorosityField",true);
-
-
- DriftModel myProblem(around155bars600K,spaceDim);
- int nVar = myProblem.getNumberOfVariables();
-
- // Prepare for the initial condition
- vector<double> VV_Constant(nVar);
- // constant vector
- VV_Constant[1] = initialConc;
- VV_Constant[1] = initialPressure;
- VV_Constant[2] = initialVelocityX;
- VV_Constant[3] = initialTemperature;
-
- cout << "Building initial data " << endl;
-
- // generate initial condition
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"Inlet","Outlet");
-
- //set the boundary conditions
- myProblem.setInletBoundaryCondition("Inlet",initialTemperature,initialConc,initialVelocityX);
- myProblem.setOutletBoundaryCondition("Outlet",initialPressure,vector<double>(1,xsup));
-
- // physical parameters
- myProblem.setPorosityField(porosityField);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
- myProblem.setWellBalancedCorrection(true);
- myProblem.setNonLinearFormulation(VFFC) ;
-
- // name file save
- string fileName = "1DPorosityJumpUpwindWB";
-
-
- /* set numerical parameters */
- unsigned MaxNbOfTimeStep =3;
- int freqSave = 1;
- double cfl = 0.95;
- double maxTime = 5;
- double precision = 1e-5;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- bool ok;
-
- // evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
-
+++ /dev/null
-#include "DriftModel.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- cout << "Building a regular grid " << endl;
- int spaceDim=1;
- double xinf=0.0;
- double xsup=4.2;
- int nx=50;
-
- Mesh M(xinf,xsup,nx);
- double eps=1.E-8;
- M.setGroupAtPlan(xsup,0,eps,"Outlet");
- M.setGroupAtPlan(xinf,0,eps,"Inlet");
-
- double inletConc=0;
- double inletVelocityX =1;
- double inletTemperature=563;
-
- double outletPressure=155e5;
-
- // physical parameters
- Field pressureLossField("pressureLoss", FACES, M, 1);
- pressureLossField(nx/4)=50;
- pressureLossField(nx/2)=100;
- pressureLossField(3*nx/4)=150;
-
- DriftModel myProblem(around155bars600K,spaceDim);
- int nVar = myProblem.getNumberOfVariables();
-
- // Prepare for the initial condition
- vector<double> VV_Constant(nVar);
- // constant vector
- VV_Constant[0] = inletConc;
- VV_Constant[1] = outletPressure;
- VV_Constant[2] = inletVelocityX;
- VV_Constant[3] = inletTemperature;
-
- cout << "Building initial data " << endl;
-
- // generate initial condition
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
-
- //set the boundary conditions
- myProblem.setInletBoundaryCondition("inlet",inletTemperature,inletConc,inletVelocityX);
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,vector<double>(1,xsup));
-
- // physical parameters
- myProblem.setPressureLossField(pressureLossField);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
- myProblem.setWellBalancedCorrection(true);
-
- // name file save
- string fileName = "1DPressureLossUpwindWB";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep =3;
- int freqSave = 1;
- double cfl = 0.95;
- double maxTime = 5;
- double precision = 1e-5;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "DriftModel.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- cout << "Building cartesian mesh" << endl;
- double xinf=0.0;
- double xsup=1.0;
- int nx=10;
- Mesh M(xinf,xsup,nx);
- double eps=1.E-8;
- M.setGroupAtPlan(xsup,0,eps,"Neumann");
- M.setGroupAtPlan(xinf,0,eps,"Neumann");
- int spaceDim = M.getSpaceDimension();
-
- // set the limit field for each boundary
- LimitField limitNeumann;
- limitNeumann.bcType=Neumann;
- map<string, LimitField> boundaryFields;
- boundaryFields["Neumann"] = limitNeumann;
-
- DriftModel myProblem(around155bars600K,spaceDim);
- int nbPhase = myProblem.getNumberOfPhases();
- int nVar = myProblem.getNumberOfVariables();
- Field VV("Primitive", CELLS, M, nVar);//3+spaceDim*nbPhase
-
- // Prepare for the initial condition
- Vector VV_Left(nVar),VV_Right(nVar);
- double discontinuity = (xinf+xsup)/2.;
- VV_Left(0) = 0.5; VV_Right(0) = 0.2;
- VV_Left(1) = 155e5; VV_Right(1) = 155e5;
- for (int idim=0; idim<spaceDim;idim++){
- VV_Left(2+idim) = 1;VV_Right(2+idim) = 1;
- }
- VV_Left(2+spaceDim) = 573;
- VV_Right(2+spaceDim) = 618;
-
- //Initial field creation
- cout << "Building initial data" << endl;
- myProblem.setInitialFieldStepFunction(M,VV_Left,VV_Right,discontinuity);
-
- //set the boundary fields
- myProblem.setBoundaryFields(boundaryFields);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
-
- // name file save
- string fileName = "RiemannProblem";
-
- //numerical parameters
- unsigned MaxNbOfTimeStep =3 ;
- int freqSave = 1;
- double cfl = 0.95;
- double maxTime = 1;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
-
- // set display option to monitor the calculation
- myProblem.setVerbose( true);
- myProblem.saveConservativeField(true);
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "DriftModel.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv) {
- //setting mesh and groups
- cout << "Building a regular grid " << endl;
- double xinf = 0.0;
- double xsup = 4.2;
- int nx = 2; //50;
- Mesh M(xinf, xsup, nx);
- double eps = 1.E-8;
- M.setGroupAtPlan(xinf, 0, eps, "Outlet");
- M.setGroupAtPlan(xsup, 0, eps, "Inlet");
- int spaceDim = M.getSpaceDimension();
-
- // setting boundary conditions
- double inletConc = 1;
- double inletTemperature = 300;
- double outletPressure = 1e5;
-
- double initialConcTop = 1;
- double initialConcBottom = 0.0001;
- double initialVelocityX = 1;
- double initialPressure = 1e5;
- double initialTemperature = 300;
-
- // setting physical parameters
- vector<double> gravite(spaceDim, 0.);
- gravite[0] = -10;
-
- DriftModel myProblem(around1bar300K, spaceDim, false);
- int nbPhase = myProblem.getNumberOfPhases();
- int nVar = myProblem.getNumberOfVariables();
-
- // Prepare for the initial condition
- Vector VV_top(nVar), VV_bottom(nVar);
-
-// top and bottom vectors
- VV_top[0] = initialConcTop;
- VV_top[1] = initialPressure;
- VV_top[2] = initialVelocityX;
- VV_top[3] = initialTemperature;
-
- VV_bottom[0] = initialConcBottom;
- VV_bottom[1] = initialPressure;
- VV_bottom[2] = initialVelocityX;
- VV_bottom[3] = initialTemperature;
-
- //Initial field creation
- cout << "Setting initial data " << endl;
- myProblem.setInitialFieldStepFunction(M, VV_bottom, VV_top, .8, 0);
-
- //set the boundary conditions
- myProblem.setInletPressureBoundaryCondition("Inlet", outletPressure,inletTemperature, inletConc, vector<double>(1, xinf));
- myProblem.setOutletBoundaryCondition("Outlet", outletPressure,vector<double>(1, xsup));
-
- // physical parameters
- myProblem.setGravity(gravite);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
- myProblem.setWellBalancedCorrection(true);
- myProblem.setNonLinearFormulation(VFFC);
-
- // name the result file
- string fileName = "Driftmodel_1DVidangeReservoir";
-
- // setting numerical parameters
- unsigned MaxNbOfTimeStep = 1;
- int freqSave = 1;
- double cfl = 0.95;
- double maxTime = 1;
- double precision = 1e-5;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.usePrimitiveVarsInNewton(true);
- myProblem.saveAllFields(true);
- myProblem.setVerbose(true);
- myProblem.displayConditionNumber();
- myProblem.setSaveFileFormat(CSV);
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation " << fileName << " is successful !" << endl;
- else
- cout << "Simulation " << fileName << " failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "DriftModel.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- int spaceDim = 2;
-
- // set the limit field for each boundary
- double wallVelocityX=0;
- double wallVelocityY=0;
- double wallTemperature=563;
-
- double inletConcentration=0;
- double inletVelocityX=0;
- double inletVelocityY=1;
- double inletTemperature=563;
-
- double outletPressure=155e5;
-
- // physical constants
- vector<double> gravite(spaceDim,0.) ;
- gravite[1]=-7;
- gravite[0]=7;
- double heatPower=1e8;
-
- DriftModel myProblem(around155bars600K,spaceDim);
- int nVar = myProblem.getNumberOfVariables();
-
- //Prepare for the mesh
- double xinf=0.0;
- double xsup=1.0;
- double yinf=0.0;
- double ysup=1.0;
- int nx=20;
- int ny=20;
-
- // Prepare for the initial condition
- vector<double> VV_Constant(nVar);
- // constant vector
- VV_Constant[0] = 0;
- VV_Constant[1] = 155e5;
- VV_Constant[2] = 0;
- VV_Constant[3] = 1;
- VV_Constant[4] = 563;
-
- //Initial field creation
- cout << "Building initial data" << endl;
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"wall","wall",yinf,ysup,ny,"inlet","outlet");
-
- //set the boundary conditions
- vector<double>pressure_reference_point(2);
- pressure_reference_point[0]=xsup;
- pressure_reference_point[1]=ysup;
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,pressure_reference_point);
- myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- // set physical parameters
- myProblem.setHeatSource(heatPower);
- myProblem.setGravity(gravite);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
- myProblem.setWellBalancedCorrection(true);
-
- // name of result file
- string fileName = "DriftModel_2DInclinedBoilingChannel";
-
- // computation parameters
- unsigned MaxNbOfTimeStep = 3 ;
- int freqSave = 1;
- double cfl = 0.5;
- double maxTime = 5;
- double precision = 1e-4;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.saveVelocity();
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "DriftModel.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- int spaceDim = 2;
-
- //Prepare for the mesh
- double xinf=0.0;
- double xsup=1.0;
- double yinf=0.0;
- double ysup=4.0;
- int nx=10;
- int ny=40;
-
- // set the limit field for each boundary
- double wallVelocityX=0;
- double wallVelocityY=0;
- double wallTemperature=563;
-
- double inletConcentration=0;
- double inletVelocityX=0;
- double inletVelocityY=1;
- double inletTemperature=563;
-
- double outletPressure=155e5;
-
- // physical constants
- vector<double> gravite(spaceDim,0.) ;
- gravite[1]=-8.5;
- gravite[0]=5;
-
- DriftModel myProblem(around155bars600K,spaceDim);
- int nVar = myProblem.getNumberOfVariables();
-
- // Prepare for the initial condition
- vector<double> VV_Constant(nVar);
- // constant vector
- VV_Constant[0] = 0;
- VV_Constant[1] = 155e5;
- VV_Constant[2] = 0;
- VV_Constant[3] = 1;
- VV_Constant[4] = 563;
-
- //Initial field creation
- cout << "Building initial data" << endl;
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"wall","wall",yinf,ysup,ny,"inlet","outlet");
-
- //set the boundary conditions
- vector<double>pressure_reference_point(2);
- pressure_reference_point[0]=xsup;
- pressure_reference_point[1]=ysup;
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,pressure_reference_point);
- myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- // set physical parameters
- myProblem.setGravity(gravite);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
- myProblem.setWellBalancedCorrection(true);
- myProblem.setNonLinearFormulation(VFFC);
-
- // name of result file
- string fileName = "2DInclinedChannelGravity";
-
- // computation parameters
- unsigned MaxNbOfTimeStep = 3 ;
- int freqSave = 1;
- double cfl = 0.5;
- double maxTime = 5;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.usePrimitiveVarsInNewton(true);
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "DriftModel.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- int spaceDim = 2;
-
- //Prepare for the mesh
- double xinf=0.0;
- double xsup=.6;
- double yinf=0.0;
- double ysup=2.0;
- int nx=3;
- int ny=100;
- Mesh M(xinf,xsup,nx,yinf,ysup,ny);
-
- //Set the barriers
- double xcloison1=xinf+(xsup-xinf)/3;
- double xcloison2=xinf+2*(xsup-xinf)/3;
- Field barrierField("Barrier Field", FACES, M, 1);
- double eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"wall");
- M.setGroupAtPlan(xinf,0,eps,"wall");
- M.setGroupAtPlan(ysup,1,eps,"outlet");
- M.setGroupAtPlan(yinf,1,eps,"inlet");
- double dy=(ysup-yinf)/ny;
- int ncloison=3*ny/4;
- int i=0;
- while( i<= ncloison+1)
- {
- M.setGroupAtFaceByCoords(xcloison1,yinf+((ysup-yinf)/4)+(i+0.5)*dy,0,eps,"wall");
- M.setGroupAtFaceByCoords(xcloison2,yinf+((ysup-yinf)/4)+(i+0.5)*dy,0,eps,"wall");
- i++;
- }
-
- int nbFaces=M.getNumberOfFaces();
- for( i=0;i<nbFaces;i++)
- {
- double x=M.getFace(i).x();
- double y=M.getFace(i).y();
- if (((y> yinf+(ysup-yinf)/4) && (abs(x-xcloison1)< eps or abs(x-xcloison2)< eps) ) || abs(x-xinf)< eps || abs(x-xsup)< eps)
- barrierField[i]=1;
- else
- barrierField[i]=0;
- }
-
- barrierField.writeVTK("barrierField",true);
-
- // set the limit field for each boundary
- double wallVelocityX=0;
- double wallVelocityY=0;
- double wallTemperature=563;
-
- double inletConcentration=0;
- double inletVelocityX=0;
- double inletVelocityY=1;
- double inletTemperature=563;
-
- double outletPressure=155e5;
-
- // physical constants
- vector<double> gravite(spaceDim,0.) ;
- gravite[1]=-7;
- gravite[0]=7;
-
- DriftModel myProblem(around155bars600K,spaceDim);
- int nVar = myProblem.getNumberOfVariables();
-
- // Prepare for the initial condition
- vector<double> VV_Constant(nVar);
- // constant vector
- VV_Constant[0] = 0;
- VV_Constant[1] = 155e5;
- VV_Constant[2] = 0;
- VV_Constant[3] = 1;
- VV_Constant[4] = 563;
-
- //Initial field creation
- cout << "Building initial data" << endl;
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- //set the boundary conditions
- vector<double>pressure_reference_point(2);
- pressure_reference_point[0]=xsup;
- pressure_reference_point[1]=ysup;
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,pressure_reference_point);
- myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- // set physical parameters
- myProblem.setGravity(gravite);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
- myProblem.setWellBalancedCorrection(true);
- myProblem.setNonLinearFormulation(VFFC);
-
- // name of result file
- string fileName = "2DInclinedChannelGravityBarriers";
-
- // computation parameters
- unsigned MaxNbOfTimeStep = 3 ;
- int freqSave = 1;
- double cfl = 0.5;
- double maxTime = 500;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.usePrimitiveVarsInNewton(true);
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "DriftModel.hxx"\r
-\r
-using namespace std;\r
-\r
-int main(int argc, char** argv)\r
-{\r
- int spaceDim = 3;\r
- // Prepare for the mesh\r
- cout << "Building cartesian mesh" << endl;\r
- double xinf = 0 ;\r
- double xsup=2.0;\r
- double yinf=0.0;\r
- double ysup=2.0;\r
- double zinf=0.0;\r
- double zsup=4.0;\r
- int nx=10;\r
- int ny=nx;\r
- int nz=20;\r
- double xcloison=(xinf+xsup)/2;\r
- double ycloison=(yinf+ysup)/2;\r
- double zcloisonmin=1;\r
- double zcloisonmax=3;\r
- Mesh M(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz);\r
- // set the limit field for each boundary\r
- double eps=1e-6;\r
- M.setGroupAtPlan(xsup,0,eps,"wall");\r
- M.setGroupAtPlan(xinf,0,eps,"wall");\r
- M.setGroupAtPlan(ysup,1,eps,"wall");\r
- M.setGroupAtPlan(yinf,1,eps,"wall");\r
- M.setGroupAtPlan(zsup,2,eps,"outlet");\r
- M.setGroupAtPlan(zinf,2,eps,"inlet");\r
- double dx=(xsup-xinf)/nx;\r
- double dy=(ysup-yinf)/ny;\r
- double dz=(zsup-zinf)/nz;\r
- int ncloison=nz*(zcloisonmax-zcloisonmin)/(zsup-zinf);\r
- int i=0 ;\r
- int j=0;\r
- while( i< ncloison){\r
- while(j< ny){\r
- M.setGroupAtFaceByCoords(xcloison,(j+0.5)*dy,zcloisonmin+(i+0.5)*dz,eps,"wall");\r
- M.setGroupAtFaceByCoords((j+0.5)*dx,ycloison,zcloisonmin+(i+0.5)*dz,eps,"wall");\r
- j=j+1;\r
- }\r
- i=i+1;\r
- }\r
-\r
- // set the limit field for each boundary\r
- double wallVelocityX=0;\r
- double wallVelocityY=0;\r
- double wallVelocityZ=0;\r
- double wallTemperature=573;\r
- double inletConc=0;\r
- double inletVelocityX=0;\r
- double inletVelocityY=0;\r
- double inletVelocityZ=1;\r
- double inletTemperature=563;\r
- double outletPressure=155e5;\r
-\r
- // physical constants\r
- vector<double> gravite = vector<double>(spaceDim,0);\r
-\r
- gravite[0]=0;\r
- gravite[1]=0;\r
- gravite[2]=-10;\r
-\r
- double heatPower1=0;\r
- double heatPower2=0.25e8;\r
- double heatPower3=0.5e8;\r
- double heatPower4=1e8;\r
-\r
- DriftModel myProblem = DriftModel(around155bars600K,spaceDim);\r
- int nVar =myProblem.getNumberOfVariables();\r
- Field heatPowerField=Field("heatPowerField", CELLS, M, 1);\r
-\r
- int nbCells=M.getNumberOfCells();\r
-\r
- for (int i=0;i<nbCells;i++){\r
- double x=M.getCell(i).x();\r
- double y=M.getCell(i).y();\r
- double z=M.getCell(i).z();\r
- if (z> zcloisonmin && z< zcloisonmax)\r
- if (y<ycloison && x<xcloison)\r
- heatPowerField[i]=heatPower1;\r
- if (y<ycloison && x>xcloison)\r
- heatPowerField[i]=heatPower2;\r
- if (y>ycloison && x<xcloison)\r
- heatPowerField[i]=heatPower3;\r
- if (y>ycloison && x>xcloison)\r
- heatPowerField[i]=heatPower4;\r
- else\r
- heatPowerField[i]=0;\r
- }\r
- heatPowerField.writeVTK("heatPowerField",true);\r
-\r
- //Prepare for the initial condition\r
- Vector VV_Constant =Vector(nVar);\r
-\r
- // constant vector\r
- VV_Constant[0] = inletConc ;\r
- VV_Constant[1] = outletPressure ;\r
- VV_Constant[2] = inletVelocityX;\r
- VV_Constant[3] = inletVelocityY;\r
- VV_Constant[4] = inletVelocityZ;\r
- VV_Constant[5] = inletTemperature ;\r
-\r
- //Initial field creation\r
- cout<<"Building initial data " <<endl;\r
- myProblem.setInitialFieldConstant(M,VV_Constant);\r
-\r
- // the boundary conditions\r
- myProblem.setOutletBoundaryCondition("outlet", outletPressure);\r
- myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConc, inletVelocityX, inletVelocityY, inletVelocityZ);\r
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY,wallVelocityZ);\r
-\r
- // set physical parameters\r
- myProblem.setHeatPowerField(heatPowerField);\r
- myProblem.setGravity(gravite);\r
-\r
- // set the numerical method\r
- myProblem.setNumericalScheme(upwind, Explicit);\r
- myProblem.setWellBalancedCorrection(false);\r
-\r
- // name file save\r
- string fileName = "3DCanalCloison";\r
-\r
- // parameters calculation\r
- unsigned MaxNbOfTimeStep = 3;\r
- int freqSave = 1;\r
- double cfl = 0.3;\r
- double maxTime = 5;\r
- double precision = 1e-6;\r
-\r
- myProblem.setCFL(cfl);\r
- myProblem.setPrecision(precision);\r
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
- myProblem.setTimeMax(maxTime);\r
- myProblem.setFreqSave(freqSave);\r
- myProblem.setFileName(fileName);\r
- myProblem.setNewtonSolver(precision,20);\r
- myProblem.saveVelocity();\r
-\r
- // evolution\r
- myProblem.initialize();\r
-\r
- bool ok = myProblem.run();\r
- if (ok)\r
- cout << "Simulation "<<fileName<<" is successful !" << endl;\r
- else\r
- cout << "Simulation "<<fileName<<" failed ! " << endl;\r
-\r
- cout << "------------ End of calculation !!! -----------" << endl;\r
- myProblem.terminate();\r
-\r
- return EXIT_SUCCESS;\r
-}\r
+++ /dev/null
-#include "FiveEqsTwoFluid.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh data
- cout << "Building cartesian mesh" << endl;
- double xinf=0.0;
- double xsup=4.2;
- int nx=50;
-
- int spaceDim=1;
-
- double inletVoidFraction=0;
- vector<double>inletVelocityX(2,2);
- double inletTemperature=563;
-
- double outletPressure=155e5;
-
- // physical constants
- double heatPower=1e8;
- int nbPhase=2;
-
- FiveEqsTwoFluid myProblem(around155bars600K,spaceDim);
- int nVar = myProblem.getNumberOfVariables();
-
- // Prepare for the initial condition
- vector<double> VV_Constant(nVar);
- // constant vector
- VV_Constant[0] = inletVoidFraction;
- VV_Constant[1] = outletPressure;
- VV_Constant[2] = inletVelocityX[0];
- VV_Constant[3] = inletVelocityX[1];
- VV_Constant[2+spaceDim*nbPhase] = inletTemperature;
-
- cout << "Building initial data" << endl;
- // generate initial condition
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
-
- //set the boundary conditions
- myProblem.setInletBoundaryCondition("inlet",inletVoidFraction,inletTemperature,inletVelocityX);
- myProblem.setOutletBoundaryCondition("outlet", outletPressure);
-
- // physical parameters
- myProblem.setHeatSource(heatPower);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
- myProblem.setWellBalancedCorrection(true);
- myProblem.setEntropicCorrection(true);
-
- // name file save
- string fileName = "1DBoilingChannel";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep =3;
- int freqSave = 1;
- double cfl = 0.5;
- double maxTime = 5;
- double precision = 1e-8;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "FiveEqsTwoFluid.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- cout << "Building cartesian mesh" << endl;
- double xinf=0.0;
- double xsup=4.2;
- int nx=50;
- Mesh M(xinf,xsup,nx);
- double eps=1.E-8;
- M.setGroupAtPlan(xsup,0,eps,"Outlet");//Neumann
- M.setGroupAtPlan(xinf,0,eps,"Wall");//
- int spaceDim = M.getSpaceDimension();
-
- // set the limit field for each boundary
- LimitField limitOutlet, limitWall;
- map<string, LimitField> boundaryFields;
- limitOutlet.bcType=Outlet;
- limitOutlet.p = 100e5;
- boundaryFields["Outlet"] = limitOutlet;
-
- limitWall.bcType=Wall;
- limitWall.T = 600;
- limitWall.v_x = vector<double>(2,0);
- boundaryFields["Wall"]= limitWall;
-
- // physical constants
- double latentHeat=1e6;
- double satTemp=618;
- double dHsatl_over_dp=0.05;
- double Psat=85e5;
-
- FiveEqsTwoFluid myProblem(around155bars600K,spaceDim);
- int nbPhase = myProblem.getNumberOfPhases();
- int nVar = myProblem.getNumberOfVariables();
-
- //Initial field creation
- Vector VV_Constant(nVar);
- VV_Constant(0) = 0.;
- VV_Constant(1) = 155e5;
- for (int idim=0; idim<spaceDim;idim++){
- VV_Constant(2+idim) = 0;
- VV_Constant(2+idim +spaceDim) =0;
- }
- VV_Constant(2+spaceDim*nbPhase) = 600;
-
- cout << "Number of Phases = " << nbPhase << endl;
- cout << "Building initial data " << endl;
-
- // generate initial condition
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- //set the boundary conditions
- myProblem.setBoundaryFields(boundaryFields);
- /* set physical parameters*/
-// myProblem.setLatentHeat(latentHeat);
-// myProblem.setSatPressure( Psat, dHsatl_over_dp);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
- myProblem.setEntropicCorrection(true);
-
- // name file save
- string fileName = "1DDepressurisation";
-
- // set numerical parameters
- unsigned MaxNbOfTimeStep =3;
- int freqSave = 1;
- double cfl = 0.5;
- double maxTime = 5;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- bool ok;
-
- // evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "FiveEqsTwoFluid.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- cout << "Building cartesian mesh " << endl;
- double xinf=0.0;
- double xsup=1.0;
- int nx=10;
- Mesh M(xinf,xsup,nx);
- double eps=1.E-8;
- M.setGroupAtPlan(xsup,0,eps,"Neumann");
- M.setGroupAtPlan(xinf,0,eps,"Neumann");
- int spaceDim = M.getSpaceDimension();
-
- // set the limit field for each boundary
- LimitField limitNeumann;
- map<string, LimitField> boundaryFields;
-
- limitNeumann.bcType=Neumann;
- limitNeumann.T =0.;
- limitNeumann.p = 155e5;
- limitNeumann.alpha = 0;
- limitNeumann.v_x = vector<double>(2,0);
- limitNeumann.v_y = vector<double>(2,0);
- limitNeumann.v_z = vector<double>(2,0);
- boundaryFields["Neumann"] = limitNeumann;
-
- FiveEqsTwoFluid myProblem(around155bars600K,spaceDim);
- int nbPhase = myProblem.getNumberOfPhases();
- int nVar = myProblem.getNumberOfVariables();
- Field VV("Primitive", CELLS, M, nVar);
-
- // Prepare for the initial condition
- Vector VV_Left(nVar),VV_Right(nVar);
- double discontinuity = (xinf+xsup)/2.;
- // two vectors
- VV_Left(0) = 0.5; VV_Right(0) = 0.2;
- VV_Left(1) = 155e5; VV_Right(1) = 155e5;
- for (int idim=0; idim<spaceDim;idim++){
- VV_Left(2+idim) = 1;VV_Right(2+idim) = 1;
- VV_Left(2+idim +spaceDim) =1;VV_Right(2+idim +spaceDim) = 1;
- }
- VV_Left(2+spaceDim*nbPhase) = 618;
- VV_Right(2+spaceDim*nbPhase) = 618;
-
- //Initial field creation
- cout << "Building initial data" << endl;
- myProblem.setInitialFieldStepFunction(M,VV_Left,VV_Right,discontinuity);
-
- //set the boundary fields
- myProblem.setBoundaryFields(boundaryFields);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
-
- // name of result file
- string fileName = "RiemannProblem";
-
- // simuulation parameters
- unsigned MaxNbOfTimeStep =3;
- int freqSave = 1;
- double cfl = 0.95;
- double maxTime = 1;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
-
- // set display options to monitor the calculation
- myProblem.setVerbose( true);
- myProblem.saveConservativeField(true);
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "FiveEqsTwoFluid.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- cout << "Building regular mesh " << endl;
- double xinf=0.0;
- double xsup=1.0;
- double yinf=0.0;
- double ysup=1.0;
- int nx=20;
- int ny=20;
- Mesh M(xinf,xsup,nx,yinf,ysup,ny);
- double eps=1.E-6;
- M.setGroupAtPlan(xsup,0,eps,"Wall");
- M.setGroupAtPlan(xinf,0,eps,"Wall");
- M.setGroupAtPlan(yinf,1,eps,"Inlet");
- M.setGroupAtPlan(ysup,1,eps,"Outlet");
- int spaceDim = M.getSpaceDimension();
-
- // physical constants
- vector<double> gravite(spaceDim,0.) ;
- gravite[1]=-7;
- gravite[0]=7;
-
- // set the limit field for each boundary
- LimitField limitWall;
- map<string, LimitField> boundaryFields;
- limitWall.bcType=Wall;
- limitWall.T = 563;
- limitWall.v_x = vector<double>(2,0);
- limitWall.v_y = vector<double>(2,0);
- boundaryFields["Wall"]= limitWall;
-
- LimitField limitInlet;
- limitInlet.bcType=Inlet;
- limitInlet.T = 563;
- limitInlet.alpha = 0;
- limitInlet.v_x = vector<double>(2,0);
- limitInlet.v_y = vector<double>(2,1);
- boundaryFields["Inlet"]= limitInlet;
-
- LimitField limitOutlet;
- limitOutlet.bcType=Outlet;
- limitOutlet.p = 155e5;
- boundaryFields["Outlet"]= limitOutlet;
-
- // physical constants
- double heatPower=1e8;
-
- FiveEqsTwoFluid myProblem(around155bars600K,spaceDim);
- int nbPhase = myProblem.getNumberOfPhases();
- int nVar = myProblem.getNumberOfVariables();
- // Prepare for the initial condition
- Vector VV_Constant(nVar);
- // constant vector
- VV_Constant(0) = 0;
- VV_Constant(1) = 155e5;
- VV_Constant(2) = 0;
- VV_Constant(3) = 1;
- VV_Constant(4) = 0;
- VV_Constant(5) = 1;
- VV_Constant(6) = 563;
-
- //Initial field creation
- cout << "Building initial data " << endl;
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- //set the boundary conditions
- myProblem.setBoundaryFields(boundaryFields);
-
- // set physical parameters
- myProblem.setHeatSource(heatPower);
- myProblem.setGravity(gravite);
-
- // name file save
- string fileName = "2DInclinedBoilingChannel";
-
- //numerical parameters
- myProblem.setNumericalScheme(upwind, Explicit);
- unsigned MaxNbOfTimeStep = 3 ;
- int freqSave = 5;
- double cfl = 0.5;
- double maxTime = 5;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.saveVelocity();
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "FiveEqsTwoFluid.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- cout << "Building Cartesian mesh " << endl;
- double xinf=0.0;
- double xsup=1.0;
- double yinf=0.0;
- double ysup=1.0;
- int nx=50;
- int ny=50;
- Mesh M(xinf,xsup,nx,yinf,ysup,ny);
- double eps=1.E-6;
- M.setGroupAtPlan(xsup,0,eps,"Wall");
- M.setGroupAtPlan(xinf,0,eps,"Wall");
- M.setGroupAtPlan(yinf,1,eps,"Wall");
- M.setGroupAtPlan(ysup,1,eps,"Wall");
- int spaceDim = M.getSpaceDimension();
-
- // set the limit field for each boundary
- vector<double> wallVelocityX(2,0);
- vector<double> wallVelocityY(2,0);
- double wallTemperature=300;
-
- // physical constants
- vector<double> gravite(spaceDim,0.) ;
- gravite[1]=-7;
- gravite[0]=7;
-
- FiveEqsTwoFluid myProblem(around1bar300K,spaceDim);
- int nbPhase = myProblem.getNumberOfPhases();
- int nVar = myProblem.getNumberOfVariables();
- // Prepare for the initial condition
- Vector VV_Constant(nVar);
- // constant vector
- VV_Constant(0) = 0.5;
- VV_Constant(1) = 1e5;
- VV_Constant(2) = 0;
- VV_Constant(3) = 0;
- VV_Constant(4) = 0;
- VV_Constant(5) = 0;
- VV_Constant(6) = wallTemperature;
-
- //Initial field creation
- cout << "Building initial data" << endl;
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- //set the boundary conditions
- myProblem.setWallBoundaryCondition("Wall",wallTemperature,wallVelocityX,wallVelocityY);
-
- // set physical parameters
- myProblem.setGravity(gravite);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Implicit);
-
- // name file save
- string fileName = "2DInclinedSedimentation";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep = 3 ;
- int freqSave = 1;
- double cfl = 0.1;
- double maxTime = 5;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.saveVelocity();
- myProblem.displayConditionNumber();
- myProblem.setSaveFileFormat(CSV);
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "IsothermalTwoFluid.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- cout << "Building cartesian mesh" << endl;
- double xinf=0.0;
- double xsup=1.0;
- int nx=50;
- Mesh M(xinf,xsup,nx);
- double eps=1.E-6;
- M.setGroupAtPlan(xsup,0,eps,"Outlet");
- M.setGroupAtPlan(xinf,0,eps,"Wall");
- int spaceDim = M.getSpaceDimension();
-
- // physical constants
- double dHsatl_over_dp=0.05;
- double Psat=85e5;
- double latentHeat=1e6;
-
- // set the limit field for each boundary
- LimitField limitOutlet, limitWall;
- map<string, LimitField> boundaryFields;
- limitOutlet.bcType=Outlet;
- limitOutlet.p = 80e5;
- boundaryFields["Outlet"] = limitOutlet;
-
- limitWall.bcType=Wall;
- limitWall.v_x = vector<double>(2,0);
- boundaryFields["Wall"]= limitWall;
- IsothermalTwoFluid myProblem(around155bars600K,spaceDim);
- // Prepare for the initial condition
- int nVar = myProblem.getNumberOfVariables();
- Vector VV_Constant(nVar);
- VV_Constant(0) = 0.;
- VV_Constant(1) = 155e5;
- VV_Constant(2) = 0;
- VV_Constant(3) = 0;
-
- //Initial field creation
- cout << "Building initial data" << endl;
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- //set the boundary conditions
- myProblem.setBoundaryFields(boundaryFields);
-
- //set physical parameters
-// myProblem.setSatPressure( Psat, dHsatl_over_dp);
-// myProblem.setLatentHeat(latentHeat);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
- myProblem.setEntropicCorrection(true);
-
- // name file save
- string fileName = "1DDepressurisation";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep = 3;
- int freqSave = 1;
- double cfl = 0.95;
- double maxTime = 5;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- bool ok;
-
- // evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of simulation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "IsothermalTwoFluid.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- cout << "Building Cartesian mesh " << endl;
- double xinf=0.0;
- double xsup=1.0;
- int nx=10;
- Mesh M(xinf,xsup,nx);
- double eps=1.E-8;
- M.setGroupAtPlan(xsup,0,eps,"Neumann");
- M.setGroupAtPlan(xinf,0,eps,"Neumann");
- int spaceDim = M.getSpaceDimension();
-
- // set the limit field for each boundary
- LimitField limitNeumann;
- limitNeumann.bcType=Neumann;
- map<string, LimitField> boundaryFields;
-
- limitNeumann.p = 155e5;
- limitNeumann.alpha = 0;
- limitNeumann.v_x = vector<double>(2,0);
- limitNeumann.v_y = vector<double>(2,0);
- limitNeumann.v_z = vector<double>(2,0);
- boundaryFields["Neumann"] = limitNeumann;
-
- IsothermalTwoFluid myProblem(around155bars600K,spaceDim);
- int nbPhase = myProblem.getNumberOfPhases();
- int nVar = myProblem.getNumberOfVariables();
- Field VV("Primitive", CELLS, M, nVar);
-
- // Prepare for the initial condition
- Vector VV_Left(nVar),VV_Right(nVar);
- double discontinuity = (xinf+xsup)/2.;
- // two vectors
- VV_Left(0) = 0.5; VV_Right(0) = 0.2;
- VV_Left(1) = 155e5; VV_Right(1) = 155e5;
- for (int idim=0; idim<spaceDim;idim++){
- VV_Left(2+idim) = 1;VV_Right(2+idim) = 1;
- VV_Left(2+idim +spaceDim) =2;VV_Right(2+idim +spaceDim) = 1;
- }
-
- //Initial field creation
- cout << "Building initial data" << endl;
-
- myProblem.setInitialFieldStepFunction(M,VV_Left,VV_Right,discontinuity);
-
- //set the boundary fields
- myProblem.setBoundaryFields(boundaryFields);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
-
- // name file save
- string fileName = "RiemannProblem";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep =3 ;
- int freqSave = 1;
- double cfl = 0.95;
- double maxTime = 1;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.saveConservativeField(true);
- myProblem.setSaveFileFormat(MED);
-
- /* set display option to monitor the calculation */
- myProblem.setVerbose( true);
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "IsothermalTwoFluid.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- cout << "Building Cartesian mesh " << endl;
- int spaceDim=1;
- double xinf=0.0;
- double xsup=1.0;
- int nx=50;
-
- vector<double> wallVelocityX(2,0);
-
- // physical constants
- vector<double> gravite(spaceDim,0.) ;
- gravite[0]=-10;
-
- IsothermalTwoFluid myProblem(around1bar300K,spaceDim);
- int nVar = myProblem.getNumberOfVariables();
-
- // Prepare for the initial condition
- vector<double> VV_Constant(nVar,0.);
- // constant vector
- VV_Constant[0] = 0.5;
- VV_Constant[1] = 1e5;
- VV_Constant[2] = 0;
- VV_Constant[3] = 0;
-
- //Initial field creation
- cout << "Building initial data " << endl;
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"wall","wall");
- myProblem.setWallBoundaryCondition("wall",wallVelocityX);
-
-
- // physical parameters
- myProblem.setGravity(gravite);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Implicit);
- myProblem.setEntropicCorrection(true);
-
- // name file save
- string fileName = "1DSedimentation";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep = 3;
- int freqSave = 1;
- double cfl = 1;
- double maxTime = 5;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.displayConditionNumber();
- myProblem.setSaveFileFormat(CSV);
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of simulation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "IsothermalTwoFluid.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- cout << "Building Cartesian mesh " << endl;
- double xinf=0.0;
- double xsup=1.0;
- double yinf=0.0;
- double ysup=1.0;
- int nx=50;
- int ny=50;
- Mesh M(xinf,xsup,nx,yinf,ysup,ny);
- double eps=1.E-6;
- M.setGroupAtPlan(xsup,0,eps,"Wall");
- M.setGroupAtPlan(xinf,0,eps,"Wall");
- M.setGroupAtPlan(yinf,1,eps,"Wall");
- M.setGroupAtPlan(ysup,1,eps,"Wall");
- int spaceDim = M.getSpaceDimension();
-
- // set the limit field for each boundary
- vector<double> wallVelocityX(2,0);
- vector<double> wallVelocityY(2,0);
-
- // physical constants
- vector<double> gravite(spaceDim,0.) ;
- gravite[1]=-7;
- gravite[0]=7;
-
- IsothermalTwoFluid myProblem(around1bar300K,spaceDim);
- int nbPhase = myProblem.getNumberOfPhases();
- int nVar = myProblem.getNumberOfVariables();
- // Prepare for the initial condition
- Vector VV_Constant(nVar);
- // constant vector
- VV_Constant(0) = 0.5;
- VV_Constant(1) = 1e5;
- VV_Constant(2) = 0;
- VV_Constant(3) = 0;
- VV_Constant(4) = 0;
- VV_Constant(5) = 0;
-
- //Initial field creation
- cout << "Building initial data" << endl;
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- //set the boundary conditions
- myProblem.setWallBoundaryCondition("Wall",wallVelocityX,wallVelocityY);
-
- // set physical parameters
- myProblem.setGravity(gravite);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
-
- // name file save
- string fileName = "2DInclinedSedimentation";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep = 3 ;
- int freqSave = 1;
- double cfl = 0.25;
- double maxTime = 5;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.saveVelocity();
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "IsothermalTwoFluid.hxx"\r
-\r
-#include <iostream>\r
-\r
-using namespace std;\r
-\r
-int main(int argc, char** argv)\r
-{\r
- //Preprocessing: mesh and group creation\r
- cout << "Building Cartesian mesh " << endl;\r
- double xinf=0.0;\r
- double xsup=1.0;\r
- double yinf=0.0;\r
- double ysup=1.0;\r
- int nx=50;\r
- int ny=50;\r
- Mesh M(xinf,xsup,nx,yinf,ysup,ny);\r
- double eps=1.E-6;\r
- M.setGroupAtPlan(xsup,0,eps,"Wall");\r
- M.setGroupAtPlan(xinf,0,eps,"Wall");\r
- M.setGroupAtPlan(yinf,1,eps,"Wall");\r
- M.setGroupAtPlan(ysup,1,eps,"inlet");\r
- int spaceDim = M.getSpaceDimension();\r
-\r
- // set the limit field for each boundary\r
- vector<double> wallVelocityX(2,0);\r
- vector<double> wallVelocityY(2,0);\r
- double inletAlpha=1;\r
- double outletPressure=1e5;\r
-\r
- // physical constants\r
- vector<double> gravite(spaceDim,0.) ;\r
- gravite[1]=-10;\r
- gravite[0]=0;\r
-\r
- IsothermalTwoFluid myProblem(around1bar300K,spaceDim);\r
- int nbPhase = myProblem.getNumberOfPhases();\r
- int nVar = myProblem.getNumberOfVariables();\r
- // Prepare for the initial condition\r
- Vector VV_Constant(nVar);\r
- // constant vector\r
- VV_Constant(0) = 0.;\r
- VV_Constant(1) = 1e5;\r
- VV_Constant(2) = 0;\r
- VV_Constant(3) = 0;\r
-\r
- //Initial field creation\r
- cout << "Building initial data" << endl;\r
- myProblem.setInitialFieldConstant(M,VV_Constant);\r
-\r
- //set the boundary conditions\r
- myProblem.setWallBoundaryCondition("Wall",wallVelocityX,wallVelocityY);\r
- myProblem.setInletPressureBoundaryCondition("inlet", inletAlpha, outletPressure);\r
-\r
- // set physical parameters\r
- myProblem.setGravity(gravite);\r
-\r
- // set the numerical method\r
- myProblem.setNumericalScheme(upwind, Explicit);\r
-\r
- // name file save\r
- string fileName = "2DInclinedSedimentation";\r
-\r
- // parameters calculation\r
- unsigned MaxNbOfTimeStep = 3 ;\r
- int freqSave = 1;\r
- double cfl = 0.1;\r
- double maxTime = 5;\r
- double precision = 1e-6;\r
-\r
- myProblem.setCFL(cfl);\r
- myProblem.setPrecision(precision);\r
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
- myProblem.setTimeMax(maxTime);\r
- myProblem.setFreqSave(freqSave);\r
- myProblem.setFileName(fileName);\r
- myProblem.saveVelocity();\r
-\r
- // evolution\r
- myProblem.initialize();\r
-\r
- bool ok = myProblem.run();\r
- if (ok)\r
- cout << "Simulation "<<fileName<<" is successful !" << endl;\r
- else\r
- cout << "Simulation "<<fileName<<" failed ! " << endl;\r
-\r
- cout << "------------ End of calculation !!! -----------" << endl;\r
- myProblem.terminate();\r
-\r
- return EXIT_SUCCESS;\r
-}\r
#---------------------------------------------------------------------------------------------------------------#
+SET(TESTS_LIBRARY_PATH ${CMAKE_BINARY_DIR}/Models/src:${CDMATH_DIR}/lib:${MEDCOUPLING_LIBRARIES}:${MEDFILE_C_LIBRARIES}:${PETSC_DIR}/${PETSC_ARCH}/lib:${PV_LIB_DIR} )
+SET(TESTS_PYTHON_PATH ${CMAKE_BINARY_DIR}/Models/src:${CMAKE_BINARY_DIR}/swig:${CDMATH_DIR}/lib:${CDMATH_DIR}/lib/cdmath:${CDMATH_DIR}/bin/cdmath:${CDMATH_DIR}/bin/cdmath/postprocessing:${MEDCOUPLING_LIBRARIES}:${MEDFILE_C_LIBRARIES}:${PETSC_DIR}/${PETSC_ARCH}/lib:${PV_PYTHON_DIR} )
############# python example tests
function(CreatePythonTest pythonFile)
add_test(${pythonFile} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${pythonFile})
- SET_PROPERTY(TEST ${pythonFile} PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:${CDMATH_DIR}/lib:${CDMATH_DIR}/lib/med:${CDMATH_DIR}/lib/medcoupling:${PETSC_DIR}/${PETSC_ARCH}/lib)
- SET_PROPERTY(TEST ${pythonFile} APPEND PROPERTY ENVIRONMENT PYTHONPATH=${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib/CoreFlows_Python:${CMAKE_INSTALL_PREFIX}/bin/CoreFlows_Python:${CDMATH_DIR}/lib:${CDMATH_DIR}/lib/cdmath:${CDMATH_DIR}/bin/cdmath:${CDMATH_DIR}/lib/med:${CDMATH_DIR}/lib/medcoupling)
- message("setting python example test ${pythonFile}")
+ SET_PROPERTY(TEST ${pythonFile} PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${TESTS_LIBRARY_PATH} )
+ SET_PROPERTY(TEST ${pythonFile} APPEND PROPERTY ENVIRONMENT PYTHONPATH=${TESTS_PYTHON_PATH} )
endfunction(CreatePythonTest)
# copy all *.py tests files before build
)
-CreatePythonTest(DiffusionEquation_1DHeatedRod.py)
-CreatePythonTest(DriftModel_1DBoilingAssembly.py)
-CreatePythonTest(DriftModel_1DBoilingChannel.py)
-CreatePythonTest(DriftModel_1DDepressurisation.py)
-CreatePythonTest(DriftModel_1DPorosityJump.py)
-CreatePythonTest(DriftModel_1DPressureLoss.py)
-CreatePythonTest(DriftModel_1DRiemannProblem.py)
-CreatePythonTest(DriftModel_1DVidangeReservoir.py)
-CreatePythonTest(DriftModel_2BranchesBoilingChannels.py)
-CreatePythonTest(DriftModel_2DInclinedChannelGravity.py)
-CreatePythonTest(DriftModel_2DInclinedChannelGravityTriangles.py)
-CreatePythonTest(DriftModel_2DInclinedChannelGravityBarriers.py)
-CreatePythonTest(DriftModel_2DBoilingChannelBarrier.py)
-CreatePythonTest(DriftModel_2DInclinedBoilingChannelBarrier.py)
-CreatePythonTest(DriftModel_2DInclinedBoilingChannel.py)
-CreatePythonTest(DriftModel_2DPorosityJump.py)
-CreatePythonTest(DriftModel_2DPressureLoss.py)
-CreatePythonTest(DriftModel_2DVidangeReservoir.py)
-CreatePythonTest(DriftModel_2DVidangeReservoirUnstructured.py)
-CreatePythonTest(DriftModel_3DBoilingChannelBarrier.py)
-CreatePythonTest(FiveEqsTwoFluid_1DBoilingAssembly.py)
-CreatePythonTest(FiveEqsTwoFluid_1DBoilingChannel.py)
-CreatePythonTest(FiveEqsTwoFluid_1DVidangeReservoir.py)
-CreatePythonTest(FiveEqsTwoFluid_2DInclinedBoilingChannel.py)
-CreatePythonTest(FiveEqsTwoFluid_2DInclinedSedimentation.py)
-CreatePythonTest(FiveEqsTwoFluid_2DVidangeReservoir.py)
-CreatePythonTest(IsothermalTwoFluid_1DSedimentation.py)
-CreatePythonTest(IsothermalTwoFluid_1DVidangeReservoir.py)
-CreatePythonTest(IsothermalTwoFluid_2DVidangeReservoir.py)
-CreatePythonTest(SinglePhase_1DDepressurisation.py)
-CreatePythonTest(SinglePhase_1DHeatedAssembly.py)
-CreatePythonTest(SinglePhase_1DHeatedChannel.py)
-CreatePythonTest(SinglePhase_1DRiemannProblem.py)
-CreatePythonTest(SinglePhase_1DWaterHammer.py)
-CreatePythonTest(SinglePhase_2BranchesHeatedChannels.py)
-CreatePythonTest(SinglePhase_2DHeatedChannelInclined.py)
-CreatePythonTest(SinglePhase_2DLidDrivenCavity.py)
-CreatePythonTest(SinglePhase_2DLidDrivenCavity_unstructured.py)
-CreatePythonTest(SinglePhase_2DSphericalExplosion_unstructured.py)
-CreatePythonTest(SinglePhase_3DSphericalExplosion_unstructured.py)
-CreatePythonTest(SinglePhase_2DThermalDiffusion.py)
-CreatePythonTest(SinglePhase_2DVidangeReservoir.py)
-CreatePythonTest(SinglePhase_2DWallHeatedChannel_ChangeSect.py)
-CreatePythonTest(SinglePhase_3DHeatDrivenCavity.py)
-CreatePythonTest(SinglePhase_3DVortexTube_NoCone_NoViscosity.py)
-CreatePythonTest(SinglePhase_3DVortexTube_WithCone_NoViscosity.py)
-CreatePythonTest(TransportEquation_1DHeatedChannel.py)
-CreatePythonTest(StationaryDiffusionEquation_2DEF.py)
-CreatePythonTest(StationaryDiffusionEquation_2DEF_Neumann.py)
-CreatePythonTest(StationaryDiffusionEquation_2DFV_StructuredTriangles.py)
-CreatePythonTest(StationaryDiffusionEquation_2DFV_EquilateralTriangles.py)
-CreatePythonTest(StationaryDiffusionEquation_2DFV_StructuredSquares.py)
-CreatePythonTest(StationaryDiffusionEquation_2DFV_StructuredSquares_Neumann.py)
-CreatePythonTest(StationaryDiffusionEquation_3DEF.py)
-CreatePythonTest(StationaryDiffusionEquation_3DFV_StructuredCubes.py)
-CreatePythonTest(StationaryDiffusionEquation_3DFV_StructuredTetrahedra.py)
-CreatePythonTest(StationaryDiffusionEquation_3DEF_RoomCooling.py)
-CreatePythonTest(StationaryDiffusionEquation_3DVF_RoomCooling_StructuredCubes.py)
-CreatePythonTest(StationaryDiffusionEquation_3DVF_RoomCooling_UnstructuredTetras.py)
+CreatePythonTest(DiffusionEquation/DiffusionEquation_1DHeatedRod.py)
+CreatePythonTest(DiffusionEquation/DiffusionEquation_1DHeatedRod_FE.py)
+
+CreatePythonTest(DriftModel/DriftModel_1DBoilingAssembly.py)
+CreatePythonTest(DriftModel/DriftModel_1DBoilingChannel.py)
+CreatePythonTest(DriftModel/DriftModel_1DChannelGravity.py)
+CreatePythonTest(DriftModel/DriftModel_1DDepressurisation.py)
+CreatePythonTest(DriftModel/DriftModel_1DPorosityJump.py)
+CreatePythonTest(DriftModel/DriftModel_1DPressureLoss.py)
+CreatePythonTest(DriftModel/DriftModel_1DRiemannProblem.py)
+CreatePythonTest(DriftModel/DriftModel_1DVidangeReservoir.py)
+CreatePythonTest(DriftModel/DriftModel_2BranchesBoilingChannels.py)
+CreatePythonTest(DriftModel/DriftModel_2DInclinedChannelGravity.py)
+CreatePythonTest(DriftModel/DriftModel_2DInclinedChannelGravityTriangles.py)
+CreatePythonTest(DriftModel/DriftModel_2DInclinedChannelGravityBarriers.py)
+CreatePythonTest(DriftModel/DriftModel_2DBoilingChannelBarrier.py)
+CreatePythonTest(DriftModel/DriftModel_2DInclinedBoilingChannelBarrier.py)
+CreatePythonTest(DriftModel/DriftModel_2DInclinedBoilingChannel.py)
+CreatePythonTest(DriftModel/DriftModel_2DPorosityJump.py)
+CreatePythonTest(DriftModel/DriftModel_2DPressureLoss.py)
+CreatePythonTest(DriftModel/DriftModel_2DVidangeReservoir.py)
+CreatePythonTest(DriftModel/DriftModel_2DVidangeReservoirUnstructured.py)
+CreatePythonTest(DriftModel/DriftModel_3DBoilingChannelBarrier.py)
+
+CreatePythonTest(FiveEqsTwoFluid/FiveEqsTwoFluid_1DBoilingAssembly.py)
+CreatePythonTest(FiveEqsTwoFluid/FiveEqsTwoFluid_1DBoilingChannel.py)
+CreatePythonTest(FiveEqsTwoFluid/FiveEqsTwoFluid_1DVidangeReservoir.py)
+CreatePythonTest(FiveEqsTwoFluid/FiveEqsTwoFluid_2DInclinedBoilingChannel.py)
+CreatePythonTest(FiveEqsTwoFluid/FiveEqsTwoFluid_2DInclinedSedimentation.py)
+CreatePythonTest(FiveEqsTwoFluid/FiveEqsTwoFluid_2DVidangeReservoir.py)
+
+CreatePythonTest(IsothermalTwoFluid/IsothermalTwoFluid_1DSedimentation.py)
+CreatePythonTest(IsothermalTwoFluid/IsothermalTwoFluid_1DVidangeReservoir.py)
+CreatePythonTest(IsothermalTwoFluid/IsothermalTwoFluid_2DVidangeReservoir.py)
+
+CreatePythonTest(SinglePhase/SinglePhase_1DDepressurisation.py)
+CreatePythonTest(SinglePhase/SinglePhase_1DHeatedAssembly.py)
+CreatePythonTest(SinglePhase/SinglePhase_1DHeatedChannel.py)
+CreatePythonTest(SinglePhase/SinglePhase_1DRiemannProblem.py)
+CreatePythonTest(SinglePhase/SinglePhase_1DWaterHammer.py)
+CreatePythonTest(SinglePhase/SinglePhase_2BranchesHeatedChannels.py)
+CreatePythonTest(SinglePhase/SinglePhase_2DVidangeReservoir.py)
+CreatePythonTest(SinglePhase/SinglePhase_2DLidDrivenCavity.py)
+CreatePythonTest(SinglePhase/SinglePhase_2DLidDrivenCavity_unstructured.py)
+CreatePythonTest(SinglePhase/SinglePhase_2DPoiseuilleFlow.py)
+CreatePythonTest(SinglePhase/SinglePhase_2DPoiseuilleFlow_restart.py)
+CreatePythonTest(SinglePhase/SinglePhase_2DPoiseuilleFlow_outputFields.py)
+CreatePythonTest(SinglePhase/SinglePhase_2DSphericalExplosion_unstructured.py)
+CreatePythonTest(SinglePhase/SinglePhase_2DHeatedChannelInclined.py)
+CreatePythonTest(SinglePhase/SinglePhase_2DThermalDiffusion.py)
+CreatePythonTest(SinglePhase/SinglePhase_2DWallHeatedChannel_ChangeSect.py)
+CreatePythonTest(SinglePhase/SinglePhase_3DSphericalExplosion_unstructured.py)
+CreatePythonTest(SinglePhase/SinglePhase_3DHeatDrivenCavity.py)
+CreatePythonTest(SinglePhase/SinglePhase_3DVortexTube_NoCone_NoViscosity.py)
+CreatePythonTest(SinglePhase/SinglePhase_3DVortexTube_WithCone_NoViscosity.py)
+
+CreatePythonTest(TransportEquation/TransportEquation_1DHeatedChannel.py)
+
+CreatePythonTest(StationaryDiffusionEquation/StationaryDiffusionEquation_2DEF.py)
+CreatePythonTest(StationaryDiffusionEquation/StationaryDiffusionEquation_2DEF_Neumann.py)
+CreatePythonTest(StationaryDiffusionEquation/StationaryDiffusionEquation_2DFV_StructuredTriangles.py)
+CreatePythonTest(StationaryDiffusionEquation/StationaryDiffusionEquation_2DFV_EquilateralTriangles.py)
+CreatePythonTest(StationaryDiffusionEquation/StationaryDiffusionEquation_2DFV_StructuredSquares.py)
+CreatePythonTest(StationaryDiffusionEquation/StationaryDiffusionEquation_2DFV_StructuredSquares_Neumann.py)
+CreatePythonTest(StationaryDiffusionEquation/StationaryDiffusionEquation_3DEF.py)
+CreatePythonTest(StationaryDiffusionEquation/StationaryDiffusionEquation_3DFV_StructuredCubes.py)
+CreatePythonTest(StationaryDiffusionEquation/StationaryDiffusionEquation_3DFV_StructuredTetrahedra.py)
+CreatePythonTest(StationaryDiffusionEquation/StationaryDiffusionEquation_3DEF_RoomCooling.py)
+CreatePythonTest(StationaryDiffusionEquation/StationaryDiffusionEquation_3DVF_RoomCooling_StructuredCubes.py)
+CreatePythonTest(StationaryDiffusionEquation/StationaryDiffusionEquation_3DVF_RoomCooling_UnstructuredTetras.py)
############# python convergence tests
file(COPY convergence_${model}_${convergenceTest}.py ../${pythonSolver} ${MY_MESHES_AND_PICTURES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE )
add_test(convergence_${model}_${convergenceTest} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/convergence_${model}_${convergenceTest}.py)
- SET_PROPERTY(TEST convergence_${model}_${convergenceTest} PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:${CDMATH_DIR}/lib:${CDMATH_DIR}/lib/med:${CDMATH_DIR}/lib/medcoupling:${PETSC_DIR}/${PETSC_ARCH}/lib:${PV_LIB_DIR})
- SET_PROPERTY(TEST convergence_${model}_${convergenceTest} APPEND PROPERTY ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib/CoreFlows_Python:${CMAKE_INSTALL_PREFIX}/bin/CoreFlows_Python:${CDMATH_DIR}/lib:${CDMATH_DIR}/lib/cdmath:${CDMATH_DIR}/bin/cdmath:${CDMATH_DIR}/lib/med:${CDMATH_DIR}/lib/medcoupling:${CDMATH_DIR}/bin/cdmath/postprocessing:${PV_PYTHON_DIR})
- message("setting python convergence test convergence_${model}_${convergenceTest}")
+ SET_PROPERTY(TEST convergence_${model}_${convergenceTest} PROPERTY ENVIRONMENT LD_LIBRARY_PATH=${TESTS_LIBRARY_PATH} )
+ SET_PROPERTY(TEST convergence_${model}_${convergenceTest} APPEND PROPERTY ENVIRONMENT PYTHONPATH=${TESTS_PYTHON_PATH} )
+
endfunction(CreatePythonConvergenceTest)
add_subdirectory (Convergence/StationaryDiffusion)
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+
+def DiffusionEquation_1DHeatedRod():
+ spaceDim = 1;
+ # Prepare for the mesh
+ xinf = 0 ;
+ xsup=4.2;
+ nx=10;
+
+ print ("Building of a 1D mesh with ", nx ," cells")
+
+ # set the limit field for each boundary
+ Temperature=623;
+ cp_ur=300
+ rho_ur=10000
+ lambda_ur=5
+
+ FECalculation=False
+ myProblem = cf.DiffusionEquation(spaceDim,FECalculation,rho_ur,cp_ur,lambda_ur);
+ nVar = myProblem.getNumberOfVariables();
+
+ #Set heat exchanges
+ fluidTemp=573.;#fluid mean temperature
+ heatTransfertCoeff=1000.;#fluid/solid exchange coefficient
+ phi=1e5;#heat power ddensity
+ myProblem.setFluidTemperature(fluidTemp);
+ myProblem.setHeatTransfertCoeff(heatTransfertCoeff);
+ myProblem.setHeatSource(phi);
+
+ # constant vector
+ VV_Constant = [623];
+
+ #Initial field creation
+ print("Building initial data" );
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"Neumann","Neumann");
+
+ # the boundary conditions
+ myProblem.setNeumannBoundaryCondition("Neumann");
+
+ # set the numerical method
+ myProblem.setTimeScheme( cf.Explicit);
+ # myProblem.setLinearSolver(GMRES,ILU,True);
+
+ # name of result file
+ fileName = "1DRodTemperature";
+
+ # computation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.95;
+ maxTime = 100000000;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+
+ # evolution
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DiffusionEquation_1DHeatedRod()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+
+def DiffusionEquation_1DHeatedRod():
+ spaceDim = 1;
+ # Prepare for the mesh
+ xinf = 0 ;
+ xsup=4.2;
+ nx=10;
+
+ print ("Building of a 1D mesh with ", nx ," cells")
+
+ # set the limit field for each boundary
+ Temperature=623;
+ cp_ur=300
+ rho_ur=10000
+ lambda_ur=5
+
+ FECalculation=True
+ myProblem = cf.DiffusionEquation(spaceDim,FECalculation,rho_ur,cp_ur,lambda_ur);
+ nVar = myProblem.getNumberOfVariables();
+
+ #Set heat exchanges
+ fluidTemp=573.;#fluid mean temperature
+ heatTransfertCoeff=1000.;#fluid/solid exchange coefficient
+ phi=1e5;#heat power ddensity
+ myProblem.setFluidTemperature(fluidTemp);
+ myProblem.setHeatTransfertCoeff(heatTransfertCoeff);
+ myProblem.setHeatSource(phi);
+
+ # constant vector
+ VV_Constant = [623];
+
+ #Initial field creation
+ print("Building initial data" );
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"Neumann","Neumann");
+
+ # the boundary conditions
+ myProblem.setNeumannBoundaryCondition("Neumann");
+
+ # set the numerical method
+ myProblem.setTimeScheme( cf.Explicit);
+ # myProblem.setLinearSolver(GMRES,ILU,True);
+
+ # name of result file
+ fileName = "1DRodTemperature_FE";
+
+ # computation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.95;
+ maxTime = 100000000;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+
+ # evolution
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DiffusionEquation_1DHeatedRod()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-
-def DiffusionEquation_1DHeatedRod():
- spaceDim = 1;
- # Prepare for the mesh
- xinf = 0 ;
- xsup=4.2;
- nx=10;
-
- print ("Building of a 1D mesh with ", nx ," cells")
-
- # set the limit field for each boundary
- Temperature=623;
- cp_ur=300
- rho_ur=10000
- lambda_ur=5
-
- FECalculation=False
- myProblem = cf.DiffusionEquation(spaceDim,FECalculation,rho_ur,cp_ur,lambda_ur);
- nVar = myProblem.getNumberOfVariables();
-
- #Set heat exchanges
- fluidTemp=573.;#fluid mean temperature
- heatTransfertCoeff=1000.;#fluid/solid exchange coefficient
- phi=1e5;#heat power ddensity
- myProblem.setFluidTemperature(fluidTemp);
- myProblem.setHeatTransfertCoeff(heatTransfertCoeff);
- myProblem.setHeatSource(phi);
-
- # constant vector
- VV_Constant = [623];
-
- #Initial field creation
- print("Building initial data" );
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"Neumann","Neumann");
-
- # the boundary conditions
- myProblem.setNeumannBoundaryCondition("Neumann");
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- # myProblem.setLinearSolver(GMRES,ILU,True);
-
- # name of result file
- fileName = "1DRodTemperature";
-
- # computation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.95;
- maxTime = 100000000;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
-
- # evolution
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DiffusionEquation_1DHeatedRod()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-
-def DiffusionEquation_1DHeatedRod():
- spaceDim = 1;
- # Prepare for the mesh
- xinf = 0 ;
- xsup=4.2;
- nx=10;
-
- print ("Building of a 1D mesh with ", nx ," cells")
-
- # set the limit field for each boundary
- Temperature=623;
- cp_ur=300
- rho_ur=10000
- lambda_ur=5
-
- FECalculation=True
- myProblem = cf.DiffusionEquation(spaceDim,FECalculation,rho_ur,cp_ur,lambda_ur);
- nVar = myProblem.getNumberOfVariables();
-
- #Set heat exchanges
- fluidTemp=573.;#fluid mean temperature
- heatTransfertCoeff=1000.;#fluid/solid exchange coefficient
- phi=1e5;#heat power ddensity
- myProblem.setFluidTemperature(fluidTemp);
- myProblem.setHeatTransfertCoeff(heatTransfertCoeff);
- myProblem.setHeatSource(phi);
-
- # constant vector
- VV_Constant = [623];
-
- #Initial field creation
- print("Building initial data" );
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"Neumann","Neumann");
-
- # the boundary conditions
- myProblem.setNeumannBoundaryCondition("Neumann");
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- # myProblem.setLinearSolver(GMRES,ILU,True);
-
- # name of result file
- fileName = "1DRodTemperature_FE";
-
- # computation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.95;
- maxTime = 100000000;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
-
- # evolution
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DiffusionEquation_1DHeatedRod()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def DriftModel_1DBoilingAssembly():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=4.2;
+ xinfcore=(xsup-xinf)/4
+ xsupcore=3*(xsup-xinf)/4
+ nx=50;
+ M=cm.Mesh(xinf,xsup,nx)
+
+ # set the limit field for each boundary
+
+ inletConc=0;
+ inletVelocityX=1;
+ inletTemperature=565;
+ outletPressure=155e5;
+
+ # physical parameters
+ heatPowerField=cm.Field("heatPowerField", cm.CELLS, M, 1);
+ nbCells=M.getNumberOfCells();
+
+ for i in range (nbCells):
+ x=M.getCell(i).x();
+
+ if (x> xinfcore) and (x< xsupcore):
+ heatPowerField[i]=1e8
+ else:
+ heatPowerField[i]=0
+ heatPowerField.writeVTK("heatPowerField",True)
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar;
+
+ # constant vector
+ VV_Constant[0] = inletConc;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX;
+ VV_Constant[3] = inletTemperature ;
+
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
+
+ # set the boundary conditions
+ myProblem.setInletBoundaryCondition("inlet",inletTemperature,inletConc,inletVelocityX)
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
+
+ # set physical parameters
+ myProblem.setHeatPowerField(heatPowerField);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setWellBalancedCorrection(True);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name of result file
+ fileName = "1DBoilingAssemblyUpwindWB";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 500;
+ precision = 1e-7;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveConservativeField(True);
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_1DBoilingAssembly()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+
+def DriftModel_1DBoilingChannel():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=4.2;
+ nx=50;
+
+ # set the limit field for each boundary
+
+ inletConc=0;
+ inletVelocityX=1;
+ inletTemperature=565;
+ outletPressure=155e5;
+
+ # physical parameters
+ heatPower=1e8;
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar;
+
+ # constant vector
+ VV_Constant[0] = inletConc;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX;
+ VV_Constant[3] = inletTemperature ;
+
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
+
+ # set the boundary conditions
+ myProblem.setInletBoundaryCondition("inlet",inletTemperature,inletConc,inletVelocityX)
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
+
+ # set physical parameters
+ myProblem.setHeatSource(heatPower);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
+ myProblem.setWellBalancedCorrection(True);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name of result file
+ fileName = "1DBoilingChannelUpwindWBImplicite";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 100;
+ maxTime = 500;
+ precision = 1e-7;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveAllFields(True);
+ myProblem.usePrimitiveVarsInNewton(True);
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_1DBoilingChannel()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+
+def DriftModel_1DChannelGravity():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=4.2;
+ nx=50;
+
+ # set the limit field for each boundary
+
+ inletConc=0;
+ inletVelocityX=1;
+ inletEnthalpy=1.3e6;
+ outletPressure=155e5;
+
+ # physical parameters
+ gravite=[-10];
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar;
+
+ # constant vector
+ VV_Constant[0] = inletConc;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX;
+ VV_Constant[3] = 578 ;
+
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
+
+ # set the boundary conditions
+ myProblem.setInletEnthalpyBoundaryCondition("inlet",inletEnthalpy,inletConc,inletVelocityX)
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
+
+ # set physical parameters
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
+ myProblem.setNonLinearFormulation(cf.VFRoe)
+
+ # name of result file
+ fileName = "1DChannelGravityUpwindImplicite";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 100;
+ maxTime = 500;
+ precision = 1e-7;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveAllFields(True);
+ myProblem.usePrimitiveVarsInNewton(True);
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_1DChannelGravity()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+
+def DriftModel_1DDepressurisation():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=4.2;
+ nx=50;
+
+ # set the boundary field for each boundary
+ initialConc=0;
+ initialVelocityX=0;
+ initialTemperature=565;
+ initialPressure=155e5
+ # set the boundary field for each boundary
+ wallVelocityX=0;
+ wallTemperature=565;
+ outletPressure=1e5;
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar;
+
+ # constant vector
+ VV_Constant[0] = initialConc;
+ VV_Constant[1] = initialPressure ;
+ VV_Constant[2] = initialVelocityX;
+ VV_Constant[3] = initialTemperature ;
+
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"wall","outlet");
+
+ # set the boundary conditions
+ myProblem.setWallBoundaryCondition("wall",wallTemperature,wallVelocityX)
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setEntropicCorrection(True);
+
+ # name of result file
+ fileName = "1DDepressurisation";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 1;
+ maxTime = 500;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision*1e7,20);
+ myProblem.saveConservativeField(True);
+ myProblem.saveAllFields(True);
+
+ # evolution
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_1DDepressurisation()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def DriftModel_1DPorosityJump():
+
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=4.2;
+ nx=100;
+ M=cm.Mesh(xinf,xsup,nx)
+ spaceDim = M.getSpaceDimension()
+
+ # set the limit field for each boundary
+ initialConc=0;
+ initialVelocityX=1;
+ initialTemperature=600;
+ initialPressure=155e5;
+
+ # physical parameters
+ porosityField=cm.Field("Porosity",cm.CELLS,M,1);
+ for i in xrange(M.getNumberOfCells()):
+ x=M.getCell(i).x();
+ if x > (xsup-xinf)/3. and x<(xsup-xinf)*2./3:
+ porosityField[i]=0.5;
+ else:
+ porosityField[i]=1;
+ pass
+ porosityField.writeVTK("PorosityField");
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar;
+
+ # constant vector
+ VV_Constant[0] = initialConc;
+ VV_Constant[1] = initialPressure ;
+ VV_Constant[2] = initialVelocityX;
+ VV_Constant[3] = initialTemperature ;
+
+
+ #Initial field creation
+ print("Building initial data " );
+ #myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"Inlet","Outlet");
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"Neumann","Neumann");
+
+ # set the boundary conditions
+ #myProblem.setInletBoundaryCondition("Inlet",initialTemperature,initialConc,initialVelocityX)
+ #myProblem.setOutletBoundaryCondition("Outlet", initialPressure,[xsup]);
+ myProblem.setNeumannBoundaryCondition("Neumann");
+
+ # set physical parameters
+ myProblem.setPorosityField(porosityField);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setWellBalancedCorrection(True);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name of result file
+ fileName = "1DPorosityJumpUpwindWB";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.95;
+ maxTime = 500;
+ precision = 1e-5;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveConservativeField(True);
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_1DPorosityJump()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def DriftModel_1DPressureLoss():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=4.2;
+ nx=50;
+ M=cm.Mesh(xinf,xsup,nx)
+
+ # set the limit field for each boundary
+
+ inletConc=0;
+ inletVelocityX=1;
+ inletTemperature=565;
+ outletPressure=155e5;
+
+ # physical parameters
+ pressureLossField=cm.Field("PressureLossCoeff", cm.FACES, M, 1);
+ nbFaces=M.getNumberOfFaces();
+
+ for i in range (nbFaces):
+ pressureLossField[i]=0
+ pressureLossField[nx/4]=50;
+ pressureLossField[nx/2]=100;
+ pressureLossField[3*nx/4]=150;
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar;
+
+ # constant vector
+ VV_Constant[0] = inletConc;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX;
+ VV_Constant[3] = inletTemperature ;
+
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
+
+ # set the boundary conditions
+ myProblem.setInletBoundaryCondition("inlet",inletTemperature,inletConc,inletVelocityX)
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
+
+ # set physical parameters
+ myProblem.setPressureLossField(pressureLossField);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setWellBalancedCorrection(True);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name of result file
+ fileName = "1DPressureLossUpwindWB";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.95;
+ maxTime = 500;
+ precision = 1e-5;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveConservativeField(True);
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_1DPressureLoss()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def DriftModel_1DRiemannProblem():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=4.2;
+ nx=50;
+ discontinuity=(xinf+xsup)/2
+ M=cm.Mesh(xinf,xsup,nx)
+ eps=1e-6
+ M.setGroupAtPlan(xsup,0,eps,"RightBoundary")
+ M.setGroupAtPlan(xinf,0,eps,"LeftBoundary")
+
+ # set the limit field for each boundary
+
+ inletConc_Left=0;
+ inletVelocity_Left=1;
+ inletTemperature_Left=565;
+ outletPressure_Left=155e5;
+
+ inletConc_Right=0;
+ inletVelocity_Right=1;
+ inletTemperature_Right=565;
+ outletPressure_Right=155.1e5;
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant_Left =cm.Vector(nVar)
+ VV_Constant_Right =cm.Vector(nVar)
+
+ # constant vectors
+ VV_Constant_Left[0] = inletConc_Left ;
+ VV_Constant_Left[1] = outletPressure_Left;
+ VV_Constant_Left[2] = inletVelocity_Left;
+ VV_Constant_Left[3] = inletTemperature_Left ;
+
+ VV_Constant_Right[0] = inletConc_Right ;
+ VV_Constant_Right[1] = outletPressure_Right;
+ VV_Constant_Right[2] = inletVelocity_Right;
+ VV_Constant_Right[3] = inletTemperature_Right ;
+
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldStepFunction(M,VV_Constant_Left,VV_Constant_Right,discontinuity)
+
+ # set the boundary conditions
+ myProblem.setNeumannBoundaryCondition("LeftBoundary")
+ myProblem.setNeumannBoundaryCondition("RightBoundary");
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+
+ # name of result file
+ fileName = "1DRiemannProblemUpwind";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.95;
+ maxTime = 500;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveConservativeField(True);
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_1DRiemannProblem()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def DriftModel_1DVidangeReservoir():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0. ;
+ xsup=1.0;
+ nx=50;
+ M=cm.Mesh(xinf,xsup,nx)
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xinf,0,eps,"outlet")
+ M.setGroupAtPlan(xsup,0,eps,"inlet")
+
+ # set the limit field for each boundary
+ inletConc=1;
+ inletTemperature=300;
+ outletPressure=1e5;
+
+ initialConcTop=1;
+ initialConcBottom=0.0001;
+ initialVelocityX=[0];
+ initialPressure=1e5;
+ initialTemperature=300
+
+ # physical constants
+ gravite=[-10];
+
+ myProblem = cf.DriftModel(cf.around1bar300K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_top =cm.Vector(nVar)
+ VV_bottom =cm.Vector(nVar)
+
+ # top and bottom vectors
+ VV_top[0] = initialConcTop ;
+ VV_top[1] = initialPressure ;
+ VV_top[2] = initialVelocityX[0];
+ VV_top[3] = initialTemperature
+
+ VV_bottom[0] = initialConcBottom ;
+ VV_bottom[1] = initialPressure ;
+ VV_bottom[2] = initialVelocityX[0];
+ VV_bottom[3] = initialTemperature
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldStepFunction( M, VV_bottom, VV_top, .8, 0);
+
+ # the boundary conditions
+ myProblem.setInletPressureBoundaryCondition("inlet", outletPressure, inletTemperature, inletConc,[xinf]);
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
+
+ # set physical parameters
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name file save
+ fileName = "1DVidangeReservoir";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = .95;
+ maxTime = 5.;
+ precision = 1e-5;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+
+if __name__ == """__main__""":
+ DriftModel_1DVidangeReservoir()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+
+def DriftModel_2BranchesBoilingChannels():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ M=cm.Mesh("../resources/BifurcatingFlow2BranchesEqualSections.med")
+ M.getFace(0).setGroupName("Inlet")#z=0
+ M.getFace(31).setGroupName("Outlet")#z=4.2
+
+ # set the initial field
+ initialConc=0;
+ initialPressure=155e5;
+ initialVelocityX=5;
+ initialTemperature=573;
+
+ # set the limit field for each boundary
+ inletConc=0;
+ inletVelocityX=5;
+ inletTemperature=573;
+ outletPressure=155e5
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar;
+
+ # constant vector
+ VV_Constant[0] = initialConc ;
+ VV_Constant[1] = initialPressure ;
+ VV_Constant[2] = initialVelocityX;
+ VV_Constant[3] = initialTemperature ;
+
+
+ #Initial field creation
+ print("Building initial data" );
+ myProblem.setInitialFieldConstant( M, VV_Constant);
+
+ # set the boundary conditions
+ myProblem.setInletBoundaryCondition("Inlet", inletTemperature, inletConc,inletVelocityX);
+ myProblem.setOutletBoundaryCondition("Outlet",outletPressure);
+
+ #set porosity, heat and gravity source
+ Sections=cm.Field("../resources/BifurcatingFlow2BranchesEqualSections", cm.CELLS,"Section area");
+ heatPowerField=cm.Field("../resources/BifurcatingFlow2BranchesEqualSections", cm.CELLS,"Heat power");
+ myProblem.setSectionField(Sections);
+ myProblem.setHeatPowerField(heatPowerField)
+ gravite=[-10]
+ myProblem.setGravity(gravite)
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setWellBalancedCorrection(True)
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name of result file
+ fileName = "2BranchesBoilingChannels";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 500;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveConservativeField(True);
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_2BranchesBoilingChannels()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+
+import CoreFlows as cf
+import cdmath as cm
+
+
+def DriftModel_2DBoilingChannelBarrier():
+
+ spaceDim = 2;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=2.0;
+ yinf=0.0;
+ ysup=4.0;
+ nx=20;
+ ny=40;
+ cloison=(xinf+xsup)/2
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"wall")
+ M.setGroupAtPlan(xinf,0,eps,"wall")
+ M.setGroupAtPlan(ysup,1,eps,"outlet")
+ M.setGroupAtPlan(yinf,1,eps,"inlet")
+ dy=(ysup-yinf)/ny
+ ncloison=ny/2
+ i=0
+ while i<= ncloison+1:
+ M.setGroupAtFaceByCoords(cloison,((ysup-yinf)/4)+(i+0.5)*dy,0,eps,"wall")
+ i=i+1
+
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=573;
+ inletConc=0;
+ inletVelocityX=0;
+ inletVelocityY=1;
+ inletTemperature=563;
+ outletPressure=155e5;
+
+ # physical constants
+ gravite = [0] * spaceDim
+
+ gravite[0]=0;
+ gravite[1]=-10;
+
+ heatPower=1e8;
+ heatPower_nul=0;
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+ heatPowerField=cm.Field("heatPowerField", cm.CELLS, M, 1);
+
+ nbCells=M.getNumberOfCells();
+
+ for i in range (nbCells):
+ x=M.getCell(i).x();
+ y=M.getCell(i).y();
+ if (y> (ysup-yinf)/4) and (y< (ysup-yinf)*3/4) and (x<cloison):
+ heatPowerField[i]=heatPower
+ else:
+ heatPowerField[i]=heatPower_nul
+ heatPowerField.writeVTK("heatPowerField",True)
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar
+
+ # constant vector
+ VV_Constant[0] = inletConc ;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX;
+ VV_Constant[3] = inletVelocityY;
+ VV_Constant[4] = inletTemperature ;
+
+ #Initial field creation
+ print("Building initial data" );
+ myProblem.setInitialFieldConstant(M,VV_Constant)
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
+ myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConc, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ # set physical parameters
+ myProblem.setHeatPowerField(heatPowerField)
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setWellBalancedCorrection(True);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name file save
+ fileName = "2DBoilingChannelBarrier";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3;
+ freqSave = 1;
+ cfl = .5;
+ maxTime = 5000;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveVelocity();
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_2DBoilingChannelBarrier()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+
+import CoreFlows as cf
+
+def DriftModel_2DInclinedBoilingChannel():
+ spaceDim = 2;
+
+ # Prepare for the mesh
+ xinf = 0 ;
+ xsup=1.0;
+ yinf=0.0;
+ ysup=1.0;
+ nx=20;
+ ny=20;
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=563;
+ inletConcentration=0;
+ inletVelocityX=0;
+ inletVelocityY=1;
+ inletTemperature=563;
+ outletPressure=155e5;
+
+ # physical constants
+ gravite = [0] * spaceDim
+
+ gravite[1]=-7;
+ gravite[0]=7;
+
+ heatPower=1e8;
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar
+
+ # constant vector
+ VV_Constant[0] = inletConcentration;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX;
+ VV_Constant[3] = inletVelocityY;
+ VV_Constant[4] = inletTemperature ;
+
+ #Initial field creation
+ print("Building mesh and initial data " );
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
+ xinf,xsup,nx,"wall","wall",
+ yinf,ysup,ny,"inlet","outlet",
+ 0.0,0.0, 0, "", "")
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
+ myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ # set physical parameters
+ myProblem.setHeatSource(heatPower);
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setWellBalancedCorrection(True);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name of result file
+ fileName = "2DInclinedBoilingChannel";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 5;
+ precision = 1e-4;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_2DInclinedBoilingChannel()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+
+import CoreFlows as cf
+import cdmath as cm
+
+
+def DriftModel_2DInclinedBoilingChannelBarrier():
+
+ spaceDim = 2;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=2.0;
+ yinf=0.0;
+ ysup=4.0;
+ nx=20;
+ ny=40;
+ cloison=(xinf+xsup)/2
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"wall")
+ M.setGroupAtPlan(xinf,0,eps,"wall")
+ M.setGroupAtPlan(ysup,1,eps,"outlet")
+ M.setGroupAtPlan(yinf,1,eps,"inlet")
+ dy=(ysup-yinf)/ny
+ ncloison=ny/2
+ i=0
+ while i<= ncloison+1:
+ M.setGroupAtFaceByCoords(cloison,((ysup-yinf)/4)+(i+0.5)*dy,0,eps,"wall")
+ i=i+1
+
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=573;
+ inletConc=0;
+ inletVelocityX=0;
+ inletVelocityY=1;
+ inletTemperature=563;
+ outletPressure=155e5;
+
+ # source terms
+ gravite = [0] * spaceDim
+
+ gravite[0]=7;
+ gravite[1]=-7;
+
+ heatPower=1e8;
+ heatPower_nul=0;
+ heatPowerField=cm.Field("heatPowerField", cm.CELLS, M, 1);
+
+ nbCells=M.getNumberOfCells();
+
+ for i in range (nbCells):
+ x=M.getCell(i).x();
+ y=M.getCell(i).y();
+ if (y> (ysup-yinf)/4) and (y< (ysup-yinf)*3/4) and (x<cloison):
+ heatPowerField[i]=heatPower
+ else:
+ heatPowerField[i]=heatPower_nul
+ heatPowerField.writeVTK("heatPowerField",True)
+
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar
+
+ # constant vector
+ VV_Constant[0] = inletConc ;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX;
+ VV_Constant[3] = inletVelocityY;
+ VV_Constant[4] = inletTemperature ;
+
+ #Initial field creation
+ print("Building initial data" );
+ myProblem.setInitialFieldConstant(M,VV_Constant)
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
+ myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConc, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ # set physical parameters
+ myProblem.setHeatPowerField(heatPowerField)
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setWellBalancedCorrection(True);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name file save
+ fileName = "2DBInclinedoilingChannelBarrier";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = .5;
+ maxTime = 5000;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveVelocity();
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_2DInclinedBoilingChannelBarrier()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+
+def DriftModel_2DInclinedBoilingChannel():
+ spaceDim = 2;
+
+ # Prepare for the mesh
+ xinf = 0 ;
+ xsup=1.0;
+ yinf=0.0;
+ ysup=4.0;
+ nx=10;
+ ny=40;
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=563;
+ inletConcentration=0;
+ inletVelocityX=0;
+ inletVelocityY=1;
+ inletTemperature=563;
+ outletPressure=155e5;
+
+ # physical constants
+ gravite = [0] * spaceDim
+
+ gravite[1]=-8.5;
+ gravite[0]=5;
+
+ heatPower=0e8;
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar
+
+ # constant vector
+ VV_Constant[0] = inletConcentration;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX;
+ VV_Constant[3] = inletVelocityY;
+ VV_Constant[4] = inletTemperature ;
+
+ #Initial field creation
+ print("Building mesh and initial data " );
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
+ xinf,xsup,nx,"wall","wall",
+ yinf,ysup,ny,"inlet","outlet",
+ 0.0,0.0, 0, "", "")
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
+ myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ # set physical parameters
+ myProblem.setHeatSource(heatPower);
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
+ myProblem.setWellBalancedCorrection(True);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name of result file
+ fileName = "2DInclinedChannelGravity";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 500;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.usePrimitiveVarsInNewton(True)
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_2DInclinedBoilingChannel()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def DriftModel_2DInclinedBoilingChannel():
+ spaceDim = 2;
+
+ # Prepare for the mesh
+ xinf = 0 ;
+ xsup=.6;
+ yinf=0.0;
+ ysup=2.0;
+ nx=3;
+ ny=100;
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
+
+ #Set the barriers
+ xcloison1=xinf+(xsup-xinf)/3
+ xcloison2=xinf+2*(xsup-xinf)/3
+ barrierField=cm.Field("Barrier Field", cm.FACES, M, 1);
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"wall")
+ M.setGroupAtPlan(xinf,0,eps,"wall")
+ M.setGroupAtPlan(ysup,1,eps,"outlet")
+ M.setGroupAtPlan(yinf,1,eps,"inlet")
+ dy=(ysup-yinf)/ny
+ ncloison=3*ny/4
+ i=0
+ while i<= ncloison+1:
+ M.setGroupAtFaceByCoords(xcloison1,yinf+((ysup-yinf)/4)+(i+0.5)*dy,0,eps,"wall")
+ M.setGroupAtFaceByCoords(xcloison2,yinf+((ysup-yinf)/4)+(i+0.5)*dy,0,eps,"wall")
+ i=i+1
+
+ nbFaces=M.getNumberOfFaces();
+ for i in range (nbFaces):
+ x=M.getFace(i).x();
+ y=M.getFace(i).y();
+ if ((y> yinf+(ysup-yinf)/4) and (abs(x-xcloison1)< eps or abs(x-xcloison2)< eps)) or abs(x-xinf)< eps or abs(x-xsup)< eps :
+ barrierField[i]=1
+ else:
+ barrierField[i]=0
+ barrierField.writeVTK("barrierField",True)
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=563;
+ inletConcentration=0;
+ inletVelocityX=0;
+ inletVelocityY=1;
+ inletTemperature=563;
+ outletPressure=155e5;
+
+ # physical constants
+ gravite = [0] * spaceDim
+
+ gravite[1]=-8.5;
+ gravite[0]=5;
+
+ heatPower=0e8;
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar
+
+ # constant vector
+ VV_Constant[0] = inletConcentration;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX;
+ VV_Constant[3] = inletVelocityY;
+ VV_Constant[4] = inletTemperature ;
+
+ #Initial field creation
+ print("Building mesh and initial data " );
+ myProblem.setInitialFieldConstant(M,VV_Constant)
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
+ myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ # set physical parameters
+ myProblem.setHeatSource(heatPower);
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
+ myProblem.setWellBalancedCorrection(True);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name of result file
+ fileName = "2DInclinedChannelVFFCStaggeredWB3x100CFL100";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1000;
+ cfl = 100;
+ maxTime = 500;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.usePrimitiveVarsInNewton(True)
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_2DInclinedBoilingChannel()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+
+def DriftModel_2DInclinedBoilingChannel():
+ spaceDim = 2;
+
+ # Prepare for the mesh
+ print( "Loading unstructured mesh " );
+ inputfile="../resources/CanalTrianglesStructures.med";
+ xinf = 0 ;
+ xsup=1.0;
+ yinf=0.0;
+ ysup=4.0;
+ nx=10;
+ ny=40;
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=563;
+ inletConcentration=0;
+ inletVelocityX=0;
+ inletVelocityY=1;
+ inletTemperature=563;
+ outletPressure=155e5;
+
+ # physical constants
+ gravite = [0] * spaceDim
+
+ gravite[1]=-8.5;
+ gravite[0]=5;
+
+ heatPower=0e8;
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar
+
+ # constant vector
+ VV_Constant[0] = inletConcentration;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX;
+ VV_Constant[3] = inletVelocityY;
+ VV_Constant[4] = inletTemperature ;
+
+ #Initial field creation
+ print("Building mesh and initial data " );
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
+ xinf,xsup,nx,"wall","wall",
+ yinf,ysup,ny,"inlet","outlet",
+ 0.0,0.0, 0, "", "")
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
+ myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ # set physical parameters
+ myProblem.setHeatSource(heatPower);
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
+ myProblem.setWellBalancedCorrection(True);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name of result file
+ fileName = "2DInclinedChannelGravityTriangles";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 500;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.usePrimitiveVarsInNewton(True)
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_2DInclinedBoilingChannel()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+
+import CoreFlows as cf
+import cdmath as cm
+import math
+
+def DriftModel_2DPorosityJump():
+ spaceDim = 2;
+
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=1.5;
+ yinf=0.0;
+ ysup=0.8;
+ nx=20;
+ ny=20;
+ discontinuity=(xinf+xsup)/2
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Outlet")
+ M.setGroupAtPlan(xinf,0,eps,"Inlet")
+ M.setGroupAtPlan(ysup,1,eps,"Wall")
+ M.setGroupAtPlan(yinf,1,eps,"Wall")
+ dx=(xsup-xinf)/nx
+ ndis=(discontinuity-xinf)/dx
+
+
+ # set the limit field for each boundary
+ inletConc=0;
+ inletVelocityX=1. ;
+ inletVelocityY=0 ;
+ inletTemperature=563 ;
+ outletPressure=155e5 ;
+
+
+ # physical parameters
+ porosityField=cm.Field("Porosity",cm.CELLS,M,1);
+ for i in xrange(M.getNumberOfCells()):
+ x=M.getCell(i).x();
+ y=M.getCell(i).y();
+ if x > (xsup-xinf)/3. and x<(xsup-xinf)*2./3 and y> (ysup-yinf)/4. and y<(ysup-yinf)*3./4:
+ porosityField[i]=0.5;
+ else:
+ porosityField[i]=1;
+ pass
+ porosityField.writeVTK("PorosityField");
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =cm.Vector(nVar)
+
+ # constant vectorsetOutletBoundaryCondition
+ VV_Constant[0] = inletConc;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX;
+ VV_Constant[3] = inletVelocityY;
+ VV_Constant[4] = inletTemperature ;
+
+ # set physical parameters
+ myProblem.setPorosityField(porosityField);
+
+ print("Building initial data");
+ myProblem.setInitialFieldConstant(M,VV_Constant)
+
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("Outlet", outletPressure);
+ myProblem.setInletBoundaryCondition("Inlet", inletTemperature,inletConc, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("Wall", inletTemperature, 0,0);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setWellBalancedCorrection(True);
+
+ # name file save
+ fileName = "2DPorosityJump";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 5000;
+ precision = 1e-4;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(1e10,20);
+ myProblem.saveVelocity();
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_2DPorosityJump()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+
+import CoreFlows as cf
+import cdmath as cm
+import math
+
+def DriftModel_2DPressureLoss():
+ spaceDim = 2;
+
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=0.42;
+ yinf=0.0;
+ ysup=4.2;
+ nx=2;
+ ny=100;
+ discontinuity=(xinf+xsup)/2
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"RightWall")
+ M.setGroupAtPlan(xinf,0,eps,"LeftWall")
+ M.setGroupAtPlan(ysup,1,eps,"outlet")
+ dx=(xsup-xinf)/nx
+ ndis=(discontinuity-xinf)/dx
+ print("ndis=",math.floor(ndis) );
+ i=0
+# while i<= ndis:
+ M.setGroupAtFaceByCoords(xinf+(i+0.5)*dx,yinf,0,eps,"inlet_1")
+ i=1
+# while i<= nx:
+ M.setGroupAtFaceByCoords(xinf+(i+0.5)*dx,yinf,0,eps,"inlet_2")
+
+
+
+ # set the limit field for each boundary
+ inletConc=0;
+ inletVelocityX1=0. ;
+ inletVelocityY1=2.7 ;
+ inletVelocityX2=0 ;
+ inletVelocityY2=1.5 ;
+ inletTemperature=563 ;
+ outletPressure=155e5 ;
+
+
+ # physical parameters
+ pressureLossField=cm.Field("PressureLossCoeff", cm.FACES, M, 1);
+ nbFaces=M.getNumberOfFaces();
+
+ for i in range (nbFaces):
+ if abs(M.getFace(i).y() - 1.0500)<eps :
+ pressureLossField[i]=50
+ print("Premiere perte de charge ok")
+ elif abs(M.getFace(i).y() - 1.680)<eps :
+ pressureLossField[i]=50
+ print("Deuxieme perte de charge ok")
+ elif M.getFace(i).y() == 2.7300:
+ pressureLossField[i]=50
+ print("Troisieme perte de charge ok")
+ else:
+ pressureLossField[i]=0;
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant_Left =cm.Vector(nVar)
+ VV_Constant_Right =cm.Vector(nVar)
+
+ # constant vectorsetOutletBoundaryCondition
+ VV_Constant_Left[0] = inletConc;
+ VV_Constant_Left[1] = outletPressure ;
+ VV_Constant_Left[2] = inletVelocityX1;
+ VV_Constant_Left[3] = inletVelocityY1;
+ VV_Constant_Left[4] = inletTemperature ;
+
+ VV_Constant_Right[0] = inletConc;
+ VV_Constant_Right[1] = outletPressure ;
+ VV_Constant_Right[2] = inletVelocityX2;
+ VV_Constant_Right[3] = inletVelocityY2;
+ VV_Constant_Right[4] = inletTemperature ;
+
+
+ # set physical parameters
+ myProblem.setPressureLossField(pressureLossField);
+
+ print("Building initial data" );
+ myProblem.setInitialFieldStepFunction(M,VV_Constant_Left,VV_Constant_Right,discontinuity)
+
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure);
+ myProblem.setInletBoundaryCondition("inlet_1", inletTemperature,inletConc, inletVelocityX1, inletVelocityY1);
+ myProblem.setInletBoundaryCondition("inlet_2", inletTemperature,inletConc, inletVelocityX2, inletVelocityY2);
+ myProblem.setWallBoundaryCondition("LeftWall", inletTemperature, 0,0);
+ myProblem.setWallBoundaryCondition("RightWall", inletTemperature, 0,0);
+
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setWellBalancedCorrection(True);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name file save
+ fileName = "2DPressureLoss";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 5000;
+ precision = 1e-4;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(1e10,20);
+ myProblem.saveVelocity();
+
+ # evolution
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_2DPressureLoss()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def DriftModel_2DVidangeReservoir():
+
+ spaceDim = 2;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=1.0;
+ yinf=0.0;
+ ysup=1.0;
+ nx=50;
+ ny=50;
+ diametreSortie=(ysup-yinf)/10.#10 percent of the height
+ nsortie=ny*diametreSortie/(ysup-yinf)
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xinf,0,eps,"wall")
+ M.setGroupAtPlan(ysup,1,eps,"inlet")
+ M.setGroupAtPlan(yinf,1,eps,"wall")
+ dy=(ysup-yinf)/ny
+ i=0
+ while i < nsortie:
+ M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"outlet")
+ i=i+1
+ while i < ny:
+ M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"wall")
+ i=i+1
+
+
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=300;
+ inletConc=1;
+ inletTemperature=300;
+ outletPressure=1e5;
+
+ # set the limit field for each boundary
+ initialConcTop=1.;
+ initialConcBottom=0.0001;
+ initialVelocityX=0;
+ initialVelocityY=0;
+ initialTemperature=300;
+ initialPressure=1e5;
+
+ # physical constants
+ gravite = [0] * spaceDim
+
+ gravite[0]=0;
+ gravite[1]=-10;
+
+ myProblem = cf.DriftModel(cf.around1bar300K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+ # Prepare for the initial condition
+ VV_top =cm.Vector(nVar)
+ VV_bottom =cm.Vector(nVar)
+
+ # constant vector
+ VV_top[0] = initialConcTop ;
+ VV_top[1] = initialPressure ;
+ VV_top[2] = initialVelocityX;
+ VV_top[3] = initialVelocityY;
+ VV_top[4] = initialTemperature ;
+
+ VV_bottom[0] = initialConcBottom ;
+ VV_bottom[1] = initialPressure ;
+ VV_bottom[2] = initialVelocityX;
+ VV_bottom[3] = initialVelocityY;
+ VV_bottom[4] = initialTemperature ;
+
+ #Initial field creation
+ print("Building initial data" );
+ #myProblem.setInitialFieldStepFunction( M, VV_bottom, VV_top, .8, 1);
+ myProblem.setInitialFieldConstant( M, VV_bottom)
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
+ myProblem.setInletPressureBoundaryCondition("inlet", outletPressure, inletTemperature, inletConc,[xsup,yinf]);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ # set physical parameters
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name file save
+ fileName = "2DVidangeReservoir";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = .5;
+ maxTime = 5000;
+ precision = 1e-5;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveVelocity();
+
+ # evolution
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_2DVidangeReservoir()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def DriftModel_2DVidangeReservoirUnstructured():
+
+ print( "Loading unstructured mesh " );
+ inputfile="../resources/BoxWithMeshWithTriangularCells.med";
+
+ spaceDim = 2;
+ # Prepare for the mesh
+ xinf = 0 ;
+ xsup=1.0;
+ yinf=0.0;
+ ysup=1.0;
+ ny=33;
+ diametreSortie=(ysup-yinf)/10.#1à percent of the height
+ nsortie=ny*diametreSortie/(ysup-yinf)
+ M=cm.Mesh(inputfile);
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xinf,0,eps,"wall")
+ M.setGroupAtPlan(ysup,1,eps,"inlet")
+ M.setGroupAtPlan(yinf,1,eps,"wall")
+ dy=(ysup-yinf)/ny
+ i=0
+ while i < nsortie:
+ M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"outlet")
+ i=i+1
+ while i < ny:
+ M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"wall")
+ i=i+1
+
+ #print M.getNamesOfGroups()
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=300;
+ inletConc=1;
+ inletVelocityX=0;
+ inletVelocityY=1;
+ inletTemperature=300;
+ outletPressure=1e5;
+
+ # set the limit field for each boundary
+ initialConc=0.0001;
+ initialVelocityX=0;
+ initialVelocityY=0;
+ initialTemperature=300;
+ initialPressure=1e5;
+
+ # physical constants
+ gravite = [0] * spaceDim
+
+ gravite[0]=0;
+ gravite[1]=-10;
+
+ myProblem = cf.DriftModel(cf.around1bar300K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar
+
+ # constant vector
+ VV_Constant[0] = initialConc ;
+ VV_Constant[1] = initialPressure ;
+ VV_Constant[2] = initialVelocityX;
+ VV_Constant[3] = initialVelocityY;
+ VV_Constant[4] = initialTemperature ;
+
+ #Initial field creation
+ print("Building initial data" ); #import cdmath
+ myProblem.setInitialFieldConstant(M,VV_Constant)
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
+ myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConc, inletVelocityX, inletVelocityY);
+ #myProblem.setNeumannBoundaryCondition("inlet");
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ # set physical parameters
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name file save
+ fileName = "2DVidangeReservoirUntructureUpwind";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = .5;
+ maxTime = 5000;
+ precision = 1e-5;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveVelocity();
+
+ # evolution
+ myProblem.initialize();
+ print("Running "+ fileName );
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_2DVidangeReservoirUnstructured()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+
+import CoreFlows as cf
+import cdmath as cm
+
+
+def DriftModel_3DBoilingChannelBarrier():
+
+ spaceDim = 3;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=2.0;
+ yinf=0.0;
+ ysup=2.0;
+ zinf=0.0;
+ zsup=4.0;
+ nx=10;
+ ny=nx;
+ nz=20;
+ xcloison=(xinf+xsup)/2
+ ycloison=(yinf+ysup)/2
+ zcloisonmin=1
+ zcloisonmax=3
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz)
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"wall")
+ M.setGroupAtPlan(xinf,0,eps,"wall")
+ M.setGroupAtPlan(ysup,1,eps,"wall")
+ M.setGroupAtPlan(yinf,1,eps,"wall")
+ M.setGroupAtPlan(zsup,2,eps,"outlet")
+ M.setGroupAtPlan(zinf,2,eps,"inlet")
+ dx=(xsup-xinf)/nx
+ dy=(ysup-yinf)/ny
+ dz=(zsup-zinf)/nz
+ ncloison=nz*(zcloisonmax-zcloisonmin)/(zsup-zinf)
+ i=0
+ j=0
+ while i< ncloison:
+ while j< ny:
+ M.setGroupAtFaceByCoords(xcloison,(j+0.5)*dy,zcloisonmin+(i+0.5)*dz,eps,"wall")
+ M.setGroupAtFaceByCoords((j+0.5)*dx,ycloison,zcloisonmin+(i+0.5)*dz,eps,"wall")
+ j=j+1
+ i=i+1
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallVelocityZ=0;
+ wallTemperature=573;
+ inletConc=0;
+ inletVelocityX=0;
+ inletVelocityY=0;
+ inletVelocityZ=1;
+ inletTemperature=563;
+ outletPressure=155e5;
+
+ # physical constants
+ gravite = [0] * spaceDim
+
+ gravite[0]=0;
+ gravite[1]=0;
+ gravite[2]=-10;
+
+ heatPower1=0;
+ heatPower2=0.25e8;
+ heatPower3=0.5e8;
+ heatPower4=1e8;
+
+ myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+ heatPowerField=cm.Field("heatPowerField", cm.CELLS, M, 1);
+
+ nbCells=M.getNumberOfCells();
+
+ for i in range (nbCells):
+ x=M.getCell(i).x();
+ y=M.getCell(i).y();
+ z=M.getCell(i).z();
+ if (z> zcloisonmin) and (z< zcloisonmax) :
+ if (y<ycloison) and (x<xcloison):
+ heatPowerField[i]=heatPower1
+ if (y<ycloison) and (x>xcloison):
+ heatPowerField[i]=heatPower2
+ if (y>ycloison) and (x<xcloison):
+ heatPowerField[i]=heatPower3
+ if (y>ycloison) and (x>xcloison):
+ heatPowerField[i]=heatPower4
+ else:
+ heatPowerField[i]=0
+
+ heatPowerField.writeVTK("heatPowerField",True)
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar
+
+ # constant vector
+ VV_Constant[0] = inletConc ;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX;
+ VV_Constant[3] = inletVelocityY;
+ VV_Constant[4] = inletVelocityZ;
+ VV_Constant[5] = inletTemperature ;
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldConstant(M,VV_Constant)
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup,zsup]);
+ myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConc, inletVelocityX, inletVelocityY, inletVelocityZ);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY,wallVelocityZ);
+
+ # set physical parameters
+ myProblem.setHeatPowerField(heatPowerField)
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
+ myProblem.setWellBalancedCorrection(True);
+
+ # name file save
+ fileName = "3DBoilingChannelBarrier";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3;
+ freqSave = 100;
+ cfl = .3;
+ maxTime = 5000;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveVelocity();
+
+ # evolution
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ DriftModel_3DBoilingChannelBarrier()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def DriftModel_1DBoilingAssembly():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=4.2;
- xinfcore=(xsup-xinf)/4
- xsupcore=3*(xsup-xinf)/4
- nx=50;
- M=cm.Mesh(xinf,xsup,nx)
-
- # set the limit field for each boundary
-
- inletConc=0;
- inletVelocityX=1;
- inletTemperature=565;
- outletPressure=155e5;
-
- # physical parameters
- heatPowerField=cm.Field("heatPowerField", cm.CELLS, M, 1);
- nbCells=M.getNumberOfCells();
-
- for i in range (nbCells):
- x=M.getCell(i).x();
-
- if (x> xinfcore) and (x< xsupcore):
- heatPowerField[i]=1e8
- else:
- heatPowerField[i]=0
- heatPowerField.writeVTK("heatPowerField",True)
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar;
-
- # constant vector
- VV_Constant[0] = inletConc;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX;
- VV_Constant[3] = inletTemperature ;
-
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
-
- # set the boundary conditions
- myProblem.setInletBoundaryCondition("inlet",inletTemperature,inletConc,inletVelocityX)
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
-
- # set physical parameters
- myProblem.setHeatPowerField(heatPowerField);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setWellBalancedCorrection(True);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name of result file
- fileName = "1DBoilingAssemblyUpwindWB";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.5;
- maxTime = 500;
- precision = 1e-7;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveConservativeField(True);
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_1DBoilingAssembly()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-
-def DriftModel_1DBoilingChannel():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=4.2;
- nx=50;
-
- # set the limit field for each boundary
-
- inletConc=0;
- inletVelocityX=1;
- inletTemperature=565;
- outletPressure=155e5;
-
- # physical parameters
- heatPower=1e8;
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar;
-
- # constant vector
- VV_Constant[0] = inletConc;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX;
- VV_Constant[3] = inletTemperature ;
-
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
-
- # set the boundary conditions
- myProblem.setInletBoundaryCondition("inlet",inletTemperature,inletConc,inletVelocityX)
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
-
- # set physical parameters
- myProblem.setHeatSource(heatPower);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
- myProblem.setWellBalancedCorrection(True);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name of result file
- fileName = "1DBoilingChannelUpwindWBImplicite";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 100;
- maxTime = 500;
- precision = 1e-7;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.saveAllFields(True);
- myProblem.usePrimitiveVarsInNewton(True);
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_1DBoilingChannel()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-
-def DriftModel_1DChannelGravity():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=4.2;
- nx=50;
-
- # set the limit field for each boundary
-
- inletConc=0;
- inletVelocityX=1;
- inletEnthalpy=1.3e6;
- outletPressure=155e5;
-
- # physical parameters
- gravite=[-10];
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar;
-
- # constant vector
- VV_Constant[0] = inletConc;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX;
- VV_Constant[3] = 578 ;
-
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
-
- # set the boundary conditions
- myProblem.setInletEnthalpyBoundaryCondition("inlet",inletEnthalpy,inletConc,inletVelocityX)
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
-
- # set physical parameters
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
- myProblem.setNonLinearFormulation(cf.VFRoe)
-
- # name of result file
- fileName = "1DChannelGravityUpwindImplicite";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 100;
- maxTime = 500;
- precision = 1e-7;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.saveAllFields(True);
- myProblem.usePrimitiveVarsInNewton(True);
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_1DChannelGravity()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-
-def DriftModel_1DDepressurisation():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=4.2;
- nx=50;
-
- # set the boundary field for each boundary
- initialConc=0;
- initialVelocityX=0;
- initialTemperature=565;
- initialPressure=155e5
- # set the boundary field for each boundary
- wallVelocityX=0;
- wallTemperature=565;
- outletPressure=1e5;
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar;
-
- # constant vector
- VV_Constant[0] = initialConc;
- VV_Constant[1] = initialPressure ;
- VV_Constant[2] = initialVelocityX;
- VV_Constant[3] = initialTemperature ;
-
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"wall","outlet");
-
- # set the boundary conditions
- myProblem.setWallBoundaryCondition("wall",wallTemperature,wallVelocityX)
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setEntropicCorrection(True);
-
- # name of result file
- fileName = "1DDepressurisation";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 1;
- maxTime = 500;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision*1e7,20);
- myProblem.saveConservativeField(True);
- myProblem.saveAllFields(True);
-
- # evolution
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_1DDepressurisation()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def DriftModel_1DPorosityJump():
-
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=4.2;
- nx=100;
- M=cm.Mesh(xinf,xsup,nx)
- spaceDim = M.getSpaceDimension()
-
- # set the limit field for each boundary
- initialConc=0;
- initialVelocityX=1;
- initialTemperature=600;
- initialPressure=155e5;
-
- # physical parameters
- porosityField=cm.Field("Porosity",cm.CELLS,M,1);
- for i in xrange(M.getNumberOfCells()):
- x=M.getCell(i).x();
- if x > (xsup-xinf)/3. and x<(xsup-xinf)*2./3:
- porosityField[i]=0.5;
- else:
- porosityField[i]=1;
- pass
- porosityField.writeVTK("PorosityField");
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar;
-
- # constant vector
- VV_Constant[0] = initialConc;
- VV_Constant[1] = initialPressure ;
- VV_Constant[2] = initialVelocityX;
- VV_Constant[3] = initialTemperature ;
-
-
- #Initial field creation
- print("Building initial data " );
- #myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"Inlet","Outlet");
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"Neumann","Neumann");
-
- # set the boundary conditions
- #myProblem.setInletBoundaryCondition("Inlet",initialTemperature,initialConc,initialVelocityX)
- #myProblem.setOutletBoundaryCondition("Outlet", initialPressure,[xsup]);
- myProblem.setNeumannBoundaryCondition("Neumann");
-
- # set physical parameters
- myProblem.setPorosityField(porosityField);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setWellBalancedCorrection(True);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name of result file
- fileName = "1DPorosityJumpUpwindWB";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.95;
- maxTime = 500;
- precision = 1e-5;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveConservativeField(True);
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_1DPorosityJump()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def DriftModel_1DPressureLoss():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=4.2;
- nx=50;
- M=cm.Mesh(xinf,xsup,nx)
-
- # set the limit field for each boundary
-
- inletConc=0;
- inletVelocityX=1;
- inletTemperature=565;
- outletPressure=155e5;
-
- # physical parameters
- pressureLossField=cm.Field("PressureLossCoeff", cm.FACES, M, 1);
- nbFaces=M.getNumberOfFaces();
-
- for i in range (nbFaces):
- pressureLossField[i]=0
- pressureLossField[nx/4]=50;
- pressureLossField[nx/2]=100;
- pressureLossField[3*nx/4]=150;
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar;
-
- # constant vector
- VV_Constant[0] = inletConc;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX;
- VV_Constant[3] = inletTemperature ;
-
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
-
- # set the boundary conditions
- myProblem.setInletBoundaryCondition("inlet",inletTemperature,inletConc,inletVelocityX)
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
-
- # set physical parameters
- myProblem.setPressureLossField(pressureLossField);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setWellBalancedCorrection(True);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name of result file
- fileName = "1DPressureLossUpwindWB";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.95;
- maxTime = 500;
- precision = 1e-5;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveConservativeField(True);
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_1DPressureLoss()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def DriftModel_1DRiemannProblem():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=4.2;
- nx=50;
- discontinuity=(xinf+xsup)/2
- M=cm.Mesh(xinf,xsup,nx)
- eps=1e-6
- M.setGroupAtPlan(xsup,0,eps,"RightBoundary")
- M.setGroupAtPlan(xinf,0,eps,"LeftBoundary")
-
- # set the limit field for each boundary
-
- inletConc_Left=0;
- inletVelocity_Left=1;
- inletTemperature_Left=565;
- outletPressure_Left=155e5;
-
- inletConc_Right=0;
- inletVelocity_Right=1;
- inletTemperature_Right=565;
- outletPressure_Right=155.1e5;
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant_Left =cm.Vector(nVar)
- VV_Constant_Right =cm.Vector(nVar)
-
- # constant vectors
- VV_Constant_Left[0] = inletConc_Left ;
- VV_Constant_Left[1] = outletPressure_Left;
- VV_Constant_Left[2] = inletVelocity_Left;
- VV_Constant_Left[3] = inletTemperature_Left ;
-
- VV_Constant_Right[0] = inletConc_Right ;
- VV_Constant_Right[1] = outletPressure_Right;
- VV_Constant_Right[2] = inletVelocity_Right;
- VV_Constant_Right[3] = inletTemperature_Right ;
-
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldStepFunction(M,VV_Constant_Left,VV_Constant_Right,discontinuity)
-
- # set the boundary conditions
- myProblem.setNeumannBoundaryCondition("LeftBoundary")
- myProblem.setNeumannBoundaryCondition("RightBoundary");
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
-
- # name of result file
- fileName = "1DRiemannProblemUpwind";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.95;
- maxTime = 500;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveConservativeField(True);
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_1DRiemannProblem()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def DriftModel_1DVidangeReservoir():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0. ;
- xsup=1.0;
- nx=50;
- M=cm.Mesh(xinf,xsup,nx)
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xinf,0,eps,"outlet")
- M.setGroupAtPlan(xsup,0,eps,"inlet")
-
- # set the limit field for each boundary
- inletConc=1;
- inletTemperature=300;
- outletPressure=1e5;
-
- initialConcTop=1;
- initialConcBottom=0.0001;
- initialVelocityX=[0];
- initialPressure=1e5;
- initialTemperature=300
-
- # physical constants
- gravite=[-10];
-
- myProblem = cf.DriftModel(cf.around1bar300K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_top =cm.Vector(nVar)
- VV_bottom =cm.Vector(nVar)
-
- # top and bottom vectors
- VV_top[0] = initialConcTop ;
- VV_top[1] = initialPressure ;
- VV_top[2] = initialVelocityX[0];
- VV_top[3] = initialTemperature
-
- VV_bottom[0] = initialConcBottom ;
- VV_bottom[1] = initialPressure ;
- VV_bottom[2] = initialVelocityX[0];
- VV_bottom[3] = initialTemperature
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldStepFunction( M, VV_bottom, VV_top, .8, 0);
-
- # the boundary conditions
- myProblem.setInletPressureBoundaryCondition("inlet", outletPressure, inletTemperature, inletConc,[xinf]);
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
-
- # set physical parameters
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name file save
- fileName = "1DVidangeReservoir";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = .95;
- maxTime = 5.;
- precision = 1e-5;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-
-if __name__ == """__main__""":
- DriftModel_1DVidangeReservoir()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-
-def DriftModel_2BranchesBoilingChannels():
-
- spaceDim = 1;
- # Prepare for the mesh
- M=cm.Mesh("../resources/BifurcatingFlow2BranchesEqualSections.med")
- M.getFace(0).setGroupName("Inlet")#z=0
- M.getFace(31).setGroupName("Outlet")#z=4.2
-
- # set the initial field
- initialConc=0;
- initialPressure=155e5;
- initialVelocityX=5;
- initialTemperature=573;
-
- # set the limit field for each boundary
- inletConc=0;
- inletVelocityX=5;
- inletTemperature=573;
- outletPressure=155e5
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar;
-
- # constant vector
- VV_Constant[0] = initialConc ;
- VV_Constant[1] = initialPressure ;
- VV_Constant[2] = initialVelocityX;
- VV_Constant[3] = initialTemperature ;
-
-
- #Initial field creation
- print("Building initial data" );
- myProblem.setInitialFieldConstant( M, VV_Constant);
-
- # set the boundary conditions
- myProblem.setInletBoundaryCondition("Inlet", inletTemperature, inletConc,inletVelocityX);
- myProblem.setOutletBoundaryCondition("Outlet",outletPressure);
-
- #set porosity, heat and gravity source
- Sections=cm.Field("../resources/BifurcatingFlow2BranchesEqualSections", cm.CELLS,"Section area");
- heatPowerField=cm.Field("../resources/BifurcatingFlow2BranchesEqualSections", cm.CELLS,"Heat power");
- myProblem.setSectionField(Sections);
- myProblem.setHeatPowerField(heatPowerField)
- gravite=[-10]
- myProblem.setGravity(gravite)
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setWellBalancedCorrection(True)
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name of result file
- fileName = "2BranchesBoilingChannels";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.5;
- maxTime = 500;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveConservativeField(True);
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_2BranchesBoilingChannels()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-
-import CoreFlows as cf
-import cdmath as cm
-
-
-def DriftModel_2DBoilingChannelBarrier():
-
- spaceDim = 2;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=2.0;
- yinf=0.0;
- ysup=4.0;
- nx=20;
- ny=40;
- cloison=(xinf+xsup)/2
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"wall")
- M.setGroupAtPlan(xinf,0,eps,"wall")
- M.setGroupAtPlan(ysup,1,eps,"outlet")
- M.setGroupAtPlan(yinf,1,eps,"inlet")
- dy=(ysup-yinf)/ny
- ncloison=ny/2
- i=0
- while i<= ncloison+1:
- M.setGroupAtFaceByCoords(cloison,((ysup-yinf)/4)+(i+0.5)*dy,0,eps,"wall")
- i=i+1
-
-
- # set the limit field for each boundary
- wallVelocityX=0;
- wallVelocityY=0;
- wallTemperature=573;
- inletConc=0;
- inletVelocityX=0;
- inletVelocityY=1;
- inletTemperature=563;
- outletPressure=155e5;
-
- # physical constants
- gravite = [0] * spaceDim
-
- gravite[0]=0;
- gravite[1]=-10;
-
- heatPower=1e8;
- heatPower_nul=0;
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
- heatPowerField=cm.Field("heatPowerField", cm.CELLS, M, 1);
-
- nbCells=M.getNumberOfCells();
-
- for i in range (nbCells):
- x=M.getCell(i).x();
- y=M.getCell(i).y();
- if (y> (ysup-yinf)/4) and (y< (ysup-yinf)*3/4) and (x<cloison):
- heatPowerField[i]=heatPower
- else:
- heatPowerField[i]=heatPower_nul
- heatPowerField.writeVTK("heatPowerField",True)
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar
-
- # constant vector
- VV_Constant[0] = inletConc ;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX;
- VV_Constant[3] = inletVelocityY;
- VV_Constant[4] = inletTemperature ;
-
- #Initial field creation
- print("Building initial data" );
- myProblem.setInitialFieldConstant(M,VV_Constant)
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
- myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConc, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- # set physical parameters
- myProblem.setHeatPowerField(heatPowerField)
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setWellBalancedCorrection(True);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name file save
- fileName = "2DBoilingChannelBarrier";
-
- # parameters calculation
- MaxNbOfTimeStep = 3;
- freqSave = 1;
- cfl = .5;
- maxTime = 5000;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveVelocity();
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_2DBoilingChannelBarrier()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-
-import CoreFlows as cf
-
-def DriftModel_2DInclinedBoilingChannel():
- spaceDim = 2;
-
- # Prepare for the mesh
- xinf = 0 ;
- xsup=1.0;
- yinf=0.0;
- ysup=1.0;
- nx=20;
- ny=20;
-
- # set the limit field for each boundary
- wallVelocityX=0;
- wallVelocityY=0;
- wallTemperature=563;
- inletConcentration=0;
- inletVelocityX=0;
- inletVelocityY=1;
- inletTemperature=563;
- outletPressure=155e5;
-
- # physical constants
- gravite = [0] * spaceDim
-
- gravite[1]=-7;
- gravite[0]=7;
-
- heatPower=1e8;
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar
-
- # constant vector
- VV_Constant[0] = inletConcentration;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX;
- VV_Constant[3] = inletVelocityY;
- VV_Constant[4] = inletTemperature ;
-
- #Initial field creation
- print("Building mesh and initial data " );
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
- xinf,xsup,nx,"wall","wall",
- yinf,ysup,ny,"inlet","outlet",
- 0.0,0.0, 0, "", "")
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
- myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- # set physical parameters
- myProblem.setHeatSource(heatPower);
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setWellBalancedCorrection(True);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name of result file
- fileName = "2DInclinedBoilingChannel";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.5;
- maxTime = 5;
- precision = 1e-4;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_2DInclinedBoilingChannel()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-
-import CoreFlows as cf
-import cdmath as cm
-
-
-def DriftModel_2DInclinedBoilingChannelBarrier():
-
- spaceDim = 2;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=2.0;
- yinf=0.0;
- ysup=4.0;
- nx=20;
- ny=40;
- cloison=(xinf+xsup)/2
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"wall")
- M.setGroupAtPlan(xinf,0,eps,"wall")
- M.setGroupAtPlan(ysup,1,eps,"outlet")
- M.setGroupAtPlan(yinf,1,eps,"inlet")
- dy=(ysup-yinf)/ny
- ncloison=ny/2
- i=0
- while i<= ncloison+1:
- M.setGroupAtFaceByCoords(cloison,((ysup-yinf)/4)+(i+0.5)*dy,0,eps,"wall")
- i=i+1
-
-
- # set the limit field for each boundary
- wallVelocityX=0;
- wallVelocityY=0;
- wallTemperature=573;
- inletConc=0;
- inletVelocityX=0;
- inletVelocityY=1;
- inletTemperature=563;
- outletPressure=155e5;
-
- # source terms
- gravite = [0] * spaceDim
-
- gravite[0]=7;
- gravite[1]=-7;
-
- heatPower=1e8;
- heatPower_nul=0;
- heatPowerField=cm.Field("heatPowerField", cm.CELLS, M, 1);
-
- nbCells=M.getNumberOfCells();
-
- for i in range (nbCells):
- x=M.getCell(i).x();
- y=M.getCell(i).y();
- if (y> (ysup-yinf)/4) and (y< (ysup-yinf)*3/4) and (x<cloison):
- heatPowerField[i]=heatPower
- else:
- heatPowerField[i]=heatPower_nul
- heatPowerField.writeVTK("heatPowerField",True)
-
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
- # Prepare for the initial condition
- VV_Constant =[0]*nVar
-
- # constant vector
- VV_Constant[0] = inletConc ;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX;
- VV_Constant[3] = inletVelocityY;
- VV_Constant[4] = inletTemperature ;
-
- #Initial field creation
- print("Building initial data" );
- myProblem.setInitialFieldConstant(M,VV_Constant)
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
- myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConc, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- # set physical parameters
- myProblem.setHeatPowerField(heatPowerField)
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setWellBalancedCorrection(True);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name file save
- fileName = "2DBInclinedoilingChannelBarrier";
-
- # parameters calculation
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = .5;
- maxTime = 5000;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.saveVelocity();
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_2DInclinedBoilingChannelBarrier()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-
-def DriftModel_2DInclinedBoilingChannel():
- spaceDim = 2;
-
- # Prepare for the mesh
- xinf = 0 ;
- xsup=1.0;
- yinf=0.0;
- ysup=4.0;
- nx=10;
- ny=40;
-
- # set the limit field for each boundary
- wallVelocityX=0;
- wallVelocityY=0;
- wallTemperature=563;
- inletConcentration=0;
- inletVelocityX=0;
- inletVelocityY=1;
- inletTemperature=563;
- outletPressure=155e5;
-
- # physical constants
- gravite = [0] * spaceDim
-
- gravite[1]=-8.5;
- gravite[0]=5;
-
- heatPower=0e8;
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar
-
- # constant vector
- VV_Constant[0] = inletConcentration;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX;
- VV_Constant[3] = inletVelocityY;
- VV_Constant[4] = inletTemperature ;
-
- #Initial field creation
- print("Building mesh and initial data " );
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
- xinf,xsup,nx,"wall","wall",
- yinf,ysup,ny,"inlet","outlet",
- 0.0,0.0, 0, "", "")
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
- myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- # set physical parameters
- myProblem.setHeatSource(heatPower);
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
- myProblem.setWellBalancedCorrection(True);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name of result file
- fileName = "2DInclinedChannelGravity";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.5;
- maxTime = 500;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.usePrimitiveVarsInNewton(True)
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_2DInclinedBoilingChannel()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def DriftModel_2DInclinedBoilingChannel():
- spaceDim = 2;
-
- # Prepare for the mesh
- xinf = 0 ;
- xsup=.6;
- yinf=0.0;
- ysup=2.0;
- nx=3;
- ny=100;
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
-
- #Set the barriers
- xcloison1=xinf+(xsup-xinf)/3
- xcloison2=xinf+2*(xsup-xinf)/3
- barrierField=cm.Field("Barrier Field", cm.FACES, M, 1);
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"wall")
- M.setGroupAtPlan(xinf,0,eps,"wall")
- M.setGroupAtPlan(ysup,1,eps,"outlet")
- M.setGroupAtPlan(yinf,1,eps,"inlet")
- dy=(ysup-yinf)/ny
- ncloison=3*ny/4
- i=0
- while i<= ncloison+1:
- M.setGroupAtFaceByCoords(xcloison1,yinf+((ysup-yinf)/4)+(i+0.5)*dy,0,eps,"wall")
- M.setGroupAtFaceByCoords(xcloison2,yinf+((ysup-yinf)/4)+(i+0.5)*dy,0,eps,"wall")
- i=i+1
-
- nbFaces=M.getNumberOfFaces();
- for i in range (nbFaces):
- x=M.getFace(i).x();
- y=M.getFace(i).y();
- if ((y> yinf+(ysup-yinf)/4) and (abs(x-xcloison1)< eps or abs(x-xcloison2)< eps)) or abs(x-xinf)< eps or abs(x-xsup)< eps :
- barrierField[i]=1
- else:
- barrierField[i]=0
- barrierField.writeVTK("barrierField",True)
-
- # set the limit field for each boundary
- wallVelocityX=0;
- wallVelocityY=0;
- wallTemperature=563;
- inletConcentration=0;
- inletVelocityX=0;
- inletVelocityY=1;
- inletTemperature=563;
- outletPressure=155e5;
-
- # physical constants
- gravite = [0] * spaceDim
-
- gravite[1]=-8.5;
- gravite[0]=5;
-
- heatPower=0e8;
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar
-
- # constant vector
- VV_Constant[0] = inletConcentration;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX;
- VV_Constant[3] = inletVelocityY;
- VV_Constant[4] = inletTemperature ;
-
- #Initial field creation
- print("Building mesh and initial data " );
- myProblem.setInitialFieldConstant(M,VV_Constant)
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
- myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- # set physical parameters
- myProblem.setHeatSource(heatPower);
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
- myProblem.setWellBalancedCorrection(True);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name of result file
- fileName = "2DInclinedChannelVFFCStaggeredWB3x100CFL100";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1000;
- cfl = 100;
- maxTime = 500;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.usePrimitiveVarsInNewton(True)
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_2DInclinedBoilingChannel()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-
-def DriftModel_2DInclinedBoilingChannel():
- spaceDim = 2;
-
- # Prepare for the mesh
- print( "Loading unstructured mesh " );
- inputfile="../resources/CanalTrianglesStructures.med";
- xinf = 0 ;
- xsup=1.0;
- yinf=0.0;
- ysup=4.0;
- nx=10;
- ny=40;
-
- # set the limit field for each boundary
- wallVelocityX=0;
- wallVelocityY=0;
- wallTemperature=563;
- inletConcentration=0;
- inletVelocityX=0;
- inletVelocityY=1;
- inletTemperature=563;
- outletPressure=155e5;
-
- # physical constants
- gravite = [0] * spaceDim
-
- gravite[1]=-8.5;
- gravite[0]=5;
-
- heatPower=0e8;
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar
-
- # constant vector
- VV_Constant[0] = inletConcentration;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX;
- VV_Constant[3] = inletVelocityY;
- VV_Constant[4] = inletTemperature ;
-
- #Initial field creation
- print("Building mesh and initial data " );
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
- xinf,xsup,nx,"wall","wall",
- yinf,ysup,ny,"inlet","outlet",
- 0.0,0.0, 0, "", "")
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
- myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- # set physical parameters
- myProblem.setHeatSource(heatPower);
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
- myProblem.setWellBalancedCorrection(True);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name of result file
- fileName = "2DInclinedChannelGravityTriangles";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.5;
- maxTime = 500;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.usePrimitiveVarsInNewton(True)
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_2DInclinedBoilingChannel()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-
-import CoreFlows as cf
-import cdmath as cm
-import math
-
-def DriftModel_2DPorosityJump():
- spaceDim = 2;
-
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=1.5;
- yinf=0.0;
- ysup=0.8;
- nx=20;
- ny=20;
- discontinuity=(xinf+xsup)/2
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Outlet")
- M.setGroupAtPlan(xinf,0,eps,"Inlet")
- M.setGroupAtPlan(ysup,1,eps,"Wall")
- M.setGroupAtPlan(yinf,1,eps,"Wall")
- dx=(xsup-xinf)/nx
- ndis=(discontinuity-xinf)/dx
-
-
- # set the limit field for each boundary
- inletConc=0;
- inletVelocityX=1. ;
- inletVelocityY=0 ;
- inletTemperature=563 ;
- outletPressure=155e5 ;
-
-
- # physical parameters
- porosityField=cm.Field("Porosity",cm.CELLS,M,1);
- for i in xrange(M.getNumberOfCells()):
- x=M.getCell(i).x();
- y=M.getCell(i).y();
- if x > (xsup-xinf)/3. and x<(xsup-xinf)*2./3 and y> (ysup-yinf)/4. and y<(ysup-yinf)*3./4:
- porosityField[i]=0.5;
- else:
- porosityField[i]=1;
- pass
- porosityField.writeVTK("PorosityField");
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =cm.Vector(nVar)
-
- # constant vectorsetOutletBoundaryCondition
- VV_Constant[0] = inletConc;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX;
- VV_Constant[3] = inletVelocityY;
- VV_Constant[4] = inletTemperature ;
-
- # set physical parameters
- myProblem.setPorosityField(porosityField);
-
- print("Building initial data");
- myProblem.setInitialFieldConstant(M,VV_Constant)
-
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("Outlet", outletPressure);
- myProblem.setInletBoundaryCondition("Inlet", inletTemperature,inletConc, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("Wall", inletTemperature, 0,0);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setWellBalancedCorrection(True);
-
- # name file save
- fileName = "2DPorosityJump";
-
- # parameters calculation
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.5;
- maxTime = 5000;
- precision = 1e-4;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(1e10,20);
- myProblem.saveVelocity();
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_2DPorosityJump()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-
-import CoreFlows as cf
-import cdmath as cm
-import math
-
-def DriftModel_2DPressureLoss():
- spaceDim = 2;
-
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=0.42;
- yinf=0.0;
- ysup=4.2;
- nx=2;
- ny=100;
- discontinuity=(xinf+xsup)/2
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"RightWall")
- M.setGroupAtPlan(xinf,0,eps,"LeftWall")
- M.setGroupAtPlan(ysup,1,eps,"outlet")
- dx=(xsup-xinf)/nx
- ndis=(discontinuity-xinf)/dx
- print("ndis=",math.floor(ndis) );
- i=0
-# while i<= ndis:
- M.setGroupAtFaceByCoords(xinf+(i+0.5)*dx,yinf,0,eps,"inlet_1")
- i=1
-# while i<= nx:
- M.setGroupAtFaceByCoords(xinf+(i+0.5)*dx,yinf,0,eps,"inlet_2")
-
-
-
- # set the limit field for each boundary
- inletConc=0;
- inletVelocityX1=0. ;
- inletVelocityY1=2.7 ;
- inletVelocityX2=0 ;
- inletVelocityY2=1.5 ;
- inletTemperature=563 ;
- outletPressure=155e5 ;
-
-
- # physical parameters
- pressureLossField=cm.Field("PressureLossCoeff", cm.FACES, M, 1);
- nbFaces=M.getNumberOfFaces();
-
- for i in range (nbFaces):
- if abs(M.getFace(i).y() - 1.0500)<eps :
- pressureLossField[i]=50
- print("Premiere perte de charge ok")
- elif abs(M.getFace(i).y() - 1.680)<eps :
- pressureLossField[i]=50
- print("Deuxieme perte de charge ok")
- elif M.getFace(i).y() == 2.7300:
- pressureLossField[i]=50
- print("Troisieme perte de charge ok")
- else:
- pressureLossField[i]=0;
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant_Left =cm.Vector(nVar)
- VV_Constant_Right =cm.Vector(nVar)
-
- # constant vectorsetOutletBoundaryCondition
- VV_Constant_Left[0] = inletConc;
- VV_Constant_Left[1] = outletPressure ;
- VV_Constant_Left[2] = inletVelocityX1;
- VV_Constant_Left[3] = inletVelocityY1;
- VV_Constant_Left[4] = inletTemperature ;
-
- VV_Constant_Right[0] = inletConc;
- VV_Constant_Right[1] = outletPressure ;
- VV_Constant_Right[2] = inletVelocityX2;
- VV_Constant_Right[3] = inletVelocityY2;
- VV_Constant_Right[4] = inletTemperature ;
-
-
- # set physical parameters
- myProblem.setPressureLossField(pressureLossField);
-
- print("Building initial data" );
- myProblem.setInitialFieldStepFunction(M,VV_Constant_Left,VV_Constant_Right,discontinuity)
-
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure);
- myProblem.setInletBoundaryCondition("inlet_1", inletTemperature,inletConc, inletVelocityX1, inletVelocityY1);
- myProblem.setInletBoundaryCondition("inlet_2", inletTemperature,inletConc, inletVelocityX2, inletVelocityY2);
- myProblem.setWallBoundaryCondition("LeftWall", inletTemperature, 0,0);
- myProblem.setWallBoundaryCondition("RightWall", inletTemperature, 0,0);
-
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setWellBalancedCorrection(True);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name file save
- fileName = "2DPressureLoss";
-
- # parameters calculation
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.5;
- maxTime = 5000;
- precision = 1e-4;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(1e10,20);
- myProblem.saveVelocity();
-
- # evolution
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_2DPressureLoss()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def DriftModel_2DVidangeReservoir():
-
- spaceDim = 2;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=1.0;
- yinf=0.0;
- ysup=1.0;
- nx=50;
- ny=50;
- diametreSortie=(ysup-yinf)/10.#10 percent of the height
- nsortie=ny*diametreSortie/(ysup-yinf)
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xinf,0,eps,"wall")
- M.setGroupAtPlan(ysup,1,eps,"inlet")
- M.setGroupAtPlan(yinf,1,eps,"wall")
- dy=(ysup-yinf)/ny
- i=0
- while i < nsortie:
- M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"outlet")
- i=i+1
- while i < ny:
- M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"wall")
- i=i+1
-
-
-
- # set the limit field for each boundary
- wallVelocityX=0;
- wallVelocityY=0;
- wallTemperature=300;
- inletConc=1;
- inletTemperature=300;
- outletPressure=1e5;
-
- # set the limit field for each boundary
- initialConcTop=1.;
- initialConcBottom=0.0001;
- initialVelocityX=0;
- initialVelocityY=0;
- initialTemperature=300;
- initialPressure=1e5;
-
- # physical constants
- gravite = [0] * spaceDim
-
- gravite[0]=0;
- gravite[1]=-10;
-
- myProblem = cf.DriftModel(cf.around1bar300K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
- # Prepare for the initial condition
- VV_top =cm.Vector(nVar)
- VV_bottom =cm.Vector(nVar)
-
- # constant vector
- VV_top[0] = initialConcTop ;
- VV_top[1] = initialPressure ;
- VV_top[2] = initialVelocityX;
- VV_top[3] = initialVelocityY;
- VV_top[4] = initialTemperature ;
-
- VV_bottom[0] = initialConcBottom ;
- VV_bottom[1] = initialPressure ;
- VV_bottom[2] = initialVelocityX;
- VV_bottom[3] = initialVelocityY;
- VV_bottom[4] = initialTemperature ;
-
- #Initial field creation
- print("Building initial data" );
- #myProblem.setInitialFieldStepFunction( M, VV_bottom, VV_top, .8, 1);
- myProblem.setInitialFieldConstant( M, VV_bottom)
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
- myProblem.setInletPressureBoundaryCondition("inlet", outletPressure, inletTemperature, inletConc,[xsup,yinf]);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- # set physical parameters
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name file save
- fileName = "2DVidangeReservoir";
-
- # parameters calculation
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = .5;
- maxTime = 5000;
- precision = 1e-5;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveVelocity();
-
- # evolution
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_2DVidangeReservoir()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def DriftModel_2DVidangeReservoirUnstructured():
-
- print( "Loading unstructured mesh " );
- inputfile="../resources/BoxWithMeshWithTriangularCells.med";
-
- spaceDim = 2;
- # Prepare for the mesh
- xinf = 0 ;
- xsup=1.0;
- yinf=0.0;
- ysup=1.0;
- ny=33;
- diametreSortie=(ysup-yinf)/10.#1à percent of the height
- nsortie=ny*diametreSortie/(ysup-yinf)
- M=cm.Mesh(inputfile);
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xinf,0,eps,"wall")
- M.setGroupAtPlan(ysup,1,eps,"inlet")
- M.setGroupAtPlan(yinf,1,eps,"wall")
- dy=(ysup-yinf)/ny
- i=0
- while i < nsortie:
- M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"outlet")
- i=i+1
- while i < ny:
- M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"wall")
- i=i+1
-
- #print M.getNamesOfGroups()
-
- # set the limit field for each boundary
- wallVelocityX=0;
- wallVelocityY=0;
- wallTemperature=300;
- inletConc=1;
- inletVelocityX=0;
- inletVelocityY=1;
- inletTemperature=300;
- outletPressure=1e5;
-
- # set the limit field for each boundary
- initialConc=0.0001;
- initialVelocityX=0;
- initialVelocityY=0;
- initialTemperature=300;
- initialPressure=1e5;
-
- # physical constants
- gravite = [0] * spaceDim
-
- gravite[0]=0;
- gravite[1]=-10;
-
- myProblem = cf.DriftModel(cf.around1bar300K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
- # Prepare for the initial condition
- VV_Constant =[0]*nVar
-
- # constant vector
- VV_Constant[0] = initialConc ;
- VV_Constant[1] = initialPressure ;
- VV_Constant[2] = initialVelocityX;
- VV_Constant[3] = initialVelocityY;
- VV_Constant[4] = initialTemperature ;
-
- #Initial field creation
- print("Building initial data" ); #import cdmath
- myProblem.setInitialFieldConstant(M,VV_Constant)
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
- myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConc, inletVelocityX, inletVelocityY);
- #myProblem.setNeumannBoundaryCondition("inlet");
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- # set physical parameters
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name file save
- fileName = "2DVidangeReservoirUntructureUpwind";
-
- # parameters calculation
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = .5;
- maxTime = 5000;
- precision = 1e-5;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveVelocity();
-
- # evolution
- myProblem.initialize();
- print("Running "+ fileName );
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_2DVidangeReservoirUnstructured()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-
-import CoreFlows as cf
-import cdmath as cm
-
-
-def DriftModel_3DBoilingChannelBarrier():
-
- spaceDim = 3;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=2.0;
- yinf=0.0;
- ysup=2.0;
- zinf=0.0;
- zsup=4.0;
- nx=10;
- ny=nx;
- nz=20;
- xcloison=(xinf+xsup)/2
- ycloison=(yinf+ysup)/2
- zcloisonmin=1
- zcloisonmax=3
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz)
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"wall")
- M.setGroupAtPlan(xinf,0,eps,"wall")
- M.setGroupAtPlan(ysup,1,eps,"wall")
- M.setGroupAtPlan(yinf,1,eps,"wall")
- M.setGroupAtPlan(zsup,2,eps,"outlet")
- M.setGroupAtPlan(zinf,2,eps,"inlet")
- dx=(xsup-xinf)/nx
- dy=(ysup-yinf)/ny
- dz=(zsup-zinf)/nz
- ncloison=nz*(zcloisonmax-zcloisonmin)/(zsup-zinf)
- i=0
- j=0
- while i< ncloison:
- while j< ny:
- M.setGroupAtFaceByCoords(xcloison,(j+0.5)*dy,zcloisonmin+(i+0.5)*dz,eps,"wall")
- M.setGroupAtFaceByCoords((j+0.5)*dx,ycloison,zcloisonmin+(i+0.5)*dz,eps,"wall")
- j=j+1
- i=i+1
-
- # set the limit field for each boundary
- wallVelocityX=0;
- wallVelocityY=0;
- wallVelocityZ=0;
- wallTemperature=573;
- inletConc=0;
- inletVelocityX=0;
- inletVelocityY=0;
- inletVelocityZ=1;
- inletTemperature=563;
- outletPressure=155e5;
-
- # physical constants
- gravite = [0] * spaceDim
-
- gravite[0]=0;
- gravite[1]=0;
- gravite[2]=-10;
-
- heatPower1=0;
- heatPower2=0.25e8;
- heatPower3=0.5e8;
- heatPower4=1e8;
-
- myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
- heatPowerField=cm.Field("heatPowerField", cm.CELLS, M, 1);
-
- nbCells=M.getNumberOfCells();
-
- for i in range (nbCells):
- x=M.getCell(i).x();
- y=M.getCell(i).y();
- z=M.getCell(i).z();
- if (z> zcloisonmin) and (z< zcloisonmax) :
- if (y<ycloison) and (x<xcloison):
- heatPowerField[i]=heatPower1
- if (y<ycloison) and (x>xcloison):
- heatPowerField[i]=heatPower2
- if (y>ycloison) and (x<xcloison):
- heatPowerField[i]=heatPower3
- if (y>ycloison) and (x>xcloison):
- heatPowerField[i]=heatPower4
- else:
- heatPowerField[i]=0
-
- heatPowerField.writeVTK("heatPowerField",True)
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar
-
- # constant vector
- VV_Constant[0] = inletConc ;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX;
- VV_Constant[3] = inletVelocityY;
- VV_Constant[4] = inletVelocityZ;
- VV_Constant[5] = inletTemperature ;
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldConstant(M,VV_Constant)
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup,zsup]);
- myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConc, inletVelocityX, inletVelocityY, inletVelocityZ);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY,wallVelocityZ);
-
- # set physical parameters
- myProblem.setHeatPowerField(heatPowerField)
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
- myProblem.setWellBalancedCorrection(True);
-
- # name file save
- fileName = "3DBoilingChannelBarrier";
-
- # parameters calculation
- MaxNbOfTimeStep = 3;
- freqSave = 100;
- cfl = .3;
- maxTime = 5000;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveVelocity();
-
- # evolution
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- DriftModel_3DBoilingChannelBarrier()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def FiveEqsTwoFluid_1DBoilingAssembly():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=4.2;
+ nx=50;
+ M=cm.Mesh(xinf,xsup,nx)
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"outlet")
+ M.setGroupAtPlan(xinf,0,eps,"inlet")
+
+ # set the limit field for each boundary
+
+ inletVoidFraction=0;
+ inletVelocityX=[1]*2;
+ inletTemperature=563;
+ outletPressure=155e5;
+
+ # physical constants
+ heatPowerField=cm.Field("heatPowerField", cm.CELLS, M, 1);
+
+ nbCells=M.getNumberOfCells();
+
+ for i in range (nbCells):
+ x=M.getCell(i).x();
+ if (x> (xsup-xinf)/4) and (x< (xsup-xinf)*3/4):
+ heatPowerField[i]=1e8
+ else:
+ heatPowerField[i]=0
+ heatPowerField.writeVTK("heatPowerField",True)
+
+
+ myProblem = cf.FiveEqsTwoFluid(cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar;
+
+ # constant vector
+ VV_Constant[0] = inletVoidFraction;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX[0];
+ VV_Constant[3] = inletVelocityX[1];
+ VV_Constant[4] = inletTemperature ;
+
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldConstant(M,VV_Constant)
+
+ # set the boundary conditions
+ myProblem.setInletBoundaryCondition("inlet",inletVoidFraction,inletTemperature,inletVelocityX)
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure);
+
+ # set physical parameters
+ myProblem.setHeatPowerField(heatPowerField)
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setEntropicCorrection(True);
+ myProblem.setWellBalancedCorrection(True);
+
+ # name of result file
+ fileName = "1DBoilingAssembly";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 500;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ #myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ FiveEqsTwoFluid_1DBoilingAssembly()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+
+def FiveEqsTwoFluid_1DBoilingChannel():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ xinf = 0 ;
+ xsup=4.2;
+ nx=50;
+
+ # set the limit field for each boundary
+
+ inletVoidFraction=0;
+ inletVelocityX=[1]*2;
+ inletTemperature=563;
+ outletPressure=155e5;
+
+ # physical constants
+ heatPower=1e8;
+
+ myProblem = cf.FiveEqsTwoFluid(cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar;
+
+ # constant vector
+ VV_Constant[0] = inletVoidFraction;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX[0];
+ VV_Constant[3] = inletVelocityX[1];
+ VV_Constant[4] = inletTemperature ;
+
+
+ #Initial field creation
+ print("Building mesh and initial data " );
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
+
+ # set the boundary conditions
+ myProblem.setInletBoundaryCondition("inlet",inletVoidFraction,inletTemperature,inletVelocityX)
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure);
+
+ # set physical parameters
+ myProblem.setHeatSource(heatPower);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setEntropicCorrection(True);
+ myProblem.setWellBalancedCorrection(True);
+
+ # name of result file
+ fileName = "1DBoilingChannel";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 500;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ #myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ FiveEqsTwoFluid_1DBoilingChannel()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def FiveEqsTwoFluid_1DVidangeReservoir():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0. ;
+ xsup=1.0;
+ nx=50;
+ M=cm.Mesh(xinf,xsup,nx)
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xinf,0,eps,"wall")
+ M.setGroupAtPlan(xsup,0,eps,"inlet")
+
+ # set the limit field for each boundary
+ wallVelocityX=[0] * 2
+ wallTemperature=300
+
+ # set the limit field for each boundary
+ initialAlphaTop=1;
+ initialAlphaBottom=0.;
+ initialVelocityX=[0]*2;
+ initialPressure=1e5;
+ initialTemperature=300
+
+ # physical constants
+ gravite=[-10];
+
+ myProblem = cf.FiveEqsTwoFluid(cf.around1bar300K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_top =cm.Vector(nVar)
+ VV_bottom =cm.Vector(nVar)
+
+ # top and bottom vectors
+ VV_top[0] = initialAlphaTop ;
+ VV_top[1] = initialPressure ;
+ VV_top[2] = initialVelocityX[0];
+ VV_top[3] = initialVelocityX[1];
+ VV_top[4] = initialTemperature
+
+ VV_bottom[0] = initialAlphaBottom ;
+ VV_bottom[1] = initialPressure ;
+ VV_bottom[2] = initialVelocityX[0];
+ VV_bottom[3] = initialVelocityX[1];
+ VV_bottom[4] = initialTemperature
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldStepFunction( M, VV_bottom, VV_top, .8, 0);
+
+ # the boundary conditions
+ myProblem.setWallBoundaryCondition("wall",initialTemperature, wallVelocityX);
+ myProblem.setNeumannBoundaryCondition("inlet");
+
+ # set physical parameters
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ #myProblem.setEntropicCorrection(True);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name file save
+ fileName = "1DVidangeReservoir";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = .1;
+ maxTime = 5.;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+
+ return ok
+
+
+if __name__ == """__main__""":
+ FiveEqsTwoFluid_1DVidangeReservoir()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+
+import CoreFlows as cf
+
+def FiveEqsTwoFluid_2DInclinedBoilingChannel():
+ spaceDim = 2;
+
+ # Prepare for the mesh
+ xinf = 0 ;
+ xsup=2;
+ yinf=0.0;
+ ysup=4;
+ nx=20;
+ ny=40;
+
+ # set the limit field for each boundary
+ wallVelocityX=[0];
+ wallVelocityY=[0];
+ wallTemperature=573;
+ inletVoidFraction=0;
+ inletVelocityX=[0]*2;
+ inletVelocityY=[1]*2;
+ inletTemperature=573;
+ outletPressure=155e5;
+
+ # physical constants
+ gravite = [0] * spaceDim
+
+ gravite[1]=-7;
+ gravite[0]=7;
+
+ heatPower=5e7;
+
+ myProblem = cf.FiveEqsTwoFluid(cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar
+
+ # constant vector
+ VV_Constant[0] = inletVoidFraction;
+ VV_Constant[1] = outletPressure ;
+ VV_Constant[2] = inletVelocityX[0];
+ VV_Constant[3] = inletVelocityY[0];
+ VV_Constant[4] = inletVelocityX[1];
+ VV_Constant[5] = inletVelocityY[1];
+ VV_Constant[6] = inletTemperature ;
+
+ #Initial field creation
+ print("Building mesh and initial data " );
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
+ xinf,xsup,nx,"wall","wall",
+ yinf,ysup,ny,"inlet","outlet",
+ 0.0,0.0, 0, "", "")
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure);
+ myProblem.setInletBoundaryCondition("inlet", inletVoidFraction, inletTemperature, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ # set physical parameters
+ myProblem.setHeatSource(heatPower);
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
+ myProblem.setEntropicCorrection(True);
+ #myProblem.setWellBalancedCorrection(True);
+
+ # name of result file
+ fileName = "2DInclinedBoilingChannel";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.25;
+ maxTime = 5;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ #myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ FiveEqsTwoFluid_2DInclinedBoilingChannel()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+
+import CoreFlows as cf
+
+def FiveEqsTwoFluid_2DInclinedSedimentation():
+ spaceDim = 2;
+
+ # Prepare for the mesh
+ xinf = 0 ;
+ xsup=2.0;
+ yinf=0.0;
+ ysup=4.0;
+ nx=20;
+ ny=40;
+
+ # set the limit field for each boundary
+ wallVelocityX=[0];
+ wallVelocityY=[0];
+ wallTemperature=573;
+
+ # set the initial field
+ initialVoidFraction=0.5;
+ initialVelocityX=[0]*2;
+ initialVelocityY=[1]*2;
+ initialTemperature=573;
+ initialPressure=155e5;
+
+ # physical constants
+ gravite = [0] * spaceDim
+
+ gravite[1]=-7;
+ gravite[0]=7;
+
+ myProblem = cf.FiveEqsTwoFluid(cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar
+
+ # constant vector
+ VV_Constant[0] = initialVoidFraction;
+ VV_Constant[1] = initialPressure ;
+ VV_Constant[2] = initialVelocityX[0];
+ VV_Constant[3] = initialVelocityY[0];
+ VV_Constant[4] = initialVelocityX[1];
+ VV_Constant[5] = initialVelocityY[1];
+ VV_Constant[6] = initialTemperature ;
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
+ xinf,xsup,nx,"wall","wall",
+ yinf,ysup,ny,"wall","wall",
+ 0.0,0.0, 0, "", "")
+
+ # the boundary conditions
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ # set physical parameters
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setEntropicCorrection(True);
+
+ # name of result file
+ fileName = "2DInclinedSedimentation";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.25;
+ maxTime = 5;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ FiveEqsTwoFluid_2DInclinedSedimentation()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def FiveEqsTwoFluid_2DVidangeReservoir():
+
+ spaceDim = 2;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=1.0;
+ yinf=0.0;
+ ysup=1.0;
+ nx=50;
+ ny=50;
+ diametreSortie=(ysup-yinf)/10.#10 percent of the height
+ nsortie=ny*diametreSortie/(ysup-yinf)
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xinf,0,eps,"wall")
+ M.setGroupAtPlan(ysup,1,eps,"inlet")
+ M.setGroupAtPlan(yinf,1,eps,"wall")
+ dy=(ysup-yinf)/ny
+ i=0
+ while i < nsortie:
+ M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"wall")
+ i=i+1
+ while i < ny:
+ M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"wall")
+ i=i+1
+
+
+
+ # set the limit field for each boundary
+ wallVelocityX=[0]*2;
+ wallVelocityY=[0]*2;
+ wallTemperature=300;
+ outletPressure=1e5;
+ inletTemperature=300;
+
+ # set the limit field for each boundary
+ initialAlphaTop=1.;
+ initialAlphaBottom=0.;
+ initialVelocityX=[0]*2;
+ initialVelocityY=[0]*2;
+ initialPressure=1e5;
+ initialTemperature=300;
+
+ # physical constants
+ gravite = [0] * spaceDim
+
+ gravite[0]=0;
+ gravite[1]=-10;
+
+ myProblem = cf.FiveEqsTwoFluid(cf.around1bar300K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+ # Prepare for the initial condition
+ VV_top =cm.Vector(nVar)
+ VV_bottom =cm.Vector(nVar)
+
+ # constant vector
+ VV_top[0] = initialAlphaTop ;
+ VV_top[1] = initialPressure ;
+ VV_top[2] = initialVelocityX[0];
+ VV_top[3] = initialVelocityX[1];
+ VV_top[4] = initialVelocityY[0];
+ VV_top[5] = initialVelocityY[1];
+ VV_top[6] = initialTemperature ;
+
+ VV_bottom[0] = initialAlphaBottom ;
+ VV_bottom[1] = initialPressure ;
+ VV_bottom[2] = initialVelocityX[0];
+ VV_bottom[3] = initialVelocityX[1];
+ VV_bottom[4] = initialVelocityY[0];
+ VV_bottom[5] = initialVelocityY[1];
+ VV_bottom[6] = initialTemperature ;
+
+ #Initial field creation
+ print("Building initial data" );
+ myProblem.setInitialFieldStepFunction( M, VV_bottom, VV_top, .8, 1);
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure);
+ myProblem.setNeumannBoundaryCondition("inlet");
+ myProblem.setWallBoundaryCondition("wall", wallTemperature,wallVelocityX, wallVelocityY);
+
+ # set physical parameters
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ #myProblem.setEntropicCorrection(True);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name file save
+ fileName = "2DVidangeReservoir";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.1;
+ maxTime = 500;
+ precision = 1e-4;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveVelocity();
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+
+ return ok
+
+if __name__ == """__main__""":
+ FiveEqsTwoFluid_2DVidangeReservoir()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def FiveEqsTwoFluid_1DBoilingAssembly():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=4.2;
- nx=50;
- M=cm.Mesh(xinf,xsup,nx)
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"outlet")
- M.setGroupAtPlan(xinf,0,eps,"inlet")
-
- # set the limit field for each boundary
-
- inletVoidFraction=0;
- inletVelocityX=[1]*2;
- inletTemperature=563;
- outletPressure=155e5;
-
- # physical constants
- heatPowerField=cm.Field("heatPowerField", cm.CELLS, M, 1);
-
- nbCells=M.getNumberOfCells();
-
- for i in range (nbCells):
- x=M.getCell(i).x();
- if (x> (xsup-xinf)/4) and (x< (xsup-xinf)*3/4):
- heatPowerField[i]=1e8
- else:
- heatPowerField[i]=0
- heatPowerField.writeVTK("heatPowerField",True)
-
-
- myProblem = cf.FiveEqsTwoFluid(cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar;
-
- # constant vector
- VV_Constant[0] = inletVoidFraction;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX[0];
- VV_Constant[3] = inletVelocityX[1];
- VV_Constant[4] = inletTemperature ;
-
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldConstant(M,VV_Constant)
-
- # set the boundary conditions
- myProblem.setInletBoundaryCondition("inlet",inletVoidFraction,inletTemperature,inletVelocityX)
- myProblem.setOutletBoundaryCondition("outlet", outletPressure);
-
- # set physical parameters
- myProblem.setHeatPowerField(heatPowerField)
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setEntropicCorrection(True);
- myProblem.setWellBalancedCorrection(True);
-
- # name of result file
- fileName = "1DBoilingAssembly";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.5;
- maxTime = 500;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- #myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- FiveEqsTwoFluid_1DBoilingAssembly()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-
-def FiveEqsTwoFluid_1DBoilingChannel():
-
- spaceDim = 1;
- # Prepare for the mesh
- xinf = 0 ;
- xsup=4.2;
- nx=50;
-
- # set the limit field for each boundary
-
- inletVoidFraction=0;
- inletVelocityX=[1]*2;
- inletTemperature=563;
- outletPressure=155e5;
-
- # physical constants
- heatPower=1e8;
-
- myProblem = cf.FiveEqsTwoFluid(cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar;
-
- # constant vector
- VV_Constant[0] = inletVoidFraction;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX[0];
- VV_Constant[3] = inletVelocityX[1];
- VV_Constant[4] = inletTemperature ;
-
-
- #Initial field creation
- print("Building mesh and initial data " );
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
-
- # set the boundary conditions
- myProblem.setInletBoundaryCondition("inlet",inletVoidFraction,inletTemperature,inletVelocityX)
- myProblem.setOutletBoundaryCondition("outlet", outletPressure);
-
- # set physical parameters
- myProblem.setHeatSource(heatPower);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setEntropicCorrection(True);
- myProblem.setWellBalancedCorrection(True);
-
- # name of result file
- fileName = "1DBoilingChannel";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.5;
- maxTime = 500;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- #myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- FiveEqsTwoFluid_1DBoilingChannel()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def FiveEqsTwoFluid_1DVidangeReservoir():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0. ;
- xsup=1.0;
- nx=50;
- M=cm.Mesh(xinf,xsup,nx)
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xinf,0,eps,"wall")
- M.setGroupAtPlan(xsup,0,eps,"inlet")
-
- # set the limit field for each boundary
- wallVelocityX=[0] * 2
- wallTemperature=300
-
- # set the limit field for each boundary
- initialAlphaTop=1;
- initialAlphaBottom=0.;
- initialVelocityX=[0]*2;
- initialPressure=1e5;
- initialTemperature=300
-
- # physical constants
- gravite=[-10];
-
- myProblem = cf.FiveEqsTwoFluid(cf.around1bar300K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_top =cm.Vector(nVar)
- VV_bottom =cm.Vector(nVar)
-
- # top and bottom vectors
- VV_top[0] = initialAlphaTop ;
- VV_top[1] = initialPressure ;
- VV_top[2] = initialVelocityX[0];
- VV_top[3] = initialVelocityX[1];
- VV_top[4] = initialTemperature
-
- VV_bottom[0] = initialAlphaBottom ;
- VV_bottom[1] = initialPressure ;
- VV_bottom[2] = initialVelocityX[0];
- VV_bottom[3] = initialVelocityX[1];
- VV_bottom[4] = initialTemperature
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldStepFunction( M, VV_bottom, VV_top, .8, 0);
-
- # the boundary conditions
- myProblem.setWallBoundaryCondition("wall",initialTemperature, wallVelocityX);
- myProblem.setNeumannBoundaryCondition("inlet");
-
- # set physical parameters
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- #myProblem.setEntropicCorrection(True);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name file save
- fileName = "1DVidangeReservoir";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = .1;
- maxTime = 5.;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
-
- return ok
-
-
-if __name__ == """__main__""":
- FiveEqsTwoFluid_1DVidangeReservoir()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-
-import CoreFlows as cf
-
-def FiveEqsTwoFluid_2DInclinedBoilingChannel():
- spaceDim = 2;
-
- # Prepare for the mesh
- xinf = 0 ;
- xsup=2;
- yinf=0.0;
- ysup=4;
- nx=20;
- ny=40;
-
- # set the limit field for each boundary
- wallVelocityX=[0];
- wallVelocityY=[0];
- wallTemperature=573;
- inletVoidFraction=0;
- inletVelocityX=[0]*2;
- inletVelocityY=[1]*2;
- inletTemperature=573;
- outletPressure=155e5;
-
- # physical constants
- gravite = [0] * spaceDim
-
- gravite[1]=-7;
- gravite[0]=7;
-
- heatPower=5e7;
-
- myProblem = cf.FiveEqsTwoFluid(cf.around155bars600K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar
-
- # constant vector
- VV_Constant[0] = inletVoidFraction;
- VV_Constant[1] = outletPressure ;
- VV_Constant[2] = inletVelocityX[0];
- VV_Constant[3] = inletVelocityY[0];
- VV_Constant[4] = inletVelocityX[1];
- VV_Constant[5] = inletVelocityY[1];
- VV_Constant[6] = inletTemperature ;
-
- #Initial field creation
- print("Building mesh and initial data " );
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
- xinf,xsup,nx,"wall","wall",
- yinf,ysup,ny,"inlet","outlet",
- 0.0,0.0, 0, "", "")
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure);
- myProblem.setInletBoundaryCondition("inlet", inletVoidFraction, inletTemperature, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- # set physical parameters
- myProblem.setHeatSource(heatPower);
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
- myProblem.setEntropicCorrection(True);
- #myProblem.setWellBalancedCorrection(True);
-
- # name of result file
- fileName = "2DInclinedBoilingChannel";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.25;
- maxTime = 5;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- #myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- FiveEqsTwoFluid_2DInclinedBoilingChannel()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-
-import CoreFlows as cf
-
-def FiveEqsTwoFluid_2DInclinedSedimentation():
- spaceDim = 2;
-
- # Prepare for the mesh
- xinf = 0 ;
- xsup=2.0;
- yinf=0.0;
- ysup=4.0;
- nx=20;
- ny=40;
-
- # set the limit field for each boundary
- wallVelocityX=[0];
- wallVelocityY=[0];
- wallTemperature=573;
-
- # set the initial field
- initialVoidFraction=0.5;
- initialVelocityX=[0]*2;
- initialVelocityY=[1]*2;
- initialTemperature=573;
- initialPressure=155e5;
-
- # physical constants
- gravite = [0] * spaceDim
-
- gravite[1]=-7;
- gravite[0]=7;
-
- myProblem = cf.FiveEqsTwoFluid(cf.around155bars600K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar
-
- # constant vector
- VV_Constant[0] = initialVoidFraction;
- VV_Constant[1] = initialPressure ;
- VV_Constant[2] = initialVelocityX[0];
- VV_Constant[3] = initialVelocityY[0];
- VV_Constant[4] = initialVelocityX[1];
- VV_Constant[5] = initialVelocityY[1];
- VV_Constant[6] = initialTemperature ;
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
- xinf,xsup,nx,"wall","wall",
- yinf,ysup,ny,"wall","wall",
- 0.0,0.0, 0, "", "")
-
- # the boundary conditions
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- # set physical parameters
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setEntropicCorrection(True);
-
- # name of result file
- fileName = "2DInclinedSedimentation";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.25;
- maxTime = 5;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- FiveEqsTwoFluid_2DInclinedSedimentation()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def FiveEqsTwoFluid_2DVidangeReservoir():
-
- spaceDim = 2;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=1.0;
- yinf=0.0;
- ysup=1.0;
- nx=50;
- ny=50;
- diametreSortie=(ysup-yinf)/10.#10 percent of the height
- nsortie=ny*diametreSortie/(ysup-yinf)
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xinf,0,eps,"wall")
- M.setGroupAtPlan(ysup,1,eps,"inlet")
- M.setGroupAtPlan(yinf,1,eps,"wall")
- dy=(ysup-yinf)/ny
- i=0
- while i < nsortie:
- M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"wall")
- i=i+1
- while i < ny:
- M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"wall")
- i=i+1
-
-
-
- # set the limit field for each boundary
- wallVelocityX=[0]*2;
- wallVelocityY=[0]*2;
- wallTemperature=300;
- outletPressure=1e5;
- inletTemperature=300;
-
- # set the limit field for each boundary
- initialAlphaTop=1.;
- initialAlphaBottom=0.;
- initialVelocityX=[0]*2;
- initialVelocityY=[0]*2;
- initialPressure=1e5;
- initialTemperature=300;
-
- # physical constants
- gravite = [0] * spaceDim
-
- gravite[0]=0;
- gravite[1]=-10;
-
- myProblem = cf.FiveEqsTwoFluid(cf.around1bar300K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
- # Prepare for the initial condition
- VV_top =cm.Vector(nVar)
- VV_bottom =cm.Vector(nVar)
-
- # constant vector
- VV_top[0] = initialAlphaTop ;
- VV_top[1] = initialPressure ;
- VV_top[2] = initialVelocityX[0];
- VV_top[3] = initialVelocityX[1];
- VV_top[4] = initialVelocityY[0];
- VV_top[5] = initialVelocityY[1];
- VV_top[6] = initialTemperature ;
-
- VV_bottom[0] = initialAlphaBottom ;
- VV_bottom[1] = initialPressure ;
- VV_bottom[2] = initialVelocityX[0];
- VV_bottom[3] = initialVelocityX[1];
- VV_bottom[4] = initialVelocityY[0];
- VV_bottom[5] = initialVelocityY[1];
- VV_bottom[6] = initialTemperature ;
-
- #Initial field creation
- print("Building initial data" );
- myProblem.setInitialFieldStepFunction( M, VV_bottom, VV_top, .8, 1);
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure);
- myProblem.setNeumannBoundaryCondition("inlet");
- myProblem.setWallBoundaryCondition("wall", wallTemperature,wallVelocityX, wallVelocityY);
-
- # set physical parameters
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- #myProblem.setEntropicCorrection(True);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name file save
- fileName = "2DVidangeReservoir";
-
- # parameters calculation
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.1;
- maxTime = 500;
- precision = 1e-4;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveVelocity();
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
-
- return ok
-
-if __name__ == """__main__""":
- FiveEqsTwoFluid_2DVidangeReservoir()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+
+def IsothermalTwoFluid_1DSedimentation():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ xinf = 0. ;
+ xsup=1.0;
+ nx=50;
+
+ # set the limit field for each boundary
+ wallVelocityX=[0] * 2;
+ wallPressure=1.e5;
+
+ initialVoidFraction=0.5;
+
+ # physical constants
+ gravite=[-10];
+
+ myProblem = cf.IsothermalTwoFluid(cf.around1bar300K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+ print(nVar)
+
+ # Prepare for the initial condition
+ VV_Constant =[0] *nVar
+
+ # constant vector
+ VV_Constant[0] = initialVoidFraction;
+ VV_Constant[1] = wallPressure;
+ VV_Constant[2] = wallVelocityX[0];
+ VV_Constant[3] = wallVelocityX[1];
+
+ #Initial field creation
+ print("Building mesh and initial data " );
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"wall","wall")
+
+ # the boundary conditions
+ myProblem.setWallBoundaryCondition("wall", wallVelocityX);
+
+ # set physical parameters
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
+ myProblem.setEntropicCorrection(True);
+
+ # name file save
+ fileName = "1DSedimentation";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 5.;
+ maxTime = 5.;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+
+ # evolution
+ myProblem.initialize();
+ print("Running python"+ fileName );
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+
+if __name__ == """__main__""":
+ IsothermalTwoFluid_1DSedimentation()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def IsothermalTwoFluid_1DVidangeReservoir():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0. ;
+ xsup=1.0;
+ nx=50;
+ M=cm.Mesh(xinf,xsup,nx)
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xinf,0,eps,"wall")
+ M.setGroupAtPlan(xsup,0,eps,"inlet")
+
+ # set the limit field for each boundary
+ wallVelocityX=[0] * 2
+
+ # set the limit field for each boundary
+ initialAlphaTop=1;
+ initialAlphaBottom=0.;
+ initialVelocityX=[0]*2;
+ initialPressure=1e5;
+
+
+ # physical constants
+ gravite=[-10];
+
+ myProblem = cf.IsothermalTwoFluid(cf.around1bar300K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_top =cm.Vector(nVar)
+ VV_bottom =cm.Vector(nVar)
+
+ # top and bottom vectors
+ VV_top[0] = initialAlphaTop ;
+ VV_top[1] = initialPressure ;
+ VV_top[2] = initialVelocityX[0];
+ VV_top[3] = initialVelocityX[1];
+
+ VV_bottom[0] = initialAlphaBottom ;
+ VV_bottom[1] = initialPressure ;
+ VV_bottom[2] = initialVelocityX[0];
+ VV_bottom[3] = initialVelocityX[1];
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldStepFunction( M, VV_bottom, VV_top, .8, 0);
+
+ # the boundary conditions
+ myProblem.setWallBoundaryCondition("wall", wallVelocityX);
+ myProblem.setNeumannBoundaryCondition("inlet");
+
+ # set physical parameters
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ #myProblem.setEntropicCorrection(True);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+
+ # name file save
+ fileName = "1DVidangeReservoir";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = .1;
+ maxTime = 5.;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+
+ return ok
+
+
+if __name__ == """__main__""":
+ IsothermalTwoFluid_1DVidangeReservoir()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def IsothermalTwoFluid_2DVidangeReservoir():
+
+ spaceDim = 2;
+ print("Building mesh " );
+ # Prepare for the mesh
+ xinf = 0 ;
+ xsup=1.0;
+ yinf=0.0;
+ ysup=1.0;
+ nx=50;
+ ny=50;
+ diametreSortie=(ysup-yinf)/10.#10 percent of the height
+ nsortie=ny*diametreSortie/(ysup-yinf)
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xinf,0,eps,"wall")
+ M.setGroupAtPlan(ysup,1,eps,"inlet")
+ M.setGroupAtPlan(yinf,1,eps,"wall")
+ dy=(ysup-yinf)/ny
+ i=0
+ while i < nsortie:
+ M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"wall")
+ i=i+1
+ while i < ny:
+ M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"wall")
+ i=i+1
+
+
+
+ # set the limit field for each boundary
+ wallVelocityX=[0]*2;
+ wallVelocityY=[0]*2;
+ inletAlpha=1;
+ outletPressure=1e5;
+
+ # set the limit field for each boundary
+ initialAlphaTop=1;
+ initialAlphaBottom=0.;
+ initialVelocityX=[0]*2;
+ initialVelocityY=[0]*2;
+ initialPressure=1e5;
+
+ # physical constants
+ gravite = [0] * spaceDim
+
+ gravite[0]=0;
+ gravite[1]=-10;
+
+ myProblem = cf.IsothermalTwoFluid(cf.around1bar300K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+ # Prepare for the initial condition
+ VV_top =cm.Vector(nVar)
+ VV_bottom =cm.Vector(nVar)
+
+ # top and bottom vectors
+ VV_top[0] = initialAlphaTop ;
+ VV_top[1] = initialPressure ;
+ VV_top[2] = initialVelocityX[0];
+ VV_top[3] = initialVelocityX[1];
+ VV_top[4] = initialVelocityY[0];
+ VV_top[5] = initialVelocityY[1];
+
+ VV_bottom[0] = initialAlphaBottom ;
+ VV_bottom[1] = initialPressure ;
+ VV_bottom[2] = initialVelocityX[0];
+ VV_bottom[3] = initialVelocityX[1];
+ VV_bottom[4] = initialVelocityY[0];
+ VV_bottom[5] = initialVelocityY[1];
+
+ #Initial field creation
+ print("Building initial data" );
+ myProblem.setInitialFieldStepFunction( M, VV_bottom, VV_top, .8, 1);
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure);
+ myProblem.setNeumannBoundaryCondition("inlet");
+ myProblem.setWallBoundaryCondition("wall",wallVelocityX, wallVelocityY);
+
+ # set physical parameters
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setNonLinearFormulation(cf.VFFC)
+ myProblem.setEntropicCorrection(True);
+
+ # name file save
+ fileName = "2DVidangeReservoir";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = .1;
+ maxTime = 500;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveVelocity();
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+
+ return ok
+
+if __name__ == """__main__""":
+ IsothermalTwoFluid_2DVidangeReservoir()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-
-def IsothermalTwoFluid_1DSedimentation():
-
- spaceDim = 1;
- # Prepare for the mesh
- xinf = 0. ;
- xsup=1.0;
- nx=50;
-
- # set the limit field for each boundary
- wallVelocityX=[0] * 2;
- wallPressure=1.e5;
-
- initialVoidFraction=0.5;
-
- # physical constants
- gravite=[-10];
-
- myProblem = cf.IsothermalTwoFluid(cf.around1bar300K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
- print(nVar)
-
- # Prepare for the initial condition
- VV_Constant =[0] *nVar
-
- # constant vector
- VV_Constant[0] = initialVoidFraction;
- VV_Constant[1] = wallPressure;
- VV_Constant[2] = wallVelocityX[0];
- VV_Constant[3] = wallVelocityX[1];
-
- #Initial field creation
- print("Building mesh and initial data " );
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"wall","wall")
-
- # the boundary conditions
- myProblem.setWallBoundaryCondition("wall", wallVelocityX);
-
- # set physical parameters
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
- myProblem.setEntropicCorrection(True);
-
- # name file save
- fileName = "1DSedimentation";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 5.;
- maxTime = 5.;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
-
- # evolution
- myProblem.initialize();
- print("Running python"+ fileName );
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-
-if __name__ == """__main__""":
- IsothermalTwoFluid_1DSedimentation()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def IsothermalTwoFluid_1DVidangeReservoir():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0. ;
- xsup=1.0;
- nx=50;
- M=cm.Mesh(xinf,xsup,nx)
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xinf,0,eps,"wall")
- M.setGroupAtPlan(xsup,0,eps,"inlet")
-
- # set the limit field for each boundary
- wallVelocityX=[0] * 2
-
- # set the limit field for each boundary
- initialAlphaTop=1;
- initialAlphaBottom=0.;
- initialVelocityX=[0]*2;
- initialPressure=1e5;
-
-
- # physical constants
- gravite=[-10];
-
- myProblem = cf.IsothermalTwoFluid(cf.around1bar300K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_top =cm.Vector(nVar)
- VV_bottom =cm.Vector(nVar)
-
- # top and bottom vectors
- VV_top[0] = initialAlphaTop ;
- VV_top[1] = initialPressure ;
- VV_top[2] = initialVelocityX[0];
- VV_top[3] = initialVelocityX[1];
-
- VV_bottom[0] = initialAlphaBottom ;
- VV_bottom[1] = initialPressure ;
- VV_bottom[2] = initialVelocityX[0];
- VV_bottom[3] = initialVelocityX[1];
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldStepFunction( M, VV_bottom, VV_top, .8, 0);
-
- # the boundary conditions
- myProblem.setWallBoundaryCondition("wall", wallVelocityX);
- myProblem.setNeumannBoundaryCondition("inlet");
-
- # set physical parameters
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- #myProblem.setEntropicCorrection(True);
- myProblem.setNonLinearFormulation(cf.VFFC)
-
- # name file save
- fileName = "1DVidangeReservoir";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = .1;
- maxTime = 5.;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
-
- return ok
-
-
-if __name__ == """__main__""":
- IsothermalTwoFluid_1DVidangeReservoir()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def IsothermalTwoFluid_2DVidangeReservoir():
-
- spaceDim = 2;
- print("Building mesh " );
- # Prepare for the mesh
- xinf = 0 ;
- xsup=1.0;
- yinf=0.0;
- ysup=1.0;
- nx=50;
- ny=50;
- diametreSortie=(ysup-yinf)/10.#10 percent of the height
- nsortie=ny*diametreSortie/(ysup-yinf)
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xinf,0,eps,"wall")
- M.setGroupAtPlan(ysup,1,eps,"inlet")
- M.setGroupAtPlan(yinf,1,eps,"wall")
- dy=(ysup-yinf)/ny
- i=0
- while i < nsortie:
- M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"wall")
- i=i+1
- while i < ny:
- M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"wall")
- i=i+1
-
-
-
- # set the limit field for each boundary
- wallVelocityX=[0]*2;
- wallVelocityY=[0]*2;
- inletAlpha=1;
- outletPressure=1e5;
-
- # set the limit field for each boundary
- initialAlphaTop=1;
- initialAlphaBottom=0.;
- initialVelocityX=[0]*2;
- initialVelocityY=[0]*2;
- initialPressure=1e5;
-
- # physical constants
- gravite = [0] * spaceDim
-
- gravite[0]=0;
- gravite[1]=-10;
-
- myProblem = cf.IsothermalTwoFluid(cf.around1bar300K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
- # Prepare for the initial condition
- VV_top =cm.Vector(nVar)
- VV_bottom =cm.Vector(nVar)
-
- # top and bottom vectors
- VV_top[0] = initialAlphaTop ;
- VV_top[1] = initialPressure ;
- VV_top[2] = initialVelocityX[0];
- VV_top[3] = initialVelocityX[1];
- VV_top[4] = initialVelocityY[0];
- VV_top[5] = initialVelocityY[1];
-
- VV_bottom[0] = initialAlphaBottom ;
- VV_bottom[1] = initialPressure ;
- VV_bottom[2] = initialVelocityX[0];
- VV_bottom[3] = initialVelocityX[1];
- VV_bottom[4] = initialVelocityY[0];
- VV_bottom[5] = initialVelocityY[1];
-
- #Initial field creation
- print("Building initial data" );
- myProblem.setInitialFieldStepFunction( M, VV_bottom, VV_top, .8, 1);
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure);
- myProblem.setNeumannBoundaryCondition("inlet");
- myProblem.setWallBoundaryCondition("wall",wallVelocityX, wallVelocityY);
-
- # set physical parameters
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setNonLinearFormulation(cf.VFFC)
- myProblem.setEntropicCorrection(True);
-
- # name file save
- fileName = "2DVidangeReservoir";
-
- # parameters calculation
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = .1;
- maxTime = 500;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveVelocity();
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
-
- return ok
-
-if __name__ == """__main__""":
- IsothermalTwoFluid_2DVidangeReservoir()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+import math
+
+def SinglePhase_1DDepressurisation():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=4.2;
+ nx=50;
+ M=cm.Mesh(xinf,xsup,nx)
+
+ # set the initial field
+ initialPressure=155e5;
+ initialVelocityX=0;
+ initialTemperature=573;
+
+ # set the boundary data for each boundary
+ outletPressure=80e5;
+ wallVelocityX=0;
+ wallTemperature=573;
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar;
+
+ # constant vector
+ VV_Constant[0] = initialPressure ;
+ VV_Constant[1] = initialVelocityX;
+ VV_Constant[2] = initialTemperature ;
+
+
+ #Initial field creation
+ print("Building initial data" );
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"wall","outlet");
+
+ # set the boundary conditions
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX);
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
+
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+
+ # name of result file
+ fileName = "1DDepressurisation";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.95;
+ maxTime = 500;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ #myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_1DDepressurisation()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def SinglePhase_1DHeatedAssembly():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=4.2;
+ xinfcore=(xsup-xinf)/4
+ xsupcore=3*(xsup-xinf)/4
+ nx=50;
+ M=cm.Mesh(xinf,xsup,nx)
+
+ # set the limit field for each boundary
+
+ inletVelocityX=5;
+ inletTemperature=565;
+ outletPressure=155e5;
+
+ # physical parameters
+ heatPowerField=cm.Field("heatPowerField", cm.CELLS, M, 1);
+ nbCells=M.getNumberOfCells();
+
+ for i in range (nbCells):
+ x=M.getCell(i).x();
+
+ if (x> xinfcore) and (x< xsupcore):
+ heatPowerField[i]=1e8
+ else:
+ heatPowerField[i]=0
+ heatPowerField.writeVTK("heatPowerField",True)
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar;
+
+ # constant vector
+ VV_Constant[0] = outletPressure ;
+ VV_Constant[1] = inletVelocityX;
+ VV_Constant[2] = inletTemperature ;
+
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
+
+ # set the boundary conditions
+ myProblem.setInletBoundaryCondition("inlet",inletTemperature,inletVelocityX)
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
+
+ # set physical parameters
+ myProblem.setHeatPowerField(heatPowerField);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setWellBalancedCorrection(True);
+
+ # name of result file
+ fileName = "1DHeatedChannelUpwindWB";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.95;
+ maxTime = 500;
+ precision = 1e-7;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_1DHeatedAssembly()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+
+def SinglePhase_1DHeatedChannel():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=4.2;
+ nx=50;
+
+ # set the limit field for each boundary
+
+ inletVelocityX=5;
+ inletTemperature=565;
+ outletPressure=155e5;
+
+ # physical parameters
+ heatPower=1e7;
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar;
+
+ # constant vector
+ VV_Constant[0] = outletPressure ;
+ VV_Constant[1] = inletVelocityX;
+ VV_Constant[2] = inletTemperature ;
+
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
+
+ # set the boundary conditions
+ myProblem.setInletBoundaryCondition("inlet",inletTemperature,inletVelocityX)
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
+
+ # set physical parameters
+ myProblem.setHeatSource(heatPower);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setWellBalancedCorrection(True);
+
+ # name of result file
+ fileName = "1DHeatedChannelUpwindWB";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.95;
+ maxTime = 500;
+ precision = 1e-7;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_1DHeatedChannel()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def SinglePhase_1DRiemannProblem():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=4.2;
+ nx=50;
+ discontinuity=(xinf+xsup)/2
+ M=cm.Mesh(xinf,xsup,nx)
+ eps=1e-6
+ M.setGroupAtPlan(xsup,0,eps,"RightBoundary")
+ M.setGroupAtPlan(xinf,0,eps,"LeftBoundary")
+
+ # set the limit field for each boundary
+
+ initialVelocity_Left=1;
+ initialTemperature_Left=565;
+ initialPressure_Left=155e5;
+
+ initialVelocity_Right=1;
+ initialTemperature_Right=565;
+ initialPressure_Right=150e5;
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Left =cm.Vector(nVar)
+ VV_Right =cm.Vector(nVar)
+
+ # left and right constant vectors
+ VV_Left[0] = initialPressure_Left;
+ VV_Left[1] = initialVelocity_Left;
+ VV_Left[2] = initialTemperature_Left ;
+
+ VV_Right[0] = initialPressure_Right;
+ VV_Right[1] = initialVelocity_Right;
+ VV_Right[2] = initialTemperature_Right ;
+
+
+ #Initial field creation
+ print("Building initial data " );
+ myProblem.setInitialFieldStepFunction(M,VV_Left,VV_Right,discontinuity);
+
+ # set the boundary conditions
+ myProblem.setNeumannBoundaryCondition("LeftBoundary");
+ myProblem.setNeumannBoundaryCondition("RightBoundary");
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
+
+ # name of result file
+ fileName = "1DRiemannProblem";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.95;
+ maxTime = 500;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.usePrimitiveVarsInNewton(True)
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_1DRiemannProblem()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def SinglePhase_1DWaterHammer():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=4.2;
+ nx=50;
+ M=cm.Mesh(xinf,xsup,nx)
+
+ # set the initial field
+
+ initialPressure=155e5;
+ initialVelocityX=-5;
+ initialTemperature=573;
+
+ # set the limit field for each boundary
+
+ wallVelocityX=0;
+ wallTemperature=573;
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar;
+
+ # constant vector
+ VV_Constant[0] = initialPressure ;
+ VV_Constant[1] = initialVelocityX;
+ VV_Constant[2] = initialTemperature ;
+
+
+ #Initial field creation
+ print("Building initial data" );
+ myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"wall","neumann");
+
+ # set the boundary conditions
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX);
+ myProblem.setNeumannBoundaryCondition("neumann");
+
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+
+ # name of result file
+ fileName = "1DSinglePhase_1DWaterHammer";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.95;
+ maxTime = 500;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ #myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_1DWaterHammer()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+
+def SinglePhase_2BranchesHeatedChannels():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ M=cm.Mesh("../resources/BifurcatingFlow2BranchesEqualSections.med")
+ M.getFace(0).setGroupName("Inlet")#z=0
+ M.getFace(31).setGroupName("Outlet")#z=4.2
+
+ # set the initial field
+ initialPressure=155e5;
+ initialVelocityX=5;
+ initialTemperature=573;
+
+ # set the limit field for each boundary
+ inletVelocityX=5;
+ inletTemperature=573;
+ outletPressure=155e5
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar;
+
+ # constant vector
+ VV_Constant[0] = initialPressure ;
+ VV_Constant[1] = initialVelocityX;
+ VV_Constant[2] = initialTemperature ;
+
+
+ #Initial field creation
+ print("Building initial data" );
+ myProblem.setInitialFieldConstant( M, VV_Constant);
+
+ # set the boundary conditions
+ myProblem.setInletBoundaryCondition("Inlet", inletTemperature, inletVelocityX);
+ myProblem.setOutletBoundaryCondition("Outlet",outletPressure);
+
+ #set porosity, heat and gravity source
+ Sections=cm.Field("../resources/BifurcatingFlow2BranchesEqualSections", cm.CELLS,"Section area");
+ heatPowerField=cm.Field("../resources/BifurcatingFlow2BranchesEqualSections", cm.CELLS,"Heat power");
+
+ heatPowerField.writeVTK("heatPowerField");
+ Sections.writeVTK("crossSectionPowerField");
+
+ myProblem.setSectionField(Sections);
+ myProblem.setHeatPowerField(heatPowerField)
+ gravite=[-10]
+ myProblem.setGravity(gravite)
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setWellBalancedCorrection(True)
+
+ # name of result file
+ fileName = "2BranchesHeatedChannels";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.95;
+ maxTime = 500;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ #myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_2BranchesHeatedChannels()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+
+def SinglePhase_2DHeatedChannelInclined():
+ spaceDim = 2;
+
+ # Prepare the mesh data
+ xinf = 0 ;
+ xsup=3.0;
+ yinf=0.0;
+ ysup=5.0;
+ nx=50;
+ ny=50;
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=573;
+ inletVelocityX=0;
+ inletVelocityY=0.5;
+ inletTemperature=563;
+ outletPressure=155e5;
+
+ # physical constants
+ gravite = [0] * spaceDim
+
+ gravite[1]=-7;
+ gravite[0]=7;
+
+ heatPower=1e8;
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar
+
+ # constant vector
+ VV_Constant[0] = outletPressure ;
+ VV_Constant[1] = inletVelocityX;
+ VV_Constant[2] = inletVelocityY;
+ VV_Constant[3] = inletTemperature ;
+
+ #Initial field creation
+ print("Building mesh and initial data" );
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
+ xinf,xsup,nx,"wall","wall",
+ yinf,ysup,ny,"inlet","outlet",
+ 0.0,0.0, 0, "", "")
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
+ myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+ # set physical parameters
+
+ myProblem.setHeatSource(heatPower);
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
+ myProblem.setWellBalancedCorrection(False);
+
+ # name file save
+ fileName = "2DInclinedHeatedChannel";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 5000;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_2DHeatedChannelInclined()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+
+import CoreFlows as cf
+
+def SinglePhase_2DLidDrivenCavity():
+
+ spaceDim = 2;
+ #Preprocessing: mesh data
+ xinf=0;
+ xsup=1;
+ yinf=0;
+ ysup=1;
+
+ nx=50;
+ ny=50;
+
+ # set the limit field for each boundary
+
+ fixedWallVelocityX=0;
+ fixedWallVelocityY=0;
+ fixedWallTemperature=273;
+
+ movingWallVelocityX=1;
+ movingWallVelocityY=0;
+ movingWallTemperature=273;
+
+ # physical constants
+
+ viscosite=[0.025];
+
+ myProblem = cf.SinglePhase(cf.Gas,cf.around1bar300K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ #Initial field creation
+ print("Building initial data " );
+
+ # Prepare for the initial condition
+
+ VV_Constant = [0] * nVar
+
+ # constant vector
+ VV_Constant[0] = 1e5;
+ VV_Constant[1] = 0 ;
+ VV_Constant[2] = 0;
+ VV_Constant[3] = 273;
+
+ #Initial field creation
+ print("Building mesh and initial data" );
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"fixedWall","fixedWall",yinf,ysup,ny,"fixedWall","movingWall");
+
+ # Set the boundary conditions
+ myProblem.setWallBoundaryCondition("fixedWall", fixedWallTemperature, fixedWallVelocityX, fixedWallVelocityY);
+ myProblem.setWallBoundaryCondition("movingWall", movingWallTemperature, movingWallVelocityX, movingWallVelocityY);
+
+ # set physical parameters
+ myProblem.setViscosity(viscosite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
+ myProblem.setLinearSolver(cf.GMRES,cf.LU,True);
+
+ # name file save
+ fileName = "2DLidDrivenCavity";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 10;
+ maxTime = 50;
+ precision = 1e-9;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(float('inf'),20);
+ myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+
+if __name__ == """__main__""":
+ SinglePhase_2DLidDrivenCavity()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+
+import CoreFlows as cf
+
+def SinglePhase_2DLidDrivenCavity_unstructured():
+ spaceDim = 2;
+
+ print( "Loading unstructured mesh " );
+ inputfile="../resources/BoxWithMeshWithTriangularCells.med";
+
+ # set the limit field for each boundary
+
+ fixedWallVelocityX=0;
+ fixedWallVelocityY=0;
+ fixedWallTemperature=273;
+
+ movingWallVelocityX=1;
+ movingWallVelocityY=0;
+ movingWallTemperature=273;
+
+ # physical constants
+
+ viscosite=[0.025];
+
+ myProblem = cf.SinglePhase(cf.Gas,cf.around1bar300K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ #Initial field creation
+ print("Building initial data " );
+
+ # Prepare for the initial condition
+
+ VV_Constant = [0] * nVar
+
+ # constant vector
+ VV_Constant[0] = 1e5;
+ VV_Constant[1] = 0 ;
+ VV_Constant[2] = 0;
+ VV_Constant[3] = 273;
+
+ #Initial field creation
+ print("Setting mesh and initial data" );
+ myProblem.setInitialFieldConstant(inputfile,VV_Constant);
+
+ # Set the boundary conditions
+ myProblem.setWallBoundaryCondition("BAS", fixedWallTemperature, fixedWallVelocityX, fixedWallVelocityY);
+ myProblem.setWallBoundaryCondition("GAUCHE", fixedWallTemperature, fixedWallVelocityX, fixedWallVelocityY);
+ myProblem.setWallBoundaryCondition("DROITE", fixedWallTemperature, fixedWallVelocityX, fixedWallVelocityY);
+ myProblem.setWallBoundaryCondition("HAUT", movingWallTemperature, movingWallVelocityX, movingWallVelocityY);
+
+ # set physical parameters
+ myProblem.setViscosity(viscosite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.pressureCorrection, cf.Implicit);
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
+
+ # name file save
+ fileName = "2DLidDrivenCavityUnstructured";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 10;
+ maxTime = 50;
+ precision = 1e-9;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_2DLidDrivenCavity_unstructured()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def SinglePhase_2DPoiseuilleFlow():
+ spaceDim = 2;
+
+ print("Building the mesh" );
+ # Prepare the mesh data
+ xinf = 0 ;
+ xsup = 1.0;
+ yinf = 0.0;
+ ysup = 4;
+ nx = 10;
+ ny = 40;
+
+ my_mesh=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
+ # set the boundary names for each boundary
+ eps=1e-6;
+ my_mesh.setGroupAtPlan(xsup,0,eps,"wall")
+ my_mesh.setGroupAtPlan(xinf,0,eps,"wall")
+ my_mesh.setGroupAtPlan(ysup,1,eps,"neumann")
+ my_mesh.setGroupAtPlan(yinf,1,eps,"neumann")
+
+ # physical constants
+ viscosity=0.025
+ viscosite=[viscosity];
+ Vy_max = 1.5
+ a = -8*viscosity*Vy_max / ((ysup-yinf)*(ysup-yinf) ) #pressure slope
+
+ initialTemperature = 573
+ outletPressure = 155e5
+
+ initial_field=cm.Field("Initial field", cm.CELLS, my_mesh, 4)
+ for i in range( 0 , my_mesh.getNumberOfCells() ):
+ Ci=my_mesh.getCell(i)
+ x=Ci.x()
+ y=Ci.y()
+ initial_field[i,0] = outletPressure + a*(y - ysup )
+ initial_field[i,1] = 0 #x component of the velocity
+ initial_field[i,2] = a/(2*viscosity)*( (x-(xsup+xinf)/2)*(x-(xsup+xinf)/2) - (xsup-xinf)*(xsup-xinf)/4) #y component of the velocity
+ initial_field[i,3] = initialTemperature
+
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=573;
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+
+ #Initial field creation
+ print("Setting initial data" );
+ myProblem.setInitialField(initial_field)
+
+ # the boundary conditions
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+ myProblem.setNeumannBoundaryCondition("neumann");
+
+ # set physical parameters
+ myProblem.setViscosity(viscosite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
+ #myProblem.setLinearSolver(cf.GMRES,cf.LU,True);
+
+ # name file save
+ fileName = "2DPoiseuilleFlow";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 10000 ;
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 5000;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setNewtonSolver(float('inf'),20);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_2DPoiseuilleFlow()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def SinglePhase_2DPoiseuilleFlow():
+ spaceDim = 2;
+
+ print("Building the mesh" );
+ # Prepare the mesh data
+ xinf = 0 ;
+ xsup = 1.0;
+ yinf = 0.0;
+ ysup = 4;
+ nx = 10;
+ ny = 40;
+
+ my_mesh=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
+ # set the boundary names for each boundary
+ eps=1e-6;
+ my_mesh.setGroupAtPlan(xsup,0,eps,"wall")
+ my_mesh.setGroupAtPlan(xinf,0,eps,"wall")
+ my_mesh.setGroupAtPlan(ysup,1,eps,"neumann")
+ my_mesh.setGroupAtPlan(yinf,1,eps,"neumann")
+
+ # physical constants
+ viscosity=0.025
+ viscosite=[viscosity];
+ Vy_max = 1.5
+ a = -8*viscosity*Vy_max / ((ysup-yinf)*(ysup-yinf) ) #pressure slope
+
+ initialTemperature = 573
+ outletPressure = 155e5
+
+ initial_field=cm.Field("Initial field", cm.CELLS, my_mesh, 4)
+ for i in range( 0 , my_mesh.getNumberOfCells() ):
+ Ci=my_mesh.getCell(i)
+ x=Ci.x()
+ y=Ci.y()
+ initial_field[i,0] = outletPressure + a*(y - ysup )
+ initial_field[i,1] = 0 #x component of the velocity
+ initial_field[i,2] = a/(2*viscosity)*( (x-(xsup+xinf)/2)*(x-(xsup+xinf)/2) - (xsup-xinf)*(xsup-xinf)/4) #y component of the velocity
+ initial_field[i,3] = initialTemperature
+
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=573;
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+
+ #Initial field creation
+ print("Setting initial data" );
+ myProblem.setInitialField(initial_field)
+
+ # the boundary conditions
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+ myProblem.setNeumannBoundaryCondition("neumann");
+
+ # set physical parameters
+ myProblem.setViscosity(viscosite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
+ #myProblem.setLinearSolver(cf.GMRES,cf.LU,True);
+
+ # name file save
+ fileName = "2DPoiseuilleFlow";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 10000 ;
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 5000;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setNewtonSolver(float('inf'),20);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ message=myProblem.getOutputFieldsNames()
+ numberOfFields=len(message)
+
+ for i in range(numberOfFields):
+ print( message[i])
+
+ pressureField=myProblem.getOutputField("Pressure")
+ pressureField.writeMED("pressureField")
+ pressureField.writeVTK("pressureField")
+ print("Pressure in first cell ", pressureField[0])
+
+ PressureField=myProblem.getPressureField()
+ PressureField.writeMED("PressureField2")
+ PressureField.writeVTK("PressureField2")
+ print("Pressure in first cell ", pressureField[0])
+
+ temperatureField=myProblem.getTemperatureField()
+ temperatureField.writeMED("temperatureField")
+ temperatureField.writeVTK("temperatureField")
+ print("Temperature in first cell ", temperatureField[0])
+
+ temperatureField=myProblem.getOutputField("Temperature")
+ temperatureField.writeMED("temperatureField2")
+ temperatureField.writeVTK("temperatureField2")
+ print("Temperature in first cell ", temperatureField[0])
+
+ velocityField=myProblem.getVelocityField()
+ velocityField.writeMED("velocityField")
+ velocityField.writeVTK("velocityField")
+ print("Velocity X in first cell ", velocityField[0,0])
+ print("Velocity Y in first cell ", velocityField[0,1])
+
+ velocityField=myProblem.getOutputField("Velocity")
+ velocityField.writeMED("velocityField2")
+ velocityField.writeVTK("velocityField2")
+ print("Velocity X in first cell ", velocityField[0,0])
+ print("Velocity Y in first cell ", velocityField[0,1])
+
+ densityField=myProblem.getDensityField()
+ densityField.writeMED("densityField")
+ densityField.writeVTK("densityField")
+ print("Density in first cell ", densityField[0])
+
+ densityField=myProblem.getOutputField("Density")
+ densityField.writeMED("densityField2")
+ densityField.writeVTK("densityField2")
+ print("Density in first cell ", densityField[0])
+
+ momentumField=myProblem.getMomentumField()
+ momentumField.writeMED("momentumField")
+ momentumField.writeVTK("momentumField")
+ print("Momentum X in first cell ", momentumField[0,0])
+ print("Momentum Y in first cell ", momentumField[0,1])
+
+ momentumField=myProblem.getOutputField("Momentum")
+ momentumField.writeMED("momentumField2")
+ momentumField.writeVTK("momentumField2")
+ print("Momentum X in first cell ", momentumField[0,0])
+ print("Momentum Y in first cell ", momentumField[0,1])
+
+ totalEnergyField=myProblem.getTotalEnergyField()
+ totalEnergyField.writeMED("totalEnergyField")
+ totalEnergyField.writeVTK("totalEnergyField")
+ print("Total energy in first cell ", totalEnergyField[0])
+
+ totalEnergyField=myProblem.getOutputField("TotalEnergy")
+ totalEnergyField.writeMED("totalEnergyField2")
+ totalEnergyField.writeVTK("totalEnergyField2")
+ print("Total energy in first cell ", totalEnergyField[0])
+
+ enthalpyField=myProblem.getEnthalpyField()
+ enthalpyField.writeMED("enthalpyField")
+ enthalpyField.writeVTK("enthalpyField")
+ print("Enthalpy in first cell ", enthalpyField[0])
+
+ enthalpyField=myProblem.getOutputField("Enthalpy")
+ enthalpyField.writeMED("enthalpyField2")
+ enthalpyField.writeVTK("enthalpyField2")
+ print("Enthalpy in first cell ", enthalpyField[0])
+
+ velocityXField=myProblem.getVelocityXField()
+ velocityXField.writeMED("velocityXField")
+ velocityXField.writeVTK("velocityXField")
+ print("Velocity X in first cell ", velocityXField[0])
+
+ velocityXField=myProblem.getOutputField("VelocityX")
+ velocityXField.writeMED("velocityXField2")
+ velocityXField.writeVTK("velocityXField2")
+ print("Velocity X in first cell ", velocityXField[0])
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_2DPoiseuilleFlow()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+
+def SinglePhase_2DPoiseuilleFlow():
+ spaceDim = 2;
+
+ # Prepare the mesh data
+ xinf = 0 ;
+ xsup=1.0;
+ yinf=0.0;
+ ysup=4;
+ nx=10;
+ ny=40;
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=573;
+
+ # physical constants
+ viscosite=[0.025];
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =[0]*nVar
+
+ # constant vector
+ initialVelocityX=0;
+ initialVelocityY=1;
+ initialTemperature=573;
+ initialPressure=155e5;
+ VV_Constant[0] = initialPressure ;
+ VV_Constant[1] = initialVelocityX;
+ VV_Constant[2] = initialVelocityY;
+ VV_Constant[3] = initialTemperature ;
+
+ #Initial field creation
+ print("Building mesh and initial data" );
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
+ xinf,xsup,nx,"wall","wall",
+ yinf,ysup,ny,"neumann","neumann",
+ 0.0,0.0, 0, "", "")
+
+ # the boundary conditions
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+ myProblem.setNeumannBoundaryCondition("neumann");
+
+ # set physical parameters
+ myProblem.setViscosity(viscosite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+
+ # name file save
+ fileName = "2DPoiseuilleFlowExplicit_Phase1";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 10
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 5000;
+ precision = 1e-7;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setNewtonSolver(1e-3,20);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of Phase 1 !!! -----------" );
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
+
+ # name file save
+ fileName = "2DPoiseuilleFlowImplicit_Phase2";
+
+ cfl = 0.5;
+ MaxNbOfTimeStep = 20 ;
+ myProblem.setCFL(cfl);
+ myProblem.setNewtonSolver(1e-6,20);
+ myProblem.setFileName(fileName);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+
+ # evolution
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of phase 2 !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_2DPoiseuilleFlow()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+
+
+
+def SinglePhase_2DSphericalExplosion_unstructured():
+
+ inputfile="../resources/BoxWithMeshWithTriangularCells";
+ fieldName="Initial variables for spherical explosion";
+ spaceDim=2
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar=myProblem.getNumberOfVariables();
+
+ # Initial field creation
+ print ("Loading unstructured mesh and initial data for test SinglePhase_2DSphericalExplosion_unstructured()" ) ;
+ myProblem.setInitialField(inputfile,fieldName,0);
+
+ # set the boundary conditions
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=563;
+
+ myProblem.setWallBoundaryCondition("GAUCHE", wallTemperature, wallVelocityX, wallVelocityY);
+ myProblem.setWallBoundaryCondition("DROITE", wallTemperature, wallVelocityX, wallVelocityY);
+ myProblem.setWallBoundaryCondition("HAUT", wallTemperature, wallVelocityX, wallVelocityY);
+ myProblem.setWallBoundaryCondition("BAS", wallTemperature, wallVelocityX, wallVelocityY);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
+ myProblem.setEntropicCorrection(False);
+ myProblem.setWellBalancedCorrection(False);
+
+ # name file save
+ fileName = "2DSphericalExplosion_unstructured";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 5;
+ cfl = 0.5;
+ maxTime = 5;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_2DSphericalExplosion_unstructured()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+
+import CoreFlows as cf
+import cdmath as cm
+import math
+
+def SinglePhase_2DThermalDiffusion():
+ spaceDim = 2;
+
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=0.2;
+ yinf=0.0;
+ ysup=0.4;
+ nx=10;
+ ny=20;
+ discontinuity=(xinf+xsup)/2
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"RightWall")
+ M.setGroupAtPlan(xinf,0,eps,"LeftWall")
+ M.setGroupAtPlan(ysup,1,eps,"outlet")
+ dx=(xsup-xinf)/nx
+ ndis=(discontinuity-xinf)/dx
+ print("ndis=",math.floor(ndis) );
+ i=0
+ while i<= ndis:
+ M.setGroupAtFaceByCoords(xinf+(i+0.5)*dx,yinf,0,eps,"inlet_1")
+ i=i+1
+ while i<= nx:
+ M.setGroupAtFaceByCoords(xinf+(i+0.5)*dx,yinf,0,eps,"inlet_2")
+ i=i+1
+
+
+ # set the limit field for each boundary
+ inletVelocityX=0;
+ inletVelocityY=1;
+ inletTemperature1=563;
+ inletTemperature2=593;
+ outletPressure=155e5;
+
+ viscosite= [1.5];
+ conductivite=[5000];
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant_Left =cm.Vector(nVar)
+ VV_Constant_Right =cm.Vector(nVar)
+
+ # constant vectors
+ VV_Constant_Left[0] = outletPressure ;
+ VV_Constant_Left[1] = inletVelocityX;
+ VV_Constant_Left[2] = inletVelocityY;
+ VV_Constant_Left[3] = inletTemperature1 ;
+
+ VV_Constant_Right[0] = outletPressure ;
+ VV_Constant_Right[1] = inletVelocityX;
+ VV_Constant_Right[2] = inletVelocityY;
+ VV_Constant_Right[3] = inletTemperature2 ;
+
+ print("Building initial data" );
+ myProblem.setInitialFieldStepFunction(M,VV_Constant_Left,VV_Constant_Right,discontinuity)
+
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure);
+ myProblem.setInletBoundaryCondition("inlet_1", inletTemperature1, inletVelocityX, inletVelocityY);
+ myProblem.setInletBoundaryCondition("inlet_2", inletTemperature2, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("LeftWall", inletTemperature1, 0,0);
+ myProblem.setWallBoundaryCondition("RightWall", inletTemperature2, 0,0);
+
+
+ myProblem.setViscosity(viscosite);
+ myProblem.setConductivity(conductivite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
+
+ # name file save
+ fileName = "2DThermalDiffusion";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = .01;
+ maxTime = 5000;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveVelocity();
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_2DThermalDiffusion()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def SinglePhase_2DVidangeReservoir():
+
+ spaceDim = 2;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=1.0;
+ yinf=0.0;
+ ysup=1.0;
+ nx=50;
+ ny=50;
+ diametreSortie=(ysup-yinf)/10.#10 percent of the height
+ nsortie=ny*diametreSortie/(ysup-yinf)
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xinf,0,eps,"wall")
+ M.setGroupAtPlan(ysup,1,eps,"inlet")
+ M.setGroupAtPlan(yinf,1,eps,"wall")
+ dy=(ysup-yinf)/ny
+ i=0
+ while i < nsortie:
+ M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"outlet")
+ i=i+1
+ while i < ny:
+ M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"wall")
+ i=i+1
+
+
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=300;
+ inletTemperature=300;
+ outletPressure=1e5;
+
+ # set the limit field for each boundary
+ initialVelocityX=0;
+ initialVelocityY=0;
+ initialTemperature=300;
+ initialPressure=1e5;
+
+ # physical constants
+ gravite = [0] * spaceDim
+
+ gravite[0]=0;
+ gravite[1]=-10;
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around1bar300K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+ # Prepare for the initial condition
+ VV_constant =cm.Vector(nVar)
+
+ # constant vector
+ VV_constant[0] = initialPressure ;
+ VV_constant[1] = initialVelocityX;
+ VV_constant[2] = initialVelocityY;
+ VV_constant[3] = initialTemperature ;
+
+
+ #Initial field creation
+ print("Building initial data" );
+ myProblem.setInitialFieldConstant( M, VV_constant)
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
+ myProblem.setInletPressureBoundaryCondition("inlet", outletPressure, inletTemperature,[xsup,yinf]);
+ myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ # set physical parameters
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
+
+ # name file save
+ fileName = "2DVidangeReservoir";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = .05;
+ maxTime = 5000;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveVelocity();
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_2DVidangeReservoir()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath as cm
+
+def SinglePhase_2DWallHeatedChannel_ChangeSect():
+
+ #import themesh
+ print("Reading a mesh with sudden cross-section change for test SinglePhase_2DWallHeatedChannel_ChangeSect()")
+ M=cm.Mesh("../resources/VaryingSectionDuct.med")
+
+ # Prepare the mesh boundaries
+ xinf=0.0;
+ xsup=0.01;
+ yinf=0.0;
+ ysup=0.01;
+ eps=1.E-6;
+ M.setGroupAtPlan(xsup,0,eps,"Wall");
+ M.setGroupAtPlan(xinf,0,eps,"Wall");
+ M.setGroupAtPlan(yinf,1,eps,"Inlet");
+ M.setGroupAtPlan(ysup,1,eps,"Outlet");
+
+ #Nombre de cellules utilisees au depart dans Salome ou Alamos
+ nx=60
+ ny=60
+ #taille d'une cellule
+ dx = (xsup-xinf)/nx
+ dy = (ysup-yinf)/ny;
+ for i in range(ny/2):
+ M.setGroupAtFaceByCoords((xsup-xinf)/4,(ysup-yinf)/4+(i+0.5)*dy,0,eps,"Wall");#Paroi verticale intérieure gauche
+ M.setGroupAtFaceByCoords((xsup-xinf)*3/4,(ysup-yinf)/4+(i+0.5)*dy,0,eps,"Wall");#Paroi verticale intérieure droitee
+
+ for i in range(nx/4):
+ M.setGroupAtFaceByCoords((i+0.5)*dx,(ysup-yinf)/4,0,eps,"Wall");#paroi horizontale en bas à gauche
+ M.setGroupAtFaceByCoords((i+0.5)*dx,(ysup-yinf)*3/4,0,eps,"Wall");#paroi horizontale en haut à gauche
+ M.setGroupAtFaceByCoords((xsup-xinf)*3/4+(i+0.5)*dx,(ysup-yinf)/4,0,eps,"Wall");#paroi horizontale en bas à droite
+ M.setGroupAtFaceByCoords((xsup-xinf)*3/4+(i+0.5)*dx,(ysup-yinf)*3/4,0,eps,"Wall");#paroi horizontale en haut à droite
+
+ spaceDim = M.getSpaceDimension();
+
+ # set the limit field for each boundary
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallTemperature=623;
+ inletVelocityX=0;
+ inletVelocityY=2.5;
+ inletTemperature=563;
+ outletPressure=155e5;
+
+ # physical constants
+ viscosite=[8.85e-5]
+ conductivite=[1000]
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar =myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant =cm.Vector(nVar)
+
+ # constant vector
+ VV_Constant[0] = outletPressure ;
+ VV_Constant[1] = inletVelocityX;
+ VV_Constant[2] = inletVelocityY;
+ VV_Constant[3] = inletTemperature ;
+
+ #Initial field creation
+ print("Building mesh and initial data" );
+ myProblem.setInitialFieldConstant(M,VV_Constant);
+
+ # the boundary conditions
+ myProblem.setOutletBoundaryCondition("Outlet", outletPressure,[xsup,ysup]);
+ myProblem.setInletBoundaryCondition("Inlet", inletTemperature, inletVelocityX, inletVelocityY);
+ myProblem.setWallBoundaryCondition("Wall", wallTemperature, wallVelocityX, wallVelocityY);
+
+ # set physical parameters
+ myProblem.setViscosity(viscosite);
+ myProblem.setConductivity(conductivite);
+
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
+
+ # name file save
+ fileName = "2DWallHeatedChannel_ChangeSect";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 5000;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(float('inf'),20);#newton precision should be infinite for staggered scheme!!!
+ myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_2DWallHeatedChannel_ChangeSect()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+
+import CoreFlows as cf
+
+def SinglePhase_3DHeatDrivenCavity():
+
+ spaceDim = 3;
+ #Preprocessing: mesh data
+ xinf=0;
+ xsup=1;
+ yinf=0;
+ ysup=1;
+ zinf=0;
+ zsup=1;
+
+ nx=10;
+ ny=10;
+ nz=10;
+
+ # set the limit field for each boundary
+
+ coldWallVelocityX=0;
+ coldWallVelocityY=0;
+ coldWallVelocityZ=0;
+ coldWallTemperature=563;
+
+ hotWallVelocityX=0;
+ hotWallVelocityY=0;
+ hotWallVelocityZ=0;
+ hotWallTemperature=613;
+
+ # physical constants
+
+ gravite = [0] * spaceDim
+ gravite[2]=-10;
+ gravite[1]=0;
+ gravite[0]=0;
+ viscosite=[8.85e-5];
+ conductivite=[1000];#Wall heat transfert due to nucleate boiling.
+
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ #Initial field creation
+ print("Building initial data " );
+
+ # Prepare for the initial condition
+
+ VV_Constant = [0] * nVar
+
+ # constant vector
+ VV_Constant[0] = 155e5;
+ VV_Constant[1] = 0 ;
+ VV_Constant[2] = 0;
+ VV_Constant[3] = 0;
+ VV_Constant[4] = 573;
+
+ #Initial field creation
+ print("Setting mesh and initial data" );
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"hotWall","hotWall",yinf,ysup,ny,"hotWall","hotWall",zinf,zsup,nz, "hotWall", "coldWall");
+
+ # Set the boundary conditions
+ myProblem.setWallBoundaryCondition("coldWall", coldWallTemperature, coldWallVelocityX, coldWallVelocityY, coldWallVelocityZ);
+ myProblem.setWallBoundaryCondition("hotWall", hotWallTemperature, hotWallVelocityX, hotWallVelocityY, hotWallVelocityZ);
+
+ # set physical parameters
+ myProblem.setViscosity(viscosite);
+ myProblem.setConductivity(conductivite);
+ myProblem.setGravity(gravite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
+ myProblem.setEntropicCorrection(False);
+ myProblem.setWellBalancedCorrection(False);
+
+ # name file save
+ fileName = "3DHeatDrivenCavity";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 10;
+ maxTime = 50;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,50);
+ myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_3DHeatDrivenCavity()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+import cdmath
+
+
+def SinglePhase_3DSphericalExplosion_unstructured():
+
+ inputfile="../../resources/meshCube.med";
+
+ xinf=0;
+ xsup=1;
+ yinf=0;
+ ysup=1;
+ zinf=0;
+ zsup=1;
+ M=cdmath.Mesh(inputfile);
+ eps=1.E-6;
+ M.setGroupAtPlan(xinf,0,eps,"GAUCHE");
+ M.setGroupAtPlan(xsup,0,eps,"DROITE");
+ M.setGroupAtPlan(yinf,1,eps,"ARRIERE");
+ M.setGroupAtPlan(ysup,1,eps,"AVANT");
+ M.setGroupAtPlan(zinf,2,eps,"BAS");
+ M.setGroupAtPlan(zsup,2,eps,"HAUT");
+
+ # Initial field data
+ spaceDim = 3;
+ nVar=2+spaceDim;
+ radius=0.5;
+ Center=cdmath.Vector(3);#default value is (0,0,0)
+ Vout=cdmath.Vector(nVar)
+ Vin =cdmath.Vector(nVar)
+ Vin[0]=1.1;
+ Vin[1]=0;
+ Vin[2]=0;
+ Vin[3]=0;
+ Vin[4]=300;
+ Vout[0]=1;
+ Vout[1]=0;
+ Vout[2]=0;
+ Vout[3]=0;
+ Vout[4]=300;
+
+ myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
+ nVar=myProblem.getNumberOfVariables();
+
+ # Initial field creation
+ print ("Setting mesh and initial data" ) ;
+ myProblem.setInitialFieldSphericalStepFunction( M, Vout, Vin, radius, Center);
+
+ # set the boundary conditions
+ wallVelocityX=0;
+ wallVelocityY=0;
+ wallVelocityZ=0;
+ wallTemperature=563;
+
+ myProblem.setWallBoundaryCondition("GAUCHE", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
+ myProblem.setWallBoundaryCondition("DROITE", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
+ myProblem.setWallBoundaryCondition("HAUT", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
+ myProblem.setWallBoundaryCondition("BAS", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
+ myProblem.setWallBoundaryCondition("AVANT", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
+ myProblem.setWallBoundaryCondition("ARRIERE", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
+ myProblem.setEntropicCorrection(False);
+ myProblem.setWellBalancedCorrection(False);
+
+ # name file save
+ fileName = "3DSphericalExplosion_unstructured";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 1;
+ cfl = 0.5;
+ maxTime = 5;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ myProblem.setNewtonSolver(precision,20);
+ myProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_3DSphericalExplosion_unstructured()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+
+import CoreFlows as cf
+
+def SinglePhase_3DVortexTube_WithoutCone():
+ spaceDim = 3;
+
+ print( "Loading mesh of vortex tube without cone" );
+ inputfile="../resources/VortexTubeWithoutCone.med";
+
+ # set the limit field for each boundary
+ outletPressure = 1e5;
+ inletPressure = 10e5;
+ inletTemperature = 300;
+
+ # physical constants
+ #viscosite=[0.025];
+
+ myProblem = cf.SinglePhase(cf.Gas,cf.around1bar300K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ #Initial field creation
+ print("Building initial data " );
+
+ # Prepare for the initial condition
+
+ VV_Constant = [0] * nVar
+
+ # constant vector
+ VV_Constant[0] = 1e5;
+ VV_Constant[1] = 0 ;
+ VV_Constant[2] = 0;
+ VV_Constant[3] = 0;
+ VV_Constant[4] = 300;
+
+ #Initial field creation
+ print("Setting mesh and initial data" );
+ myProblem.setInitialFieldConstant(inputfile,VV_Constant);
+
+ # Set the boundary conditions
+ myProblem.setInletPressureBoundaryCondition("Inlet flow", inletPressure, inletTemperature,0,100,0)
+ myProblem.setOutletBoundaryCondition("Hot outlet", outletPressure)
+ myProblem.setOutletBoundaryCondition("Cold outlet", outletPressure)
+ myProblem.setWallBoundaryCondition("Wall", inletTemperature)
+
+ # set physical parameters
+ #myProblem.setViscosity(viscosite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setNonLinearFormulation(cf.reducedRoe);
+ myProblem.setEntropicCorrection(True)
+ #myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
+
+ # name file save
+ fileName = "3DVortexTubeWithoutCone";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 10000 ;
+ freqSave = 100;
+ cfl = 1./3;
+ maxTime = 50;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ #myProblem.setNewtonSolver(precision,20);
+ #yProblem.saveConservativeField(True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_3DVortexTube_WithoutCone()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+
+import CoreFlows as cf
+
+def SinglePhase_3DVortexTube_WithCone():
+ spaceDim = 3;
+
+ print( "Loading mesh of vortex tube with cone" );
+ inputfile="../resources/VortexTubeWithCone.med";
+
+ # set the limit field for each boundary
+ outletPressure = 1.e5;
+ inletPressure = 10.e5;
+ inletTemperature = 300.;
+
+ # physical constants
+ #viscosite=[0.025];
+
+ myProblem = cf.SinglePhase(cf.Gas,cf.around1bar300K,spaceDim);
+ nVar = myProblem.getNumberOfVariables();
+
+ #Initial field creation
+ print("Building initial data " );
+
+ # Prepare for the initial condition
+
+ VV_Constant = [0] * nVar
+
+ # constant vector
+ VV_Constant[0] = 1.e5;
+ VV_Constant[1] = 0 ;
+ VV_Constant[2] = 0;
+ VV_Constant[3] = 0;
+ VV_Constant[4] = 300.;
+
+ #Initial field creation
+ print("Setting mesh and initial data" );
+ myProblem.setInitialFieldConstant(inputfile,VV_Constant);
+
+ # Set the boundary conditions
+ myProblem.setInletPressureBoundaryCondition("Inlet flow", inletPressure, inletTemperature,0,100,0)
+ myProblem.setOutletBoundaryCondition("Hot outlet", outletPressure)
+ myProblem.setOutletBoundaryCondition("Cold outlet", outletPressure)
+ myProblem.setWallBoundaryCondition("Wall", inletTemperature)
+
+ # set physical parameters
+ #myProblem.setViscosity(viscosite);
+
+ # set the numerical method
+ myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
+ myProblem.setNonLinearFormulation(cf.reducedRoe);
+ myProblem.setEntropicCorrection(False)
+ #myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
+
+ # name file save
+ fileName = "3DVortexTubeWithCone";
+
+ # simulation parameters
+ MaxNbOfTimeStep = 100000 ;
+ freqSave = 1;
+ cfl = 0.3;
+ maxTime = 50;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+ #myProblem.setNewtonSolver(precision,20);
+ #yProblem.saveConservativeField(True);
+ #myProblem.setVerbose(False,True);
+ if(spaceDim>1):
+ myProblem.saveVelocity();
+ pass
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ SinglePhase_3DVortexTube_WithCone()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-import math
-
-def SinglePhase_1DDepressurisation():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=4.2;
- nx=50;
- M=cm.Mesh(xinf,xsup,nx)
-
- # set the initial field
- initialPressure=155e5;
- initialVelocityX=0;
- initialTemperature=573;
-
- # set the boundary data for each boundary
- outletPressure=80e5;
- wallVelocityX=0;
- wallTemperature=573;
-
- myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar;
-
- # constant vector
- VV_Constant[0] = initialPressure ;
- VV_Constant[1] = initialVelocityX;
- VV_Constant[2] = initialTemperature ;
-
-
- #Initial field creation
- print("Building initial data" );
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"wall","outlet");
-
- # set the boundary conditions
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX);
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
-
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
-
- # name of result file
- fileName = "1DDepressurisation";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.95;
- maxTime = 500;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- #myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_1DDepressurisation()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def SinglePhase_1DHeatedAssembly():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=4.2;
- xinfcore=(xsup-xinf)/4
- xsupcore=3*(xsup-xinf)/4
- nx=50;
- M=cm.Mesh(xinf,xsup,nx)
-
- # set the limit field for each boundary
-
- inletVelocityX=5;
- inletTemperature=565;
- outletPressure=155e5;
-
- # physical parameters
- heatPowerField=cm.Field("heatPowerField", cm.CELLS, M, 1);
- nbCells=M.getNumberOfCells();
-
- for i in range (nbCells):
- x=M.getCell(i).x();
-
- if (x> xinfcore) and (x< xsupcore):
- heatPowerField[i]=1e8
- else:
- heatPowerField[i]=0
- heatPowerField.writeVTK("heatPowerField",True)
-
- myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar;
-
- # constant vector
- VV_Constant[0] = outletPressure ;
- VV_Constant[1] = inletVelocityX;
- VV_Constant[2] = inletTemperature ;
-
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
-
- # set the boundary conditions
- myProblem.setInletBoundaryCondition("inlet",inletTemperature,inletVelocityX)
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
-
- # set physical parameters
- myProblem.setHeatPowerField(heatPowerField);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setWellBalancedCorrection(True);
-
- # name of result file
- fileName = "1DHeatedChannelUpwindWB";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.95;
- maxTime = 500;
- precision = 1e-7;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_1DHeatedAssembly()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-
-def SinglePhase_1DHeatedChannel():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=4.2;
- nx=50;
-
- # set the limit field for each boundary
-
- inletVelocityX=5;
- inletTemperature=565;
- outletPressure=155e5;
-
- # physical parameters
- heatPower=1e7;
-
- myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar;
-
- # constant vector
- VV_Constant[0] = outletPressure ;
- VV_Constant[1] = inletVelocityX;
- VV_Constant[2] = inletTemperature ;
-
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
-
- # set the boundary conditions
- myProblem.setInletBoundaryCondition("inlet",inletTemperature,inletVelocityX)
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup]);
-
- # set physical parameters
- myProblem.setHeatSource(heatPower);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setWellBalancedCorrection(True);
-
- # name of result file
- fileName = "1DHeatedChannelUpwindWB";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.95;
- maxTime = 500;
- precision = 1e-7;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_1DHeatedChannel()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def SinglePhase_1DRiemannProblem():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=4.2;
- nx=50;
- discontinuity=(xinf+xsup)/2
- M=cm.Mesh(xinf,xsup,nx)
- eps=1e-6
- M.setGroupAtPlan(xsup,0,eps,"RightBoundary")
- M.setGroupAtPlan(xinf,0,eps,"LeftBoundary")
-
- # set the limit field for each boundary
-
- initialVelocity_Left=1;
- initialTemperature_Left=565;
- initialPressure_Left=155e5;
-
- initialVelocity_Right=1;
- initialTemperature_Right=565;
- initialPressure_Right=150e5;
-
- myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Left =cm.Vector(nVar)
- VV_Right =cm.Vector(nVar)
-
- # left and right constant vectors
- VV_Left[0] = initialPressure_Left;
- VV_Left[1] = initialVelocity_Left;
- VV_Left[2] = initialTemperature_Left ;
-
- VV_Right[0] = initialPressure_Right;
- VV_Right[1] = initialVelocity_Right;
- VV_Right[2] = initialTemperature_Right ;
-
-
- #Initial field creation
- print("Building initial data " );
- myProblem.setInitialFieldStepFunction(M,VV_Left,VV_Right,discontinuity);
-
- # set the boundary conditions
- myProblem.setNeumannBoundaryCondition("LeftBoundary");
- myProblem.setNeumannBoundaryCondition("RightBoundary");
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
-
- # name of result file
- fileName = "1DRiemannProblem";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.95;
- maxTime = 500;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.usePrimitiveVarsInNewton(True)
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_1DRiemannProblem()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def SinglePhase_1DWaterHammer():
-
- spaceDim = 1;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=4.2;
- nx=50;
- M=cm.Mesh(xinf,xsup,nx)
-
- # set the initial field
-
- initialPressure=155e5;
- initialVelocityX=-5;
- initialTemperature=573;
-
- # set the limit field for each boundary
-
- wallVelocityX=0;
- wallTemperature=573;
-
- myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar;
-
- # constant vector
- VV_Constant[0] = initialPressure ;
- VV_Constant[1] = initialVelocityX;
- VV_Constant[2] = initialTemperature ;
-
-
- #Initial field creation
- print("Building initial data" );
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"wall","neumann");
-
- # set the boundary conditions
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX);
- myProblem.setNeumannBoundaryCondition("neumann");
-
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
-
- # name of result file
- fileName = "1DSinglePhase_1DWaterHammer";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.95;
- maxTime = 500;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- #myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_1DWaterHammer()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-
-def SinglePhase_2BranchesHeatedChannels():
-
- spaceDim = 1;
- # Prepare for the mesh
- M=cm.Mesh("../resources/BifurcatingFlow2BranchesEqualSections.med")
- M.getFace(0).setGroupName("Inlet")#z=0
- M.getFace(31).setGroupName("Outlet")#z=4.2
-
- # set the initial field
- initialPressure=155e5;
- initialVelocityX=5;
- initialTemperature=573;
-
- # set the limit field for each boundary
- inletVelocityX=5;
- inletTemperature=573;
- outletPressure=155e5
-
- myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar;
-
- # constant vector
- VV_Constant[0] = initialPressure ;
- VV_Constant[1] = initialVelocityX;
- VV_Constant[2] = initialTemperature ;
-
-
- #Initial field creation
- print("Building initial data" );
- myProblem.setInitialFieldConstant( M, VV_Constant);
-
- # set the boundary conditions
- myProblem.setInletBoundaryCondition("Inlet", inletTemperature, inletVelocityX);
- myProblem.setOutletBoundaryCondition("Outlet",outletPressure);
-
- #set porosity, heat and gravity source
- Sections=cm.Field("../resources/BifurcatingFlow2BranchesEqualSections", cm.CELLS,"Section area");
- heatPowerField=cm.Field("../resources/BifurcatingFlow2BranchesEqualSections", cm.CELLS,"Heat power");
-
- heatPowerField.writeVTK("heatPowerField");
- Sections.writeVTK("crossSectionPowerField");
-
- myProblem.setSectionField(Sections);
- myProblem.setHeatPowerField(heatPowerField)
- gravite=[-10]
- myProblem.setGravity(gravite)
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setWellBalancedCorrection(True)
-
- # name of result file
- fileName = "2BranchesHeatedChannels";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.95;
- maxTime = 500;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- #myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_2BranchesHeatedChannels()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-
-def SinglePhase_2DHeatedChannelInclined():
- spaceDim = 2;
-
- # Prepare the mesh data
- xinf = 0 ;
- xsup=3.0;
- yinf=0.0;
- ysup=5.0;
- nx=50;
- ny=50;
-
- # set the limit field for each boundary
- wallVelocityX=0;
- wallVelocityY=0;
- wallTemperature=573;
- inletVelocityX=0;
- inletVelocityY=0.5;
- inletTemperature=563;
- outletPressure=155e5;
-
- # physical constants
- gravite = [0] * spaceDim
-
- gravite[1]=-7;
- gravite[0]=7;
-
- heatPower=1e8;
-
- myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =[0]*nVar
-
- # constant vector
- VV_Constant[0] = outletPressure ;
- VV_Constant[1] = inletVelocityX;
- VV_Constant[2] = inletVelocityY;
- VV_Constant[3] = inletTemperature ;
-
- #Initial field creation
- print("Building mesh and initial data" );
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
- xinf,xsup,nx,"wall","wall",
- yinf,ysup,ny,"inlet","outlet",
- 0.0,0.0, 0, "", "")
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
- myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
- # set physical parameters
-
- myProblem.setHeatSource(heatPower);
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
- myProblem.setWellBalancedCorrection(False);
-
- # name file save
- fileName = "2DInclinedHeatedChannel";
-
- # parameters calculation
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.5;
- maxTime = 5000;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_2DHeatedChannelInclined()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-
-import CoreFlows as cf
-
-def SinglePhase_2DLidDrivenCavity():
-
- spaceDim = 2;
- #Preprocessing: mesh data
- xinf=0;
- xsup=1;
- yinf=0;
- ysup=1;
-
- nx=50;
- ny=50;
-
- # set the limit field for each boundary
-
- fixedWallVelocityX=0;
- fixedWallVelocityY=0;
- fixedWallTemperature=273;
-
- movingWallVelocityX=1;
- movingWallVelocityY=0;
- movingWallTemperature=273;
-
- # physical constants
-
- viscosite=[0.025];
-
- myProblem = cf.SinglePhase(cf.Gas,cf.around1bar300K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- #Initial field creation
- print("Building initial data " );
-
- # Prepare for the initial condition
-
- VV_Constant = [0] * nVar
-
- # constant vector
- VV_Constant[0] = 1e5;
- VV_Constant[1] = 0 ;
- VV_Constant[2] = 0;
- VV_Constant[3] = 273;
-
- #Initial field creation
- print("Building mesh and initial data" );
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"fixedWall","fixedWall",yinf,ysup,ny,"fixedWall","movingWall");
-
- # Set the boundary conditions
- myProblem.setWallBoundaryCondition("fixedWall", fixedWallTemperature, fixedWallVelocityX, fixedWallVelocityY);
- myProblem.setWallBoundaryCondition("movingWall", movingWallTemperature, movingWallVelocityX, movingWallVelocityY);
-
- # set physical parameters
- myProblem.setViscosity(viscosite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
- myProblem.setLinearSolver(cf.GMRES,cf.LU,True);
-
- # name file save
- fileName = "2DLidDrivenCavity";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 10;
- maxTime = 50;
- precision = 1e-9;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(float('inf'),20);
- myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-
-if __name__ == """__main__""":
- SinglePhase_2DLidDrivenCavity()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-
-import CoreFlows as cf
-
-def SinglePhase_2DLidDrivenCavity_unstructured():
- spaceDim = 2;
-
- print( "Loading unstructured mesh " );
- inputfile="../resources/BoxWithMeshWithTriangularCells.med";
-
- # set the limit field for each boundary
-
- fixedWallVelocityX=0;
- fixedWallVelocityY=0;
- fixedWallTemperature=273;
-
- movingWallVelocityX=1;
- movingWallVelocityY=0;
- movingWallTemperature=273;
-
- # physical constants
-
- viscosite=[0.025];
-
- myProblem = cf.SinglePhase(cf.Gas,cf.around1bar300K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- #Initial field creation
- print("Building initial data " );
-
- # Prepare for the initial condition
-
- VV_Constant = [0] * nVar
-
- # constant vector
- VV_Constant[0] = 1e5;
- VV_Constant[1] = 0 ;
- VV_Constant[2] = 0;
- VV_Constant[3] = 273;
-
- #Initial field creation
- print("Setting mesh and initial data" );
- myProblem.setInitialFieldConstant(inputfile,VV_Constant);
-
- # Set the boundary conditions
- myProblem.setWallBoundaryCondition("BAS", fixedWallTemperature, fixedWallVelocityX, fixedWallVelocityY);
- myProblem.setWallBoundaryCondition("GAUCHE", fixedWallTemperature, fixedWallVelocityX, fixedWallVelocityY);
- myProblem.setWallBoundaryCondition("DROITE", fixedWallTemperature, fixedWallVelocityX, fixedWallVelocityY);
- myProblem.setWallBoundaryCondition("HAUT", movingWallTemperature, movingWallVelocityX, movingWallVelocityY);
-
- # set physical parameters
- myProblem.setViscosity(viscosite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.pressureCorrection, cf.Implicit);
- myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
-
- # name file save
- fileName = "2DLidDrivenCavityUnstructured";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 10;
- maxTime = 50;
- precision = 1e-9;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_2DLidDrivenCavity_unstructured()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-
-
-
-def SinglePhase_2DSphericalExplosion_unstructured():
-
- inputfile="../resources/BoxWithMeshWithTriangularCells";
- fieldName="Initial variables for spherical explosion";
- spaceDim=2
-
- myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
- nVar=myProblem.getNumberOfVariables();
-
- # Initial field creation
- print ("Loading unstructured mesh and initial data for test SinglePhase_2DSphericalExplosion_unstructured()" ) ;
- myProblem.setInitialField(inputfile,fieldName,0);
-
- # set the boundary conditions
- wallVelocityX=0;
- wallVelocityY=0;
- wallTemperature=563;
-
- myProblem.setWallBoundaryCondition("GAUCHE", wallTemperature, wallVelocityX, wallVelocityY);
- myProblem.setWallBoundaryCondition("DROITE", wallTemperature, wallVelocityX, wallVelocityY);
- myProblem.setWallBoundaryCondition("HAUT", wallTemperature, wallVelocityX, wallVelocityY);
- myProblem.setWallBoundaryCondition("BAS", wallTemperature, wallVelocityX, wallVelocityY);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
- myProblem.setEntropicCorrection(False);
- myProblem.setWellBalancedCorrection(False);
-
- # name file save
- fileName = "2DSphericalExplosion_unstructured";
-
- # parameters calculation
- MaxNbOfTimeStep = 3 ;
- freqSave = 5;
- cfl = 0.5;
- maxTime = 5;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_2DSphericalExplosion_unstructured()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-
-import CoreFlows as cf
-import cdmath as cm
-import math
-
-def SinglePhase_2DThermalDiffusion():
- spaceDim = 2;
-
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=0.2;
- yinf=0.0;
- ysup=0.4;
- nx=10;
- ny=20;
- discontinuity=(xinf+xsup)/2
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"RightWall")
- M.setGroupAtPlan(xinf,0,eps,"LeftWall")
- M.setGroupAtPlan(ysup,1,eps,"outlet")
- dx=(xsup-xinf)/nx
- ndis=(discontinuity-xinf)/dx
- print("ndis=",math.floor(ndis) );
- i=0
- while i<= ndis:
- M.setGroupAtFaceByCoords(xinf+(i+0.5)*dx,yinf,0,eps,"inlet_1")
- i=i+1
- while i<= nx:
- M.setGroupAtFaceByCoords(xinf+(i+0.5)*dx,yinf,0,eps,"inlet_2")
- i=i+1
-
-
- # set the limit field for each boundary
- inletVelocityX=0;
- inletVelocityY=1;
- inletTemperature1=563;
- inletTemperature2=593;
- outletPressure=155e5;
-
- viscosite= [1.5];
- conductivite=[5000];
-
- myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant_Left =cm.Vector(nVar)
- VV_Constant_Right =cm.Vector(nVar)
-
- # constant vectors
- VV_Constant_Left[0] = outletPressure ;
- VV_Constant_Left[1] = inletVelocityX;
- VV_Constant_Left[2] = inletVelocityY;
- VV_Constant_Left[3] = inletTemperature1 ;
-
- VV_Constant_Right[0] = outletPressure ;
- VV_Constant_Right[1] = inletVelocityX;
- VV_Constant_Right[2] = inletVelocityY;
- VV_Constant_Right[3] = inletTemperature2 ;
-
- print("Building initial data" );
- myProblem.setInitialFieldStepFunction(M,VV_Constant_Left,VV_Constant_Right,discontinuity)
-
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure);
- myProblem.setInletBoundaryCondition("inlet_1", inletTemperature1, inletVelocityX, inletVelocityY);
- myProblem.setInletBoundaryCondition("inlet_2", inletTemperature2, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("LeftWall", inletTemperature1, 0,0);
- myProblem.setWallBoundaryCondition("RightWall", inletTemperature2, 0,0);
-
-
- myProblem.setViscosity(viscosite);
- myProblem.setConductivity(conductivite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
-
- # name file save
- fileName = "2DThermalDiffusion";
-
- # parameters calculation
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = .01;
- maxTime = 5000;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveVelocity();
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_2DThermalDiffusion()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def SinglePhase_2DVidangeReservoir():
-
- spaceDim = 2;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=1.0;
- yinf=0.0;
- ysup=1.0;
- nx=50;
- ny=50;
- diametreSortie=(ysup-yinf)/10.#10 percent of the height
- nsortie=ny*diametreSortie/(ysup-yinf)
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xinf,0,eps,"wall")
- M.setGroupAtPlan(ysup,1,eps,"inlet")
- M.setGroupAtPlan(yinf,1,eps,"wall")
- dy=(ysup-yinf)/ny
- i=0
- while i < nsortie:
- M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"outlet")
- i=i+1
- while i < ny:
- M.setGroupAtFaceByCoords(xsup,yinf+(i+0.5)*dy,0,eps,"wall")
- i=i+1
-
-
-
- # set the limit field for each boundary
- wallVelocityX=0;
- wallVelocityY=0;
- wallTemperature=300;
- inletTemperature=300;
- outletPressure=1e5;
-
- # set the limit field for each boundary
- initialVelocityX=0;
- initialVelocityY=0;
- initialTemperature=300;
- initialPressure=1e5;
-
- # physical constants
- gravite = [0] * spaceDim
-
- gravite[0]=0;
- gravite[1]=-10;
-
- myProblem = cf.SinglePhase(cf.Liquid,cf.around1bar300K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
- # Prepare for the initial condition
- VV_constant =cm.Vector(nVar)
-
- # constant vector
- VV_constant[0] = initialPressure ;
- VV_constant[1] = initialVelocityX;
- VV_constant[2] = initialVelocityY;
- VV_constant[3] = initialTemperature ;
-
-
- #Initial field creation
- print("Building initial data" );
- myProblem.setInitialFieldConstant( M, VV_constant)
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
- myProblem.setInletPressureBoundaryCondition("inlet", outletPressure, inletTemperature,[xsup,yinf]);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- # set physical parameters
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
-
- # name file save
- fileName = "2DVidangeReservoir";
-
- # parameters calculation
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = .05;
- maxTime = 5000;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveVelocity();
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_2DVidangeReservoir()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath as cm
-
-def SinglePhase_2DWallHeatedChannel_ChangeSect():
-
- #import themesh
- print("Reading a mesh with sudden cross-section change for test SinglePhase_2DWallHeatedChannel_ChangeSect()")
- M=cm.Mesh("../resources/VaryingSectionDuct.med")
-
- # Prepare the mesh boundaries
- xinf=0.0;
- xsup=0.01;
- yinf=0.0;
- ysup=0.01;
- eps=1.E-6;
- M.setGroupAtPlan(xsup,0,eps,"Wall");
- M.setGroupAtPlan(xinf,0,eps,"Wall");
- M.setGroupAtPlan(yinf,1,eps,"Inlet");
- M.setGroupAtPlan(ysup,1,eps,"Outlet");
-
- #Nombre de cellules utilisees au depart dans Salome ou Alamos
- nx=60
- ny=60
- #taille d'une cellule
- dx = (xsup-xinf)/nx
- dy = (ysup-yinf)/ny;
- for i in range(ny/2):
- M.setGroupAtFaceByCoords((xsup-xinf)/4,(ysup-yinf)/4+(i+0.5)*dy,0,eps,"Wall");#Paroi verticale intérieure gauche
- M.setGroupAtFaceByCoords((xsup-xinf)*3/4,(ysup-yinf)/4+(i+0.5)*dy,0,eps,"Wall");#Paroi verticale intérieure droitee
-
- for i in range(nx/4):
- M.setGroupAtFaceByCoords((i+0.5)*dx,(ysup-yinf)/4,0,eps,"Wall");#paroi horizontale en bas à gauche
- M.setGroupAtFaceByCoords((i+0.5)*dx,(ysup-yinf)*3/4,0,eps,"Wall");#paroi horizontale en haut à gauche
- M.setGroupAtFaceByCoords((xsup-xinf)*3/4+(i+0.5)*dx,(ysup-yinf)/4,0,eps,"Wall");#paroi horizontale en bas à droite
- M.setGroupAtFaceByCoords((xsup-xinf)*3/4+(i+0.5)*dx,(ysup-yinf)*3/4,0,eps,"Wall");#paroi horizontale en haut à droite
-
- spaceDim = M.getSpaceDimension();
-
- # set the limit field for each boundary
- wallVelocityX=0;
- wallVelocityY=0;
- wallTemperature=623;
- inletVelocityX=0;
- inletVelocityY=2.5;
- inletTemperature=563;
- outletPressure=155e5;
-
- # physical constants
- viscosite=[8.85e-5]
- conductivite=[1000]
-
- myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
- nVar =myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant =cm.Vector(nVar)
-
- # constant vector
- VV_Constant[0] = outletPressure ;
- VV_Constant[1] = inletVelocityX;
- VV_Constant[2] = inletVelocityY;
- VV_Constant[3] = inletTemperature ;
-
- #Initial field creation
- print("Building mesh and initial data" );
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- # the boundary conditions
- myProblem.setOutletBoundaryCondition("Outlet", outletPressure,[xsup,ysup]);
- myProblem.setInletBoundaryCondition("Inlet", inletTemperature, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("Wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- # set physical parameters
- myProblem.setViscosity(viscosite);
- myProblem.setConductivity(conductivite);
-
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
- myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
-
- # name file save
- fileName = "2DWallHeatedChannel_ChangeSect";
-
- # parameters calculation
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.5;
- maxTime = 5000;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(float('inf'),20);#newton precision should be infinite for staggered scheme!!!
- myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_2DWallHeatedChannel_ChangeSect()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-
-import CoreFlows as cf
-
-def SinglePhase_3DHeatDrivenCavity():
-
- spaceDim = 3;
- #Preprocessing: mesh data
- xinf=0;
- xsup=1;
- yinf=0;
- ysup=1;
- zinf=0;
- zsup=1;
-
- nx=10;
- ny=10;
- nz=10;
-
- # set the limit field for each boundary
-
- coldWallVelocityX=0;
- coldWallVelocityY=0;
- coldWallVelocityZ=0;
- coldWallTemperature=563;
-
- hotWallVelocityX=0;
- hotWallVelocityY=0;
- hotWallVelocityZ=0;
- hotWallTemperature=613;
-
- # physical constants
-
- gravite = [0] * spaceDim
- gravite[2]=-10;
- gravite[1]=0;
- gravite[0]=0;
- viscosite=[8.85e-5];
- conductivite=[1000];#Wall heat transfert due to nucleate boiling.
-
-
- myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- #Initial field creation
- print("Building initial data " );
-
- # Prepare for the initial condition
-
- VV_Constant = [0] * nVar
-
- # constant vector
- VV_Constant[0] = 155e5;
- VV_Constant[1] = 0 ;
- VV_Constant[2] = 0;
- VV_Constant[3] = 0;
- VV_Constant[4] = 573;
-
- #Initial field creation
- print("Setting mesh and initial data" );
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"hotWall","hotWall",yinf,ysup,ny,"hotWall","hotWall",zinf,zsup,nz, "hotWall", "coldWall");
-
- # Set the boundary conditions
- myProblem.setWallBoundaryCondition("coldWall", coldWallTemperature, coldWallVelocityX, coldWallVelocityY, coldWallVelocityZ);
- myProblem.setWallBoundaryCondition("hotWall", hotWallTemperature, hotWallVelocityX, hotWallVelocityY, hotWallVelocityZ);
-
- # set physical parameters
- myProblem.setViscosity(viscosite);
- myProblem.setConductivity(conductivite);
- myProblem.setGravity(gravite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
- myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
- myProblem.setEntropicCorrection(False);
- myProblem.setWellBalancedCorrection(False);
-
- # name file save
- fileName = "3DHeatDrivenCavity";
-
- # simulation parameters
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 10;
- maxTime = 50;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,50);
- myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_3DHeatDrivenCavity()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-import cdmath
-
-
-def SinglePhase_3DSphericalExplosion_unstructured():
-
- inputfile="../../resources/meshCube.med";
-
- xinf=0;
- xsup=1;
- yinf=0;
- ysup=1;
- zinf=0;
- zsup=1;
- M=cdmath.Mesh(inputfile);
- eps=1.E-6;
- M.setGroupAtPlan(xinf,0,eps,"GAUCHE");
- M.setGroupAtPlan(xsup,0,eps,"DROITE");
- M.setGroupAtPlan(yinf,1,eps,"ARRIERE");
- M.setGroupAtPlan(ysup,1,eps,"AVANT");
- M.setGroupAtPlan(zinf,2,eps,"BAS");
- M.setGroupAtPlan(zsup,2,eps,"HAUT");
-
- # Initial field data
- spaceDim = 3;
- nVar=2+spaceDim;
- radius=0.5;
- Center=cdmath.Vector(3);#default value is (0,0,0)
- Vout=cdmath.Vector(nVar)
- Vin =cdmath.Vector(nVar)
- Vin[0]=1.1;
- Vin[1]=0;
- Vin[2]=0;
- Vin[3]=0;
- Vin[4]=300;
- Vout[0]=1;
- Vout[1]=0;
- Vout[2]=0;
- Vout[3]=0;
- Vout[4]=300;
-
- myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
- nVar=myProblem.getNumberOfVariables();
-
- # Initial field creation
- print ("Setting mesh and initial data" ) ;
- myProblem.setInitialFieldSphericalStepFunction( M, Vout, Vin, radius, Center);
-
- # set the boundary conditions
- wallVelocityX=0;
- wallVelocityY=0;
- wallVelocityZ=0;
- wallTemperature=563;
-
- myProblem.setWallBoundaryCondition("GAUCHE", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
- myProblem.setWallBoundaryCondition("DROITE", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
- myProblem.setWallBoundaryCondition("HAUT", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
- myProblem.setWallBoundaryCondition("BAS", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
- myProblem.setWallBoundaryCondition("AVANT", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
- myProblem.setWallBoundaryCondition("ARRIERE", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
- myProblem.setEntropicCorrection(False);
- myProblem.setWellBalancedCorrection(False);
-
- # name file save
- fileName = "3DSphericalExplosion_unstructured";
-
- # parameters calculation
- MaxNbOfTimeStep = 3 ;
- freqSave = 1;
- cfl = 0.5;
- maxTime = 5;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_3DSphericalExplosion_unstructured()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-
-import CoreFlows as cf
-
-def SinglePhase_3DVortexTube_WithoutCone():
- spaceDim = 3;
-
- print( "Loading mesh of vortex tube without cone" );
- inputfile="../resources/VortexTubeWithoutCone.med";
-
- # set the limit field for each boundary
- outletPressure = 1e5;
- inletPressure = 10e5;
- inletTemperature = 300;
-
- # physical constants
- #viscosite=[0.025];
-
- myProblem = cf.SinglePhase(cf.Gas,cf.around1bar300K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- #Initial field creation
- print("Building initial data " );
-
- # Prepare for the initial condition
-
- VV_Constant = [0] * nVar
-
- # constant vector
- VV_Constant[0] = 1e5;
- VV_Constant[1] = 0 ;
- VV_Constant[2] = 0;
- VV_Constant[3] = 0;
- VV_Constant[4] = 300;
-
- #Initial field creation
- print("Setting mesh and initial data" );
- myProblem.setInitialFieldConstant(inputfile,VV_Constant);
-
- # Set the boundary conditions
- myProblem.setInletPressureBoundaryCondition("Inlet flow", inletPressure, inletTemperature,0,100,0)
- myProblem.setOutletBoundaryCondition("Hot outlet", outletPressure)
- myProblem.setOutletBoundaryCondition("Cold outlet", outletPressure)
- myProblem.setWallBoundaryCondition("Wall", inletTemperature)
-
- # set physical parameters
- #myProblem.setViscosity(viscosite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setNonLinearFormulation(cf.reducedRoe);
- myProblem.setEntropicCorrection(True)
- #myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
-
- # name file save
- fileName = "3DVortexTubeWithoutCone";
-
- # simulation parameters
- MaxNbOfTimeStep = 10000 ;
- freqSave = 100;
- cfl = 1./3;
- maxTime = 50;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- #myProblem.setNewtonSolver(precision,20);
- #yProblem.saveConservativeField(True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_3DVortexTube_WithoutCone()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-
-import CoreFlows as cf
-
-def SinglePhase_3DVortexTube_WithCone():
- spaceDim = 3;
-
- print( "Loading mesh of vortex tube with cone" );
- inputfile="../resources/VortexTubeWithCone.med";
-
- # set the limit field for each boundary
- outletPressure = 1.e5;
- inletPressure = 10.e5;
- inletTemperature = 300.;
-
- # physical constants
- #viscosite=[0.025];
-
- myProblem = cf.SinglePhase(cf.Gas,cf.around1bar300K,spaceDim);
- nVar = myProblem.getNumberOfVariables();
-
- #Initial field creation
- print("Building initial data " );
-
- # Prepare for the initial condition
-
- VV_Constant = [0] * nVar
-
- # constant vector
- VV_Constant[0] = 1.e5;
- VV_Constant[1] = 0 ;
- VV_Constant[2] = 0;
- VV_Constant[3] = 0;
- VV_Constant[4] = 300.;
-
- #Initial field creation
- print("Setting mesh and initial data" );
- myProblem.setInitialFieldConstant(inputfile,VV_Constant);
-
- # Set the boundary conditions
- myProblem.setInletPressureBoundaryCondition("Inlet flow", inletPressure, inletTemperature,0,100,0)
- myProblem.setOutletBoundaryCondition("Hot outlet", outletPressure)
- myProblem.setOutletBoundaryCondition("Cold outlet", outletPressure)
- myProblem.setWallBoundaryCondition("Wall", inletTemperature)
-
- # set physical parameters
- #myProblem.setViscosity(viscosite);
-
- # set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
- myProblem.setNonLinearFormulation(cf.reducedRoe);
- myProblem.setEntropicCorrection(False)
- #myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
-
- # name file save
- fileName = "3DVortexTubeWithCone";
-
- # simulation parameters
- MaxNbOfTimeStep = 100000 ;
- freqSave = 1;
- cfl = 0.3;
- maxTime = 50;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- #myProblem.setNewtonSolver(precision,20);
- #yProblem.saveConservativeField(True);
- #myProblem.setVerbose(False,True);
- if(spaceDim>1):
- myProblem.saveVelocity();
- pass
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- SinglePhase_3DVortexTube_WithCone()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+#===============================================================================================================================
+# Name : Résolution EF de l'équation de Poisson 2D -\triangle T = f avec conditions aux limites de Dirichlet T=0
+# Author : Michaël Ndjinga
+# Copyright : CEA Saclay 2019
+# Description : Utilisation de la méthode des éléménts finis P1 avec champs T et f discrétisés aux noeuds d'un maillage triangulaire
+# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant la librairie CDMATH
+# Comparaison de la solution numérique avec la solution exacte T=-sin(pi*x)*sin(pi*y)
+#================================================================================================================================
+
+import CoreFlows as cf
+import cdmath as cm
+from math import sin, pi
+
+def StationaryDiffusionEquation_2DEF_StructuredTriangles():
+ spaceDim = 2;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=1.0;
+ yinf=0.0;
+ ysup=1.0;
+ nx=20;
+ ny=20;
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny,0)#Regular triangular mesh
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1")
+ M.setGroupAtPlan(xinf,0,eps,"Bord2")
+ M.setGroupAtPlan(ysup,1,eps,"Bord3")
+ M.setGroupAtPlan(yinf,1,eps,"Bord4")
+
+ print "Built a regular triangular 2D mesh from a square mesh with ", nx,"x" ,ny, " cells"
+
+ FEComputation=True
+ myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ # set the limit value for each boundary
+ T1=0;
+ T2=0;
+ T3=0;
+ T4=0;
+
+ myProblem.setDirichletBoundaryCondition("Bord1",T1)
+ myProblem.setDirichletBoundaryCondition("Bord2",T2)
+ myProblem.setDirichletBoundaryCondition("Bord3",T3)
+ myProblem.setDirichletBoundaryCondition("Bord4",T4)
+
+ #Set the right hand side function
+ my_RHSfield = cm.Field("RHS_field", cm.NODES, M, 1)
+ for i in range(M.getNumberOfNodes()):
+ Ni= M.getNode(i)
+ x = Ni.x()
+ y = Ni.y()
+
+ my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)#mettre la fonction definie au second membre de l'edp
+
+ myProblem.setHeatPowerField(my_RHSfield)
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU);
+
+ # name of result file
+ fileName = "StationnaryDiffusion_2DEF_StructuredTriangles";
+
+ # computation parameters
+ myProblem.setFileName(fileName);
+
+ # Run the computation
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.solveStationaryProblem();
+ if (not ok):
+ print( "Python simulation of " + fileName + " failed ! " );
+ pass
+ else:
+ ####################### Postprocessing #########################
+ my_ResultField = myProblem.getOutputTemperatureField()
+ #The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi
+ max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi)
+ max_sol_num=my_ResultField.max()
+ min_sol_num=my_ResultField.min()
+ erreur_abs=0
+ for i in range(M.getNumberOfNodes()) :
+ if erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) :
+ erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i])
+
+ print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
+ print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
+ print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
+
+ assert erreur_abs/max_abs_sol_exacte <1.
+ pass
+
+ print( "------------ !!! End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ StationaryDiffusionEquation_2DEF_StructuredTriangles()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+#===============================================================================================================================
+# Name : Résolution EF de l'équation de Poisson 2D -\triangle T = f avec conditions aux limites de Neumann T=0
+# Author : Michaël Ndjinga
+# Copyright : CEA Saclay 2019
+# Description : Utilisation de la méthode des éléménts finis P1 avec champs T et f discrétisés aux noeuds d'un maillage triangulaire
+# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant la librairie CDMATH
+# Comparaison de la solution numérique avec la solution exacte T=-cos(pi*x)*cos(pi*y)
+#================================================================================================================================
+
+import CoreFlows as cf
+import cdmath as cm
+from math import cos, pi
+
+def StationaryDiffusionEquation_2DEF_StructuredTriangles_Neumann():
+ spaceDim = 2;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0.0;
+ xsup = 1.0;
+ yinf = 0.0;
+ ysup = 1.0;
+ nx=20;
+ ny=20;
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny,0)#Regular triangular mesh
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1")
+ M.setGroupAtPlan(xinf,0,eps,"Bord2")
+ M.setGroupAtPlan(ysup,1,eps,"Bord3")
+ M.setGroupAtPlan(yinf,1,eps,"Bord4")
+
+ print "Built a regular triangular 2D mesh from a square mesh with ", nx,"x" ,ny, " cells"
+
+ FEComputation=True
+ myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ # set the boundary condition for each boundary
+ myProblem.setNeumannBoundaryCondition("Bord1")
+ myProblem.setNeumannBoundaryCondition("Bord2")
+ myProblem.setNeumannBoundaryCondition("Bord3")
+ myProblem.setNeumannBoundaryCondition("Bord4")
+
+ #Set the right hand side function
+ my_RHSfield = cm.Field("RHS_field", cm.NODES, M, 1)
+ for i in range(M.getNumberOfNodes()):
+ Ni= M.getNode(i)
+ x = Ni.x()
+ y = Ni.y()
+
+ my_RHSfield[i]=2*pi*pi*cos(pi*x)*cos(pi*y)#mettre la fonction definie au second membre de l'edp
+
+ myProblem.setHeatPowerField(my_RHSfield)
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU);
+
+ # name of result file
+ fileName = "StationnaryDiffusion_2DEF_StructuredTriangles_Neumann";
+
+ # computation parameters
+ myProblem.setFileName(fileName);
+
+ # Run the computation
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.solveStationaryProblem();
+ if (not ok):
+ print( "Python simulation of " + fileName + " failed ! " );
+ pass
+ else:
+ ####################### Postprocessing #########################
+ my_ResultField = myProblem.getOutputTemperatureField()
+ #The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi
+ max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi)
+ max_sol_num=my_ResultField.max()
+ min_sol_num=my_ResultField.min()
+ erreur_abs=0
+ for i in range(M.getNumberOfNodes()) :
+ if erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) :
+ erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i])
+
+ print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
+ print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
+ print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
+
+ assert erreur_abs/max_abs_sol_exacte <1.
+ pass
+
+ print( "------------ !!! End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ StationaryDiffusionEquation_2DEF_StructuredTriangles_Neumann()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+#===============================================================================================================================
+# Name : Résolution VF de l'équation de Poisson 2D -\triangle T = f sur un carré avec conditions aux limites de Dirichlet T=0
+# Author : Michaël Ndjinga
+# Copyright : CEA Saclay 2019
+# Description : Utilisation de la méthode des volumes finis avec champs T et f discrétisés aux cellules d'un maillage de triangules équilatéraux
+# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant CDMATH
+# Comparaison de la solution numérique avec la solution exacte T=sin(pi*x)*sin(pi*y)
+#================================================================================================================================
+
+import CoreFlows as cf
+import cdmath as cm
+from math import sin, pi
+import os
+
+def StationaryDiffusionEquation_2DFV_EquilateralTriangles():
+ spaceDim = 2;
+ # Prepare for the mesh
+ print("Loading mesh " );
+ M=cm.Mesh(os.environ['CDMATH_INSTALL']+'/share/meshes/2DEquilateralTriangles/squareWithEquilateralTriangles20.med')#Equilateral triangular mesh
+
+ print( "Loaded 2D equilateral triangle mesh with ", M.getNumberOfCells(), " cells")
+
+ # set the limit field
+ boundaryFaces = M.getBoundaryFaceIds()
+ boundaryValues = {}
+ print("Setting Dirichlet boundary values")
+ for i in boundaryFaces :
+ Fi=M.getFace(i)
+ x=Fi.x()
+ y=Fi.y()
+ boundaryValues[i] = sin(pi*x)*sin(pi*y)
+
+ FEComputation=False
+ myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+ myProblem.setDirichletValues(cf.MapIntDouble(boundaryValues))
+
+ #Set the right hand side function
+ my_RHSfield = cm.Field("RHS_field", cm.CELLS, M, 1)
+ for i in range(M.getNumberOfCells()):
+ Ci= M.getCell(i)
+ x = Ci.x()
+ y = Ci.y()
+
+ my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)#mettre la fonction definie au second membre de l'edp
+
+ myProblem.setHeatPowerField(my_RHSfield)
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU);
+
+ # name of result file
+ fileName = "StationnaryDiffusion_2DFV_StructuredTriangles";
+
+ # computation parameters
+ myProblem.setFileName(fileName);
+
+ # Run the computation
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.solveStationaryProblem();
+ if (not ok):
+ print( "Python simulation of " + fileName + " failed ! " );
+ pass
+ else:
+ print( "Python simulation of " + fileName + " is successful !" );
+ ####################### Postprocessing #########################
+ my_ResultField = myProblem.getOutputTemperatureField()
+ #The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi
+ max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi)
+ max_sol_num=my_ResultField.max()
+ min_sol_num=my_ResultField.min()
+ erreur_abs=0
+ for i in range(M.getNumberOfCells()) :
+ if erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) :
+ erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i])
+
+ print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
+ print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
+ print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
+
+ assert erreur_abs/max_abs_sol_exacte <1.
+ pass
+
+ print( "------------ !!! End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ StationaryDiffusionEquation_2DFV_EquilateralTriangles()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+#===============================================================================================================================
+# Name : Résolution VF de l'équation de Poisson 2D -\triangle T = f sur un carré avec conditions aux limites de Dirichlet T=0
+# Author : Michaël Ndjinga
+# Copyright : CEA Saclay 2019
+# Description : Utilisation de la méthode des volumes finis avec champs T et f discrétisés aux cellules d'un maillage triangulaire
+# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant CDMATH
+# Comparaison de la solution numérique avec la solution exacte T=sin(pi*x)*sin(pi*y)
+#================================================================================================================================
+
+import CoreFlows as cf
+import cdmath as cm
+from math import sin, pi
+
+def StationaryDiffusionEquation_2DFV_StructuredSquares():
+ spaceDim = 2;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=1.0;
+ yinf=0.0;
+ ysup=1.0;
+ nx=30;
+ ny=30;
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)#Regular square mesh
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1")
+ M.setGroupAtPlan(xinf,0,eps,"Bord2")
+ M.setGroupAtPlan(ysup,1,eps,"Bord3")
+ M.setGroupAtPlan(yinf,1,eps,"Bord4")
+
+ print "Built a regular 2D square mesh with ", nx,"x" ,ny, " cells"
+
+ FEComputation=False
+ myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ # set the limit value for each boundary
+ T1=0;
+ T2=0;
+ T3=0;
+ T4=0;
+
+ myProblem.setDirichletBoundaryCondition("Bord1",T1)
+ myProblem.setDirichletBoundaryCondition("Bord2",T2)
+ myProblem.setDirichletBoundaryCondition("Bord3",T3)
+ myProblem.setDirichletBoundaryCondition("Bord4",T4)
+
+ #Set the right hand side function
+ my_RHSfield = cm.Field("RHS_field", cm.CELLS, M, 1)
+ for i in range(M.getNumberOfCells()):
+ Ci= M.getCell(i)
+ x = Ci.x()
+ y = Ci.y()
+
+ my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)#mettre la fonction definie au second membre de l'edp
+
+ myProblem.setHeatPowerField(my_RHSfield)
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU);
+
+ # name of result file
+ fileName = "StationnaryDiffusion_2DFV_StructuredSquares";
+
+ # computation parameters
+ myProblem.setFileName(fileName);
+
+ # Run the computation
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.solveStationaryProblem();
+ if (not ok):
+ print( "Python simulation of " + fileName + " failed ! " );
+ pass
+ else:
+ print( "Python simulation of " + fileName + " is successful !" );
+ ####################### Postprocessing #########################
+ my_ResultField = myProblem.getOutputTemperatureField()
+ #The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi
+ max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi)
+ max_sol_num=my_ResultField.max()
+ min_sol_num=my_ResultField.min()
+ erreur_abs=0
+ for i in range(M.getNumberOfCells()) :
+ if erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) :
+ erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i])
+
+ print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
+ print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
+ print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
+
+ assert erreur_abs/max_abs_sol_exacte <1.
+ pass
+
+ print( "------------ !!! End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ StationaryDiffusionEquation_2DFV_StructuredSquares()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+#===============================================================================================================================
+# Name : Résolution VF de l'équation de Poisson 2D -\triangle T = f sur un carré avec conditions aux limites de Neumann T=0
+# Author : Michaël Ndjinga
+# Copyright : CEA Saclay 2019
+# Description : Utilisation de la méthode des volumes finis avec champs T et f discrétisés aux cellules d'un maillage triangulaire
+# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant CDMATH
+# Comparaison de la solution numérique avec la solution exacte T=cos(pi*x)*cos(pi*y)
+#================================================================================================================================
+
+import CoreFlows as cf
+import cdmath as cm
+from math import cos, pi
+
+def StationaryDiffusionEquation_2DFV_StructuredSquares_Neumann():
+ spaceDim = 2;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0.0;
+ xsup = 1.0;
+ yinf = 0.0;
+ ysup = 1.0;
+ nx=30;
+ ny=30;
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)#Regular square mesh
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1")
+ M.setGroupAtPlan(xinf,0,eps,"Bord2")
+ M.setGroupAtPlan(ysup,1,eps,"Bord3")
+ M.setGroupAtPlan(yinf,1,eps,"Bord4")
+
+ print "Built a regular 2D square mesh with ", nx,"x" ,ny, " cells"
+
+ FEComputation=False
+ myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ # set the limit value for each boundary
+ T1=0;
+ T2=0;
+ T3=0;
+ T4=0;
+
+ myProblem.setNeumannBoundaryCondition("Bord1")
+ myProblem.setNeumannBoundaryCondition("Bord2")
+ myProblem.setNeumannBoundaryCondition("Bord3")
+ myProblem.setNeumannBoundaryCondition("Bord4")
+
+ #Set the right hand side function
+ my_RHSfield = cm.Field("RHS_field", cm.CELLS, M, 1)
+ for i in range(M.getNumberOfCells()):
+ Ci= M.getCell(i)
+ x = Ci.x()
+ y = Ci.y()
+
+ my_RHSfield[i]=2*pi*pi*cos(pi*x)*cos(pi*y)#mettre la fonction definie au second membre de l'edp
+
+ myProblem.setHeatPowerField(my_RHSfield)
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU);
+
+ # name of result file
+ fileName = "StationnaryDiffusion_2DFV_StructuredSquares_Neumann";
+
+ # computation parameters
+ myProblem.setFileName(fileName);
+
+ # Run the computation
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.solveStationaryProblem();
+ if (not ok):
+ print( "Python simulation of " + fileName + " failed ! " );
+ pass
+ else:
+ print( "Python simulation of " + fileName + " is successful !" );
+ ####################### Postprocessing #########################
+ my_ResultField = myProblem.getOutputTemperatureField()
+ #The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi
+ max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi)
+ max_sol_num=my_ResultField.max()
+ min_sol_num=my_ResultField.min()
+ erreur_abs=0
+ for i in range(M.getNumberOfCells()) :
+ if erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) :
+ erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i])
+
+ print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
+ print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
+ print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
+
+ assert erreur_abs/max_abs_sol_exacte <1.
+ pass
+
+ print( "------------ !!! End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ StationaryDiffusionEquation_2DFV_StructuredSquares_Neumann()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+#===============================================================================================================================
+# Name : Résolution VF de l'équation de Poisson 2D -\triangle T = f sur un carré avec conditions aux limites de Dirichlet T=0
+# Author : Michaël Ndjinga
+# Copyright : CEA Saclay 2019
+# Description : Utilisation de la méthode des volumes finis avec champs T et f discrétisés aux cellules d'un maillage triangulaire
+# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant CDMATH
+# Comparaison de la solution numérique avec la solution exacte T=sin(pi*x)*sin(pi*y)
+#================================================================================================================================
+
+import CoreFlows as cf
+import cdmath as cm
+from math import sin, pi
+
+def StationaryDiffusionEquation_2DFV_StructuredTriangles():
+ spaceDim = 2;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup=1.0;
+ yinf=0.0;
+ ysup=1.0;
+ nx=20;
+ ny=20;
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny,0)#Regular triangular mesh
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1")
+ M.setGroupAtPlan(xinf,0,eps,"Bord2")
+ M.setGroupAtPlan(ysup,1,eps,"Bord3")
+ M.setGroupAtPlan(yinf,1,eps,"Bord4")
+
+ print "Built a regular triangular 2D mesh from a square mesh with ", nx,"x" ,ny, " cells"
+
+ FEComputation=False
+ myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ # set the limit value for each boundary
+ T1=0;
+ T2=0;
+ T3=0;
+ T4=0;
+
+ myProblem.setDirichletBoundaryCondition("Bord1",T1)
+ myProblem.setDirichletBoundaryCondition("Bord2",T2)
+ myProblem.setDirichletBoundaryCondition("Bord3",T3)
+ myProblem.setDirichletBoundaryCondition("Bord4",T4)
+
+ #Set the right hand side function
+ my_RHSfield = cm.Field("RHS_field", cm.CELLS, M, 1)
+ for i in range(M.getNumberOfCells()):
+ Ci= M.getCell(i)
+ x = Ci.x()
+ y = Ci.y()
+
+ my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)#mettre la fonction definie au second membre de l'edp
+
+ myProblem.setHeatPowerField(my_RHSfield)
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU);
+
+ # name of result file
+ fileName = "StationnaryDiffusion_2DFV_StructuredTriangles";
+
+ # computation parameters
+ myProblem.setFileName(fileName);
+
+ # Run the computation
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.solveStationaryProblem();
+ if (not ok):
+ print( "Python simulation of " + fileName + " failed ! " );
+ pass
+ else:
+ print( "Python simulation of " + fileName + " is successful !" );
+ ####################### Postprocessing #########################
+ my_ResultField = myProblem.getOutputTemperatureField()
+ #The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi
+ max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi)
+ max_sol_num=my_ResultField.max()
+ min_sol_num=my_ResultField.min()
+ erreur_abs=0
+ for i in range(M.getNumberOfCells()) :
+ if erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) :
+ erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i])
+
+ print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
+ print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
+ print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
+
+ assert erreur_abs/max_abs_sol_exacte <1.
+ pass
+
+ print( "------------ !!! End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ StationaryDiffusionEquation_2DFV_StructuredTriangles()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+#===============================================================================================================================
+# Name : Résolution EF de l'équation de Poisson 3D -\triangle T = f avec conditions aux limites de Dirichlet T=0
+# Author : Michaël Ndjinga
+# Copyright : CEA Saclay 2019
+# Description : Utilisation de la méthode des éléménts finis P1 avec champs T et f discrétisés aux noeuds d'un maillage tétraédrique
+# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant la librairie CDMATH
+# Comparaison de la solution numérique avec la solution exacte T=-sin(pi*x)*sin(pi*y)*sin(pi*z)
+#================================================================================================================================
+
+import CoreFlows as cf
+import cdmath as cm
+from math import sin, pi
+
+def StationaryDiffusionEquation_3DEF_StructuredTriangles():
+ spaceDim = 3;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0.0;
+ xsup = 1.0;
+ yinf = 0.0;
+ ysup = 1.0;
+ zinf = 0.0;
+ zsup = 1.0;
+ nx = 5;
+ ny = 5;
+ nz = 5;
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz,1)#Regular tetrahedral mesh
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1")
+ M.setGroupAtPlan(xinf,0,eps,"Bord2")
+ M.setGroupAtPlan(ysup,1,eps,"Bord3")
+ M.setGroupAtPlan(yinf,1,eps,"Bord4")
+ M.setGroupAtPlan(zsup,2,eps,"Bord5")
+ M.setGroupAtPlan(zinf,2,eps,"Bord6")
+
+ print "Built a regular tetrahedra 3D mesh from a cube mesh with ", nx,"x" ,ny,"x" ,nz, " cells"
+
+ FEComputation=True
+ myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ # set the limit value for each boundary
+ T1=0;
+ T2=0;
+ T3=0;
+ T4=0;
+ T5=0;
+ T6=0;
+
+ myProblem.setDirichletBoundaryCondition("Bord1",T1)
+ myProblem.setDirichletBoundaryCondition("Bord2",T2)
+ myProblem.setDirichletBoundaryCondition("Bord3",T3)
+ myProblem.setDirichletBoundaryCondition("Bord4",T4)
+ myProblem.setDirichletBoundaryCondition("Bord5",T5)
+ myProblem.setDirichletBoundaryCondition("Bord6",T6)
+
+ #Set the right hand side function
+ my_RHSfield = cm.Field("RHS_field", cm.NODES, M, 1)
+ for i in range(M.getNumberOfNodes()):
+ Ni= M.getNode(i)
+ x = Ni.x()
+ y = Ni.y()
+ z = Ni.z()
+
+ my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)*sin(pi*z)#mettre la fonction definie au second membre de l'edp
+
+ myProblem.setHeatPowerField(my_RHSfield)
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU);
+
+ # name of result file
+ fileName = "StationnaryDiffusion_3DEF_StructuredTriangles";
+
+ # computation parameters
+ myProblem.setFileName(fileName);
+
+ # Run the computation
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.solveStationaryProblem();
+ if (not ok):
+ print( "Python simulation of " + fileName + " failed ! " );
+ pass
+ else:
+ ####################### Postprocessing #########################
+ my_ResultField = myProblem.getOutputTemperatureField()
+ #The following formulas use the fact that the exact solution is equal the right hand side divided by 3*pi*pi
+ max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(3*pi*pi)
+ max_sol_num=my_ResultField.max()
+ min_sol_num=my_ResultField.min()
+ erreur_abs=0
+ for i in range(M.getNumberOfNodes()) :
+ if erreur_abs < abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i]) :
+ erreur_abs = abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i])
+
+ print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
+ print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
+ print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
+
+ assert erreur_abs/max_abs_sol_exacte <1.
+ pass
+
+ print( "------------ !!! End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ StationaryDiffusionEquation_3DEF_StructuredTriangles()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+#===============================================================================================================================
+# Name : Résolution EF de l'équation de Laplace 3D -\Delta T = 0 avec conditions aux limites de Dirichlet u non nulle (fenetre et radiateur)
+# Authors : Michaël Ndjinga, Sédrick Kameni Ngwamou
+# Copyright : CEA Saclay 2019
+# Description : Utilisation de la méthode des éléménts finis P1 avec champs u discrétisés aux noeuds d'un maillage tétraédrique
+# Condition limites correspondant au refroidissement dû à une fenêtre et au chauffage dû à un radiateur
+# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant la librairie CDMATH
+#================================================================================================================================
+
+import CoreFlows as cf
+import cdmath
+
+def StationaryDiffusionEquation_3DEF_RoomCooling():
+ spaceDim = 3;
+
+ #Chargement du maillage tétraédrique du domaine
+ #==============================================
+ my_mesh = cdmath.Mesh("../resources/RoomWithTetras2488.med")
+
+ print "Loaded unstructured 3D mesh"
+
+ #Conditions limites
+ Tmur=20
+ Tfenetre=0
+ Tradiateur=40
+
+ FEComputation=True
+ myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
+ myProblem.setMesh(my_mesh);
+
+ myProblem.setDirichletBoundaryCondition("Fenetre",Tfenetre)
+ myProblem.setDirichletBoundaryCondition("Radiateur_sous_fenetre",Tradiateur)
+ myProblem.setDirichletBoundaryCondition("Radiateur_Devant",Tmur)
+ myProblem.setDirichletBoundaryCondition("Radiateur_droit",Tmur)
+ myProblem.setDirichletBoundaryCondition("Murs",Tmur)
+
+ # name of result file
+ fileName = "StationnaryDiffusion_3DEF_UnstructuredTetrahedra";
+
+ # computation parameters
+ myProblem.setFileName(fileName);
+
+ # Run the computation
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.solveStationaryProblem();
+ if (not ok):
+ print( "Python simulation of " + fileName + " failed ! " );
+ pass
+ else:
+ print( "Python simulation of " + fileName + " successful ! " );
+ pass
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ StationaryDiffusionEquation_3DEF_RoomCooling()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+#===============================================================================================================================
+# Name : Résolution VF de l'équation de Poisson 3D -\triangle T = f sur un cube avec conditions aux limites de Dirichlet T=0
+# Author : Michaël Ndjinga
+# Copyright : CEA Saclay 2019
+# Description : Utilisation de la méthode des volumes finis avec champs T et f discrétisés aux cellules d'un maillage de cubes
+# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant CDMATH
+# Comparaison de la solution numérique avec la solution exacte T=sin(pi*x)*sin(pi*y)*sin(pi*z)
+#================================================================================================================================
+
+import CoreFlows as cf
+import cdmath as cm
+from math import sin, pi
+
+def StationaryDiffusionEquation_3DFV_StructuredCubes():
+ spaceDim = 3;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup = 1.0;
+ yinf = 0.0;
+ ysup = 1.0;
+ zinf = 0.0;
+ zsup = 1.0;
+ nx = 20;
+ ny = 20;
+ nz = 20;
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz)#Regular cube mesh
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1")
+ M.setGroupAtPlan(xinf,0,eps,"Bord2")
+ M.setGroupAtPlan(ysup,1,eps,"Bord3")
+ M.setGroupAtPlan(yinf,1,eps,"Bord4")
+ M.setGroupAtPlan(zsup,2,eps,"Bord5")
+ M.setGroupAtPlan(zinf,2,eps,"Bord6")
+
+ print "Built a regular 3D cube mesh with ", nx,"x" ,ny,"x" ,nz, " cells"
+
+ FEComputation=False
+ myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ # set the limit value for each boundary
+ T1=0;
+ T2=0;
+ T3=0;
+ T4=0;
+ T5=0;
+ T6=0;
+
+ myProblem.setDirichletBoundaryCondition("Bord1",T1)
+ myProblem.setDirichletBoundaryCondition("Bord2",T2)
+ myProblem.setDirichletBoundaryCondition("Bord3",T3)
+ myProblem.setDirichletBoundaryCondition("Bord4",T4)
+ myProblem.setDirichletBoundaryCondition("Bord5",T5)
+ myProblem.setDirichletBoundaryCondition("Bord6",T6)
+
+ #Set the right hand side function
+ my_RHSfield = cm.Field("RHS_field", cm.CELLS, M, 1)
+ for i in range(M.getNumberOfCells()):
+ Ci= M.getCell(i)
+ x = Ci.x()
+ y = Ci.y()
+ z = Ci.z()
+
+ my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)*sin(pi*z)#mettre la fonction definie au second membre de l'edp
+
+ myProblem.setHeatPowerField(my_RHSfield)
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU);
+
+ # name of result file
+ fileName = "StationaryDiffusion_3DFV_StructuredCubes";
+
+ # computation parameters
+ myProblem.setFileName(fileName);
+
+ # Run the computation
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.solveStationaryProblem();
+ if (not ok):
+ print( "Python simulation of " + fileName + " failed ! " );
+ pass
+ else:
+ print( "Python simulation of " + fileName + " is successful !" );
+ ####################### Postprocessing #########################
+ my_ResultField = myProblem.getOutputTemperatureField()
+ #The following formulas use the fact that the exact solution is equal the right hand side divided by 3*pi*pi
+ max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(3*pi*pi)
+ max_sol_num=my_ResultField.max()
+ min_sol_num=my_ResultField.min()
+ erreur_abs=0
+ for i in range(M.getNumberOfCells()) :
+ if erreur_abs < abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i]) :
+ erreur_abs = abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i])
+
+ print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
+ print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
+ print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
+
+ assert erreur_abs/max_abs_sol_exacte <1.
+ pass
+
+ print( "------------ !!! End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ StationaryDiffusionEquation_3DFV_StructuredCubes()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+#===============================================================================================================================
+# Name : Résolution VF de l'équation de Poisson 3D -\triangle T = f sur un cube avec conditions aux limites de Dirichlet T=0
+# Author : Michaël Ndjinga
+# Copyright : CEA Saclay 2019
+# Description : Utilisation de la méthode des volumes finis avec champs T et f discrétisés aux cellules d'un maillage tétraédrique
+# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant CDMATH
+# Comparaison de la solution numérique avec la solution exacte T=sin(pi*x)*sin(pi*y)*sin(pi*z)
+#================================================================================================================================
+
+import CoreFlows as cf
+import cdmath as cm
+from math import sin, pi
+
+def StationaryDiffusionEquation_3DFV_StructuredTetrahedra():
+ spaceDim = 3;
+ # Prepare for the mesh
+ print("Building mesh " );
+ xinf = 0 ;
+ xsup = 1.0;
+ yinf = 0.0;
+ ysup = 1.0;
+ zinf = 0.0;
+ zsup = 1.0;
+ nx = 5;
+ ny = 5;
+ nz = 5;
+ M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz,1)#Regular tetrahedral mesh
+ # set the limit field for each boundary
+ eps=1e-6;
+ M.setGroupAtPlan(xsup,0,eps,"Bord1")
+ M.setGroupAtPlan(xinf,0,eps,"Bord2")
+ M.setGroupAtPlan(ysup,1,eps,"Bord3")
+ M.setGroupAtPlan(yinf,1,eps,"Bord4")
+ M.setGroupAtPlan(zsup,2,eps,"Bord5")
+ M.setGroupAtPlan(zinf,2,eps,"Bord6")
+
+ print "Built a regular 3D tetrahedral mesh from ", nx,"x" ,ny,"x" ,nz, " cubic cells"
+
+ FEComputation=False
+ myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
+ myProblem.setMesh(M);
+
+ # set the limit value for each boundary
+ T1=0;
+ T2=0;
+ T3=0;
+ T4=0;
+ T5=0;
+ T6=0;
+
+ myProblem.setDirichletBoundaryCondition("Bord1",T1)
+ myProblem.setDirichletBoundaryCondition("Bord2",T2)
+ myProblem.setDirichletBoundaryCondition("Bord3",T3)
+ myProblem.setDirichletBoundaryCondition("Bord4",T4)
+ myProblem.setDirichletBoundaryCondition("Bord5",T5)
+ myProblem.setDirichletBoundaryCondition("Bord6",T6)
+
+ #Set the right hand side function
+ my_RHSfield = cm.Field("RHS_field", cm.CELLS, M, 1)
+ for i in range(M.getNumberOfCells()):
+ Ci= M.getCell(i)
+ x = Ci.x()
+ y = Ci.y()
+ z = Ci.z()
+
+ my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)*sin(pi*z)#mettre la fonction definie au second membre de l'edp
+
+ myProblem.setHeatPowerField(my_RHSfield)
+ myProblem.setLinearSolver(cf.GMRES,cf.ILU);
+
+ # name of result file
+ fileName = "StationaryDiffusion_3DFV_StructuredTetrahedra";
+
+ # computation parameters
+ myProblem.setFileName(fileName);
+
+ # Run the computation
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.solveStationaryProblem();
+ if (not ok):
+ print( "Python simulation of " + fileName + " failed ! " );
+ pass
+ else:
+ print( "Python simulation of " + fileName + " is successful !" );
+ ####################### Postprocessing #########################
+ my_ResultField = myProblem.getOutputTemperatureField()
+ #The following formulas use the fact that the exact solution is equal the right hand side divided by 3*pi*pi
+ max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(3*pi*pi)
+ max_sol_num=my_ResultField.max()
+ min_sol_num=my_ResultField.min()
+ erreur_abs=0
+ for i in range(M.getNumberOfCells()) :
+ if erreur_abs < abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i]) :
+ erreur_abs = abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i])
+
+ print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
+ print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
+ print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
+
+ assert erreur_abs/max_abs_sol_exacte <1.
+ pass
+
+ print( "------------ !!! End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ StationaryDiffusionEquation_3DFV_StructuredTetrahedra()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+#===============================================================================================================================
+# Name : Résolution VF de l'équation de Laplace 3D -\Delta T = 0 avec conditions aux limites de Dirichlet u non nulle (fenetre et radiateur)
+# Authors : Michaël Ndjinga, Sédrick Kameni Ngwamou
+# Copyright : CEA Saclay 2019
+# Description : Utilisation de la méthode des volumes finis avec champs u discrétisés aux cellules d'un maillage de cubes
+# Conditions limites correspondant au refroidissement dû à une fenêtre et au chauffage dû à un radiateur
+# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant la librairie CDMATH
+#================================================================================================================================
+
+import CoreFlows as cf
+import cdmath
+
+def StationaryDiffusionEquation_3DVF_RoomCooling_StructuredCubes():
+ spaceDim = 3;
+
+ #Chargement du maillage cartésien du domaine
+ #==============================================
+ my_mesh = cdmath.Mesh("../resources/RoomWithCubes480.med")
+
+ print "Loaded Structured 3D mesh"
+
+ #Conditions limites
+ Tmur=20
+ Tfenetre=0
+ Tradiateur=40
+
+ FEComputation=False
+ myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
+ myProblem.setMesh(my_mesh);
+
+ myProblem.setDirichletBoundaryCondition("Fenetre",Tfenetre)
+ myProblem.setDirichletBoundaryCondition("Radiateur_sous_fenetre",Tradiateur)
+ myProblem.setDirichletBoundaryCondition("Radiateur_devant",Tmur)
+ myProblem.setDirichletBoundaryCondition("Radiateur_droite",Tmur)
+ myProblem.setDirichletBoundaryCondition("Mur",Tmur)
+
+ # name of result file
+ fileName = "StationnaryDiffusion_3DVF_StructuredCubes";
+
+ # computation parameters
+ myProblem.setFileName(fileName);
+
+ # Run the computation
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.solveStationaryProblem();
+ if (not ok):
+ print( "Python simulation of " + fileName + " failed ! " );
+ pass
+ else:
+ print( "Python simulation of " + fileName + " successful ! " );
+ pass
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ StationaryDiffusionEquation_3DVF_RoomCooling_StructuredCubes()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+#===============================================================================================================================
+# Name : Résolution VF de l'équation de Laplace 3D -\Delta T = 0 avec conditions aux limites de Dirichlet u non nulle (fenetre et radiateur)
+# Authors : Michaël Ndjinga, Sédrick Kameni Ngwamou
+# Copyright : CEA Saclay 2019
+# Description : Utilisation de la méthode des volumes finis avec champs u discrétisés aux cellules d'un maillage de tétraèdres
+# Conditions limites correspondant au refroidissement dû à une fenêtre et au chauffage dû à un radiateur
+# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant la librairie CDMATH
+#================================================================================================================================
+
+import CoreFlows as cf
+import cdmath
+
+def StationaryDiffusionEquation_3DVF_RoomCooling_UnstructuredTetras():
+ spaceDim = 3;
+
+ #Chargement du maillage cartésien du domaine
+ #==============================================
+ my_mesh = cdmath.Mesh("../resources/RoomWithTetras2488.med")
+
+ print "Loaded Structured 3D mesh"
+
+ #Conditions limites
+ Tmur=20
+ Tfenetre=0
+ Tradiateur=40
+
+ FEComputation=False
+ myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
+ myProblem.setMesh(my_mesh);
+
+ myProblem.setDirichletBoundaryCondition("Fenetre",Tfenetre)
+ myProblem.setDirichletBoundaryCondition("Radiateur_sous_fenetre",Tradiateur)
+ myProblem.setDirichletBoundaryCondition("Radiateur_Devant",Tmur)
+ myProblem.setDirichletBoundaryCondition("Radiateur_droit",Tmur)
+ myProblem.setDirichletBoundaryCondition("Murs",Tmur)
+
+ # name of result file
+ fileName = "StationnaryDiffusion_3DVF_UnstructuredTetras";
+
+ # computation parameters
+ myProblem.setFileName(fileName);
+
+ # Run the computation
+ myProblem.initialize();
+ print("Running python "+ fileName );
+
+ ok = myProblem.solveStationaryProblem();
+ if (not ok):
+ print( "Python simulation of " + fileName + " failed ! " );
+ pass
+ else:
+ print( "Python simulation of " + fileName + " successful ! " );
+ pass
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ StationaryDiffusionEquation_3DVF_RoomCooling_UnstructuredTetras()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-#===============================================================================================================================
-# Name : Résolution EF de l'équation de Poisson 2D -\triangle T = f avec conditions aux limites de Dirichlet T=0
-# Author : Michaël Ndjinga
-# Copyright : CEA Saclay 2019
-# Description : Utilisation de la méthode des éléménts finis P1 avec champs T et f discrétisés aux noeuds d'un maillage triangulaire
-# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant la librairie CDMATH
-# Comparaison de la solution numérique avec la solution exacte T=-sin(pi*x)*sin(pi*y)
-#================================================================================================================================
-
-import CoreFlows as cf
-import cdmath as cm
-from math import sin, pi
-
-def StationaryDiffusionEquation_2DEF_StructuredTriangles():
- spaceDim = 2;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=1.0;
- yinf=0.0;
- ysup=1.0;
- nx=20;
- ny=20;
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny,0)#Regular triangular mesh
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1")
- M.setGroupAtPlan(xinf,0,eps,"Bord2")
- M.setGroupAtPlan(ysup,1,eps,"Bord3")
- M.setGroupAtPlan(yinf,1,eps,"Bord4")
-
- print "Built a regular triangular 2D mesh from a square mesh with ", nx,"x" ,ny, " cells"
-
- FEComputation=True
- myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- # set the limit value for each boundary
- T1=0;
- T2=0;
- T3=0;
- T4=0;
-
- myProblem.setDirichletBoundaryCondition("Bord1",T1)
- myProblem.setDirichletBoundaryCondition("Bord2",T2)
- myProblem.setDirichletBoundaryCondition("Bord3",T3)
- myProblem.setDirichletBoundaryCondition("Bord4",T4)
-
- #Set the right hand side function
- my_RHSfield = cm.Field("RHS_field", cm.NODES, M, 1)
- for i in range(M.getNumberOfNodes()):
- Ni= M.getNode(i)
- x = Ni.x()
- y = Ni.y()
-
- my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)#mettre la fonction definie au second membre de l'edp
-
- myProblem.setHeatPowerField(my_RHSfield)
- myProblem.setLinearSolver(cf.GMRES,cf.ILU);
-
- # name of result file
- fileName = "StationnaryDiffusion_2DEF_StructuredTriangles";
-
- # computation parameters
- myProblem.setFileName(fileName);
-
- # Run the computation
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.solveStationaryProblem();
- if (not ok):
- print( "Python simulation of " + fileName + " failed ! " );
- pass
- else:
- ####################### Postprocessing #########################
- my_ResultField = myProblem.getOutputTemperatureField()
- #The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi
- max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi)
- max_sol_num=my_ResultField.max()
- min_sol_num=my_ResultField.min()
- erreur_abs=0
- for i in range(M.getNumberOfNodes()) :
- if erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) :
- erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i])
-
- print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
- print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
- print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
-
- assert erreur_abs/max_abs_sol_exacte <1.
- pass
-
- print( "------------ !!! End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- StationaryDiffusionEquation_2DEF_StructuredTriangles()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-#===============================================================================================================================
-# Name : Résolution EF de l'équation de Poisson 2D -\triangle T = f avec conditions aux limites de Neumann T=0
-# Author : Michaël Ndjinga
-# Copyright : CEA Saclay 2019
-# Description : Utilisation de la méthode des éléménts finis P1 avec champs T et f discrétisés aux noeuds d'un maillage triangulaire
-# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant la librairie CDMATH
-# Comparaison de la solution numérique avec la solution exacte T=-cos(pi*x)*cos(pi*y)
-#================================================================================================================================
-
-import CoreFlows as cf
-import cdmath as cm
-from math import cos, pi
-
-def StationaryDiffusionEquation_2DEF_StructuredTriangles_Neumann():
- spaceDim = 2;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0.0;
- xsup = 1.0;
- yinf = 0.0;
- ysup = 1.0;
- nx=20;
- ny=20;
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny,0)#Regular triangular mesh
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1")
- M.setGroupAtPlan(xinf,0,eps,"Bord2")
- M.setGroupAtPlan(ysup,1,eps,"Bord3")
- M.setGroupAtPlan(yinf,1,eps,"Bord4")
-
- print "Built a regular triangular 2D mesh from a square mesh with ", nx,"x" ,ny, " cells"
-
- FEComputation=True
- myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- # set the boundary condition for each boundary
- myProblem.setNeumannBoundaryCondition("Bord1")
- myProblem.setNeumannBoundaryCondition("Bord2")
- myProblem.setNeumannBoundaryCondition("Bord3")
- myProblem.setNeumannBoundaryCondition("Bord4")
-
- #Set the right hand side function
- my_RHSfield = cm.Field("RHS_field", cm.NODES, M, 1)
- for i in range(M.getNumberOfNodes()):
- Ni= M.getNode(i)
- x = Ni.x()
- y = Ni.y()
-
- my_RHSfield[i]=2*pi*pi*cos(pi*x)*cos(pi*y)#mettre la fonction definie au second membre de l'edp
-
- myProblem.setHeatPowerField(my_RHSfield)
- myProblem.setLinearSolver(cf.GMRES,cf.ILU);
-
- # name of result file
- fileName = "StationnaryDiffusion_2DEF_StructuredTriangles_Neumann";
-
- # computation parameters
- myProblem.setFileName(fileName);
-
- # Run the computation
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.solveStationaryProblem();
- if (not ok):
- print( "Python simulation of " + fileName + " failed ! " );
- pass
- else:
- ####################### Postprocessing #########################
- my_ResultField = myProblem.getOutputTemperatureField()
- #The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi
- max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi)
- max_sol_num=my_ResultField.max()
- min_sol_num=my_ResultField.min()
- erreur_abs=0
- for i in range(M.getNumberOfNodes()) :
- if erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) :
- erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i])
-
- print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
- print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
- print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
-
- assert erreur_abs/max_abs_sol_exacte <1.
- pass
-
- print( "------------ !!! End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- StationaryDiffusionEquation_2DEF_StructuredTriangles_Neumann()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-#===============================================================================================================================
-# Name : Résolution VF de l'équation de Poisson 2D -\triangle T = f sur un carré avec conditions aux limites de Dirichlet T=0
-# Author : Michaël Ndjinga
-# Copyright : CEA Saclay 2019
-# Description : Utilisation de la méthode des volumes finis avec champs T et f discrétisés aux cellules d'un maillage de triangules équilatéraux
-# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant CDMATH
-# Comparaison de la solution numérique avec la solution exacte T=sin(pi*x)*sin(pi*y)
-#================================================================================================================================
-
-import CoreFlows as cf
-import cdmath as cm
-from math import sin, pi
-import os
-
-def StationaryDiffusionEquation_2DFV_EquilateralTriangles():
- spaceDim = 2;
- # Prepare for the mesh
- print("Loading mesh " );
- M=cm.Mesh(os.environ['CDMATH_INSTALL']+'/share/meshes/2DEquilateralTriangles/squareWithEquilateralTriangles20.med')#Equilateral triangular mesh
-
- print( "Loaded 2D equilateral triangle mesh with ", M.getNumberOfCells(), " cells")
-
- # set the limit field
- boundaryFaces = M.getBoundaryFaceIds()
- boundaryValues = {}
- print("Setting Dirichlet boundary values")
- for i in boundaryFaces :
- Fi=M.getFace(i)
- x=Fi.x()
- y=Fi.y()
- boundaryValues[i] = sin(pi*x)*sin(pi*y)
-
- FEComputation=False
- myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
- myProblem.setMesh(M);
- myProblem.setDirichletValues(cf.MapIntDouble(boundaryValues))
-
- #Set the right hand side function
- my_RHSfield = cm.Field("RHS_field", cm.CELLS, M, 1)
- for i in range(M.getNumberOfCells()):
- Ci= M.getCell(i)
- x = Ci.x()
- y = Ci.y()
-
- my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)#mettre la fonction definie au second membre de l'edp
-
- myProblem.setHeatPowerField(my_RHSfield)
- myProblem.setLinearSolver(cf.GMRES,cf.ILU);
-
- # name of result file
- fileName = "StationnaryDiffusion_2DFV_StructuredTriangles";
-
- # computation parameters
- myProblem.setFileName(fileName);
-
- # Run the computation
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.solveStationaryProblem();
- if (not ok):
- print( "Python simulation of " + fileName + " failed ! " );
- pass
- else:
- print( "Python simulation of " + fileName + " is successful !" );
- ####################### Postprocessing #########################
- my_ResultField = myProblem.getOutputTemperatureField()
- #The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi
- max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi)
- max_sol_num=my_ResultField.max()
- min_sol_num=my_ResultField.min()
- erreur_abs=0
- for i in range(M.getNumberOfCells()) :
- if erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) :
- erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i])
-
- print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
- print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
- print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
-
- assert erreur_abs/max_abs_sol_exacte <1.
- pass
-
- print( "------------ !!! End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- StationaryDiffusionEquation_2DFV_EquilateralTriangles()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-#===============================================================================================================================
-# Name : Résolution VF de l'équation de Poisson 2D -\triangle T = f sur un carré avec conditions aux limites de Dirichlet T=0
-# Author : Michaël Ndjinga
-# Copyright : CEA Saclay 2019
-# Description : Utilisation de la méthode des volumes finis avec champs T et f discrétisés aux cellules d'un maillage triangulaire
-# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant CDMATH
-# Comparaison de la solution numérique avec la solution exacte T=sin(pi*x)*sin(pi*y)
-#================================================================================================================================
-
-import CoreFlows as cf
-import cdmath as cm
-from math import sin, pi
-
-def StationaryDiffusionEquation_2DFV_StructuredSquares():
- spaceDim = 2;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=1.0;
- yinf=0.0;
- ysup=1.0;
- nx=30;
- ny=30;
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)#Regular square mesh
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1")
- M.setGroupAtPlan(xinf,0,eps,"Bord2")
- M.setGroupAtPlan(ysup,1,eps,"Bord3")
- M.setGroupAtPlan(yinf,1,eps,"Bord4")
-
- print "Built a regular 2D square mesh with ", nx,"x" ,ny, " cells"
-
- FEComputation=False
- myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- # set the limit value for each boundary
- T1=0;
- T2=0;
- T3=0;
- T4=0;
-
- myProblem.setDirichletBoundaryCondition("Bord1",T1)
- myProblem.setDirichletBoundaryCondition("Bord2",T2)
- myProblem.setDirichletBoundaryCondition("Bord3",T3)
- myProblem.setDirichletBoundaryCondition("Bord4",T4)
-
- #Set the right hand side function
- my_RHSfield = cm.Field("RHS_field", cm.CELLS, M, 1)
- for i in range(M.getNumberOfCells()):
- Ci= M.getCell(i)
- x = Ci.x()
- y = Ci.y()
-
- my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)#mettre la fonction definie au second membre de l'edp
-
- myProblem.setHeatPowerField(my_RHSfield)
- myProblem.setLinearSolver(cf.GMRES,cf.ILU);
-
- # name of result file
- fileName = "StationnaryDiffusion_2DFV_StructuredSquares";
-
- # computation parameters
- myProblem.setFileName(fileName);
-
- # Run the computation
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.solveStationaryProblem();
- if (not ok):
- print( "Python simulation of " + fileName + " failed ! " );
- pass
- else:
- print( "Python simulation of " + fileName + " is successful !" );
- ####################### Postprocessing #########################
- my_ResultField = myProblem.getOutputTemperatureField()
- #The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi
- max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi)
- max_sol_num=my_ResultField.max()
- min_sol_num=my_ResultField.min()
- erreur_abs=0
- for i in range(M.getNumberOfCells()) :
- if erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) :
- erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i])
-
- print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
- print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
- print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
-
- assert erreur_abs/max_abs_sol_exacte <1.
- pass
-
- print( "------------ !!! End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- StationaryDiffusionEquation_2DFV_StructuredSquares()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-#===============================================================================================================================
-# Name : Résolution VF de l'équation de Poisson 2D -\triangle T = f sur un carré avec conditions aux limites de Neumann T=0
-# Author : Michaël Ndjinga
-# Copyright : CEA Saclay 2019
-# Description : Utilisation de la méthode des volumes finis avec champs T et f discrétisés aux cellules d'un maillage triangulaire
-# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant CDMATH
-# Comparaison de la solution numérique avec la solution exacte T=cos(pi*x)*cos(pi*y)
-#================================================================================================================================
-
-import CoreFlows as cf
-import cdmath as cm
-from math import cos, pi
-
-def StationaryDiffusionEquation_2DFV_StructuredSquares_Neumann():
- spaceDim = 2;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0.0;
- xsup = 1.0;
- yinf = 0.0;
- ysup = 1.0;
- nx=30;
- ny=30;
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)#Regular square mesh
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1")
- M.setGroupAtPlan(xinf,0,eps,"Bord2")
- M.setGroupAtPlan(ysup,1,eps,"Bord3")
- M.setGroupAtPlan(yinf,1,eps,"Bord4")
-
- print "Built a regular 2D square mesh with ", nx,"x" ,ny, " cells"
-
- FEComputation=False
- myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- # set the limit value for each boundary
- T1=0;
- T2=0;
- T3=0;
- T4=0;
-
- myProblem.setNeumannBoundaryCondition("Bord1")
- myProblem.setNeumannBoundaryCondition("Bord2")
- myProblem.setNeumannBoundaryCondition("Bord3")
- myProblem.setNeumannBoundaryCondition("Bord4")
-
- #Set the right hand side function
- my_RHSfield = cm.Field("RHS_field", cm.CELLS, M, 1)
- for i in range(M.getNumberOfCells()):
- Ci= M.getCell(i)
- x = Ci.x()
- y = Ci.y()
-
- my_RHSfield[i]=2*pi*pi*cos(pi*x)*cos(pi*y)#mettre la fonction definie au second membre de l'edp
-
- myProblem.setHeatPowerField(my_RHSfield)
- myProblem.setLinearSolver(cf.GMRES,cf.ILU);
-
- # name of result file
- fileName = "StationnaryDiffusion_2DFV_StructuredSquares_Neumann";
-
- # computation parameters
- myProblem.setFileName(fileName);
-
- # Run the computation
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.solveStationaryProblem();
- if (not ok):
- print( "Python simulation of " + fileName + " failed ! " );
- pass
- else:
- print( "Python simulation of " + fileName + " is successful !" );
- ####################### Postprocessing #########################
- my_ResultField = myProblem.getOutputTemperatureField()
- #The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi
- max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi)
- max_sol_num=my_ResultField.max()
- min_sol_num=my_ResultField.min()
- erreur_abs=0
- for i in range(M.getNumberOfCells()) :
- if erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) :
- erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i])
-
- print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
- print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
- print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
-
- assert erreur_abs/max_abs_sol_exacte <1.
- pass
-
- print( "------------ !!! End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- StationaryDiffusionEquation_2DFV_StructuredSquares_Neumann()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-#===============================================================================================================================
-# Name : Résolution VF de l'équation de Poisson 2D -\triangle T = f sur un carré avec conditions aux limites de Dirichlet T=0
-# Author : Michaël Ndjinga
-# Copyright : CEA Saclay 2019
-# Description : Utilisation de la méthode des volumes finis avec champs T et f discrétisés aux cellules d'un maillage triangulaire
-# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant CDMATH
-# Comparaison de la solution numérique avec la solution exacte T=sin(pi*x)*sin(pi*y)
-#================================================================================================================================
-
-import CoreFlows as cf
-import cdmath as cm
-from math import sin, pi
-
-def StationaryDiffusionEquation_2DFV_StructuredTriangles():
- spaceDim = 2;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup=1.0;
- yinf=0.0;
- ysup=1.0;
- nx=20;
- ny=20;
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny,0)#Regular triangular mesh
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1")
- M.setGroupAtPlan(xinf,0,eps,"Bord2")
- M.setGroupAtPlan(ysup,1,eps,"Bord3")
- M.setGroupAtPlan(yinf,1,eps,"Bord4")
-
- print "Built a regular triangular 2D mesh from a square mesh with ", nx,"x" ,ny, " cells"
-
- FEComputation=False
- myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- # set the limit value for each boundary
- T1=0;
- T2=0;
- T3=0;
- T4=0;
-
- myProblem.setDirichletBoundaryCondition("Bord1",T1)
- myProblem.setDirichletBoundaryCondition("Bord2",T2)
- myProblem.setDirichletBoundaryCondition("Bord3",T3)
- myProblem.setDirichletBoundaryCondition("Bord4",T4)
-
- #Set the right hand side function
- my_RHSfield = cm.Field("RHS_field", cm.CELLS, M, 1)
- for i in range(M.getNumberOfCells()):
- Ci= M.getCell(i)
- x = Ci.x()
- y = Ci.y()
-
- my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)#mettre la fonction definie au second membre de l'edp
-
- myProblem.setHeatPowerField(my_RHSfield)
- myProblem.setLinearSolver(cf.GMRES,cf.ILU);
-
- # name of result file
- fileName = "StationnaryDiffusion_2DFV_StructuredTriangles";
-
- # computation parameters
- myProblem.setFileName(fileName);
-
- # Run the computation
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.solveStationaryProblem();
- if (not ok):
- print( "Python simulation of " + fileName + " failed ! " );
- pass
- else:
- print( "Python simulation of " + fileName + " is successful !" );
- ####################### Postprocessing #########################
- my_ResultField = myProblem.getOutputTemperatureField()
- #The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi
- max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi)
- max_sol_num=my_ResultField.max()
- min_sol_num=my_ResultField.min()
- erreur_abs=0
- for i in range(M.getNumberOfCells()) :
- if erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) :
- erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i])
-
- print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
- print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
- print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
-
- assert erreur_abs/max_abs_sol_exacte <1.
- pass
-
- print( "------------ !!! End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- StationaryDiffusionEquation_2DFV_StructuredTriangles()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-#===============================================================================================================================
-# Name : Résolution EF de l'équation de Poisson 3D -\triangle T = f avec conditions aux limites de Dirichlet T=0
-# Author : Michaël Ndjinga
-# Copyright : CEA Saclay 2019
-# Description : Utilisation de la méthode des éléménts finis P1 avec champs T et f discrétisés aux noeuds d'un maillage tétraédrique
-# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant la librairie CDMATH
-# Comparaison de la solution numérique avec la solution exacte T=-sin(pi*x)*sin(pi*y)*sin(pi*z)
-#================================================================================================================================
-
-import CoreFlows as cf
-import cdmath as cm
-from math import sin, pi
-
-def StationaryDiffusionEquation_3DEF_StructuredTriangles():
- spaceDim = 3;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0.0;
- xsup = 1.0;
- yinf = 0.0;
- ysup = 1.0;
- zinf = 0.0;
- zsup = 1.0;
- nx = 5;
- ny = 5;
- nz = 5;
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz,1)#Regular tetrahedral mesh
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1")
- M.setGroupAtPlan(xinf,0,eps,"Bord2")
- M.setGroupAtPlan(ysup,1,eps,"Bord3")
- M.setGroupAtPlan(yinf,1,eps,"Bord4")
- M.setGroupAtPlan(zsup,2,eps,"Bord5")
- M.setGroupAtPlan(zinf,2,eps,"Bord6")
-
- print "Built a regular tetrahedra 3D mesh from a cube mesh with ", nx,"x" ,ny,"x" ,nz, " cells"
-
- FEComputation=True
- myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- # set the limit value for each boundary
- T1=0;
- T2=0;
- T3=0;
- T4=0;
- T5=0;
- T6=0;
-
- myProblem.setDirichletBoundaryCondition("Bord1",T1)
- myProblem.setDirichletBoundaryCondition("Bord2",T2)
- myProblem.setDirichletBoundaryCondition("Bord3",T3)
- myProblem.setDirichletBoundaryCondition("Bord4",T4)
- myProblem.setDirichletBoundaryCondition("Bord5",T5)
- myProblem.setDirichletBoundaryCondition("Bord6",T6)
-
- #Set the right hand side function
- my_RHSfield = cm.Field("RHS_field", cm.NODES, M, 1)
- for i in range(M.getNumberOfNodes()):
- Ni= M.getNode(i)
- x = Ni.x()
- y = Ni.y()
- z = Ni.z()
-
- my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)*sin(pi*z)#mettre la fonction definie au second membre de l'edp
-
- myProblem.setHeatPowerField(my_RHSfield)
- myProblem.setLinearSolver(cf.GMRES,cf.ILU);
-
- # name of result file
- fileName = "StationnaryDiffusion_3DEF_StructuredTriangles";
-
- # computation parameters
- myProblem.setFileName(fileName);
-
- # Run the computation
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.solveStationaryProblem();
- if (not ok):
- print( "Python simulation of " + fileName + " failed ! " );
- pass
- else:
- ####################### Postprocessing #########################
- my_ResultField = myProblem.getOutputTemperatureField()
- #The following formulas use the fact that the exact solution is equal the right hand side divided by 3*pi*pi
- max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(3*pi*pi)
- max_sol_num=my_ResultField.max()
- min_sol_num=my_ResultField.min()
- erreur_abs=0
- for i in range(M.getNumberOfNodes()) :
- if erreur_abs < abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i]) :
- erreur_abs = abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i])
-
- print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
- print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
- print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
-
- assert erreur_abs/max_abs_sol_exacte <1.
- pass
-
- print( "------------ !!! End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- StationaryDiffusionEquation_3DEF_StructuredTriangles()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-#===============================================================================================================================
-# Name : Résolution EF de l'équation de Laplace 3D -\Delta T = 0 avec conditions aux limites de Dirichlet u non nulle (fenetre et radiateur)
-# Authors : Michaël Ndjinga, Sédrick Kameni Ngwamou
-# Copyright : CEA Saclay 2019
-# Description : Utilisation de la méthode des éléménts finis P1 avec champs u discrétisés aux noeuds d'un maillage tétraédrique
-# Condition limites correspondant au refroidissement dû à une fenêtre et au chauffage dû à un radiateur
-# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant la librairie CDMATH
-#================================================================================================================================
-
-import CoreFlows as cf
-import cdmath
-
-def StationaryDiffusionEquation_3DEF_RoomCooling():
- spaceDim = 3;
-
- #Chargement du maillage tétraédrique du domaine
- #==============================================
- my_mesh = cdmath.Mesh("../resources/RoomWithTetras2488.med")
-
- print "Loaded unstructured 3D mesh"
-
- #Conditions limites
- Tmur=20
- Tfenetre=0
- Tradiateur=40
-
- FEComputation=True
- myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
- myProblem.setMesh(my_mesh);
-
- myProblem.setDirichletBoundaryCondition("Fenetre",Tfenetre)
- myProblem.setDirichletBoundaryCondition("Radiateur_sous_fenetre",Tradiateur)
- myProblem.setDirichletBoundaryCondition("Radiateur_Devant",Tmur)
- myProblem.setDirichletBoundaryCondition("Radiateur_droit",Tmur)
- myProblem.setDirichletBoundaryCondition("Murs",Tmur)
-
- # name of result file
- fileName = "StationnaryDiffusion_3DEF_UnstructuredTetrahedra";
-
- # computation parameters
- myProblem.setFileName(fileName);
-
- # Run the computation
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.solveStationaryProblem();
- if (not ok):
- print( "Python simulation of " + fileName + " failed ! " );
- pass
- else:
- print( "Python simulation of " + fileName + " successful ! " );
- pass
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- StationaryDiffusionEquation_3DEF_RoomCooling()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-#===============================================================================================================================
-# Name : Résolution VF de l'équation de Poisson 3D -\triangle T = f sur un cube avec conditions aux limites de Dirichlet T=0
-# Author : Michaël Ndjinga
-# Copyright : CEA Saclay 2019
-# Description : Utilisation de la méthode des volumes finis avec champs T et f discrétisés aux cellules d'un maillage de cubes
-# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant CDMATH
-# Comparaison de la solution numérique avec la solution exacte T=sin(pi*x)*sin(pi*y)*sin(pi*z)
-#================================================================================================================================
-
-import CoreFlows as cf
-import cdmath as cm
-from math import sin, pi
-
-def StationaryDiffusionEquation_3DFV_StructuredCubes():
- spaceDim = 3;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup = 1.0;
- yinf = 0.0;
- ysup = 1.0;
- zinf = 0.0;
- zsup = 1.0;
- nx = 20;
- ny = 20;
- nz = 20;
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz)#Regular cube mesh
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1")
- M.setGroupAtPlan(xinf,0,eps,"Bord2")
- M.setGroupAtPlan(ysup,1,eps,"Bord3")
- M.setGroupAtPlan(yinf,1,eps,"Bord4")
- M.setGroupAtPlan(zsup,2,eps,"Bord5")
- M.setGroupAtPlan(zinf,2,eps,"Bord6")
-
- print "Built a regular 3D cube mesh with ", nx,"x" ,ny,"x" ,nz, " cells"
-
- FEComputation=False
- myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- # set the limit value for each boundary
- T1=0;
- T2=0;
- T3=0;
- T4=0;
- T5=0;
- T6=0;
-
- myProblem.setDirichletBoundaryCondition("Bord1",T1)
- myProblem.setDirichletBoundaryCondition("Bord2",T2)
- myProblem.setDirichletBoundaryCondition("Bord3",T3)
- myProblem.setDirichletBoundaryCondition("Bord4",T4)
- myProblem.setDirichletBoundaryCondition("Bord5",T5)
- myProblem.setDirichletBoundaryCondition("Bord6",T6)
-
- #Set the right hand side function
- my_RHSfield = cm.Field("RHS_field", cm.CELLS, M, 1)
- for i in range(M.getNumberOfCells()):
- Ci= M.getCell(i)
- x = Ci.x()
- y = Ci.y()
- z = Ci.z()
-
- my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)*sin(pi*z)#mettre la fonction definie au second membre de l'edp
-
- myProblem.setHeatPowerField(my_RHSfield)
- myProblem.setLinearSolver(cf.GMRES,cf.ILU);
-
- # name of result file
- fileName = "StationaryDiffusion_3DFV_StructuredCubes";
-
- # computation parameters
- myProblem.setFileName(fileName);
-
- # Run the computation
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.solveStationaryProblem();
- if (not ok):
- print( "Python simulation of " + fileName + " failed ! " );
- pass
- else:
- print( "Python simulation of " + fileName + " is successful !" );
- ####################### Postprocessing #########################
- my_ResultField = myProblem.getOutputTemperatureField()
- #The following formulas use the fact that the exact solution is equal the right hand side divided by 3*pi*pi
- max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(3*pi*pi)
- max_sol_num=my_ResultField.max()
- min_sol_num=my_ResultField.min()
- erreur_abs=0
- for i in range(M.getNumberOfCells()) :
- if erreur_abs < abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i]) :
- erreur_abs = abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i])
-
- print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
- print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
- print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
-
- assert erreur_abs/max_abs_sol_exacte <1.
- pass
-
- print( "------------ !!! End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- StationaryDiffusionEquation_3DFV_StructuredCubes()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-#===============================================================================================================================
-# Name : Résolution VF de l'équation de Poisson 3D -\triangle T = f sur un cube avec conditions aux limites de Dirichlet T=0
-# Author : Michaël Ndjinga
-# Copyright : CEA Saclay 2019
-# Description : Utilisation de la méthode des volumes finis avec champs T et f discrétisés aux cellules d'un maillage tétraédrique
-# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant CDMATH
-# Comparaison de la solution numérique avec la solution exacte T=sin(pi*x)*sin(pi*y)*sin(pi*z)
-#================================================================================================================================
-
-import CoreFlows as cf
-import cdmath as cm
-from math import sin, pi
-
-def StationaryDiffusionEquation_3DFV_StructuredTetrahedra():
- spaceDim = 3;
- # Prepare for the mesh
- print("Building mesh " );
- xinf = 0 ;
- xsup = 1.0;
- yinf = 0.0;
- ysup = 1.0;
- zinf = 0.0;
- zsup = 1.0;
- nx = 5;
- ny = 5;
- nz = 5;
- M=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz,1)#Regular tetrahedral mesh
- # set the limit field for each boundary
- eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1")
- M.setGroupAtPlan(xinf,0,eps,"Bord2")
- M.setGroupAtPlan(ysup,1,eps,"Bord3")
- M.setGroupAtPlan(yinf,1,eps,"Bord4")
- M.setGroupAtPlan(zsup,2,eps,"Bord5")
- M.setGroupAtPlan(zinf,2,eps,"Bord6")
-
- print "Built a regular 3D tetrahedral mesh from ", nx,"x" ,ny,"x" ,nz, " cubic cells"
-
- FEComputation=False
- myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- # set the limit value for each boundary
- T1=0;
- T2=0;
- T3=0;
- T4=0;
- T5=0;
- T6=0;
-
- myProblem.setDirichletBoundaryCondition("Bord1",T1)
- myProblem.setDirichletBoundaryCondition("Bord2",T2)
- myProblem.setDirichletBoundaryCondition("Bord3",T3)
- myProblem.setDirichletBoundaryCondition("Bord4",T4)
- myProblem.setDirichletBoundaryCondition("Bord5",T5)
- myProblem.setDirichletBoundaryCondition("Bord6",T6)
-
- #Set the right hand side function
- my_RHSfield = cm.Field("RHS_field", cm.CELLS, M, 1)
- for i in range(M.getNumberOfCells()):
- Ci= M.getCell(i)
- x = Ci.x()
- y = Ci.y()
- z = Ci.z()
-
- my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)*sin(pi*z)#mettre la fonction definie au second membre de l'edp
-
- myProblem.setHeatPowerField(my_RHSfield)
- myProblem.setLinearSolver(cf.GMRES,cf.ILU);
-
- # name of result file
- fileName = "StationaryDiffusion_3DFV_StructuredTetrahedra";
-
- # computation parameters
- myProblem.setFileName(fileName);
-
- # Run the computation
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.solveStationaryProblem();
- if (not ok):
- print( "Python simulation of " + fileName + " failed ! " );
- pass
- else:
- print( "Python simulation of " + fileName + " is successful !" );
- ####################### Postprocessing #########################
- my_ResultField = myProblem.getOutputTemperatureField()
- #The following formulas use the fact that the exact solution is equal the right hand side divided by 3*pi*pi
- max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(3*pi*pi)
- max_sol_num=my_ResultField.max()
- min_sol_num=my_ResultField.min()
- erreur_abs=0
- for i in range(M.getNumberOfCells()) :
- if erreur_abs < abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i]) :
- erreur_abs = abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i])
-
- print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
- print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)
- print ("Maximum numerical solution = ", max_sol_num, " Minimum numerical solution = ", min_sol_num)
-
- assert erreur_abs/max_abs_sol_exacte <1.
- pass
-
- print( "------------ !!! End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- StationaryDiffusionEquation_3DFV_StructuredTetrahedra()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-#===============================================================================================================================
-# Name : Résolution VF de l'équation de Laplace 3D -\Delta T = 0 avec conditions aux limites de Dirichlet u non nulle (fenetre et radiateur)
-# Authors : Michaël Ndjinga, Sédrick Kameni Ngwamou
-# Copyright : CEA Saclay 2019
-# Description : Utilisation de la méthode des volumes finis avec champs u discrétisés aux cellules d'un maillage de cubes
-# Conditions limites correspondant au refroidissement dû à une fenêtre et au chauffage dû à un radiateur
-# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant la librairie CDMATH
-#================================================================================================================================
-
-import CoreFlows as cf
-import cdmath
-
-def StationaryDiffusionEquation_3DVF_RoomCooling_StructuredCubes():
- spaceDim = 3;
-
- #Chargement du maillage cartésien du domaine
- #==============================================
- my_mesh = cdmath.Mesh("../resources/RoomWithCubes480.med")
-
- print "Loaded Structured 3D mesh"
-
- #Conditions limites
- Tmur=20
- Tfenetre=0
- Tradiateur=40
-
- FEComputation=False
- myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
- myProblem.setMesh(my_mesh);
-
- myProblem.setDirichletBoundaryCondition("Fenetre",Tfenetre)
- myProblem.setDirichletBoundaryCondition("Radiateur_sous_fenetre",Tradiateur)
- myProblem.setDirichletBoundaryCondition("Radiateur_devant",Tmur)
- myProblem.setDirichletBoundaryCondition("Radiateur_droite",Tmur)
- myProblem.setDirichletBoundaryCondition("Mur",Tmur)
-
- # name of result file
- fileName = "StationnaryDiffusion_3DVF_StructuredCubes";
-
- # computation parameters
- myProblem.setFileName(fileName);
-
- # Run the computation
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.solveStationaryProblem();
- if (not ok):
- print( "Python simulation of " + fileName + " failed ! " );
- pass
- else:
- print( "Python simulation of " + fileName + " successful ! " );
- pass
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- StationaryDiffusionEquation_3DVF_RoomCooling_StructuredCubes()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-#===============================================================================================================================
-# Name : Résolution VF de l'équation de Laplace 3D -\Delta T = 0 avec conditions aux limites de Dirichlet u non nulle (fenetre et radiateur)
-# Authors : Michaël Ndjinga, Sédrick Kameni Ngwamou
-# Copyright : CEA Saclay 2019
-# Description : Utilisation de la méthode des volumes finis avec champs u discrétisés aux cellules d'un maillage de tétraèdres
-# Conditions limites correspondant au refroidissement dû à une fenêtre et au chauffage dû à un radiateur
-# Création et sauvegarde du champ résultant ainsi que du champ second membre en utilisant la librairie CDMATH
-#================================================================================================================================
-
-import CoreFlows as cf
-import cdmath
-
-def StationaryDiffusionEquation_3DVF_RoomCooling_UnstructuredTetras():
- spaceDim = 3;
-
- #Chargement du maillage cartésien du domaine
- #==============================================
- my_mesh = cdmath.Mesh("../resources/RoomWithTetras2488.med")
-
- print "Loaded Structured 3D mesh"
-
- #Conditions limites
- Tmur=20
- Tfenetre=0
- Tradiateur=40
-
- FEComputation=False
- myProblem = cf.StationaryDiffusionEquation(spaceDim,FEComputation);
- myProblem.setMesh(my_mesh);
-
- myProblem.setDirichletBoundaryCondition("Fenetre",Tfenetre)
- myProblem.setDirichletBoundaryCondition("Radiateur_sous_fenetre",Tradiateur)
- myProblem.setDirichletBoundaryCondition("Radiateur_Devant",Tmur)
- myProblem.setDirichletBoundaryCondition("Radiateur_droit",Tmur)
- myProblem.setDirichletBoundaryCondition("Murs",Tmur)
-
- # name of result file
- fileName = "StationnaryDiffusion_3DVF_UnstructuredTetras";
-
- # computation parameters
- myProblem.setFileName(fileName);
-
- # Run the computation
- myProblem.initialize();
- print("Running python "+ fileName );
-
- ok = myProblem.solveStationaryProblem();
- if (not ok):
- print( "Python simulation of " + fileName + " failed ! " );
- pass
- else:
- print( "Python simulation of " + fileName + " successful ! " );
- pass
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- StationaryDiffusionEquation_3DVF_RoomCooling_UnstructuredTetras()
--- /dev/null
+#!/usr/bin/env python
+# -*-coding:utf-8 -*
+
+import CoreFlows as cf
+
+def TransportEquation_1DHeatedChannel():
+
+ spaceDim = 1;
+ # Prepare for the mesh
+ xinf = 0 ;
+ xsup=4.2;
+ nx=10;
+
+ # set the limit field for each boundary
+ inletEnthalpy=1.3e6;
+
+ # Set the transport velocity
+ transportVelocity=[5];
+
+ myProblem = cf.TransportEquation(cf.LiquidPhase,cf.around155bars600KTransport,transportVelocity);
+ nVar = myProblem.getNumberOfVariables();
+
+ # Prepare for the initial condition
+ VV_Constant = [1.3e6]; #initial enthalpy
+
+ #Set rod temperature and heat exchamge coefficient
+ rodTemp=623;#Rod clad temperature
+ heatTransfertCoeff=1000;#fluid/solid heat exchange coefficient
+ myProblem.setRodTemperature(rodTemp);
+ myProblem.setHeatTransfertCoeff(heatTransfertCoeff);
+
+ #Initial field creation
+ print("Building mesh and initial data " );
+ myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"inlet","neumann");
+
+ # Set the boundary conditions
+ myProblem.setInletBoundaryCondition("inlet", inletEnthalpy);
+ myProblem.setNeumannBoundaryCondition("neumann")
+
+ # Set the numerical method
+ myProblem.setTimeScheme( cf.Explicit);
+
+ # name file save
+ fileName = "1DFluidEnthalpy";
+
+ # parameters calculation
+ MaxNbOfTimeStep = 3 ;
+ freqSave = 5;
+ cfl = 0.95;
+ maxTime = 5;
+ precision = 1e-6;
+
+ myProblem.setCFL(cfl);
+ myProblem.setPrecision(precision);
+ myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
+ myProblem.setTimeMax(maxTime);
+ myProblem.setFreqSave(freqSave);
+ myProblem.setFileName(fileName);
+
+
+ # evolution
+ myProblem.initialize();
+
+ ok = myProblem.run();
+ if (ok):
+ print( "Simulation python " + fileName + " is successful !" );
+ pass
+ else:
+ print( "Simulation python " + fileName + " failed ! " );
+ pass
+
+ print( "------------ End of calculation !!! -----------" );
+
+ myProblem.terminate();
+ return ok
+
+if __name__ == """__main__""":
+ TransportEquation_1DHeatedChannel()
+++ /dev/null
-#!/usr/bin/env python
-# -*-coding:utf-8 -*
-
-import CoreFlows as cf
-
-def TransportEquation_1DHeatedChannel():
-
- spaceDim = 1;
- # Prepare for the mesh
- xinf = 0 ;
- xsup=4.2;
- nx=10;
-
- # set the limit field for each boundary
- inletEnthalpy=1.3e6;
-
- # Set the transport velocity
- transportVelocity=[5];
-
- myProblem = cf.TransportEquation(cf.Liquid,cf.around155bars600K,transportVelocity);
- nVar = myProblem.getNumberOfVariables();
-
- # Prepare for the initial condition
- VV_Constant = [1.3e6]; #initial enthalpy
-
- #Set rod temperature and heat exchamge coefficient
- rodTemp=623;#Rod clad temperature
- heatTransfertCoeff=1000;#fluid/solid heat exchange coefficient
- myProblem.setRodTemperature(rodTemp);
- myProblem.setHeatTransfertCoeff(heatTransfertCoeff);
-
- #Initial field creation
- print("Building mesh and initial data " );
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"inlet","neumann");
-
- # Set the boundary conditions
- myProblem.setInletBoundaryCondition("inlet", inletEnthalpy);
- myProblem.setNeumannBoundaryCondition("neumann")
-
- # Set the numerical method
- myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
-
- # name file save
- fileName = "1DFluidEnthalpy";
-
- # parameters calculation
- MaxNbOfTimeStep = 3 ;
- freqSave = 5;
- cfl = 0.95;
- maxTime = 5;
- precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
-
-
- # evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok):
- print( "Simulation python " + fileName + " is successful !" );
- pass
- else:
- print( "Simulation python " + fileName + " failed ! " );
- pass
-
- print( "------------ End of calculation !!! -----------" );
-
- myProblem.terminate();
- return ok
-
-if __name__ == """__main__""":
- TransportEquation_1DHeatedChannel()
+++ /dev/null
-#include "SinglePhase.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- cout << "Building cartesian mesh" << endl;
- double xinf=0.0;
- double xsup=4.2;
- int nx=50;
- Mesh M(xinf,xsup,nx);
- double eps=1.E-8;
- M.setGroupAtPlan(xsup,0,eps,"Outlet");
- M.setGroupAtPlan(xinf,0,eps,"Wall");
- int spaceDim = M.getSpaceDimension();
-
- // set the initial field
- double initialPressure=155e5;
- double initialVelocityX=0;
- double initialTemperature=573;
-
- //set the boundary data for each boundary
- double outletPressure=80e5;
- double wallVelocityX=0;
- double wallTemperature=573;
-
- SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
- int nbPhase = myProblem.getNumberOfPhases();
-
- // Prepare for the initial condition
- int nVar = myProblem.getNumberOfVariables();
- Vector VV_constant(nVar);
- VV_constant(0) = initialPressure ;
- VV_constant(1) = initialVelocityX;
- VV_constant(2) = initialTemperature ;
-
- cout << "Building initial data" << endl;
- Field VV("Primitive", CELLS, M, nVar);
-
- myProblem.setInitialFieldConstant(M,VV_constant);
-
- //set the boundary conditions
- myProblem.setWallBoundaryCondition("Wall", wallTemperature, wallVelocityX);
- myProblem.setOutletBoundaryCondition("Outlet", outletPressure,vector<double>(1,xsup));
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
- myProblem.setEntropicCorrection(true);
-
- // name file save
- string fileName = "1DDepressurisation";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep = 3;
- int freqSave = 1;
- double cfl = 0.95;
- double maxTime = 5;
- double precision = 1e-8;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- bool ok;
-
- // evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "SinglePhase.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- double xinf=0.0;
- double xsup=4.2;
- int nx=50;
- cout << "Building a regular mesh of "<< nx<< " cells " << endl;
- Mesh M(xinf,xsup,nx);
- double eps=1.E-8;
- M.setGroupAtPlan(xsup,0,eps,"Outlet");//Neumann
- M.setGroupAtPlan(xinf,0,eps,"Inlet");//
- int spaceDim = M.getSpaceDimension();
-
- // set the limit field for each boundary
- LimitField limitInlet, limitOutlet;
- map<string, LimitField> boundaryFields;
-
- limitInlet.T =573.;
- limitInlet.bcType=Inlet;
- limitInlet.v_x = vector<double>(1,5);
- boundaryFields["Inlet"] = limitInlet;
-
- limitOutlet.bcType=Outlet;
- limitOutlet.p = 155e5;
- boundaryFields["Outlet"] = limitOutlet;
-
- SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
- int nbPhase = myProblem.getNumberOfPhases();
- int nVar = myProblem.getNumberOfVariables();
- Field VV("Primitive", CELLS, M, nVar);//Field of primitive unknowns
-
- // Prepare for the initial condition
- Vector VV_Constant(nVar);
- VV_Constant(0) = 155e5;//pression initiale
- VV_Constant(1) = 5;//vitesse initiale
- VV_Constant(2) = 573;//temperature initiale
-
- cout << "Number of Phases = " << nbPhase << endl;
- cout << "Construction de la condition initiale ... " << endl;
- //set the initial field
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- //set the boundary conditions
- myProblem.setBoundaryFields(boundaryFields);
-
- //Physical parameters
- double heatPower=1e8;
- myProblem.setHeatSource(heatPower);
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
-
- // name file save
- string fileName = "1DHeatedChannel";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep =3;
- int freqSave = 1;
- double cfl = 0.95;
- double maxTime = 5;
- double precision = 1e-7;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- bool ok;
-
- // evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
-
+++ /dev/null
-#include "SinglePhase.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- cout << "Building cartesian mesh" << endl;
- double xinf=0.0;
- double xsup=4.2;
- int nx=100;
- Mesh M(xinf,xsup,nx);
- double eps=1.E-8;
- int spaceDim = M.getSpaceDimension();
-
- //Initial data
- double initialVelocityX =1;
- double initialTemperature=600;
- double initialPressure=155e5;
-
- // physical parameters
- Field porosityField("Porosity", CELLS, M, 1);
- for(int i=0;i<M.getNumberOfCells();i++){
- double x=M.getCell(i).x();
- if (x> (xsup-xinf)/3 && x< 2*(xsup-xinf)/3)
- porosityField[i]=0.5;
- else
- porosityField[i]=1;
- }
- porosityField.writeVTK("PorosityField",true);
-
-
- SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
- int nVar = myProblem.getNumberOfVariables();
-
- // Prepare for the initial condition
- vector<double> VV_Constant(nVar);
- // constant vector
- VV_Constant[0] = initialPressure;
- VV_Constant[1] = initialVelocityX;
- VV_Constant[2] = initialTemperature;
-
- cout << "Building initial data " << endl;
-
- // generate initial condition
- myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"Inlet","Outlet");
-
- //set the boundary conditions
- myProblem.setInletBoundaryCondition("Inlet",initialTemperature,initialVelocityX);
- myProblem.setOutletBoundaryCondition("Outlet",initialPressure,vector<double>(1,xsup));
- // physical parameters
- myProblem.setPorosityField(porosityField);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
- myProblem.setWellBalancedCorrection(true);
- myProblem.setNonLinearFormulation(VFFC) ;
-
- // name file save
- string fileName = "1DPorosityJumpUpwindWB";
-
-
- /* set numerical parameters */
- unsigned MaxNbOfTimeStep =3;
- int freqSave = 1;
- double cfl = 0.95;
- double maxTime = 5;
- double precision = 1e-5;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- bool ok;
-
- // evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
-
-
+++ /dev/null
-#include "SinglePhase.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- cout << "Building Cartesian mesh " << endl;
- double xinf=0.0;
- double xsup=1.0;
- int nx=10;
- Mesh M(xinf,xsup,nx);
- double eps=1.E-8;
- M.setGroupAtPlan(xsup,0,eps,"LeftBoundary");
- M.setGroupAtPlan(xinf,0,eps,"RightBoundary");
- int spaceDim = M.getSpaceDimension();
-
- //initial data
- double initialVelocity_Left=1;
- double initialTemperature_Left=565;
- double initialPressure_Left=155e5;
-
- //boundary data
- double initialVelocity_Right=1;
- double initialTemperature_Right=565;
- double initialPressure_Right=155e5;
-
- SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
- // Prepare for the initial condition
- int nVar = myProblem.getNumberOfVariables();
- Vector VV_Left(nVar),VV_Right(nVar);
- // left and right constant vectors
- VV_Left[0] = initialPressure_Left;
- VV_Left[1] = initialVelocity_Left;
- VV_Left[2] = initialTemperature_Left ;
-
- VV_Right[0] = initialPressure_Right;
- VV_Right[1] = initialVelocity_Right;
- VV_Right[2] = initialTemperature_Right ;
-
- //Initial field creation
- double discontinuity = (xinf+xsup)/2.;
-
- cout << "Building initial data " << endl;
- Field VV("Primitive", CELLS, M, nVar);
-
- myProblem.setInitialFieldStepFunction(M,VV_Left,VV_Right,discontinuity);
-
- //set the boundary conditions
- myProblem.setNeumannBoundaryCondition("LeftBoundary");
- myProblem.setNeumannBoundaryCondition("RightBoundary");
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
-
- // name file save
- string fileName = "1DRiemannProblem";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep = 3;
- int freqSave = 1;
- double cfl = 0.95;
- double maxTime = 5;
- double precision = 1e-8;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.saveConservativeField(true);
- myProblem.setSaveFileFormat(CSV);
-
- // set display option to monitor the calculation
- myProblem.setVerbose( true);
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "SinglePhase.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- /*Preprocessing: mesh and group creation*/
- double xinf=0;
- double xsup=1;
- double yinf=0;
- double ysup=1;
- int nx=10;
- int ny=10;
- cout << "Building a regular mesh with "<<nx<<" times "<< ny<< " cells " << endl;
- Mesh M(xinf,xsup,nx,yinf,ysup,ny);
- double eps=1.E-6;
- M.setGroupAtPlan(xinf,0,eps,"coldWall");
- M.setGroupAtPlan(xsup,0,eps,"hotWall");
- M.setGroupAtPlan(yinf,1,eps,"coldWall");
- M.setGroupAtPlan(ysup,1,eps,"hotWall");
- int spaceDim = M.getSpaceDimension();
-
- // physical constants
- vector<double> viscosite(1), conductivite(1);
- viscosite[0]= 8.85e-5;
- conductivite[0]=1000;//transfert de chaleur du à l'ébullition en paroi.
- vector<double> gravite(spaceDim,0.) ;
- gravite[1]=-10;
- gravite[0]=0;
-
- // set the limit field for each boundary
- LimitField limitColdWall, limitHotWall;
- map<string, LimitField> boundaryFields;
- limitColdWall.bcType=Wall;
- limitColdWall.T = 590;//Temperature de la parois froide
- limitColdWall.v_x = vector<double>(1,0);
- limitColdWall.v_y = vector<double>(1,0);
- boundaryFields["coldWall"]= limitColdWall;
-
- limitHotWall.bcType=Wall;
- limitHotWall.T = 560;//Temperature des parois chauffantes
- limitHotWall.v_x = vector<double>(1,0);
- limitHotWall.v_y = vector<double>(1,0);
- boundaryFields["hotWall"]= limitHotWall;
-
- SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
- int nVar = myProblem.getNumberOfVariables();
-
- //Initial field creation
- cout << "Building initial data" << endl;
- /* First case constant initial data */
- Vector VV_Constant(nVar);
- // constant vector
- VV_Constant(0) = 155e5;
- VV_Constant(1) = 0;
- VV_Constant(2) = 0;
- VV_Constant(3) = 573;
-
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- //set the boundary conditions
- myProblem.setBoundaryFields(boundaryFields);
-
- // physical parameters
- myProblem.setViscosity(viscosite);
- myProblem.setConductivity(conductivite);
- myProblem.setGravity(gravite);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Implicit);
-
- // set the Petsc resolution
- myProblem.setLinearSolver(GMRES,LU,false);
-
- // name result file
- string fileName = "2DHeatDrivenCavity";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep = 3;
- int freqSave = 1;
- double cfl = 10;
- double maxTime = 50;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,50);
- myProblem.saveVelocity();
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
-
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "SinglePhase.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- /*Preprocessing: mesh and group creation*/
- double xinf=0;
- double xsup=1;
- double yinf=0;
- double ysup=1;
- cout << "Loading unstuctured mesh for test SinglePhase_2DHeatDrivenCavity_unstructured" << endl;
- Mesh M("resources/BoxWithMeshWithTriangularCells.med");
- double eps=1.E-6;
- M.setGroupAtPlan(xinf,0,eps,"coldWall");
- M.setGroupAtPlan(xsup,0,eps,"hotWall");
- M.setGroupAtPlan(yinf,1,eps,"coldWall");
- M.setGroupAtPlan(ysup,1,eps,"hotWall");
- int spaceDim = M.getSpaceDimension();
-
- // physical constants
- vector<double> viscosite(1), conductivite(1);
- viscosite[0]= 8.85e-5;
- conductivite[0]=1000;//transfert de chaleur du à l'ébullition en paroi.
- vector<double> gravite(spaceDim,0.) ;
- gravite[1]=-10;
- gravite[0]=0;
-
- // set the limit field for each boundary
- LimitField limitColdWall, limitHotWall;
- map<string, LimitField> boundaryFields;
- limitColdWall.bcType=Wall;
- limitColdWall.T = 590;//Temperature de la parois froide
- limitColdWall.v_x = vector<double>(1,0);
- limitColdWall.v_y = vector<double>(1,0);
- boundaryFields["coldWall"]= limitColdWall;
-
- limitHotWall.bcType=Wall;
- limitHotWall.T = 560;//Temperature des parois chauffantes
- limitHotWall.v_x = vector<double>(1,0);
- limitHotWall.v_y = vector<double>(1,0);
- boundaryFields["hotWall"]= limitHotWall;
-
- SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
- int nVar = myProblem.getNumberOfVariables();
-
- //Initial field creation
- cout << "Construction de la condition initiale" << endl;
- /* First case constant initial data */
- Vector VV_Constant(nVar);
- // constant vector
- VV_Constant(0) = 155e5;
- VV_Constant(1) = 0;
- VV_Constant(2) = 0;
- VV_Constant(3) = 573;
-
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- //set the boundary conditions
- myProblem.setBoundaryFields(boundaryFields);
-
- // physical parameters
- myProblem.setViscosity(viscosite);
- myProblem.setConductivity(conductivite);
- myProblem.setGravity(gravite);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Implicit);
-
- // set the Petsc resolution
- myProblem.setLinearSolver(GMRES,ILU,true);
-
- // name result file
- string fileName = "2DHeatDrivenCavity_unstructured";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep = 3;
- int freqSave = 1;
- double cfl = 1;
- double maxTime = 50;
- double precision = 1e-7;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,50);
- myProblem.saveVelocity();
-
- // evolution
- myProblem.initialize();
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
-
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "SinglePhase.hxx"
-#include <iostream>
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- int spaceDim = 2;
-
- // Prepare for the mesh
- double xinf = 0 ;
- double xsup=3.0;
- double yinf=0.0;
- double ysup=5.0;
- int nx=10;
- int ny=10;
-
- // set the limit field for each boundary
- double wallVelocityX=0;
- double wallVelocityY=0;
- double wallTemperature=573;
- double inletVelocityX=0;
- double inletVelocityY=0.5;
- double inletTemperature=563;
- double outletPressure=155e5;
-
- // physical constants
- vector<double> gravite (spaceDim);
-
- gravite[1]=-7;
- gravite[0]=7;
-
- double heatPower=1e8;
-
- SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
- int nVar =myProblem.getNumberOfVariables();
-
- // Prepare for the initial condition
- vector<double> VV_Constant (nVar);
-
- // constant vector
- VV_Constant[0] = outletPressure ;
- VV_Constant[1] = inletVelocityX;
- VV_Constant[2] = inletVelocityY;
- VV_Constant[3] = inletTemperature ;
-
- //Initial field creation
- cout<<"Building initial data"<<endl;
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
- xinf,xsup,nx,"wall","wall",
- yinf,ysup,ny,"inlet","outlet",
- 0.0,0.0, 0, "", "");
-
- // the boundary conditions
- vector<double>pressure_reference_point(2);
- pressure_reference_point[0]=xsup;
- pressure_reference_point[1]=ysup;
- myProblem.setOutletBoundaryCondition("outlet", outletPressure,pressure_reference_point);
- myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletVelocityX, inletVelocityY);
- myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
-
- // set physical parameters
- myProblem.setHeatSource(heatPower);
- myProblem.setGravity(gravite);
-
- // set the numerical method
- myProblem.setNumericalScheme(staggered, Implicit);
- myProblem.setNonLinearFormulation(VFFC);
-
- // name file save
- string fileName = "2DInclinedHeatedChannel";
-
- /* set numerical parameters */
- unsigned MaxNbOfTimeStep =3;
- int freqSave = 1;
- double cfl = 0.95;
- double maxTime = 5;
- double precision = 1e-5;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.usePrimitiveVarsInNewton(true);
- bool ok;
-
- // evolution
- myProblem.initialize();
-
- ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
-
+++ /dev/null
-#include "SinglePhase.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- cout << "Building cartesian mesh " << endl;
- double xinf=0.0;
- double xsup=1;
- double yinf=0.0;
- double ysup=1;
- int nx=50;
- int ny=50;
- Mesh M(xinf,xsup,nx,yinf,ysup,ny);
- int spaceDim = M.getSpaceDimension();
-
- // physical constants
- vector<double> viscosite(1) ;
- viscosite[0]= 0.025;
-
- // set the limit field for each boundary
- double fixedWallVelocityX=0;
- double fixedWallVelocityY=0;
- double fixedWallTemperature=273;
-
- double movingWallVelocityX=1;
- double movingWallVelocityY=0;
- double movingWallTemperature=273;
-
-
- SinglePhase myProblem(Gas,around1bar300K,spaceDim);
- // Prepare for the initial condition
- int nVar = myProblem.getNumberOfVariables();
- vector<double> VV_Constant(nVar);
- // constant vector
- VV_Constant[0] = 1e5;
- VV_Constant[1] = 0;
- VV_Constant[2] = 0;
- VV_Constant[3] = 273;
-
- // name output file
- string fileName = "2DLidDrivenCavityStructuredCentered1bar";
-
- //Initial field creation
- cout << "Building initial data" << endl;
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"fixedWall","fixedWall",yinf,ysup,ny,"fixedWall","movingWall");
-
- //set the boundary conditions
- myProblem.setWallBoundaryCondition("fixedWall", fixedWallTemperature, fixedWallVelocityX, fixedWallVelocityY);
- myProblem.setWallBoundaryCondition("movingWall", movingWallTemperature, movingWallVelocityX, movingWallVelocityY);
-
- // physical parameters
- myProblem.setViscosity(viscosite);
-
- // set the numerical method
- myProblem.setNumericalScheme(staggered, Implicit);
-
- // set the Petsc resolution
- myProblem.setLinearSolver(GMRES,LU,true);
-
- //Numerical parameters
- unsigned MaxNbOfTimeStep = 3 ;
- int freqSave = 1;
- double cfl = 1;
- double maxTime = 100000;
- double precision = 1e-9;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision*1e8,20);
- myProblem.saveVelocity();
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-
-}
+++ /dev/null
-#include "SinglePhase.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- /* preprocessing: mesh and group creation */
- cout << "Loading unstructured mesh for test SinglePhase_2DLidDrivenCavity_unstructured()" << endl;
- double xinf=0.0;
- double xsup=1.0;
- double yinf=0.0;
- double ysup=1.0;
- Mesh M("resources/BoxWithMeshWithTriangularCells.med");
- double eps=1.E-6;
- M.setGroupAtPlan(xsup,0,eps,"wall");
- M.setGroupAtPlan(xinf,0,eps,"wall");
- M.setGroupAtPlan(yinf,1,eps,"wall");
- M.setGroupAtPlan(ysup,1,eps,"MovingWall");
- int spaceDim = M.getSpaceDimension();
-
- // physical constants
- vector<double> viscosite(1) ;
- viscosite[0]= 0.025;
-
- /* set the limit field for each boundary*/
- LimitField limitWall;
- map<string, LimitField> boundaryFields;
- limitWall.bcType=Wall;
- limitWall.T = 273;
- limitWall.p = 1e5;
- limitWall.v_x = vector<double>(1,0);
- limitWall.v_y = vector<double>(1,0);
- limitWall.v_z = vector<double>(1,0);
- boundaryFields["wall"]= limitWall;
-
- LimitField limitMovingWall;
- limitMovingWall.bcType=Wall;
- limitMovingWall.T = 273;
- limitMovingWall.p = 1e5;
- limitMovingWall.v_x = vector<double>(1,1);
- limitMovingWall.v_y = vector<double>(1,0);
- limitMovingWall.v_z = vector<double>(1,0);
- boundaryFields["MovingWall"]= limitMovingWall;
-
-
- SinglePhase myProblem(Liquid,around1bar300K,spaceDim);
- int nbPhase = myProblem.getNumberOfPhases();
- // Prepare for the initial condition
- int nVar = myProblem.getNumberOfVariables();
- Vector VV_Constant(nVar);
- // constant vector
- VV_Constant(0) = 1e5;
- VV_Constant(1) = 0;
- VV_Constant(2) = 0;
- VV_Constant(3) = 273;
-
- //Initial field creation
- cout << "Setting initial data " << endl;
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- //set the boundary conditions
- myProblem.setBoundaryFields(boundaryFields);
-
- // physical parameters
- myProblem.setViscosity(viscosite);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Implicit);
-
- // set the Petsc resolution
- myProblem.setLinearSolver(GMRES,ILU,true);
-
- // name file save
- string fileName = "2DLidDrivenCavity_unstructured";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep = 3 ;
- int freqSave = 1;
- double cfl = 5;
- double maxTime = 5;
- double precision = 1e-8;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveVelocity();
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "SinglePhase.hxx"
-
-using namespace std;
-
-//Function that generates and save a spherical initial data
-/*void initialField(){
- int spaceDim = 2;
- int nVar=2+spaceDim;
- double x,y;
- cout << "Loading unstructured mesh " << endl;
- Mesh M("../examples/resources/BoxWithMeshWithTriangularCells.med");
- Field VV("Primitive variables for spherical explosion", CELLS, M, nVar);
- vector<double>Vout(nVar), Vin(nVar);
- Vin[0]=1.1;
- Vin[1]=0;
- Vin[2]=0;
- Vin[3]=300;
- Vout[0]=1;
- Vout[1]=0;
- Vout[2]=0;
- Vout[3]=300;
-
- for(int i=0;i<M.getNumberOfCells();i++){
- x=M.getCell(i).x();
- y=M.getCell(i).y();
- if((x-0.5)*(x-0.5)+(y-0.5)*(y-0.5)<0.25*0.25)
- for(int j=0;j<nVar;j++)
- VV(i,j)=Vin[j];
- else
- for(int j=0;j<nVar;j++)
- VV(i,j)=Vout[j];
- }
- //VV.writeMED("../examples/ressources/BoxWithMeshWithTriangularCells",false);
-}*/
-int main(int argc, char** argv)
-{
- // preprocessing: mesh and group creation
- cout << "Loading unstructured mesh and initial data for test SinglePhase_2DSphericalExplosion_unstructured()" << endl;
- string inputfile="resources/BoxWithMeshWithTriangularCells";
- string fieldName="Initial variables for spherical explosion";
- int spaceDim=2;
-
- SinglePhase myProblem(Gas,around1bar300K,spaceDim);
-
- //Initial field creation
- cout << "Loading unstructured mesh and initial data for test SinglePhase_2DSphericalExplosion_unstructured()" << endl;
- myProblem.setInitialField(inputfile,fieldName,0);
-
- //set the boundary conditions
- double wallVelocityX=0;
- double wallVelocityY=0;
- double wallTemperature=563;
- myProblem.setWallBoundaryCondition("GAUCHE", wallTemperature, wallVelocityX, wallVelocityY);
- myProblem.setWallBoundaryCondition("DROITE", wallTemperature, wallVelocityX, wallVelocityY);
- myProblem.setWallBoundaryCondition("HAUT", wallTemperature, wallVelocityX, wallVelocityY);
- myProblem.setWallBoundaryCondition("BAS", wallTemperature, wallVelocityX, wallVelocityY);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
-
- // name file save
- string fileName = "2DSphericalExplosion_unstructured";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep = 3 ;
- int freqSave = 5;
- double cfl = 0.5;
- double maxTime = 5;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveVelocity();
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "SinglePhase.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group creation
- double xinf=-0.005;
- double xsup= 0.005;
- double yinf=0.0;
- double ysup=2.0;
- int nx=50;
- int ny=50;
- cout << "Building a regular mesh with "<<nx<<" times "<< ny<< " cells " << endl;
- Mesh M(xinf,xsup,nx,yinf,ysup,ny);
- double eps=1.E-6;
- M.setGroupAtPlan(xsup,0,eps,"wall");
- M.setGroupAtPlan(xinf,0,eps,"wall");
- M.setGroupAtPlan(yinf,1,eps,"Neumann");//Inlet
- M.setGroupAtPlan(ysup,1,eps,"Neumann");//Outlet
- int spaceDim = M.getSpaceDimension();
-
- // physical constants
- vector<double> viscosite(1), conductivite(1);
- viscosite[0]= 8.85e-5;
- conductivite[0]=1000;//transfert de chaleur du à l'ébullition en paroi.
-
- // set the limit field for each boundary
- LimitField limitWall;
- map<string, LimitField> boundaryFields;
- limitWall.bcType=Wall;
- limitWall.T = 623;//Temperature des parois chauffantes
- limitWall.p = 155e5;
- limitWall.v_x = vector<double>(1,0);
- limitWall.v_y = vector<double>(1,0);
- boundaryFields["wall"]= limitWall;
-
- LimitField limitInlet;
- limitInlet.bcType=Inlet;
- limitInlet.T = 573;//Temperature d'entree du fluide
- limitInlet.v_x = vector<double>(1,0);
- limitInlet.v_y = vector<double>(1,5);//Vitesse d'entree du fluide
- boundaryFields["Inlet"]= limitInlet;
-
- LimitField limitOutlet;
- limitOutlet.bcType=Outlet;
- limitOutlet.p = 155e5;
- boundaryFields["Outlet"]= limitOutlet;
-
- LimitField limitNeumann;
- limitNeumann.bcType=Neumann;
- boundaryFields["Neumann"] = limitNeumann;
-
- SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
- int nVar = myProblem.getNumberOfVariables();
-
- //Initial field creation
- cout << "Construction de la condition initiale" << endl;
- /* First case constant initial data */
- Vector VV_Constant(nVar);
- // constant vector
- VV_Constant(0) = 155e5;
- VV_Constant(1) = 0;
- VV_Constant(2) = 5;
- VV_Constant(3) = 573;
- /* Second case restart from a previous calculation */
-/*
- string inputfile = "SinglePhasePrim_2DChannelWithViscosityWithConduction";//nom du fichier (sans le .med)
- int iter=50400;//numero du pas de temps a recuperer dans le fichier
- Field VV1(inputfile,CELLS,"P,vx,vy,T",iter,0);//Chargement des valeurs du champ
- for(int i=0;i<M.getNumberOfCells();i++)
- for(int j=0;j<nVar;j++)
- VV(i,j)=VV1(i,j);//recuperation des valeurs du champ
-*/
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- //set the boundary conditions
- myProblem.setBoundaryFields(boundaryFields);
-
- // physical parameters
- myProblem.setViscosity(viscosite);
- myProblem.setConductivity(conductivite);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Implicit);
-
- // set the Petsc resolution
- myProblem.setLinearSolver(GMRES,ILU,true);
-
- // name result file
- string fileName = "2DHeatedWallChannel";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep = 3;
- int freqSave = 1;
- double cfl = 10;
- double maxTime = 50;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,50);
- myProblem.saveVelocity();
-
- // evolution
- myProblem.initialize();
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
-
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "SinglePhase.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- //Preprocessing: mesh and group importation
- cout << "Reading a mesh with sudden cross-section change for test SinglePhase_2DWallHeatedChannel_ChangeSect()" << endl;
- Mesh M("resources/VaryingSectionDuct.med");
-
- // Conditions aux limites
- //Bords externes
- double xinf=0.0;
- double xsup=0.01;
- double yinf=0.0;
- double ysup=0.01;
- double eps=1.E-6;
- M.setGroupAtPlan(xsup,0,eps,"Wall");
- M.setGroupAtPlan(xinf,0,eps,"Wall");
- M.setGroupAtPlan(yinf,1,eps,"Inlet");//
- M.setGroupAtPlan(ysup,1,eps,"Outlet");//
- //Bords internes
- int nx=60, ny=60;//Nombre de cellules utilisees au depart dans Salome ou Alamos
- double dx = (xsup-xinf)/nx, dy = (ysup-yinf)/ny;//taille d'une cellule
- for(int i=0; i<ny/2;i++){
- M.setGroupAtFaceByCoords((xsup-xinf)/4,(ysup-yinf)/4+(i+0.5)*dy,0,eps,"Wall");//Paroi verticale intérieure gauche
- M.setGroupAtFaceByCoords((xsup-xinf)*3/4,(ysup-yinf)/4+(i+0.5)*dy,0,eps,"Wall");//Paroi verticale intérieure droitee
- }
- for(int i=0; i<nx/4;i++){
- M.setGroupAtFaceByCoords((i+0.5)*dx,(ysup-yinf)/4,0,eps,"Wall");//paroi horizontale en bas à gauche
- M.setGroupAtFaceByCoords((i+0.5)*dx,(ysup-yinf)*3/4,0,eps,"Wall");//paroi horizontale en haut à gauche
- M.setGroupAtFaceByCoords((xsup-xinf)*3/4+(i+0.5)*dx,(ysup-yinf)/4,0,eps,"Wall");//paroi horizontale en bas à droite
- M.setGroupAtFaceByCoords((xsup-xinf)*3/4+(i+0.5)*dx,(ysup-yinf)*3/4,0,eps,"Wall");//paroi horizontale en haut à droite
- }
-
- int spaceDim = M.getSpaceDimension();
-
- // set the limit field for each boundary
- LimitField limitWall;
- map<string, LimitField> boundaryFields;
- limitWall.bcType=Wall;
- limitWall.T = 623;//Temperature des parois chauffantes
- limitWall.p = 155e5;
- limitWall.v_x = vector<double>(1,0);
- limitWall.v_y = vector<double>(1,0);
- boundaryFields["Wall"]= limitWall;
-
- LimitField limitInlet;
- limitInlet.bcType=Inlet;
- limitInlet.T = 573;//Temperature d'entree du fluide
- limitInlet.v_x = vector<double>(1,0);
- limitInlet.v_y = vector<double>(1,2.5);//Vitesse d'entree du fluide
- boundaryFields["Inlet"]= limitInlet;
-
- LimitField limitOutlet;
- limitOutlet.bcType=Outlet;
- limitOutlet.p = 155e5;
- boundaryFields["Outlet"]= limitOutlet;
-
- SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
- // Prepare for the initial condition
- int nVar = myProblem.getNumberOfVariables();
- Vector VV_Constant(nVar);
- // constant vector
- VV_Constant(0) = 155e5;
- VV_Constant(1) = 0;
- VV_Constant(2) = 2.5;
- VV_Constant(3) = 573;
-
- //Initial field creation
- cout << "Building initial data" << endl;
- myProblem.setInitialFieldConstant(M,VV_Constant);
-
- // physical constants
- vector<double> viscosite(1), conductivite(1);
- viscosite[0]= 8.85e-5;
- conductivite[0]=1000;//transfert de chaleur du à l'ébullition en paroi.
-
- //Set boundary values
- myProblem.setBoundaryFields(boundaryFields);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
-
- // name result file
- string fileName = "2DWallHeatedChannel_ChangeSect";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep = 3;
- int freqSave = 1;
- double cfl =.5;
- double maxTime = 500;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,50);
- myProblem.saveVelocity();
-
- // evolution
- myProblem.initialize();
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
-
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "SinglePhase.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
- int spaceDim = 3;
- /*Preprocessing: mesh data*/
- double xinf=0;
- double xsup=1;
- double yinf=0;
- double ysup=1;
- double zinf=0;
- double zsup=1;
- int nx=10;
- int ny=10;
- int nz=10;
-
- /* set the limit field for each boundary*/
- double coldWallVelocityX=0;
- double coldWallVelocityY=0;
- double coldWallVelocityZ=0;
- double coldWallTemperature=563;
-
- double hotWallVelocityX=0;
- double hotWallVelocityY=0;
- double hotWallVelocityZ=0;
- double hotWallTemperature=613;
-
- /* physical constants*/
- vector<double> gravite(spaceDim,0.) ;
- gravite[2]=-10;
- gravite[1]=0;
- gravite[0]=0;
- vector<double> viscosite(1), conductivite(1);
- viscosite[0]= 8.85e-5;
- conductivite[0]=1000;//nucleate boiling heat transfert coefficient
-
- SinglePhase myProblem(Liquid,around155bars600K,spaceDim);
- int nVar = myProblem.getNumberOfVariables();
-
- //Initial field creation
- cout << "Construction de la condition initiale" << endl;
- vector<double> VV_Constant(nVar);
- // constant vector
- VV_Constant[0] = 155e5;
- VV_Constant[1] = 0;
- VV_Constant[2] = 0;
- VV_Constant[3] = 0;
- VV_Constant[4] = 573;
- myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"hotWall","hotWall",
- yinf,ysup,ny,"hotWall","hotWall",
- zinf,zsup,nz,"hotWall","coldWall");
-
- //set the boundary conditions
- myProblem.setWallBoundaryCondition("coldWall", coldWallTemperature, coldWallVelocityX, coldWallVelocityY, coldWallVelocityZ);
- myProblem.setWallBoundaryCondition("hotWall", hotWallTemperature, hotWallVelocityX, hotWallVelocityY, hotWallVelocityZ);
-
-
- // physical parameters
- myProblem.setViscosity(viscosite);
- myProblem.setConductivity(conductivite);
- myProblem.setGravity(gravite);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Implicit);
-
- // set the Petsc resolution
- myProblem.setLinearSolver(GMRES,ILU,false);
-
- // name result file
- string fileName = "3DHeatDrivenCavity";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep = 3;
- int freqSave = 1;
- double cfl = 10;
- double maxTime = 50;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,50);
- myProblem.saveVelocity();
-
- // evolution
- myProblem.initialize();
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
-
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "SinglePhase.hxx"
-
-using namespace std;
-
-
-int main(int argc, char** argv)
-{
- // preprocessing: mesh and group creation
- cout << "Loading unstructured mesh for test SinglePhase_3DSphericalExplosion_unstructured()" << endl;
- string inputfile="resources/meshCube.med";
-
- double xinf=0;
- double xsup=1;
- double yinf=0;
- double ysup=1;
- double zinf=0;
- double zsup=1;
- Mesh M(inputfile);
- double eps=1.E-6;
- M.setGroupAtPlan(xinf,0,eps,"GAUCHE");
- M.setGroupAtPlan(xsup,0,eps,"DROITE");
- M.setGroupAtPlan(yinf,1,eps,"ARRIERE");
- M.setGroupAtPlan(ysup,1,eps,"AVANT");
- M.setGroupAtPlan(zinf,2,eps,"BAS");
- M.setGroupAtPlan(zsup,2,eps,"HAUT");
-
- /* Initial field data */
- int spaceDim = 3;
- int nVar=2+spaceDim;
- double radius=0.5;
- Vector Center(3);//default value is (0,0,0)
- Vector Vout(nVar), Vin(nVar);
- Vin[0]=1.1;
- Vin[1]=0;
- Vin[2]=0;
- Vin[3]=0;
- Vin[4]=300;
- Vout[0]=1;
- Vout[1]=0;
- Vout[2]=0;
- Vout[3]=0;
- Vout[4]=300;
-
-
- SinglePhase myProblem(Gas,around1bar300K,spaceDim);
-
- /*Setting mesh and Initial */
- cout << "Setting initial data " << endl;
- myProblem.setInitialFieldSphericalStepFunction( M, Vout, Vin, radius, Center);
-
- //set the boundary conditions
- double wallVelocityX=0;
- double wallVelocityY=0;
- double wallVelocityZ=0;
- double wallTemperature=563;
- myProblem.setWallBoundaryCondition("GAUCHE", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
- myProblem.setWallBoundaryCondition("DROITE", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
- myProblem.setWallBoundaryCondition("HAUT", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
- myProblem.setWallBoundaryCondition("BAS" , wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
- myProblem.setWallBoundaryCondition("AVANT", wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
- myProblem.setWallBoundaryCondition("ARRIERE" , wallTemperature, wallVelocityX, wallVelocityY, wallVelocityZ);
-
- // set the numerical method
- myProblem.setNumericalScheme(upwind, Explicit);
-
- // name file save
- string fileName = "3DSphericalExplosion_unstructured";
-
- // parameters calculation
- unsigned MaxNbOfTimeStep = 3 ;
- int freqSave = 1;
- double cfl = 0.3;
- double maxTime = 5;
- double precision = 1e-6;
-
- myProblem.setCFL(cfl);
- myProblem.setPrecision(precision);
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
- myProblem.setTimeMax(maxTime);
- myProblem.setFreqSave(freqSave);
- myProblem.setFileName(fileName);
- myProblem.setNewtonSolver(precision,20);
- myProblem.saveVelocity();
-
- // evolution
- myProblem.initialize();
-
- bool ok = myProblem.run();
- if (ok)
- cout << "Simulation "<<fileName<<" is successful !" << endl;
- else
- cout << "Simulation "<<fileName<<" failed ! " << endl;
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "SinglePhase.hxx"\r
-\r
-using namespace std;\r
-\r
-int main(int argc, char** argv)\r
-{\r
- //Preprocessing: mesh and group creation\r
- cout << "Reading mesh with two branches and two forks" << endl;\r
- Mesh M("resources/BifurcatingFlow2BranchesEqualSections.med");\r
- cout << "Reading power and coss sectional area fields " << endl;\r
- Field Sections("resources/BifurcatingFlow2BranchesEqualSections", CELLS,"Section area");\r
- Field heatPowerField("resources/BifurcatingFlow2BranchesEqualSections", CELLS,"Heat power");\r
-\r
- heatPowerField.writeVTK("heatPowerField");\r
- Sections.writeVTK("crossSectionPowerField");\r
-\r
- M.getFace(0).setGroupName("Inlet");//z==0\r
- M.getFace(31).setGroupName("Outlet");//z==4.2\r
- cout<<"F0.isBorder() "<<M.getFace(0).isBorder()<<endl;\r
- int meshDim = 1;//M.getSpaceDimension();\r
-\r
- // set the limit values for each boundary\r
- double inletTemperature =573.;\r
- double inletVelocityX = 5;\r
- double outletPressure = 155e5;\r
-\r
- SinglePhase myProblem(Liquid,around155bars600K,meshDim);\r
- int nVar = myProblem.getNumberOfVariables();\r
-\r
- //Set heat source\r
- myProblem.setHeatPowerField(heatPowerField);\r
- //Set gravity force\r
- vector<double> gravite(1,-10);\r
- myProblem.setGravity(gravite);\r
-\r
- //Set section field\r
- myProblem.setSectionField(Sections);\r
- // Prepare the initial condition\r
- Vector VV_Constant(nVar);\r
- VV_Constant(0) = 155e5;\r
- VV_Constant(1) = 5;\r
- VV_Constant(2) = 573;\r
-\r
- cout << "Building initial data " << endl;\r
-\r
- // generate initial condition\r
- myProblem.setInitialFieldConstant(M,VV_Constant);\r
-\r
- //set the boundary conditions\r
- myProblem.setInletBoundaryCondition("Inlet",inletTemperature,inletVelocityX);\r
- myProblem.setOutletBoundaryCondition("Outlet", outletPressure);\r
-\r
- // set the numerical method\r
- myProblem.setNumericalScheme(upwind, Explicit);\r
- myProblem.setWellBalancedCorrection(true);\r
-\r
- // name file save\r
- string fileName = "2BranchesHeatedChannels";\r
-\r
- // parameters calculation\r
- unsigned MaxNbOfTimeStep =3;\r
- int freqSave = 1;\r
- double cfl = 0.5;\r
- double maxTime = 5;\r
- double precision = 1e-6;\r
-\r
- myProblem.setCFL(cfl);\r
- myProblem.setPrecision(precision);\r
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
- myProblem.setTimeMax(maxTime);\r
- myProblem.setFreqSave(freqSave);\r
- myProblem.setFileName(fileName);\r
- bool ok;\r
-\r
- // evolution\r
- myProblem.initialize();\r
- ok = myProblem.run();\r
- if (ok)\r
- cout << "Simulation "<<fileName<<" is successful !" << endl;\r
- else\r
- cout << "Simulation "<<fileName<<" failed ! " << endl;\r
-\r
- cout << "------------ End of calculation -----------" << endl;\r
- myProblem.terminate();\r
-\r
- return EXIT_SUCCESS;\r
-}\r
-\r
+++ /dev/null
-#include "StationaryDiffusionEquation.hxx"
-#include "math.h"
-#include <assert.h>
-
-double pi = M_PI;
-using namespace std;
-
-int main(int argc, char** argv)
-{
- int spaceDim = 2;
-
- /* Mesh data */
- double xinf=0.0;
- double xsup=1.0;
- double yinf=0.0;
- double ysup=1.0;
- int nx=20;
- int ny=20;
-
- /* Mesh construction */
- Mesh M(xinf,xsup,nx,yinf,ysup,ny,0); //Regular triangular mesh
-
- /* set the limit field for each boundary */
- double eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1");
- M.setGroupAtPlan(xinf,0,eps,"Bord2");
- M.setGroupAtPlan(ysup,1,eps,"Bord3");
- M.setGroupAtPlan(yinf,1,eps,"Bord4");
-
- /* set the boundary values for each boundary */
- double T1=0;
- double T2=0;
- double T3=0;
- double T4=0;
-
- cout<< "Built a regular triangular 2D mesh from a square mesh with "<< nx<<"x" <<ny<< " cells"<<endl;
-
- /* Create the problem */
- bool FEComputation=true;
- StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- /* set the boundary conditions */
- myProblem.setDirichletBoundaryCondition("Bord1",T1);
- myProblem.setDirichletBoundaryCondition("Bord2",T2);
- myProblem.setDirichletBoundaryCondition("Bord3",T3);
- myProblem.setDirichletBoundaryCondition("Bord4",T4);
-
- /* Set the right hand side function*/
- Field my_RHSfield("RHS_field", NODES, M, 1);
- Node Ni;
- double x, y;
- for(int i=0; i< M.getNumberOfNodes(); i++)
- {
- Ni= M.getNode(i);
- x = Ni.x();
- y = Ni.y();
-
- my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y);//mettre la fonction definie au second membre de l'edp
- }
- myProblem.setHeatPowerField(my_RHSfield);
- myProblem.setLinearSolver(GMRES,ILU);
-
- /* name the result file */
- string fileName = "StationnaryDiffusion_2DFV_StructuredTriangles";
- myProblem.setFileName(fileName);
-
- /* Run the computation */
- myProblem.initialize();
- bool ok = myProblem.solveStationaryProblem();
- if (!ok)
- cout << "Simulation of "<<fileName<<" failed !" << endl;
- else
- {
- /********************** Postprocessing and measure od numerical error******************************/
- Field my_ResultField = myProblem.getOutputTemperatureField();
- /* The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi */
- double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi);
- double max_sol_num=my_ResultField.max();
- double min_sol_num=my_ResultField.min();
- double erreur_abs=0;
- for(int i=0; i< M.getNumberOfNodes() ; i++)
- if( erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) )
- erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]);
-
- cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
- cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
- cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
-
- assert( erreur_abs/max_abs_sol_exacte <1.);
-
- cout << "Simulation of "<<fileName<<" is successful ! " << endl;
- }
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "StationaryDiffusionEquation.hxx"
-#include "math.h"
-#include <assert.h>
-
-double pi = M_PI;
-using namespace std;
-
-int main(int argc, char** argv)
-{
- int spaceDim = 2;
-
- /* Mesh data */
- double xinf=0.0;
- double xsup=1.0;
- double yinf=0.0;
- double ysup=1.0;
- int nx=20;
- int ny=20;
-
- /* Mesh construction */
- Mesh M(xinf,xsup,nx,yinf,ysup,ny,0); //Regular triangular mesh
-
- /* set the limit field for each boundary */
- double eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1");
- M.setGroupAtPlan(xinf,0,eps,"Bord2");
- M.setGroupAtPlan(ysup,1,eps,"Bord3");
- M.setGroupAtPlan(yinf,1,eps,"Bord4");
-
- /* set the boundary values for each boundary */
- double T1=0;
- double T2=0;
- double T3=0;
- double T4=0;
-
- cout<< "Built a regular triangular 2D mesh from a square mesh with "<< nx<<"x" <<ny<< " cells"<<endl;
-
- /* Create the problem */
- bool FEComputation=true;
- StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- /* set the boundary conditions */
- myProblem.setNeumannBoundaryCondition("Bord1");
- myProblem.setNeumannBoundaryCondition("Bord2");
- myProblem.setNeumannBoundaryCondition("Bord3");
- myProblem.setNeumannBoundaryCondition("Bord4");
-
- /* Set the right hand side function*/
- Field my_RHSfield("RHS_field", NODES, M, 1);
- Node Ni;
- double x, y;
- for(int i=0; i< M.getNumberOfNodes(); i++)
- {
- Ni= M.getNode(i);
- x = Ni.x();
- y = Ni.y();
-
- my_RHSfield[i]=2*pi*pi*cos(pi*x)*cos(pi*y);//mettre la fonction definie au second membre de l'edp
- }
- myProblem.setHeatPowerField(my_RHSfield);
- myProblem.setLinearSolver(GMRES,ILU);
-
- /* name the result file */
- string fileName = "StationnaryDiffusion_2DFV_StructuredTriangles_Neumann";
- myProblem.setFileName(fileName);
-
- /* Run the computation */
- myProblem.initialize();
- bool ok = myProblem.solveStationaryProblem();
- if (!ok)
- cout << "Simulation of "<<fileName<<" failed !" << endl;
- else
- {
- /********************** Postprocessing and measure od numerical error******************************/
- Field my_ResultField = myProblem.getOutputTemperatureField();
- /* The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi */
- double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi);
- double max_sol_num=my_ResultField.max();
- double min_sol_num=my_ResultField.min();
- double erreur_abs=0;
- for(int i=0; i< M.getNumberOfNodes() ; i++)
- if( erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) )
- erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]);
-
- cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
- cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
- cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
-
- assert( erreur_abs/max_abs_sol_exacte <1.);
-
- cout << "Simulation of "<<fileName<<" is successful ! " << endl;
- }
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "StationaryDiffusionEquation.hxx"
-#include "math.h"
-#include <assert.h>
-
-double pi = M_PI;
-using namespace std;
-
-int main(int argc, char** argv)
-{
- int spaceDim = 2;
-
- /* Square mesh and groups loading */
- string filename="resources/squareWithTriangles.med";
- cout << "Loading mesh and groups from file" << filename<<endl;
- Mesh M(filename);//unstructured triangular mesh
-
- /* set the limit field for each boundary */
- double eps=1e-6;
- M.setGroupAtPlan(0,0,eps,"Bord1");
- M.setGroupAtPlan(1,0,eps,"Bord2");
- M.setGroupAtPlan(0,1,eps,"Bord3");
- M.setGroupAtPlan(1,1,eps,"Bord4");
-
- cout<< "Loaded unstructured 2D mesh with "<< M.getNumberOfCells()<<" cells and " <<M.getNumberOfNodes()<< " nodes"<<endl;
-
- /* set the boundary values for each boundary */
- double T1=0;
- double T2=0;
- double T3=0;
- double T4=0;
-
- /* Create the problem */
- bool FEComputation=true;
- StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- /* set the boundary conditions */
- myProblem.setDirichletBoundaryCondition("Bord1",T1);
- myProblem.setDirichletBoundaryCondition("Bord2",T2);
- myProblem.setDirichletBoundaryCondition("Bord3",T3);
- myProblem.setDirichletBoundaryCondition("Bord4",T4);
-
- /* Set the right hand side function*/
- Field my_RHSfield("RHS_field", NODES, M, 1);
- Node Ni;
- double x, y;
- for(int i=0; i< M.getNumberOfNodes(); i++)
- {
- Ni= M.getNode(i);
- x = Ni.x();
- y = Ni.y();
-
- my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y);//mettre la fonction definie au second membre de l'edp
- }
- myProblem.setHeatPowerField(my_RHSfield);
- myProblem.setLinearSolver(GMRES,ILU);
-
- /* name the result file */
- string fileName = "StationnaryDiffusion_2DEF_UnstructuredTriangles";
- myProblem.setFileName(fileName);
-
- /* Run the computation */
- myProblem.initialize();
- bool ok = myProblem.solveStationaryProblem();
- if (!ok)
- cout << "Simulation of "<<fileName<<" failed !" << endl;
- else
- {
- /********************** Postprocessing and measure od numerical error******************************/
- Field my_ResultField = myProblem.getOutputTemperatureField();
- /* The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi */
- double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi);
- double max_sol_num=my_ResultField.max();
- double min_sol_num=my_ResultField.min();
- double erreur_abs=0;
- for(int i=0; i< M.getNumberOfNodes() ; i++)
- if( erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) )
- erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]);
-
- cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
- cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
- cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
-
- assert( erreur_abs/max_abs_sol_exacte <1.);
-
- cout << "Simulation of "<<fileName<<" is successful ! " << endl;
- }
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "StationaryDiffusionEquation.hxx"
-#include "math.h"
-#include <assert.h>
-
-double pi = M_PI;
-using namespace std;
-
-int main(int argc, char** argv)
-{
- int spaceDim = 2;
-
- /* Mesh data */
- double xinf=0.0;
- double xsup=1.0;
- double yinf=0.0;
- double ysup=1.0;
- int nx=30;
- int ny=30;
-
- /* Mesh construction */
- Mesh M(xinf,xsup,nx,yinf,ysup,ny); //Regular square mesh
-
- /* set the limit field for each boundary */
- double eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1");
- M.setGroupAtPlan(xinf,0,eps,"Bord2");
- M.setGroupAtPlan(ysup,1,eps,"Bord3");
- M.setGroupAtPlan(yinf,1,eps,"Bord4");
-
- /* set the boundary values for each boundary */
- double T1=0;
- double T2=0;
- double T3=0;
- double T4=0;
-
- cout<< "Built a regular square 2D mesh with "<< nx<<"x" <<ny<< " cells"<<endl;
-
- /* Create the problem */
- bool FEComputation=false;
- StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- /* set the boundary conditions */
- myProblem.setDirichletBoundaryCondition("Bord1",T1);
- myProblem.setDirichletBoundaryCondition("Bord2",T2);
- myProblem.setDirichletBoundaryCondition("Bord3",T3);
- myProblem.setDirichletBoundaryCondition("Bord4",T4);
-
- /* Set the right hand side function*/
- Field my_RHSfield("RHS_field", CELLS, M, 1);
- Cell Ci;
- double x, y;
- for(int i=0; i< M.getNumberOfCells(); i++)
- {
- Ci= M.getCell(i);
- x = Ci.x();
- y = Ci.y();
-
- my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y);//mettre la fonction definie au second membre de l'edp
- }
- myProblem.setHeatPowerField(my_RHSfield);
- myProblem.setLinearSolver(GMRES,ILU);
-
- /* name the result file */
- string fileName = "StationnaryDiffusion_2DFV_StructuredSquares";
- myProblem.setFileName(fileName);
-
- /* Run the computation */
- myProblem.initialize();
- bool ok = myProblem.solveStationaryProblem();
- if (!ok)
- cout << "Simulation of "<<fileName<<" failed !" << endl;
- else
- {
- /********************** Postprocessing and measure od numerical error******************************/
- Field my_ResultField = myProblem.getOutputTemperatureField();
- /* The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi */
- double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi);
- double max_sol_num=my_ResultField.max();
- double min_sol_num=my_ResultField.min();
- double erreur_abs=0;
- for(int i=0; i< M.getNumberOfCells() ; i++)
- if( erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) )
- erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]);
-
- cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
- cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
- cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
-
- assert( erreur_abs/max_abs_sol_exacte <1.);
-
- cout << "Simulation of "<<fileName<<" is successful ! " << endl;
- }
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "StationaryDiffusionEquation.hxx"
-#include "math.h"
-#include <assert.h>
-
-double pi = M_PI;
-using namespace std;
-
-int main(int argc, char** argv)
-{
- int spaceDim = 2;
-
- /* Mesh data */
- double xinf=0.0;
- double xsup=1.0;
- double yinf=0.0;
- double ysup=1.0;
- int nx=20;
- int ny=20;
-
- /* Mesh construction */
- Mesh M(xinf,xsup,nx,yinf,ysup,ny,0); //Regular triangular mesh
-
- /* set the limit field for each boundary */
- double eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1");
- M.setGroupAtPlan(xinf,0,eps,"Bord2");
- M.setGroupAtPlan(ysup,1,eps,"Bord3");
- M.setGroupAtPlan(yinf,1,eps,"Bord4");
-
- /* set the boundary values for each boundary */
- double T1=0;
- double T2=0;
- double T3=0;
- double T4=0;
-
- cout<< "Building of a regular triangular 2D mesh from a square mesh with "<< nx<<"x" <<ny<< " cells"<<endl;
-
- /* Create the problem */
- bool FEComputation=false;
- StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- /* set the boundary conditions */
- myProblem.setDirichletBoundaryCondition("Bord1",T1);
- myProblem.setDirichletBoundaryCondition("Bord2",T2);
- myProblem.setDirichletBoundaryCondition("Bord3",T3);
- myProblem.setDirichletBoundaryCondition("Bord4",T4);
-
- /* Set the right hand side function*/
- Field my_RHSfield("RHS_field", CELLS, M, 1);
- Cell Ci;
- double x, y;
- for(int i=0; i< M.getNumberOfCells(); i++)
- {
- Ci= M.getCell(i);
- x = Ci.x();
- y = Ci.y();
-
- my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y);//mettre la fonction definie au second membre de l'edp
- }
- myProblem.setHeatPowerField(my_RHSfield);
- myProblem.setLinearSolver(GMRES,ILU);
-
- /* name the result file */
- string fileName = "StationnaryDiffusion_2DFV";
- myProblem.setFileName(fileName);
-
- /* Run the computation */
- myProblem.initialize();
- bool ok = myProblem.solveStationaryProblem();
- if (!ok)
- cout << "Simulation of "<<fileName<<" failed !" << endl;
- else
- {
- /********************** Postprocessing and measure od numerical error******************************/
- Field my_ResultField = myProblem.getOutputTemperatureField();
- /* The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi */
- double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi);
- double max_sol_num=my_ResultField.max();
- double min_sol_num=my_ResultField.min();
- double erreur_abs=0;
- for(int i=0; i< M.getNumberOfCells() ; i++)
- if( erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) )
- erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]);
-
- cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
- cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
- cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
-
- assert( erreur_abs/max_abs_sol_exacte <1.);
-
- cout << "Simulation of "<<fileName<<" is successful ! " << endl;
- }
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "StationaryDiffusionEquation.hxx"
-#include "math.h"
-#include <assert.h>
-
-double pi = M_PI;
-using namespace std;
-
-int main(int argc, char** argv)
-{
- int spaceDim = 2;
-
- /* Mesh data */
- double xinf=0.0;
- double xsup=1.0;
- double yinf=0.0;
- double ysup=1.0;
- int nx=20;
- int ny=20;
-
- /* Mesh construction */
- Mesh M(xinf,xsup,nx,yinf,ysup,ny,0); //Regular triangular mesh
-
- /* set the limit field for each boundary */
- double eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1");
- M.setGroupAtPlan(xinf,0,eps,"Bord2");
- M.setGroupAtPlan(ysup,1,eps,"Bord3");
- M.setGroupAtPlan(yinf,1,eps,"Bord4");
-
- /* set the boundary values for each boundary */
- double T1=0;
- double T2=0;
- double T3=0;
- double T4=0;
-
- cout<< "Building of a regular triangular 2D mesh from a square mesh with "<< nx<<"x" <<ny<< " cells"<<endl;
-
- /* Create the problem */
- bool FEComputation=false;
- StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- /* set the boundary conditions */
- myProblem.setNeumannBoundaryCondition("Bord1");
- myProblem.setNeumannBoundaryCondition("Bord2");
- myProblem.setNeumannBoundaryCondition("Bord3");
- myProblem.setNeumannBoundaryCondition("Bord4");
-
- /* Set the right hand side function*/
- Field my_RHSfield("RHS_field", CELLS, M, 1);
- Cell Ci;
- double x, y;
- for(int i=0; i< M.getNumberOfCells(); i++)
- {
- Ci= M.getCell(i);
- x = Ci.x();
- y = Ci.y();
-
- my_RHSfield[i]=2*pi*pi*cos(pi*x)*cos(pi*y);//mettre la fonction definie au second membre de l'edp
- }
- myProblem.setHeatPowerField(my_RHSfield);
- myProblem.setLinearSolver(GMRES,ILU);
-
- /* name the result file */
- string fileName = "StationnaryDiffusion_2DFV_RegularTriangles_Neumann";
- myProblem.setFileName(fileName);
-
- /* Run the computation */
- myProblem.initialize();
- bool ok = myProblem.solveStationaryProblem();
- if (!ok)
- cout << "Simulation of "<<fileName<<" failed !" << endl;
- else
- {
- /********************** Postprocessing and measure od numerical error******************************/
- Field my_ResultField = myProblem.getOutputTemperatureField();
- /* The following formulas use the fact that the exact solution is equal the right hand side divided by 2*pi*pi */
- double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(2*pi*pi);
- double max_sol_num=my_ResultField.max();
- double min_sol_num=my_ResultField.min();
- double erreur_abs=0;
- for(int i=0; i< M.getNumberOfCells() ; i++)
- if( erreur_abs < abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]) )
- erreur_abs = abs(my_RHSfield[i]/(2*pi*pi) - my_ResultField[i]);
-
- cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
- cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
- cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
-
- assert( erreur_abs/max_abs_sol_exacte <1.);
-
- cout << "Simulation of "<<fileName<<" is successful ! " << endl;
- }
-
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "StationaryDiffusionEquation.hxx"
-#include "math.h"
-#include <assert.h>
-
-double pi = M_PI;
-using namespace std;
-
-int main(int argc, char** argv)
-{
- int spaceDim = 3;
-
- /* Mesh data */
- double xinf=0.0;
- double xsup=1.0;
- double yinf=0.0;
- double ysup=1.0;
- double zinf=0.0;
- double zsup=1.0;
- int nx=2;
- int ny=2;
- int nz=2;
-
- /* Mesh construction : splitting polity to 0 yield all nodes considered boundary nodes */
- Mesh M(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz,0); //Regular tetrahadral mesh
-
- /* set the limit field for each boundary */
- double eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1");
- M.setGroupAtPlan(xinf,0,eps,"Bord2");
- M.setGroupAtPlan(ysup,1,eps,"Bord3");
- M.setGroupAtPlan(yinf,1,eps,"Bord4");
- M.setGroupAtPlan(zsup,2,eps,"Bord5");
- M.setGroupAtPlan(zinf,2,eps,"Bord6");
-
- /* set the boundary values for each boundary */
- double T1=0;
- double T2=0;
- double T3=0;
- double T4=0;
- double T5=0;
- double T6=0;
-
- cout<< "Built a regular tetrahedral 3D mesh from a cube mesh with "<< nx<<"x" <<ny<<"x" <<nz<< " cells"<<endl;
-
- /* Create the problem */
- bool FEComputation=true;
- StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- /* set the boundary conditions */
- myProblem.setDirichletBoundaryCondition("Bord1",T1);
- myProblem.setDirichletBoundaryCondition("Bord2",T2);
- myProblem.setDirichletBoundaryCondition("Bord3",T3);
- myProblem.setDirichletBoundaryCondition("Bord4",T4);
- myProblem.setDirichletBoundaryCondition("Bord5",T5);
- myProblem.setDirichletBoundaryCondition("Bord6",T6);
-
- /* Set the right hand side function*/
- Field my_RHSfield("RHS_field", NODES, M, 1);
- Node Ni;
- double x, y, z;
- for(int i=0; i< M.getNumberOfNodes(); i++)
- {
- Ni= M.getNode(i);
- x = Ni.x();
- y = Ni.y();
- z = Ni.z();
-
- my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)*sin(pi*z);//mettre la fonction definie au second membre de l'edp
- }
- myProblem.setHeatPowerField(my_RHSfield);
- myProblem.setLinearSolver(GMRES,ILU);
-
- /* name the result file */
- string fileName = "StationaryDiffusion_3DFE_StructuredTetrahedra";
- myProblem.setFileName(fileName);
-
- /* Run the computation */
- myProblem.initialize();
- bool ok = myProblem.solveStationaryProblem();
- if (!ok)
- cout << "Simulation of "<<fileName<<" failed !" << endl;
- else
- {
- /********************** Postprocessing and measure od numerical error******************************/
- Field my_ResultField = myProblem.getOutputTemperatureField();
- /* The following formulas use the fact that the exact solution is equal the right hand side divided by 3*pi*pi */
- double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(3*pi*pi);
- double max_sol_num=my_ResultField.max();
- double min_sol_num=my_ResultField.min();
- double erreur_abs=0;
- for(int i=0; i< M.getNumberOfNodes() ; i++)
- if( erreur_abs < abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i]) )
- erreur_abs = abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i]);
-
- cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
- cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
- cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
-
- assert( erreur_abs/max_abs_sol_exacte <1.);
-
- cout << "Simulation of "<<fileName<<" is successful ! " << endl;
- }
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "StationaryDiffusionEquation.hxx"
-#include "math.h"
-#include <assert.h>
-
-double pi = M_PI;
-using namespace std;
-
-int main(int argc, char** argv)
-{
- int spaceDim = 3;
-
- /* Mesh data */
- double xinf=0.0;
- double xsup=1.0;
- double yinf=0.0;
- double ysup=1.0;
- double zinf=0.0;
- double zsup=1.0;
- int nx=2;
- int ny=2;
- int nz=2;
-
- /* Mesh construction : splitting polity to 0 yield all nodes considered boundary nodes */
- Mesh M(xinf,xsup,nx,yinf,ysup,ny,zinf,zsup,nz,0); //Regular tetrahadral mesh
-
- /* set the limit field for each boundary */
- double eps=1e-6;
- M.setGroupAtPlan(xsup,0,eps,"Bord1");
- M.setGroupAtPlan(xinf,0,eps,"Bord2");
- M.setGroupAtPlan(ysup,1,eps,"Bord3");
- M.setGroupAtPlan(yinf,1,eps,"Bord4");
- M.setGroupAtPlan(zsup,2,eps,"Bord5");
- M.setGroupAtPlan(zinf,2,eps,"Bord6");
-
- /* set the boundary values for each boundary */
- double T1=0;
- double T2=0;
- double T3=0;
- double T4=0;
- double T5=0;
- double T6=0;
-
- cout<< "Built a regular tetrahedral 3D mesh from a cube mesh with "<< nx<<"x" <<ny<<"x" <<nz<< " cells"<<endl;
-
- /* Create the problem */
- bool FEComputation=false;
- StationaryDiffusionEquation myProblem(spaceDim,FEComputation);
- myProblem.setMesh(M);
-
- /* set the boundary conditions */
- myProblem.setDirichletBoundaryCondition("Bord1",T1);
- myProblem.setDirichletBoundaryCondition("Bord2",T2);
- myProblem.setDirichletBoundaryCondition("Bord3",T3);
- myProblem.setDirichletBoundaryCondition("Bord4",T4);
- myProblem.setDirichletBoundaryCondition("Bord5",T5);
- myProblem.setDirichletBoundaryCondition("Bord6",T6);
-
- /* Set the right hand side function*/
- Field my_RHSfield("RHS_field", CELLS, M, 1);
- Cell Ci;
- double x, y, z;
- for(int i=0; i< M.getNumberOfCells(); i++)
- {
- Ci= M.getCell(i);
- x = Ci.x();
- y = Ci.y();
- z = Ci.z();
-
- my_RHSfield[i]=2*pi*pi*sin(pi*x)*sin(pi*y)*sin(pi*z);//mettre la fonction definie au second membre de l'edp
- }
- myProblem.setHeatPowerField(my_RHSfield);
- myProblem.setLinearSolver(GMRES,ILU);
-
- /* name the result file */
- string fileName = "StationaryDiffusion_3DFV_StructuredTetrahedra";
- myProblem.setFileName(fileName);
-
- /* Run the computation */
- myProblem.initialize();
- bool ok = myProblem.solveStationaryProblem();
- if (!ok)
- cout << "Simulation of "<<fileName<<" failed !" << endl;
- else
- {
- /********************** Postprocessing and measure od numerical error******************************/
- Field my_ResultField = myProblem.getOutputTemperatureField();
- /* The following formulas use the fact that the exact solution is equal the right hand side divided by 3*pi*pi */
- double max_abs_sol_exacte=max(my_RHSfield.max(),-my_RHSfield.min())/(3*pi*pi);
- double max_sol_num=my_ResultField.max();
- double min_sol_num=my_ResultField.min();
- double erreur_abs=0;
- for(int i=0; i< M.getNumberOfNodes() ; i++)
- if( erreur_abs < abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i]) )
- erreur_abs = abs(my_RHSfield[i]/(3*pi*pi) - my_ResultField[i]);
-
- cout<<"Absolute error = max(| exact solution - numerical solution |) = "<<erreur_abs <<endl;
- cout<<"Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = "<<erreur_abs/max_abs_sol_exacte<<endl;
- cout<<"Maximum numerical solution = "<< max_sol_num<< " Minimum numerical solution = "<< min_sol_num << endl;
-
- assert( erreur_abs/max_abs_sol_exacte <1.);
-
- cout << "Simulation of "<<fileName<<" is successful ! " << endl;
- }
- cout << "------------ End of calculation !!! -----------" << endl;
- myProblem.terminate();
-
- return EXIT_SUCCESS;
-}
+++ /dev/null
-#include "TransportEquation.hxx"\r
-\r
-using namespace std;\r
-\r
-\r
-int main(int argc, char** argv)\r
-{\r
- //Preprocessing: mesh and group creation\r
- double xinf=0.0;\r
- double xsup=4.2;\r
- int nx=10;\r
- cout << "Building a 1D mesh with "<<nx<<" cells" << endl;\r
- Mesh M(xinf,xsup,nx);\r
- double eps=1.E-8;\r
- M.setGroupAtPlan(xsup,0,eps,"Neumann");\r
- M.setGroupAtPlan(xinf,0,eps,"Inlet");\r
- int spaceDim = M.getSpaceDimension();\r
-\r
- // Boundary conditions\r
- map<string, LimitField> boundaryFields;\r
-\r
- LimitField limitNeumann;\r
- limitNeumann.bcType=Neumann;\r
- boundaryFields["Neumann"] = limitNeumann;\r
-\r
- LimitField limitInlet;\r
- limitInlet.bcType=Inlet;\r
- limitInlet.h =1.3e6;//Inlet water enthalpy\r
- boundaryFields["Inlet"] = limitInlet;\r
-\r
- //Set the fluid transport velocity\r
- vector<double> transportVelocity(1,5);//fluid velocity vector\r
-\r
- TransportEquation myProblem(Liquid,around155bars600K,transportVelocity);\r
- Field VV("Enthalpy", CELLS, M, 1);\r
-\r
- //Set rod temperature and heat exchamge coefficient\r
- double rodTemp=623;//Rod clad temperature\r
- double heatTransfertCoeff=1000;//fluid/solid exchange coefficient \r
- myProblem.setRodTemperature(rodTemp);\r
- myProblem.setHeatTransfertCoeff(heatTransfertCoeff);\r
-\r
- //Initial field creation\r
- Vector VV_Constant(1);//initial enthalpy\r
- VV_Constant(0) = 1.3e6;\r
-\r
- cout << "Building the initial data " << endl;\r
-\r
- // generate initial condition\r
- myProblem.setInitialFieldConstant(M,VV_Constant);\r
-\r
- //set the boundary conditions\r
- myProblem.setBoundaryFields(boundaryFields);\r
-\r
- // set the numerical method\r
- myProblem.setNumericalScheme(upwind, Explicit);\r
-\r
- // name result file\r
- string fileName = "1DFluidEnthalpy";\r
-\r
- // parameters calculation\r
- unsigned MaxNbOfTimeStep =3;\r
- int freqSave = 1;\r
- double cfl = 0.95;\r
- double maxTime = 5;\r
- double precision = 1e-6;\r
-\r
- myProblem.setCFL(cfl);\r
- myProblem.setPrecision(precision);\r
- myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);\r
- myProblem.setTimeMax(maxTime);\r
- myProblem.setFreqSave(freqSave);\r
- myProblem.setFileName(fileName);\r
-\r
- // set display option to monitor the calculation\r
- bool computation=true;\r
- bool system=true;\r
- myProblem.setVerbose( computation, system);\r
- myProblem.setSaveFileFormat(CSV);\r
-\r
- // evolution\r
- myProblem.initialize();\r
- bool ok = myProblem.run();\r
- if (ok)\r
- cout << "Simulation "<<fileName<<" is successful !" << endl;\r
- else\r
- cout << "Simulation "<<fileName<<" failed ! " << endl;\r
-\r
- cout << "------------ End of calculation -----------" << endl;\r
- myProblem.terminate();\r
-\r
- return EXIT_SUCCESS;\r
-}\r
+++ /dev/null
-#include "SinglePhase_1DRiemannProblem.cxx"
-#include "SinglePhase_1DHeatedChannel.cxx"
-#include "SinglePhase_1DDepressurisation.cxx"
-#include "SinglePhase_2DWallHeatedChannel.cxx"
-#include "SinglePhase_2DWallHeatedChannel_ChangeSect.cxx"
-#include "SinglePhase_2DHeatedChannelInclined.cxx"
-#include "SinglePhase_HeatedWire_2Branches.cxx"
-#include "SinglePhase_2DLidDrivenCavity.cxx"
-#include "SinglePhase_2DLidDrivenCavity_unstructured.cxx"
-#include "SinglePhase_2DHeatDrivenCavity.cxx"
-#include "SinglePhase_2DHeatDrivenCavity_unstructured.cxx"
-#include "SinglePhase_2DSphericalExplosion_unstructured.cxx"
-#include "SinglePhase_3DHeatDrivenCavity.cxx"
-#include "DriftModel_1DBoilingChannel.cxx"
-#include "DriftModel_1DBoilingAssembly.cxx"
-#include "DriftModel_1DRiemannProblem.cxx"
-#include "DriftModel_1DPressureLoss.cxx"
-#include "DriftModel_1DDepressurisation.cxx"
-#include "DriftModel_2DInclinedBoilingChannel.cxx"
-#include "DriftModel_3DCanalCloison.cxx"
-#include "IsothermalTwoFluid_1DSedimentation.cxx"
-#include "IsothermalTwoFluid_1DRiemannProblem.cxx"
-#include "IsothermalTwoFluid_1DDepressurisation.cxx"
-#include "IsothermalTwoFluid_2DInclinedSedimentation.cxx"
-#include "IsothermalTwoFluid_2DVidangeReservoir.cxx"
-#include "FiveEqsTwoFluid_1DBoilingChannel.cxx"
-#include "FiveEqsTwoFluid_1DRiemannProblem.cxx"
-#include "FiveEqsTwoFluid_1DDepressurisation.cxx"
-#include "FiveEqsTwoFluid_2DInclinedBoilingChannel.cxx"
-#include "FiveEqsTwoFluid_2DInclinedSedimentation.cxx"
-#include "DiffusionEquation_1DHeatedRod.cxx"
-#include "TransportEquation_1DHeatedChannel.cxx"
-#include "CoupledTransportDiffusionEquations_1DHeatedChannel.cxx"
-
-using namespace std;
-
-
-int main(int argc,char **argv)
-{
- if(!SinglePhase_1DRiemannProblem())
- throw CdmathException("test SinglePhase_1DRiemannProblem failed");
- else if(!SinglePhase_1DHeatedChannel())
- throw CdmathException("test SinglePhase_1DHeatedChannel() failed");
- else if(!SinglePhase_1DDepressurisation())
- throw CdmathException("test SinglePhase_1DDepressurisation() failed");
- else if (!SinglePhase_2DLidDrivenCavity())
- throw CdmathException("test SinglePhase_2DLidDrivenCavity failed");
- else if (!SinglePhase_2DLidDrivenCavity_unstructured())
- throw CdmathException("test SinglePhase_2DLidDrivenCavity_unstructured failed");
- else if (!SinglePhase_2DHeatDrivenCavity())
- throw CdmathException("test SinglePhase_2DHeatDrivenCavity failed");
- else if (!SinglePhase_2DHeatDrivenCavity_unstructured())
- throw CdmathException("test SinglePhase_2DHeatDrivenCavity_unstructured failed");
- else if(!SinglePhase_2DWallHeatedChannel())
- throw CdmathException("test SinglePhase_2DWallHeatedChannel() failed");
- else if(!SinglePhase_2DWallHeatedChannel_ChangeSect())
- throw CdmathException("test SinglePhase_2DWallHeatedChannel_ChangeSect() failed");
- else if(!SinglePhase_2DHeatedChannelInclined())
- throw CdmathException("test SinglePhase_2DHeatedChannelInclined() failed");
- else if(!SinglePhase_HeatedWire_2Branches())
- throw CdmathException("test SinglePhase_HeatedWire_2Branches() failed");
- else if (!SinglePhase_2DSphericalExplosion_unstructured())
- throw CdmathException("test SinglePhase_2DSphericalExplosion_unstructured failed");
- else if (!SinglePhase_3DHeatDrivenCavity())
- throw CdmathException("test SinglePhase_3DHeatDrivenCavity failed");
- else if(!DriftModel_1DRiemannProblem())
- throw CdmathException("test DriftModel_1DRiemannProblem failed ");
- else if(!DriftModel_1DPressureLoss())
- throw CdmathException("test DriftModel_1DPressureLoss failed ");
- else if(!DriftModel_1DBoilingChannel())
- throw CdmathException("test DriftModel_1DBoilingChannel failed ");
- else if(!DriftModel_1DBoilingAssembly())
- throw CdmathException("test DriftModel_1DBoilingAssembly failed ");
- else if(!DriftModel_1DDepressurisation())
- throw CdmathException("test DriftModel_1DDepressurisation failed ");
- else if(!DriftModel_2DInclinedBoilingChannel())
- throw CdmathException("test DriftModel_2DInclinedBoilingChannel failed ");
- else if(!DriftModel_3DCanalCloison())
- throw CdmathException("test DriftModel_3DCanalCloison failed ");
- else if(!IsothermalTwoFluid_1DRiemannProblem())
- throw CdmathException("test IsothermalTwoFluid_1DRiemannProblem failed");
- else if(!IsothermalTwoFluid_1DSedimentation())
- throw CdmathException("test IsothermalTwoFluid_1DSedimentation failed");
- else if(!IsothermalTwoFluid_1DDepressurisation())
- throw CdmathException("test IsothermalTwoFluid_1DDepressurisation failed");
- else if(!IsothermalTwoFluid_2DInclinedSedimentation())
- throw CdmathException("test IsothermalTwoFluid_2DInclinedSedimentation failed");
- else if(!IsothermalTwoFluid_2DVidangeReservoir())
- throw CdmathException("test IsothermalTwoFluid_2DVidangeReservoir failed");
- else if(!FiveEqsTwoFluid_1DRiemannProblem())
- throw CdmathException("test FiveEqsTwoFluid_1DRiemannProblem failed");
- else if(!FiveEqsTwoFluid_1DBoilingChannel())
- throw CdmathException("test FiveEqsTwoFluid_1DBoilingChannel failed");
- else if(!FiveEqsTwoFluid_1DDepressurisation())
- throw CdmathException("test FiveEqsTwoFluid_1DDepressurisation failed");
- else if(!FiveEqsTwoFluid_2DInclinedBoilingChannel())
- throw CdmathException("test FiveEqsTwoFluid_2DInclinedBoilingChannel failed ");
- else if(!FiveEqsTwoFluid_2DInclinedSedimentation())
- throw CdmathException("test FiveEqsTwoFluid_2DInclinedSedimentation failed ");
- else if(!TransportEquation_1DHeatedChannel())
- throw CdmathException("test TransportEquation_1DHeatedChannel() failed");
- else if(!DiffusionEquation_1DHeatedRod())
- throw CdmathException("test DiffusionEquation_1DHeatedRod() failed");
- else if(!CoupledTransportDiffusionEquations_1DHeatedChannel())
- throw CdmathException("test CoupledTransportDiffusionEquations_1DHeatedChannel() failed");//choose correct physical parameters to obtain good physical results
- else
- cout<<"All C tests successful"<<endl;
-
- return 1;
-}
+++ /dev/null
-#include "Fluide.h"
-#include <cstdlib>
-
-#include <iostream>
-
-using namespace std;
-
-int main(int argc, char** argv) {
- double _Tsat = 656; //saturation temperature used in Dellacherie EOS
- StiffenedGasDellacherie fluid1 = StiffenedGasDellacherie(1.43, 0,
- 2.030255e6, 1040.14); //stiffened gas law for Gas from S. Dellacherie
- StiffenedGasDellacherie fluid2 = StiffenedGasDellacherie(2.35, 1e9,
- -1.167056e6, 1816.2); //stiffened gas law for water from S. Dellacherie
-
- double P = 155e6;
- double T = 500;
- double h = 0;
-
- double rho1 = fluid1.getDensity(P, T);
- double Tvalid1 = fluid1.getTemperatureFromPressure(P, rho1);
- double h1 = fluid1.getEnthalpy(T, rho1);
-
- cout << endl;
- cout << "density fluide 1 = " << rho1 << endl;
- cout << "Tvalid1 fluide 1 = " << Tvalid1 << endl;
- cout << "h1 fluide 1 = " << h1 << endl;
-
- return EXIT_SUCCESS;
-}
INCLUDE_DIRECTORIES(
${PYTHON_INCLUDE_DIRS}
- ${CoreFlows_SRC}/inc
+ ${CoreFlows_INCLUDES} #
)
-INCLUDE_DIRECTORIES(
- ${PETSC_INCLUDES}
- ${CDMATH_INCLUDES}
- ${CDMATH_INCLUDES}/med #
- ${CDMATH_INCLUDES}/medcoupling #
-)
SET(_extra_lib_SWIG ${CDMATH_LIBRARIES} ${PETSC_LIBRARIES})