From 942a8e46cb98500cec4a9c682c001d9b0749bf96 Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Thu, 8 May 2003 10:40:18 +0000 Subject: [PATCH] test for DataOutBase; DX output must be checked later git-svn-id: https://svn.dealii.org/trunk@7605 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/Makefile | 18 ++-- tests/base/data_out_base.cc | 186 ++++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 9 deletions(-) create mode 100644 tests/base/data_out_base.cc diff --git a/tests/base/Makefile b/tests/base/Makefile index dc044d7627..23becf9f8c 100644 --- a/tests/base/Makefile +++ b/tests/base/Makefile @@ -24,25 +24,25 @@ threads.cc : threads.pl @echo =====regenerating== $@ @$(PERL) $^ > $@ +data_out_base.exe : data_out_base.g.$(OBJEXT) $(lib-base.g) logtest.exe : logtest.g.$(OBJEXT) $(lib-base.g) polynomial_test.exe: polynomial_test.g.$(OBJEXT) abort.g.$(OBJEXT) $(lib-base.g) polynomial1d.exe : polynomial1d.g.$(OBJEXT) $(lib-base.g) -quadrature_test.exe: quadrature_test.g.$(OBJEXT) $(libraries) -reference.exe : reference.g.$(OBJEXT) abort.g.$(OBJEXT) $(libraries) -table.exe : table.g.$(OBJEXT) $(libraries) -tensor.exe : tensor.g.$(OBJEXT) $(libraries) -timer.exe : timer.g.$(OBJEXT) $(libraries) -threads.exe : threads.g.$(OBJEXT) $(libraries) +quadrature_test.exe: quadrature_test.g.$(OBJEXT) $(lib-base.g) +reference.exe : reference.g.$(OBJEXT) abort.g.$(OBJEXT) $(lib-base.g) +table.exe : table.g.$(OBJEXT) $(lib-base.g) +tensor.exe : tensor.g.$(OBJEXT) $(lib-base.g) +timer.exe : timer.g.$(OBJEXT) $(lib-base.g) +threads.exe : threads.g.$(OBJEXT) $(lib-base.g) auto_derivative_function.exe : auto_derivative_function.g.$(OBJEXT) $(libraries) anisotropic_1.exe : anisotropic_1.g.$(OBJEXT) $(lib-base.g) anisotropic_2.exe : anisotropic_2.g.$(OBJEXT) $(lib-base.g) hierarchical.exe : hierarchical.g.$(OBJEXT) $(lib-base.g) -tests = $(sort \ - logtest reference quadrature_test table tensor \ +tests = logtest reference quadrature_test table tensor \ timer threads polynomial1d polynomial_test \ auto_derivative_function anisotropic_1 anisotropic_2 \ - hierarchical) + hierarchical data_out_base ############################################################ diff --git a/tests/base/data_out_base.cc b/tests/base/data_out_base.cc new file mode 100644 index 0000000000..3e929644e7 --- /dev/null +++ b/tests/base/data_out_base.cc @@ -0,0 +1,186 @@ +//----------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2000, 2001, 2002, 2003 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. +// +//----------------------------------------------------------------------------- + +#include +#include + +#include +#include +#include +#include + +#define WRITE(type) DataOutBase::write_ ## type (patches, names, type ## flags, out) + +template +void +write_patches(const std::vector >& patches, + std::ostream& out) +{ + std::vector names(2); + names[0] = std::string("first name"); + names[1] = std::string("last name"); + + DataOutBase::DXFlags dxflags; +// DataOutBase::EpsFlags epsflags; +// DataOutBase::GnuplotFlags gnuplotflags; +// DataOutBase::GmvFlags gmvflags; +// DataOutBase::PovrayFlags povrayflags; +// DataOutBase::UcdFlags ucdflags; +// DataOutBase::VtkFlags vtkflags; + + WRITE(dx); + +} + +template +struct PatchInfo +{ + static double vertices[GeometryInfo::vertices_per_cell][3]; + static double offsets[GeometryInfo::vertices_per_cell][3]; + static int neighbors[GeometryInfo::vertices_per_cell][GeometryInfo::faces_per_cell]; +}; + + +double PatchInfo<1>::vertices[2][3] += {{0, 0, 0} + ,{3, 6, 9} +}; + +double PatchInfo<2>::vertices[4][3] += {{0, 0, 0} + ,{3, 0, 3} + ,{3, 3, 6} + ,{3, 0, 3} +}; + + +double PatchInfo<3>::vertices[8][3] += {{0, 0, 0} + ,{3, 0, 0} + ,{3, 3, 0} + ,{0, 3, 0} + ,{0, 0, 3} + ,{3, 0, 3} + ,{3, 3, 3} + ,{0, 3, 3} +}; + + +int PatchInfo<1>::neighbors[2][2] += {{-1, 1} + ,{ 0, -1} +}; + + + +int PatchInfo<2>::neighbors[4][4] += {{-1, 1, 2, -1} + ,{-1, -1, 3, 0} + ,{ 0, 3, -1, -1} + ,{ 1, -1, -1, 2} +}; + + + +int PatchInfo<3>::neighbors[8][6] += {{-1, -1, -1, -1, -1, -1} + ,{-1, -1, -1, -1, -1, -1} + ,{-1, -1, -1, -1, -1, -1} + ,{-1, -1, -1, -1, -1, -1} + ,{-1, -1, -1, -1, -1, -1} + ,{-1, -1, -1, -1, -1, -1} + ,{-1, -1, -1, -1, -1, -1} + ,{-1, -1, -1, -1, -1, -1} +}; + + +double PatchInfo<1>::offsets[2][3] += {{ 0, 0, 0} + ,{ 3, 0, 0} +}; + + +double PatchInfo<2>::offsets[4][3] += {{ 0, 0, 0} + ,{ 3, 0, 0} + ,{ 0, 3, 0} + ,{ 3, 3, 0} +}; + + +double PatchInfo<3>::offsets[8][3] += {{ 0, 0, 0} + ,{ 3, 0, 0} + ,{ 0, 3, 0} + ,{ 3, 3, 0} + ,{ 0, 0, 3} + ,{ 3, 0, 3} + ,{ 0, 3, 3} + ,{ 3, 3, 3} +}; + + + +template +void +create_patches(std::vector >& patches) +{ + const unsigned int ncells = GeometryInfo::vertices_per_cell; + const unsigned int nsub = 3; + + patches.resize(ncells); + + for (unsigned int c = 0; c < ncells;++c) + { + DataOutBase::Patch& p = patches[c]; + p.patch_index = c; + p.n_subdivisions = nsub; + + for (unsigned int i=0;i::vertices[i][j] + + PatchInfo::offsets[c][j]; + + for (unsigned int i=0;i::faces_per_cell;++i) + p.neighbors[i] = (unsigned int) PatchInfo::neighbors[c][i]; + + unsigned int ndata = 1; + for (unsigned int i=0;i > patch11; + std::vector > patch12; + std::vector > patch13; + std::vector > patch22; + std::vector > patch23; + std::vector > patch33; + + create_patches(patch33); + write_patches(patch33, logfile); +} -- 2.39.5