From 4f00c67df75190e9faddaee5eda28f868be2da3f Mon Sep 17 00:00:00 2001 From: asartori86 Date: Sat, 22 Jul 2017 18:09:54 +0200 Subject: [PATCH] instantiate ParsedGridGenerator<1,3> --- source/parsed_grid_generator.cc | 91 ++++++++++++++++--- .../parsed_grid_generator_13.cc | 46 ++++++++++ .../parsed_grid_generator_13.output | 28 ++++++ 3 files changed, 152 insertions(+), 13 deletions(-) create mode 100644 tests/parsed_grid_generator/parsed_grid_generator_13.cc create mode 100644 tests/parsed_grid_generator/parsed_grid_generator_13.output diff --git a/source/parsed_grid_generator.cc b/source/parsed_grid_generator.cc index ada3ef91..c814f3d6 100644 --- a/source/parsed_grid_generator.cc +++ b/source/parsed_grid_generator.cc @@ -595,6 +595,63 @@ struct PGGHelper } } + static void + create_grid(ParsedGridGenerator<1, 3> *p, + Triangulation<1,3> &tria) + { + if (p->grid_name == "rectangle") + { + Tensor<1,1> initializer1; + Tensor<1,1> initializer2; + for (unsigned int i=0; i<1; ++i) + { + initializer1[i]=p->point_option_one(i); + initializer2[i]=p->point_option_two(i); + } + Point<1> p1(initializer1); + Point<1> p2(initializer2); + + GridGenerator::subdivided_hyper_rectangle (tria, + p->un_int_vec_option_one, + p2, + p1, + p->colorize); + } + else if (p->grid_name == "file") + { + GridIn<1, 3> gi; + gi.attach_triangulation(tria); + + std::ifstream in(p->input_grid_file_name.c_str()); + AssertThrow(in, ExcIO()); + + std::string ext = extension(p->input_grid_file_name); + if (ext == "vtk") + gi.read_vtk(in); + else if (ext == "msh") + gi.read_msh(in); + else if (ext == "ucd" || ext == "inp") + gi.read_ucd(in); + else if (ext == "unv") + gi.read_unv(in); + else if (ext == "ar") + { + boost::archive::text_iarchive ia(in); + tria.load(ia, 0); + } + else if (ext == "bin") + { + boost::archive::binary_iarchive ia(in); + tria.load(ia, 0); + } + else + Assert(false, ExcNotImplemented()); + } + else + AssertThrow(false, ExcMessage("Not implemented: " + p->grid_name)); + + } + /** * This function is used to generate grids when spacedim = dim = 3. */ @@ -886,25 +943,34 @@ void ParsedGridGenerator::create(Triangulation &tri Assert(grid_name != "", ExcNotInitialized()); PGGHelper::create_grid( this, tria); - parse_manifold_descriptors(optional_manifold_descriptors); + if (!(dim==1 && spacedim==3)) + { + parse_manifold_descriptors(optional_manifold_descriptors); - if (copy_boundary_to_manifold_ids || create_default_manifolds) - GridTools::copy_boundary_to_manifold_id(tria); + if (copy_boundary_to_manifold_ids || create_default_manifolds) + GridTools::copy_boundary_to_manifold_id(tria); - if (copy_material_to_manifold_ids) - GridTools::copy_material_to_manifold_id(tria); + if (copy_material_to_manifold_ids) + GridTools::copy_material_to_manifold_id(tria); - if (create_default_manifolds) - parse_manifold_descriptors(default_manifold_descriptors); + if (create_default_manifolds) + parse_manifold_descriptors(default_manifold_descriptors); - // Now attach the manifold descriptors - for (auto m: manifold_descriptors) - { - tria.set_manifold(m.first, *m.second); + // Now attach the manifold descriptors + for (auto m: manifold_descriptors) + { + tria.set_manifold(m.first, *m.second); + } } } +template<> +void +ParsedGridGenerator<1, 3>::parse_manifold_descriptors(const std::string &) +{ + Assert(false,ExcNotImplemented()); +} template void @@ -923,7 +989,6 @@ ParsedGridGenerator::parse_manifold_descriptors(const std::string } - template void ParsedGridGenerator::write(const Triangulation &tria, const std::string &filename) const @@ -1019,7 +1084,7 @@ D2K_NAMESPACE_CLOSE template class deal2lkit::ParsedGridGenerator<1,1>; template class deal2lkit::ParsedGridGenerator<1,2>; -//template class deal2lkit::ParsedGridGenerator<1,3>; +template class deal2lkit::ParsedGridGenerator<1,3>; template class deal2lkit::ParsedGridGenerator<2,2>; template class deal2lkit::ParsedGridGenerator<2,3>; template class deal2lkit::ParsedGridGenerator<3,3>; diff --git a/tests/parsed_grid_generator/parsed_grid_generator_13.cc b/tests/parsed_grid_generator/parsed_grid_generator_13.cc new file mode 100644 index 00000000..54eed97a --- /dev/null +++ b/tests/parsed_grid_generator/parsed_grid_generator_13.cc @@ -0,0 +1,46 @@ +//----------------------------------------------------------- +// +// Copyright (C) 2017 by the deal2lkit authors +// +// This file is part of the deal2lkit library. +// +// The deal2lkit library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal2lkit distribution. +// +//----------------------------------------------------------- + + +#include "../tests.h" +#include +#include + +#include +#include + + +using namespace deal2lkit; + +template +void test(ParsedGridGenerator &pgg) +{ + Triangulation *tria = pgg.serial(); + GridOut go; + go.write_msh(*tria, deallog.get_file_stream()); + delete tria; +} + + +int main () +{ + initlog(); + ParsedGridGenerator<1,3> a("Flagellum", "rectangle"); + ParameterAcceptor::initialize(); + ParameterAcceptor::prm.log_parameters(deallog); + + deallog <<"flagellum"< 1: 0,0,0 +DEAL:parameters:Flagellum::Optional Point 2: 1,0,0 +DEAL:parameters:Flagellum::Optional double 1: 1.0 +DEAL:parameters:Flagellum::Optional double 2: 0.5 +DEAL:parameters:Flagellum::Optional double 3: 1.5 +DEAL:parameters:Flagellum::Optional int 1: 1 +DEAL:parameters:Flagellum::Optional int 2: 2 +DEAL:parameters:Flagellum::Optional vector of dim int: 1 +DEAL:parameters:Flagellum::Output grid file name: +DEAL::flagellum +$NOD +2 +1 0.00000 0.00000 0.00000 +2 1.00000 0.00000 0.00000 +$ENDNOD +$ELM +1 +1 1 0 0 2 1 2 +$ENDELM