void AdaptiveTimeSteppingOptions::check_dup_input_style( const GetPot& input ) const { if( (input.have_variable("unsteady-solver/target_tolerance") && input.have_section("Strategies/AdaptiveTimeStepping/target_tolerance")) || (input.have_variable("unsteady-solver/upper_tolerance") && input.have_section("Strategies/AdaptiveTimeStepping/upper_tolerance")) || (input.have_variable("unsteady-solver/max_growth") && input.have_section("Strategies/AdaptiveTimeStepping/max_growth")) ) libmesh_error_msg("ERROR: Cannot use both old and new style of options for AdaptiveTimeSteppingOptions!"); }
bool BCBuilder::is_new_bc_input_style( const GetPot& input ) { bool new_style = false; if( input.have_section(BoundaryConditionNames::bc_section()) ) new_style = true; return new_style; }
void testSections() { // GetPot stores the '/' at the end of each section name CPPUNIT_ASSERT(input.have_section("Section1/")); CPPUNIT_ASSERT(input.have_section("Section1/SubSection1/")); CPPUNIT_ASSERT(input.have_section("Section2/Subsection2/")); CPPUNIT_ASSERT(input.have_section("Section2/Subsection2/Subsection3/")); CPPUNIT_ASSERT(input.have_section("Section2/Subsection4/")); CPPUNIT_ASSERT(input.have_section("Section3/")); // But we don't need to supply the trailing '/' CPPUNIT_ASSERT(input.have_section("Section1")); CPPUNIT_ASSERT(input.have_section("Section1/SubSection1")); CPPUNIT_ASSERT(input.have_section("Section2/Subsection2/Subsection3")); // No such thing as this section CPPUNIT_ASSERT(!input.have_section("ImNotASection/")); }
void ViscosityBase::check_input_consistency( const GetPot& input, const std::string& material ) const { // We can't have both the materials version and the old versions MaterialsParsing::duplicate_input_test(input, "Materials/"+material+"/Viscosity/value", "Materials/Viscosity/mu" ); // If the material section exists, but not the variable, this is an error if( input.have_section("Materials/"+material+"/Viscosity") && !input.have_variable("Materials/"+material+"/Viscosity/value") ) { libmesh_error_msg("Error: Found section Materials/"+material+"/Viscosity, but not variable value."); } return; }
std::shared_ptr<libMesh::UnstructuredMesh> MeshBuilder::build (const GetPot& input, const libMesh::Parallel::Communicator &comm) { // First check if the user has both old and new versions of mesh input if( input.have_section("mesh-options/") && input.have_section("Mesh/") ) { libmesh_error_msg("Error: Detected illegal simulataneous use of [mesh-options] and [Mesh] in input!"); } // User needs to tell us if we are generating or reading a mesh // We infer this by checking and seeing if the use has a Mesh/Read // or a Mesh/Generation section if( !input.have_variable("mesh-options/mesh_option") && !input.have_section("Mesh/Read/") && !input.have_section("Mesh/Generation/") ) { libmesh_error_msg("ERROR: Must specify either Mesh/Read or Mesh/Generation in input."); } // But you can't have it both ways if( input.have_section("Mesh/Read/") && input.have_section("Mesh/Generation/") ) { libmesh_error_msg("ERROR: Can only specify one of Mesh/Read and Mesh/Generation"); } // Are we generating the mesh or are we reading one in from a file? std::string mesh_build_type = "NULL"; if( input.have_section("Mesh/Read/") ) mesh_build_type = "read"; else if( input.have_section("Mesh/Generation/") ) mesh_build_type = "generate"; this->deprecated_option<std::string>( input, "mesh-options/mesh_option", "Mesh/Read or Mesh/Generation", "DIE!", mesh_build_type); // Make sure the user gave a valid option /*! \todo Can remove last 4 checks once mesh-options/mesh_option support is removed. */ if( mesh_build_type != std::string("generate") && mesh_build_type != std::string("read") && mesh_build_type != std::string("read_mesh_from_file") && mesh_build_type != std::string("create_1D_mesh") && mesh_build_type != std::string("create_2D_mesh") && mesh_build_type != std::string("create_3D_mesh") ) { std::string error = "ERROR: Invalid value of "+mesh_build_type+" for Mesh/type.\n"; error += " Valid values are: generate\n"; error += " read\n"; libmesh_error_msg(error); } // Create UnstructuredMesh object (defaults to dimension 1). libMesh::UnstructuredMesh* mesh; // Were we specifically asked to use a ParallelMesh or SerialMesh? { std::string mesh_class = input("Mesh/class", "default"); this->deprecated_option<std::string>( input, "mesh-options/mesh_class", "Mesh/class", "default", mesh_class); if (mesh_class == "parallel") mesh = new libMesh::ParallelMesh(comm); else if (mesh_class == "serial") mesh = new libMesh::SerialMesh(comm); else if (mesh_class == "default") mesh = new libMesh::Mesh(comm); else { std::string error = "ERROR: Invalid class "+mesh_class+" input for Mesh/class.\n"; error += " Valid choices are: serial, parallel.\n"; libmesh_error_msg(error); } } // Read mesh from file if(mesh_build_type =="read_mesh_from_file" /* This is deprecated */ || mesh_build_type == "read" ) { // Make sure the user set the filename to read if( !input.have_variable("mesh-options/mesh_filename") /* This is deprecated */ && !input.have_variable("Mesh/Read/filename") ) { libmesh_error_msg("ERROR: Must specify Mesh/Read/filename for reading mesh."); } std::string mesh_filename = input("Mesh/Read/filename", "DIE!"); this->deprecated_option<std::string>( input, "mesh-options/mesh_filename", "Mesh/Read/filename", "DIE!", mesh_filename); // According to Roy Stogner, the only read format // that won't properly reset the dimension is gmsh. /*! \todo Need to a check a GMSH meshes */ mesh->read(mesh_filename); // If we have a first order mesh file but we need second order // elements we should fix that. bool all_second_order = input("Mesh/all_second_order", false); if (all_second_order) mesh->all_second_order(); } // Generate the mesh using built-in libMesh functions else if(mesh_build_type=="create_1D_mesh" /* This is deprecated */ || mesh_build_type=="create_2D_mesh" /* This is deprecated */ || mesh_build_type=="create_3D_mesh" /* This is deprecated */ || mesh_build_type=="generate") { this->generate_mesh(mesh_build_type,input,mesh); } else { // Shouldn't have gotten here libmesh_error(); } /* Only do the mesh refinement here if we don't have a restart file. Otherwise, we need to wait until we've read in the restart file. That is done in Simulation::check_for_restart */ if( !input.have_variable("restart-options/restart_file") ) { this->do_mesh_refinement_from_input( input, comm, *mesh ); } return std::shared_ptr<libMesh::UnstructuredMesh>(mesh); }