Skip to content

Commit

Permalink
Merge pull request #34 from aurora-multiphysics/hsaunders1904/17_clea…
Browse files Browse the repository at this point in the history
…n_up_how_we_pass_options_to_openfoam

Clean up how we pass options to openfoam
  • Loading branch information
hsaunders1904 authored Nov 26, 2024
2 parents a3caff1 + 71965d2 commit 0e27394
Show file tree
Hide file tree
Showing 25 changed files with 32 additions and 50 deletions.
1 change: 1 addition & 0 deletions include/base/FoamInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace Hippo
// just have it there
// Forward declare the implementation
struct EnvImpl;

class FoamInterface
{
private:
Expand Down
2 changes: 0 additions & 2 deletions src/base/FoamInterface.C
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@

namespace Hippo
{

namespace
{

constexpr auto FOAM_PARALLEL_FLAG = "-parallel";

/** Check if OpenFOAM's parallel flag needs to be added to the CLI arguments.
Expand Down
4 changes: 2 additions & 2 deletions src/base/buoyantFoamImpl.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
/*
* Code in here is directly copied from buoyantFoam.C in openFOAM
* changes are that the #includes have been expanded out
* and field variables etc. are memebers of this class
* and field variables etc. are members of this class
* so we can persist data across timesteps
*/

// This is a hack this macro is defined somewhere in moose and foam
// I had to undef it in the fvCFD_moose.h macro
// but I need to redefne it here
// but I need to redefine it here
// The foam one is not in scope
#define NotImplemented
#include "fvModels.H"
Expand Down
4 changes: 4 additions & 0 deletions src/mesh/Foam2MooseMeshGen.C
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,13 @@ Foam2MooseMeshAdapter::Foam2MooseMeshAdapter(std::vector<std::string> const & pa
}

if (comm)
{
this->set_up_parallel();
}
else
{
this->set_up_serial();
}

// TODO: Move this - this is some annoying bookeeping I need to change the
// patch ids in the local2global maps so that they point to the id in the moose mesh
Expand Down
11 changes: 4 additions & 7 deletions src/mesh/FoamMesh.C
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ FoamMesh::validParams()
{
auto params = MooseMesh::validParams();
params.addRequiredParam<std::vector<std::string>>("foam_patch",
"Name of foam boundary patches to replicate");

std::vector<std::string> empty_vec;
params.addParam<std::vector<std::string>>(
"foam_args", empty_vec, "List of arguments to be passed to OpenFoam solver");
"Name of foam boundary patches to replicate.");
params.addRequiredParam<std::string>("case", "The directory containing the OpenFOAM case.");
return params;
}

FoamMesh::FoamMesh(InputParameters const & params)
: MooseMesh(params),
_foam_patch(getParam<std::vector<std::string>>("foam_patch")),
_interface(Hippo::FoamInterface::getInstance(getParam<std::vector<std::string>>("foam_args"),
_interface(Hippo::FoamInterface::getInstance({"-case", getParam<std::string>("case")},
_communicator.get()))
{
auto comm = _communicator.get();
Expand Down Expand Up @@ -57,7 +54,7 @@ FoamMesh::buildMesh()
{
auto comm = _communicator.get();
auto mesh_adapter = std::make_unique<Hippo::Foam2MooseMeshAdapter>(
_foam_patch, _interface, (_serial) ? nullptr : &comm);
_foam_patch, _interface, _serial ? nullptr : &comm);

// TODO: Can reserve elements if _mesh->reserve_elements(#el)
// TODO: Can also reserve nodes _mesh->reserve_nodes(#nodes?)
Expand Down
3 changes: 1 addition & 2 deletions test/tests/buoyantFoam/buoyantFoam_par/run.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case buoyantCavity'
case = 'buoyantCavity'
foam_patch = 'topAndBottom frontAndBack'
dim=2
[]

[Variables]
Expand Down
3 changes: 1 addition & 2 deletions test/tests/buoyantFoam/buoyantFoam_serial/run.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case buoyantCavity'
case = buoyantCavity
foam_patch = 'topAndBottom frontAndBack'
dim = 2
[]

[Variables]
Expand Down
3 changes: 1 addition & 2 deletions test/tests/cube_slice/test_1/run.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case foaminput'
case = 'foaminput'
foam_patch = ' Wall-2 Wall-3 Wall-4 Wall-5'
dim=2
[]
[Variables]
[T]
Expand Down
3 changes: 1 addition & 2 deletions test/tests/cube_slice/test_10/run.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case foaminput'
case = 'foaminput'
foam_patch = ' Wall-0 Wall-3 Wall-5'
dim=2
[]
[Variables]
[T]
Expand Down
3 changes: 1 addition & 2 deletions test/tests/cube_slice/test_2/run.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case foaminput'
case = 'foaminput'
foam_patch = ' Wall-0 Wall-3 Wall-5'
dim=2
[]
[Variables]
[T]
Expand Down
3 changes: 1 addition & 2 deletions test/tests/cube_slice/test_3/run.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case foaminput'
case = 'foaminput'
foam_patch = ' Wall-0 Wall-3 Wall-5'
dim=2
[]
[Variables]
[T]
Expand Down
3 changes: 1 addition & 2 deletions test/tests/cube_slice/test_4/run.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case foaminput'
case = 'foaminput'
foam_patch = ' Wall-2 Wall-4 Wall-5'
dim=2
[]
[Variables]
[T]
Expand Down
3 changes: 1 addition & 2 deletions test/tests/cube_slice/test_5/run.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case foaminput'
case = 'foaminput'
foam_patch = ' Wall-0 Wall-2 Wall-4'
dim=2
[]
[Variables]
[T]
Expand Down
3 changes: 1 addition & 2 deletions test/tests/cube_slice/test_6/run.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case foaminput'
case = 'foaminput'
foam_patch = ' Wall-3'
dim=2
[]
[Variables]
[T]
Expand Down
3 changes: 1 addition & 2 deletions test/tests/cube_slice/test_7/run.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case foaminput'
case = 'foaminput'
foam_patch = ' Wall-0 Wall-1 Wall-2 Wall-3 Wall-4 Wall-5'
dim=2
[]
[Variables]
[T]
Expand Down
3 changes: 1 addition & 2 deletions test/tests/cube_slice/test_8/run.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case foaminput'
case = 'foaminput'
foam_patch = ' Wall-1 Wall-3'
dim=2
[]
[Variables]
[T]
Expand Down
3 changes: 1 addition & 2 deletions test/tests/cube_slice/test_9/run.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case foaminput'
case = 'foaminput'
foam_patch = ' Wall-0 Wall-2 Wall-4 Wall-5'
dim=2
[]
[Variables]
[T]
Expand Down
3 changes: 1 addition & 2 deletions test/tests/input_errors/order_of_foam_t_is_not_constant.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case ./foam_mesh'
case = './foam_mesh'
foam_patch = 'topAndBottom frontAndBack'
dim=2
[]

[AuxVariables]
Expand Down
3 changes: 1 addition & 2 deletions test/tests/input_errors/order_of_t_is_not_constant.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case ./foam_mesh'
case = './foam_mesh'
foam_patch = 'topAndBottom frontAndBack'
dim=2
[]

[AuxVariables]
Expand Down
3 changes: 1 addition & 2 deletions test/tests/input_errors/same_foam_t_and_hf_variable.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case ./foam_mesh'
case = './foam_mesh'
foam_patch = 'topAndBottom frontAndBack'
dim=2
[]

[AuxVariables]
Expand Down
5 changes: 2 additions & 3 deletions test/tests/multiapps/flow_over_heated_plate/fluid.i
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case fluid-openfoam'
case = 'fluid-openfoam'
foam_patch = 'interface'
dim = 2
[]

[Variables]
Expand Down Expand Up @@ -38,7 +37,7 @@
type = Transient
start_time = 0
end_time = 1
dt = 0.01
dt = 0.025

solve_type = 'PJFNK'
petsc_options_iname = '-pc_type -pc_hypre_type'
Expand Down
2 changes: 1 addition & 1 deletion test/tests/multiapps/flow_over_heated_plate/heated_plate.i
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
type = Transient
start_time = 0
end_time = 1
dt = 0.01
dt = 0.025

fixed_point_abs_tol = 1e-7
fixed_point_rel_tol = 1e-8
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case buoyantCavity'
case = 'buoyantCavity'
foam_patch = 'patch2 patch4'
dim=2
[]

[Variables]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[Mesh]
type = FoamMesh
foam_args = '-case buoyantCavity'
case = 'buoyantCavity'
foam_patch = 'patch2 patch4'
dim=2
[]

[Variables]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Mesh]
type = FoamMesh
foam_args = '-case buoyantCavity'
case = 'buoyantCavity'
foam_patch = 'topAndBottom frontAndBack'
dim = 2
[]
Expand Down

0 comments on commit 0e27394

Please sign in to comment.