Skip to content

Commit 02e75a0

Browse files
Clang formatted #31772
1 parent 8fdcb1e commit 02e75a0

File tree

12 files changed

+86
-73
lines changed

12 files changed

+86
-73
lines changed

framework/include/mfem/equation_systems/EquationSystem.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ class EquationSystem : public mfem::Operator
6161
/// Build bilinear forms
6262
virtual void BuildBilinearForms();
6363
virtual void BuildMixedBilinearForms();
64-
virtual void BuildEquationSystem(Moose::MFEM::GridFunctions & gridfunctions, mfem::Array<int> & btoffsets);
64+
virtual void BuildEquationSystem(Moose::MFEM::GridFunctions & gridfunctions,
65+
mfem::Array<int> & btoffsets);
6566

6667
/// Form linear system, with essential boundary conditions accounted for
6768
virtual void FormLinearSystem(mfem::OperatorHandle & op,
@@ -89,7 +90,7 @@ class EquationSystem : public mfem::Operator
8990
virtual void RecoverFEMSolution(mfem::BlockVector & trueX,
9091
Moose::MFEM::GridFunctions & gridfunctions);
9192

92-
void CopyVec(const mfem::Vector & x, mfem::Vector & y){ y = x;}
93+
void CopyVec(const mfem::Vector & x, mfem::Vector & y) { y = x; }
9394

9495
std::vector<mfem::Array<int>> _ess_tdof_lists;
9596

@@ -259,7 +260,6 @@ EquationSystem::ApplyDomainLFIntegrators(
259260
}
260261
}
261262

262-
263263
inline void
264264
EquationSystem::ApplyDomainNLActionIntegrators(
265265
const std::string & test_var_name,
@@ -284,8 +284,6 @@ EquationSystem::ApplyDomainNLActionIntegrators(
284284
}
285285
}
286286

287-
288-
289287
template <class FormType>
290288
void
291289
EquationSystem::ApplyBoundaryBLFIntegrators(
@@ -349,7 +347,8 @@ class TimeDependentEquationSystem : public EquationSystem
349347
void AddCoupledVariableNameIfMissing(const std::string & coupled_var_name) override;
350348

351349
virtual void SetTimeStep(mfem::real_t dt);
352-
virtual void UpdateEquationSystem(Moose::MFEM::GridFunctions & gridfunctions, mfem::Array<int> & btoffsets);
350+
virtual void UpdateEquationSystem(Moose::MFEM::GridFunctions & gridfunctions,
351+
mfem::Array<int> & btoffsets);
353352

354353
virtual void AddKernel(std::shared_ptr<MFEMKernel> kernel) override;
355354
virtual void BuildBilinearForms() override;

framework/include/mfem/functions/MFEMGradientGridFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ class MFEMGradientGridFunction : public MFEMGeneralUserObject
2929
const VariableName & _var_name;
3030
};
3131

32-
#endif
32+
#endif

framework/include/mfem/problem/MFEMProblem.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ class MFEMProblem : public ExternalProblem
208208
/**
209209
* set newton solver parameters
210210
*/
211-
void setNewtonParamaters(unsigned int nl_max_its, mfem::real_t nl_abs_tol, mfem::real_t nl_rel_tol, unsigned int print_level);
211+
void setNewtonParamaters(unsigned int nl_max_its,
212+
mfem::real_t nl_abs_tol,
213+
mfem::real_t nl_rel_tol,
214+
unsigned int print_level);
212215

213216
protected:
214217
MFEMProblemData _problem_data;

framework/src/mfem/equation_systems/EquationSystem.C

Lines changed: 54 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include "EquationSystem.h"
1313
#include "libmesh/int_range.h"
14-
#include "../../../contrib/mfem/general/forall.hpp"
1514

1615
namespace Moose::MFEM
1716
{
@@ -130,7 +129,7 @@ EquationSystem::Init(Moose::MFEM::GridFunctions & gridfunctions,
130129
mfem::AssemblyLevel assembly_level)
131130
{
132131
_assembly_level = assembly_level;
133-
132+
134133
// Extract which coupled variables are to be trivially eliminated and which are trial variables
135134
SetTrialVariableNames();
136135

@@ -328,7 +327,7 @@ EquationSystem::BuildJacobian(mfem::BlockVector & trueX, mfem::BlockVector & tru
328327
void
329328
EquationSystem::Mult(const mfem::Vector & sol, mfem::Vector & residual) const
330329
{
331-
const_cast<EquationSystem*>(this)->CopyVec(sol,_trueBlockSol);
330+
const_cast<EquationSystem *>(this)->CopyVec(sol, _trueBlockSol);
332331

333332
for (int i = 0; i < _trial_var_names.size(); i++)
334333
{
@@ -338,7 +337,7 @@ EquationSystem::Mult(const mfem::Vector & sol, mfem::Vector & residual) const
338337

339338
UpdateJacobian();
340339

341-
_BlockResidual=0.0;
340+
_BlockResidual = 0.0;
342341

343342
for (int i = 0; i < _test_var_names.size(); i++)
344343
{
@@ -358,40 +357,44 @@ EquationSystem::Mult(const mfem::Vector & sol, mfem::Vector & residual) const
358357
_BlockResidual.GetBlock(i) -= b;
359358
_BlockResidual.GetBlock(i) *= -1;
360359

361-
if(_non_linear)
362-
_BlockResidual.GetBlock(i).SetSubVector(_ess_tdof_lists.at(i),0.0);
360+
if (_non_linear)
361+
_BlockResidual.GetBlock(i).SetSubVector(_ess_tdof_lists.at(i), 0.0);
363362
}
364363

365-
if(!_non_linear){
366-
const_cast<EquationSystem*>(this)->FormLinearSystem(_jacobian, _trueBlockSol, _BlockResidual);
367-
const_cast<EquationSystem*>(this)->CopyVec(_BlockResidual, residual);
368-
}else{
369-
const_cast<EquationSystem*>(this)->CopyVec(_BlockResidual, residual);
370-
const_cast<EquationSystem*>(this)->FormLinearSystem(_jacobian, _trueBlockSol, _BlockResidual);
364+
if (!_non_linear)
365+
{
366+
const_cast<EquationSystem *>(this)->FormLinearSystem(_jacobian, _trueBlockSol, _BlockResidual);
367+
const_cast<EquationSystem *>(this)->CopyVec(_BlockResidual, residual);
368+
}
369+
else
370+
{
371+
const_cast<EquationSystem *>(this)->CopyVec(_BlockResidual, residual);
372+
const_cast<EquationSystem *>(this)->FormLinearSystem(_jacobian, _trueBlockSol, _BlockResidual);
371373
}
372374

373375
residual *= -1.0;
374376

375-
if(!_non_linear)
376-
{
377-
_jacobian->AddMult(sol, residual);
378-
}
377+
if (!_non_linear)
378+
{
379+
_jacobian->AddMult(sol, residual);
380+
}
379381

380382
sol.HostRead();
381383
residual.HostRead();
382384
}
383385

384386
void
385-
TimeDependentEquationSystem::UpdateEssDerivativeVals(const mfem::real_t & dt, const mfem::Vector & x_old)
387+
TimeDependentEquationSystem::UpdateEssDerivativeVals(const mfem::real_t & dt,
388+
const mfem::Vector & x_old)
386389
{
387-
//Update the old vector
390+
// Update the old vector
388391
mfem::BlockVector block_x_old;
389392
block_x_old.Update(*_block_true_offsets);
390393

391-
//Update the old vector
394+
// Update the old vector
392395
CopyVec(x_old, block_x_old);
393396

394-
//Update the xs boundary conditions
397+
// Update the xs boundary conditions
395398
ApplyEssentialBCs();
396399

397400
// Update the dxdts boundary conditions
@@ -407,28 +410,28 @@ EquationSystem::UpdateJacobian() const
407410
{
408411

409412
for (int i = 0; i < _test_var_names.size(); i++)
410-
{
411-
auto & test_var_name = _test_var_names.at(i);
412-
auto blf = _blfs.Get(test_var_name);
413-
blf->Update();
414-
blf->Assemble();
415-
}
413+
{
414+
auto & test_var_name = _test_var_names.at(i);
415+
auto blf = _blfs.Get(test_var_name);
416+
blf->Update();
417+
blf->Assemble();
418+
}
416419

417-
// Form off-diagonal blocks
418-
for (int i = 0; i < _test_var_names.size(); i++)
420+
// Form off-diagonal blocks
421+
for (int i = 0; i < _test_var_names.size(); i++)
422+
{
423+
auto test_var_name = _test_var_names.at(i);
424+
for (int j = 0; j < _test_var_names.size(); j++)
419425
{
420-
auto test_var_name = _test_var_names.at(i);
421-
for (int j = 0; j < _test_var_names.size(); j++)
426+
auto trial_var_name = _test_var_names.at(j);
427+
if (_mblfs.Has(test_var_name) && _mblfs.Get(test_var_name)->Has(trial_var_name))
422428
{
423-
auto trial_var_name = _test_var_names.at(j);
424-
if (_mblfs.Has(test_var_name) && _mblfs.Get(test_var_name)->Has(trial_var_name))
425-
{
426-
auto mblf = _mblfs.Get(test_var_name)->Get(trial_var_name);
427-
mblf->Update();
428-
mblf->Assemble();
429-
}
429+
auto mblf = _mblfs.Get(test_var_name)->Get(trial_var_name);
430+
mblf->Update();
431+
mblf->Assemble();
430432
}
431433
}
434+
}
432435
}
433436

434437
mfem::Operator &
@@ -554,7 +557,8 @@ EquationSystem::BuildMixedBilinearForms()
554557
}
555558

556559
void
557-
EquationSystem::BuildEquationSystem(Moose::MFEM::GridFunctions & gridfunctions, mfem::Array<int> & btoffsets)
560+
EquationSystem::BuildEquationSystem(Moose::MFEM::GridFunctions & gridfunctions,
561+
mfem::Array<int> & btoffsets)
558562
{
559563
_gfuncs = &gridfunctions;
560564
_block_true_offsets = &btoffsets;
@@ -721,13 +725,14 @@ TimeDependentEquationSystem::FormLegacySystem(mfem::OperatorHandle & op,
721725
// }
722726
mfem::Vector aux_x, aux_rhs;
723727
// Update solution values on Dirichlet values to be in terms of du/dt instead of u
724-
//mfem::Vector bc_x = *(_var_ess_constraints.at(i).get());
725-
//bc_x -= *_eliminated_variables.Get(test_var_name);
726-
//bc_x /= _dt_coef.constant;
728+
// mfem::Vector bc_x = *(_var_ess_constraints.at(i).get());
729+
// bc_x -= *_eliminated_variables.Get(test_var_name);
730+
// bc_x /= _dt_coef.constant;
727731

728732
// Form linear system for operator acting on vector of du/dt
729733
mfem::HypreParMatrix * aux_a = new mfem::HypreParMatrix;
730-
td_blf->FormLinearSystem(_ess_tdof_lists.at(i), *(_var_ess_constraints.at(i)), *lf, *aux_a, aux_x, aux_rhs);
734+
td_blf->FormLinearSystem(
735+
_ess_tdof_lists.at(i), *(_var_ess_constraints.at(i)), *lf, *aux_a, aux_x, aux_rhs);
731736
_h_blocks(i, i) = aux_a;
732737
truedXdt.GetBlock(i) = aux_x;
733738
trueRHS.GetBlock(i) = aux_rhs;
@@ -759,13 +764,14 @@ TimeDependentEquationSystem::FormSystem(mfem::OperatorHandle & op,
759764
// }
760765
mfem::Vector aux_x, aux_rhs;
761766
// Update solution values on Dirichlet values to be in terms of du/dt instead of u
762-
//mfem::Vector bc_x = *(_var_ess_constraints.at(0).get());
763-
//bc_x -= *_eliminated_variables.Get(test_var_name);
764-
//bc_x /= _dt_coef.constant;
767+
// mfem::Vector bc_x = *(_var_ess_constraints.at(0).get());
768+
// bc_x -= *_eliminated_variables.Get(test_var_name);
769+
// bc_x /= _dt_coef.constant;
765770

766771
// Form linear system for operator acting on vector of du/dt
767772
mfem::OperatorPtr aux_a;
768-
td_blf->FormLinearSystem(_ess_tdof_lists.at(0), *(_var_ess_constraints.at(0)), *lf, aux_a, aux_x, aux_rhs);
773+
td_blf->FormLinearSystem(
774+
_ess_tdof_lists.at(0), *(_var_ess_constraints.at(0)), *lf, aux_a, aux_x, aux_rhs);
769775

770776
truedXdt.GetBlock(0) = aux_x;
771777
trueRHS.GetBlock(0) = aux_rhs;
@@ -778,7 +784,8 @@ TimeDependentEquationSystem::FormSystem(mfem::OperatorHandle & op,
778784
}
779785

780786
void
781-
TimeDependentEquationSystem::UpdateEquationSystem(Moose::MFEM::GridFunctions & gridfunctions, mfem::Array<int> & btoffsets)
787+
TimeDependentEquationSystem::UpdateEquationSystem(Moose::MFEM::GridFunctions & gridfunctions,
788+
mfem::Array<int> & btoffsets)
782789
{
783790
EquationSystem::BuildEquationSystem(gridfunctions, btoffsets);
784791
}

framework/src/mfem/executioners/MFEMProblemSolve.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ MFEMProblemSolve::MFEMProblemSolve(
4646
: _app.isUltimateMaster() ? "cpu"
4747
: "",
4848
Moose::PassKey<MFEMProblemSolve>());
49-
49+
5050
_mfem_problem.setNewtonParamaters(_nl_max_its, _nl_abs_tol, _nl_rel_tol, _print_level);
5151
}
5252

framework/src/mfem/functions/MFEMGradientGridFunction.C

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ MFEMGradientGridFunction::validParams()
2020
InputParameters params = MFEMGeneralUserObject::validParams();
2121
params.registerBase("Function");
2222
params.addClassDescription("Creates a GradientGridFunctionCoefficient out of a variable");
23-
params.addRequiredParam<VariableName>("var_name",
24-
"The names of the gridfunction variable");
23+
params.addRequiredParam<VariableName>("var_name", "The names of the gridfunction variable");
2524
return params;
2625
}
2726

2827
MFEMGradientGridFunction::MFEMGradientGridFunction(const InputParameters & parameters)
29-
: MFEMGeneralUserObject(parameters),
30-
_var_name(getParam<VariableName>("var_name"))
28+
: MFEMGeneralUserObject(parameters), _var_name(getParam<VariableName>("var_name"))
3129
{
3230
// declares GradientGridFunctionCoefficient
3331
getMFEMProblem().getCoefficients().declareVector<mfem::GradientGridFunctionCoefficient>(
@@ -36,4 +34,4 @@ MFEMGradientGridFunction::MFEMGradientGridFunction(const InputParameters & param
3634

3735
MFEMGradientGridFunction::~MFEMGradientGridFunction() {}
3836

39-
#endif
37+
#endif

framework/src/mfem/kernels/MFEMDomainLFGradKernel.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ MFEMDomainLFGradKernel::MFEMDomainLFGradKernel(const InputParameters & parameter
3737
mfem::LinearFormIntegrator *
3838
MFEMDomainLFGradKernel::createNLActionIntegrator()
3939
{
40-
mfem::VectorCoefficient & vec_coef = getMFEMProblem().getCoefficients().getVectorCoefficient(name());
40+
mfem::VectorCoefficient & vec_coef =
41+
getMFEMProblem().getCoefficients().getVectorCoefficient(name());
4142
_product_coeff = new mfem::ScalarVectorProductCoefficient(_coef, vec_coef);
4243
return new mfem::DomainLFGradIntegrator(*_product_coeff);
4344
}
4445

45-
4646
#endif

framework/src/mfem/kernels/MFEMMixedScalarWeakDivergenceKernel.C

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,22 @@ MFEMMixedScalarWeakDivergenceKernel::validParams()
2727
return params;
2828
}
2929

30-
MFEMMixedScalarWeakDivergenceKernel::MFEMMixedScalarWeakDivergenceKernel(const InputParameters & parameters)
30+
MFEMMixedScalarWeakDivergenceKernel::MFEMMixedScalarWeakDivergenceKernel(
31+
const InputParameters & parameters)
3132
: MFEMKernel(parameters), _coef(getScalarCoefficient("coefficient"))
3233
// FIXME: The MFEM bilinear form can also handle vector and matrix
3334
// coefficients, so ideally we'd handle all three too.
3435
{
35-
// declares GradientGridFunctionCoefficient
36+
// declares GradientGridFunctionCoefficient
3637
getMFEMProblem().getCoefficients().declareVector<mfem::GradientGridFunctionCoefficient>(
3738
name(), getMFEMProblem().getProblemData().gridfunctions.Get(_test_var_name));
3839
}
3940

4041
mfem::BilinearFormIntegrator *
4142
MFEMMixedScalarWeakDivergenceKernel::createBFIntegrator()
4243
{
43-
mfem::VectorCoefficient & vec_coef = getMFEMProblem().getCoefficients().getVectorCoefficient(name());
44+
mfem::VectorCoefficient & vec_coef =
45+
getMFEMProblem().getCoefficients().getVectorCoefficient(name());
4446
_product_coef = new mfem::ScalarVectorProductCoefficient(_coef, vec_coef);
4547
return new mfem::MixedScalarWeakDivergenceIntegrator(*_product_coef);
4648
}

framework/src/mfem/problem/MFEMProblem.C

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,11 @@ MFEMProblem::getGridFunction(const std::string & name)
510510
return getUserObject<MFEMVariable>(name).getGridFunction();
511511
}
512512

513-
void
514-
MFEMProblem::setNewtonParamaters(unsigned int nl_max_its, mfem::real_t nl_abs_tol, mfem::real_t nl_rel_tol, unsigned int print_level)
513+
void
514+
MFEMProblem::setNewtonParamaters(unsigned int nl_max_its,
515+
mfem::real_t nl_abs_tol,
516+
mfem::real_t nl_rel_tol,
517+
unsigned int print_level)
515518
{
516519
_nl_max_its = nl_max_its;
517520
_nl_abs_tol = nl_abs_tol;

framework/src/mfem/problem_operators/EquationSystemProblemOperator.C

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ EquationSystemProblemOperator::Solve()
3535

3636
for (const auto i : index_range(_test_var_names))
3737
{
38-
auto & test_var_name = _test_var_names.at(i);
39-
*(GetEquationSystem()->_var_ess_constraints.at(i)) = *(_problem_data.gridfunctions.GetShared(test_var_name));
38+
auto & test_var_name = _test_var_names.at(i);
39+
*(GetEquationSystem()->_var_ess_constraints.at(i)) =
40+
*(_problem_data.gridfunctions.GetShared(test_var_name));
4041
}
41-
42+
4243
GetEquationSystem()->ApplyEssentialBCs();
4344
GetEquationSystem()->BuildJacobian(_true_x, _true_rhs);
4445

0 commit comments

Comments
 (0)