parent a0c46bfc
 ... ... @@ -26,6 +26,9 @@ In the following, we take a close look at the files containing the set-up: At fi Before we enter the problem class containing initial and boundary conditions, we include necessary files and introduce properties. ### Include files
Click to toggle details The dune grid interphase is included here: ```cpp #include ... ... @@ -47,7 +50,12 @@ The fluid properties are specified in the following headers: #include #include ```
### Define basic properties for our simulation
Click to toggle details We enter the namespace Dumux in order to import the entire Dumux namespace for general use ```cpp namespace Dumux { ... ... @@ -115,7 +123,12 @@ We leave the namespace Properties. ```cpp } ```
### The problem class
Click to toggle details We enter the problem class where all necessary initial and boundary conditions are set for our simulation. As this is a Stokes problem, we inherit from the basic `NavierStokesProblem`. ```cpp ... ... @@ -155,11 +168,13 @@ We set the outlet pressure to 1.1e5 Pa as no run-time value is specified. outletPressure_ = getParam("Problem.OutletPressure", 1.1e5); } ``` First, we define the type of initial and boundary conditions depending on location. Two types of boundary conditions can be specified: Dirichlet and Neumann. On a Dirichlet boundary, the values of the primary variables need First, we define the type of initial and boundary conditions depending on location. Two types of boundary conditions can be specified: Dirichlet and Neumann. On a Dirichlet boundary, the values of the primary variables need to be fixed. On a Neumann boundary condition, values for derivatives need to be fixed. When Dirichlet conditions are set for the pressure, the derivative of the velocity vector with respect to the direction normal to the boundary is automatically set to zero. This boundary condition is called in-/outflow boundary condition in Dumux. When Dirichlet conditions are set for the pressure, the derivative of the velocity vector with respect to the direction normal to the boundary is automatically set to zero. This boundary condition is called in-/outflow boundary condition in Dumux. ```cpp BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const { ... ... @@ -264,7 +279,9 @@ This is everything the freeflow channel problem class contains. We leave the namespace Dumux. ```cpp } // end namespace Dumux #endif ```
... ... @@ -273,6 +290,9 @@ We leave the namespace Dumux. We look now at the main file for the channel problem. ### Includes
Click to toggle details ```cpp #include ``` ... ... @@ -335,7 +355,8 @@ We need the following class to simplify the writing of dumux simulation data to ```cpp #include ``` The gridmanager constructs a grid from the information in the input or grid file. There is a specification for the different supported grid managers. The gridmanager constructs a grid from the information in the input or grid file. There is a specification for the different supported grid managers. ```cpp #include ``` ... ... @@ -343,7 +364,12 @@ The following class contains functionality for additional flux output to the con ```cpp #include ```
### Beginning of the main function
Click to toggle details ```cpp int main(int argc, char** argv) try { ... ... @@ -366,7 +392,12 @@ We parse command line arguments and input file ```cpp Parameters::init(argc, argv); ```
### Create the grid
Click to toggle details A gridmanager tries to create the grid either from a grid file or the input file. ```cpp GridManager> gridManager; ... ... @@ -378,9 +409,14 @@ we compute on the leaf grid view ```cpp const auto& leafGridView = gridManager.grid().leafGridView(); ```
### Set-up and solving of the problem #### Set-up
Click to toggle details We create and initialize the finite volume grid geometry, the problem, the linear system, including the jacobian matrix, the residual and the solution vector and the gridvariables. We need the finite volume geometry to build up the subcontrolvolumes (scv) and subcontrolvolume faces (scvf) for each element of the grid partition. ... ... @@ -408,28 +444,14 @@ and then use the solution vector to intialize the `gridVariables`. auto gridVariables = std::make_shared(problem, gridGeometry); gridVariables->init(x); ``` and then initialize the vtkoutput. Each model has a predefined model specific output with relevant parameters for that model. and then initialize the vtkoutput. Each model has a predefined model specific output with relevant parameters for that model. ```cpp using IOFields = GetPropType; StaggeredVtkOutputModule vtkWriter(*gridVariables, x, problem->name()); IOFields::initOutputModule(vtkWriter); // Add model specific output fields vtkWriter.write(0.0); ``` we set the assembler ```cpp using Assembler = StaggeredFVAssembler; auto assembler = std::make_shared(problem, gridGeometry, gridVariables); ``` we set the linear solver ```cpp using LinearSolver = Dumux::UMFPackBackend; auto linearSolver = std::make_shared(); ``` additionally, we set the non-linear solver ```cpp using NewtonSolver = Dumux::NewtonSolver; NewtonSolver nonLinearSolver(assembler, linearSolver); ``` we set up two surfaces over which fluxes are calculated ```cpp FluxOverSurface #### Assembling the linear system
Click to toggle details we set the assembler ```cpp using Assembler = StaggeredFVAssembler; auto assembler = std::make_shared(problem, gridGeometry, gridVariables); ```
#### Solution
Click to toggle details we set the linear solver ```cpp using LinearSolver = Dumux::UMFPackBackend; auto linearSolver = std::make_shared(); ``` additionally, we set the non-linear solver ```cpp using NewtonSolver = Dumux::NewtonSolver; NewtonSolver nonLinearSolver(assembler, linearSolver); ``` we solve the non-linear system ```cpp nonLinearSolver.solve(x); ``` we calculate mass fluxes over the planes ```cpp flux.calculateMassOrMoleFluxes(); ```
### Final Output
Click to toggle details we write vtk output ```cpp vtkWriter.write(1.0); ``` we calculate and print mass fluxes over the planes we print mass fluxes over the planes ```cpp flux.calculateMassOrMoleFluxes(); if(GetPropType::enableEnergyBalance()) { std::cout << "mass / energy flux at middle is: " << flux.netFlux("middle") << std::endl; ... ... @@ -502,10 +560,7 @@ we calculate and print volume fluxes over the planes flux.calculateVolumeFluxes(); std::cout << "volume flux at middle is: " << flux.netFlux("middle") << std::endl; std::cout << "volume flux at outlet is: " << flux.netFlux("outlet") << std::endl; ``` ### Final Output print dumux end message ```cpp if (mpiHelper.rank() == 0) ... ... @@ -541,6 +596,8 @@ catch (...) return 4; } ```
## Results This example computes the following stationary velocity profile: ... ...
 ... ... @@ -19,6 +19,9 @@ // We look now at the main file for the channel problem. // ### Includes //
// Click to toggle details // #include // We include the problem in the main file ... ... @@ -65,8 +68,12 @@ // The following class contains functionality for additional flux output to the console. #include //
// // ### Beginning of the main function //
// Click to toggle details // int main(int argc, char** argv) try { using namespace Dumux; ... ... @@ -83,8 +90,12 @@ int main(int argc, char** argv) try //We parse command line arguments and input file Parameters::init(argc, argv); //
// // ### Create the grid //
// Click to toggle details // // A gridmanager tries to create the grid either from a grid file or the input file. GridManager> gridManager; gridManager.init(); ... ... @@ -93,10 +104,14 @@ int main(int argc, char** argv) try // // we compute on the leaf grid view const auto& leafGridView = gridManager.grid().leafGridView(); //
// // ### Set-up and solving of the problem // // #### Set-up //
// Click to toggle details // // We create and initialize the finite volume grid geometry, the problem, the linear system, including the jacobian matrix, the residual and the solution vector and the gridvariables. // // We need the finite volume geometry to build up the subcontrolvolumes (scv) and subcontrolvolume faces (scvf) for each element of the grid partition. ... ... @@ -127,18 +142,6 @@ int main(int argc, char** argv) try IOFields::initOutputModule(vtkWriter); // Add model specific output fields vtkWriter.write(0.0); // we set the assembler using Assembler = StaggeredFVAssembler; auto assembler = std::make_shared(problem, gridGeometry, gridVariables); // we set the linear solver using LinearSolver = Dumux::UMFPackBackend; auto linearSolver = std::make_shared(); // additionally, we set the non-linear solver using NewtonSolver = Dumux::NewtonSolver; NewtonSolver nonLinearSolver(assembler, linearSolver); // we set up two surfaces over which fluxes are calculated FluxOverSurface // // #### Assembling the linear system //
// Click to toggle details // // we set the assembler using Assembler = StaggeredFVAssembler; auto assembler = std::make_shared(problem, gridGeometry, gridVariables); //
// // #### Solution //
// Click to toggle details // // we set the linear solver using LinearSolver = Dumux::UMFPackBackend; auto linearSolver = std::make_shared(); // additionally, we set the non-linear solver using NewtonSolver = Dumux::NewtonSolver; NewtonSolver nonLinearSolver(assembler, linearSolver); // we solve the non-linear system nonLinearSolver.solve(x); // we calculate mass fluxes over the planes flux.calculateMassOrMoleFluxes(); //
// // ### Final Output //
// Click to toggle details // // we write vtk output vtkWriter.write(1.0); // we calculate and print mass fluxes over the planes flux.calculateMassOrMoleFluxes(); // we print mass fluxes over the planes if(GetPropType::enableEnergyBalance()) { std::cout << "mass / energy flux at middle is: " << flux.netFlux("middle") << std::endl; ... ... @@ -204,9 +236,6 @@ int main(int argc, char** argv) try std::cout << "volume flux at middle is: " << flux.netFlux("middle") << std::endl; std::cout << "volume flux at outlet is: " << flux.netFlux("outlet") << std::endl; // ### Final Output // // print dumux end message if (mpiHelper.rank() == 0) { ... ... @@ -240,3 +269,5 @@ catch (...) std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl; return 4; } //
//
 ... ... @@ -23,6 +23,9 @@ //Before we enter the problem class containing initial and boundary conditions, we include necessary files and introduce properties. // ### Include files //
// Click to toggle details // // The dune grid interphase is included here: #include ... ... @@ -36,8 +39,12 @@ // The fluid properties are specified in the following headers: #include #include //
// // ### Define basic properties for our simulation //
// Click to toggle details // // We enter the namespace Dumux in order to import the entire Dumux namespace for general use namespace Dumux { ... ... @@ -83,8 +90,12 @@ struct EnableGridGeometryCache { static constexpr //The cache stores values that were already calculated for later usage. This makes the simulation faster. // We leave the namespace Properties. } //
// // ### The problem class //
// Click to toggle details // // We enter the problem class where all necessary initial and boundary conditions are set for our simulation. // As this is a Stokes problem, we inherit from the basic `NavierStokesProblem`. template ... ... @@ -208,3 +219,5 @@ private: // We leave the namespace Dumux. } // end namespace Dumux #endif //
//
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!