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

Add additional variable-dependent function coefficients #67

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once
#include "MFEMCoefficient.h"
#include "auxsolvers.hpp"

class MFEMTemperatureDependentConductivityCoefficient : public MFEMCoefficient,
public hephaestus::CoupledCoefficient
{
public:
static InputParameters validParams();

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

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

double Eval(mfem::ElementTransformation & trans, const mfem::IntegrationPoint & ip) override;

virtual mfem::Coefficient * getCoefficient() override { return this; };

private:
const Function & _func;
};
24 changes: 24 additions & 0 deletions include/coefficients/MFEMVariableDependentFunctionCoefficient.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once
#include "MFEMCoefficient.h"
#include "auxsolvers.hpp"

class MFEMVariableDependentFunctionCoefficient : public MFEMCoefficient,
public hephaestus::CoupledCoefficient
{
public:
static InputParameters validParams();

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

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

double Eval(mfem::ElementTransformation & trans, const mfem::IntegrationPoint & ip) override;

virtual mfem::Coefficient * getCoefficient() override { return this; };

private:
const Function & _func;
};
2 changes: 2 additions & 0 deletions src/base/ApolloApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ associateSyntaxInner(Syntax & syntax, ActionFactory & /*action_factory*/)
registerMooseObjectTask("add_mfem_coefficients", MFEMCoefficient, false);
registerSyntaxTask("AddCoefficientAction", "Coefficients/*", "add_mfem_coefficients");
addTaskDependency("add_material", "add_mfem_coefficients");
addTaskDependency("add_mfem_coefficients", "add_variable");
addTaskDependency("add_mfem_coefficients", "add_aux_variable");

// add vector coefficients
registerMooseObjectTask("add_mfem_vector_coefficients", MFEMVectorCoefficient, false);
Expand Down
35 changes: 35 additions & 0 deletions src/coefficients/MFEMTemperatureDependentConductivityCoefficient.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "MFEMTemperatureDependentConductivityCoefficient.h"

registerMooseObject("ApolloApp", MFEMTemperatureDependentConductivityCoefficient);

InputParameters
MFEMTemperatureDependentConductivityCoefficient::validParams()
{
InputParameters params = MFEMCoefficient::validParams();
params.addParam<FunctionName>(
"resistivity_function", 1.0, "The resistivity of the material as a function of temperature");
params.addParam<std::string>("temperature_variable",
"The MFEMVariable describing the temperature of the material.");
return params;
}

MFEMTemperatureDependentConductivityCoefficient::MFEMTemperatureDependentConductivityCoefficient(
const InputParameters & parameters)
: MFEMCoefficient(parameters),
hephaestus::CoupledCoefficient(hephaestus::InputParameters(
{{"CoupledVariableName", getParam<std::string>("temperature_variable")}})),
_func(getFunction("resistivity_function"))
{
}

double
MFEMTemperatureDependentConductivityCoefficient::Eval(mfem::ElementTransformation & trans,
const mfem::IntegrationPoint & ip)
{
auto gf_value{hephaestus::CoupledCoefficient::Eval(trans, ip)};
return 1.0 / _func.value(gf_value);
};

MFEMTemperatureDependentConductivityCoefficient::~MFEMTemperatureDependentConductivityCoefficient()
{
}
33 changes: 33 additions & 0 deletions src/coefficients/MFEMVariableDependentFunctionCoefficient.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "MFEMVariableDependentFunctionCoefficient.h"

registerMooseObject("ApolloApp", MFEMVariableDependentFunctionCoefficient);

InputParameters
MFEMVariableDependentFunctionCoefficient::validParams()
{
InputParameters params = MFEMCoefficient::validParams();
params.addParam<FunctionName>(
"function", 1, "The function acting on the MFEM variable to return the coefficient");

params.addParam<std::string>("coupled_variable", "The MFEMVariable the coefficient depends on.");
return params;
}

MFEMVariableDependentFunctionCoefficient::MFEMVariableDependentFunctionCoefficient(
const InputParameters & parameters)
: MFEMCoefficient(parameters),
hephaestus::CoupledCoefficient(hephaestus::InputParameters(
{{"CoupledVariableName", getParam<std::string>("coupled_variable")}})),
_func(getFunction("function"))
{
}

double
MFEMVariableDependentFunctionCoefficient::Eval(mfem::ElementTransformation & trans,
const mfem::IntegrationPoint & ip)
{
auto gf_value{hephaestus::CoupledCoefficient::Eval(trans, ip)};
return _func.value(gf_value);
};

MFEMVariableDependentFunctionCoefficient::~MFEMVariableDependentFunctionCoefficient() {}
Loading