forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add element ID interface to support using extra element integers idah…
- Loading branch information
Showing
25 changed files
with
416 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!template load file=stubs/moose_object.md.template name=ElementIntegerAux syntax=/AuxKernels/ElementIntegerAux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "AuxKernel.h" | ||
|
||
class ElementIntegerAux; | ||
|
||
template <> | ||
InputParameters validParams<ElementIntegerAux>(); | ||
|
||
class ElementIntegerAux : public AuxKernel | ||
{ | ||
public: | ||
ElementIntegerAux(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual Real computeValue() override; | ||
|
||
unsigned int _id; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//* 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 <string> | ||
#include <memory> | ||
|
||
class InputParameters; | ||
class MooseObject; | ||
class MooseMesh; | ||
|
||
class ElementIDInterface | ||
{ | ||
public: | ||
ElementIDInterface(const MooseObject * moose_object); | ||
virtual ~ElementIDInterface() {} | ||
|
||
/** | ||
* Gets index of an element integer with a parameter of the object this interface attachs | ||
* @param id_name Name of object parameter | ||
* @param comp Component number for vector of integer names | ||
* @return Index of the element integer to be used in get_extra_integer() function | ||
*/ | ||
virtual unsigned int getElementID(const std::string & id_name, unsigned int comp = 0); | ||
|
||
private: | ||
/// Reference to the object's input parameters | ||
const InputParameters & _obj_parameters; | ||
|
||
/// References to the mesh and displaced mesh (currently in the ActionWarehouse) | ||
std::shared_ptr<MooseMesh> & _mesh; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//* 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 | ||
|
||
#include "ElementIntegerAux.h" | ||
|
||
registerMooseObject("MooseApp", ElementIntegerAux); | ||
|
||
template <> | ||
InputParameters | ||
validParams<ElementIntegerAux>() | ||
{ | ||
InputParameters params = validParams<AuxKernel>(); | ||
params.addClassDescription("Creates a field showing the element integer."); | ||
params.addParam<std::vector<std::string>>("integer_names", "Element integers to be retrieved"); | ||
return params; | ||
} | ||
|
||
ElementIntegerAux::ElementIntegerAux(const InputParameters & parameters) | ||
: AuxKernel(parameters), _id(getElementID("integer_names")) | ||
{ | ||
if (isNodal()) | ||
mooseError("ElementIntegerAux must be for an elemental variable"); | ||
} | ||
|
||
Real | ||
ElementIntegerAux::computeValue() | ||
{ | ||
return _current_elem->get_extra_integer(_id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//* 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 | ||
|
||
#include "ElementIDInterface.h" | ||
|
||
#include "InputParameters.h" | ||
#include "MooseObject.h" | ||
#include "MooseApp.h" | ||
#include "ActionWarehouse.h" | ||
#include "MooseMesh.h" | ||
|
||
#include "libmesh/mesh_base.h" | ||
|
||
ElementIDInterface::ElementIDInterface(const MooseObject * moose_object) | ||
: _obj_parameters(moose_object->parameters()), | ||
_mesh(moose_object->getMooseApp().actionWarehouse().mesh()) | ||
{ | ||
} | ||
|
||
unsigned int | ||
ElementIDInterface::getElementID(const std::string & id_name, unsigned int comp) | ||
{ | ||
auto & p = _obj_parameters.get<std::vector<std::string>>(id_name); | ||
if (comp >= p.size()) | ||
mooseError(id_name, " does not have enough integer names"); | ||
|
||
if (!_mesh.get()) | ||
mooseError("Mesh is not available for getting element integers"); | ||
|
||
auto mesh_base = _mesh->buildMeshBaseObject(); | ||
|
||
if (!mesh_base->has_elem_integer(p[comp])) | ||
mooseError("Mesh does not have an element integer names as ", p[comp]); | ||
|
||
return mesh_base->get_elem_integer_index(p[comp]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.