diff --git a/framework/include/actions/GlobalParamsAction.h b/framework/include/actions/GlobalParamsAction.h index ebac19de136d..6a5a95f4fc8d 100644 --- a/framework/include/actions/GlobalParamsAction.h +++ b/framework/include/actions/GlobalParamsAction.h @@ -50,5 +50,13 @@ class GlobalParamsAction: public Action { return parameters().set >(name); } + + template + inline + std::vector > & setDoubleIndexParam(const std::string &name) + { + return parameters().set > >(name); + } + }; #endif //GLOBALPARAMSACTION_H diff --git a/framework/include/parser/Parser.h b/framework/include/parser/Parser.h index d1529df1af9d..52742c98b90d 100644 --- a/framework/include/parser/Parser.h +++ b/framework/include/parser/Parser.h @@ -137,6 +137,11 @@ class Parser : public ConsoleStreamInterface void setVectorParameter(const std::string & full_name, const std::string & short_name, InputParameters::Parameter >* param, bool in_global, GlobalParamsAction * global_block); + /// Template method for setting any double indexed type parameter read from the input file or command line + template + void setDoubleIndexParameter(const std::string & full_name, const std::string & short_name, + InputParameters::Parameter > >* param, bool in_global, GlobalParamsAction * global_block); + /// Template method for setting any multivalue "scalar" type parameter read from the input file or command line. Examples include "Point" and "RealVectorValue" template void setScalarComponentParameter(const std::string & full_name, const std::string & short_name, diff --git a/framework/include/utils/MooseUtils.h b/framework/include/utils/MooseUtils.h index 481634922eed..4d1b33fc044f 100644 --- a/framework/include/utils/MooseUtils.h +++ b/framework/include/utils/MooseUtils.h @@ -276,6 +276,28 @@ namespace MooseUtils pos = str.find_first_of(delims, std::min(last_pos + min_len, str.size())); } } + + /** + * tokenizeAndConvert splits a string using delimiter and then converts to type T. + * If the conversion fails tokenizeAndConvert returns false, otherwise true. + */ + template + bool + tokenizeAndConvert(const std::string & str, std::vector & tokenized_vector, const std::string & delimiter = " \t\n\v\f\r") + { + std::vector tokens; + MooseUtils::tokenize(str, tokens, 1, delimiter); + tokenized_vector.resize(tokens.size()); + for (unsigned int j = 0; j < tokens.size(); ++j) + { + std::stringstream ss(tokens[j]); + // we have to make sure that the conversion succeeded _and_ that the string + // was fully read to avoid situations like [conversion to Real] 3.0abc to work + if ((ss >> tokenized_vector[j]).fail() || !ss.eof()) + return false; + } + return true; + } } #endif //MOOSEUTILS_H diff --git a/framework/src/parser/Parser.C b/framework/src/parser/Parser.C index a70f8b4b9a63..1ebed91877de 100644 --- a/framework/src/parser/Parser.C +++ b/framework/src/parser/Parser.C @@ -649,6 +649,9 @@ template<> void Parser::setVectorParameter(const std::string & full_name, const std::string & short_name, InputParameters::Parameter > * param, bool in_global, GlobalParamsAction * global_block); +template<> +void Parser::setDoubleIndexParameter(const std::string & full_name, const std::string & short_name, + InputParameters::Parameter > >* param, bool /*in_global*/, GlobalParamsAction * /*global_block*/); // Macros for parameter extraction #define dynamicCastAndExtractScalar(type, param, full_name, short_name, in_global, global_block) \ @@ -675,6 +678,14 @@ void Parser::setVectorParameter(const std::string & full_name, con setVectorParameter(full_name, short_name, vector_p, in_global, global_block); \ } while (0) +#define dynamicCastAndExtractDoubleIndex(type, param, full_name, short_name, in_global, global_block) \ + do \ + { \ + InputParameters::Parameter > > * double_index_p = dynamic_cast > > *>(param); \ + if (double_index_p) \ + setDoubleIndexParameter(full_name, short_name, double_index_p, in_global, global_block); \ + } while (0) + void Parser::extractParams(const std::string & prefix, InputParameters &p) { @@ -832,6 +843,43 @@ Parser::extractParams(const std::string & prefix, InputParameters &p) dynamicCastAndExtractVector(VectorPostprocessorName, it->second, full_name, it->first, in_global, global_params_block); dynamicCastAndExtractVector(OutputName , it->second, full_name, it->first, in_global, global_params_block); dynamicCastAndExtractVector(MaterialPropertyName , it->second, full_name, it->first, in_global, global_params_block); + + /** + * Double indexed types + */ + // built-ins + dynamicCastAndExtractDoubleIndex(Real , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(int , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(long , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(unsigned int , it->second, full_name, it->first, in_global, global_params_block); + // See vector type explanation + #if LIBMESH_DOF_ID_BYTES == 8 + dynamicCastAndExtractDoubleIndex(uint64_t , it->second, full_name, it->first, in_global, global_params_block); + #endif + + dynamicCastAndExtractDoubleIndex(SubdomainID , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(BoundaryID , it->second, full_name, it->first, in_global, global_params_block); + + // Moose String-derived vectors + dynamicCastAndExtractDoubleIndex(/*std::*/string , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(FileName , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(FileNameNoExtension , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(MeshFileName , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(SubdomainName , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(BoundaryName , it->second, full_name, it->first, in_global, global_params_block); + // these are problematic because Coupleable inherently assumes this is a vector. + //dynamicCastAndExtractDoubleIndex(VariableName , it->second, full_name, it->first, in_global, global_params_block); + //dynamicCastAndExtractDoubleIndex(NonlinearVariableName , it->second, full_name, it->first, in_global, global_params_block); + //dynamicCastAndExtractDoubleIndex(AuxVariableName , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(FunctionName , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(UserObjectName , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(IndicatorName , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(MarkerName , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(MultiAppName , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(PostprocessorName , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(VectorPostprocessorName, it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(OutputName , it->second, full_name, it->first, in_global, global_params_block); + dynamicCastAndExtractDoubleIndex(MaterialPropertyName , it->second, full_name, it->first, in_global, global_params_block); } } @@ -929,6 +977,45 @@ void Parser::setVectorParameter(const std::string & full_name, const std::string } } + +template +void Parser::setDoubleIndexParameter(const std::string & full_name, const std::string & short_name, InputParameters::Parameter > >* param, bool in_global, GlobalParamsAction * global_block) +{ + GetPot *gp; + + // See if this variable was passed on the command line + // if it was then we will retrieve the value from the command line instead of the file + if (_app.commandLine() && _app.commandLine()->haveVariable(full_name.c_str())) + gp = _app.commandLine()->getPot(); + else + gp = &_getpot_file; + + // Get the full string assigned to the variable full_name + std::string buffer = gp->get_value_no_default(full_name, ""); + + // split vector at delim ; + // NOTE: the substrings are _not_ of type T yet + std::vector first_tokenized_vector; + MooseUtils::tokenize(buffer, first_tokenized_vector, 1, ";"); + param->set().resize(first_tokenized_vector.size()); + + for (unsigned j = 0; j < first_tokenized_vector.size(); ++j) + if (!MooseUtils::tokenizeAndConvert(first_tokenized_vector[j], param->set()[j])) + mooseError("Reading parameter " << short_name << " failed."); + + if (in_global) + { + global_block->remove(short_name); + global_block->setDoubleIndexParam(short_name).resize(first_tokenized_vector.size()); + for (unsigned j = 0; j < first_tokenized_vector.size(); ++j) + { + global_block->setDoubleIndexParam(short_name)[j].resize(param->get()[j].size()); + for (unsigned int i = 0; i < param->get()[j].size(); ++i) + global_block->setDoubleIndexParam(short_name)[j][i] = param->get()[j][i]; + } + } +} + template void Parser::setScalarComponentParameter(const std::string & full_name, const std::string & short_name, InputParameters::Parameter * param, bool in_global, GlobalParamsAction * global_block) { @@ -1202,6 +1289,8 @@ void Parser::setVectorParameter(const std::string & full_name, con // If we are able to convert this value into a Real, then set a default coupled value if (ss >> real_value && ss.eof()) + // FIXME: the real_value is assigned to defaultCoupledValue overriding the value assigned before. + // Currently there is no functionality to separately assign the correct "real_value[i]" in InputParameters _current_params->defaultCoupledValue(short_name, real_value); else { @@ -1221,3 +1310,58 @@ void Parser::setVectorParameter(const std::string & full_name, con param->set()[i] = var_names[i]; } } + +// Specialization for coupling double index objects. This routine handles default values and auto generated VariableValue vectors +// Problematic because Coupleable assumes that coupled variables come as a vector. This would require changes in Coupleable and probably elsewhere. +/* +template<> +void Parser::setDoubleIndexParameter(const std::string & full_name, const std::string & short_name, InputParameters::Parameter > >* param, bool in_global, GlobalParamsAction * global_block) +{ + GetPot *gp; + + // See if this variable was passed on the command line + // if it was then we will retrieve the value from the command line instead of the file + if (_app.commandLine() && _app.commandLine()->haveVariable(full_name.c_str())) + gp = _app.commandLine()->getPot(); + else + gp = &_getpot_file; + + // Get the full string assigned to the variable full_name + std::string buffer = gp->get_value_no_default(full_name, ""); + + // split vector at delim ; + // NOTE: the substrings are _not_ of type T yet + std::vector first_tokenized_vector; + MooseUtils::tokenize(buffer, first_tokenized_vector, 1, ";"); + + // Check if all entries can be converted to Real -> default case + std::vector > default_reals; + bool success = true; + default_reals.resize(first_tokenized_vector.size()); + for (unsigned j = 0; j < first_tokenized_vector.size(); ++j) + if (!MooseUtils::tokenizeAndConvert(first_tokenized_vector[j], default_reals[j])) + { + success = false; + break; + } + + if (success) + { + // the conversion to Real was successful for all elements. Set default values + // and leave function + for (unsigned j = 0; j < default_reals.size(); ++j) + for (unsigned int i = 0; i < default_reals[j].size(); ++i) + // FIXME: the real_value is assigned to defaultCoupledValue overriding the value assigned before. + // Currently there is no functionality to separately assign the correct "real_value[i]" in InputParameters + _current_params->defaultCoupledValue(short_name, default_reals[j][i]); + return; + } + + // Conversion to Real failed for at least one element so we assume that all elements are + // of type VariableName. If not error out. + param->set().resize(first_tokenized_vector.size()); + for (unsigned j = 0; j < first_tokenized_vector.size(); ++j) + if (!MooseUtils::tokenizeAndConvert(first_tokenized_vector[j], param->set()[j])) + mooseError("Reading parameter " << short_name << " failed. This can occur if VariableName and Reals (defaults) are mixed. Moose does not support this."); +} +*/ diff --git a/test/include/userobjects/ReadDoubleIndex.h b/test/include/userobjects/ReadDoubleIndex.h new file mode 100644 index 000000000000..72ba20094e4c --- /dev/null +++ b/test/include/userobjects/ReadDoubleIndex.h @@ -0,0 +1,67 @@ +/****************************************************************/ +/* DO NOT MODIFY THIS HEADER */ +/* MOOSE - Multiphysics Object Oriented Simulation Environment */ +/* */ +/* (c) 2010 Battelle Energy Alliance, LLC */ +/* ALL RIGHTS RESERVED */ +/* */ +/* Prepared by Battelle Energy Alliance, LLC */ +/* Under Contract No. DE-AC07-05ID14517 */ +/* With the U. S. Department of Energy */ +/* */ +/* See COPYRIGHT for full restrictions */ +/****************************************************************/ + +#ifndef READDOUBLEINDEX_H +#define READDOUBLEINDEX_H + +#include "GeneralUserObject.h" + +class ReadDoubleIndex; + +template<> +InputParameters validParams(); + + +/** + * User Object for testing double index parsing + */ +class ReadDoubleIndex : public GeneralUserObject +{ +public: + ReadDoubleIndex(const InputParameters & params); + + virtual void initialize() {}; + virtual void execute(); + virtual void finalize() {}; + +protected: + const std::vector > & _real_di; + const std::vector > & _uint_di; + const std::vector > & _int_di; + const std::vector > & _long_di; + const std::vector > & _subid_di; + const std::vector > & _bid_di; + + const std::vector > & _str_di; + const std::vector > & _file_di; + const std::vector > & _file_no_di; + + const std::vector > & _mesh_file_di; + const std::vector > & _subdomain_name_di; + const std::vector > & _boundary_name_di; + const std::vector > & _function_name_di; + const std::vector > & _userobject_name_di; + const std::vector > & _indicator_name_di; + + const std::vector > & _marker_name_di; + const std::vector > & _multiapp_name_di; + const std::vector > & _postprocessor_name_di; + const std::vector > & _vector_postprocessor_name_di; + const std::vector > & _output_name_di; + const std::vector > & _material_property_name_di; + +}; + + +#endif /* ReadDoubleIndex_H */ diff --git a/test/src/base/MooseTestApp.C b/test/src/base/MooseTestApp.C index c2ed3a4688ef..5669a9adefd8 100644 --- a/test/src/base/MooseTestApp.C +++ b/test/src/base/MooseTestApp.C @@ -173,6 +173,7 @@ #include "BoundaryUserObject.h" #include "TestBoundaryRestrictableAssert.h" #include "GetMaterialPropertyBoundaryBlockNamesTest.h" +#include "ReadDoubleIndex.h" // Postprocessors #include "TestCopyInitialSolution.h" @@ -454,6 +455,7 @@ MooseTestApp::registerObjects(Factory & factory) registerUserObject(BoundaryUserObject); registerUserObject(TestBoundaryRestrictableAssert); registerUserObject(GetMaterialPropertyBoundaryBlockNamesTest); + registerUserObject(ReadDoubleIndex); registerPostprocessor(InsideValuePPS); registerPostprocessor(TestCopyInitialSolution); diff --git a/test/src/userobjects/ReadDoubleIndex.C b/test/src/userobjects/ReadDoubleIndex.C new file mode 100644 index 000000000000..54de206fd2c9 --- /dev/null +++ b/test/src/userobjects/ReadDoubleIndex.C @@ -0,0 +1,399 @@ +/****************************************************************/ +/* DO NOT MODIFY THIS HEADER */ +/* MOOSE - Multiphysics Object Oriented Simulation Environment */ +/* */ +/* (c) 2010 Battelle Energy Alliance, LLC */ +/* ALL RIGHTS RESERVED */ +/* */ +/* Prepared by Battelle Energy Alliance, LLC */ +/* Under Contract No. DE-AC07-05ID14517 */ +/* With the U. S. Department of Energy */ +/* */ +/* See COPYRIGHT for full restrictions */ +/****************************************************************/ + +#include "ReadDoubleIndex.h" +#include + +template<> +InputParameters validParams() +{ + InputParameters params = validParams(); + params.addRequiredParam > >("real_di", "A double index field of real numbers."); + params.addRequiredParam > >("uint_di", "A double index field of unsigned integers."); + params.addRequiredParam > >("int_di", "A double index field of integers."); + params.addRequiredParam > >("long_di", "A double index field of long integers."); + params.addRequiredParam > >("subid_di", "A double index field of SubdomainID."); + params.addRequiredParam > >("bid_di", "A double index field of SubdomainID."); + params.addRequiredParam > >("str_di", "A double index field of std::string."); + params.addRequiredParam > >("file_di", "A double index field of FileName."); + params.addRequiredParam > >("file_no_di", "A double index field of FileNameNoExtension."); + params.addRequiredParam > >("mesh_file_di", "A double index field of MeshFileName."); + params.addRequiredParam > >("subdomain_name_di", "A double index field of SubdomainName."); + params.addRequiredParam > >("boundary_name_di", "A double index field of BoundaryName."); + params.addRequiredParam > >("function_name_di", "A double index field of FunctionName."); + params.addRequiredParam > >("userobject_name_di", "A double index field of UserObjectName."); + params.addRequiredParam > >("indicator_name_di", "A double index field of IndicatorName."); + params.addRequiredParam > >("marker_name_di", "A double index field of MarkerName."); + params.addRequiredParam > >("multiapp_name_di", "A double index field of MultiAppName."); + params.addRequiredParam > >("postprocessor_name_di", "A double index field of PostprocessorName."); + params.addRequiredParam > >("vector_postprocessor_name_di", "A double index field of VectorPostprocessorName."); + params.addRequiredParam > >("output_name_di", "A double index field of OutputName."); + params.addRequiredParam > >("material_property_name_di", "A double index field of MaterialPropertyName."); + return params; +} + + +ReadDoubleIndex::ReadDoubleIndex(const InputParameters & params) : + GeneralUserObject(params), + _real_di(getParam > >("real_di")), + _uint_di(getParam > >("uint_di")), + _int_di(getParam > >("int_di")), + _long_di(getParam > >("long_di")), + _subid_di(getParam > >("subid_di")), + _bid_di(getParam > >("bid_di")), + _str_di(getParam > >("str_di")), + _file_di(getParam > >("file_di")), + _file_no_di(getParam > >("file_no_di")), + _mesh_file_di(getParam > >("mesh_file_di")), + _subdomain_name_di(getParam > >("subdomain_name_di")), + _boundary_name_di(getParam > >("boundary_name_di")), + _function_name_di(getParam > >("function_name_di")), + _userobject_name_di(getParam > >("userobject_name_di")), + _indicator_name_di(getParam > >("indicator_name_di")), + _marker_name_di(getParam > >("marker_name_di")), + _multiapp_name_di(getParam > >("multiapp_name_di")), + _postprocessor_name_di(getParam > >("postprocessor_name_di")), + _vector_postprocessor_name_di(getParam > >("vector_postprocessor_name_di")), + _output_name_di(getParam > >("output_name_di")), + _material_property_name_di(getParam > >("material_property_name_di")) +{ + std::vector array_length; + array_length.resize(3); + array_length[0] = 1; + array_length[1] = 3; + array_length[2] = 2; + + // check real + if (_real_di.size() != 3) + mooseError("Error reading real_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_real_di[j].size() != array_length[j]) + mooseError("Error reading real_di."); + for (unsigned int i = 0; i < _real_di[j].size(); ++i) + if (!MooseUtils::absoluteFuzzyEqual(_real_di[j][i], (j + 1.0) + 0.1 * (i + 1))) + mooseError("Error reading real_di."); + } + + // check unsigned int + if (_uint_di.size() != 3) + mooseError("Error reading uint_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_uint_di[j].size() != array_length[j]) + mooseError("Error reading uint_di."); + for (unsigned int i = 0; i < _uint_di[j].size(); ++i) + if (_uint_di[j][i] != (j + 1) * 10 + i + 1) + mooseError("Error reading uint_di."); + } + + // check int + if (_int_di.size() != 3) + mooseError("Error reading int_di."); + for (int j = 0; j < 3; ++j) + { + if (_int_di[j].size() != array_length[j]) + mooseError("Error reading int_di."); + for (int i = 0; i < _int_di[j].size(); ++i) + { + int mult = ((j == 1) ? -1 : 1); + if (_int_di[j][i] != mult * ((j + 1) * 10 + i + 1)) + mooseError("Error reading int_di."); + } + } + + // check long + if (_long_di.size() != 3) + mooseError("Error reading long_di."); + for (long j = 0; j < 3; ++j) + { + if (_long_di[j].size() != array_length[j]) + mooseError("Error reading long_di."); + for (long i = 0; i < _long_di[j].size(); ++i) + { + long mult = ((j != 1) ? -1 : 1); + if (_long_di[j][i] != mult * ((j + 1) * 10 + i + 1)) + mooseError("Error reading long_di."); + } + } + + // check SubdomainID + if (_subid_di.size() != 3) + mooseError("Error reading subid_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_subid_di[j].size() != array_length[j]) + mooseError("Error reading subid_di."); + for (unsigned int i = 0; i < _subid_di[j].size(); ++i) + if (_subid_di[j][i] != (j + 2) * 10 + i + 2) + mooseError("Error reading subid_di."); + } + + // check BoundaryID + if (_bid_di.size() != 3) + mooseError("Error reading bid_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_bid_di[j].size() != array_length[j]) + mooseError("Error reading bid_di."); + for (unsigned int i = 0; i < _bid_di[j].size(); ++i) + if (_bid_di[j][i] != (j + 2) * 10 + i + 1) + mooseError("Error reading bid_di."); + } + + // check std::string + if (_str_di.size() != 3) + mooseError("Error reading str_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_str_di[j].size() != array_length[j]) + mooseError("Error reading str_di."); + for (unsigned int i = 0; i < _str_di[j].size(); ++i) + { + std::stringstream ss; + ss << "string" << j << i; + if (_str_di[j][i] != ss.str()) + mooseError("Error reading str_di."); + } + } + + // check FileName + if (_file_di.size() != 3) + mooseError("Error reading file_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_file_di[j].size() != array_length[j]) + mooseError("Error reading file_di."); + for (unsigned int i = 0; i < _file_di[j].size(); ++i) + { + std::stringstream ss; + ss << "file" << j << i; + if (_file_di[j][i] != ss.str()) + mooseError("Error reading file_di."); + } + } + + // check FileNameNoExtension + if (_file_no_di.size() != 3) + mooseError("Error reading file_no_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_file_no_di[j].size() != array_length[j]) + mooseError("Error reading file_no_di."); + for (unsigned int i = 0; i < _file_no_di[j].size(); ++i) + { + std::stringstream ss; + ss << "file_no" << j << i; + if (_file_no_di[j][i] != ss.str()) + mooseError("Error reading file_no_di."); + } + } + + // check MeshFileName + if (_mesh_file_di.size() != 3) + mooseError("Error reading mesh_file_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_mesh_file_di[j].size() != array_length[j]) + mooseError("Error reading mesh_file_di."); + for (unsigned int i = 0; i < _mesh_file_di[j].size(); ++i) + { + std::stringstream ss; + ss << "mesh_file" << j << i; + if (_mesh_file_di[j][i] != ss.str()) + mooseError("Error reading mesh_file_di."); + } + } + + // check SubdomainName + if (_subdomain_name_di.size() != 3) + mooseError("Error reading subdomain_name_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_subdomain_name_di[j].size() != array_length[j]) + mooseError("Error reading subdomain_name_di."); + for (unsigned int i = 0; i < _subdomain_name_di[j].size(); ++i) + { + std::stringstream ss; + ss << "subdomain_name" << j << i; + if (_subdomain_name_di[j][i] != ss.str()) + mooseError("Error reading subdomain_name_di."); + } + } + + // check BoundaryName + if (_boundary_name_di.size() != 3) + mooseError("Error reading boundary_name_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_boundary_name_di[j].size() != array_length[j]) + mooseError("Error reading boundary_name_di."); + for (unsigned int i = 0; i < _boundary_name_di[j].size(); ++i) + { + std::stringstream ss; + ss << "boundary_name" << j << i; + if (_boundary_name_di[j][i] != ss.str()) + mooseError("Error reading boundary_name_di."); + } + } + + // check FunctionName + if (_function_name_di.size() != 3) + mooseError("Error reading function_name_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_function_name_di[j].size() != array_length[j]) + mooseError("Error reading function_name_di."); + for (unsigned int i = 0; i < _function_name_di[j].size(); ++i) + { + std::stringstream ss; + ss << "function_name" << j << i; + if (_function_name_di[j][i] != ss.str()) + mooseError("Error reading function_name_di."); + } + } + + // check UserObjectName + if (_userobject_name_di.size() != 3) + mooseError("Error reading userobject_name_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_userobject_name_di[j].size() != array_length[j]) + mooseError("Error reading userobject_name_di."); + for (unsigned int i = 0; i < _userobject_name_di[j].size(); ++i) + { + std::stringstream ss; + ss << "userobject_name" << j << i; + if (_userobject_name_di[j][i] != ss.str()) + mooseError("Error reading userobject_name_di."); + } + } + + // check IndicatorName + if (_indicator_name_di.size() != 3) + mooseError("Error reading indicator_name_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_indicator_name_di[j].size() != array_length[j]) + mooseError("Error reading indicator_name_di."); + for (unsigned int i = 0; i < _indicator_name_di[j].size(); ++i) + { + std::stringstream ss; + ss << "indicator_name" << j << i; + if (_indicator_name_di[j][i] != ss.str()) + mooseError("Error reading indicator_name_di."); + } + } + + // check MarkerName + if (_marker_name_di.size() != 3) + mooseError("Error reading marker_name_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_marker_name_di[j].size() != array_length[j]) + mooseError("Error reading marker_name_di."); + for (unsigned int i = 0; i < _marker_name_di[j].size(); ++i) + { + std::stringstream ss; + ss << "marker_name" << j << i; + if (_marker_name_di[j][i] != ss.str()) + mooseError("Error reading marker_name_di."); + } + } + + // check MultiAppName + if (_multiapp_name_di.size() != 3) + mooseError("Error reading multiapp_name_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_multiapp_name_di[j].size() != array_length[j]) + mooseError("Error reading multiapp_name_di."); + for (unsigned int i = 0; i < _multiapp_name_di[j].size(); ++i) + { + std::stringstream ss; + ss << "multiapp_name" << j << i; + if (_multiapp_name_di[j][i] != ss.str()) + mooseError("Error reading multiapp_name_di."); + } + } + + // check PostprocessorName + if (_postprocessor_name_di.size() != 3) + mooseError("Error reading postprocessor_name_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_postprocessor_name_di[j].size() != array_length[j]) + mooseError("Error reading postprocessor_name_di."); + for (unsigned int i = 0; i < _postprocessor_name_di[j].size(); ++i) + { + std::stringstream ss; + ss << "postprocessor_name" << j << i; + if (_postprocessor_name_di[j][i] != ss.str()) + mooseError("Error reading postprocessor_name_di."); + } + } + + // check VectorPostprocessorName + if (_vector_postprocessor_name_di.size() != 3) + mooseError("Error reading vector_postprocessor_name_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_vector_postprocessor_name_di[j].size() != array_length[j]) + mooseError("Error reading vector_postprocessor_name_di."); + for (unsigned int i = 0; i < _vector_postprocessor_name_di[j].size(); ++i) + { + std::stringstream ss; + ss << "vector_postprocessor_name" << j << i; + if (_vector_postprocessor_name_di[j][i] != ss.str()) + mooseError("Error reading vector_postprocessor_name_di."); + } + } + + // check OutputName + if (_output_name_di.size() != 3) + mooseError("Error reading output_name_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_output_name_di[j].size() != array_length[j]) + mooseError("Error reading output_name_di."); + for (unsigned int i = 0; i < _output_name_di[j].size(); ++i) + { + std::stringstream ss; + ss << "output_name" << j << i; + if (_output_name_di[j][i] != ss.str()) + mooseError("Error reading output_name_di."); + } + } + + // check MaterialPropertyName + if (_material_property_name_di.size() != 3) + mooseError("Error reading material_property_name_di."); + for (unsigned int j = 0; j < 3; ++j) + { + if (_material_property_name_di[j].size() != array_length[j]) + mooseError("Error reading material_property_name_di."); + for (unsigned int i = 0; i < _material_property_name_di[j].size(); ++i) + { + std::stringstream ss; + ss << "material_property_name" << j << i; + if (_material_property_name_di[j][i] != ss.str()) + mooseError("Error reading material_property_name_di."); + } + } +} + +void +ReadDoubleIndex::execute() +{ +} diff --git a/test/tests/parser/parse_double_index/gold/parse_double_index.e b/test/tests/parser/parse_double_index/gold/parse_double_index.e new file mode 100644 index 000000000000..1dd73a89492a Binary files /dev/null and b/test/tests/parser/parse_double_index/gold/parse_double_index.e differ diff --git a/test/tests/parser/parse_double_index/parse_double_index.i b/test/tests/parser/parse_double_index/parse_double_index.i new file mode 100644 index 000000000000..fe1f79c4b7b5 --- /dev/null +++ b/test/tests/parser/parse_double_index/parse_double_index.i @@ -0,0 +1,79 @@ +[Mesh] + type = GeneratedMesh + dim = 2 + nx = 10 + ny = 10 +[] + +[Variables] + [./u] + [../] +[] + +[Kernels] + [./diff] + type = Diffusion + variable = u + [../] +[] + +[BCs] + [./left] + type = DirichletBC + variable = u + boundary = left + value = 0 + [../] + [./right] + type = DirichletBC + variable = u + boundary = right + value = 1 + [../] +[] + +[UserObjects] + [./double_index] + type = ReadDoubleIndex + real_di = ' 1.1 ; 2.1 2.2 2.3 ; 3.1 3.2' + uint_di = ' 11 ; 21 22 23 ; + 31 32' + int_di = ' 11 ; -21 -22 -23 ; + 31 32' + long_di = ' -11 ; 21 22 23 ; -31 -32' + subid_di = '22 ; 32 33 34 ; 42 43' + bid_di = '21 ; 31 32 33 ; 41 42' + + str_di = 'string00 ; string10 string11 string12 ; string20 string21 ' + file_di = 'file00; file10 file11 file12; file20 file21' + file_no_di = 'file_no00; file_no10 file_no11 file_no12; file_no20 file_no21' + mesh_file_di = 'mesh_file00; mesh_file10 mesh_file11 mesh_file12; mesh_file20 mesh_file21' + subdomain_name_di = 'subdomain_name00; subdomain_name10 subdomain_name11 subdomain_name12; subdomain_name20 subdomain_name21' + boundary_name_di = 'boundary_name00; boundary_name10 boundary_name11 boundary_name12; boundary_name20 boundary_name21' + function_name_di = 'function_name00; function_name10 function_name11 function_name12; function_name20 function_name21' + userobject_name_di = 'userobject_name00; userobject_name10 userobject_name11 userobject_name12; userobject_name20 userobject_name21' + indicator_name_di = 'indicator_name00; indicator_name10 indicator_name11 indicator_name12; indicator_name20 indicator_name21' + marker_name_di = 'marker_name00; marker_name10 marker_name11 marker_name12; marker_name20 marker_name21' + multiapp_name_di = 'multiapp_name00; multiapp_name10 multiapp_name11 multiapp_name12; multiapp_name20 multiapp_name21' + postprocessor_name_di = 'postprocessor_name00; postprocessor_name10 postprocessor_name11 postprocessor_name12; postprocessor_name20 postprocessor_name21' + vector_postprocessor_name_di = 'vector_postprocessor_name00; vector_postprocessor_name10 vector_postprocessor_name11 vector_postprocessor_name12; vector_postprocessor_name20 vector_postprocessor_name21' + output_name_di = 'output_name00; output_name10 output_name11 output_name12; output_name20 output_name21' + material_property_name_di = 'material_property_name00; material_property_name10 material_property_name11 material_property_name12; material_property_name20 material_property_name21' + [../] +[] + +[Executioner] + type = Steady + + # Preconditioned JFNK (default) + solve_type = 'PJFNK' + + + petsc_options_iname = '-pc_type -pc_hypre_type' + petsc_options_value = 'hypre boomeramg' +[] + +[Outputs] + exodus = true + file_base = parse_double_index +[] diff --git a/test/tests/parser/parse_double_index/tests b/test/tests/parser/parse_double_index/tests new file mode 100644 index 000000000000..48e97abdfe0b --- /dev/null +++ b/test/tests/parser/parse_double_index/tests @@ -0,0 +1,7 @@ +[Tests] + [./parse_double_index] + type = 'Exodiff' + input = 'parse_double_index.i' + exodiff = 'parse_double_index.e' + [../] +[]