> > The minimal code. > -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/006ec2fb-d714-4798-a1ca-35ae0b14d0be%40googlegroups.com.
#include <deal.II/base/quadrature_lib.h> #include <deal.II/base/function.h> #include <deal.II/base/timer.h>
#include <deal.II/lac/generic_linear_algebra.h> namespace LA { #if defined(DEAL_II_WITH_TRILINOS) using namespace dealii::LinearAlgebraTrilinos; #else # error DEAL_II_WITH_TRILINOS required #endif } #include <deal.II/lac/vector.h> #include <deal.II/lac/full_matrix.h> #include <deal.II/lac/solver_cg.h> #include <deal.II/lac/solver_gmres.h> #include <deal.II/lac/solver_minres.h> #include <deal.II/lac/constraint_matrix.h> #include <deal.II/lac/dynamic_sparsity_pattern.h> #include <deal.II/lac/petsc_parallel_sparse_matrix.h> #include <deal.II/lac/petsc_parallel_vector.h> #include <deal.II/lac/petsc_solver.h> #include <deal.II/lac/petsc_precondition.h> #include <deal.II/grid/grid_generator.h> #include <deal.II/grid/tria_accessor.h> #include <deal.II/grid/tria_iterator.h> #include <deal.II/grid/manifold_lib.h> #include <deal.II/grid/grid_tools.h> #include <deal.II/dofs/dof_handler.h> #include <deal.II/dofs/dof_renumbering.h> #include <deal.II/dofs/dof_accessor.h> #include <deal.II/dofs/dof_tools.h> #include <deal.II/fe/fe_values.h> #include <deal.II/fe/fe_raviart_thomas.h> #include <deal.II/fe/fe_dgq.h> #include <deal.II/fe/fe_system.h> #include <deal.II/numerics/vector_tools.h> #include <deal.II/numerics/data_out.h> #include <deal.II/numerics/error_estimator.h> #include <deal.II/base/utilities.h> #include <deal.II/base/conditional_ostream.h> #include <deal.II/base/index_set.h> #include <deal.II/lac/sparsity_tools.h> #include <deal.II/distributed/tria.h> #include <deal.II/distributed/grid_refinement.h> #include <deal.II/base/tensor_function.h> #include <cmath> #include <fstream> #include <iostream> namespace Step55 { using namespace dealii; template <int dim> class StokesProblem { public: StokesProblem (unsigned int degree); void run (); private: void make_grid (); void setup_system (); unsigned int degree; MPI_Comm mpi_communicator; FESystem<dim> fe; parallel::distributed::Triangulation<dim> triangulation; DoFHandler<dim> dof_handler; std::vector<IndexSet> owned_partitioning; std::vector<IndexSet> relevant_partitioning; ConstraintMatrix constraints; }; template <int dim> StokesProblem<dim>::StokesProblem (unsigned int degree) : degree (degree), mpi_communicator (MPI_COMM_WORLD), fe (FE_RaviartThomas<dim>(degree), 1, FE_DGQ<dim>(degree), 1), triangulation (mpi_communicator, typename Triangulation<dim>::MeshSmoothing (Triangulation<dim>::smoothing_on_refinement | Triangulation<dim>::smoothing_on_coarsening)), dof_handler (triangulation) {} template <int dim> void StokesProblem<dim>::make_grid() { GridGenerator::hyper_cube (triangulation, 0, 1.0); triangulation.refine_global (3); } template <int dim> void StokesProblem<dim>::setup_system () { dof_handler.distribute_dofs (fe); DoFRenumbering::component_wise(dof_handler); std::vector<types::global_dof_index> dofs_per_component(dim + 1); DoFTools::count_dofs_per_component(dof_handler, dofs_per_component); const unsigned int n_u = dofs_per_component[0], n_p = dofs_per_component[dim]; std::cout << "Number of active cells: " << triangulation.n_active_cells() << std::endl << "Total number of cells: " << triangulation.n_cells() << std::endl << "Number of degrees of freedom: " << dof_handler.n_dofs() << " (" << n_u << '+' << n_p << ')' << std::endl; owned_partitioning.resize(2); owned_partitioning[0] = dof_handler.locally_owned_dofs ().get_view(0, n_u); owned_partitioning[1] = dof_handler.locally_owned_dofs ().get_view(n_u, n_u+n_p); IndexSet locally_relevant_dofs; DoFTools::extract_locally_relevant_dofs (dof_handler, locally_relevant_dofs); relevant_partitioning.resize(2); relevant_partitioning[0] = locally_relevant_dofs.get_view(0, n_u); relevant_partitioning[1] = locally_relevant_dofs.get_view(n_u, n_u+n_p); constraints.reinit (locally_relevant_dofs); DoFTools::make_hanging_node_constraints (dof_handler, constraints); VectorTools::project_boundary_values_div_conforming(dof_handler, 0, ZeroFunction<dim>(dim), 0, constraints); constraints.close (); } template <int dim> void StokesProblem<dim>::run () { make_grid (); setup_system (); } } int main(int argc, char *argv[]) { using namespace dealii; using namespace Step55; Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); StokesProblem<2> problem (0); problem.run (); return 0; }
## # CMake script for the step-21 tutorial program: ## # Set the name of the project and target: SET(TARGET "test") # Declare all source files the target consists of. Here, this is only # the one step-X.cc file, but as you expand your project you may wish # to add other source files as well. If your project becomes much larger, # you may want to either replace the following statement by something like # FILE(GLOB_RECURSE TARGET_SRC "source/*.cc") # FILE(GLOB_RECURSE TARGET_INC "include/*.h") # SET(TARGET_SRC ${TARGET_SRC} ${TARGET_INC}) # or switch altogether to the large project CMakeLists.txt file discussed # in the "CMake in user projects" page accessible from the "User info" # page of the documentation. SET(TARGET_SRC ${TARGET}.cc ) # Usually, you will not need to modify anything beyond this point... CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) FIND_PACKAGE(deal.II 9.0.0 QUIET HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} ) IF(NOT ${deal.II_FOUND}) MESSAGE(FATAL_ERROR "\n" "*** Could not locate a (sufficiently recent) version of deal.II. ***\n\n" "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n" "or set an environment variable \"DEAL_II_DIR\" that contains this path." ) ENDIF() DEAL_II_INITIALIZE_CACHED_VARIABLES() PROJECT(${TARGET}) DEAL_II_INVOKE_AUTOPILOT()