]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
example for CompressedBlockSparsityPattern
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 14 Jun 2006 14:02:42 +0000 (14:02 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 14 Jun 2006 14:02:42 +0000 (14:02 +0000)
git-svn-id: https://svn.dealii.org/trunk@13245 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/examples/doxygen/.cvsignore
deal.II/examples/doxygen/Makefile
deal.II/examples/doxygen/compressed_block_sparsity_pattern.cc [new file with mode: 0644]

index 243b7093adc19406b954f34170c81cfd4b0c3558..043cff5be150d8445d6e9f21fcc618a41e00842e 100644 (file)
@@ -1,3 +1,4 @@
 Makefile.dep
 block_matrix_array
 product_matrix
+compressed_block_sparsity_pattern
index 6ea5575bf63f199314562c541dad7f9b0b298688..422270a3e26cd7721e9f572b859a19e393063200 100644 (file)
@@ -2,7 +2,7 @@
 #    $Id$
 #    Version: $Name$
 #
-#    Copyright (C) 1998 - 2005 by the deal.II authors
+#    Copyright (C) 1998 - 2006 by the deal.II authors
 #
 #    This file is subject to QPL and may not be  distributed
 #    without copyright and license information. Please refer
@@ -12,7 +12,8 @@
 ###########################################################################
 include ../../common/Make.global_options
 
-all: product_matrix$(EXEEXT) block_matrix_array$(EXEEXT)
+all: product_matrix$(EXEEXT) block_matrix_array$(EXEEXT) \
+     compressed_block_sparsity_pattern$(EXEEXT)
 
 ######################################################################
 # Compilation of source code
@@ -34,6 +35,10 @@ product_matrix$(EXEEXT): product_matrix.$(OBJEXT) $(lib-lac.g) $(lib-base.g)
        @echo =====linking====$(MT)== $<
        @$(CXX) $(CXXFLAGS.g) $(LDFLAGS) -o $@ $^ $(LIBS)
 
+compressed_block_sparsity_pattern$(EXEEXT): compressed_block_sparsity_pattern.$(OBJEXT) $(lib-deal2-2d.g) $(lib-lac.g) $(lib-base.g)
+       @echo =====linking====$(MT)== $<
+       @$(CXX) $(CXXFLAGS.g) $(LDFLAGS) -o $@ $^ $(LIBS)
+
 ######################################################################
 # Pseudo target for cleaning directory
 ######################################################################
diff --git a/deal.II/examples/doxygen/compressed_block_sparsity_pattern.cc b/deal.II/examples/doxygen/compressed_block_sparsity_pattern.cc
new file mode 100644 (file)
index 0000000..540215b
--- /dev/null
@@ -0,0 +1,67 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2006 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+
+// See documentation of CompressedBlockSparsityPattern for documentation of this example
+
+#include <lac/block_sparsity_pattern.h>
+#include <grid/tria.h>
+#include <grid/tria_accessor.h>
+#include <grid/tria_iterator.h>
+#include <grid/grid_generator.h>
+#include <fe/fe_q.h>
+#include <fe/fe_system.h>
+#include <dofs/dof_handler.h>
+#include <dofs/dof_constraints.h>
+#include <dofs/dof_tools.h>
+
+#include <iostream>
+
+int main()
+{
+  Triangulation<2> tr;
+  GridGenerator::subdivided_hyper_cube(tr, 3);
+  tr.begin_active()->set_refine_flag();
+  tr.execute_coarsening_and_refinement();
+
+  FE_Q<2> fe1(1);
+  FE_Q<2> fe2(2);
+  FESystem<2> fe(fe1, 2, fe2, 1);
+  
+  DoFHandler<2> dof(tr);
+  dof.distribute_dofs(fe);
+  ConstraintMatrix constraints;
+  DoFTools::make_hanging_node_constraints(dof, constraints);
+  constraints.close();
+  
+  std::vector<unsigned int> dofs_per_block(fe.n_blocks());
+  DoFTools::count_dofs_per_block(dof, dofs_per_block);
+  
+  CompressedBlockSparsityPattern c_sparsity(fe.n_blocks(), fe.n_blocks());
+  for (unsigned int i=0;i<fe.n_blocks();++i)
+    for (unsigned int j=0;j<fe.n_blocks();++j)
+      c_sparsity.block(i,j).reinit(dofs_per_block[i],dofs_per_block[j]);
+  c_sparsity.collect_sizes();
+
+  DoFTools::make_sparsity_pattern(dof, c_sparsity);
+  constraints.condense(c_sparsity);
+
+  BlockSparsityPattern sparsity;
+  sparsity.copy_from(c_sparsity);
+  
+  for (unsigned int i=0;i<fe.n_blocks();++i)
+    for (unsigned int j=0;j<fe.n_blocks();++j)
+      {
+       std::cout << "   Block " << i << ' ' << j << std::endl;
+       sparsity.block(i,j).print(std::cout);
+      }
+}

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.