From 3927577a988981496b5d015279d7635636fd102b Mon Sep 17 00:00:00 2001 From: MFraters Date: Sat, 11 Apr 2015 11:28:31 +0200 Subject: [PATCH 1/4] Large cleanup of the isoterms plugin. Renamed variabled and added some comments on their function --- include/aspect/mesh_refinement/isotherms.h | 88 ++++++ source/mesh_refinement/isotherms.cc | 343 +++++++++++++++++++++ 2 files changed, 431 insertions(+) create mode 100644 include/aspect/mesh_refinement/isotherms.h create mode 100644 source/mesh_refinement/isotherms.cc diff --git a/include/aspect/mesh_refinement/isotherms.h b/include/aspect/mesh_refinement/isotherms.h new file mode 100644 index 00000000000..9370a49561a --- /dev/null +++ b/include/aspect/mesh_refinement/isotherms.h @@ -0,0 +1,88 @@ +/* + Copyright (C) 2011, 2012 by the authors of the ASPECT code. + + This file is part of ASPECT. + + ASPECT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + ASPECT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with ASPECT; see the file doc/COPYING. If not see + . +*/ +/* $Id: positiontime.h 1433 2012-12-08 08:24:55Z bangerth $ */ + + +#ifndef __aspect__mesh_refinement_isotherms_h +#define __aspect__mesh_refinement_isotherms_h + +#include +#include + +namespace aspect +{ + namespace MeshRefinement + { + + /** + * A class that implements a mesh refinement criterion based on + * isotherms. + * + * @ingroup MeshRefinement + */ + template + class Isotherms : public Interface, + public SimulatorAccess + { + public: + /** + * After cells have been marked for coarsening/refinement, apply + * additional criteria independent of the error estimate. + * + */ + virtual + void + tag_additional_cells () const; + + /** + * Declare the parameters this class takes through input files. + */ + static + void + declare_parameters (ParameterHandler &prm); + + /** + * Read the parameters this class declares from the parameter file. + */ + virtual + void + parse_parameters (ParameterHandler &prm); + + private: + /** + * Declare a variable which indicates if and which compositional field should be excluded from the process. + */ + signed int excludeComposition; + /** + * Declare a variable which indicates how many isotherms the user has declared, and a variable to store all those isotherms + */ + int number_of_isotherms + std::vector > isotherms; + /** + * Declare a variable to store the global minimum refinement level and a variable to store the global maximum refinement level set by the user + */ + unsigned int minimum_refinement_level; + unsigned int maximum_refinement_level; + + }; + } +} + +#endif diff --git a/source/mesh_refinement/isotherms.cc b/source/mesh_refinement/isotherms.cc new file mode 100644 index 00000000000..9fa66726ef5 --- /dev/null +++ b/source/mesh_refinement/isotherms.cc @@ -0,0 +1,343 @@ +/* + Copyright (C) 2011 - 2014 by the authors of the ASPECT code. + + This file is part of ASPECT. + + ASPECT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + ASPECT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with ASPECT; see the file doc/COPYING. If not see + . +*/ + +#include +#include +#include +#include +#include + +namespace aspect +{ + namespace MeshRefinement + { + template + void + Isotherms::tag_additional_cells () const + { + if(this->get_dof_handler().n_dofs() != 0){ + + /// Gather all information on the state of the system /// + LinearAlgebra::BlockVector vec_distributed (this->introspection().index_sets.system_partitioning, + this->get_mpi_communicator()); + + const Quadrature quadrature(this->get_fe().base_element(this->introspection().base_elements.temperature).get_unit_support_points()); + std::vector local_dof_indices (this->get_fe().dofs_per_cell); + FEValues fe_values (this->get_mapping(), + this->get_fe(), + quadrature, + update_quadrature_points | update_values); + std::vector pressure_values(quadrature.size()); + std::vector temperature_values(quadrature.size()); + + /// the values of the compositional fields are stored as blockvectors for each field + /// we have to extract them in this structure + std::vector > prelim_composition_values (this->n_compositional_fields(), + std::vector (quadrature.size())); + std::vector > composition_values (quadrature.size(), + std::vector (this->n_compositional_fields())); + + typename MaterialModel::Interface::MaterialModelInputs in(quadrature.size(), this->n_compositional_fields()); + typename MaterialModel::Interface::MaterialModelOutputs out(quadrature.size(), this->n_compositional_fields()); + + typename DoFHandler::active_cell_iterator + cell = this->get_dof_handler().begin_active(), + endc = this->get_dof_handler().end(); + for (; cell!=endc; ++cell) + if (cell->is_locally_owned()) + { + bool coarsen = false; + bool clear_refine = false; + bool refine = false; + bool clear_coarsen = false; + fe_values.reinit(cell); + fe_values[this->introspection().extractors.pressure].get_function_values (this->get_solution(), + pressure_values); + fe_values[this->introspection().extractors.temperature].get_function_values (this->get_solution(), + temperature_values); + for (unsigned int c=0; cn_compositional_fields(); ++c) + fe_values[this->introspection().extractors.compositional_fields[c]].get_function_values (this->get_solution(), + prelim_composition_values[c]); + + cell->get_dof_indices (local_dof_indices); + in.position = fe_values.get_quadrature_points(); + in.strain_rate.resize(0);// we are not reading the viscosity + for (unsigned int i=0; in_compositional_fields(); ++c) + in.composition[i][c] = prelim_composition_values[c][i]; + } + this->get_material_model().evaluate(in, out); + + // all data has been gethered, now do something with it. + + std::vector > isotherms_i(number_of_isotherms,std::vector(2)); + // isotherms_i[0] is the minimum, and isotherms_i[1] is the maximum cell level. + + // convert max,max-1,max-2 etc and min, min-1,min-2 to numbers in integer + for ( unsigned int it1 = 0; it1 != isotherms_i.size(); ++it1 ) + { + if(isotherms[it1][0].compare(0,3,"max")==0){ + if(isotherms[it1][0].compare(0,4,"max-")==0){ + std::vector tmpNumber = Utilities::split_string_list(isotherms[it1][0],'-'); + isotherms_i[it1][0]=maximum_refinement_level-Utilities::string_to_int(tmpNumber[1]); + }else{ + isotherms_i[it1][0]=maximum_refinement_level; + } + }else if(isotherms[it1][0].compare(0,3,"min")==0){ + if(isotherms[it1][0].compare(0,4,"min+")==0){ + std::vector tmpNumber = Utilities::split_string_list(isotherms[it1][0],'+'); + isotherms_i[it1][0]=minimum_refinement_level+Utilities::string_to_int(tmpNumber[1]); + }else{ + isotherms_i[it1][0]=minimum_refinement_level; + } + }else if(!isotherms[it1][0].empty() && isotherms[it1][0].find_first_not_of("0123456789") == std::string::npos){ + isotherms_i[it1][0]=Utilities::string_to_int(isotherms[it1][0]); + }else{ + + AssertThrow (true, + ExcMessage ("Not able to read input at inputline " + + + Utilities::int_to_string(it1) + + + ": " + + + isotherms[it1][0] + ) + ); + } + + if(isotherms[it1][1].compare(0,3,"max")==0){ + if(isotherms[it1][1].compare(0,4,"max-")==0){ + std::vector tmpNumber = Utilities::split_string_list(isotherms[it1][1],'-'); + isotherms_i[it1][1]=maximum_refinement_level-Utilities::string_to_int(tmpNumber[1]); + }else{ + isotherms_i[it1][1]=maximum_refinement_level; + } + }else if(isotherms[it1][1].compare(0,3,"min")==0){ + if(isotherms[it1][1].compare(0,4,"min+")==0){ + std::vector tmpNumber = Utilities::split_string_list(isotherms[it1][1],'+'); + isotherms_i[it1][1]=minimum_refinement_level-Utilities::string_to_int(tmpNumber[1]); + }else{ + isotherms_i[it1][1]=minimum_refinement_level; + } + }else if(!isotherms[it1][1].empty() && isotherms[it1][1].find_first_not_of("0123456789") == std::string::npos){ + isotherms_i[it1][1]=Utilities::string_to_int(isotherms[it1][1]); + }else{ + AssertThrow (true, + ExcMessage ("Not able to read input at inputline " + + + Utilities::int_to_string(it1) + + + ": " + + + isotherms[it1][0] + ) + ); + } + } + /// We have now converted max,max-1,max-2 etc and min, min-1,min-2 to numbers in integer + + for (unsigned int i=0; i 0 && excludeComposition <= static_cast (this->n_compositional_fields())){ // static cast to prevent compiler warnings. Will only go wrong when there are more compositional fields then a the positive part of an int can handle ;) + // there is a exclude compostion (>0) and exclude composition is smaller or equal to the current composition + if(rint(in.temperature[i]) <= Utilities::string_to_int(isotherms[it1][3]) && rint(in.temperature[i]) >= Utilities::string_to_int(isotherms[it1][2]) && in.composition[it1][excludeComposition]<0.5){ + // the temperature is between the isotherms and the exclude composition is smaller then 0.5 at this location + + // If the current refinement level is smaller or equal to the refinement minimum level, any coarsening flags should be cleared. + if (cell->level() <= isotherms_i[it1][0]){ + clear_coarsen = true; + } + // If the current refinement level is smaller then the minimum level, a refinment flag should be placed, and we don't have to look any further. + if (cell->level() < isotherms_i[it1][0]) + { + refine = true; + break; + } + + // If the current refinement level is larger or equal to the maximum refinement level, any refinement flag should be cleared. + if (cell->level() >= isotherms_i[it1][1]){ + clear_refine = true; + } + // If the current refinement level is larger then the maximum level, a coarsening flag should be placed, and we don't have to look any further. + if (cell->level() > isotherms_i[it1][1]) + { + coarsen = true; + break; + } + + } + }else{ + // there is not a exclude compostion (>0) and/or the exclude composition is larger or equal to the current composition. Now we don't have to check the value of the composition anymore. + if(rint(in.temperature[i]) <= Utilities::string_to_int(isotherms[it1][3]) && rint(in.temperature[i]) >= Utilities::string_to_int(isotherms[it1][2])){ + // the temperature is between the isotherms + // If the current refinement level is smaller or equal to the refinement minimum level, any coarsening flags should be cleared. + if (cell->level() <= isotherms_i[it1][0]){ + clear_coarsen = true; + } + // If the current refinement level is smaller then the minimum level, a refinment flag should be placed, and we don't have to look any further. + if (cell->level() < isotherms_i[it1][0]) + { + refine = true; + break; + } + + // If the current refinement level is larger or equal to the maximum refinement level, any refinement flag should be cleared. + if (cell->level() >= isotherms_i[it1][1]){ + clear_refine = true; + } + // If the current refinement level is larger then the maximum level, a coarsening flag should be placed, and we don't have to look any further. + if (cell->level() > isotherms_i[it1][1]) + { + coarsen = true; + break; + } + + } + } + } + } + + /// Perform the actual placement of the coarsening and refinement flags + if (clear_refine) + cell->clear_refine_flag (); + if (coarsen) + cell->set_coarsen_flag (); + if (clear_coarsen) + cell->clear_coarsen_flag (); + if (refine) + cell->set_refine_flag (); + } + } + } + + template + void + Isotherms:: + declare_parameters (ParameterHandler &prm) + { + prm.enter_subsection("Mesh refinement"); + { + + prm.enter_subsection("Isotherms"); + { + + prm.declare_entry ("Exclude composition", "-1", + Patterns::Double (), + "Number of mininum and maximum areas defined by isotherms are going to be defined." + ); + prm.declare_entry ("List of isotherms", "", + Patterns::List(Patterns::List(Patterns::Anything(),0,100000000,","),0,100000000,";"), + "Number of mininum and maximum areas defined by isotherms are going to be defined." + ); + + } + prm.leave_subsection(); + } + prm.leave_subsection(); + } + + template + void + Isotherms::parse_parameters (ParameterHandler &prm) + { + prm.enter_subsection("Mesh refinement"); + { + minimum_refinement_level = Utilities::string_to_int(prm.get ("Minimum refinement level")); + maximum_refinement_level = Utilities::string_to_int(prm.get("Initial global refinement")) + Utilities::string_to_int(prm.get("Initial adaptive refinement")); + prm.enter_subsection("Isotherms"); + { + excludeComposition = Utilities::string_to_int(prm.get("Exclude composition")); + std::vector isotherms_outer_loop = Utilities::split_string_list(prm.get ("List of isotherms"),';'); + // process the List of isotherms to get all data out of the structure + number_of_isotherms = isotherms_outer_loop.size(); + isotherms.resize(size_element,std::vector(4,"0")); + // loop through all given isotherms + for ( unsigned int it1 = 0; it1 != number_of_isotherms; ++it1 ) + { + std::vector isotherms_inner_loop = Utilities::split_string_list(isotherms_outer_loop[it1]); + // The minimum and maximum refinemnt levels respecively + isotherms[it1][0]=isotherms_inner_loop[0]; + isotherms[it1][1]=isotherms_inner_loop[1]; + // The temperatures for the min and max isotherms respectively + isotherms[it1][2]=isotherms_inner_loop[2]; + isotherms[it1][3]=isotherms_inner_loop[3]; + + } + } + prm.leave_subsection(); + } + prm.leave_subsection(); + } + } +} + +// explicit instantiations +namespace aspect +{ + namespace MeshRefinement + { + ASPECT_REGISTER_MESH_REFINEMENT_CRITERION(Isotherms, + "isotherms", + "A mesh refinement criterion that ensures a " + "maximum and minimum refinement level between" + "two temperatures (isotherms), with the posibility" + " to exclude a composition from this criterion." + "To accomplish this there are two parameters " + "available: 'Exclude composition' and 'List of" + " isotherms'. The first parameter takes the " + "number of the compositional field and excludes " + "it from the min/max refinment level prodedure. " + "The second parameters takes a list of isoterm " + "parameters for one isoterm separated by a ';'." + "Each line of isoterm parameters contains four " + "subparameters. The first subparameter sets " + "the minimun refinement level for this isoterm" + " , the second subparameter sets the maximum " + "refiment level for this isoterm, the third " + "subparameter sets the minimum temperature for " + "this isoterm and the fourth subparameter sets" + " the maximum termperature for the isoterm. " + "The minimum and maximum level can be indicated" + " by the absolute number of the refinement level" + " or by using the key words 'min' or 'max', " + "corrosponding respecively to the set minimum " + "and maximum refinment level. The keywords " + "'min' and 'max' may also be used in combination" + " with addition or substraction, e.g. 'max-1' " + " or 'min+1'. For formating it is usefull to " + "make use of the build in option of ASPECT " + "to split parameters over several line by " + "putting ' \\' at the end of the line." + "\n\n" + "Example input format of List of isotherms:\n" + "set List of isotherms = " + "max,\t max,\t 0,\t 1000; \\ \n\t\t 5,\t max-1,\t" + " 1000,\t 1500; \\ \n\t\t min,\t max-1,\t 1500,\t" + " 2000") + } +} From f2e9ea7d92ffc02f25aa17c3f3089af3f516931d Mon Sep 17 00:00:00 2001 From: MFraters Date: Sat, 11 Apr 2015 11:35:02 +0200 Subject: [PATCH 2/4] astyle of the isoterms plugin --- include/aspect/mesh_refinement/isoterms.h | 80 ----- source/mesh_refinement/isoterms.cc | 343 ---------------------- 2 files changed, 423 deletions(-) delete mode 100644 include/aspect/mesh_refinement/isoterms.h delete mode 100644 source/mesh_refinement/isoterms.cc diff --git a/include/aspect/mesh_refinement/isoterms.h b/include/aspect/mesh_refinement/isoterms.h deleted file mode 100644 index f575213ae3e..00000000000 --- a/include/aspect/mesh_refinement/isoterms.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright (C) 2011, 2012 by the authors of the ASPECT code. - - This file is part of ASPECT. - - ASPECT is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - ASPECT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with ASPECT; see the file doc/COPYING. If not see - . -*/ -/* $Id: positiontime.h 1433 2012-12-08 08:24:55Z bangerth $ */ - - -#ifndef __aspect__mesh_refinement_isoterms_h -#define __aspect__mesh_refinement_isoterms_h - -#include -#include - -namespace aspect -{ - namespace MeshRefinement - { - - /** - * A class that implements a mesh refinement criterion based on - * isoterms. - * - * @ingroup MeshRefinement - */ - template - class Isoterms : public Interface, - public SimulatorAccess - { - public: - /** - * After cells have been marked for coarsening/refinement, apply - * additional criteria independent of the error estimate. - * - */ - virtual - void - tag_additional_cells () const; - - /** - * Declare the parameters this class takes through input files. - */ - static - void - declare_parameters (ParameterHandler &prm); - - /** - * Read the parameters this class declares from the parameter file. - */ - virtual - void - parse_parameters (ParameterHandler &prm); - - private: - signed int i_excludeComposition; - std::vector > isoterms; - std::vector n_isoterms_inner; - unsigned int minimum_refinement_level; - unsigned int maximum_refinement_level; - std::vector n_isoterms_outer; - - }; - } -} - -#endif diff --git a/source/mesh_refinement/isoterms.cc b/source/mesh_refinement/isoterms.cc deleted file mode 100644 index 163275c6fd0..00000000000 --- a/source/mesh_refinement/isoterms.cc +++ /dev/null @@ -1,343 +0,0 @@ -/* - Copyright (C) 2011 - 2014 by the authors of the ASPECT code. - - This file is part of ASPECT. - - ASPECT is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - ASPECT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with ASPECT; see the file doc/COPYING. If not see - . -*/ - -#include -#include -#include -#include -#include - -namespace aspect -{ - namespace MeshRefinement - { - template - void - Isoterms::tag_additional_cells () const - { - if(this->get_dof_handler().n_dofs() != 0){ - - /// Gather all information on the state of the system /// - LinearAlgebra::BlockVector vec_distributed (this->introspection().index_sets.system_partitioning, - this->get_mpi_communicator()); - - const Quadrature quadrature(this->get_fe().base_element(this->introspection().base_elements.temperature).get_unit_support_points()); - std::vector local_dof_indices (this->get_fe().dofs_per_cell); - FEValues fe_values (this->get_mapping(), - this->get_fe(), - quadrature, - update_quadrature_points | update_values); - std::vector pressure_values(quadrature.size()); - std::vector temperature_values(quadrature.size()); - - /// the values of the compositional fields are stored as blockvectors for each field - /// we have to extract them in this structure - std::vector > prelim_composition_values (this->n_compositional_fields(), - std::vector (quadrature.size())); - std::vector > composition_values (quadrature.size(), - std::vector (this->n_compositional_fields())); - - typename MaterialModel::Interface::MaterialModelInputs in(quadrature.size(), this->n_compositional_fields()); - typename MaterialModel::Interface::MaterialModelOutputs out(quadrature.size(), this->n_compositional_fields()); - - typename DoFHandler::active_cell_iterator - cell = this->get_dof_handler().begin_active(), - endc = this->get_dof_handler().end(); - for (; cell!=endc; ++cell) - if (cell->is_locally_owned()) - { - bool coarsen = false; - bool clear_refine = false; - bool refine = false; - bool clear_coarsen = false; - fe_values.reinit(cell); - fe_values[this->introspection().extractors.pressure].get_function_values (this->get_solution(), - pressure_values); - fe_values[this->introspection().extractors.temperature].get_function_values (this->get_solution(), - temperature_values); - for (unsigned int c=0; cn_compositional_fields(); ++c) - fe_values[this->introspection().extractors.compositional_fields[c]].get_function_values (this->get_solution(), - prelim_composition_values[c]); - - cell->get_dof_indices (local_dof_indices); - in.position = fe_values.get_quadrature_points(); - in.strain_rate.resize(0);// we are not reading the viscosity - for (unsigned int i=0; in_compositional_fields(); ++c) - in.composition[i][c] = prelim_composition_values[c][i]; - } - this->get_material_model().evaluate(in, out); - - // all data has been gethered, now do something with it. - - std::vector > isoterms_i(n_isoterms_outer.size(),std::vector(2)); - // isoterms_i[0] is the minimum, and isoterms_i[1] is the maximum cell level. - - // convert max,max-1,max-2 etc and min, min-1,min-2 to numbers in integer - for ( unsigned int it1 = 0; it1 != isoterms_i.size(); ++it1 ) - { - if(isoterms[it1][0].compare(0,3,"max")==0){ - if(isoterms[it1][0].compare(0,4,"max-")==0){ - std::vector tmpNumber = Utilities::split_string_list(isoterms[it1][0],'-'); - isoterms_i[it1][0]=maximum_refinement_level-Utilities::string_to_int(tmpNumber[1]); - }else{ - isoterms_i[it1][0]=maximum_refinement_level; - } - }else if(isoterms[it1][0].compare(0,3,"min")==0){ - if(isoterms[it1][0].compare(0,4,"min+")==0){ - std::vector tmpNumber = Utilities::split_string_list(isoterms[it1][0],'+'); - isoterms_i[it1][0]=minimum_refinement_level+Utilities::string_to_int(tmpNumber[1]); - }else{ - isoterms_i[it1][0]=minimum_refinement_level; - } - }else if(!isoterms[it1][0].empty() && isoterms[it1][0].find_first_not_of("0123456789") == std::string::npos){ - isoterms_i[it1][0]=Utilities::string_to_int(isoterms[it1][0]); - }else{ - - AssertThrow (true, - ExcMessage ("Not able to read input at inputline " - + - Utilities::int_to_string(it1) - + - ": " - + - isoterms[it1][0] - ) - ); - } - - if(isoterms[it1][1].compare(0,3,"max")==0){ - if(isoterms[it1][1].compare(0,4,"max-")==0){ - std::vector tmpNumber = Utilities::split_string_list(isoterms[it1][1],'-'); - isoterms_i[it1][1]=maximum_refinement_level-Utilities::string_to_int(tmpNumber[1]); - }else{ - isoterms_i[it1][1]=maximum_refinement_level; - } - }else if(isoterms[it1][1].compare(0,3,"min")==0){ - if(isoterms[it1][1].compare(0,4,"min+")==0){ - std::vector tmpNumber = Utilities::split_string_list(isoterms[it1][1],'+'); - isoterms_i[it1][1]=minimum_refinement_level-Utilities::string_to_int(tmpNumber[1]); - }else{ - isoterms_i[it1][1]=minimum_refinement_level; - } - }else if(!isoterms[it1][1].empty() && isoterms[it1][1].find_first_not_of("0123456789") == std::string::npos){ - isoterms_i[it1][1]=Utilities::string_to_int(isoterms[it1][1]); - }else{ - AssertThrow (true, - ExcMessage ("Not able to read input at inputline " - + - Utilities::int_to_string(it1) - + - ": " - + - isoterms[it1][0] - ) - ); - } - } - /// We have now converted max,max-1,max-2 etc and min, min-1,min-2 to numbers in integer - - for (unsigned int i=0; i 0 && i_excludeComposition <= static_cast (this->n_compositional_fields())){ // static cast to prevent compiler warnings. Will only go wrong when there are more compositional fields then a the positive part of an int can handle ;) - // there is a exclude compostion (>0) and exclude composition is smaller or equal to the current composition - if(rint(in.temperature[i]) <= Utilities::string_to_int(isoterms[it1][3]) && rint(in.temperature[i]) >= Utilities::string_to_int(isoterms[it1][2]) && in.composition[it1][i_excludeComposition]<0.5){ - // the temperature is between the isoterms and the exclude composition is smaller then 0.5 at this location - - // If the current refinement level is smaller or equal to the refinement minimum level, any coarsening flags should be cleared. - if (cell->level() <= isoterms_i[it1][0]){ - clear_coarsen = true; - } - // If the current refinement level is smaller then the minimum level, a refinment flag should be placed, and we don't have to look any further. - if (cell->level() < isoterms_i[it1][0]) - { - refine = true; - break; - } - - // If the current refinement level is larger or equal to the maximum refinement level, any refinement flag should be cleared. - if (cell->level() >= isoterms_i[it1][1]){ - clear_refine = true; - } - // If the current refinement level is larger then the maximum level, a coarsening flag should be placed, and we don't have to look any further. - if (cell->level() > isoterms_i[it1][1]) - { - coarsen = true; - break; - } - - } - }else{ - // there is not a exclude compostion (>0) and/or the exclude composition is larger or equal to the current composition. Now we don't have to check the value of the composition anymore. - if(rint(in.temperature[i]) <= Utilities::string_to_int(isoterms[it1][3]) && rint(in.temperature[i]) >= Utilities::string_to_int(isoterms[it1][2])){ - // the temperature is between the isoterms - // If the current refinement level is smaller or equal to the refinement minimum level, any coarsening flags should be cleared. - if (cell->level() <= isoterms_i[it1][0]){ - clear_coarsen = true; - } - // If the current refinement level is smaller then the minimum level, a refinment flag should be placed, and we don't have to look any further. - if (cell->level() < isoterms_i[it1][0]) - { - refine = true; - break; - } - - // If the current refinement level is larger or equal to the maximum refinement level, any refinement flag should be cleared. - if (cell->level() >= isoterms_i[it1][1]){ - clear_refine = true; - } - // If the current refinement level is larger then the maximum level, a coarsening flag should be placed, and we don't have to look any further. - if (cell->level() > isoterms_i[it1][1]) - { - coarsen = true; - break; - } - - } - } - } - } - - /// Perform the actual placement of the coarsening and refinement flags - if (clear_refine) - cell->clear_refine_flag (); - if (coarsen) - cell->set_coarsen_flag (); - if (clear_coarsen) - cell->clear_coarsen_flag (); - if (refine) - cell->set_refine_flag (); - } - } - } - - template - void - Isoterms:: - declare_parameters (ParameterHandler &prm) - { - prm.enter_subsection("Mesh refinement"); - { - - prm.enter_subsection("Isoterms"); - { - - prm.declare_entry ("Exclude composition", "-1", - Patterns::Double (), - "Number of mininum and maximum areas defined by isoterms are going to be defined." - ); - prm.declare_entry ("List of isoterms", "", - Patterns::List(Patterns::List(Patterns::Anything(),0,100000000,","),0,100000000,";"), - "Number of mininum and maximum areas defined by isoterms are going to be defined." - ); - - } - prm.leave_subsection(); - } - prm.leave_subsection(); - } - - template - void - Isoterms::parse_parameters (ParameterHandler &prm) - { - prm.enter_subsection("Mesh refinement"); - { - minimum_refinement_level =Utilities::string_to_int(prm.get ("Minimum refinement level")); - maximum_refinement_level = Utilities::string_to_int(prm.get("Initial global refinement")) + Utilities::string_to_int(prm.get("Initial adaptive refinement")); - prm.enter_subsection("Isoterms"); - { - i_excludeComposition = Utilities::string_to_int(prm.get("Exclude composition")); - n_isoterms_outer = Utilities::split_string_list(prm.get ("List of isoterms"),';'); - // process the List of isoterms to get all data out of the structure - int size_element = n_isoterms_outer.size(); - isoterms.resize(size_element,std::vector(4,"0")); - // loop through all given isoterms - for ( unsigned int it1 = 0; it1 != n_isoterms_outer.size(); ++it1 ) - { - n_isoterms_inner = Utilities::split_string_list(n_isoterms_outer[it1]); - // The minimum and maximum refinemnt levels respecively - isoterms[it1][0]=n_isoterms_inner[0]; - isoterms[it1][1]=n_isoterms_inner[1]; - // The temperatures for the min and max isoterms respectively - isoterms[it1][2]=n_isoterms_inner[2]; - isoterms[it1][3]=n_isoterms_inner[3]; - - } - } - prm.leave_subsection(); - } - prm.leave_subsection(); - } - } -} - -// explicit instantiations -namespace aspect -{ - namespace MeshRefinement - { - ASPECT_REGISTER_MESH_REFINEMENT_CRITERION(Isoterms, - "isoterms", - "A mesh refinement criterion that ensures a " - "maximum and minimum refinement level between" - "two temperatures (isoterms), with the posibility" - " to exclude a composition from this criterion." - "To accomplish this there are two parameters " - "available: 'Exclude composition' and 'List of" - " isoterms'. The first parameter takes the " - "number of the compositional field and excludes " - "it from the min/max refinment level prodedure. " - "The second parameters takes a list of isoterm " - "parameters for one isoterm separated by a ';'." - "Each line of isoterm parameters contains four " - "subparameters. The first subparameter sets " - "the minimun refinement level for this isoterm" - " , the second subparameter sets the maximum " - "refiment level for this isoterm, the third " - "subparameter sets the minimum temperature for " - "this isoterm and the fourth subparameter sets" - " the maximum termperature for the isoterm. " - "The minimum and maximum level can be indicated" - " by the absolute number of the refinement level" - " or by using the key words 'min' or 'max', " - "corrosponding respecively to the set minimum " - "and maximum refinment level. The keywords " - "'min' and 'max' may also be used in combination" - " with addition or substraction, e.g. 'max-1' " - " or 'min+1'. For formating it is usefull to " - "make use of the build in option of ASPECT " - "to split parameters over several line by " - "putting ' \\' at the end of the line." - "\n\n" - "Example input format of List of isoterms:\n" - "set List of isoterms = " - "max,\t max,\t 0,\t 1000; \\ \n\t\t 5,\t max-1,\t" - " 1000,\t 1500; \\ \n\t\t min,\t max-1,\t 1500,\t" - " 2000") - } -} From 77476345170094a143fe0f29edd09f9ffab00c94 Mon Sep 17 00:00:00 2001 From: MFraters Date: Sat, 11 Apr 2015 11:45:30 +0200 Subject: [PATCH 3/4] Moved all spaces in the description to the end of the line --- source/mesh_refinement/isotherms.cc | 576 ++++++++++++++-------------- 1 file changed, 288 insertions(+), 288 deletions(-) diff --git a/source/mesh_refinement/isotherms.cc b/source/mesh_refinement/isotherms.cc index 9fa66726ef5..d465ebb92c3 100644 --- a/source/mesh_refinement/isotherms.cc +++ b/source/mesh_refinement/isotherms.cc @@ -26,318 +26,318 @@ namespace aspect { - namespace MeshRefinement - { - template - void - Isotherms::tag_additional_cells () const - { - if(this->get_dof_handler().n_dofs() != 0){ - - /// Gather all information on the state of the system /// - LinearAlgebra::BlockVector vec_distributed (this->introspection().index_sets.system_partitioning, - this->get_mpi_communicator()); - - const Quadrature quadrature(this->get_fe().base_element(this->introspection().base_elements.temperature).get_unit_support_points()); - std::vector local_dof_indices (this->get_fe().dofs_per_cell); - FEValues fe_values (this->get_mapping(), - this->get_fe(), - quadrature, - update_quadrature_points | update_values); - std::vector pressure_values(quadrature.size()); - std::vector temperature_values(quadrature.size()); - - /// the values of the compositional fields are stored as blockvectors for each field - /// we have to extract them in this structure - std::vector > prelim_composition_values (this->n_compositional_fields(), - std::vector (quadrature.size())); - std::vector > composition_values (quadrature.size(), - std::vector (this->n_compositional_fields())); - - typename MaterialModel::Interface::MaterialModelInputs in(quadrature.size(), this->n_compositional_fields()); - typename MaterialModel::Interface::MaterialModelOutputs out(quadrature.size(), this->n_compositional_fields()); - - typename DoFHandler::active_cell_iterator - cell = this->get_dof_handler().begin_active(), - endc = this->get_dof_handler().end(); - for (; cell!=endc; ++cell) - if (cell->is_locally_owned()) - { - bool coarsen = false; - bool clear_refine = false; - bool refine = false; - bool clear_coarsen = false; - fe_values.reinit(cell); - fe_values[this->introspection().extractors.pressure].get_function_values (this->get_solution(), - pressure_values); - fe_values[this->introspection().extractors.temperature].get_function_values (this->get_solution(), - temperature_values); - for (unsigned int c=0; cn_compositional_fields(); ++c) - fe_values[this->introspection().extractors.compositional_fields[c]].get_function_values (this->get_solution(), - prelim_composition_values[c]); - - cell->get_dof_indices (local_dof_indices); - in.position = fe_values.get_quadrature_points(); - in.strain_rate.resize(0);// we are not reading the viscosity - for (unsigned int i=0; in_compositional_fields(); ++c) - in.composition[i][c] = prelim_composition_values[c][i]; - } - this->get_material_model().evaluate(in, out); - - // all data has been gethered, now do something with it. - - std::vector > isotherms_i(number_of_isotherms,std::vector(2)); - // isotherms_i[0] is the minimum, and isotherms_i[1] is the maximum cell level. - - // convert max,max-1,max-2 etc and min, min-1,min-2 to numbers in integer - for ( unsigned int it1 = 0; it1 != isotherms_i.size(); ++it1 ) - { - if(isotherms[it1][0].compare(0,3,"max")==0){ - if(isotherms[it1][0].compare(0,4,"max-")==0){ - std::vector tmpNumber = Utilities::split_string_list(isotherms[it1][0],'-'); - isotherms_i[it1][0]=maximum_refinement_level-Utilities::string_to_int(tmpNumber[1]); - }else{ - isotherms_i[it1][0]=maximum_refinement_level; - } - }else if(isotherms[it1][0].compare(0,3,"min")==0){ - if(isotherms[it1][0].compare(0,4,"min+")==0){ - std::vector tmpNumber = Utilities::split_string_list(isotherms[it1][0],'+'); - isotherms_i[it1][0]=minimum_refinement_level+Utilities::string_to_int(tmpNumber[1]); - }else{ - isotherms_i[it1][0]=minimum_refinement_level; - } - }else if(!isotherms[it1][0].empty() && isotherms[it1][0].find_first_not_of("0123456789") == std::string::npos){ - isotherms_i[it1][0]=Utilities::string_to_int(isotherms[it1][0]); - }else{ - - AssertThrow (true, - ExcMessage ("Not able to read input at inputline " - + - Utilities::int_to_string(it1) - + - ": " - + - isotherms[it1][0] - ) - ); - } - - if(isotherms[it1][1].compare(0,3,"max")==0){ - if(isotherms[it1][1].compare(0,4,"max-")==0){ - std::vector tmpNumber = Utilities::split_string_list(isotherms[it1][1],'-'); - isotherms_i[it1][1]=maximum_refinement_level-Utilities::string_to_int(tmpNumber[1]); - }else{ - isotherms_i[it1][1]=maximum_refinement_level; - } - }else if(isotherms[it1][1].compare(0,3,"min")==0){ - if(isotherms[it1][1].compare(0,4,"min+")==0){ - std::vector tmpNumber = Utilities::split_string_list(isotherms[it1][1],'+'); - isotherms_i[it1][1]=minimum_refinement_level-Utilities::string_to_int(tmpNumber[1]); - }else{ - isotherms_i[it1][1]=minimum_refinement_level; - } - }else if(!isotherms[it1][1].empty() && isotherms[it1][1].find_first_not_of("0123456789") == std::string::npos){ - isotherms_i[it1][1]=Utilities::string_to_int(isotherms[it1][1]); - }else{ - AssertThrow (true, - ExcMessage ("Not able to read input at inputline " - + - Utilities::int_to_string(it1) - + - ": " - + - isotherms[it1][0] - ) - ); - } - } - /// We have now converted max,max-1,max-2 etc and min, min-1,min-2 to numbers in integer - - for (unsigned int i=0; i 0 && excludeComposition <= static_cast (this->n_compositional_fields())){ // static cast to prevent compiler warnings. Will only go wrong when there are more compositional fields then a the positive part of an int can handle ;) - // there is a exclude compostion (>0) and exclude composition is smaller or equal to the current composition - if(rint(in.temperature[i]) <= Utilities::string_to_int(isotherms[it1][3]) && rint(in.temperature[i]) >= Utilities::string_to_int(isotherms[it1][2]) && in.composition[it1][excludeComposition]<0.5){ - // the temperature is between the isotherms and the exclude composition is smaller then 0.5 at this location - - // If the current refinement level is smaller or equal to the refinement minimum level, any coarsening flags should be cleared. - if (cell->level() <= isotherms_i[it1][0]){ - clear_coarsen = true; - } - // If the current refinement level is smaller then the minimum level, a refinment flag should be placed, and we don't have to look any further. - if (cell->level() < isotherms_i[it1][0]) - { - refine = true; - break; - } - - // If the current refinement level is larger or equal to the maximum refinement level, any refinement flag should be cleared. - if (cell->level() >= isotherms_i[it1][1]){ - clear_refine = true; - } - // If the current refinement level is larger then the maximum level, a coarsening flag should be placed, and we don't have to look any further. - if (cell->level() > isotherms_i[it1][1]) - { - coarsen = true; - break; - } - - } - }else{ - // there is not a exclude compostion (>0) and/or the exclude composition is larger or equal to the current composition. Now we don't have to check the value of the composition anymore. - if(rint(in.temperature[i]) <= Utilities::string_to_int(isotherms[it1][3]) && rint(in.temperature[i]) >= Utilities::string_to_int(isotherms[it1][2])){ - // the temperature is between the isotherms - // If the current refinement level is smaller or equal to the refinement minimum level, any coarsening flags should be cleared. - if (cell->level() <= isotherms_i[it1][0]){ - clear_coarsen = true; - } - // If the current refinement level is smaller then the minimum level, a refinment flag should be placed, and we don't have to look any further. - if (cell->level() < isotherms_i[it1][0]) - { - refine = true; - break; +namespace MeshRefinement +{ +template +void +Isotherms::tag_additional_cells () const +{ + if(this->get_dof_handler().n_dofs() != 0) { + + /// Gather all information on the state of the system /// + LinearAlgebra::BlockVector vec_distributed (this->introspection().index_sets.system_partitioning, + this->get_mpi_communicator()); + + const Quadrature quadrature(this->get_fe().base_element(this->introspection().base_elements.temperature).get_unit_support_points()); + std::vector local_dof_indices (this->get_fe().dofs_per_cell); + FEValues fe_values (this->get_mapping(), + this->get_fe(), + quadrature, + update_quadrature_points | update_values); + std::vector pressure_values(quadrature.size()); + std::vector temperature_values(quadrature.size()); + + /// the values of the compositional fields are stored as blockvectors for each field + /// we have to extract them in this structure + std::vector > prelim_composition_values (this->n_compositional_fields(), + std::vector (quadrature.size())); + std::vector > composition_values (quadrature.size(), + std::vector (this->n_compositional_fields())); + + typename MaterialModel::Interface::MaterialModelInputs in(quadrature.size(), this->n_compositional_fields()); + typename MaterialModel::Interface::MaterialModelOutputs out(quadrature.size(), this->n_compositional_fields()); + + typename DoFHandler::active_cell_iterator + cell = this->get_dof_handler().begin_active(), + endc = this->get_dof_handler().end(); + for (; cell!=endc; ++cell) + if (cell->is_locally_owned()) + { + bool coarsen = false; + bool clear_refine = false; + bool refine = false; + bool clear_coarsen = false; + fe_values.reinit(cell); + fe_values[this->introspection().extractors.pressure].get_function_values (this->get_solution(), + pressure_values); + fe_values[this->introspection().extractors.temperature].get_function_values (this->get_solution(), + temperature_values); + for (unsigned int c=0; cn_compositional_fields(); ++c) + fe_values[this->introspection().extractors.compositional_fields[c]].get_function_values (this->get_solution(), + prelim_composition_values[c]); + + cell->get_dof_indices (local_dof_indices); + in.position = fe_values.get_quadrature_points(); + in.strain_rate.resize(0);// we are not reading the viscosity + for (unsigned int i=0; in_compositional_fields(); ++c) + in.composition[i][c] = prelim_composition_values[c][i]; + } + this->get_material_model().evaluate(in, out); + + // all data has been gethered, now do something with it. + + std::vector > isotherms_i(number_of_isotherms,std::vector(2)); + // isotherms_i[0] is the minimum, and isotherms_i[1] is the maximum cell level. + + // convert max,max-1,max-2 etc and min, min-1,min-2 to numbers in integer + for ( unsigned int it1 = 0; it1 != isotherms_i.size(); ++it1 ) + { + if(isotherms[it1][0].compare(0,3,"max")==0) { + if(isotherms[it1][0].compare(0,4,"max-")==0) { + std::vector tmpNumber = Utilities::split_string_list(isotherms[it1][0],'-'); + isotherms_i[it1][0]=maximum_refinement_level-Utilities::string_to_int(tmpNumber[1]); + } else { + isotherms_i[it1][0]=maximum_refinement_level; + } + } else if(isotherms[it1][0].compare(0,3,"min")==0) { + if(isotherms[it1][0].compare(0,4,"min+")==0) { + std::vector tmpNumber = Utilities::split_string_list(isotherms[it1][0],'+'); + isotherms_i[it1][0]=minimum_refinement_level+Utilities::string_to_int(tmpNumber[1]); + } else { + isotherms_i[it1][0]=minimum_refinement_level; + } + } else if(!isotherms[it1][0].empty() && isotherms[it1][0].find_first_not_of("0123456789") == std::string::npos) { + isotherms_i[it1][0]=Utilities::string_to_int(isotherms[it1][0]); + } else { + + AssertThrow (true, + ExcMessage ("Not able to read input at inputline " + + + Utilities::int_to_string(it1) + + + ": " + + + isotherms[it1][0] + ) + ); } - - // If the current refinement level is larger or equal to the maximum refinement level, any refinement flag should be cleared. - if (cell->level() >= isotherms_i[it1][1]){ - clear_refine = true; - } - // If the current refinement level is larger then the maximum level, a coarsening flag should be placed, and we don't have to look any further. - if (cell->level() > isotherms_i[it1][1]) + + if(isotherms[it1][1].compare(0,3,"max")==0) { + if(isotherms[it1][1].compare(0,4,"max-")==0) { + std::vector tmpNumber = Utilities::split_string_list(isotherms[it1][1],'-'); + isotherms_i[it1][1]=maximum_refinement_level-Utilities::string_to_int(tmpNumber[1]); + } else { + isotherms_i[it1][1]=maximum_refinement_level; + } + } else if(isotherms[it1][1].compare(0,3,"min")==0) { + if(isotherms[it1][1].compare(0,4,"min+")==0) { + std::vector tmpNumber = Utilities::split_string_list(isotherms[it1][1],'+'); + isotherms_i[it1][1]=minimum_refinement_level-Utilities::string_to_int(tmpNumber[1]); + } else { + isotherms_i[it1][1]=minimum_refinement_level; + } + } else if(!isotherms[it1][1].empty() && isotherms[it1][1].find_first_not_of("0123456789") == std::string::npos) { + isotherms_i[it1][1]=Utilities::string_to_int(isotherms[it1][1]); + } else { + AssertThrow (true, + ExcMessage ("Not able to read input at inputline " + + + Utilities::int_to_string(it1) + + + ": " + + + isotherms[it1][0] + ) + ); + } + } + /// We have now converted max,max-1,max-2 etc and min, min-1,min-2 to numbers in integer + + for (unsigned int i=0; i 0 && excludeComposition <= static_cast (this->n_compositional_fields())) { // static cast to prevent compiler warnings. Will only go wrong when there are more compositional fields then a the positive part of an int can handle ;) + // there is a exclude compostion (>0) and exclude composition is smaller or equal to the current composition + if(rint(in.temperature[i]) <= Utilities::string_to_int(isotherms[it1][3]) && rint(in.temperature[i]) >= Utilities::string_to_int(isotherms[it1][2]) && in.composition[it1][excludeComposition]<0.5) { + // the temperature is between the isotherms and the exclude composition is smaller then 0.5 at this location + + // If the current refinement level is smaller or equal to the refinement minimum level, any coarsening flags should be cleared. + if (cell->level() <= isotherms_i[it1][0]) { + clear_coarsen = true; + } + // If the current refinement level is smaller then the minimum level, a refinment flag should be placed, and we don't have to look any further. + if (cell->level() < isotherms_i[it1][0]) + { + refine = true; + break; + } + + // If the current refinement level is larger or equal to the maximum refinement level, any refinement flag should be cleared. + if (cell->level() >= isotherms_i[it1][1]) { + clear_refine = true; + } + // If the current refinement level is larger then the maximum level, a coarsening flag should be placed, and we don't have to look any further. + if (cell->level() > isotherms_i[it1][1]) + { + coarsen = true; + break; + } + + } + } else { + // there is not a exclude compostion (>0) and/or the exclude composition is larger or equal to the current composition. Now we don't have to check the value of the composition anymore. + if(rint(in.temperature[i]) <= Utilities::string_to_int(isotherms[it1][3]) && rint(in.temperature[i]) >= Utilities::string_to_int(isotherms[it1][2])) { + // the temperature is between the isotherms + // If the current refinement level is smaller or equal to the refinement minimum level, any coarsening flags should be cleared. + if (cell->level() <= isotherms_i[it1][0]) { + clear_coarsen = true; + } + // If the current refinement level is smaller then the minimum level, a refinment flag should be placed, and we don't have to look any further. + if (cell->level() < isotherms_i[it1][0]) + { + refine = true; + break; + } + + // If the current refinement level is larger or equal to the maximum refinement level, any refinement flag should be cleared. + if (cell->level() >= isotherms_i[it1][1]) { + clear_refine = true; + } + // If the current refinement level is larger then the maximum level, a coarsening flag should be placed, and we don't have to look any further. + if (cell->level() > isotherms_i[it1][1]) + { + coarsen = true; + break; + } + + } + } } - - } - } - } - } - - /// Perform the actual placement of the coarsening and refinement flags - if (clear_refine) - cell->clear_refine_flag (); - if (coarsen) - cell->set_coarsen_flag (); - if (clear_coarsen) - cell->clear_coarsen_flag (); - if (refine) - cell->set_refine_flag (); + } + + /// Perform the actual placement of the coarsening and refinement flags + if (clear_refine) + cell->clear_refine_flag (); + if (coarsen) + cell->set_coarsen_flag (); + if (clear_coarsen) + cell->clear_coarsen_flag (); + if (refine) + cell->set_refine_flag (); } - } } +} - template - void - Isotherms:: - declare_parameters (ParameterHandler &prm) +template +void +Isotherms:: +declare_parameters (ParameterHandler &prm) +{ + prm.enter_subsection("Mesh refinement"); { - prm.enter_subsection("Mesh refinement"); - { prm.enter_subsection("Isotherms"); { - - prm.declare_entry ("Exclude composition", "-1", - Patterns::Double (), - "Number of mininum and maximum areas defined by isotherms are going to be defined." - ); - prm.declare_entry ("List of isotherms", "", - Patterns::List(Patterns::List(Patterns::Anything(),0,100000000,","),0,100000000,";"), - "Number of mininum and maximum areas defined by isotherms are going to be defined." - ); + + prm.declare_entry ("Exclude composition", "-1", + Patterns::Double (), + "Number of mininum and maximum areas defined by isotherms are going to be defined." + ); + prm.declare_entry ("List of isotherms", "", + Patterns::List(Patterns::List(Patterns::Anything(),0,100000000,","),0,100000000,";"), + "Number of mininum and maximum areas defined by isotherms are going to be defined." + ); } prm.leave_subsection(); - } - prm.leave_subsection(); } + prm.leave_subsection(); +} - template - void - Isotherms::parse_parameters (ParameterHandler &prm) +template +void +Isotherms::parse_parameters (ParameterHandler &prm) +{ + prm.enter_subsection("Mesh refinement"); { - prm.enter_subsection("Mesh refinement"); - { - minimum_refinement_level = Utilities::string_to_int(prm.get ("Minimum refinement level")); - maximum_refinement_level = Utilities::string_to_int(prm.get("Initial global refinement")) + Utilities::string_to_int(prm.get("Initial adaptive refinement")); + minimum_refinement_level = Utilities::string_to_int(prm.get ("Minimum refinement level")); + maximum_refinement_level = Utilities::string_to_int(prm.get("Initial global refinement")) + Utilities::string_to_int(prm.get("Initial adaptive refinement")); prm.enter_subsection("Isotherms"); { - excludeComposition = Utilities::string_to_int(prm.get("Exclude composition")); - std::vector isotherms_outer_loop = Utilities::split_string_list(prm.get ("List of isotherms"),';'); - // process the List of isotherms to get all data out of the structure - number_of_isotherms = isotherms_outer_loop.size(); - isotherms.resize(size_element,std::vector(4,"0")); - // loop through all given isotherms - for ( unsigned int it1 = 0; it1 != number_of_isotherms; ++it1 ) - { - std::vector isotherms_inner_loop = Utilities::split_string_list(isotherms_outer_loop[it1]); - // The minimum and maximum refinemnt levels respecively - isotherms[it1][0]=isotherms_inner_loop[0]; - isotherms[it1][1]=isotherms_inner_loop[1]; - // The temperatures for the min and max isotherms respectively - isotherms[it1][2]=isotherms_inner_loop[2]; - isotherms[it1][3]=isotherms_inner_loop[3]; - - } + excludeComposition = Utilities::string_to_int(prm.get("Exclude composition")); + std::vector isotherms_outer_loop = Utilities::split_string_list(prm.get ("List of isotherms"),';'); + // process the List of isotherms to get all data out of the structure + number_of_isotherms = isotherms_outer_loop.size(); + isotherms.resize(size_element,std::vector(4,"0")); + // loop through all given isotherms + for ( unsigned int it1 = 0; it1 != number_of_isotherms; ++it1 ) + { + std::vector isotherms_inner_loop = Utilities::split_string_list(isotherms_outer_loop[it1]); + // The minimum and maximum refinemnt levels respecively + isotherms[it1][0]=isotherms_inner_loop[0]; + isotherms[it1][1]=isotherms_inner_loop[1]; + // The temperatures for the min and max isotherms respectively + isotherms[it1][2]=isotherms_inner_loop[2]; + isotherms[it1][3]=isotherms_inner_loop[3]; + + } } prm.leave_subsection(); - } - prm.leave_subsection(); } - } + prm.leave_subsection(); +} +} } // explicit instantiations namespace aspect { - namespace MeshRefinement - { - ASPECT_REGISTER_MESH_REFINEMENT_CRITERION(Isotherms, - "isotherms", - "A mesh refinement criterion that ensures a " - "maximum and minimum refinement level between" - "two temperatures (isotherms), with the posibility" - " to exclude a composition from this criterion." - "To accomplish this there are two parameters " - "available: 'Exclude composition' and 'List of" - " isotherms'. The first parameter takes the " - "number of the compositional field and excludes " - "it from the min/max refinment level prodedure. " - "The second parameters takes a list of isoterm " - "parameters for one isoterm separated by a ';'." - "Each line of isoterm parameters contains four " - "subparameters. The first subparameter sets " - "the minimun refinement level for this isoterm" - " , the second subparameter sets the maximum " - "refiment level for this isoterm, the third " - "subparameter sets the minimum temperature for " - "this isoterm and the fourth subparameter sets" - " the maximum termperature for the isoterm. " - "The minimum and maximum level can be indicated" - " by the absolute number of the refinement level" - " or by using the key words 'min' or 'max', " - "corrosponding respecively to the set minimum " - "and maximum refinment level. The keywords " - "'min' and 'max' may also be used in combination" - " with addition or substraction, e.g. 'max-1' " - " or 'min+1'. For formating it is usefull to " - "make use of the build in option of ASPECT " - "to split parameters over several line by " - "putting ' \\' at the end of the line." - "\n\n" - "Example input format of List of isotherms:\n" - "set List of isotherms = " - "max,\t max,\t 0,\t 1000; \\ \n\t\t 5,\t max-1,\t" - " 1000,\t 1500; \\ \n\t\t min,\t max-1,\t 1500,\t" - " 2000") - } +namespace MeshRefinement +{ +ASPECT_REGISTER_MESH_REFINEMENT_CRITERION(Isotherms, + "isotherms", + "A mesh refinement criterion that ensures a " + "maximum and minimum refinement level between " + "two temperatures (isotherms), with the posibility " + "to exclude a composition from this criterion. " + "To accomplish this there are two parameters " + "available: 'Exclude composition' and 'List of " + "isotherms'. The first parameter takes the " + "number of the compositional field and excludes " + "it from the min/max refinment level prodedure. " + "The second parameters takes a list of isoterm " + "parameters for one isoterm separated by a ';'. " + "Each line of isoterm parameters contains four " + "subparameters. The first subparameter sets " + "the minimun refinement level for this isoterm, " + "the second subparameter sets the maximum " + "refiment level for this isoterm, the third " + "subparameter sets the minimum temperature for " + "this isoterm and the fourth subparameter sets " + "the maximum termperature for the isoterm. " + "The minimum and maximum level can be indicated " + "by the absolute number of the refinement level " + "or by using the key words 'min' or 'max', " + "corrosponding respecively to the set minimum " + "and maximum refinment level. The keywords " + "'min' and 'max' may also be used in combination " + "with addition or substraction, e.g. 'max-1' " + "or 'min+1'. For formating it is usefull to " + "make use of the build in option of ASPECT " + "to split parameters over several line by " + "putting ' \\' at the end of the line. " + "\n\n" + "Example input format of List of isotherms:\n" + "set List of isotherms = " + "max,\t max,\t 0,\t 1000; \\ \n\t\t 5,\t max-1,\t" + " 1000,\t 1500; \\ \n\t\t min,\t max-1,\t 1500,\t" + " 2000") +} } From 64f4faae55e6493e75d393df7c3d0d79c70458f8 Mon Sep 17 00:00:00 2001 From: MFraters Date: Sat, 11 Apr 2015 12:12:52 +0200 Subject: [PATCH 4/4] Some changes to make it compile again. --- include/aspect/mesh_refinement/isotherms.h | 2 +- source/mesh_refinement/isotherms.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/aspect/mesh_refinement/isotherms.h b/include/aspect/mesh_refinement/isotherms.h index 9370a49561a..ecf4e6b9786 100644 --- a/include/aspect/mesh_refinement/isotherms.h +++ b/include/aspect/mesh_refinement/isotherms.h @@ -73,7 +73,7 @@ namespace aspect /** * Declare a variable which indicates how many isotherms the user has declared, and a variable to store all those isotherms */ - int number_of_isotherms + int number_of_isotherms; std::vector > isotherms; /** * Declare a variable to store the global minimum refinement level and a variable to store the global maximum refinement level set by the user diff --git a/source/mesh_refinement/isotherms.cc b/source/mesh_refinement/isotherms.cc index d465ebb92c3..7cb404d6a1a 100644 --- a/source/mesh_refinement/isotherms.cc +++ b/source/mesh_refinement/isotherms.cc @@ -275,7 +275,7 @@ Isotherms::parse_parameters (ParameterHandler &prm) std::vector isotherms_outer_loop = Utilities::split_string_list(prm.get ("List of isotherms"),';'); // process the List of isotherms to get all data out of the structure number_of_isotherms = isotherms_outer_loop.size(); - isotherms.resize(size_element,std::vector(4,"0")); + isotherms.resize(number_of_isotherms,std::vector(4,"0")); // loop through all given isotherms for ( unsigned int it1 = 0; it1 != number_of_isotherms; ++it1 ) {