From 57b193477ee28389fca39479120a8711f0bfdc32 Mon Sep 17 00:00:00 2001 From: adityakpandare Date: Wed, 8 Mar 2023 13:15:33 -0700 Subject: [PATCH] removed unneeded stuff from CommonGrammar --- src/Control/CommonGrammar.hpp | 335 ---------------------------------- 1 file changed, 335 deletions(-) diff --git a/src/Control/CommonGrammar.hpp b/src/Control/CommonGrammar.hpp index b5b7a1b5960..747ae0056f7 100644 --- a/src/Control/CommonGrammar.hpp +++ b/src/Control/CommonGrammar.hpp @@ -53,10 +53,6 @@ namespace grm { //! case). This is true for both inserting variables into the set as well as //! at matching terms of products in parsing requested statistics. static std::set< char, tk::ctr::CaseInsensitiveCharLess > depvars; - //! \brief Parser-lifetime storage for PDF names - //! \details Used to track the names of PDFs registered so that parsing new - //! ones can be required to be unique. - static std::set< std::string > pdfnames; // Common auxiliary functions (reused by multiple grammars) @@ -91,19 +87,6 @@ namespace grm { NOSUCHMULTIMATVAR, //!< Variable not acceptable for multi-material output POSITIVECOMPONENT, //!< Scalar component must be positive NOTALPHA, //!< Variable must be alphanumeric - NOTERMS, //!< Statistic need a variable - ODDSPIKES, //!< Incomplete spikes block - HEIGHTSPIKES, //!< Height-sum of spikes does not add up to unity - NODELTA, //!< No icdelta...end block when initpolicy = jointdelta - NOBETA, //!< No icbeta...end block when initpolicy = jointbeta - NOGAMMA, //!< No icgamma...end block when initpolicy = jointgamma - NOMEAN, //!< No mean when initpolicy = jointcorrgaussian - NOCOV, //!< No cov when initpolicy = jointcorrgaussian - WRONGBETAPDF, //!< Wrong number of parameters for a beta pdf - WRONGGAMMAPDF, //!< Wrong number of parameters for a gamma pdf - WRONGGAUSSIAN, //!< Wrong number of parameters for a Gaussian PDF - WRONGDIRICHLET, //!< Wrong number of parameters for a Dirichlet PDF - NEGATIVEPARAM, //!< Negative parameter given configuring a PDF NONCOMP, //!< No number of components selected LARGECOMP, //!< Component index indexing out of max eq sys ncomp BADRANGE, //!< Incorrect time range configuration @@ -119,20 +102,6 @@ namespace grm { EOSJWLPARAM, //!< Wrong number of JWL EOS parameters NODT, //!< No time-step-size policy selected MULDT, //!< Multiple time-step-size policies selected - NOSAMPLES, //!< PDF need a variable - INVALIDSAMPLESPACE, //!< PDF sample space specification incorrect - MALFORMEDSAMPLE, //!< PDF sample space variable specification incorrect - INVALIDBINSIZE, //!< PDF sample space bin size specification incorrect - INVALIDEXTENT, //!< PDF sample space extent specification incorrect - EXTENTLOWER, //!< PDF sample space extents in non-increasing order - NOBINS, //!< PDF sample space bin size required - ZEROBINSIZE, //!< PDF sample space bin size incorrect - MAXSAMPLES, //!< PDF sample space dimension too large - MAXBINSIZES, //!< PDF sample space bin sizes too many - MAXEXTENTS, //!< PDF sample space extent-pairs too many - BINSIZES, //!< PDF sample space vars unequal to number of bins - PDF, //!< PDF specification syntax error - PDFEXISTS, //!< PDF identifier already defined POINTEXISTS, //!< Point identifier already defined BADPRECISION, //!< Floating point precision specification incorrect BOUNDS, //!< Specified value out of bounds @@ -159,16 +128,6 @@ namespace grm { WRONGMESHMOTION, //!< Error in mesh motion dimensions STEADYALE, //!< ALE + steady state not supported INCOMPLETEUSERFN, //!< Incomplete user-defined function - HYDROTIMESCALES, //!< Missing required hydrotimescales vector - HYDROPRODUCTIONS, //!< Missing required hydroproductions vector - POSITION_DEPVAR, //!< Missing required position model dependent variable - VELOCITY_DEPVAR, //!< Missing required velocity model dependent variable - DISSIPATION_DEPVAR, //!< Missing required dissipation model dependent var - MIXMASSFRACBETA_DEPVAR,//!< Missing required mass fraction model dependent var - POSITION_MISSING, //!< Missing required position model - VELOCITY_MISSING, //!< Missing required velocity model - DISSIPATION_MISSING,//!< Missing required dissipation model - MIXDIR_RHO, //!< MixDirichlet parameter vector rho inconsistent T0REFODD, //!< AMR initref vector size is odd (must be even) T0REFNOOP, //!< AMR t<0 refinement will be no-op DTREFNOOP, //!< AMR t>0 refinement will be no-op @@ -220,12 +179,6 @@ namespace grm { "case (as a request for an instantaneous) quantity?" }, { MsgKey::POSITIVECOMPONENT, "Scalar component must be positive." }, { MsgKey::NOTALPHA, "Variable not alphanumeric." }, - { MsgKey::HEIGHTSPIKES, "The sum of all spike heights given in the " - "spike...end block does not add up to unity. A spike...end block " - "must contain an even number of real numbers, where every odd one is the " - "sample space position of a spike followed by the spike height " - "specifying the relative probability of the spike. Since the spike " - "heights are probabilities relative to unity, they must sum to one." }, { MsgKey::NODEPVAR, "Dependent variable not specified within the block " "preceding this position. This is mandatory for the preceding block. Use " "the keyword 'depvar' to specify the dependent variable." }, @@ -311,83 +264,6 @@ namespace grm { { MsgKey::NOCOEFF, "No coefficients policy has been specified within the " "block preceding this position. This is mandatory for the preceding " "block. Use the keyword 'coeff' to specify an coefficients policy." }, - { MsgKey::NODELTA, "No icdelta...end block with at least a single " - "spike...end block has been specified within the block preceding this " - "position. This is mandatory for the preceding block if the joint delta " - "initpolicy is selected. Pick an initpolicy different than jointdelta " - "(using keyword 'init') or specify at least a single spike...end block " - "(within an icdelta...end block)." }, - { MsgKey::NOBETA, "No beta...end block with at least a single " - "betapdf...end block has been specified within the block preceding this " - "position. This is mandatory for the preceding block if jointbeta " - "initpolicy is selected. Pick an initpolicy different than jointbeta " - "(using keyword 'init') or specify at least a single betapdf...end block " - "(within a icbeta...end block)." }, - { MsgKey::NOGAMMA, "No gamma...end block with at least a single " - "gammapdf...end block has been specified within the block preceding this " - "position. This is mandatory for the preceding block if jointgamma " - "initpolicy is selected. Pick an initpolicy different than jointgamma " - "(using keyword 'init') or specify at least a single gammapdf...end block " - "(within a icgamma...end block)." }, - { MsgKey::NOMEAN, "No means have been specified within icjointgaussian..." - "end block for jointcorrgaussian initialization policy." }, - { MsgKey::NOCOV, "No covariance matrix has been specified within " - "icjointgaussian...end block for jointcorrgaussian initialization " - "policy." }, - { MsgKey::ODDSPIKES, "Incomplete spike...end block has been specified " - "within the block preceding this position. A spike...end block " - "must contain an even number of real numbers, where every odd one is the " - "sample space position of a spike followed by the spike height " - "specifying the relative probability of the spike." }, - { MsgKey::WRONGBETAPDF, "Wrong number of beta distribution parameters. A " - "beta distribution must be configured by exactly four real numbers in a " - "betapdf...end block." }, - { MsgKey::WRONGGAMMAPDF, "Wrong number of gamma distribution parameters. A " - "gamma distribution must be configured by exactly two real numbers in a " - "gammapdf...end block." }, - { MsgKey::WRONGGAUSSIAN, "Wrong number of Gaussian distribution " - "parameters. A Gaussian distribution must be configured by exactly 2 " - "real numbers in a gaussian...end block." }, - { MsgKey::WRONGDIRICHLET, "Wrong number of Dirichlet distribution " - "parameters." }, - { MsgKey::NEGATIVEPARAM, "Negative distribution parameter (e.g., variance, " - "shape, scale) specified configuring a probabililty distribution." }, - { MsgKey::NOTERMS, "Statistic requires at least one variable." }, - { MsgKey::NOSAMPLES, "PDF requires at least one sample space variable." }, - { MsgKey::INVALIDSAMPLESPACE, "PDF sample space specification incorrect. A " - "non-empty list of sample space variables, must be followed by a " - "colon, followed by a non-empty list of bin sizes (reals numbers), e.g., " - "\"(x y : 0.1 0.2)\"" }, - { MsgKey::MALFORMEDSAMPLE, "A PDF sample space variable must be a single " - "upper or lowercase letter optionally followed by an integer. " - "Multiple variables, specifying a multi-dimensional sample space, must " - "be separated by white spaces." }, - { MsgKey::INVALIDBINSIZE, "PDF sample space bin size(s) specification " - "incorrect. A non-empty list of sample space variables, must be followed " - "by a colon, followed by a non-empty list of bin sizes (real numbers), " - "e.g., \"(x y : 0.1 0.2)\"" }, - { MsgKey::INVALIDEXTENT, "PDF sample space extents specification " - "incorrect. The semi-colon following the list of bin sizes, must be " - "followed by a non-empty list of extents (real numbers), e.g., \"(x y : " - "0.1 0.2 ; 0.0 1.0 0.2 0.9)\". The number of real numbers representing " - "the sample space extents must be exactly twice the number of sample " - "space dimensions, i.e., in this 2D example 4 (2 pairs)." }, - { MsgKey::EXTENTLOWER, "PDF sample space extents must be a pair of a " - "smaller and a larger numerical value, in that order." }, - { MsgKey::NOBINS, "Need at least one sample space bin size, followed by a " - "colon, in a PDF specification." }, - { MsgKey::ZEROBINSIZE, "Sample space bin size must be a real number and " - "greater than zero." }, - { MsgKey::MAXSAMPLES, "The maximum number of sample space variables for a " - "joint PDF is 3." }, - { MsgKey::MAXBINSIZES, "The maximum number of bins sizes for a joint PDF " - "is 3."}, - { MsgKey::MAXEXTENTS, "The maximum number of optional sample space extents " - "for a joint PDF is 3 pairs."}, - { MsgKey::BINSIZES, "The number of sample space variables for a PDF must " - "equal the number of bin sizes given." }, - { MsgKey::PDF, "Syntax error while parsing PDF specification." }, - { MsgKey::PDFEXISTS, "PDF already exists. PDF identifiers must be unique."}, { MsgKey::POINTEXISTS, "Point already exists. Point identifiers must be " "unique."}, { MsgKey::BADPRECISION, "Precision specification invalid. It should be a " @@ -464,37 +340,6 @@ namespace grm { "the correct number. For example, if a R->R^3 function is expected the " "number of descrete entries must be divisible by 4: one 'column' for " "the abscissa, and 3 for the ordinate." }, - { MsgKey::HYDROTIMESCALES, "Error in the preceding line or block. " - "Specification of a 'hydrotimescales' vector missing." }, - { MsgKey::HYDROPRODUCTIONS, "Error in the preceding line or block. " - "Specification of a 'hydroproductions' vector missing." }, - { MsgKey::POSITION_DEPVAR, "Error in the preceding line or block. " - "Specification of a dependent variable, configured as a coupled position " - "model, is missing. Specify a dependent variable in an equation block " - "as, e.g., depvar x, then use 'position x' within the block in question, " - "e.g., velocity." }, - { MsgKey::DISSIPATION_DEPVAR, "Error in the preceding line or block. " - "Specification of a dependent variable, configured as a coupled " - "dissipation model, is missing. Specify a dependent variable in an " - "equation block as, e.g., depvar x, then use 'dissipation x' within the " - "block in question, e.g., velocity." }, - { MsgKey::MIXMASSFRACBETA_DEPVAR, "Error in the preceding line or block. " - "Specification of a dependent variable, configured as a coupled " - "mass fraction model, is missing. Specify a dependent variable in an " - "equation block as, e.g., depvar x, then use 'massfraction x' within the " - "block in question, e.g., velocity." }, - { MsgKey::VELOCITY_DEPVAR, "Error in the preceding line or block. " - "Specification of a dependent variable, configured as a coupled velocity " - "model, is missing. Specify a dependent variable in an equation block " - "as, e.g., depvar u, then use 'velocity u' within the block in question, " - "e.g., position." }, - { MsgKey::POSITION_MISSING, "Specification for a position model missing." }, - { MsgKey::VELOCITY_MISSING, "Specification for a velocity model missing." }, - { MsgKey::DISSIPATION_MISSING, - "Specification for a dissipation model missing." }, - { MsgKey::MIXDIR_RHO, - "The MixDirichlet SDE parameter vector rho is inconsistent. Its size " - "must be ncomp-1 and must be listed in non-decreasing order." }, { MsgKey::T0REFODD, "Error in the preceding line or block. " "The number of edge-nodes, marking edges as pairs of nodes, used for " "explicit tagging of edges for initial mesh refineoment is odd (it must " @@ -1233,181 +1078,6 @@ namespace grm { static void apply( const Input&, Stack& ) {} }; - //! Rule used to trigger action - template< class eq, class param, class... xparam > - struct check_spikes : pegtl::success {}; - //! Check if the spikes parameter vector specifications are correct - //! \details Spikes are used to specify sample-space locations and relative - //! probability heights for a joint-delta PDF. - template< class eq, class param, class... xparam > - struct action< check_spikes< eq, param, xparam... > > { - template< typename Input, typename Stack > - static void apply( const Input& in, Stack& stack ) { - const auto& spike = - stack.template get< tag::param, eq, param, xparam... >().back().back(); - // Error out if the number of spikes-vector is odd - if (spike.size() % 2) - Message< Stack, ERROR, MsgKey::ODDSPIKES >( stack, in ); - // Error out if the sum of spike heights does not add up to unity, but - // only if the spike block is not empty (an empty spike..end block - // is okay and is used to specify no delta spikes for a dependent - // variable). - if (!spike.empty()) { - tk::real sum = 0.0; - for (std::size_t i=1; i std::numeric_limits< tk::real >::epsilon()) - Message< Stack, ERROR, MsgKey::HEIGHTSPIKES >( stack, in ); - } - } - }; - - //! Rule used to trigger action - template< class eq, class param, class... xparam > - struct check_betapdfs : pegtl::success {}; - //! Check if the betapdf parameter vector specifications are correct - //! \details Betapdf vectors are used to configure univariate beta - //! distributions. - template< class eq, class param, class... xparam > - struct action< check_betapdfs< eq, param, xparam... > > { - template< typename Input, typename Stack > - static void apply( const Input& in, Stack& stack ) { - const auto& betapdf = - stack.template get< tag::param, eq, param, xparam... >().back().back(); - // Error out if the number parameters is not four - if (betapdf.size() != 4) - Message< Stack, ERROR, MsgKey::WRONGBETAPDF >( stack, in ); - } - }; - - //! Rule used to trigger action - template< class eq, class param, class... xparam > - struct check_gammapdfs : pegtl::success {}; - //! Check if the gammapdf parameter vector specifications are correct - //! \details gammapdf vectors are used to configure univariate gamma - //! distributions. - template< class eq, class param, class... xparam > - struct action< check_gammapdfs< eq, param, xparam... > > { - template< typename Input, typename Stack > - static void apply( const Input& in, Stack& stack ) { - const auto& gamma = - stack.template get< tag::param, eq, param, xparam... >().back().back(); - // Error out if the number parameters is not two - if (gamma.size() != 2) - Message< Stack, ERROR, MsgKey::WRONGGAMMAPDF >( stack, in ); - // Error out if the specified shape or scale parameter negative - if (gamma[0] < 0.0 || gamma[1] < 0.0) - Message< Stack, ERROR, MsgKey::NEGATIVEPARAM >( stack, in ); - } - }; - - //! Rule used to trigger action - template< class eq, class param, class... xparam > - struct check_dirichletpdf : pegtl::success {}; - //! Check if the dirichletpdf parameter vector specifications are correct - //! \details dirichletpdf vectors are used to configure multivariate - //! Dirichlet distributions. - template< class eq, class param, class... xparam > - struct action< check_dirichletpdf< eq, param, xparam... > > { - template< typename Input, typename Stack > - static void apply( const Input& in, Stack& stack ) { - const auto& dir = - stack.template get< tag::param, eq, param, xparam... >().back(); - // get recently configured eq block number of scalar components - auto ncomp = - stack.template get< tag::component >().template get< eq >().back(); - // Error out if the number parameters does not equal ncomp - if (dir.size() != ncomp-2) - Message< Stack, ERROR, MsgKey::WRONGDIRICHLET >( stack, in ); - // Error out if the specified shape or scale parameter negative - for (auto a : dir) - if (a < 0.0) - Message< Stack, ERROR, MsgKey::NEGATIVEPARAM >( stack, in ); - } - }; - - //! Rule used to trigger action - template< class eq, class param, class... xparam > - struct check_gaussians : pegtl::success {}; - //! Check if the Gaussian PDF parameter vector specifications are correct - //! \details Gaussian vectors are used to configure univariate Gaussian - //! distributions. - template< class eq, class param, class... xparam > - struct action< check_gaussians< eq, param, xparam... > > { - template< typename Input, typename Stack > - static void apply( const Input& in, Stack& stack ) { - const auto& gaussian = - stack.template get< tag::param, eq, param, xparam... >().back().back(); - // Error out if the number parameters is not two - if (gaussian.size() != 2) - Message< Stack, ERROR, MsgKey::WRONGGAUSSIAN >( stack, in ); - // Error out if the specified variance is negative - if (gaussian.back() < 0.0) - Message< Stack, ERROR, MsgKey::NEGATIVEPARAM >( stack, in ); - } - }; - - //! Rule used to trigger action - struct check_expectation : pegtl::success {}; - //! Check if there is at least one variable in expectation - template<> - struct action< check_expectation > { - template< typename Input, typename Stack > - static void apply( const Input& in, Stack& stack ) { - if (stack.template get< tag::stat >().back().empty()) - Message< Stack, ERROR, MsgKey::NOTERMS >( stack, in ); - } - }; - - //! Rule used to trigger action - struct check_binsizes : pegtl::success {}; - //! Check if the number of binsizes equal the PDF sample space variables - template<> - struct action< check_binsizes > { - template< typename Input, typename Stack > - static void apply( const Input& in, Stack& stack ) { - if (stack.template get< tag::pdf >().back().size() != - stack.template get< tag::discr, tag::binsize >().back().size()) - Message< Stack, ERROR, MsgKey::BINSIZES >( stack, in ); - } - }; - - //! Rule used to trigger action - struct check_extents : pegtl::success {}; - //! Check if the number of extents equal 2 * the PDF sample space variables - template<> - struct action< check_extents > { - template< typename Input, typename Stack > - static void apply( const Input& in, Stack& stack ) { - // Use a shorthand to extents vector - const auto& e = stack.template get< tag::discr, tag::extent >().back(); - // Check if the number of extents are correct - if (!e.empty() && - e.size() != - stack.template get< tag::discr, tag::binsize >().back().size()*2) - Message< Stack, ERROR, MsgKey::INVALIDEXTENT >( stack, in ); - // Check if the lower extents are indeed lower than the higher extents - if (e.size() > 1 && e[0] > e[1]) - Message< Stack, ERROR, MsgKey::EXTENTLOWER >( stack, in ); - if (e.size() > 3 && e[2] > e[3]) - Message< Stack, ERROR, MsgKey::EXTENTLOWER >( stack, in ); - if (e.size() > 5 && e[4] > e[5]) - Message< Stack, ERROR, MsgKey::EXTENTLOWER >( stack, in ); - } - }; - - //! Rule used to trigger action - struct check_samples : pegtl::success {}; - //! Check if there is at least one sample space variable in PDF - template<> - struct action< check_samples > { - template< typename Input, typename Stack > - static void apply( const Input& in, Stack& stack ) { - if (stack.template get< tag::pdf >().back().empty()) - Message< Stack, ERROR, MsgKey::NOSAMPLES >( stack, in ); - } - }; - //! Rule used to trigger action struct save_field : pegtl::success {}; //! Save field ID to parser's state so push_term can pick it up @@ -1819,11 +1489,6 @@ namespace grm { store_back_option< use, option, tag::param, p, tags... >, pegtl::alpha > {}; - //! Match and set a PDF option - template< class keyword, class store > - struct pdf_option : - process< keyword, store, pegtl::alpha > {}; - //! \brief Ensure that a grammar only uses keywords from a pool of //! pre-defined keywords //! \details In grammar definitions, every keyword should be wrapped around