diff --git a/Makefile b/Makefile index 3a792393..4c6713fb 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,7 @@ RDG := no RICHARDS := no STOCHASTIC_TOOLS := no TENSOR_MECHANICS := no +THERMAL_HYDRAULICS := no XFEM := no include $(MOOSE_DIR)/modules/modules.mk diff --git a/doc/content/hit/step_by_step/fluid.i b/doc/content/hit/step_by_step/fluid.i index 1599dffb..bc3a2426 100644 --- a/doc/content/hit/step_by_step/fluid.i +++ b/doc/content/hit/step_by_step/fluid.i @@ -14,9 +14,8 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = 'T' - diffusivity_coefficient = kappa initial_condition = 0 [] [] diff --git a/doc/content/shell_tube_hx.md b/doc/content/shell_tube_hx.md index 913d1207..e1bf449d 100644 --- a/doc/content/shell_tube_hx.md +++ b/doc/content/shell_tube_hx.md @@ -234,7 +234,7 @@ Both `inner.i` and `outer.i` are the same: ``` Note that this is a different type to the step-by-step example where a -`FoamFixedGradientBC` is used. +`FoamDiffusionFluxBC` is used. ## Imposing the fluid heat flux on the solid diff --git a/doc/content/step_by_step.md b/doc/content/step_by_step.md index 518e9af5..a3c09868 100644 --- a/doc/content/step_by_step.md +++ b/doc/content/step_by_step.md @@ -136,19 +136,16 @@ and so can be transferred between MOOSE apps. Hippo also implements the `FoamBC` system that allows you to impose boundary conditions on OpenFOAM from the Hippo input file. In this case, we wish to impose a heat flux BC -on the temperature field. This requires the `FoamFixedGradientBC`, which mirrors OpenFOAM's -`fixedGradient` BC type. As in this case, we provide a heat flux, we must also provide the -thermal conductivity, which is specified as the `diffusivity_coefficient`. -`kappa` is the name of the thermal conductivity variable in OpenFOAM. +on the temperature field, which can be done using `FoamDiffusionFluxBC`. A diffusivity can be specified, +although the default is the thermal conductivity `kappa`, which is what we require here. ```toml # fluid.i [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = T - diffusivity_coefficient = kappa [] [] ``` diff --git a/include/actions/AddFoamBCAction.h b/include/actions/AddFoamBCAction.h index cc90072b..84853b3d 100644 --- a/include/actions/AddFoamBCAction.h +++ b/include/actions/AddFoamBCAction.h @@ -1,7 +1,9 @@ #pragma once #include "InputParameters.h" -#include "MooseObjectAction.h" +#include "FoamProblem.h" + +#include class AddFoamBCAction : public MooseObjectAction { @@ -15,4 +17,7 @@ class AddFoamBCAction : public MooseObjectAction protected: // Create AuxVariable associated with new-style BCs void createAuxVariable(); + + // Create Receiver for Postprocessor-based BCs + void createReceiver(FoamProblem & problem); }; diff --git a/include/bcs/FoamBCBase.h b/include/bcs/FoamBCBase.h index 11b865ee..67cfaa5b 100644 --- a/include/bcs/FoamBCBase.h +++ b/include/bcs/FoamBCBase.h @@ -7,6 +7,9 @@ #include #include #include +#include "VariadicTable.h" + +typedef std::tuple BCInfoTableRow; class FoamBCBase : public MooseObject, public Coupleable { @@ -26,7 +29,10 @@ class FoamBCBase : public MooseObject, public Coupleable // returns the name of the foam boundaries the BC applies to std::vector boundary() const { return _boundary; }; - virtual void initialSetup(); + virtual void initialSetup() = 0; + + // Add information about BC to table + virtual BCInfoTableRow getInfoRow() const = 0; protected: // OpenFOAM variable which this BC is to be imposed on diff --git a/include/bcs/FoamDiffusionFluxBC.h b/include/bcs/FoamDiffusionFluxBC.h new file mode 100644 index 00000000..d26f7e19 --- /dev/null +++ b/include/bcs/FoamDiffusionFluxBC.h @@ -0,0 +1,17 @@ +#pragma once + +#include "FoamVariableBCBase.h" + +class FoamDiffusionFluxBC : public FoamVariableBCBase +{ +public: + static InputParameters validParams(); + explicit FoamDiffusionFluxBC(const InputParameters & params); + + // Impose boundary conditions (to be called from FoamProblem class) + virtual void imposeBoundaryCondition() override; + +protected: + // diffusivity name for flux condition + const std::string _diffusivity; +}; diff --git a/include/bcs/FoamDiffusionFluxPostprocessorBC.h b/include/bcs/FoamDiffusionFluxPostprocessorBC.h new file mode 100644 index 00000000..1a6d7d9b --- /dev/null +++ b/include/bcs/FoamDiffusionFluxPostprocessorBC.h @@ -0,0 +1,19 @@ +#pragma once + +#include "FoamPostprocessorBCBase.h" +#include "InputParameters.h" + +class FoamDiffusionFluxPostprocessorBC : public FoamPostprocessorBCBase +{ +public: + static InputParameters validParams(); + + FoamDiffusionFluxPostprocessorBC(const InputParameters & params); + + // impose boundary condition + virtual void imposeBoundaryCondition() override; + +protected: + // name of diffusivity coefficient used to divide flux + std::string _diffusivity; +}; diff --git a/include/bcs/FoamFixedGradientBC.h b/include/bcs/FoamFixedGradientBC.h index 97041d43..c4c3e5f8 100644 --- a/include/bcs/FoamFixedGradientBC.h +++ b/include/bcs/FoamFixedGradientBC.h @@ -1,9 +1,9 @@ #pragma once -#include "FoamBCBase.h" +#include "FoamVariableBCBase.h" #include "InputParameters.h" -class FoamFixedGradientBC : public FoamBCBase +class FoamFixedGradientBC : public FoamVariableBCBase { public: // Validate input file parameters @@ -14,8 +14,4 @@ class FoamFixedGradientBC : public FoamBCBase // Impose boundary conditions (to be called from FoamProblem class) virtual void imposeBoundaryCondition() override; - -protected: - // name of diffusivity coefficient used to divide flux - std::string _diffusivity_coefficient; }; diff --git a/include/bcs/FoamFixedGradientPostprocessorBC.h b/include/bcs/FoamFixedGradientPostprocessorBC.h new file mode 100644 index 00000000..5eb7adf6 --- /dev/null +++ b/include/bcs/FoamFixedGradientPostprocessorBC.h @@ -0,0 +1,15 @@ +#pragma once + +#include "FoamPostprocessorBCBase.h" +#include "InputParameters.h" + +class FoamFixedGradientPostprocessorBC : public FoamPostprocessorBCBase +{ +public: + static InputParameters validParams(); + + FoamFixedGradientPostprocessorBC(const InputParameters & params); + + // impose boundary condition + virtual void imposeBoundaryCondition() override; +}; diff --git a/include/bcs/FoamFixedValueBC.h b/include/bcs/FoamFixedValueBC.h index 70a9f865..00932728 100644 --- a/include/bcs/FoamFixedValueBC.h +++ b/include/bcs/FoamFixedValueBC.h @@ -1,9 +1,9 @@ #pragma once -#include "FoamBCBase.h" +#include "FoamVariableBCBase.h" #include "InputParameters.h" -class FoamFixedValueBC : public FoamBCBase +class FoamFixedValueBC : public FoamVariableBCBase { public: // Validate input file parameters diff --git a/include/bcs/FoamFixedValuePostprocessorBC.h b/include/bcs/FoamFixedValuePostprocessorBC.h new file mode 100644 index 00000000..57010a45 --- /dev/null +++ b/include/bcs/FoamFixedValuePostprocessorBC.h @@ -0,0 +1,14 @@ +#pragma once + +#include "FoamPostprocessorBCBase.h" + +class FoamFixedValuePostprocessorBC : public FoamPostprocessorBCBase +{ +public: + static InputParameters validParams(); + + FoamFixedValuePostprocessorBC(const InputParameters & params); + + // Impose boundary conditions (to be called from FoamProblem class) + virtual void imposeBoundaryCondition() override; +}; diff --git a/include/bcs/FoamMassFlowRateInletBC.h b/include/bcs/FoamMassFlowRateInletBC.h new file mode 100644 index 00000000..741b2b6e --- /dev/null +++ b/include/bcs/FoamMassFlowRateInletBC.h @@ -0,0 +1,17 @@ +#include "FoamPostprocessorBCBase.h" +#include "InputParameters.h" +#include "MooseTypes.h" +#include "PostprocessorInterface.h" + +class FoamMassFlowRateInletBC : public FoamPostprocessorBCBase +{ +public: + static InputParameters validParams(); + + FoamMassFlowRateInletBC(const InputParameters & params); + + virtual void imposeBoundaryCondition() override; + +protected: + const Real _scale_factor; +}; diff --git a/include/bcs/FoamPostprocessorBCBase.h b/include/bcs/FoamPostprocessorBCBase.h new file mode 100644 index 00000000..7d14362f --- /dev/null +++ b/include/bcs/FoamPostprocessorBCBase.h @@ -0,0 +1,27 @@ +#pragma once + +#include "FoamBCBase.h" +#include "InputParameters.h" +#include "MooseTypes.h" +#include "PostprocessorInterface.h" + +class FoamPostprocessorBCBase : public FoamBCBase, public PostprocessorInterface +{ +public: + static InputParameters validParams(); + + explicit FoamPostprocessorBCBase(const InputParameters & params); + + // returns the moose Postprocessor imposed on OpenFOAM + VariableName moosePostprocessor() const { return _pp_name; } + + virtual void initialSetup() override {}; + + virtual BCInfoTableRow getInfoRow() const override; + +protected: + const PostprocessorName _pp_name; + + // Reference to Moose PostprocessorValue used to impose BC + const PostprocessorValue & _pp_value; +}; diff --git a/include/bcs/FoamVariableBCBase.h b/include/bcs/FoamVariableBCBase.h new file mode 100644 index 00000000..ac68f96a --- /dev/null +++ b/include/bcs/FoamVariableBCBase.h @@ -0,0 +1,30 @@ +#pragma once + +#include "FoamBCBase.h" +#include "InputParameters.h" +#include + +class FoamVariableBCBase : public FoamBCBase +{ +public: + static InputParameters validParams(); + + explicit FoamVariableBCBase(const InputParameters & params); + + // returns the moose AuxVariable imposed on OpenFOAM + VariableName mooseVariable() const { return _moose_var->get().name(); } + + virtual void initialSetup() override; + + virtual BCInfoTableRow getInfoRow() const override; + +protected: + // Get the value of the MOOSE variable at an element + Real variableValueAtElement(const libMesh::Elem & elem) const; + + // Get the data vector of the MOOSE field on a subdomain + std::vector getMooseVariableArray(int subdomainId) const; + + // Pointer to Moose variable used to impose BC + std::optional> _moose_var; +}; diff --git a/include/mesh/FoamMesh.h b/include/mesh/FoamMesh.h index 3643248d..b4cf892c 100644 --- a/include/mesh/FoamMesh.h +++ b/include/mesh/FoamMesh.h @@ -63,12 +63,19 @@ class FoamMesh : public MooseMesh return _foam_mesh.foundObject(name); } + // Returns the patch array for field and subdomain + template + Foam::fvPatchField & getBCField(SubdomainID subdomain, Foam::word const & field) + { + return const_cast &>( + _foam_mesh.boundary()[subdomain].lookupPatchField(field)); + } + // Returns the gradient BC array for field and subdomain template Foam::Field & getGradientBCField(SubdomainID subdomain, Foam::word const & field) { - auto & var = const_cast &>( - _foam_mesh.boundary()[subdomain].lookupPatchField(field)); + auto & var = getBCField(subdomain, field); return Foam::refCast>(var).gradient(); } diff --git a/include/util/hippoUtils.h b/include/util/hippoUtils.h index de43b41d..d684bab6 100644 --- a/include/util/hippoUtils.h +++ b/include/util/hippoUtils.h @@ -13,5 +13,19 @@ copyParamFromParam(InputParameters & dst, const InputParameters & src, const std if (src.isParamValid(name_in)) dst.set(name_in) = src.get(name_in); } + +template +inline std::string +listFromVector(std::vector vec, StrType sep = ", ") +{ + if (vec.size() == 0) + return std::string(); + else if (vec.size() == 1) + return vec.at(0); + + std::string str{vec[0]}; + auto binary_op = [&](const std::string & acc, const std::string & it) { return acc + sep + it; }; + return std::accumulate(vec.begin() + 1, vec.end(), str, binary_op); +} } } diff --git a/src/actions/AddFoamBCAction.C b/src/actions/AddFoamBCAction.C index f2ffce49..f56ee815 100644 --- a/src/actions/AddFoamBCAction.C +++ b/src/actions/AddFoamBCAction.C @@ -7,6 +7,17 @@ registerMooseAction("hippoApp", AddFoamBCAction, "add_foam_bc"); +namespace +{ +inline bool +findParamKey(const InputParameters & params, const std::string & key) +{ + return std::find_if(params.begin(), + params.end(), + [&](const auto & param) { return param.first == key; }) != params.end(); +} +} + InputParameters AddFoamBCAction::validParams() { @@ -27,9 +38,14 @@ AddFoamBCAction::act() mooseError("FoamBCs system can only be used with FoamProblem."); // Do not create aux variable if variable provided. - if (!_moose_object_pars.isParamSetByUser("v")) + if (findParamKey(_moose_object_pars, "v") && !_moose_object_pars.isParamSetByUser("v")) createAuxVariable(); + // Create receiver if pp_name not provided and pp_name is an allowed parameter + if (findParamKey(_moose_object_pars, "pp_name") && + !_moose_object_pars.isParamSetByUser("pp_name")) + createReceiver(*foam_problem); + foam_problem->addObject(_type, _name, _moose_object_pars, false); } } @@ -56,3 +72,12 @@ AddFoamBCAction::createAuxVariable() std::static_pointer_cast(_action_factory.create(class_name, name(), action_params)); _awh.addActionBlock(action); } + +void +AddFoamBCAction::createReceiver(FoamProblem & problem) +{ + auto params = _factory.getValidParams("Receiver"); + + Hippo::internal::copyParamFromParam(params, _moose_object_pars, "default"); + problem.addPostprocessor("Receiver", name(), params); +} diff --git a/src/bcs/FoamBCBase.C b/src/bcs/FoamBCBase.C index b2879f11..5ab066a4 100644 --- a/src/bcs/FoamBCBase.C +++ b/src/bcs/FoamBCBase.C @@ -14,16 +14,6 @@ #include #include -namespace -{ -// Private function to check if variables are constant monomials -inline bool -is_constant_monomial(const MooseVariableFieldBase & var) -{ - return var.order() == libMesh::Order::CONSTANT && var.feType().family == FEFamily::MONOMIAL; -} -} - InputParameters FoamBCBase::validParams() { @@ -32,13 +22,8 @@ FoamBCBase::validParams() "Name of a Foam field. e.g. T (temperature) U (velocity)."); params.addParam>("boundary", "Boundaries that the boundary condition applies to."); - - params.addParam( - "v", - "Optional variable to use in BC. This allows existing AuxVariables to be" - " used rather than creating a new one under the hood."); - // Get desired parameters from Variable objects - params.transferParam>(MooseVariable::validParams(), "initial_condition"); + params.addRequiredParam("foam_variable", + "Name of a Foam field. e.g. T (temperature) U (velocity)."); params.registerSystemAttributeName("FoamBC"); params.registerBase("FoamBC"); @@ -50,7 +35,6 @@ FoamBCBase::FoamBCBase(const InputParameters & params) : MooseObject(params), Coupleable(this, false), _foam_variable(params.get("foam_variable")), - _moose_var(nullptr), _boundary(params.get>("boundary")) { auto * problem = dynamic_cast(&_c_fe_problem); @@ -60,7 +44,8 @@ FoamBCBase::FoamBCBase(const InputParameters & params) _mesh = &problem->mesh(); // check that the foam variable exists - if (!_mesh->foamHasObject(_foam_variable)) + if (!params.isPrivate("foam_variable") && + !_mesh->foamHasObject(_foam_variable)) mooseError("There is no OpenFOAM field named '", _foam_variable, "'"); // check that the boundary is in the FoamMesh @@ -75,45 +60,3 @@ FoamBCBase::FoamBCBase(const InputParameters & params) if (_boundary.empty()) _boundary = all_subdomain_names; } - -void -FoamBCBase::initialSetup() -{ - // Check variable exists - auto var_name = parameters().isParamValid("v") ? parameters().get("v") : _name; - if (!_c_fe_problem.hasVariable(var_name)) - mooseError("Variable '", var_name, "' doesn't exist"); - - THREAD_ID tid = parameters().get("_tid"); - _moose_var = &_c_fe_problem.getVariable(tid, var_name); - - // Check variable is constant monomial in case it is provided. - if (!is_constant_monomial(*_moose_var)) - mooseError("Variable '", var_name, "' must be a constant monomial."); -} - -Real -FoamBCBase::variableValueAtElement(const libMesh::Elem * elem) -{ - auto & sys = _moose_var->sys(); - auto dof = elem->dof_number(sys.number(), _moose_var->number(), 0); - return sys.solution()(dof); -} - -std::vector -FoamBCBase::getMooseVariableArray(int subdomain_id) -{ - size_t patch_count = _mesh->getPatchCount(subdomain_id); - size_t patch_offset = _mesh->getPatchOffset(subdomain_id); - - std::vector var_array(patch_count); - for (size_t j = 0; j < patch_count; ++j) - { - auto elem = patch_offset + j; - auto elem_ptr = _mesh->getElemPtr(elem + _mesh->rank_element_offset); - assert(elem_ptr); - var_array[j] = variableValueAtElement(elem_ptr); - } - - return var_array; -} diff --git a/src/bcs/FoamDiffusionFluxBC.C b/src/bcs/FoamDiffusionFluxBC.C new file mode 100644 index 00000000..aea80990 --- /dev/null +++ b/src/bcs/FoamDiffusionFluxBC.C @@ -0,0 +1,60 @@ + +#include "FoamDiffusionFluxBC.h" +#include "FoamVariableBCBase.h" +#include "MooseError.h" + +#include +#include +#include +#include + +registerMooseObject("hippoApp", FoamDiffusionFluxBC); + +InputParameters +FoamDiffusionFluxBC::validParams() +{ + auto params = FoamVariableBCBase::validParams(); + params.addParam( + "diffusivity", "kappa", "Diffusivity for BC, defaults to kappa, the thermal conducitivity."); + params.addClassDescription("A FoamBC that imposes a fixed gradient boundary condition " + "on the OpenFOAM simulation"); + return params; +} + +FoamDiffusionFluxBC::FoamDiffusionFluxBC(const InputParameters & params) + : FoamVariableBCBase(params), _diffusivity(getParam("diffusivity")) +{ + if (!_mesh->fvMesh().foundObject(_diffusivity)) + { + mooseError("Diffusivity '", _diffusivity, "' not a Foam volScalarField."); + } +} + +void +FoamDiffusionFluxBC::imposeBoundaryCondition() +{ + auto & foam_mesh = _mesh->fvMesh(); + + // Get subdomains this FoamBC acts on + // TODO: replace with BoundaryRestriction member functions once FoamMesh is updated + auto subdomains = _mesh->getSubdomainIDs(_boundary); + for (auto subdomain : subdomains) + { + std::vector && grad_array = getMooseVariableArray(subdomain); + + // Get the gradient associated with the field + auto & foam_gradient = + _mesh->getGradientBCField(subdomain, _foam_variable); + assert(grad_array.size() == static_cast(foam_gradient.size())); + + auto & coeff = foam_mesh.boundary()[subdomain].lookupPatchField( + _diffusivity); + + assert(foam_gradient.size() == coeff.size()); + // set gradient + for (auto i = 0; i < foam_gradient.size(); ++i) + { + foam_gradient[i] = grad_array[i] / coeff[i]; + } + } +} diff --git a/src/bcs/FoamDiffusionFluxPostprocessorBC.C b/src/bcs/FoamDiffusionFluxPostprocessorBC.C new file mode 100644 index 00000000..49a6fab1 --- /dev/null +++ b/src/bcs/FoamDiffusionFluxPostprocessorBC.C @@ -0,0 +1,55 @@ +#include "FoamDiffusionFluxPostprocessorBC.h" +#include "FoamPostprocessorBCBase.h" +#include "PstreamReduceOps.H" +#include "Registry.h" +#include + +registerMooseObject("hippoApp", FoamDiffusionFluxPostprocessorBC); + +InputParameters +FoamDiffusionFluxPostprocessorBC::validParams() +{ + auto params = FoamPostprocessorBCBase::validParams(); + params.addParam( + "diffusivity", "kappa", "Diffusivity for BC, defaults to kappa, the thermal conducitivity."); + return params; +} + +FoamDiffusionFluxPostprocessorBC::FoamDiffusionFluxPostprocessorBC(const InputParameters & params) + : FoamPostprocessorBCBase(params), _diffusivity(getParam("diffusivity")) +{ + if (!_mesh->fvMesh().foundObject(_diffusivity)) + { + mooseError("Diffusivity '", _diffusivity, "' not a Foam volScalarField."); + } +} + +void +FoamDiffusionFluxPostprocessorBC::imposeBoundaryCondition() +{ + auto & foam_mesh = _mesh->fvMesh(); + + // Get subdomains this FoamBC acts on + auto subdomains = _mesh->getSubdomainIDs(_boundary); + for (auto subdomain : subdomains) + { + const auto & boundary = foam_mesh.boundary()[subdomain]; + // Get underlying field from OpenFOAM boundary patch. + auto & foam_gradient = + _mesh->getGradientBCField(subdomain, _foam_variable); + + // Get the underlying diffusivity field + const auto & coeff = + foam_mesh.boundary()[subdomain].lookupPatchField( + _diffusivity); + + // Calculate the bulk value of the diffusivity coefficient + const auto area = boundary.magSf(); + const auto total_area = Foam::returnReduce(Foam::sum(area), Foam::sumOp()); + const auto coeff_bulk = + Foam::returnReduce(Foam::sum(coeff * area), Foam::sumOp()) / total_area; + + // set gradient + std::fill(foam_gradient.begin(), foam_gradient.end(), _pp_value / coeff_bulk); + } +} diff --git a/src/bcs/FoamFixedGradientBC.C b/src/bcs/FoamFixedGradientBC.C index 7434d077..7b4d9ed2 100644 --- a/src/bcs/FoamFixedGradientBC.C +++ b/src/bcs/FoamFixedGradientBC.C @@ -10,24 +10,15 @@ registerMooseObject("hippoApp", FoamFixedGradientBC); InputParameters FoamFixedGradientBC::validParams() { - auto params = FoamBCBase::validParams(); - params.addClassDescription("A FoamBC that imposes a fixed gradient dirichlet boundary condition " + auto params = FoamVariableBCBase::validParams(); + params.addClassDescription("A FoamBC that imposes a fixed gradient boundary condition " "on the OpenFOAM simulation"); - params.addParam("diffusivity_coefficient", - "OpenFOAM scalar field name to be specified if 'v' is " - "a flux rather than a gradient"); return params; } FoamFixedGradientBC::FoamFixedGradientBC(const InputParameters & parameters) - : FoamBCBase(parameters), - _diffusivity_coefficient(parameters.get("diffusivity_coefficient")) + : FoamVariableBCBase(parameters) { - // check that the diffusivity coefficient is a OpenFOAM scalar field - if (!_diffusivity_coefficient.empty() && - !_mesh->foamHasObject(_diffusivity_coefficient)) - mooseError( - "Diffusivity coefficient '", _diffusivity_coefficient, "' not a Foam volScalarField"); } void @@ -47,24 +38,6 @@ FoamFixedGradientBC::imposeBoundaryCondition() _mesh->getGradientBCField(subdomain, _foam_variable); assert(grad_array.size() == static_cast(foam_gradient.size())); - // If diffusivity_coefficient is specified grad array is a flux, so result - // must be divided by it - if (!_diffusivity_coefficient.empty()) - { - // Get the underlying diffusivity field - auto & coeff = foam_mesh.boundary()[subdomain].lookupPatchField( - _diffusivity_coefficient); - - assert(foam_gradient.size() == coeff.size()); - // set gradient - for (auto i = 0; i < foam_gradient.size(); ++i) - { - foam_gradient[i] = grad_array[i] / coeff[i]; - } - } - else // if no diffusivity coefficient grad_array is just the gradient so copy - { - std::copy(grad_array.begin(), grad_array.end(), foam_gradient.begin()); - } + std::copy(grad_array.begin(), grad_array.end(), foam_gradient.begin()); } } diff --git a/src/bcs/FoamFixedGradientPostprocessorBC.C b/src/bcs/FoamFixedGradientPostprocessorBC.C new file mode 100644 index 00000000..374c7228 --- /dev/null +++ b/src/bcs/FoamFixedGradientPostprocessorBC.C @@ -0,0 +1,38 @@ +#include "FoamFixedGradientPostprocessorBC.h" +#include "PstreamReduceOps.H" +#include "Registry.h" +#include + +registerMooseObject("hippoApp", FoamFixedGradientPostprocessorBC); + +InputParameters +FoamFixedGradientPostprocessorBC::validParams() +{ + auto params = FoamPostprocessorBCBase::validParams(); + return params; +} + +FoamFixedGradientPostprocessorBC::FoamFixedGradientPostprocessorBC(const InputParameters & params) + : FoamPostprocessorBCBase(params) +{ +} + +void +FoamFixedGradientPostprocessorBC::imposeBoundaryCondition() +{ + auto & foam_mesh = _mesh->fvMesh(); + + // Get subdomains this FoamBC acts on + auto subdomains = _mesh->getSubdomainIDs(_boundary); + for (auto subdomain : subdomains) + { + auto & boundary = foam_mesh.boundary()[subdomain]; + // Get underlying field from OpenFOAM boundary patch. + auto & foam_gradient = + _mesh->getGradientBCField(subdomain, _foam_variable); + + // If diffusivity_coefficient is specified grad array is a flux, so result + // must be divided by it + std::fill(foam_gradient.begin(), foam_gradient.end(), _pp_value); + } +} diff --git a/src/bcs/FoamFixedValueBC.C b/src/bcs/FoamFixedValueBC.C index 11c74268..29c7b0dc 100644 --- a/src/bcs/FoamFixedValueBC.C +++ b/src/bcs/FoamFixedValueBC.C @@ -1,36 +1,35 @@ #include "FoamFixedValueBC.h" #include "InputParameters.h" #include "MooseTypes.h" +#include registerMooseObject("hippoApp", FoamFixedValueBC); InputParameters FoamFixedValueBC::validParams() { - auto params = FoamBCBase::validParams(); + auto params = FoamVariableBCBase::validParams(); params.addClassDescription("A FoamBC that imposes a fixed value dirichlet boundary condition " "on the OpenFOAM simulation"); return params; } -FoamFixedValueBC::FoamFixedValueBC(const InputParameters & parameters) : FoamBCBase(parameters) {} +FoamFixedValueBC::FoamFixedValueBC(const InputParameters & parameters) + : FoamVariableBCBase(parameters) +{ +} void FoamFixedValueBC::imposeBoundaryCondition() { - auto & foam_mesh = _mesh->fvMesh(); - // Get subdomains this FoamBC acts on - // TODO: replace with BoundaryRestriction member functions once FoamMesh is updated auto subdomains = _mesh->getSubdomainIDs(_boundary); for (auto subdomain : subdomains) { std::vector && var_array = getMooseVariableArray(subdomain); // Get underlying field from OpenFOAM boundary patch - auto & foam_var = const_cast &>( - foam_mesh.boundary()[subdomain].lookupPatchField( - _foam_variable)); + auto & foam_var = _mesh->getBCField(subdomain, _foam_variable); assert(var_array.size() == static_cast(foam_var.size())); diff --git a/src/bcs/FoamFixedValuePosprocessorBC.C b/src/bcs/FoamFixedValuePosprocessorBC.C new file mode 100644 index 00000000..03958d0d --- /dev/null +++ b/src/bcs/FoamFixedValuePosprocessorBC.C @@ -0,0 +1,29 @@ +#include "FoamFixedValuePostprocessorBC.h" +#include "Registry.h" + +registerMooseObject("hippoApp", FoamFixedValuePostprocessorBC); + +InputParameters +FoamFixedValuePostprocessorBC::validParams() +{ + return FoamPostprocessorBCBase::validParams(); +} + +FoamFixedValuePostprocessorBC::FoamFixedValuePostprocessorBC(const InputParameters & params) + : FoamPostprocessorBCBase(params) +{ +} + +void +FoamFixedValuePostprocessorBC::imposeBoundaryCondition() +{ + // Get subdomains this FoamBC acts on + auto subdomains = _mesh->getSubdomainIDs(_boundary); + for (auto subdomain : subdomains) + { + // Get underlying field from OpenFOAM boundary patch + auto & foam_var = _mesh->getBCField(subdomain, _foam_variable); + + std::fill(foam_var.begin(), foam_var.end(), _pp_value); + } +} diff --git a/src/bcs/FoamMassFlowRateInletBC.C b/src/bcs/FoamMassFlowRateInletBC.C new file mode 100644 index 00000000..b458c6fa --- /dev/null +++ b/src/bcs/FoamMassFlowRateInletBC.C @@ -0,0 +1,44 @@ +#include "FoamMassFlowRateInletBC.h" +#include "InputParameters.h" +#include "MooseTypes.h" +#include "PstreamReduceOps.H" +#include "Registry.h" + +registerMooseObject("hippoApp", FoamMassFlowRateInletBC); + +InputParameters +FoamMassFlowRateInletBC::validParams() +{ + auto params = FoamPostprocessorBCBase::validParams(); + + params.addParam("scale_factor", 1., "Scale factor multiply mass flow rate pp_name by."); + params.suppressParameter("foam_variable"); + params.set("foam_variable") = "U"; + + return params; +} + +FoamMassFlowRateInletBC::FoamMassFlowRateInletBC(const InputParameters & params) + : FoamPostprocessorBCBase(params), _scale_factor(params.get("scale_factor")) +{ +} + +void +FoamMassFlowRateInletBC::imposeBoundaryCondition() +{ + auto & foam_mesh = _mesh->fvMesh(); + + // Get subdomains this FoamBC acts on + // TODO: replace with BoundaryRestriction member functions once FoamMesh is updated + auto subdomains = _mesh->getSubdomainIDs(_boundary); + for (auto subdomain : subdomains) + { + const auto & boundary_patch = foam_mesh.boundary()[subdomain]; + + auto & U_var = const_cast &>( + boundary_patch.lookupPatchField("U")); + const auto & rho = boundary_patch.lookupPatchField("rho"); + const Real area = Foam::returnReduce(Foam::sum(boundary_patch.magSf()), Foam::sumOp()); + U_var == -_scale_factor * _pp_value * boundary_patch.nf() / (rho * area); + } +} diff --git a/src/bcs/FoamPostprocessorBCBase.C b/src/bcs/FoamPostprocessorBCBase.C new file mode 100644 index 00000000..fb84f98e --- /dev/null +++ b/src/bcs/FoamPostprocessorBCBase.C @@ -0,0 +1,41 @@ +#include "FoamBCBase.h" +#include "FoamPostprocessorBCBase.h" +#include "hippoUtils.h" + +#include "InputParameters.h" +#include "MooseTypes.h" +#include "PostprocessorInterface.h" +#include "Receiver.h" +#include + +InputParameters +FoamPostprocessorBCBase::validParams() +{ + auto params = FoamBCBase::validParams(); + + params.addParam("pp_name", "optional postprocessor to be used in BC"); + params.transferParam(Receiver::validParams(), "default"); + + return params; +} + +FoamPostprocessorBCBase::FoamPostprocessorBCBase(const InputParameters & params) + : FoamBCBase(params), + PostprocessorInterface(this), + _pp_name((params.isParamSetByUser("pp_name")) ? params.get("pp_name") + : _name), + _pp_value(getPostprocessorValueByName(_pp_name)) +{ + if (params.isParamSetByUser("pp_name") && params.isParamSetByUser("default")) + mooseWarning("'pp_name' and 'default' should not both be set. 'default' ignored."); +} + +BCInfoTableRow +FoamPostprocessorBCBase::getInfoRow() const +{ + return std::make_tuple(name(), + type(), + foamVariable(), + moosePostprocessor(), + Hippo::internal::listFromVector(boundary())); +} diff --git a/src/bcs/FoamVariableBCBase.C b/src/bcs/FoamVariableBCBase.C new file mode 100644 index 00000000..f8896577 --- /dev/null +++ b/src/bcs/FoamVariableBCBase.C @@ -0,0 +1,86 @@ + +#include "FoamBCBase.h" +#include "FoamVariableBCBase.h" +#include "hippoUtils.h" + +#include "FEProblemBase.h" + +namespace +{ +// Private function to check if variables are constant monomials +inline bool +is_constant_monomial(const MooseVariableFieldBase & var) +{ + return var.order() == libMesh::Order::CONSTANT && var.feType().family == FEFamily::MONOMIAL; +} +} + +InputParameters +FoamVariableBCBase::validParams() +{ + InputParameters params = FoamBCBase::validParams(); + + params.addParam( + "v", + "Optional variable allowing existing AuxVariables to be used in the BC." + "If v is not provided, an AuxVariable with the name of this object is created."); + // Get desired parameters from Variable objects + params.transferParam>(MooseVariable::validParams(), "initial_condition"); + + return params; +} + +FoamVariableBCBase::FoamVariableBCBase(const InputParameters & params) + : FoamBCBase(params), _moose_var() +{ +} + +void +FoamVariableBCBase::initialSetup() +{ + // Check variable exists + auto var_name = parameters().isParamValid("v") ? parameters().get("v") : _name; + if (!_c_fe_problem.hasVariable(var_name)) + mooseError("Variable '", var_name, "' doesn't exist"); + + THREAD_ID tid = parameters().get("_tid"); + _moose_var = _c_fe_problem.getVariable(tid, var_name); + + // Check variable is constant monomial in case it is provided. + if (!is_constant_monomial(_moose_var->get())) + mooseError("Variable '", var_name, "' must be a constant monomial."); +} + +BCInfoTableRow +FoamVariableBCBase::getInfoRow() const +{ + // List info about BC + return std::make_tuple( + name(), type(), foamVariable(), mooseVariable(), Hippo::internal::listFromVector(boundary())); +} + +Real +FoamVariableBCBase::variableValueAtElement(const libMesh::Elem & elem) const +{ + auto & sys = _moose_var->get().sys(); + auto dof = elem.dof_number(sys.number(), _moose_var->get().number(), 0); + return sys.solution()(dof); +} + +std::vector +FoamVariableBCBase::getMooseVariableArray(int subdomainId) const +{ + size_t patch_count = _mesh->getPatchCount(subdomainId); + size_t patch_offset = _mesh->getPatchOffset(subdomainId); + + std::vector var_array(patch_count); + for (size_t j = 0; j < patch_count; ++j) + { + auto elem = patch_offset + j; + const auto elem_ptr = _mesh->getElemPtr(elem + _mesh->rank_element_offset); + assert(elem_ptr); + var_array[j] = variableValueAtElement(*elem_ptr); + } + + return var_array; +} diff --git a/src/problems/FoamProblem.C b/src/problems/FoamProblem.C index d1c470f9..9fadb6d5 100644 --- a/src/problems/FoamProblem.C +++ b/src/problems/FoamProblem.C @@ -1,47 +1,27 @@ -#include "Attributes.h" -#include "ExternalProblem.h" +#include "FoamVariableField.h" #include "FoamMesh.h" #include "FoamProblem.h" #include "FoamSolver.h" -#include "VariadicTable.h" -#include "word.H" +#include "hippoUtils.h" -#include -#include -#include -#include -#include -#include "FoamVariableField.h" +#include "Attributes.h" +#include "ExternalProblem.h" +#include "VariadicTable.h" +#include "MooseTypes.h" #include "InputParameters.h" #include "VariadicTable.h" + #include +#include #include #include #include - #include #include -registerMooseObject("hippoApp", FoamProblem); +#include -namespace -{ -// Create comma separated list from vector -template -inline std::string -listFromVector(std::vector vec, StrType sep = ", ") -{ - if (vec.size() == 0) - return std::string(); - else if (vec.size() == 1) - return vec.at(0); - - std::string str; - auto binary_op = [&](const std::string & acc, const std::string & it) { return acc + sep + it; }; - std::accumulate(vec.begin(), vec.end(), str, binary_op); - return str; -} -} +registerMooseObject("hippoApp", FoamProblem); InputParameters FoamProblem::validParams() @@ -154,7 +134,7 @@ FoamProblem::verifyFoamBCs() "FoamBC name", "Type", "Foam variable", - "Moose variable", + "Moose variable/postprocessor", "Boundaries", }); @@ -172,11 +152,8 @@ FoamProblem::verifyFoamBCs() auto && boundary = bc->boundary(); used_bcs.insert(used_bcs.end(), boundary.begin(), boundary.end()); // List info about BC - vt.addRow(bc->name(), - bc->type(), - bc->foamVariable(), - bc->mooseVariable(), - listFromVector(boundary)); + auto [name, type, foam_var, moose_var, boundaries] = bc->getInfoRow(); + vt.addRow(name, type, foam_var, moose_var, boundaries); } } @@ -198,7 +175,7 @@ FoamProblem::verifyFoamBCs() unused_bcs.push_back(bc); } if (unused_bcs.size() > 0) - vt.addRow("", "UnusedBoundaries", "", "", listFromVector(unused_bcs)); + vt.addRow("", "UnusedBoundaries", "", "", Hippo::internal::listFromVector(unused_bcs)); } vt.print(_console); } @@ -223,7 +200,7 @@ FoamProblem::verifyFoamPostprocessors() if (fpp) { _foam_postprocessor.push_back(fpp); - vt.addRow(fpp->name(), fpp->type(), listFromVector(fpp->blocks())); + vt.addRow(fpp->name(), fpp->type(), Hippo::internal::listFromVector(fpp->blocks())); } } diff --git a/test/include/bcs/FoamTestBC.h b/test/include/bcs/FoamTestBC.h index 28cd2a91..0ae3cf71 100644 --- a/test/include/bcs/FoamTestBC.h +++ b/test/include/bcs/FoamTestBC.h @@ -1,10 +1,10 @@ -#include "FoamBCBase.h" +#include "FoamVariableBCBase.h" #include "InputParameters.h" -class FoamTestBC : public FoamBCBase +class FoamTestBC : public FoamVariableBCBase { public: - explicit FoamTestBC(const InputParameters & params) : FoamBCBase(params) {}; + explicit FoamTestBC(const InputParameters & params) : FoamVariableBCBase(params) {}; void imposeBoundaryCondition() {}; }; diff --git a/test/tests/actions/foam_bc/test.py b/test/tests/actions/foam_bc/test.py deleted file mode 100644 index d0ea36c3..00000000 --- a/test/tests/actions/foam_bc/test.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Tests for imposing BCs in OpenFOAM using MOOSE input file syntax""" - -import unittest - -import fluidfoam as ff -import numpy as np -from read_hippo_data import get_foam_times - - -class TestFoamBCFixedGradient(unittest.TestCase): - """Test class for imposing fixed gradient BCs in Hippo.""" - - def test_fixed_gradient_x(self): - """Test case for imposing fixed gradient.""" - case_dir = "foam/" - times = get_foam_times(case_dir)[1:] - - for time in times: - coords = dict(zip(("x", "y", "z"), ff.readof.readmesh(case_dir))) - - temp = ff.readof.readscalar(case_dir, time, "T") - - temp_ref = coords["x"] * np.float64(time) - - temp_diff_max = np.argmax(abs(temp - temp_ref)) - assert np.allclose(temp_ref, temp, rtol=1e-7, atol=1e-12), ( - f"Max diff ({time}): {abs(temp - temp_ref).max()} " - f"{temp[temp_diff_max]} {temp_ref[temp_diff_max]}" - ) diff --git a/test/tests/actions/foam_bc/tests b/test/tests/actions/foam_bc/tests index 3e5b200b..9ed2ded2 100644 --- a/test/tests/actions/foam_bc/tests +++ b/test/tests/actions/foam_bc/tests @@ -9,7 +9,6 @@ input = main.i prereq = foam_bc_action/setup allow_test_objects = true - allow_warnings = true [] [foam_var_error] type = RunException @@ -18,7 +17,6 @@ expect_err = "There is no OpenFOAM field named 'T1'" cli_args = 'FoamBCs/temp/foam_variable=T1' allow_test_objects = true - allow_warnings = true [] [foam_boundary_error] type = RunException @@ -27,7 +25,6 @@ expect_err = "Boundary 'left1' not found in FoamMesh" cli_args = 'FoamBCs/temp/boundary=left1' allow_test_objects = true - allow_warnings = true [] [foam_duplicated_boundary_error] type = RunException @@ -35,7 +32,6 @@ prereq = foam_bc_action/setup expect_err = "Imposed FoamBC has duplicated boundary 'left' for foam variable 'T'" cli_args = 'FoamBCs/temp_r/boundary=left' - allow_warnings = true allow_test_objects = true [] [] diff --git a/test/tests/actions/foam_variable/tests b/test/tests/actions/foam_variable/tests index c7e7fa3b..1fa573db 100644 --- a/test/tests/actions/foam_variable/tests +++ b/test/tests/actions/foam_variable/tests @@ -8,7 +8,6 @@ type = RunApp input = main.i prereq = transfer_test/setup - allow_warnings = true [] [err_problem] type = RunException @@ -16,7 +15,6 @@ prereq = transfer_test/setup expect_err = "can only be used with FoamProblem" cli_args = "Problem/type=FEProblem" - allow_warnings = true [] [] [] diff --git a/test/tests/bcs/diffusion_flux_pp/foam/0/T b/test/tests/bcs/diffusion_flux_pp/foam/0/T new file mode 100644 index 00000000..6da637de --- /dev/null +++ b/test/tests/bcs/diffusion_flux_pp/foam/0/T @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0.; + +boundaryField +{ + left + { + type fixedValue; + value uniform 0.; + } + right + { + type fixedGradient; + gradient uniform 1.; + } + top + { + type zeroGradient; + } + front + { + type zeroGradient; + } + bottom + { + type zeroGradient; + } + back + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/test/tests/bcs/diffusion_flux_pp/foam/constant/physicalProperties b/test/tests/bcs/diffusion_flux_pp/foam/constant/physicalProperties new file mode 100644 index 00000000..6dab7b1c --- /dev/null +++ b/test/tests/bcs/diffusion_flux_pp/foam/constant/physicalProperties @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object physicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heSolidThermo; + mixture pureMixture; + transport constIsoSolid; + thermo eConst; + equationOfState rhoConst; + specie specie; + energy sensibleInternalEnergy; +} + +mixture +{ + specie + { + molWeight 1; + } + thermodynamics + { + Cv 1; // Specific heat capacity [J/(kg·K)] + Hf 1; // Heat of formation [J/kg] + Tref 0; + } + transport + { + kappa 2.; // Thermal conductivity [W/(m·K)] + } + equationOfState + { + rho 1; // Density [kg/m^3] + } +} + + +// ************************************************************************* // diff --git a/test/tests/bcs/diffusion_flux_pp/foam/system/blockMeshDict b/test/tests/bcs/diffusion_flux_pp/foam/system/blockMeshDict new file mode 100644 index 00000000..face9ea6 --- /dev/null +++ b/test/tests/bcs/diffusion_flux_pp/foam/system/blockMeshDict @@ -0,0 +1,85 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +vertices +( + ( 0.0 0.0 0.0 ) + ( 10.0 0.0 0.0 ) + ( 10.0 1.0 0.0 ) + ( 0.0 1.0 0.0 ) + + ( 0.0 0.0 1.0) + ( 10.0 0.0 1.0) + ( 10.0 1.0 1.0) + ( 0.0 1.0 1.0) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (50 1 1) simpleGrading (25 1 1) +); + +boundary +( + + // interface + left + { + type wall; + faces + ( + (4 7 3 0) + ); + } + + right + { + type wall; + faces + ( + (6 5 1 2) + ); + } + + top + { + type wall; + faces + ( + (2 3 7 6) + ); + } + + front + { + type wall; + faces + ( + (3 2 1 0) + ); + } + + bottom + { + type wall; + faces + ( + (0 1 5 4) + ); + } + + back + { + type wall; + faces + ( + (4 5 6 7) + ); + } + +); diff --git a/test/tests/bcs/diffusion_flux_pp/foam/system/controlDict b/test/tests/bcs/diffusion_flux_pp/foam/system/controlDict new file mode 100644 index 00000000..89301ab0 --- /dev/null +++ b/test/tests/bcs/diffusion_flux_pp/foam/system/controlDict @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solver bcTestSolver; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 32.; + +deltaT 1.; + +writeControl timeStep; + +writeInterval 1; + +writeFormat ascii; + +writePrecision 20; + +writeCompression off; + +timeFormat general; + +timePrecision 20; + +runTimeModifiable true; + +// ************************************************************************* // diff --git a/test/tests/bcs/diffusion_flux_pp/foam/system/fvSchemes b/test/tests/bcs/diffusion_flux_pp/foam/system/fvSchemes new file mode 100644 index 00000000..a24aaf80 --- /dev/null +++ b/test/tests/bcs/diffusion_flux_pp/foam/system/fvSchemes @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +// ************************************************************************* // diff --git a/test/tests/bcs/diffusion_flux_pp/foam/system/fvSolution b/test/tests/bcs/diffusion_flux_pp/foam/system/fvSolution new file mode 100644 index 00000000..639b272d --- /dev/null +++ b/test/tests/bcs/diffusion_flux_pp/foam/system/fvSolution @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + rho + { + solver diagonal; + } + + rhoFinal + { + $rho; + } + + + e + { + solver PBiCGStab; + preconditioner DIC; + tolerance 1e-15; + relTol 1e-15; + } + + eFinal + { + $e; + tolerance 1e-15; + relTol 1e-15; + } +} + +PIMPLE +{ +} + +// ************************************************************************* // diff --git a/test/tests/bcs/diffusion_flux_pp/main.i b/test/tests/bcs/diffusion_flux_pp/main.i new file mode 100644 index 00000000..69d94b6e --- /dev/null +++ b/test/tests/bcs/diffusion_flux_pp/main.i @@ -0,0 +1,55 @@ +[Mesh] + type = FoamMesh + case = 'foam' + foam_patch = 'left right' +[] + +[Variables] + [dummy] + family = MONOMIAL + order = CONSTANT + initial_condition = 999 + [] +[] + +[FoamBCs] + [T_value] + type=FoamFixedValuePostprocessorBC + foam_variable = T + default = 0. + boundary = 'left' + [] + [T_flux] + type=FoamDiffusionFluxPostprocessorBC + foam_variable = T + boundary = 'right' + pp_name = T_flux + [] +[] + +[Postprocessors] + [T_flux] + type = ParsedPostprocessor + expression = '2*t' + use_t = true + execute_on = 'INITIAL TIMESTEP_BEGIN' + [] +[] + +[Problem] + type = FoamProblem +[] + +[Executioner] + type = Transient + end_time = 32 + [TimeSteppers] + [foam] + type = FoamTimeStepper + [] + [] +[] + +[Outputs] + exodus = true +[] diff --git a/test/tests/bcs/diffusion_flux_pp/test.py b/test/tests/bcs/diffusion_flux_pp/test.py new file mode 100644 index 00000000..a8dd55e7 --- /dev/null +++ b/test/tests/bcs/diffusion_flux_pp/test.py @@ -0,0 +1,40 @@ +"""Tests for imposing BCs in OpenFOAM using MOOSE input file syntax""" + +import unittest + +import fluidfoam as ff +import numpy as np +from read_hippo_data import get_foam_times # pylint: disable=E0401 + + +class TestFoamBCDiffusionFluxPP(unittest.TestCase): + """Test class for imposing fixed gradient BCs in Hippo.""" + + def test_fixed_gradient_x(self): + """ + Test case for imposing diffusion flux BC with postprocessor. + + Solves laplace equation at each time step with right BC being k\partial_x T = 2t + where k is 2. The analytical solution is t*x. + """ + case_dir = "foam/" + times = get_foam_times(case_dir, string=True)[1:] + + for time in times: + coords = dict(zip(("x", "y", "z"), ff.readof.readmesh(case_dir))) + + temp = ff.readof.readscalar(case_dir, time, "T") + + temp_ref = coords["x"] * np.float64(time) + + temp_diff_max = np.argmax(abs(temp - temp_ref)) + np.testing.assert_allclose( + temp_ref, + temp, + rtol=1e-7, + atol=1e-12, + err_msg=( + f"Max diff ({time}): {abs(temp - temp_ref).max()} " + f"{temp[temp_diff_max]} {temp_ref[temp_diff_max]}" + ), + ) diff --git a/test/tests/bcs/diffusion_flux_pp/tests b/test/tests/bcs/diffusion_flux_pp/tests new file mode 100644 index 00000000..a7969cff --- /dev/null +++ b/test/tests/bcs/diffusion_flux_pp/tests @@ -0,0 +1,36 @@ +[Tests] + [foam_bc_diffusion_flux_pp] + [setup] + type = RunCommand + command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam"' + [] + [diffusivity_err] + type = RunException + input = main.i + prereq = foam_bc_diffusion_flux_pp/setup + expect_err = "Diffusivity 'kappa1' not a Foam volScalarField" + cli_args = 'FoamBCs/T_flux/diffusivity=kappa1' + [] + [run] + type = RunApp + input = main.i + prereq = foam_bc_diffusion_flux_pp/setup + [] + [verify] + type = PythonUnitTest + input = test.py + prereq = foam_bc_diffusion_flux_pp/run + [] + [run_diffusivity_cv] + type = RunApp + input = main.i + cli_args = "FoamBCs/T_flux/diffusivity='Cv' Postprocessors/T_flux/expression='t'" + prereq = foam_bc_diffusion_flux_pp/verify + [] + [verify_diffusivity_cv] + type = PythonUnitTest + input = test.py + prereq = foam_bc_diffusion_flux_pp/run_diffusivity_cv + [] + [] +[] diff --git a/test/tests/bcs/fixed_gradient_pp/foam/0/T b/test/tests/bcs/fixed_gradient_pp/foam/0/T new file mode 100644 index 00000000..6da637de --- /dev/null +++ b/test/tests/bcs/fixed_gradient_pp/foam/0/T @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0.; + +boundaryField +{ + left + { + type fixedValue; + value uniform 0.; + } + right + { + type fixedGradient; + gradient uniform 1.; + } + top + { + type zeroGradient; + } + front + { + type zeroGradient; + } + bottom + { + type zeroGradient; + } + back + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/test/tests/bcs/fixed_gradient_pp/foam/constant/physicalProperties b/test/tests/bcs/fixed_gradient_pp/foam/constant/physicalProperties new file mode 100644 index 00000000..6dab7b1c --- /dev/null +++ b/test/tests/bcs/fixed_gradient_pp/foam/constant/physicalProperties @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object physicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heSolidThermo; + mixture pureMixture; + transport constIsoSolid; + thermo eConst; + equationOfState rhoConst; + specie specie; + energy sensibleInternalEnergy; +} + +mixture +{ + specie + { + molWeight 1; + } + thermodynamics + { + Cv 1; // Specific heat capacity [J/(kg·K)] + Hf 1; // Heat of formation [J/kg] + Tref 0; + } + transport + { + kappa 2.; // Thermal conductivity [W/(m·K)] + } + equationOfState + { + rho 1; // Density [kg/m^3] + } +} + + +// ************************************************************************* // diff --git a/test/tests/bcs/fixed_gradient_pp/foam/system/blockMeshDict b/test/tests/bcs/fixed_gradient_pp/foam/system/blockMeshDict new file mode 100644 index 00000000..face9ea6 --- /dev/null +++ b/test/tests/bcs/fixed_gradient_pp/foam/system/blockMeshDict @@ -0,0 +1,85 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +vertices +( + ( 0.0 0.0 0.0 ) + ( 10.0 0.0 0.0 ) + ( 10.0 1.0 0.0 ) + ( 0.0 1.0 0.0 ) + + ( 0.0 0.0 1.0) + ( 10.0 0.0 1.0) + ( 10.0 1.0 1.0) + ( 0.0 1.0 1.0) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (50 1 1) simpleGrading (25 1 1) +); + +boundary +( + + // interface + left + { + type wall; + faces + ( + (4 7 3 0) + ); + } + + right + { + type wall; + faces + ( + (6 5 1 2) + ); + } + + top + { + type wall; + faces + ( + (2 3 7 6) + ); + } + + front + { + type wall; + faces + ( + (3 2 1 0) + ); + } + + bottom + { + type wall; + faces + ( + (0 1 5 4) + ); + } + + back + { + type wall; + faces + ( + (4 5 6 7) + ); + } + +); diff --git a/test/tests/bcs/fixed_gradient_pp/foam/system/controlDict b/test/tests/bcs/fixed_gradient_pp/foam/system/controlDict new file mode 100644 index 00000000..89301ab0 --- /dev/null +++ b/test/tests/bcs/fixed_gradient_pp/foam/system/controlDict @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solver bcTestSolver; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 32.; + +deltaT 1.; + +writeControl timeStep; + +writeInterval 1; + +writeFormat ascii; + +writePrecision 20; + +writeCompression off; + +timeFormat general; + +timePrecision 20; + +runTimeModifiable true; + +// ************************************************************************* // diff --git a/test/tests/bcs/fixed_gradient_pp/foam/system/fvSchemes b/test/tests/bcs/fixed_gradient_pp/foam/system/fvSchemes new file mode 100644 index 00000000..a24aaf80 --- /dev/null +++ b/test/tests/bcs/fixed_gradient_pp/foam/system/fvSchemes @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +// ************************************************************************* // diff --git a/test/tests/bcs/fixed_gradient_pp/foam/system/fvSolution b/test/tests/bcs/fixed_gradient_pp/foam/system/fvSolution new file mode 100644 index 00000000..639b272d --- /dev/null +++ b/test/tests/bcs/fixed_gradient_pp/foam/system/fvSolution @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + rho + { + solver diagonal; + } + + rhoFinal + { + $rho; + } + + + e + { + solver PBiCGStab; + preconditioner DIC; + tolerance 1e-15; + relTol 1e-15; + } + + eFinal + { + $e; + tolerance 1e-15; + relTol 1e-15; + } +} + +PIMPLE +{ +} + +// ************************************************************************* // diff --git a/test/tests/bcs/fixed_gradient_pp/main.i b/test/tests/bcs/fixed_gradient_pp/main.i new file mode 100644 index 00000000..7732c1a9 --- /dev/null +++ b/test/tests/bcs/fixed_gradient_pp/main.i @@ -0,0 +1,55 @@ +[Mesh] + type = FoamMesh + case = 'foam' + foam_patch = 'left right' +[] + +[Variables] + [dummy] + family = MONOMIAL + order = CONSTANT + initial_condition = 999 + [] +[] + +[FoamBCs] + [T_value] + type=FoamFixedValuePostprocessorBC + foam_variable = T + default = 0. + boundary = 'left' + [] + [T_flux] + type=FoamFixedGradientPostprocessorBC + foam_variable = T + boundary = 'right' + pp_name = T_flux + [] +[] + +[Postprocessors] + [T_flux] + type = ParsedPostprocessor + expression = 't' + use_t = true + execute_on = 'INITIAL TIMESTEP_BEGIN' + [] +[] + +[Problem] + type = FoamProblem +[] + +[Executioner] + type = Transient + end_time = 32 + [TimeSteppers] + [foam] + type = FoamTimeStepper + [] + [] +[] + +[Outputs] + exodus = true +[] diff --git a/test/tests/bcs/fixed_gradient_pp/test.py b/test/tests/bcs/fixed_gradient_pp/test.py new file mode 100644 index 00000000..1bb49201 --- /dev/null +++ b/test/tests/bcs/fixed_gradient_pp/test.py @@ -0,0 +1,40 @@ +"""Tests for imposing BCs in OpenFOAM using MOOSE input file syntax""" + +import unittest + +import fluidfoam as ff +import numpy as np +from read_hippo_data import get_foam_times # pylint: disable=E0401 + + +class TestFoamBCFixedGradientPP(unittest.TestCase): + """Test class for imposing fixed value BCs in Hippo.""" + + def test_diffusion_flux_x(self): + """ + Test case for imposing diffusion flux BC with postprocessor. + + Solves laplace equation at each time step with right BC being \partial_x T = t. + The analytical solution is t*x. + """ + case_dir = "foam/" + times = get_foam_times(case_dir, string=True)[1:] + + for time in times: + coords = dict(zip(("x", "y", "z"), ff.readof.readmesh(case_dir))) + + temp = ff.readof.readscalar(case_dir, time, "T") + + temp_ref = coords["x"] * np.float64(time) + + temp_diff_max = np.argmax(abs(temp - temp_ref)) + np.testing.assert_allclose( + temp_ref, + temp, + rtol=1e-7, + atol=1e-12, + err_msg=( + f"Max diff ({time}): {abs(temp - temp_ref).max()} " + f"{temp[temp_diff_max]} {temp_ref[temp_diff_max]}" + ), + ) diff --git a/test/tests/bcs/fixed_gradient_pp/tests b/test/tests/bcs/fixed_gradient_pp/tests new file mode 100644 index 00000000..885533fd --- /dev/null +++ b/test/tests/bcs/fixed_gradient_pp/tests @@ -0,0 +1,18 @@ +[Tests] + [foam_bc_fixed_gradient_pp] + [setup] + type = RunCommand + command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam"' + [] + [run] + type = RunApp + input = main.i + prereq = foam_bc_fixed_gradient_pp/setup + [] + [verify] + type = PythonUnitTest + input = test.py + prereq = foam_bc_fixed_gradient_pp/run + [] + [] +[] diff --git a/test/tests/bcs/fixed_value/test.py b/test/tests/bcs/fixed_value/test.py index c7961bac..93782320 100644 --- a/test/tests/bcs/fixed_value/test.py +++ b/test/tests/bcs/fixed_value/test.py @@ -1,9 +1,9 @@ """Tests for imposing BCs in OpenFOAM using MOOSE input file syntax""" import unittest + import fluidfoam as ff import numpy as np - from read_hippo_data import get_foam_times # pylint: disable=E0401 @@ -32,7 +32,13 @@ def test_fixed_value(self): ) * np.float64(time) temp_diff_max = np.argmax(abs(temp - temp_ref)) - assert np.allclose(temp_ref, temp, rtol=1e-7, atol=1e-12), ( - f"Max diff {boundary} ({time}): {abs(temp - temp_ref).max()} " - f"{temp[temp_diff_max]} {temp_ref[temp_diff_max]}" + np.testing.assert_allclose( + temp_ref, + temp, + rtol=1e-7, + atol=1e-12, + err_msg=( + f"Max diff ({time}): {abs(temp - temp_ref).max()} " + f"{temp[temp_diff_max]} {temp_ref[temp_diff_max]}" + ), ) diff --git a/test/tests/bcs/fixed_value/tests b/test/tests/bcs/fixed_value/tests index 948c7de2..6b0967ee 100644 --- a/test/tests/bcs/fixed_value/tests +++ b/test/tests/bcs/fixed_value/tests @@ -8,7 +8,6 @@ type = RunApp input = main.i prereq = foam_bc_action_test/setup - allow_warnings = true [] [verify] type = PythonUnitTest @@ -21,7 +20,6 @@ min_parallel=4 max_parallel=4 prereq = foam_bc_action_test/setup - allow_warnings = true [] [prep_verify] type = RunCommand diff --git a/test/tests/bcs/fixed_value_pp/foam/0/T b/test/tests/bcs/fixed_value_pp/foam/0/T new file mode 100644 index 00000000..65a14be8 --- /dev/null +++ b/test/tests/bcs/fixed_value_pp/foam/0/T @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0.1; + +boundaryField +{ + left + { + type fixedValue; + value uniform 0.; + } + right + { + type fixedValue; + value uniform 0.; + } + top + { + type fixedValue; + value uniform 0.; + } + bottom + { + type fixedValue; + value uniform 0.; + } + back + { + type fixedValue; + value uniform 0.; + } + front + { + type fixedValue; + value uniform 0.; + } +} + + +// ************************************************************************* // diff --git a/test/tests/bcs/fixed_value_pp/foam/constant/physicalProperties b/test/tests/bcs/fixed_value_pp/foam/constant/physicalProperties new file mode 100644 index 00000000..96a14c15 --- /dev/null +++ b/test/tests/bcs/fixed_value_pp/foam/constant/physicalProperties @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object physicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heSolidThermo; + mixture pureMixture; + transport constIsoSolid; + thermo eConst; + equationOfState rhoConst; + specie specie; + energy sensibleInternalEnergy; +} + +mixture +{ + specie + { + molWeight 1; + } + thermodynamics + { + Cv 1; // Specific heat capacity [J/(kg·K)] + Hf 1; // Heat of formation [J/kg] + Tref 0; + } + transport + { + kappa 1; // Thermal conductivity [W/(m·K)] + } + equationOfState + { + rho 1; // Density [kg/m^3] + } +} + + +// ************************************************************************* // diff --git a/test/tests/bcs/fixed_value_pp/foam/system/blockMeshDict b/test/tests/bcs/fixed_value_pp/foam/system/blockMeshDict new file mode 100644 index 00000000..face9ea6 --- /dev/null +++ b/test/tests/bcs/fixed_value_pp/foam/system/blockMeshDict @@ -0,0 +1,85 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +vertices +( + ( 0.0 0.0 0.0 ) + ( 10.0 0.0 0.0 ) + ( 10.0 1.0 0.0 ) + ( 0.0 1.0 0.0 ) + + ( 0.0 0.0 1.0) + ( 10.0 0.0 1.0) + ( 10.0 1.0 1.0) + ( 0.0 1.0 1.0) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (50 1 1) simpleGrading (25 1 1) +); + +boundary +( + + // interface + left + { + type wall; + faces + ( + (4 7 3 0) + ); + } + + right + { + type wall; + faces + ( + (6 5 1 2) + ); + } + + top + { + type wall; + faces + ( + (2 3 7 6) + ); + } + + front + { + type wall; + faces + ( + (3 2 1 0) + ); + } + + bottom + { + type wall; + faces + ( + (0 1 5 4) + ); + } + + back + { + type wall; + faces + ( + (4 5 6 7) + ); + } + +); diff --git a/test/tests/bcs/fixed_value_pp/foam/system/controlDict b/test/tests/bcs/fixed_value_pp/foam/system/controlDict new file mode 100644 index 00000000..cb155c26 --- /dev/null +++ b/test/tests/bcs/fixed_value_pp/foam/system/controlDict @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solver bcTestSolver; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.32; + +deltaT 0.01; + +writeControl timeStep; + +writeInterval 1; + +writeFormat ascii; + +writePrecision 20; + +writeCompression off; + +timeFormat general; + +timePrecision 20; + +runTimeModifiable true; + +// ************************************************************************* // diff --git a/test/tests/bcs/fixed_value_pp/foam/system/fvSchemes b/test/tests/bcs/fixed_value_pp/foam/system/fvSchemes new file mode 100644 index 00000000..0e534821 --- /dev/null +++ b/test/tests/bcs/fixed_value_pp/foam/system/fvSchemes @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +// ************************************************************************* // diff --git a/test/tests/bcs/fixed_value_pp/foam/system/fvSolution b/test/tests/bcs/fixed_value_pp/foam/system/fvSolution new file mode 100644 index 00000000..59db6a2a --- /dev/null +++ b/test/tests/bcs/fixed_value_pp/foam/system/fvSolution @@ -0,0 +1,61 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + rho + { + solver diagonal; + } + + rhoFinal + { + $rho; + } + + + e + { + solver PBiCGStab; + preconditioner DIC; + tolerance 1e-8; + relTol 1e-8; + } + + eFinal + { + $e; + tolerance 1e-8; + relTol 1e-8; + } +} + +PIMPLE +{ + momentumPredictor yes; + pRefCell 0; + pRefValue 0; +} + +relaxationFactors +{ + equations + { + h 1; + U 1; + } +} + +// ************************************************************************* // diff --git a/test/tests/bcs/fixed_value_pp/main.i b/test/tests/bcs/fixed_value_pp/main.i new file mode 100644 index 00000000..b1ef805d --- /dev/null +++ b/test/tests/bcs/fixed_value_pp/main.i @@ -0,0 +1,77 @@ +[Mesh] + type = FoamMesh + case = 'foam' + foam_patch = 'left right bottom top back front' +[] + +[Variables] + [dummy] + family = MONOMIAL + order = CONSTANT + initial_condition = 999 + [] +[] + +[FoamBCs] + [temp1] + type=FoamFixedValuePostprocessorBC + foam_variable = T + boundary = 'left right top' # test boundary restrictions + pp_name = T_bc1 + [] + [temp2] + type=FoamFixedValuePostprocessorBC + foam_variable = T + boundary = 'bottom front back' # test boundary restrictions + pp_name = T_bc2 + [] +[] + +[FoamVariables] + [T_shadow] + type = FoamVariableField + foam_variable = 'T' + [] + [e_shadow] + type = FoamVariableField + foam_variable = 'e' + [] + [whf_shadow] + type = FoamFunctionObject + foam_variable = 'wallHeatFlux' + [] +[] + +[Postprocessors] + [T_bc1] + type=ParsedPostprocessor + expression = '0.05 + t' + use_t = true + execute_on='TIMESTEP_BEGIN INITIAL' + [] + [T_bc2] + type=ParsedPostprocessor + expression = '0.05 + 2*t' + use_t = true + execute_on='TIMESTEP_BEGIN INITIAL' + [] +[] + +[Problem] + type = FoamProblem + # Take the boundary temperature from OpenFOAM and set it on the MOOSE mesh. +[] + +[Executioner] + type = Transient + end_time = 0.32 + [TimeSteppers] + [foam] + type = FoamTimeStepper + [] + [] +[] + +[Outputs] + exodus = true +[] diff --git a/test/tests/bcs/fixed_value_pp/test.py b/test/tests/bcs/fixed_value_pp/test.py new file mode 100644 index 00000000..3ab99c3f --- /dev/null +++ b/test/tests/bcs/fixed_value_pp/test.py @@ -0,0 +1,36 @@ +"""Tests for imposing BCs in OpenFOAM using MOOSE input file syntax""" + +import unittest + +import fluidfoam as ff +import numpy as np +from read_hippo_data import get_foam_times # pylint: disable=E0401 + + +class TestFoamBCFixedValuePostprocessor(unittest.TestCase): + """Test class for imposing fixed value BCs in Hippo using postprocessors.""" + + def test_fixed_value(self): + """Test case for imposing fixed value.""" + case_dir = "foam/" + boundaries = ["top", "bottom", "front", "back", "left", "right"] + times = get_foam_times(case_dir, string=True)[1:] + + for time in times: + for boundary in boundaries: + temp = ff.readof.readscalar(case_dir, time, "T", boundary=boundary) + + scale = 1.0 if boundary in ("left", "right", "top") else 2.0 + temp_ref = 0.05 + scale * np.float64(time) + + temp_diff_max = np.argmax(abs(temp - temp_ref)) + np.testing.assert_allclose( + temp_ref, + temp, + rtol=1e-7, + atol=1e-12, + err_msg=( + f"Max diff ({time}): {abs(temp - temp_ref).max()} " + f"{temp[temp_diff_max]} {temp_ref}" + ), + ) diff --git a/test/tests/bcs/fixed_value_pp/tests b/test/tests/bcs/fixed_value_pp/tests new file mode 100644 index 00000000..f33754ad --- /dev/null +++ b/test/tests/bcs/fixed_value_pp/tests @@ -0,0 +1,18 @@ +[Tests] + [foam_bc_action_test] + [setup] + type = RunCommand + command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam"' + [] + [run] + type = RunApp + input = main.i + prereq = foam_bc_action_test/setup + [] + [verify] + type = PythonUnitTest + input = test.py + prereq = foam_bc_action_test/run + [] + [] +[] diff --git a/test/tests/bcs/laplace_fixed_gradient/main.i b/test/tests/bcs/laplace_fixed_gradient/main.i index 5adb3c53..f2fd450c 100644 --- a/test/tests/bcs/laplace_fixed_gradient/main.i +++ b/test/tests/bcs/laplace_fixed_gradient/main.i @@ -23,7 +23,6 @@ type=FoamFixedGradientBC foam_variable = T boundary = 'right' - diffusivity_coefficient = kappa [] [] @@ -31,7 +30,7 @@ [T_flux] type = ParsedAux variable = T_flux - expression = '2*t' + expression = 't' use_xyzt = true execute_on = 'INITIAL TIMESTEP_BEGIN' [] diff --git a/test/tests/bcs/laplace_fixed_gradient/test.py b/test/tests/bcs/laplace_fixed_gradient/test.py index 98b48ce7..34225a55 100644 --- a/test/tests/bcs/laplace_fixed_gradient/test.py +++ b/test/tests/bcs/laplace_fixed_gradient/test.py @@ -1,17 +1,22 @@ """Tests for imposing BCs in OpenFOAM using MOOSE input file syntax""" import unittest + import fluidfoam as ff import numpy as np - from read_hippo_data import get_foam_times # pylint: disable=E0401 class TestFoamBCFixedGradient(unittest.TestCase): - """Test class for imposing fixed value BCs in Hippo.""" + """Test class for imposing fixed gradient BCs in Hippo.""" def test_fixed_gradient_x(self): - """Test case for imposing fixed value.""" + """ + Test case for imposing fixed gradient BC. + + Solves laplace equation at each time step with right BC being \partial_x T = t. + The analytical solution is t*x. + """ case_dir = "foam/" times = get_foam_times(case_dir, string=True)[1:] @@ -23,7 +28,13 @@ def test_fixed_gradient_x(self): temp_ref = coords["x"] * np.float64(time) temp_diff_max = np.argmax(abs(temp - temp_ref)) - assert np.allclose(temp_ref, temp, rtol=1e-7, atol=1e-12), ( - f"Max diff ({time}): {abs(temp - temp_ref).max()} " - f"{temp[temp_diff_max]} {temp_ref[temp_diff_max]}" + np.testing.assert_allclose( + temp_ref, + temp, + rtol=1e-7, + atol=1e-12, + err_msg=( + f"Max diff ({time}): {abs(temp - temp_ref).max()} " + f"{temp[temp_diff_max]} {temp_ref[temp_diff_max]}" + ), ) diff --git a/test/tests/bcs/laplace_fixed_gradient/tests b/test/tests/bcs/laplace_fixed_gradient/tests index ab7bf175..879f5428 100644 --- a/test/tests/bcs/laplace_fixed_gradient/tests +++ b/test/tests/bcs/laplace_fixed_gradient/tests @@ -4,19 +4,10 @@ type = RunCommand command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam"' [] - [diffusivity_coeff_err] - type = RunException - input = main.i - prereq = foam_bc_fixed_gradient/setup - expect_err = "Diffusivity coefficient 'kappa1' not a Foam volScalarField" - cli_args = 'FoamBCs/T_flux/diffusivity_coefficient=kappa1' - allow_warnings = true - [] [run] type = RunApp input = main.i prereq = foam_bc_fixed_gradient/setup - allow_warnings = true [] [verify] type = PythonUnitTest diff --git a/test/tests/bcs/laplace_flux_bc/foam/0/T b/test/tests/bcs/laplace_flux_bc/foam/0/T new file mode 100644 index 00000000..6da637de --- /dev/null +++ b/test/tests/bcs/laplace_flux_bc/foam/0/T @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0.; + +boundaryField +{ + left + { + type fixedValue; + value uniform 0.; + } + right + { + type fixedGradient; + gradient uniform 1.; + } + top + { + type zeroGradient; + } + front + { + type zeroGradient; + } + bottom + { + type zeroGradient; + } + back + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/test/tests/bcs/laplace_flux_bc/foam/constant/physicalProperties b/test/tests/bcs/laplace_flux_bc/foam/constant/physicalProperties new file mode 100644 index 00000000..6dab7b1c --- /dev/null +++ b/test/tests/bcs/laplace_flux_bc/foam/constant/physicalProperties @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object physicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heSolidThermo; + mixture pureMixture; + transport constIsoSolid; + thermo eConst; + equationOfState rhoConst; + specie specie; + energy sensibleInternalEnergy; +} + +mixture +{ + specie + { + molWeight 1; + } + thermodynamics + { + Cv 1; // Specific heat capacity [J/(kg·K)] + Hf 1; // Heat of formation [J/kg] + Tref 0; + } + transport + { + kappa 2.; // Thermal conductivity [W/(m·K)] + } + equationOfState + { + rho 1; // Density [kg/m^3] + } +} + + +// ************************************************************************* // diff --git a/test/tests/bcs/laplace_flux_bc/foam/system/blockMeshDict b/test/tests/bcs/laplace_flux_bc/foam/system/blockMeshDict new file mode 100644 index 00000000..face9ea6 --- /dev/null +++ b/test/tests/bcs/laplace_flux_bc/foam/system/blockMeshDict @@ -0,0 +1,85 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +vertices +( + ( 0.0 0.0 0.0 ) + ( 10.0 0.0 0.0 ) + ( 10.0 1.0 0.0 ) + ( 0.0 1.0 0.0 ) + + ( 0.0 0.0 1.0) + ( 10.0 0.0 1.0) + ( 10.0 1.0 1.0) + ( 0.0 1.0 1.0) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (50 1 1) simpleGrading (25 1 1) +); + +boundary +( + + // interface + left + { + type wall; + faces + ( + (4 7 3 0) + ); + } + + right + { + type wall; + faces + ( + (6 5 1 2) + ); + } + + top + { + type wall; + faces + ( + (2 3 7 6) + ); + } + + front + { + type wall; + faces + ( + (3 2 1 0) + ); + } + + bottom + { + type wall; + faces + ( + (0 1 5 4) + ); + } + + back + { + type wall; + faces + ( + (4 5 6 7) + ); + } + +); diff --git a/test/tests/bcs/laplace_flux_bc/foam/system/controlDict b/test/tests/bcs/laplace_flux_bc/foam/system/controlDict new file mode 100644 index 00000000..89301ab0 --- /dev/null +++ b/test/tests/bcs/laplace_flux_bc/foam/system/controlDict @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solver bcTestSolver; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 32.; + +deltaT 1.; + +writeControl timeStep; + +writeInterval 1; + +writeFormat ascii; + +writePrecision 20; + +writeCompression off; + +timeFormat general; + +timePrecision 20; + +runTimeModifiable true; + +// ************************************************************************* // diff --git a/test/tests/bcs/laplace_flux_bc/foam/system/fvSchemes b/test/tests/bcs/laplace_flux_bc/foam/system/fvSchemes new file mode 100644 index 00000000..a24aaf80 --- /dev/null +++ b/test/tests/bcs/laplace_flux_bc/foam/system/fvSchemes @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +// ************************************************************************* // diff --git a/test/tests/bcs/laplace_flux_bc/foam/system/fvSolution b/test/tests/bcs/laplace_flux_bc/foam/system/fvSolution new file mode 100644 index 00000000..639b272d --- /dev/null +++ b/test/tests/bcs/laplace_flux_bc/foam/system/fvSolution @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + rho + { + solver diagonal; + } + + rhoFinal + { + $rho; + } + + + e + { + solver PBiCGStab; + preconditioner DIC; + tolerance 1e-15; + relTol 1e-15; + } + + eFinal + { + $e; + tolerance 1e-15; + relTol 1e-15; + } +} + +PIMPLE +{ +} + +// ************************************************************************* // diff --git a/test/tests/bcs/laplace_flux_bc/main.i b/test/tests/bcs/laplace_flux_bc/main.i new file mode 100644 index 00000000..ed85d1d7 --- /dev/null +++ b/test/tests/bcs/laplace_flux_bc/main.i @@ -0,0 +1,55 @@ +[Mesh] + type = FoamMesh + case = 'foam' + foam_patch = 'left right' +[] + +[Variables] + [dummy] + family = MONOMIAL + order = CONSTANT + initial_condition = 999 + [] +[] + +[FoamBCs] + [T_value] + type=FoamFixedValueBC + foam_variable = T + initial_condition = 0. + boundary = 'left' + [] + [T_flux] + type=FoamDiffusionFluxBC + foam_variable = T + boundary = 'right' + [] +[] + +[AuxKernels] + [T_flux] + type = ParsedAux + variable = T_flux + expression = '2*t' + use_xyzt = true + execute_on = 'INITIAL TIMESTEP_BEGIN' + [] +[] + +[Problem] + type = FoamProblem +[] + +[Executioner] + type = Transient + end_time = 32 + [TimeSteppers] + [foam] + type = FoamTimeStepper + [] + [] +[] + +[Outputs] + exodus = true +[] diff --git a/test/tests/bcs/laplace_flux_bc/test.py b/test/tests/bcs/laplace_flux_bc/test.py new file mode 100644 index 00000000..211943a7 --- /dev/null +++ b/test/tests/bcs/laplace_flux_bc/test.py @@ -0,0 +1,41 @@ +"""Tests for imposing BCs in OpenFOAM using MOOSE input file syntax""" + +import unittest + +import fluidfoam as ff +import numpy as np +from read_hippo_data import get_foam_times # pylint: disable=E0401 + + +class TestFoamBCDiffusionFlux(unittest.TestCase): + """Test class for imposing flux BCs in Hippo.""" + + def test_diffusion_flux_x(self): + """ + Test case for imposing diffusion flux BCs. + + Solves laplace equation at each time step with right BC being f\partial_x T = 2t + where k = 2. + The analytical solution is t*x. + """ + case_dir = "foam/" + times = get_foam_times(case_dir, string=True)[1:] + + for time in times: + coords = dict(zip(("x", "y", "z"), ff.readof.readmesh(case_dir))) + + temp = ff.readof.readscalar(case_dir, time, "T") + + temp_ref = coords["x"] * np.float64(time) + + temp_diff_max = np.argmax(abs(temp - temp_ref)) + np.testing.assert_allclose( + temp_ref, + temp, + rtol=1e-7, + atol=1e-12, + err_msg=( + f"Max diff ({time}): {abs(temp - temp_ref).max()} " + f"{temp[temp_diff_max]} {temp_ref[temp_diff_max]}" + ), + ) diff --git a/test/tests/bcs/laplace_flux_bc/tests b/test/tests/bcs/laplace_flux_bc/tests new file mode 100644 index 00000000..4a84549c --- /dev/null +++ b/test/tests/bcs/laplace_flux_bc/tests @@ -0,0 +1,36 @@ +[Tests] + [foam_bc_diffusion_flux] + [setup] + type = RunCommand + command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam"' + [] + [check_invalid_diffusivity] + type = RunException + input = main.i + prereq = foam_bc_diffusion_flux/setup + cli_args ='FoamBCs/T_flux/diffusivity=kappa1' + expect_err = "Diffusivity 'kappa1' not a Foam volScalarField" + [] + [run] + type = RunApp + input = main.i + prereq = foam_bc_diffusion_flux/setup + [] + [verify] + type = PythonUnitTest + input = test.py + prereq = foam_bc_diffusion_flux/run + [] + [run_diffusivity] + type = RunApp + input = main.i + prereq = foam_bc_diffusion_flux/setup + cli_args ='FoamBCs/T_flux/diffusivity=Cv AuxKernels/T_flux/expression=t' + [] + [verify_diffusivity] + type = PythonUnitTest + input = test.py + prereq = foam_bc_diffusion_flux/run + [] + [] +[] diff --git a/test/tests/bcs/mass_flow_rate/foam/0/T b/test/tests/bcs/mass_flow_rate/foam/0/T new file mode 100644 index 00000000..f8312bb2 --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/foam/0/T @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0.1; + +boundaryField +{ + left + { + type calculated; + value uniform 0.; + } + right + { + type calculated; + value uniform 0.; + } + top + { + type calculated; + value uniform 0.; + } + bottom + { + type calculated; + value uniform 0.; + } + back + { + type calculated; + value uniform 0.; + } + front + { + type calculated; + value uniform 0.; + } +} + + +// ************************************************************************* // diff --git a/test/tests/bcs/mass_flow_rate/foam/0/U b/test/tests/bcs/mass_flow_rate/foam/0/U new file mode 100644 index 00000000..d23654bb --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/foam/0/U @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 1 -1 0 0 0 0 ]; + +internalField uniform (2 -1 0); + +boundaryField +{ + + ".*" + { + type fixedValue; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/test/tests/bcs/mass_flow_rate/foam/0/p b/test/tests/bcs/mass_flow_rate/foam/0/p new file mode 100644 index 00000000..0d00fc2f --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/foam/0/p @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 1 -1 -2 0 0 0 0 ]; + +internalField uniform 0; + +boundaryField +{ + ".*" + { + type calculated; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/test/tests/bcs/mass_flow_rate/foam/0/p_rgh b/test/tests/bcs/mass_flow_rate/foam/0/p_rgh new file mode 100644 index 00000000..cfc89a8c --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/foam/0/p_rgh @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 1 -1 -2 0 0 0 0 ]; + +internalField uniform 0; + +boundaryField +{ + ".*" + { + type fixedValue; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/test/tests/bcs/mass_flow_rate/foam/0/rho b/test/tests/bcs/mass_flow_rate/foam/0/rho new file mode 100644 index 00000000..d30a04dc --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/foam/0/rho @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object rho; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -3 0 0 0 0 0]; + +internalField uniform 1; + +boundaryField +{ + left + { + type calculated; + value uniform 1; + } + right + { + type calculated; + value uniform 1; + } + top + { + type calculated; + value uniform 1; + } + front + { + type calculated; + value uniform 1; + } + bottom + { + type calculated; + value uniform 1; + } + back + { + type calculated; + value uniform 1; + } +} + + +// ************************************************************************* // diff --git a/test/tests/bcs/mass_flow_rate/foam/constant/g b/test/tests/bcs/mass_flow_rate/foam/constant/g new file mode 100644 index 00000000..8af96f3a --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/foam/constant/g @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value (0 0 0); + + +// ************************************************************************* // diff --git a/test/tests/bcs/mass_flow_rate/foam/constant/momentumTransport b/test/tests/bcs/mass_flow_rate/foam/constant/momentumTransport new file mode 100644 index 00000000..0416f1a9 --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/foam/constant/momentumTransport @@ -0,0 +1,18 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object RASProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + +// ************************************************************************* // diff --git a/test/tests/bcs/mass_flow_rate/foam/constant/physicalProperties b/test/tests/bcs/mass_flow_rate/foam/constant/physicalProperties new file mode 100644 index 00000000..8a4c6a29 --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/foam/constant/physicalProperties @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object physicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heRhoThermo; + mixture pureMixture; + transport const; + thermo hConst; + equationOfState rhoConst; + specie specie; + energy sensibleEnthalpy; +} + +mixture +{ + specie + { + molWeight 1; + } + thermodynamics + { + Cp 1; // Specific heat capacity [J/(kg·K)] + Hf 1; // Heat of formation [J/kg] + Tref 0; + } + transport + { + kappa 1; // Thermal conductivity [W/(m·K)] + mu 1.; + } + equationOfState + { + rho 0.5; // Density [kg/m^3] + } +} + + +// ************************************************************************* // diff --git a/test/tests/bcs/mass_flow_rate/foam/system/blockMeshDict b/test/tests/bcs/mass_flow_rate/foam/system/blockMeshDict new file mode 100644 index 00000000..1adab343 --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/foam/system/blockMeshDict @@ -0,0 +1,85 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +vertices +( + ( 0.0 0.0 0.0 ) + ( 10.0 0.0 0.0 ) + ( 10.0 1.0 0.0 ) + ( 0.0 1.0 0.0 ) + + ( 0.0 0.0 1.0) + ( 10.0 0.0 1.0) + ( 10.0 1.0 1.0) + ( 0.0 1.0 1.0) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (50 2 2) simpleGrading (25 1 1) +); + +boundary +( + + // interface + left + { + type wall; + faces + ( + (4 7 3 0) + ); + } + + right + { + type wall; + faces + ( + (6 5 1 2) + ); + } + + top + { + type wall; + faces + ( + (2 3 7 6) + ); + } + + front + { + type wall; + faces + ( + (3 2 1 0) + ); + } + + bottom + { + type wall; + faces + ( + (0 1 5 4) + ); + } + + back + { + type wall; + faces + ( + (4 5 6 7) + ); + } + +); diff --git a/test/tests/bcs/mass_flow_rate/foam/system/controlDict b/test/tests/bcs/mass_flow_rate/foam/system/controlDict new file mode 100644 index 00000000..4e2baf59 --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/foam/system/controlDict @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solver postprocessorTestSolver; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.32; + +deltaT 0.01; + +writeControl timeStep; + +writeInterval 1; + +writeFormat ascii; + +writePrecision 20; + +writeCompression off; + +timeFormat general; + +timePrecision 20; + +runTimeModifiable true; + +// ************************************************************************* // diff --git a/test/tests/bcs/mass_flow_rate/foam/system/decomposeParDict b/test/tests/bcs/mass_flow_rate/foam/system/decomposeParDict new file mode 100644 index 00000000..0204a6b9 --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/foam/system/decomposeParDict @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "system"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 2; + +method simple; + +simpleCoeffs +{ + n (2 1 1); +} + +hierarchicalCoeffs +{ + n (1 1 1); + order xyz; +} + +manualCoeffs +{ + dataFile ""; +} + +distributed no; + +roots ( ); + + +// ************************************************************************* // diff --git a/test/tests/bcs/mass_flow_rate/foam/system/fvSchemes b/test/tests/bcs/mass_flow_rate/foam/system/fvSchemes new file mode 100644 index 00000000..787f3b83 --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/foam/system/fvSchemes @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + + div(phi,U) Gauss linear; + div(phi,K) Gauss linear; + div(phi,h) Gauss linear; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +// ************************************************************************* // diff --git a/test/tests/bcs/mass_flow_rate/foam/system/fvSolution b/test/tests/bcs/mass_flow_rate/foam/system/fvSolution new file mode 100644 index 00000000..61143b21 --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/foam/system/fvSolution @@ -0,0 +1,61 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + rho + { + solver diagonal; + } + + rhoFinal + { + $rho; + } + + + "(U|h|p_rgh)" + { + solver PBiCGStab; + preconditioner DILU; + tolerance 1e-8; + relTol 1e-8; + } + + "(U|h|p_rgh)Final" + { + $U; + tolerance 1e-8; + relTol 1e-8; + } +} + +PIMPLE +{ + momentumPredictor yes; + pRefCell 0; + pRefValue 0; +} + +relaxationFactors +{ + equations + { + h 1; + U 1; + } +} + +// ************************************************************************* // diff --git a/test/tests/bcs/mass_flow_rate/gold/main_out.csv b/test/tests/bcs/mass_flow_rate/gold/main_out.csv new file mode 100644 index 00000000..bb1c32b8 --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/gold/main_out.csv @@ -0,0 +1,34 @@ +time,m_dot,pp +0,0,0 +0.01,-0.01,0.01 +0.02,-0.02,0.02 +0.03,-0.03,0.03 +0.04,-0.04,0.04 +0.05,-0.05,0.05 +0.06,-0.06,0.06 +0.07,-0.07,0.07 +0.08,-0.08,0.08 +0.09,-0.09,0.09 +0.1,-0.1,0.1 +0.11,-0.11,0.11 +0.12,-0.12,0.12 +0.13,-0.13,0.13 +0.14,-0.14,0.14 +0.15,-0.15,0.15 +0.16,-0.16,0.16 +0.17,-0.17,0.17 +0.18,-0.18,0.18 +0.19,-0.19,0.19 +0.2,-0.2,0.2 +0.21,-0.21,0.21 +0.22,-0.22,0.22 +0.23,-0.23,0.23 +0.24,-0.24,0.24 +0.25,-0.25,0.25 +0.26,-0.26,0.26 +0.27,-0.27,0.27 +0.28,-0.28,0.28 +0.29,-0.29,0.29 +0.3,-0.3,0.3 +0.31,-0.31,0.31 +0.32,-0.32,0.32 diff --git a/test/tests/bcs/mass_flow_rate/main.i b/test/tests/bcs/mass_flow_rate/main.i new file mode 100644 index 00000000..6ae258c2 --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/main.i @@ -0,0 +1,48 @@ +[Mesh] + type = FoamMesh + case = 'foam' + foam_patch = 'left right bottom top back front' +[] + +[FoamBCs] + [temp1] + type=FoamMassFlowRateInletBC + boundary = 'left' # test boundary restrictions + pp_name = pp + [] +[] + +[Postprocessors] + [pp] + type = ParsedPostprocessor + expression = 't' + use_t = true + execute_on = TIMESTEP_BEGIN + [] + [m_dot] + type = FoamSideAdvectiveFluxIntegral + boundary = left + foam_scalar = rho + [] +[] + + +[Problem] + type = FoamProblem + # Take the boundary temperature from OpenFOAM and set it on the MOOSE mesh. +[] + +[Executioner] + type = Transient + end_time = 0.32 + [TimeSteppers] + [foam] + type = FoamTimeStepper + [] + [] +[] + +[Outputs] + exodus = true + csv=true +[] diff --git a/test/tests/bcs/mass_flow_rate/tests b/test/tests/bcs/mass_flow_rate/tests new file mode 100644 index 00000000..2f51d581 --- /dev/null +++ b/test/tests/bcs/mass_flow_rate/tests @@ -0,0 +1,14 @@ +[Tests] + [mass_flow_rate] + [setup] + type = RunCommand + command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam"' + [] + [run] + type = CSVDiff + input = main.i + prereq = mass_flow_rate/setup + csvdiff = main_out.csv + [] + [] +[] diff --git a/test/tests/bcs/receiver_pp/foam/0/T b/test/tests/bcs/receiver_pp/foam/0/T new file mode 100644 index 00000000..6da637de --- /dev/null +++ b/test/tests/bcs/receiver_pp/foam/0/T @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 0.; + +boundaryField +{ + left + { + type fixedValue; + value uniform 0.; + } + right + { + type fixedGradient; + gradient uniform 1.; + } + top + { + type zeroGradient; + } + front + { + type zeroGradient; + } + bottom + { + type zeroGradient; + } + back + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/test/tests/bcs/receiver_pp/foam/constant/physicalProperties b/test/tests/bcs/receiver_pp/foam/constant/physicalProperties new file mode 100644 index 00000000..6dab7b1c --- /dev/null +++ b/test/tests/bcs/receiver_pp/foam/constant/physicalProperties @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object physicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heSolidThermo; + mixture pureMixture; + transport constIsoSolid; + thermo eConst; + equationOfState rhoConst; + specie specie; + energy sensibleInternalEnergy; +} + +mixture +{ + specie + { + molWeight 1; + } + thermodynamics + { + Cv 1; // Specific heat capacity [J/(kg·K)] + Hf 1; // Heat of formation [J/kg] + Tref 0; + } + transport + { + kappa 2.; // Thermal conductivity [W/(m·K)] + } + equationOfState + { + rho 1; // Density [kg/m^3] + } +} + + +// ************************************************************************* // diff --git a/test/tests/bcs/receiver_pp/foam/system/blockMeshDict b/test/tests/bcs/receiver_pp/foam/system/blockMeshDict new file mode 100644 index 00000000..face9ea6 --- /dev/null +++ b/test/tests/bcs/receiver_pp/foam/system/blockMeshDict @@ -0,0 +1,85 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +vertices +( + ( 0.0 0.0 0.0 ) + ( 10.0 0.0 0.0 ) + ( 10.0 1.0 0.0 ) + ( 0.0 1.0 0.0 ) + + ( 0.0 0.0 1.0) + ( 10.0 0.0 1.0) + ( 10.0 1.0 1.0) + ( 0.0 1.0 1.0) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (50 1 1) simpleGrading (25 1 1) +); + +boundary +( + + // interface + left + { + type wall; + faces + ( + (4 7 3 0) + ); + } + + right + { + type wall; + faces + ( + (6 5 1 2) + ); + } + + top + { + type wall; + faces + ( + (2 3 7 6) + ); + } + + front + { + type wall; + faces + ( + (3 2 1 0) + ); + } + + bottom + { + type wall; + faces + ( + (0 1 5 4) + ); + } + + back + { + type wall; + faces + ( + (4 5 6 7) + ); + } + +); diff --git a/test/tests/bcs/receiver_pp/foam/system/controlDict b/test/tests/bcs/receiver_pp/foam/system/controlDict new file mode 100644 index 00000000..89301ab0 --- /dev/null +++ b/test/tests/bcs/receiver_pp/foam/system/controlDict @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 10 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solver bcTestSolver; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 32.; + +deltaT 1.; + +writeControl timeStep; + +writeInterval 1; + +writeFormat ascii; + +writePrecision 20; + +writeCompression off; + +timeFormat general; + +timePrecision 20; + +runTimeModifiable true; + +// ************************************************************************* // diff --git a/test/tests/bcs/receiver_pp/foam/system/fvSchemes b/test/tests/bcs/receiver_pp/foam/system/fvSchemes new file mode 100644 index 00000000..a24aaf80 --- /dev/null +++ b/test/tests/bcs/receiver_pp/foam/system/fvSchemes @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +// ************************************************************************* // diff --git a/test/tests/bcs/receiver_pp/foam/system/fvSolution b/test/tests/bcs/receiver_pp/foam/system/fvSolution new file mode 100644 index 00000000..639b272d --- /dev/null +++ b/test/tests/bcs/receiver_pp/foam/system/fvSolution @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 12 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + rho + { + solver diagonal; + } + + rhoFinal + { + $rho; + } + + + e + { + solver PBiCGStab; + preconditioner DIC; + tolerance 1e-15; + relTol 1e-15; + } + + eFinal + { + $e; + tolerance 1e-15; + relTol 1e-15; + } +} + +PIMPLE +{ +} + +// ************************************************************************* // diff --git a/test/tests/bcs/receiver_pp/main.i b/test/tests/bcs/receiver_pp/main.i new file mode 100644 index 00000000..d1ccaf7c --- /dev/null +++ b/test/tests/bcs/receiver_pp/main.i @@ -0,0 +1,47 @@ +[Mesh] + type = FoamMesh + case = 'foam' + foam_patch = 'left right' +[] + +[Variables] + [dummy] + family = MONOMIAL + order = CONSTANT + initial_condition = 999 + [] +[] + +[FoamBCs] + [T_value] + type=FoamFixedValuePostprocessorBC + foam_variable = T + default = 0. + boundary = 'left' + [] + [T_flux] + type=FoamDiffusionFluxPostprocessorBC + foam_variable = T + boundary = 'right' + default=2 + [] +[] + + +[Problem] + type = FoamProblem +[] + +[Executioner] + type = Transient + end_time = 1 + [TimeSteppers] + [foam] + type = FoamTimeStepper + [] + [] +[] + +[Outputs] + exodus = true +[] diff --git a/test/tests/bcs/receiver_pp/test.py b/test/tests/bcs/receiver_pp/test.py new file mode 100644 index 00000000..7761bfed --- /dev/null +++ b/test/tests/bcs/receiver_pp/test.py @@ -0,0 +1,37 @@ +"""Tests for imposing BCs in OpenFOAM using MOOSE input file syntax""" + +import unittest + +import fluidfoam as ff +import numpy as np + + +class TestFoamBCFixedGradient(unittest.TestCase): + """Test class for imposing fixed value BCs in Hippo.""" + + def test_diffusion_flux_x(self): + """ + Test case for imposing diffusion flux BCs using the default value of the + underlying reciever. + + Solves laplace equation with right BC being \partial_x T = 1. + The analytical solution is x. + """ + case_dir = "foam/" + time = "1" + coords = dict(zip(("x", "y", "z"), ff.readof.readmesh(case_dir))) + + temp = ff.readof.readscalar(case_dir, time, "T") + + temp_ref = coords["x"] + temp_diff_max = np.argmax(abs(temp - temp_ref)) + np.testing.assert_allclose( + temp_ref, + temp, + rtol=1e-7, + atol=1e-12, + err_msg=( + f"Max diff ({time}): {abs(temp - temp_ref).max()} " + f"{temp[temp_diff_max]} {temp_ref[temp_diff_max]}" + ), + ) diff --git a/test/tests/bcs/receiver_pp/tests b/test/tests/bcs/receiver_pp/tests new file mode 100644 index 00000000..5ad5468b --- /dev/null +++ b/test/tests/bcs/receiver_pp/tests @@ -0,0 +1,37 @@ +[Tests] + [receiver_pp] + requirement = "Tests the under-the-hood reciever in the Postprocessor BCs when using the default parameter" + [setup] + type = RunCommand + command = 'bash -c "foamCleanCase -case foam && blockMesh -case foam"' + [] + [diffusivity_coeff_err] + type = RunException + input = main.i + prereq = receiver_pp/setup + expect_err = "Diffusivity 'kappa1' not a Foam volScalarField" + cli_args = 'FoamBCs/T_flux/diffusivity=kappa1' + [] + [run] + type = RunApp + input = main.i + prereq = receiver_pp/setup + [] + [verify] + type = PythonUnitTest + input = test.py + prereq = receiver_pp/run + [] + [run_diffusivity_cv] + type = RunApp + input = main.i + cli_args = "FoamBCs/T_flux/diffusivity='Cv' FoamBCs/T_flux/default=1" + prereq = receiver_pp/verify + [] + [verify_diffusivity_cv] + type = PythonUnitTest + input = test.py + prereq = receiver_pp/run_diffusivity_cv + [] + [] +[] diff --git a/test/tests/fixed-point/flow_over_heated_plate/fluid.i b/test/tests/fixed-point/flow_over_heated_plate/fluid.i index dd4178ff..f937c25e 100644 --- a/test/tests/fixed-point/flow_over_heated_plate/fluid.i +++ b/test/tests/fixed-point/flow_over_heated_plate/fluid.i @@ -22,9 +22,9 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = 'T' - diffusivity_coefficient = kappa + initial_condition = 0 [] [] diff --git a/test/tests/fixed-point/flow_over_heated_plate/tests b/test/tests/fixed-point/flow_over_heated_plate/tests index 567f657f..28dd8121 100644 --- a/test/tests/fixed-point/flow_over_heated_plate/tests +++ b/test/tests/fixed-point/flow_over_heated_plate/tests @@ -9,7 +9,6 @@ type = RunApp input = heated_plate-no-fixed.i prereq = 'flow_over_heated_plate_parallel/no_fixed_point/setup' - allow_warnings = true cli_args="Executioner/fixed_point_max_its=1" min_parallel=4 max_parallel=4 @@ -31,7 +30,6 @@ input = heated_plate.i prereq = 'flow_over_heated_plate_parallel/fixed_point/setup' exodiff = heated_plate_out.e - allow_warnings = true min_parallel=4 max_parallel=4 [] diff --git a/test/tests/fixed-point/function_test/tests b/test/tests/fixed-point/function_test/tests index 393c987a..78dd277a 100644 --- a/test/tests/fixed-point/function_test/tests +++ b/test/tests/fixed-point/function_test/tests @@ -9,7 +9,6 @@ input = main.i prereq = 'create_reference/setup' cli_args = 'Executioner/fixed_point_min_its=1 Executioner/fixed_point_max_its=1' - allow_warnings = true [] [copy] type = RunCommand @@ -27,7 +26,6 @@ type = RunApp input = main.i prereq = function_test/setup - allow_warnings = true [] [verify] type = PythonUnitTest diff --git a/test/tests/fixed-point/heated_plate_converge/fluid.i b/test/tests/fixed-point/heated_plate_converge/fluid.i index dd4178ff..9c0817ca 100644 --- a/test/tests/fixed-point/heated_plate_converge/fluid.i +++ b/test/tests/fixed-point/heated_plate_converge/fluid.i @@ -22,9 +22,8 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = 'T' - diffusivity_coefficient = kappa initial_condition = 0 [] [] diff --git a/test/tests/fixed-point/heated_plate_converge/tests b/test/tests/fixed-point/heated_plate_converge/tests index 6407419e..f79fa52d 100644 --- a/test/tests/fixed-point/heated_plate_converge/tests +++ b/test/tests/fixed-point/heated_plate_converge/tests @@ -9,7 +9,6 @@ input = heated_plate.i prereq = 'flow_over_heated_plate_regression/setup' exodiff = heated_plate_out.e - allow_warnings = true min_parallel=4 max_parallel=4 rel_err = 1e-4 diff --git a/test/tests/fixed-point/laplacian_fixed_gradient/fluid-openfoam.i b/test/tests/fixed-point/laplacian_fixed_gradient/fluid-openfoam.i index 8108e3be..e15c691a 100644 --- a/test/tests/fixed-point/laplacian_fixed_gradient/fluid-openfoam.i +++ b/test/tests/fixed-point/laplacian_fixed_gradient/fluid-openfoam.i @@ -14,9 +14,8 @@ [FoamBCs] [fluid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = 'T' - diffusivity_coefficient = kappa initial_condition = 0.075 [] [] diff --git a/test/tests/fixed-point/laplacian_fixed_gradient/tests b/test/tests/fixed-point/laplacian_fixed_gradient/tests index 715e0ad0..f27e79b4 100644 --- a/test/tests/fixed-point/laplacian_fixed_gradient/tests +++ b/test/tests/fixed-point/laplacian_fixed_gradient/tests @@ -9,7 +9,6 @@ input = main.i prereq = 'create_reference/setup' cli_args = 'Executioner/fixed_point_min_its=1 Executioner/fixed_point_max_its=1' - allow_warnings = true [] [copy] type = RunCommand @@ -27,7 +26,6 @@ type = RunApp input = main.i prereq = laplacian_fixed_gradient/setup - allow_warnings = true [] [verify] type = PythonUnitTest diff --git a/test/tests/fixed-point/laplacian_fixed_value/tests b/test/tests/fixed-point/laplacian_fixed_value/tests index 650015ee..bd06cf55 100644 --- a/test/tests/fixed-point/laplacian_fixed_value/tests +++ b/test/tests/fixed-point/laplacian_fixed_value/tests @@ -9,7 +9,6 @@ input = main.i prereq = 'create_reference/setup' cli_args = 'Executioner/fixed_point_min_its=1 Executioner/fixed_point_max_its=1' - allow_warnings = true [] [copy] type = RunCommand @@ -27,7 +26,6 @@ type = RunApp input = main.i prereq = laplacian_fixed_value/setup - allow_warnings = true [] [verify] type = PythonUnitTest diff --git a/test/tests/fixed-point/ode_euler/tests b/test/tests/fixed-point/ode_euler/tests index 2fbdef54..85d60ed7 100644 --- a/test/tests/fixed-point/ode_euler/tests +++ b/test/tests/fixed-point/ode_euler/tests @@ -9,7 +9,6 @@ input = main.i prereq = 'create_reference/setup' cli_args = 'Executioner/fixed_point_min_its=1 Executioner/fixed_point_max_its=1' - allow_warnings = true [] [copy] type = RunCommand @@ -27,7 +26,6 @@ type = RunApp input = main.i prereq = ode_euler/setup - allow_warnings = true [] [verify] type = PythonUnitTest diff --git a/test/tests/fixed-point/restart_heated_plate/fluid.i b/test/tests/fixed-point/restart_heated_plate/fluid.i index dd4178ff..9c0817ca 100644 --- a/test/tests/fixed-point/restart_heated_plate/fluid.i +++ b/test/tests/fixed-point/restart_heated_plate/fluid.i @@ -22,9 +22,8 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = 'T' - diffusivity_coefficient = kappa initial_condition = 0 [] [] diff --git a/test/tests/fixed-point/restart_heated_plate/tests b/test/tests/fixed-point/restart_heated_plate/tests index 80cc7921..93386941 100644 --- a/test/tests/fixed-point/restart_heated_plate/tests +++ b/test/tests/fixed-point/restart_heated_plate/tests @@ -20,7 +20,6 @@ delete_output_before_running = false exodiff = heated_plate_out.e gold_dir = '../heated_plate_converge' - allow_warnings = true min_parallel=4 max_parallel=4 [] diff --git a/test/tests/fixed-point/restep_fixed_point/fluid-openfoam.i b/test/tests/fixed-point/restep_fixed_point/fluid-openfoam.i index 34f01b1d..d1be5762 100644 --- a/test/tests/fixed-point/restep_fixed_point/fluid-openfoam.i +++ b/test/tests/fixed-point/restep_fixed_point/fluid-openfoam.i @@ -14,9 +14,8 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = 'T' - diffusivity_coefficient = kappa initial_condition = 0 [] [] diff --git a/test/tests/fixed-point/restep_fixed_point/tests b/test/tests/fixed-point/restep_fixed_point/tests index db3438ef..e4bee548 100644 --- a/test/tests/fixed-point/restep_fixed_point/tests +++ b/test/tests/fixed-point/restep_fixed_point/tests @@ -10,7 +10,6 @@ min_parallel=2 max_parallel=2 prereq = run_reference/setup - allow_warnings = true cli_args="Problem/type=FEProblem Executioner/TimeStepper/type=ConstantDT Executioner/TimeStepper/dt=0.0003125 -w" [] [copy] diff --git a/test/tests/fixed-point/unsteady_fixed_point_converge/fluid-openfoam.i b/test/tests/fixed-point/unsteady_fixed_point_converge/fluid-openfoam.i index 34f01b1d..d1be5762 100644 --- a/test/tests/fixed-point/unsteady_fixed_point_converge/fluid-openfoam.i +++ b/test/tests/fixed-point/unsteady_fixed_point_converge/fluid-openfoam.i @@ -14,9 +14,8 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = 'T' - diffusivity_coefficient = kappa initial_condition = 0 [] [] diff --git a/test/tests/fixed-point/unsteady_hc_subcycling/fluid-openfoam.i b/test/tests/fixed-point/unsteady_hc_subcycling/fluid-openfoam.i index 72685c2c..7dd98811 100644 --- a/test/tests/fixed-point/unsteady_hc_subcycling/fluid-openfoam.i +++ b/test/tests/fixed-point/unsteady_hc_subcycling/fluid-openfoam.i @@ -23,9 +23,8 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = 'T' - diffusivity_coefficient = kappa initial_condition = 0 [] [] diff --git a/test/tests/fixed-point/unsteady_hc_variable_dt/fluid-openfoam.i b/test/tests/fixed-point/unsteady_hc_variable_dt/fluid-openfoam.i index 72685c2c..7dd98811 100644 --- a/test/tests/fixed-point/unsteady_hc_variable_dt/fluid-openfoam.i +++ b/test/tests/fixed-point/unsteady_hc_variable_dt/fluid-openfoam.i @@ -23,9 +23,8 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = 'T' - diffusivity_coefficient = kappa initial_condition = 0 [] [] diff --git a/test/tests/fixed-point/unsteady_heat_conduction/fluid-openfoam.i b/test/tests/fixed-point/unsteady_heat_conduction/fluid-openfoam.i index 7367636a..f760d142 100644 --- a/test/tests/fixed-point/unsteady_heat_conduction/fluid-openfoam.i +++ b/test/tests/fixed-point/unsteady_heat_conduction/fluid-openfoam.i @@ -22,9 +22,8 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = 'T' - diffusivity_coefficient = kappa initial_condition = 0 [] [] diff --git a/test/tests/mesh/polygonal/fluid-openfoam.i b/test/tests/mesh/polygonal/fluid-openfoam.i index df47e23e..c9b86e86 100644 --- a/test/tests/mesh/polygonal/fluid-openfoam.i +++ b/test/tests/mesh/polygonal/fluid-openfoam.i @@ -14,10 +14,9 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = T initial_condition = 0 - diffusivity_coefficient = kappa [] [] diff --git a/test/tests/mesh/quadrilateral/fluid-openfoam.i b/test/tests/mesh/quadrilateral/fluid-openfoam.i index 30df6206..bb4b4853 100644 --- a/test/tests/mesh/quadrilateral/fluid-openfoam.i +++ b/test/tests/mesh/quadrilateral/fluid-openfoam.i @@ -15,10 +15,9 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = T initial_condition = 0 - diffusivity_coefficient = kappa [] [] diff --git a/test/tests/mesh/triangular/fluid-openfoam.i b/test/tests/mesh/triangular/fluid-openfoam.i index 4af1f206..ac400577 100644 --- a/test/tests/mesh/triangular/fluid-openfoam.i +++ b/test/tests/mesh/triangular/fluid-openfoam.i @@ -14,10 +14,9 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = T initial_condition = 0 - diffusivity_coefficient = kappa [] [] diff --git a/test/tests/multiapps/flow_over_heated_plate/fluid.i b/test/tests/multiapps/flow_over_heated_plate/fluid.i index 47ab7f00..873a95c0 100644 --- a/test/tests/multiapps/flow_over_heated_plate/fluid.i +++ b/test/tests/multiapps/flow_over_heated_plate/fluid.i @@ -14,10 +14,9 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = T initial_condition = 0 - diffusivity_coefficient = kappa [] [] diff --git a/test/tests/multiapps/simplified_heat_exchanger/fluid-bottom.i b/test/tests/multiapps/simplified_heat_exchanger/fluid-bottom.i index 7efc43dd..f229905a 100644 --- a/test/tests/multiapps/simplified_heat_exchanger/fluid-bottom.i +++ b/test/tests/multiapps/simplified_heat_exchanger/fluid-bottom.i @@ -6,10 +6,9 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = T initial_condition = 0 - diffusivity_coefficient = kappa [] [] diff --git a/test/tests/multiapps/simplified_heat_exchanger/fluid-top.i b/test/tests/multiapps/simplified_heat_exchanger/fluid-top.i index 110c369a..bb1cad5f 100644 --- a/test/tests/multiapps/simplified_heat_exchanger/fluid-top.i +++ b/test/tests/multiapps/simplified_heat_exchanger/fluid-top.i @@ -6,10 +6,9 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = T initial_condition = 3 - diffusivity_coefficient = kappa [] [] diff --git a/test/tests/multiapps/unsteady_heat_conduction_in_infinite_system/fluid-openfoam.i b/test/tests/multiapps/unsteady_heat_conduction_in_infinite_system/fluid-openfoam.i index 4af1f206..ac400577 100644 --- a/test/tests/multiapps/unsteady_heat_conduction_in_infinite_system/fluid-openfoam.i +++ b/test/tests/multiapps/unsteady_heat_conduction_in_infinite_system/fluid-openfoam.i @@ -14,10 +14,9 @@ [FoamBCs] [solid_heat_flux] - type = FoamFixedGradientBC + type = FoamDiffusionFluxBC foam_variable = T initial_condition = 0 - diffusivity_coefficient = kappa [] [] diff --git a/test/tests/postprocessors/side_advective_flux_integral/test.py b/test/tests/postprocessors/side_advective_flux_integral/test.py index 097f99d4..51aa8f88 100644 --- a/test/tests/postprocessors/side_advective_flux_integral/test.py +++ b/test/tests/postprocessors/side_advective_flux_integral/test.py @@ -4,7 +4,6 @@ import numpy as np - U = [2, -1, 0] RHO = 0.5 AREAS = [1.0, 10.0, 10.0] @@ -21,13 +20,17 @@ def test_advective_flux_integral(self): for i in range(3): # n indicates the outward normal relative to the coordinate direction n = -1.0 - assert np.allclose( - data[i * 3], n * RHO * U[i] * AREAS[i], atol=1e-14, rtol=1e-12 - ), f"{data[i * 3]} vs {n * RHO * U[i] * AREAS[i]}" + np.testing.assert_allclose( + data[i * 3], + n * RHO * U[i] * AREAS[i], + atol=1e-14, + rtol=1e-12, + err_msg=f"{data[i * 3]} vs {n * RHO * U[i] * AREAS[i]}", + ) - assert np.allclose(data[i * 3 + 1], 0.0, atol=1e-14, rtol=1e-12) + np.testing.assert_allclose(data[i * 3 + 1], 0.0, atol=1e-14, rtol=1e-12) n = 1.0 - assert np.allclose( + np.testing.assert_allclose( data[i * 3 + 2], n * RHO * U[i] * AREAS[i], atol=1e-14, rtol=1e-12 ) diff --git a/test/tests/postprocessors/side_advective_flux_integral/tests b/test/tests/postprocessors/side_advective_flux_integral/tests index d1258876..0c6a0e08 100644 --- a/test/tests/postprocessors/side_advective_flux_integral/tests +++ b/test/tests/postprocessors/side_advective_flux_integral/tests @@ -8,7 +8,6 @@ type = RunApp input = main.i prereq = postprocessor_test/setup - allow_warnings = true [] [verify_serial] type = PythonUnitTest @@ -19,7 +18,6 @@ type = RunApp input = main.i prereq = postprocessor_test/setup - allow_warnings = true min_parallel=2 max_parallel=2 [] @@ -32,7 +30,6 @@ type = RunException input = main.i prereq = postprocessor_test/setup - allow_warnings = true cli_args='Postprocessors/m_dot_x1/advective_velocity=U1' expect_err = "advective_velocity 'U1' not found." [] @@ -40,7 +37,6 @@ type = RunException input = main.i prereq = postprocessor_test/setup - allow_warnings = true cli_args='Postprocessors/m_dot_x1/foam_scalar=rho1' expect_err = "foam_scalar 'rho1' not found." [] diff --git a/test/tests/postprocessors/side_average/test.py b/test/tests/postprocessors/side_average/test.py index 3be266a2..ff5feef0 100644 --- a/test/tests/postprocessors/side_average/test.py +++ b/test/tests/postprocessors/side_average/test.py @@ -37,18 +37,22 @@ def test_side_average(self): tol_params = {"atol": 1e-14, "rtol": 1e-12} - assert np.allclose(data["t_avg"], T_AVG[1] * time, **tol_params) - assert np.allclose(data["t_avg_multiple"], T_AVG[1] * time, **tol_params) - assert np.allclose(data["U_avg_magnitude"], np.linalg.norm(U), **tol_params) - assert np.allclose( + np.testing.assert_allclose(data["t_avg"], T_AVG[1] * time, **tol_params) + np.testing.assert_allclose( + data["t_avg_multiple"], T_AVG[1] * time, **tol_params + ) + np.testing.assert_allclose( + data["U_avg_magnitude"], np.linalg.norm(U), **tol_params + ) + np.testing.assert_allclose( data["U_avg_magnitude_multiple"], np.linalg.norm(U), **tol_params ) - assert np.allclose(data["U_avg_normal"], U[0], **tol_params) - assert np.allclose(data["U_avg_normal_multiple"], 0.0, **tol_params) - assert np.allclose(data["U_avg_x"], U[0], **tol_params) - assert np.allclose(data["U_avg_x_multiple"], U[0], **tol_params) - assert np.allclose(data["U_avg_y"], U[1], **tol_params) - assert np.allclose(data["U_avg_y_multiple"], U[1], **tol_params) - assert np.allclose(data["U_avg_z"], U[2], **tol_params) - assert np.allclose(data["heat_flux"], time, **tol_params) - assert np.allclose(data["heat_flux_multiple"], 0.0, **tol_params) + np.testing.assert_allclose(data["U_avg_normal"], U[0], **tol_params) + np.testing.assert_allclose(data["U_avg_normal_multiple"], 0.0, **tol_params) + np.testing.assert_allclose(data["U_avg_x"], U[0], **tol_params) + np.testing.assert_allclose(data["U_avg_x_multiple"], U[0], **tol_params) + np.testing.assert_allclose(data["U_avg_y"], U[1], **tol_params) + np.testing.assert_allclose(data["U_avg_y_multiple"], U[1], **tol_params) + np.testing.assert_allclose(data["U_avg_z"], U[2], **tol_params) + np.testing.assert_allclose(data["heat_flux"], time, **tol_params) + np.testing.assert_allclose(data["heat_flux_multiple"], 0.0, **tol_params) diff --git a/test/tests/postprocessors/side_average/tests b/test/tests/postprocessors/side_average/tests index 9ab58d31..b5ca82e4 100644 --- a/test/tests/postprocessors/side_average/tests +++ b/test/tests/postprocessors/side_average/tests @@ -8,7 +8,6 @@ type = RunApp input = main.i prereq = postprocessor_test/setup - allow_warnings = true [] [verify_serial] type = PythonUnitTest @@ -19,7 +18,6 @@ type = RunApp input = main.i prereq = postprocessor_test/setup - allow_warnings = true min_parallel=2 max_parallel=2 [] diff --git a/test/tests/postprocessors/side_integrated_value/test.py b/test/tests/postprocessors/side_integrated_value/test.py index 2e9a9e58..fa2f22e1 100644 --- a/test/tests/postprocessors/side_integrated_value/test.py +++ b/test/tests/postprocessors/side_integrated_value/test.py @@ -37,29 +37,33 @@ def test_side_integrated_value(self): tol_params = {"atol": 1e-14, "rtol": 1e-12} - assert np.allclose(data["t_avg"], T_AVG[1] * time * AREAS[1], **tol_params) - assert np.allclose( + np.testing.assert_allclose( + data["t_avg"], T_AVG[1] * time * AREAS[1], **tol_params + ) + np.testing.assert_allclose( data["t_avg_multiple"], 2.0 * T_AVG[1] * time * AREAS[1], **tol_params ) - assert np.allclose( + np.testing.assert_allclose( data["U_avg_magnitude"], np.linalg.norm(U) * AREAS[2], **tol_params ) - assert np.allclose( + np.testing.assert_allclose( data["U_avg_magnitude_multiple"], 2.0 * np.linalg.norm(U) * AREAS[2], **tol_params, ) n = -1 # account for outward normal vector on the bottom - assert np.allclose(data["U_avg_normal"], n * U[1] * AREAS[1], **tol_params) - assert np.allclose(data["U_avg_normal_multiple"], 0.0, **tol_params) - assert np.allclose(data["U_avg_x"], U[0] * AREAS[2], **tol_params) - assert np.allclose( + np.testing.assert_allclose( + data["U_avg_normal"], n * U[1] * AREAS[1], **tol_params + ) + np.testing.assert_allclose(data["U_avg_normal_multiple"], 0.0, **tol_params) + np.testing.assert_allclose(data["U_avg_x"], U[0] * AREAS[2], **tol_params) + np.testing.assert_allclose( data["U_avg_x_multiple"], 2.0 * U[0] * AREAS[2], **tol_params ) - assert np.allclose(data["U_avg_y"], U[1] * AREAS[2], **tol_params) - assert np.allclose( + np.testing.assert_allclose(data["U_avg_y"], U[1] * AREAS[2], **tol_params) + np.testing.assert_allclose( data["U_avg_y_multiple"], 2.0 * U[1] * AREAS[1], **tol_params ) - assert np.allclose(data["U_avg_z"], U[2] * AREAS[2], **tol_params) - assert np.allclose(data["heat_flux"], time * AREAS[0], **tol_params) - assert np.allclose(data["heat_flux_multiple"], 0.0, **tol_params) + np.testing.assert_allclose(data["U_avg_z"], U[2] * AREAS[2], **tol_params) + np.testing.assert_allclose(data["heat_flux"], time * AREAS[0], **tol_params) + np.testing.assert_allclose(data["heat_flux_multiple"], 0.0, **tol_params) diff --git a/test/tests/postprocessors/side_integrated_value/tests b/test/tests/postprocessors/side_integrated_value/tests index edd33817..7c5e4895 100644 --- a/test/tests/postprocessors/side_integrated_value/tests +++ b/test/tests/postprocessors/side_integrated_value/tests @@ -8,7 +8,6 @@ type = RunApp input = main.i prereq = postprocessor_test/setup - allow_warnings = true [] [verify_serial] type = PythonUnitTest @@ -19,7 +18,6 @@ type = RunApp input = main.i prereq = postprocessor_test/setup - allow_warnings = true min_parallel=2 max_parallel=2 [] @@ -32,7 +30,6 @@ type = RunException input = main.i prereq = postprocessor_test/setup - allow_warnings = true cli_args='Postprocessors/t_avg/boundary=top1' expect_err = "Boundary 'top1' not found in FoamMesh." [] @@ -40,7 +37,6 @@ type = RunException input = main.i prereq = postprocessor_test/setup - allow_warnings = true cli_args='Postprocessors/t_avg/foam_variable=T1' expect_err = "No Foam scalar or vector called 'T1'." [] diff --git a/test/tests/variables/foam_variable/test.py b/test/tests/variables/foam_variable/test.py index 7bd7dbb7..0c2b89c7 100644 --- a/test/tests/variables/foam_variable/test.py +++ b/test/tests/variables/foam_variable/test.py @@ -3,8 +3,10 @@ import unittest import numpy as np - -from read_hippo_data import read_moose_exodus_data, get_exodus_times # pylint: disable=E0401 +from read_hippo_data import ( # pylint: disable=E0401 + get_exodus_times, + read_moose_exodus_data, +) class TestFoamVariableTransfer(unittest.TestCase): @@ -29,9 +31,15 @@ def test_variable_transfer(self): * time ) temp_diff_max = np.argmax(abs(temp - temp_ref)) - assert np.allclose(temp_ref, temp, rtol=1e-7, atol=1e-12), ( - f"Max diff ({time}): {abs(temp - temp_ref).max()} " - f"{temp[temp_diff_max]} {temp_ref[temp_diff_max]}" + np.testing.assert_allclose( + temp_ref, + temp, + rtol=1e-7, + atol=1e-12, + err_msg=( + f"Max diff ({time}): {abs(temp - temp_ref).max()} " + f"{temp[temp_diff_max]} {temp_ref[temp_diff_max]}" + ), ) def test_wall_heat_flux_transfer(self): @@ -61,6 +69,12 @@ def test_wall_heat_flux_transfer(self): assert sum_ == whf.size, f"{sum_} {whf.size}" whf_diff_max = np.argmax(abs(whf - whf_ref)) - assert np.allclose(whf_ref, whf, rtol=1e-7, atol=1e-12), ( - f"Max diff ({time}): {abs(whf - whf_ref)[whf_diff_max]} {whf[whf_diff_max]}" + np.testing.assert_allclose( + whf_ref, + whf, + rtol=1e-7, + atol=1e-12, + err_msg=( + f"Max diff ({time}): {abs(whf - whf_ref)[whf_diff_max]} {whf[whf_diff_max]}" + ), ) diff --git a/test/tests/variables/foam_variable/tests b/test/tests/variables/foam_variable/tests index f511e12d..25ce77de 100644 --- a/test/tests/variables/foam_variable/tests +++ b/test/tests/variables/foam_variable/tests @@ -8,7 +8,6 @@ type = RunApp input = main.i prereq = transfer_test/setup - allow_warnings = true [] [verify] type = PythonUnitTest @@ -19,7 +18,6 @@ type = RunApp input = main.i prereq = transfer_test/setup - allow_warnings = true min_parallel=4 max_parallel=4 []