]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
use new perl script for ConstraintMatrix (more to do) and BlockSparseMatrix
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 1 Dec 2011 21:44:53 +0000 (21:44 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 1 Dec 2011 21:44:53 +0000 (21:44 +0000)
git-svn-id: https://svn.dealii.org/trunk@24785 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/Makefile
deal.II/source/lac/block_sparse_matrix.cc
deal.II/source/lac/block_sparse_matrix.pl [new file with mode: 0644]
deal.II/source/lac/constraint_matrix.cc
deal.II/source/lac/constraint_matrix.pl [new file with mode: 0644]

index 5b953696bc574f4bba07e19eb3dd37e15aec2db6..dafafcf5d6d0ca83a0b3120d71ba7dfc99c5c17f 100644 (file)
@@ -25,7 +25,8 @@ cc-files      := $(shell for i in $(all-dirs) ; do echo $D/source/$$i/*.cc ; don
 h-files       := $(sort $(shell echo $D/include/deal.II/*/*.h))
 
 inst-in-files := $(shell echo */*.inst.in)
-inst-files    := $(inst-in-files:%.in=%)
+pl-files      := $(shell echo */*.pl)
+inst-files    := $(inst-in-files:%.in=%) $(pl-files:%.pl=%.inst)
 
 
 # build unique object file names
@@ -53,6 +54,10 @@ $(LIBDIR)/optimized/%.$(OBJEXT) :
        @echo "===================================== $(@F)"
        @$D/common/scripts/expand_instantiations $D/common/template-arguments < $< > $@ || exit 1
 
+%.inst : %.pl $D/common/dealiitemplates.pm
+       @echo "===================================== $(@F)"
+       @perl -I $D/common/ $< > $@ || exit 1
+
 
 
 # there are extra .o file for the function parser and umfpack that we
index 25674e62858b3f22cb60d99c6473a4f343d4049c..1f4ae1e436e8caa4d266710eb1e382892b3278ff 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006 by the deal.II authors
+//    Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006, 2011 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -15,8 +15,6 @@
 
 DEAL_II_NAMESPACE_OPEN
 
-// explicit instantiations
-template class BlockSparseMatrix<double>;
-template class BlockSparseMatrix<float>;
+#include "block_sparse_matrix.inst"
 
 DEAL_II_NAMESPACE_CLOSE
diff --git a/deal.II/source/lac/block_sparse_matrix.pl b/deal.II/source/lac/block_sparse_matrix.pl
new file mode 100644 (file)
index 0000000..33925a7
--- /dev/null
@@ -0,0 +1,28 @@
+######################################################################
+# $Id$
+######################################################################
+#
+# Copyright (C) 2011 by the deal.II authors
+#
+######################################################################
+
+use strict;
+use warnings;
+
+use dealiitemplates;
+
+my $scalar_functions = <<'EOT'
+template class BlockSparseMatrix<S1>;
+EOT
+    ;
+
+######################################################################
+# End of definitions, now come the loops
+######################################################################
+
+foreach my $r1 (@real_scalars)
+{
+    my $t = $scalar_functions;
+    $t =~ s/S1/$r1/g;
+    print $t;
+}
index 3a7d1f30d883f15a7048fa2d3388438e13fdc13e..cdf3a599120e0c033a91602c78bc7d0ada195bfc 100644 (file)
@@ -1,6 +1,5 @@
 //---------------------------------------------------------------------------
 //    $Id$
-//    Version: $Name$
 //
 //    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors
 //
@@ -2276,77 +2275,21 @@ ConstraintMatrix::memory_consumption () const
                                             const FullMatrix<double>        &) const
 
 
-
-VECTOR_FUNCTIONS(Vector<float>);
-VECTOR_FUNCTIONS(Vector<double>);
-VECTOR_FUNCTIONS(Vector<long double>);
-VECTOR_FUNCTIONS(BlockVector<float>);
-VECTOR_FUNCTIONS(BlockVector<double>);
-VECTOR_FUNCTIONS(BlockVector<long double>);
-
 // TODO: Can PETSc really do all the operations required by the above
 // condense/distribute function etc also on distributed vectors? Trilinos
 // can't do that - we have to rewrite those functions by hand if we want to
 // use them. The key is to use local ranges etc., which still needs to be
 // implemented.
 #ifdef DEAL_II_USE_PETSC
-VECTOR_FUNCTIONS(PETScWrappers::Vector);
-VECTOR_FUNCTIONS(PETScWrappers::BlockVector);
 VECTOR_FUNCTIONS(PETScWrappers::MPI::Vector);
 VECTOR_FUNCTIONS(PETScWrappers::MPI::BlockVector);
 #endif
 
 #ifdef DEAL_II_USE_TRILINOS
-VECTOR_FUNCTIONS(TrilinosWrappers::Vector);
-VECTOR_FUNCTIONS(TrilinosWrappers::BlockVector);
 PARALLEL_VECTOR_FUNCTIONS(TrilinosWrappers::MPI::Vector);
 PARALLEL_VECTOR_FUNCTIONS(TrilinosWrappers::MPI::BlockVector);
 #endif
 
-#define CONDENSE_FUNCTIONS(VectorType, number, MatrixType)             \
-  template void ConstraintMatrix::condense<number,VectorType >(MatrixType &uncondensed, \
-                                                              VectorType &vec) const \
-
-
-CONDENSE_FUNCTIONS(Vector<float>,float,SparseMatrix<float>);
-CONDENSE_FUNCTIONS(Vector<double>,float,SparseMatrix<float>);
-CONDENSE_FUNCTIONS(Vector<double>,double,SparseMatrix<double>);
-CONDENSE_FUNCTIONS(Vector<float>,double,SparseMatrix<double>);
-CONDENSE_FUNCTIONS(BlockVector<double>,float,BlockSparseMatrix<float>);
-CONDENSE_FUNCTIONS(BlockVector<float>,float,BlockSparseMatrix<float>);
-CONDENSE_FUNCTIONS(BlockVector<double>,double,BlockSparseMatrix<double>);
-CONDENSE_FUNCTIONS(BlockVector<float>,double,BlockSparseMatrix<double>);
-
-
-template
-void
-ConstraintMatrix::condense<float>(const SparseMatrix<float> &uncondensed,
-                                  SparseMatrix<float> &condensed) const;
-template
-void
-ConstraintMatrix::condense<float>(SparseMatrix<float> &uncondensed) const;
-
-template
-void
-ConstraintMatrix::condense<double>(const SparseMatrix<double> &uncondensed,
-                                   SparseMatrix<double> &condensed) const;
-
-template
-void
-ConstraintMatrix::condense<double>(SparseMatrix<double> &uncondensed) const;
-
-
-// block sparse matrices are only implemented for one of the two matrix
-// functions (the single-argument, in-place function)
-template
-void
-ConstraintMatrix::condense<double>(BlockSparseMatrix<double> &uncondensed) const;
-
-template
-void
-ConstraintMatrix::condense<float>(BlockSparseMatrix<float> &uncondensed) const;
-
-
 #define MATRIX_VECTOR_FUNCTIONS(MatrixType, VectorType) \
 template void ConstraintMatrix:: \
 distribute_local_to_global<MatrixType,VectorType > (const FullMatrix<double>        &, \
@@ -2488,4 +2431,6 @@ ONLY_MATRIX_FUNCTIONS(PETScWrappers::MPI::SparseMatrix);
 ONLY_MATRIX_FUNCTIONS(PETScWrappers::MPI::BlockSparseMatrix);
 #endif
 
+#include "constraint_matrix.inst"
+
 DEAL_II_NAMESPACE_CLOSE
diff --git a/deal.II/source/lac/constraint_matrix.pl b/deal.II/source/lac/constraint_matrix.pl
new file mode 100644 (file)
index 0000000..b12bd00
--- /dev/null
@@ -0,0 +1,74 @@
+######################################################################
+# $Id$
+######################################################################
+#
+# Copyright (C) 2011 by the deal.II authors
+#
+######################################################################
+
+use strict;
+use warnings;
+
+use dealiitemplates;
+
+my $vector_functions = <<'EOT'
+
+template void ConstraintMatrix::condense<V1 >(const V1 &, V1&) const;
+template void ConstraintMatrix::condense<V1 >(V1 &vec) const;
+template void ConstraintMatrix::set_zero<V1 >(V1&) const;
+template void ConstraintMatrix::distribute_local_to_global<V1 > (
+    const Vector<double>&, const std::vector<unsigned int> &, V1&, const FullMatrix<double>&) const;
+template void ConstraintMatrix::distribute<V1 >(const V1 &, V1&) const;
+template void ConstraintMatrix::distribute<V1 >(V1 &) const;
+EOT
+    ;
+
+my $scalar_vector_functions = <<'EOT'
+
+EOT
+    ;
+
+my $scalar_functions = <<'EOT'
+
+template void ConstraintMatrix::condense<S1>(const SparseMatrix<S1>&, SparseMatrix<S1> &) const;
+template void ConstraintMatrix::condense<S1>(SparseMatrix<S1>&) const;
+template void ConstraintMatrix::condense<S1>(BlockSparseMatrix<S1>&) const;
+EOT
+    ;
+
+my $scalar_scalar_functions = <<'EOT'
+template void ConstraintMatrix::condense<S1,Vector<S2> >(SparseMatrix<S1>&, Vector<S2>&) const;
+template void ConstraintMatrix::condense<S1,BlockVector<S2> >(BlockSparseMatrix<S1>&, BlockVector<S2>&) const;
+template void ConstraintMatrix::condense<S1,Vector<S2> >(
+    const SparseMatrix<S1>&, const Vector<S2>&, SparseMatrix<S1> &, Vector<S2>&) const;
+template void ConstraintMatrix::condense<S1,BlockVector<S2> >(
+    const SparseMatrix<S1>&, const BlockVector<S2>&, SparseMatrix<S1> &, BlockVector<S2>&) const;
+EOT
+    ;
+
+######################################################################
+# End of definitions, now come the loops
+######################################################################
+
+foreach my $v (@sequential_vectors)
+{
+    my $t = $vector_functions;
+    $t =~ s/V1/$v/g;
+    print $t;
+    
+}
+
+foreach my $r1 (@real_scalars)
+{
+    my $t = $scalar_functions;
+    $t =~ s/S1/$r1/g;
+    print $t;
+    
+    foreach my $r2 (@real_scalars)
+    {
+       my $t = $scalar_scalar_functions;
+       $t =~ s/S1/$r1/g;
+       $t =~ s/S2/$r2/g;
+       print $t
+    }
+}

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.