https://mooseframework.inl.gov
GeochemicalDatabaseValidator.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "nlohmann/json.h"
13 #include "MooseTypes.h"
14 
19 {
20 public:
21  GeochemicalDatabaseValidator(const FileName filename, const nlohmann::json & db);
22 
26  void validate();
27 
28 protected:
34  bool isValueReal(const nlohmann::json & value) const;
35 
41  void checkArrayValues(const nlohmann::json & array, const std::string field) const;
42 
49  void checkArrayValues(const std::string type,
50  const std::string species,
51  const std::string field) const;
52 
58  void checkArraySize(const nlohmann::json & array, const std::string field) const;
59 
66  void
67  checkArraySize(const std::string type, const std::string species, const std::string field) const;
68 
73  void checkHeaderField(const std::string field) const;
74 
79  void checkHeaderArray(const std::string field) const;
80 
86  void checkElements(const std::string element) const;
87 
94  void checkBasisSpecies(const std::string species) const;
95 
102  void checkSecondarySpecies(const std::string species) const;
103 
110  void checkMineralSpecies(const std::string species) const;
111 
118  void checkSorbingMineralSpecies(const std::string species) const;
119 
126  void checkGasSpecies(const std::string species) const;
127 
134  void checkRedoxSpecies(const std::string species) const;
135 
142  void checkOxideSpecies(const std::string species) const;
143 
150  void checkSurfaceSpecies(const std::string species) const;
151 
158  void checkSpeciesValue(const std::string type,
159  const std::string species,
160  const std::string field) const;
161 
168  void checkSpeciesWeightValue(const std::string type,
169  const std::string species,
170  const std::string field) const;
171 
173  const FileName _filename;
175  const nlohmann::json & _root;
177  unsigned int _temperature_size;
178 };
void checkHeaderArray(const std::string field) const
Check arrays in field can be converted to Reals.
void validate()
Validate the thermodynamic database.
GeochemicalDatabaseValidator(const FileName filename, const nlohmann::json &db)
void checkMineralSpecies(const std::string species) const
Check mineral species in the database Each mineral species should have a real number as their molecul...
void checkOxideSpecies(const std::string species) const
Check oxide species in the database Each oxide species should have a real number as their molecular w...
void checkElements(const std::string element) const
Check elements in the database Each elemenent should have a real number as their molecular weights...
const GeochemicalDatabaseReader db("database/moose_testdb.json", true, true, false)
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
void checkSecondarySpecies(const std::string species) const
Check secondary species in the database Each secondary species should have a real number as their mol...
unsigned int _temperature_size
Number of temperature points.
void checkSpeciesWeightValue(const std::string type, const std::string species, const std::string field) const
Check given species stoichiometric weigth values can be converted to a Real.
const FileName _filename
Database filename.
Class for validating MOOSE geochemical database.
void checkSorbingMineralSpecies(const std::string species) const
Check sorbing mineral species in the database Each sorbing mineral species should have a real number ...
void checkSpeciesValue(const std::string type, const std::string species, const std::string field) const
Check given species field value can be converted to a Real.
bool isValueReal(const nlohmann::json &value) const
Check Json::Value can be converted to a Real.
const nlohmann::json & _root
JSON database.
void checkArrayValues(const nlohmann::json &array, const std::string field) const
Check Json::Value array is comprised of Reals.
void checkSurfaceSpecies(const std::string species) const
Check surface species in the database Each surface species should have a real number as their molecul...
void checkGasSpecies(const std::string species) const
Check gas species in the database Each gas species should have a real number as their molecular weigh...
void checkBasisSpecies(const std::string species) const
Check basis species in the database Each basis species should have a real number as their molecular w...
void checkArraySize(const nlohmann::json &array, const std::string field) const
Check Json::Value array is the correct size.
void checkHeaderField(const std::string field) const
Check fields are present in the Header section.
void checkRedoxSpecies(const std::string species) const
Check redox couple species in the database Each redox couple species should have a real number as the...