Skip to content

Commit

Permalink
#201 fixed problems preventing passing of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mlesueur committed Jan 22, 2025
1 parent 28aec55 commit 0122a0c
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 41 deletions.
2 changes: 2 additions & 0 deletions include/actions/RedbackMechAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class RedbackMechAction : public Action
protected:
/// if this vector is not empty the variables, kernels and materials are restricted to these subdomains
std::vector<SubdomainName> _subdomain_names;
/// indicates, if the vector of subdomain names is set (dont set block restrictions, if not)
const bool _subdomain_names_set;
};

#endif // REDBACKMECHACTION_H
21 changes: 19 additions & 2 deletions src/actions/RedbackMechAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RedbackMechAction::validParams()
params.addParam<std::string>(
"appended_property_name", "", "Name appended to material properties to make them unique");
params.addParam<std::vector<SubdomainName>>(
"block",
"block",{},
"The list of ids of the blocks (subdomain) that the mechanics kernels will be applied to");

// changed this from true to false
Expand All @@ -47,7 +47,8 @@ RedbackMechAction::RedbackMechAction(const InputParameters & params)
_disp_r(getParam<NonlinearVariableName>("disp_r")),
_temp(getParam<NonlinearVariableName>("temp")),
_pore_pres(getParam<NonlinearVariableName>("pore_pres")),
_subdomain_names(getParam<std::vector<SubdomainName>>("block"))
_subdomain_names(getParam<std::vector<SubdomainName>>("block")),
_subdomain_names_set(isParamSetByUser("block"))
{
}

Expand Down Expand Up @@ -132,6 +133,22 @@ RedbackMechAction::act()
name << short_name;
name << i;

// // get subdomain IDs
// std::set<SubdomainID> _subdomain_ids;
// for (auto & name : _subdomain_names)
// {
// auto id = _mesh->getSubdomainID(name);
// if (id == Moose::INVALID_BLOCK_ID)
// paramError("block", "Subdomain \"" + name + "\" not found in mesh.");
// else
// _subdomain_ids.insert(id);
// }
//
// // Make sure that all mesh subdomains have the same coordinate system
// const auto & all_subdomains =
// _subdomain_names.empty() ? _problem->mesh().meshSubdomains() : _subdomain_ids;
// if (_subdomain_names_set)
// params.set<std::vector<SubdomainName>>("block") = _subdomain_names;
params.set<std::vector<SubdomainName>>("block") = _subdomain_names;
params.set<unsigned int>("component") = i;
params.set<NonlinearVariableName>("variable") = vars[i];
Expand Down
5 changes: 3 additions & 2 deletions src/base/RedbackApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ InputParameters
RedbackApp::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 All @@ -42,11 +44,10 @@ RedbackApp::~RedbackApp() {}
void
RedbackApp::registerAll(Factory & f, ActionFactory & af, Syntax & s)
{
ModulesApp::registerAllObjects<RedbackApp>(f, af, s);
Registry::registerObjectsTo(f, {"RedbackApp"});
Registry::registerActionsTo(af, {"RedbackApp"});

ModulesApp::registerAll(f, af, s);

/* register custom execute flags, action syntax, etc. here */
RedbackApp::associateSyntax(s, af);
}
Expand Down
31 changes: 11 additions & 20 deletions src/main.C
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
#include "AppFactory.h"
#include "Moose.h"
#include "MooseApp.h"
#include "MooseInit.h"
#include "RedbackApp.h"
//* 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

// Create a performance log
PerfLog Moose::perf_log("Redback");
#include "RedbackApp.h"
#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
RedbackApp::registerApps();

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

// Execute the application
app->run();

return 0;
return Moose::main<RedbackApp>(argc, argv);
}
6 changes: 3 additions & 3 deletions src/materials/RedbackFluidMaterial.C
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ RedbackFluidMaterial::computeRedbackTerms()
_froude_number[_qp] = _froude_number_param;
_viscosity_ratio[_qp] = _viscosity_ratio_param;

Real fluid_density;
fluid_density = (1 + _fluid_compressibility_param * _pore_pres[_qp] -
_fluid_thermal_expansion_param * _T[_qp]);
// Real fluid_density;
// fluid_density = (1 + _fluid_compressibility_param * _pore_pres[_qp] -
// _fluid_thermal_expansion_param * _T[_qp]);

// Gravity term in the momentum kernel
_gravity_term[_qp] = _gravity_param / pow(_froude_number[_qp], 2);
Expand Down
10 changes: 5 additions & 5 deletions src/materials/RedbackMaterial.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ RedbackMaterial::validParams()
InputParameters params = Material::validParams();

params.addParam<std::vector<std::string>>(
"init_from_functions__params", "The names of the parameters to be initialised as functions.");
"init_from_functions__params",{}, "The names of the parameters to be initialised as functions.");
params.addParam<std::vector<FunctionName>>(
"init_from_functions__function_names",
"init_from_functions__function_names",{},
"The corresponding names of the functions to be used for the parameters "
"to be initialised as functions.");
params.addRangeCheckedParam<Real>("phi0", 0.0, "phi0>=0 & phi0<1", "initial porosity value.");
Expand Down Expand Up @@ -614,7 +614,7 @@ _ar_F[_qp] * _delta[_qp] * (1 - _total_porosity[_qp]) * (1 - _solid_ratio[_qp])
if (_are_convective_terms_on)
{
Real solid_density, fluid_density;
Real lambda_m_star, one_minus_phi_lambda_s, phi_lambda_f;
Real /*lambda_m_star,*/ one_minus_phi_lambda_s, phi_lambda_f;
RealVectorValue mixture_velocity, normalized_gravity;

// Forming the partial densities and gravity terms
Expand Down Expand Up @@ -649,8 +649,8 @@ _ar_F[_qp] * _delta[_qp] * (1 - _total_porosity[_qp]) * (1 - _solid_ratio[_qp])
phi_lambda_f = _total_porosity[_qp] * _fluid_thermal_expansion[_qp]; // normalized thermal
// expansion coefficient of
// the fluid phase
lambda_m_star =
one_minus_phi_lambda_s + phi_lambda_f; // normalized compressibility of the mixture
// lambda_m_star =
// one_minus_phi_lambda_s + phi_lambda_f; // normalized compressibility of the mixture

// Forming the velocities through mechanics and Darcy's flow law
if (_total_porosity[_qp] != 0)
Expand Down
9 changes: 5 additions & 4 deletions src/materials/RedbackMechMaterial.C
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RedbackMechMaterial::validParams()
// params.addRequiredParam< std::vector<Real> >("yield_stress", "Input data as
// pairs of equivalent plastic strain and yield stress: Should start with
// equivalent plastic strain 0");
params.addParam<std::vector<Real>>("yield_stress",
params.addParam<std::vector<Real>>("yield_stress",{},
"Input data as pairs of equivalent "
"plastic strain and yield stress: Should "
"start with equivalent plastic strain 0");
Expand Down Expand Up @@ -96,7 +96,7 @@ RedbackMechMaterial::validParams()
"temperature_reference", 0.0, "Reference temperature used for thermal expansion");
params.addParam<Real>("pressure_reference", 0.0, "Reference pressure used for compressibility");
params.addParam<std::vector<FunctionName>>(
"initial_stress",
"initial_stress",{},
"A list of functions describing the initial stress. If provided, there "
"must be 9 of these, corresponding to the xx, yx, zx, xy, yy, zy, xz, yz, "
"zz components respectively. If not provided, all components of the "
Expand Down Expand Up @@ -316,9 +316,10 @@ RedbackMechMaterial::computeStrain()
for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
{
// Deformation gradient
RankTwoTensor A(
auto A = RankTwoTensor ::initializeFromRows(
_grad_disp_x[_qp], _grad_disp_y[_qp], _grad_disp_z[_qp]); // Deformation gradient
RankTwoTensor Fbar(_grad_disp_x_old[_qp],
auto Fbar = RankTwoTensor ::initializeFromRows(
_grad_disp_x_old[_qp],
_grad_disp_y_old[_qp],
_grad_disp_z_old[_qp]); // Old Deformation gradient

Expand Down
6 changes: 3 additions & 3 deletions src/meshgenerators/BreakMeshBySidesetGenerator.C
Original file line number Diff line number Diff line change
Expand Up @@ -1067,13 +1067,13 @@ BreakMeshBySidesetGenerator::addLowerDElements(MeshBase & mesh)
subdomain_id_type
BreakMeshBySidesetGenerator::findFreeBlockId(MeshBase & mesh)
{
auto blocks = MooseMeshUtils::getSubdomainIDs(mesh, {"ANY_BLOCK_ID"});
std::set<subdomain_id_type> current_block_ids(blocks.begin(), blocks.end());
std::set<subdomain_id_type> currentBlockIds;
mesh.subdomain_ids(currentBlockIds);
bool free_block_not_found = true;
subdomain_id_type free_id;
for (free_id = 0; free_id < std::numeric_limits<subdomain_id_type>::max(); free_id++)
{
if (current_block_ids.count(free_id) == 0)
if (currentBlockIds.count(free_id) == 0)
{
// bid is not in the set, block ID is free
free_block_not_found = false;
Expand Down
2 changes: 1 addition & 1 deletion tests/image_meshing/adaptivity_loop.i
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
[Functions]
[./image_func]
type = ImageFunction
threshold = 90
threshold = 6e4
file_suffix = png
#these 2 lines needs to be paste in the next step of the simulation
#the image folder and the images selected
Expand Down
2 changes: 1 addition & 1 deletion tests/image_meshing/image_reader.i
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
type = ImageSubdomainGenerator
input = generate
file_suffix = png
threshold = 90
threshold = 6e4
#the image folder and the images selected
file_base = stack/test_0
#file_range = '32'
Expand Down

0 comments on commit 0122a0c

Please sign in to comment.