From: kanschat Date: Thu, 1 Dec 2011 21:44:53 +0000 (+0000) Subject: use new perl script for ConstraintMatrix (more to do) and BlockSparseMatrix X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=521604d44e45a1497b84e02dab2be32eb68ca595;p=dealii-svn.git use new perl script for ConstraintMatrix (more to do) and BlockSparseMatrix git-svn-id: https://svn.dealii.org/trunk@24785 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/source/Makefile b/deal.II/source/Makefile index 5b953696bc..dafafcf5d6 100644 --- a/deal.II/source/Makefile +++ b/deal.II/source/Makefile @@ -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 diff --git a/deal.II/source/lac/block_sparse_matrix.cc b/deal.II/source/lac/block_sparse_matrix.cc index 25674e6285..1f4ae1e436 100644 --- a/deal.II/source/lac/block_sparse_matrix.cc +++ b/deal.II/source/lac/block_sparse_matrix.cc @@ -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; -template class BlockSparseMatrix; +#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 index 0000000000..33925a706d --- /dev/null +++ b/deal.II/source/lac/block_sparse_matrix.pl @@ -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; +EOT + ; + +###################################################################### +# End of definitions, now come the loops +###################################################################### + +foreach my $r1 (@real_scalars) +{ + my $t = $scalar_functions; + $t =~ s/S1/$r1/g; + print $t; +} diff --git a/deal.II/source/lac/constraint_matrix.cc b/deal.II/source/lac/constraint_matrix.cc index 3a7d1f30d8..cdf3a59912 100644 --- a/deal.II/source/lac/constraint_matrix.cc +++ b/deal.II/source/lac/constraint_matrix.cc @@ -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 &) const - -VECTOR_FUNCTIONS(Vector); -VECTOR_FUNCTIONS(Vector); -VECTOR_FUNCTIONS(Vector); -VECTOR_FUNCTIONS(BlockVector); -VECTOR_FUNCTIONS(BlockVector); -VECTOR_FUNCTIONS(BlockVector); - // 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(MatrixType &uncondensed, \ - VectorType &vec) const \ - - -CONDENSE_FUNCTIONS(Vector,float,SparseMatrix); -CONDENSE_FUNCTIONS(Vector,float,SparseMatrix); -CONDENSE_FUNCTIONS(Vector,double,SparseMatrix); -CONDENSE_FUNCTIONS(Vector,double,SparseMatrix); -CONDENSE_FUNCTIONS(BlockVector,float,BlockSparseMatrix); -CONDENSE_FUNCTIONS(BlockVector,float,BlockSparseMatrix); -CONDENSE_FUNCTIONS(BlockVector,double,BlockSparseMatrix); -CONDENSE_FUNCTIONS(BlockVector,double,BlockSparseMatrix); - - -template -void -ConstraintMatrix::condense(const SparseMatrix &uncondensed, - SparseMatrix &condensed) const; -template -void -ConstraintMatrix::condense(SparseMatrix &uncondensed) const; - -template -void -ConstraintMatrix::condense(const SparseMatrix &uncondensed, - SparseMatrix &condensed) const; - -template -void -ConstraintMatrix::condense(SparseMatrix &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(BlockSparseMatrix &uncondensed) const; - -template -void -ConstraintMatrix::condense(BlockSparseMatrix &uncondensed) const; - - #define MATRIX_VECTOR_FUNCTIONS(MatrixType, VectorType) \ template void ConstraintMatrix:: \ distribute_local_to_global (const FullMatrix &, \ @@ -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 index 0000000000..b12bd001d1 --- /dev/null +++ b/deal.II/source/lac/constraint_matrix.pl @@ -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(const V1 &, V1&) const; +template void ConstraintMatrix::condense(V1 &vec) const; +template void ConstraintMatrix::set_zero(V1&) const; +template void ConstraintMatrix::distribute_local_to_global ( + const Vector&, const std::vector &, V1&, const FullMatrix&) const; +template void ConstraintMatrix::distribute(const V1 &, V1&) const; +template void ConstraintMatrix::distribute(V1 &) const; +EOT + ; + +my $scalar_vector_functions = <<'EOT' + +EOT + ; + +my $scalar_functions = <<'EOT' + +template void ConstraintMatrix::condense(const SparseMatrix&, SparseMatrix &) const; +template void ConstraintMatrix::condense(SparseMatrix&) const; +template void ConstraintMatrix::condense(BlockSparseMatrix&) const; +EOT + ; + +my $scalar_scalar_functions = <<'EOT' +template void ConstraintMatrix::condense >(SparseMatrix&, Vector&) const; +template void ConstraintMatrix::condense >(BlockSparseMatrix&, BlockVector&) const; +template void ConstraintMatrix::condense >( + const SparseMatrix&, const Vector&, SparseMatrix &, Vector&) const; +template void ConstraintMatrix::condense >( + const SparseMatrix&, const BlockVector&, SparseMatrix &, BlockVector&) 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 + } +}