Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify diffusion test into single test file #16

Merged
merged 12 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docker/platypus-deps/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install
RUN pip install --no-cache-dir packaging && \
pip install --no-cache-dir pyyaml && \
pip install --no-cache-dir setuptools && \
pip install --no-cache-dir xmltodict && \
alexanderianblair marked this conversation as resolved.
Show resolved Hide resolved
pip install --no-cache-dir deepdiff && \
pip install --no-cache-dir jinja2

# Install CMake
Expand Down
1 change: 0 additions & 1 deletion include/base/platypus.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
#include "problem_builder.h"
#include "steady_executioner.h"
#include "transient_executioner.h"
#include "utils.h"
1 change: 1 addition & 0 deletions include/outputs/MFEMParaViewDataCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ class MFEMParaViewDataCollection : public MFEMDataCollection
protected:
bool _high_order_output;
unsigned int _refinements;
const mfem::VTKFormat _vtk_format;
};
13 changes: 10 additions & 3 deletions include/problem/MFEMProblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,16 @@ class MFEMProblem : public ExternalProblem
InputParameters & parameters);

/**
* Override of ExternalProblem::addAuxVariable. Uses ExternalProblem::addAuxVariable to set the
* Moose aux var, and contains additional code to create a corresponding MFEM grid function to be
* used in the MFEM solve.
* Override of ExternalProblem::addVariable. Sets a
* MFEM grid function to be used in the MFEM solve.
*/
void addVariable(const std::string & var_type,
const std::string & var_name,
InputParameters & parameters) override;

/**
* Override of ExternalProblem::addAuxVariable. Sets a
* MFEM grid function to be used in the MFEM solve.
*/
void addAuxVariable(const std::string & var_type,
const std::string & var_name,
Expand Down
24 changes: 0 additions & 24 deletions include/utils/utils.h

This file was deleted.

10 changes: 7 additions & 3 deletions scripts/build-platypus-csd3-ampere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ install_spack_deps() {
spack install py-setuptools
spack load py-setuptools arch=${ARCH}

spack install py-deepdiff
spack load py-deepdiff arch=${ARCH}

spack install py-xmltodict
spack load py-xmltodict arch=${ARCH}
}

install_gslib() {
Expand All @@ -150,8 +155,7 @@ install_mfem() {
cd "${BUILD_PATH}" || exit 1
git clone https://github.com/mfem/mfem.git
cd mfem || exit 1
# This is just until MFEM merges Edward's changes. Without this, GPU build crashes!
git checkout EdwardPalmer99/add-missing-header-to-exodus-writer-fix
git checkout master
mkdir build
cd build || exit 1
echo "Building MFEM"
Expand Down Expand Up @@ -254,7 +258,7 @@ install_platypus() {
git clone https://github.com/aurora-multiphysics/platypus.git
cd platypus || exit 1
make -j"$compile_cores"

./run_tests -j"$compile_cores"
}

load_modules
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-platypus-csd3-sapphire.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function load_modules() {

export PATH=${BUILD_PATH}:${PATH}

cd "$WORKDIR}" || exit
cd "${WORKDIR}" || exit

#Need to set some compiler flags via config file"
echo "-std=c++17" >> icpx.cfg
Expand Down
3 changes: 2 additions & 1 deletion src/base/PlatypusApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PlatypusApp::validParams()
{
InputParameters params = MooseApp::validParams();
params.set<bool>("use_legacy_material_output") = false;
params.set<bool>("use_legacy_initial_residual_evaluation_behavior") = false;
return params;
}

Expand Down Expand Up @@ -58,7 +59,7 @@ associateSyntaxInner(Syntax & syntax, ActionFactory & /*action_factory*/)
void
PlatypusApp::registerAll(Factory & f, ActionFactory & af, Syntax & s)
{
ModulesApp::registerAll(f, af, s);
ModulesApp::registerAllObjects<PlatypusApp>(f, af, s);
Registry::registerObjectsTo(f, {"PlatypusApp"});
Registry::registerActionsTo(af, {"PlatypusApp"});
/* register custom execute flags, action syntax, etc. here */
Expand Down
22 changes: 3 additions & 19 deletions src/main.C
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
#include "PlatypusTestApp.h"
#include "MooseInit.h"
#include "Moose.h"
#include "MooseApp.h"
#include "AppFactory.h"

// Create a performance log
PerfLog Moose::perf_log("Platypus");
#include "MooseMain.h"

// Begin the main program.
int
main(int argc, char * argv[])
{
// Initialize MPI, solvers and MOOSE
MooseInit init(argc, argv);

// Register this application's MooseApp and any it depends on
PlatypusTestApp::registerApps();

// Create an instance of the application and store it in a smart pointer for easy cleanup
std::shared_ptr<MooseApp> app = AppFactory::createAppShared("PlatypusTestApp", argc, argv);

// Execute the application
app->run();
Moose::main<PlatypusTestApp>(argc, argv);

return 0;
}
}
10 changes: 9 additions & 1 deletion src/outputs/MFEMParaViewDataCollection.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ MFEMParaViewDataCollection::validParams()
"high-order elements (false by default)."
"Reading high-order data requires ParaView"
"5.5 or later.");

MooseEnum vtk_format("ASCII BINARY BINARY32", "BINARY", true);
params.addParam<MooseEnum>(
"vtk_format",
vtk_format,
"Select VTK data format to use, choosing between BINARY, BINARY32, and ASCII.");
return params;
}

MFEMParaViewDataCollection::MFEMParaViewDataCollection(const InputParameters & parameters)
: MFEMDataCollection(parameters),
_high_order_output(getParam<bool>("high_order_output")),
_refinements(getParam<unsigned int>("refinements"))
_refinements(getParam<unsigned int>("refinements")),
_vtk_format(parameters.get<MooseEnum>("vtk_format").getEnum<mfem::VTKFormat>())
{
}

Expand All @@ -36,6 +43,7 @@ MFEMParaViewDataCollection::createDataCollection(const std::string & collection_
pv_dc->SetPrecision(9);
pv_dc->SetHighOrderOutput(_high_order_output);
pv_dc->SetLevelsOfDetail(_refinements + 1);
pv_dc->SetDataFormat(_vtk_format);

return pv_dc;
}
26 changes: 25 additions & 1 deletion src/problem/MFEMProblem.C
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,31 @@
mfem_problem->_fespaces.Register(name, mfem_fespace.getFESpace());
}

void
MFEMProblem::addVariable(const std::string & var_type,
const std::string & var_name,
InputParameters & parameters)
{
if (var_type == "MFEMVariable")
{
// Add MFEM variable directly.
FEProblemBase::addUserObject(var_type, var_name, parameters);
}
else
{
// Add MOOSE auxvariable.
FEProblemBase::addVariable(var_type, var_name, parameters);

Check warning on line 228 in src/problem/MFEMProblem.C

View check run for this annotation

Codecov / codecov/patch

src/problem/MFEMProblem.C#L228

Added line #L228 was not covered by tests

// Add MFEM variable indirectly ("gridfunction").
InputParameters mfem_variable_params = addMFEMFESpaceFromMOOSEVariable(parameters);
FEProblemBase::addUserObject("MFEMVariable", var_name, mfem_variable_params);
}

Check warning on line 233 in src/problem/MFEMProblem.C

View check run for this annotation

Codecov / codecov/patch

src/problem/MFEMProblem.C#L231-L233

Added lines #L231 - L233 were not covered by tests

// Register gridfunction.
MFEMVariable & mfem_variable = getUserObject<MFEMVariable>(var_name);
mfem_problem->_gridfunctions.Register(var_name, mfem_variable.getGridFunction());
}

void
MFEMProblem::addAuxVariable(const std::string & var_type,
const std::string & var_name,
Expand All @@ -234,7 +259,6 @@

// Register gridfunction.
MFEMVariable & mfem_variable = getUserObject<MFEMVariable>(var_name);

mfem_problem->_gridfunctions.Register(var_name, mfem_variable.getGridFunction());
}

Expand Down
49 changes: 0 additions & 49 deletions src/utils/utils.C

This file was deleted.

2 changes: 1 addition & 1 deletion src/variables/MFEMVariable.C
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ MFEMVariable::validParams()
params += MooseVariableBase::validParams();

params.addClassDescription("Class for MFEM variables (gridfunctions).");
params.registerBase("MFEMVariable");
params.registerBase("MooseVariableBase");

return params;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,54 @@
[Mesh]
type = CoupledMFEMMesh
type = ExclusiveMFEMMesh
file = gold/mug.e
dim = 3
[]

[Problem]
type = MFEMProblem
use_glvis = true
device = "cpu"
[]

[Formulation]
type = CustomFormulation
[]

[AuxVariables]
[mfem_diffused]
family = LAGRANGE
order = FIRST
[FESpaces]
[H1FESpace]
type = MFEMFESpace
fec_type = H1
fec_order = FIRST
[]
[]

[Variables]
[diffused]
type = MFEMVariable
fespace = H1FESpace
[]
[]

[Functions]
[value_bottom]
type = ParsedFunction
value = 1.0
expression = 1.0
[]
[value_top]
type = ParsedFunction
value = 0.0
expression = 0.0
[]
[]

[BCs]
[bottom]
type = MFEMScalarDirichletBC
variable = mfem_diffused
variable = diffused
boundary = '1'
coefficient = BottomValue
[]
[low_terminal]
type = MFEMScalarDirichletBC
variable = mfem_diffused
variable = diffused
boundary = '2'
coefficient = TopValue
[]
Expand All @@ -65,7 +72,7 @@
[Kernels]
[diff]
type = MFEMDiffusionKernel
variable = mfem_diffused
variable = diffused
coefficient = one
[]
[]
Expand All @@ -81,8 +88,9 @@
[]

[Outputs]
[VisItDataCollection]
type = MFEMVisItDataCollection
[ParaViewDataCollection]
type = MFEMParaViewDataCollection
file_base = OutputData/Diffusion
vtk_format = ASCII
[]
[]
Loading