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

Interface to enable MFEM-based EM solves in MOOSE #7

Merged
merged 48 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
1b7e123
First launch of MFEM Joule solver from Apollo
alexanderianblair Jan 17, 2022
15c0f89
Add missing joule_solver files
alexanderianblair Jan 17, 2022
dc148e7
Removes unneccessary files
alexanderianblair Jan 17, 2022
654f4ec
Updates build for Hephaestus inclusion
alexanderianblair Jan 20, 2022
ac7f84f
Adds hephaestus as submodule
alexanderianblair Jan 28, 2022
2520062
Move Hephaestus libraries from EXTERNAL_FLAGS to ADDITIONAL_LIBS
alexanderianblair Jan 31, 2022
bf39ad7
Update submodules
alexanderianblair Jan 31, 2022
2c76958
Correct MFEMProblem input ordering
alexanderianblair Jan 31, 2022
dc08676
Update dockerfile and dummy mesh for MFEM test
alexanderianblair Feb 1, 2022
c951985
Add working Dockerfile to build
alexanderianblair Feb 1, 2022
51d2f64
Update to base off of ubuntu-moose:latest
alexanderianblair Feb 1, 2022
13478e1
Update hephaestus location
alexanderianblair Feb 2, 2022
cefc69d
Adds MooseObject to store MFEM input data
alexanderianblair Feb 7, 2022
0d7be15
Override addBoundaryCondition for MFEMProblem
alexanderianblair Feb 8, 2022
4f8eb96
Pass information on boundary conditions to MFEM solver
alexanderianblair Feb 9, 2022
05acb65
Allow (named) boundary conditions to be passed from input file to MFE…
alexanderianblair Feb 9, 2022
ce46efc
Update MFEMProblem to use new Hephaestus input object
alexanderianblair Feb 11, 2022
6989965
Update submodule version
alexanderianblair Feb 11, 2022
13382fb
Allows MOOSE to add materials for Hephaestus
alexanderianblair Feb 11, 2022
52a3755
Update material parameter names for Hephaestus
alexanderianblair Feb 11, 2022
053d661
Removes reference to problem type
alexanderianblair Feb 11, 2022
0bd1c49
Add coil example for MFEMProblem in Apollo
alexanderianblair Feb 11, 2022
fc30bb2
Pass in FE order from input file
alexanderianblair Feb 11, 2022
fc63d76
Add functionality to pass scalar MooseParsedFunctions to Hephaestus b…
alexanderianblair Feb 16, 2022
00e66a2
Update for user input of formulation name
alexanderianblair Feb 23, 2022
7b0edee
Move specification of mesh filename to Mesh block
alexanderianblair Feb 23, 2022
8053f72
Pass time step information to Hephaestus
alexanderianblair Feb 24, 2022
1824deb
Update Hephaestus
alexanderianblair Mar 8, 2022
d2a191f
Roll back gitmodules url for hephaestus
alexanderianblair Mar 8, 2022
f29aebf
Add CMake, MUMPS and GLVis to docker build
alexanderianblair Mar 8, 2022
4acaa5c
Replace 'boundary' with 'boundaries' where referencing a std:vector
alexanderianblair Mar 15, 2022
198413e
Update CI to check build
alexanderianblair Mar 16, 2022
40d2f76
Fix cmake version
alexanderianblair Mar 22, 2022
db85635
Add hypre build to Dockerfile
alexanderianblair Apr 7, 2022
b0ea3a7
Remove MOOSE LegacyParam syntax
alexanderianblair Apr 8, 2022
8132685
Update dockerfile to install apt dependencies at once
alexanderianblair Apr 13, 2022
64c8eff
Update hephaestus location
alexanderianblair Apr 13, 2022
ebcb33e
Replace std::bind usage with lambda function
alexanderianblair Apr 18, 2022
2b0d4dc
Use MOOSE Hypre for Hephaestus in Apollo
alexanderianblair Apr 18, 2022
03a2696
Update hephaestus submodule
alexanderianblair Apr 19, 2022
cbf5663
Adds MFEMConductor material type
alexanderianblair Apr 20, 2022
2c5c315
Adds MFEMMaterial to act as base class to store MFEM property coeffic…
alexanderianblair Apr 20, 2022
4b1bfce
Add MFEMBoundaryCondition and MFEMFunctionDirichletBC into Apollo
alexanderianblair Apr 21, 2022
6226361
Minor reformatting
alexanderianblair Apr 21, 2022
fb443c9
Update coil.i example to use new MFEMMaterial and MFEMBoundaryConditions
alexanderianblair Apr 27, 2022
217143a
Update Hephaestus version
alexanderianblair May 18, 2022
acd9a49
Add integration tests for MFEM Joule miniapp solves
alexanderianblair May 18, 2022
4fb4291
Remove outdated MOOSE kernel tests
alexanderianblair May 20, 2022
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 .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches:
- master
- alexanderianblair/mfem-moose
pull_request:
branches:
- master
- alexanderianblair/mfem-moose

jobs:
docker-build-test-ubuntu:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,7 @@ conf_vars.mk
*.prof

# Tarred Docker images
*docker/**/*.tar.gz
*docker/**/*.tar.gz

# MFEM Joule outputs
*Joule_000*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "contrib/hephaestus"]
path = contrib/hephaestus
url = https://github.com/aurora-multiphysics/hephaestus
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,21 @@ XFEM := no
include $(MOOSE_DIR)/modules/modules.mk
###############################################################################

.PHONY : printer

printer:
@echo $(MFEM_LIB)
@echo $(MFEM_INC)

# dep apps
APPLICATION_DIR := $(CURDIR)
APOLLO_DIR := $(CURDIR)
APPLICATION_NAME := apollo
BUILD_EXEC := yes
GEN_REVISION := no
DEP_APPS := $(shell $(FRAMEWORK_DIR)/scripts/find_dep_apps.py $(APPLICATION_NAME))
include $(FRAMEWORK_DIR)/app.mk


###############################################################################
# Additional special case targets should be added here
10 changes: 10 additions & 0 deletions apollo.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Check the existence of the contrib submodules and build accordingly
#
MFEM_DIR?=$(APPLICATION_DIR)/../mfem/build
include $(MFEM_DIR)/config/config.mk


HEPHAESTUS_DIR?=$(APPLICATION_DIR)/contrib/hephaestus
ADDITIONAL_CPPFLAGS += -DHEPHAESTUS_ENABLED
include $(APPLICATION_DIR)/contrib/hephaestus.mk
1 change: 1 addition & 0 deletions contrib/hephaestus
Submodule hephaestus added at 287742
17 changes: 17 additions & 0 deletions contrib/hephaestus.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
############################### HEPHAESTUS #######################################h
###############################################################################
# source files

MFEM_INC= -I$(MFEM_DIR) -I$(MFEM_SOURCE_DIR) -I$(MFEM_SOURCE_DIR)/miniapps/common
MFEM_LIB= -L$(MFEM_DIR) -lmfem -lrt -L$(MFEM_DIR)/miniapps/common -lmfem-common

HEPHAESTUS_INCDIR = $(HEPHAESTUS_DIR)/src/hephaestus_lib
HEPHAESTUS_LIBDIR = $(HEPHAESTUS_DIR)/lib
HEPHAESTUS_INC = -I$(HEPHAESTUS_INCDIR)
HEPHAESTUS_LIB = -Wl,-rpath,$(HEPHAESTUS_LIBDIR) -L$(HEPHAESTUS_LIBDIR) -lhephaestus -lnetcdf

ADDITIONAL_INCLUDES += $(HEPHAESTUS_INC) $(MFEM_INC) -I$(MFEM_INC_DIR)/config
ADDITIONAL_LIBS += $(HEPHAESTUS_LIB) $(MFEM_LIB)

$(info ADDITIONAL_INCLUDES = $(ADDITIONAL_INCLUDES));
$(info ADDITIONAL_LIBS = $(ADDITIONAL_LIBS));
98 changes: 88 additions & 10 deletions docker/apollo-ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,100 @@
# docker build -t apollo-ubuntu --build-arg build_git_sha=${GITHUB_SHA} .

# Get MOOSE image
FROM helenbrooks/moose-ubuntu
FROM herter4171/ubuntu-moose:latest

# By default one core is used to compile
ARG compile_cores=1

# By default checkout main branch
ARG build_git_sha="master"
# By default checkout mfem-moose branch
ARG WORKDIR="opt"
ARG build_git_sha="alexanderianblair/mfem-moose"
ARG hypre_git_sha="562c29a"

RUN cd /home && \
cd moose/framework/src/base && \
sed -i 's/(type.family == NEDELEC_ONE)/(type.family == NEDELEC_ONE||type.family == LAGRANGE_VEC)/g' Assembly.C
# Install apt dependencies
RUN apt-get update && apt-get install -y \
clang-format-9 \
curl \
libboost-all-dev \
libnetcdf-dev \
libssl-dev \
xxd \
libfontconfig1-dev \
libfreetype6-dev \
libsdl2-dev \
libglew-dev \
libglm-dev \
libpng-dev \
ninja-build

RUN cd /home && \
# Enable Nedelec element curl calculations in MOOSE
RUN cd /$WORKDIR && \
cd moose/framework/src/base && \
sed -i 's/(type.family == NEDELEC_ONE)/(type.family == NEDELEC_ONE||type.family == LAGRANGE_VEC)/g' Assembly.C

# Install CMake
RUN cd /$WORKDIR && \
git clone https://github.com/Kitware/CMake.git && \
cd CMake/ && \
git checkout 78ae759 && \
./bootstrap && \
make && \
make install && \
alias cmake='/$WORKDIR/CMake/bin/cmake'

# Install METIS 5.1.0
RUN cd /$WORKDIR && \
curl -O http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz && \
tar -zxvf metis-* && \
cd metis-5.1.0 && \
make config shared=1 && \
make && \
make install && \
ln -s ../build/Linux-x86_64/libmetis/libmetis.so lib

# Install MUMPS
RUN cd /$WORKDIR && \
git clone https://github.com/scivision/mumps && \
cd mumps/ && \
mkdir build && \
cd build && \
cmake --preset=build -DBUILD_SHARED_LIBS=on -Dscotch=true -Dintsize64=false -Darith="s;d;c;z" -Dautobuild=true \
-DCMAKE_INSTALL_PREFIX=/usr/local/ .. && \
make && \
make install

# Build MFEM and common miniapp
RUN cd /$WORKDIR && \
git clone https://github.com/mfem/mfem.git && \
cd mfem && \
mkdir build && \
cd build && \
cmake .. -DCMAKE_BUILD_TYPE=Debug -DMFEM_USE_MPI=YES -DMFEM_USE_METIS_5=YES -DMETIS_DIR=../../metis-5.1.0 \
-DMFEM_USE_OPENMP=YES -DMFEM_THREAD_SAFE=NO -DMFEM_SHARED=YES -DCMAKE_CXX_FLAGS_DEBUG=-fPIC -DMFEM_USE_NETCDF=YES \
-DCMAKE_POLICY_DEFAULT_CMP0057=NEW &&\
make && \
cd miniapps/common && \
make

# Build GLVis
RUN cd /$WORKDIR && \
git clone https://github.com/GLVis/glvis.git && \
cd glvis/ && \
mkdir build && \
cd build/ && \
cmake -G Ninja -DMFEM_DIR=/opt/mfem/build .. && \
ninja

# Build Apollo with Hephaestus
RUN cd /$WORKDIR && \
git clone https://github.com/aurora-multiphysics/apollo.git && \
cd apollo && \
git checkout "$build_git_sha" && \
make -j"$compile_cores" && \
make -j"$compile_cores" test &&\
./run_tests
git submodule update --init --recursive && \
cd contrib/hephaestus/ && \
mkdir build && \
cd build && \
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DMFEM_DIR=/$WORKDIR/mfem/build -DMFEM_COMMON_INCLUDES=/$WORKDIR/mfem/miniapps/common .. && \
make && \
cd /$WORKDIR/apollo && \
make -j"$compile_cores"
23 changes: 23 additions & 0 deletions include/bcs/MFEMBoundaryCondition.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include "GeneralUserObject.h"
#include "boundary_conditions.hpp"

class MFEMBoundaryCondition : public GeneralUserObject
{
public:
static InputParameters validParams();

MFEMBoundaryCondition(const InputParameters & parameters);
virtual ~MFEMBoundaryCondition();

virtual hephaestus::BoundaryCondition * getBC();
virtual void execute() override {}
virtual void initialize() override {}
virtual void finalize() override {}

protected:
std::vector<BoundaryName> _boundary_names;
mfem::Array<int> bdr_attr;
hephaestus::BoundaryCondition * _boundary_condition;
};
24 changes: 24 additions & 0 deletions include/bcs/MFEMFunctionDirichletBC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include "MFEMBoundaryCondition.h"
#include "boundary_conditions.hpp"

libMesh::Point PointFromMFEMVector(const mfem::Vector & vec);

class MFEMFunctionDirichletBC : public MFEMBoundaryCondition
{
public:
static InputParameters validParams();

MFEMFunctionDirichletBC(const InputParameters & parameters);
virtual ~MFEMFunctionDirichletBC();

virtual hephaestus::BoundaryCondition * getBC() override;
virtual void execute() override {}
virtual void initialize() override {}
virtual void finalize() override {}

protected:
const Function & _func;
mfem::FunctionCoefficient _function_coeff;
};
6 changes: 0 additions & 6 deletions include/kernels/CoupledVectorForce.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

#include "VectorKernel.h"

// Forward Declaration
class CoupledVectorForce;

template <>
InputParameters validParams<CoupledVectorForce>();

/**
* Class to use a coupled auxvariable to apply a vector body force.
*/
Expand Down
6 changes: 0 additions & 6 deletions include/kernels/MatTimeDerivative.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
#include "TimeDerivative.h"
#include "MaterialProperty.h"

class MatTimeDerivative;

template <>
InputParameters validParams<MatTimeDerivative>();

/**
* Time derivative term multiplied by a material coefficient
*/
Expand All @@ -34,4 +29,3 @@ class MatTimeDerivative : public TimeDerivative
/// The coefficient the time derivative is multiplied with
const MaterialProperty<Real> & _sigma;
};

35 changes: 35 additions & 0 deletions include/materials/MFEMConductor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include "MFEMMaterial.h"
#include "materials.hpp"

class MFEMConductor : public MFEMMaterial
{
public:
static InputParameters validParams();

MFEMConductor(const InputParameters & parameters);
virtual ~MFEMConductor();

/// EM constants
static const Real _mu0;
static const Real _epsilon0;

protected:
const Real & _input_electrical_conductivity;
const Real & _input_rel_permittivity;
const Real & _input_rel_permeability;
const Real & _input_thermal_conductivity;
const Real & _input_heat_capacity;

mfem::ConstantCoefficient _electrical_conductivity_coeff;
mfem::ConstantCoefficient _permittivity_coeff;
mfem::ConstantCoefficient _permeability_coeff;
mfem::ConstantCoefficient _resistivity_coeff;
mfem::ConstantCoefficient _reluctivity_coeff;

mfem::ConstantCoefficient _heat_capacity_coeff;
mfem::ConstantCoefficient _inverse_heat_capacity_coeff;
mfem::ConstantCoefficient _thermal_conductivity_coeff;
mfem::ConstantCoefficient _inverse_thermal_conductivity_coeff;
};
20 changes: 20 additions & 0 deletions include/materials/MFEMMaterial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include "GeneralUserObject.h"
#include "materials.hpp"

class MFEMMaterial : public GeneralUserObject
{
public:
static InputParameters validParams();

MFEMMaterial(const InputParameters & parameters);
virtual ~MFEMMaterial();

virtual void execute() override {}
virtual void initialize() override {}
virtual void finalize() override {}

std::map<std::string, mfem::Coefficient *> scalar_property_map;
std::vector<SubdomainName> blocks;
};
28 changes: 28 additions & 0 deletions include/mesh/MFEMMesh.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#pragma once

#include "GeneratedMesh.h"

/**
* MFEMMesh
*/
class MFEMMesh : public GeneratedMesh
{
public:
static InputParameters validParams();

MFEMMesh(const InputParameters & parameters);
MFEMMesh(const MFEMMesh & other_mesh) = default;

public:
/// the file_name from whence this mesh came
std::string file_name;
};
5 changes: 0 additions & 5 deletions include/postprocessors/BlockAveragePostprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

#include "GeneralPostprocessor.h"
#include "BlockAverageValue.h"
// Forward Declarations
class BlockAveragePostprocessor;

template <>
InputParameters validParams<BlockAveragePostprocessor>();

/**
*
Expand Down
6 changes: 0 additions & 6 deletions include/postprocessors/ElementNedelecL2Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@

class Function;

// Forward Declarations
class ElementNedelecL2Error;

template <>
InputParameters validParams<ElementNedelecL2Error>();

class ElementNedelecL2Error : public ElementIntegralPostprocessor
{
public:
Expand Down
Loading