]> SALOME platform Git repositories - tools/solverlab.git/commitdiff
Salome HOME
Updated tests for gui
authormichael <michael@localhost.localdomain>
Thu, 13 Jan 2022 17:31:40 +0000 (18:31 +0100)
committermichael <michael@localhost.localdomain>
Thu, 13 Jan 2022 17:31:40 +0000 (18:31 +0100)
CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_2DSpherical.py
CoreFlows/examples/Python/TransportEquation/TransportEquation_1DHeatedChannel.py

index 83305377d1d07e4295aaa8528139d53de21c2ad8..fab72e43621d4faf004924460b8b05cd41162f12 100644 (file)
@@ -5,7 +5,11 @@ import sys
 import solverlab
 
 #===============================================================================================================================
-# Name        : Finite Elements simulation of the 2D heat equation -\triangle T = f with Neumann boundary condition
+# Name        : Simulation of a 2D heat equation 
+# Description : Test solving the diffusion of the temperature T in a solid
+#               \rho cp dT/dt-\lambda\Delta T=\Phi + \lambda_{sf} (T_{fluid}-T_{solid}) 
+#               Neumann or Dirichlet boundary conditions
+#               Finite elements or finite volumes
 # Author      : Michaël Ndjinga
 # Copyright   : CEA Saclay 2021
 #================================================================================================================================
@@ -14,9 +18,9 @@ import solverlab
 def DiffusionEquation_2DSpherical(FECalculation, fileName):
 
        """ Description : Test solving the diffusion of the temperature T in a solid (default is Uranium). 
-               Equation : Thermal diffusion equation  \rho cp dT/dt-\lambda\Delta T=\Phi + \lambda_{sf} (T_{fluid}-T)
-                       Heat capacity, density, and conductivity of the solid MUST be defined
-                       The solid may be extra refrigerated by a fluid with transfer coefficient using functions setFluidTemperature and setHeatTransfertCoeff
+               Equation : Thermal diffusion equation  \rho cp dT/dt-\lambda\Delta T=\Phi + \lambda_{sf} (T_{fluid}-T_{solid})
+                       Heat capacity cp, density \rho, and conductivity \lambda of the solid MUST be defined
+                       The solid may be refrigerated by a fluid with temperature T_{solid} transfer coefficient \lambda_{sf} using functions setFluidTemperature and setHeatTransfertCoeff
                        The solid may receive some extra heat power due to nuclear fissions using function setHeatSource
        """
        #Space dimension of the problem
@@ -36,8 +40,8 @@ def DiffusionEquation_2DSpherical(FECalculation, fileName):
                supportOfField=solverlab.CELLS  
        
     # Set the mesh and initial data
-       initial_data_inputfile="../resources/BoxWithMeshWithTriangularCells";
-       initial_data_fieldName="Temperature";
+       initial_data_inputfile="../resources/meshSquare";
+       initial_data_fieldName="Solid temperature";
        print("Loading unstructured mesh and initial data", " in file ", initial_data_inputfile )
        initial_data_time_iteration=0# default value is 0
        initial_data_time_sub_iteration=0# default value is 0
@@ -46,8 +50,8 @@ def DiffusionEquation_2DSpherical(FECalculation, fileName):
 
     #### Optional physical values (default value is zero) : fluid temperature field, heat transfert coefficient, heat power field 
        # Loading and setting fluid temperature field
-       fluid_temperature_inputfile="../resources/BoxWithMeshWithTriangularCells";
-       fluid_temperature_fieldName="Fluid temperature field";
+       fluid_temperature_inputfile="../resources/meshSquare";
+       fluid_temperature_fieldName="Fluid temperature";
        fluid_temperature_time_iteration=0# default value is 0
        fluid_temperature_time_sub_iteration=0# default value is 0
        fluid_temperature_meshLevel=0# default value is 0
@@ -58,8 +62,8 @@ def DiffusionEquation_2DSpherical(FECalculation, fileName):
        heatTransfertCoeff=1000.;#fluid/solid exchange coefficient, default value is 0
        myProblem.setHeatTransfertCoeff(heatTransfertCoeff);
        # Loading heat power field
-       heat_power_inputfile="../resources/BoxWithMeshWithTriangularCells";
-       heat_power_fieldName="Heat power field";
+       heat_power_inputfile="../resources/meshSquare";
+       heat_power_fieldName="Heat power";
        heat_power_time_iteration=0# default value is 0
        heat_power_time_sub_iteration=0# default value is 0
        heat_power_meshLevel=0# default value is 0
@@ -69,19 +73,66 @@ def DiffusionEquation_2DSpherical(FECalculation, fileName):
 
     # the boundary conditions :
        if( FECalculation):
-               boundaryNodeGroupNames=myProblem.getMesh().getNameOfNodeGroups()
-               print(len(boundaryNodeGroupNames), " Boundary Node Group detected : ", boundaryNodeGroupNames)
+               boundaryGroupNames=myProblem.getMesh().getNameOfNodeGroups()
+               print(len(boundaryGroupNames), " Boundary Node Group detected : ", boundaryGroupNames)
        else:
-               boundaryFaceGroupNames=myProblem.getMesh().getNameOfFaceGroups()
-               print(len(boundaryFaceGroupNames), " Boundary Face Group detected : ", boundaryFaceGroupNames)
-
-       myProblem.setNeumannBoundaryCondition("GAUCHE");
-       myProblem.setNeumannBoundaryCondition("DROITE");
-       myProblem.setNeumannBoundaryCondition("HAUT");
-       myProblem.setNeumannBoundaryCondition("BAS");
+               boundaryGroupNames=myProblem.getMesh().getNameOfFaceGroups()
+               print(len(boundaryGroupNames), " Boundary Face Group detected : ", boundaryGroupNames)
+
+       # for each boundary we load the boundary field (replace by a loop over the boundaries)
+       boundary1_type=solverlab.NeumannDiffusion
+       boundary1_inputfile="../resources/meshSquare";
+       boundary1_fieldName="Left temperature";
+       boundary1_time_iteration=0# default value is 0
+       boundary1_time_sub_iteration=0# default value is 0
+       boundary1_meshLevel=0# default value is 0
+       print("Boundary ", boundaryGroupNames[3], ", loading field :", boundary1_fieldName, " in file ", boundary1_inputfile)
+       boundary1Field=solverlab.Field(boundary1_inputfile, supportOfField, boundary1_fieldName, boundary1_time_iteration, boundary1_time_sub_iteration, boundary1_meshLevel)
+       boundary2_type=solverlab.DirichletDiffusion
+       boundary2_inputfile="../resources/meshSquare";
+       boundary2_fieldName="Right temperature";
+       boundary2_time_iteration=0# default value is 0
+       boundary2_time_sub_iteration=0# default value is 0
+       boundary2_meshLevel=0# default value is 0
+       print("Boundary ", boundaryGroupNames[2], ", loading field :", boundary2_fieldName, " in file ", boundary2_inputfile)
+       boundary2Field=solverlab.Field(boundary2_inputfile, supportOfField, boundary2_fieldName, boundary2_time_iteration, boundary2_time_sub_iteration, boundary2_meshLevel)
+       boundary3_type=solverlab.NeumannDiffusion
+       boundary3_inputfile="../resources/meshSquare";
+       boundary3_fieldName="Top temperature";
+       boundary3_time_iteration=0# default value is 0
+       boundary3_time_sub_iteration=0# default value is 0
+       boundary3_meshLevel=0# default value is 0
+       print("Boundary ", boundaryGroupNames[4], ", loading field :", boundary3_fieldName, " in file ", boundary3_inputfile)
+       boundary3Field=solverlab.Field(boundary3_inputfile, supportOfField, boundary3_fieldName, boundary3_time_iteration, boundary3_time_sub_iteration, boundary3_meshLevel)
+       boundary4_type=solverlab.DirichletDiffusion
+       boundary4_inputfile="../resources/meshSquare";
+       boundary4_fieldName="Bottom temperature";
+       boundary4_time_iteration=0# default value is 0
+       boundary4_time_sub_iteration=0# default value is 0
+       boundary4_meshLevel=0# default value is 0
+       print("Boundary ", boundaryGroupNames[1], ", loading field :", boundary4_fieldName, " in file ", boundary4_inputfile)
+       boundary4Field=solverlab.Field(boundary4_inputfile, supportOfField, boundary4_fieldName, boundary4_time_iteration, boundary4_time_sub_iteration, boundary4_meshLevel)
+
+       # for each boundary we need to know if we want a Neumann or a Dirichlet boundary condition
+       if boundary1_type==solverlab.NeumannDiffusion :
+               myProblem.setNeumannBoundaryCondition("Left", boundary1Field)
+       elif boundary1_type==solverlab.DirichletDiffusion :
+               myProblem.setDirichletBoundaryCondition("Left", boundary1Field)
+       if boundary2_type==solverlab.NeumannDiffusion :
+               myProblem.setNeumannBoundaryCondition("Right", boundary2Field)
+       elif boundary2_type==solverlab.DirichletDiffusion :
+               myProblem.setDirichletBoundaryCondition("Right", boundary2Field)
+       if boundary3_type==solverlab.NeumannDiffusion :
+               myProblem.setNeumannBoundaryCondition("Top", boundary3Field)
+       elif boundary3_type==solverlab.DirichletDiffusion :
+               myProblem.setDirichletBoundaryCondition("Top", boundary3Field);
+       if boundary4_type==solverlab.NeumannDiffusion :
+               myProblem.setNeumannBoundaryCondition("Bottom", boundary4Field)
+       elif boundary4_type==solverlab.DirichletDiffusion :
+               myProblem.setDirichletBoundaryCondition("Bottom", boundary4Field);
 
     # set the numerical method
-       myProblem.setTimeScheme( solverlab.Explicit);
+       myProblem.setTimeScheme( solverlab.Explicit)# Otherwise solverlab.Implicit
        max_nb_its_lin_solver = 50
        myProblem.setLinearSolver(solverlab.GMRES, solverlab.ILU, max_nb_its_lin_solver );
 
index 4d6cabc58fb60bf3875634a61791bea3acb9edab..77110259c2145027ae9839e1cf343428d9dbf308 100755 (executable)
@@ -17,7 +17,7 @@ def TransportEquation_1DHeatedChannel():
     # Set the transport velocity
        transportVelocity=[5];
 
-       myProblem = cf.TransportEquation(cf.LiquidPhase,cf.around155bars600KTransport,transportVelocity);
+       myProblem = cf.TransportEquation(cf.Water,cf.around155bars600K,transportVelocity);
        nVar = myProblem.getNumberOfVariables();
 
     # Prepare for the initial condition