A method of constructing an openfoam solver

By introducing the Rolie-Poly constitutive model into the OpenFOAM solver, the problem of low computational efficiency of existing solvers is solved, and efficient data computation of turbulent flow fields is achieved.

CN115455862BActive Publication Date: 2026-03-20GUANGZHOU UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-08
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing OpenFOAM solvers have low computational efficiency when calculating turbulent flow fields, making it difficult to provide efficient data calculation methods.

Method used

The Rolie-Poly constitutive model was adopted, and the Rolie-Poly.H file was written in C++ and added to the PisoFoam solver. The solver was compiled in the OpenFOAM-6-exercise environment, and data was generated using a flat plate shear flow calculation case for data comparison.

Benefits of technology

While ensuring accuracy, it significantly improves the computational efficiency of calculating turbulent flow fields and provides a more efficient data calculation method.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115455862B_ABST
    Figure CN115455862B_ABST
Patent Text Reader

Abstract

A method for constructing an openfoam solver, comprising the following steps: S1: writing a Rolie-Poly.H file based on C++ code according to a Rolie-Poly constitutive model; S2: defining parameter variable names in createFeilds.H; S3: adding a Rolie-Poly.H constitutive model file to a PisoFoam.C piece in a PisoFoam solver; S4: compiling the solver in an OpenFOAM-6 exercise version; S5: using a flat plate shear flow calculation case to generate data; and S6: generating a data graph and comparing the data with data in a rheoFoam case. The present application proposes a new method for constructing an openfoam solver, which can provide effective data calculation for calculating turbulent flow fields, and has higher calculation efficiency compared with the existing rheoFoam solver.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the field of fluid mechanics experimental simulation, and particularly relates to a method for constructing an OpenFOAM solver. BACKGROUND

[0002] Computational Fluid Dynamics (CFD) is a cross-discipline between mathematics, fluid mechanics and computer, which is produced with the development of computer since 1950s. The main research content of CFD is to solve the control equation of fluid mechanics by computer and numerical method, and to simulate and analyze the fluid mechanics problem.

[0003] The direct numerical simulation (DNS) method has the following characteristics: all information of the turbulent field can be obtained

[0004] OpenFOAM is an open source field operation and operation C++ library, which is used to create executable files such as application programs. The built-in application programs (about 250) of OpenFOAM are divided into two categories: solver and tool. The solver is designed to solve specific problems of continuum mechanics; the tool is designed to perform data operations and other tasks. Using OpenFOAM to operate the field can obtain all the data of the turbulent field at each time step, so as to understand the characteristics of elastic turbulence.

[0005] C++ is a computer high-level programming language, which is upgraded from C language. C++ has the practicality of computer operation, and is committed to improving the programming quality of large-scale programs and the problem description ability of programming language.

[0006] The convenience brought by using objects to represent physical objects and abstract entities in programming cannot be underestimated. By creating such class hierarchy that can use all structures in the code, the code management can be easier. New classes can inherit from other classes. For example, vectorField can inherit from vector class and Field class. C++ also provides template class mechanism, such as Field <type>may represent any of <type>Fields, such as scalar, vector, tensor, etc. The properties of the template class are preserved on any type created from the template class. Templates and inheritance greatly simplify the duplication of code and make the overall code structure more clear.

[0007] PETSc (Parallel Extensible Toolkits for Scientific Computing) is a portable, extensible, scientific computing toolkit developed by Argonne National Laboratory, USA, based on MPI standard for message passing, mainly used for efficient solution of partial differential equations and related problems in distributed storage environment. SUMMARY

[0008] In view of the existing problems, the purpose of the present application is to provide a method for constructing an OpenFOAM solver, characterized in that it comprises the following steps: S1: writing a Rolie-Poly.H file based on C++ code according to the Rolie-Poly constitutive model; S2: defining parameter variable names in createFields.H; S3: adding the Rolie-Poly.H constitutive model file to the PisoFoam.C file in the PisoFoam solver; S4: compiling the solver in the OpenFOAM-6exercise version; S5: using a plate shear flow calculation case to generate data; S6: generating a data graph and comparing the data with that in the rheoFoam case.

[0009] Preferably, step S1 describes the Rolie-Poly constitutive model by the following equation:

[0010] A is the conformation tensor, I is the unit tensor, tr(A) is the trace of the conformation tensor A, λ D is the relaxation time of the polymer molecular chain wriggling out of the tube, λ R is the relaxation time of the polymer chain after being stretched, and β is the coefficient of convective constraint release.

[0011] Preferably, step S1 describes the Rolie-Poly constitutive model by the equation calculating the stress of the viscoelastic model in the Rolie-Poly constitutive model, wherein η p is the polymer viscosity, λ D is the relaxation time of the polymer molecular chain wriggling out of the tube, and k is calculated by the formula wherein when χ≤1, k=1; when χ>1, wherein χ max is the elasticity of the viscoelastic fluid, and in the transportproperties of the plate shear flow calculation case, it is the chiMax parameter.

[0012] Preferably, step S1 calculates the conformation tensor A by the Rolie-Poly constitutive model and the N-S equation, and encapsulates the Rolie-Poly constitutive model in a Rolie-Poly.H file.

[0013] Preferably, step S2 specifically comprises adding the following variable parameters about the Rolie-Poly model in the createFields.H: tensors in the Rolie-Poly constitutive model: conformation tensor A, trace of the conformation tensor tr(A), stress sigma, and scalars: relaxation time of the polymer chain λ D , relaxation time of the polymer chain after being stretched λ R , viscosity of the solvent etaS, viscosity of the high polymer etaP, elasticity of the high polymer solution chiMax, slope beta and delta of the solution appearing a shear platform, and fluid density rho; the above variable parameters are entered into the file createFields.H in a code format, compiled and stored in the OpenFOAM environment as a parameter part of the solver.

[0014] Preferably, step S3 specifically comprises adding the Rolie-Poly.H constitutive model file after the pressure equation in the PisoFoam.C file: #include"Rolie-Poly.H".

[0015] Step S4 specifically comprises: using the wmake command to compile the file directory under the OpenFOAM-6-exercise environment, and the compiled OpenFOAM program top-level source file is named.C, the OpenFOAM program source code is placed in a same-named folder, the same-named folder includes a Make folder, the Make folder includes an options file and a files file, wherein the files file is a specified solver name, and the options file specifies the path of the library called by the solver.

[0016] Preferably, step S5 uses a plate shear flow calculation case with Re=0.002, Wi=2, and a cubic plate shear flow with an edge length of 1x1x1, and the initial condition is that the velocity of the upper and lower planes of the shear flow is 1; the boundary condition is that the four surrounding surfaces of the cube are periodic boundary conditions; the plate shear flow calculation case is solved by using the solver in the OpenFOAM environment, and file data recorded every 0.1 time step is generated.

[0017] Preferably, step S6 processes the data generated by the probe, and generates a trend graph of the change of the velocity with Y, a trend graph of the change of the first normal stress difference coefficient with Y, a trend graph of the change of the second normal stress difference with Y, and compares the above data and images with the difference of the solving result of the RheoFoam solver.

[0018] The beneficial technical effects of the present application are that:

[0019] The present application provides a method for constructing an OpenFOAM solver based on a consistent Rolie-Poly constitutive equation of a pisoFoam solver, which uses a new solver generation idea, can provide an effective data calculation method for calculating turbulent flow fields, and greatly improves the calculation efficiency under the premise of ensuring accuracy compared with the existing rheoFoam solver. BRIEF DESCRIPTION OF DRAWINGS

[0020] Figure 1 is a flow schematic diagram of the method for constructing an OpenFOAM solver provided by the present application;

[0021] Figure 2 is a flat plate shear flow model used in a preferred embodiment of the present application;

[0022] Figure 3 is a curve of the change of the velocity with the length y of the distance from the wall surface at 0.1s in a preferred embodiment of the present application;

[0023] Figure 4 is a curve of the change of the first normal stress difference with the length y of the distance from the wall surface at 0.1s in a preferred embodiment of the present application;

[0024] Figure 5 is a curve of the change of the second normal stress difference with the length y of the distance from the wall surface at 0.1s in a preferred embodiment of the present application;

[0025] Figure 6 is a curve of the change of the velocity with the length y of the distance from the wall surface at 1s in a preferred embodiment of the present application;

[0026] Figure 7 is a curve of the change of the first normal stress difference with the length y of the distance from the wall surface at 1s in a preferred embodiment of the present application;

[0027] Figure 8 is a curve of the change of the second normal stress difference with the length y of the distance from the wall surface at 1s in a preferred embodiment of the present application;

[0028] Figure 9 is a curve of the change of the velocity with the length y of the distance from the wall surface at 10s in a preferred embodiment of the present application;

[0029] Figure 10 is a first normal stress difference curve with respect to the length y of the distance from the wall surface at 10s in a preferred embodiment provided by the present application.

[0030] Figure 11 is a second normal stress difference curve with respect to the length y of the distance from the wall surface at 10s in a preferred embodiment provided by the present application. DETAILED DESCRIPTION

[0031] The embodiments of the present application are described in detail below, the following embodiments are implemented on the premise of the technical scheme of the present application, and detailed implementation modes and specific operation processes are given, but the protection scope of the present application is not limited to the following embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0032] Reference to "an embodiment" or "the embodiment" in this text means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearance of the phrase in various places in the specification does not necessarily all refer to the same embodiment, nor is it necessarily mutually exclusive of other embodiments. It is explicitly and implicitly understood that the embodiments described herein can be combined with other embodiments without conflict.

[0033] As shown in Figure 1 , a method for constructing an OpenFOAM solver, characterized in that it comprises the following steps: S1: writing a Rolie-Poly.H file based on a C++ code according to a Rolie-Poly constitutive model; S2: defining parameter variable names in createFields.H; S3: adding a Rolie-Poly.H constitutive model file to a PisoFoam.C file in a PisoFoam solver; S4: compiling the solver in an OpenFOAM-6exercise version; S5: using a flat shear flow calculation case to generate data; and S6: generating a data graph and comparing the data with data in a rheoFoam case.

[0034] Step S1 describes the Rolie-Poly constitutive model by the following equation:

[0035] Where A is a conformation tensor, I is a unit tensor, tr(A) is the trace of the conformation tensor A, λ D is the relaxation time of the polymer molecular chain wriggling out of the tube, λ R is the relaxation time of the polymer chain after being stretched, and β is the coefficient of convective constraint release.

[0036] The Rolie-Poly constitutive model can be written in C++ as follows:

[0037]

[0038]

[0039] sigmap.correctBoundaryConditions();

[0040] Step S1 is achieved through the equation Calculate the stress in the viscoelastic model within the Rolie-Poly constitutive model, where η p λ is the polymer viscosity. D The relaxation time for the polymer molecular chains to creep out of the tube is given by the formula. Calculate the possible values ​​of k, where k = 1 when χ ≤ 1 and k > 1 when χ > 1. Where χ max This is the elasticity of the viscoelastic fluid, which is the chiMax parameter in the transport properties of the flat plate shear flow calculation case.

[0041] Step S1 calculates the conformation tensor A using the Rolie-Poly constitutive model and the Navier-Stokes equations, and encapsulates the Rolie-Poly constitutive model in the Rolie-Poly.H file.

[0042] Step S2 specifically includes adding the following variable parameters for the Rolie-Poly model to createFields.H: tensors in the Rolie-Poly constitutive model: conformation tensor A, trace tr(A) of the conformation tensor, stress sigma, and scalar: relaxation time λ of the polymer molecular chains creeping out of the tube. D λ represents the relaxation time of the polymer chain after it has been stretched. R The following variables are considered: solvent viscosity etaS, polymer viscosity etaP, polymer solution elasticity chiMax, slopes beta and delta at which the solution exhibits a shear plateau, and fluid density rho. These variables are entered into the file createFields.H using code format, compiled, and stored in the OpenFOAM environment as the parameter part of the solver. The code is shown below:

[0043]

[0044]

[0045] Step S4 is specifically: in the OpenFOAM-6-exercise environment, the file directory is compiled by using the wmake command, the compiled OpenFOAM program top layer source file is named.C, and the OpenFOAM program source code is placed in a folder with the same name, which includes a Make folder, the Make folder includes an options file and a files file, wherein the files file is a specified solver name, and the options file specifies the path of the library called by the solver; the operation mode on the computer is as follows:

[0046] (1) Modify the solver name in the make / files file in the Rolie-PolyFoam folder;

[0047] (2) Enter the folder directory in the Xshell terminal and enter the following command:

[0048] source $HOME / OpenFOAM / OpenFOAM-6-exercise / etc / bashrc

[0049] wmake

[0050] (3) The following information is obtained after successful compilation:

[0051] Making dependency list for source file Rolie-PolyFoam.C

[0052] g++-std=c++0x-m32... ...

[0054] -o...platforms / linuxGccDPInt64Opt / bin / Rolie-PolyFoam

[0055] As shown in Figure 2 , the plate shear flow calculation case used in step S5 uses Re=0.002, Wi=2, and a plate shear flow of a cube with an edge length of 1x1x1, and the initial condition is that the upward and downward velocities of the shear flow are 1; the boundary condition is that the four sides of the cube are periodic boundary conditions; the plate shear flow calculation case is solved by using a solver in the OpenFOAM environment to generate file data recorded every 0.1 time step; the number of grids of the calculation case is 40 3 , the number of parallel blocks is 8, and the Piso algorithm is used for solving; the specific operation on the computer is as follows:

[0056] (1) Copy the cavity example in the tutorial of OpenFOAM to the RUN folder;

[0057] (2) Set the vertices, blocks and edges in the blockMeshDict dictionary in the system folder;

[0058] (3) Set the decomposition method as scotch in the decomposeParDict dictionary in the system folder, and the number of blocks is 8;

[0059] (4) Set the solution algorithm PISO and the iteration number of p equation as 4 in the fvSolution in the system folder;

[0060] (5) Set the variable parameters of the Rolie-Poly constitutive equation in the transportProperties dictionary in the constant folder;

[0061] (6) Set the initial velocity field U in the 0 folder, set the velocity as 1 m / s, and add the boundary information of the tensors A, tauxx, tauyy, tauzz, tauxy, sigama, sigamaP in the 0 folder.

[0062] The specific commands input in the Xshell terminal are as follows:

[0063] source $HOME / OpenFOAM / OpenFOAM-6-exercise / etc / bashrc

[0064] blockMesh>blockMesh.log &

[0065] decomposePar>decomposePar.log &

[0066] Rolie-PolyFoam>Rolie-PolyFoam.log &

[0067] reconstructPar>reconstructPar.log &

[0068] If End appears after the solution is completed, it means that the solution is successful.

[0069] Step S6 post-processes the files under each time step file through paraview, processes the generated data image through a probe, and generates a trend graph of the velocity change with Y at the time points of 0.1s, 1s, and 10s, as shown in Figs. Figure 3 、 6 , 9; a trend graph of the first normal stress difference coefficient change with Y at the time points of 0.1s, 1s, and 10s, as shown in Figs. Figure 4 、 7 , 10; a trend graph of the second normal stress difference change with Y at the time points of 0.1s, 1s, and 10s, as shown in Figs. Figure 5 、 8 , 11; and the specific operation on the computer is as follows:

[0070] (1) Copy the calculation example set in step S5 to another folder named rheoFoam_RoliePoly

[0071] (2) Use the rheoFoam solver to solve the calculation example

[0072] (3) Input the following commands in the Xshell terminal:

[0073] source $HOME / OpenFOAM / OpenFOAM-6-exercise / etc / bashrc

[0074] blockMesh>blockMesh.log &

[0075] decomposePar>decomposePar.log &

[0076] rheoFoam>rheo.log &

[0077] reconstructPar>reconstructPar.log &

[0078] (4) The obtained data is post-processed through paraview and plotted in Origin.

[0079] The above describes the preferred embodiments of the application in detail. It should be understood that those skilled in the art can make many modifications and changes to the embodiments of the application without creative labor based on the concept of the application. Therefore, any technical solution obtained by logical analysis, reasoning or limited test based on the existing technology according to the concept of the application should be within the protection scope defined by the claims.< / type> < / type>

Claims

1. A method for constructing an OpenFOAM solver, characterized in that, Includes the following steps: S1: Write the Rolie-Poly.H file based on the Rolie-Poly constitutive model using C++ code; S2: Define the parameter variable names in createFields.H; S3: Add the Rolie-Poly.H constitutive model file to the PisoFoam.C file in the PisoFoam solver; S4: Compile the solver in the OpenFOAM-6 exercise version; S5: Data generation using the flat plate shear flow computation case; S6: Generate a data graph and compare it with the data in the rheoFoam case study; Step S1 is described by the following equations in the Rolie-Poly constitutive model: Where A is the conformation tensor, I is the unit tensor, tr(A) is the trace of the conformation tensor A, and λ D λ is the relaxation time for the polymer molecular chains to creep out of the tube. R β is the relaxation time after the polymer chain is stretched, and β is the convection constraint release coefficient. Through formula Calculate the possible values ​​of k, where k = 1 when χ ≤ 1 and k > 1 when χ > 1. Where χ max It represents the elasticity of the viscoelastic fluid, which is the chiMax parameter in the transport properties of the flat plate shear flow calculation case.

2. The method for constructing an OpenFOAM solver according to claim 1, characterized in that, Step S1 is achieved through equation Calculate the stress in the viscoelastic model of the Rolie-Poly constitutive model, where η p λ is the polymer viscosity. D This is the relaxation time for the polymer molecular chains to creep out of the tube.

3. The method for constructing an OpenFOAM solver according to claim 2, characterized in that, Step S1 calculates the conformation tensor A using the Rolie-Poly constitutive model and the NS equation, and encapsulates the Rolie-Poly constitutive model in the Rolie-Poly.H file.

4. The method for constructing an OpenFOAM solver according to claim 3, characterized in that, Step S2 specifically includes: adding the following variable parameters for the Rolie-Poly model to createFields.H: tensors in the Rolie-Poly constitutive model: conformation tensor A, trace tr(A) of the conformation tensor, stress sigma, and scalar: relaxation time λ of the polymer molecular chains creeping out of the tube. D λ represents the relaxation time of the polymer chain after it has been stretched. R The following variables are used: solvent viscosity etaS, polymer viscosity etaP, polymer solution elasticity chiMax, slopes beta and delta at which the solution exhibits shear plateaus, and fluid density rho. These variables are entered into the file createFields.H using code format, compiled, and stored in the OpenFOAM environment as part of the solver's parameters.

5. The method for constructing an OpenFOAM solver according to claim 4, characterized in that, Specifically, step S3 involves adding the Rolie-Poly.H constitutive model file after the pressure equation in the PisoFoam.C file: #include"Rolie-Poly.H".

6. The method for constructing an OpenFOAM solver according to claim 5, characterized in that, Step S4 specifically involves: in the OpenFOAM-6-exercise environment, using the wmake command to compile the file directory, and naming the compiled OpenFOAM program's top-level source file as .C. The OpenFOAM program source code is placed in a folder with the same name, which includes a Make folder. The Make folder includes an options file and a files file. The files file specifies the solver name, and the options file specifies the path to the library called by the solver.

7. The method for constructing an OpenFOAM solver according to claim 6, characterized in that, The flat plate shear flow calculation case used in step S5 uses a cube with Re = 0.002, Wi = 2, and a side length of 1x1x1. Its initial condition is: the velocity of the upper and lower planes of the shear flow is 1. Its boundary condition is: the four faces of the cube are periodic boundary conditions. The flat plate shear flow calculation case is solved using a solver in the OpenFOAM environment, generating file data recorded every 0.1 time steps.

8. The method for constructing an OpenFOAM solver according to claim 7, characterized in that, Step S6 generates data through probe processing and produces trend graphs of velocity versus Y, first normal stress difference coefficient versus Y, and second normal stress difference versus Y. The differences between the data generated by probe processing in step S6, the trend graphs of velocity versus Y, first normal stress difference coefficient versus Y, and second normal stress difference versus Y, and the solution results of the RheoFoam solver are compared.