forked from idaholab/moose
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancing access to Output objects (closes idaholab#2885)
- Loading branch information
1 parent
912a736
commit ec95a6d
Showing
8 changed files
with
331 additions
and
13 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
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,53 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ | ||
/* */ | ||
/* (c) 2010 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by Battelle Energy Alliance, LLC */ | ||
/* Under Contract No. DE-AC07-05ID14517 */ | ||
/* With the U. S. Department of Energy */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
|
||
#ifndef OUTPUTOBJECTTEST_H | ||
#define OUTPUTOBJECTTEST_H | ||
|
||
// MOOSE includes | ||
#include "Console.h" | ||
|
||
// Forward declerations | ||
class OutputObjectTest; | ||
|
||
template<> | ||
InputParameters validParams<OutputObjectTest>(); | ||
|
||
/** | ||
* | ||
*/ | ||
class OutputObjectTest : public Console | ||
{ | ||
public: | ||
|
||
/** | ||
* Class constructor | ||
* @param name | ||
* @param InputParameters | ||
*/ | ||
OutputObjectTest(const std::string & name, InputParameters parameters); | ||
|
||
/** | ||
* Class destructor | ||
*/ | ||
virtual ~OutputObjectTest(); | ||
|
||
void initialSetup(); | ||
|
||
private: | ||
MooseEnum _type; | ||
|
||
}; | ||
|
||
#endif //OUTPUTOBJECTTEST_H |
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,76 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ | ||
/* */ | ||
/* (c) 2010 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by Battelle Energy Alliance, LLC */ | ||
/* Under Contract No. DE-AC07-05ID14517 */ | ||
/* With the U. S. Department of Energy */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
|
||
#include "OutputObjectTest.h" | ||
#include "MooseApp.h" | ||
#include "Exodus.h" | ||
|
||
template<> | ||
InputParameters validParams<OutputObjectTest>() | ||
{ | ||
MooseEnum type("getOutput, getOutputs-names, getOutputs, getOutputNames"); | ||
InputParameters params = validParams<Console>(); | ||
params.addRequiredParam<MooseEnum>("test_type", type, "The type of test to execute"); | ||
return params; | ||
} | ||
|
||
OutputObjectTest::OutputObjectTest(const std::string & name, InputParameters parameters) : | ||
Console(name, parameters), | ||
_type(getParam<MooseEnum>("test_type")) | ||
{ | ||
} | ||
|
||
OutputObjectTest::~OutputObjectTest() | ||
{ | ||
} | ||
|
||
void | ||
OutputObjectTest::initialSetup() | ||
{ | ||
Console::initialSetup(); | ||
|
||
if (_type == "getOutput") | ||
{ | ||
OutputObjectTest * ptr = _app.getOutputWarehouse().getOutput<OutputObjectTest>(_name); | ||
if (ptr == this) | ||
mooseError("getOutput test passed"); | ||
} | ||
|
||
else if (_type == "getOutputs") | ||
{ | ||
std::vector<Exodus *> ptrs = _app.getOutputWarehouse().getOutputs<Exodus>(); | ||
if (ptrs.size() == 2 && ptrs[0]->name().compare("exodus") == 0 && ptrs[1]->name().compare("exodus2") == 0) | ||
mooseError("getOutputs test passed"); | ||
} | ||
|
||
else if (_type == "getOutputs-names") | ||
{ | ||
std::vector<std::string> names; | ||
names.push_back("exodus2"); | ||
names.push_back("exodus"); | ||
std::vector<Exodus *> ptrs = _app.getOutputWarehouse().getOutputs<Exodus>(names); | ||
if (ptrs.size() == 2 && ptrs[0]->name().compare("exodus2") == 0 && ptrs[1]->name().compare("exodus") == 0) | ||
mooseError("getOutputs-names test passed"); | ||
} | ||
|
||
else if (_type == "getOutputNames") | ||
{ | ||
std::vector<std::string> names = _app.getOutputWarehouse().getOutputNames<Exodus>(); | ||
if (names.size() == 2 && names[0].compare("exodus") == 0 && names[1].compare("exodus2") == 0) | ||
mooseError("getOutputsNames test passed"); | ||
} | ||
|
||
else | ||
mooseError("You must specify a 'test_type'"); | ||
} |
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,30 @@ | ||
[Tests] | ||
[./getOutput] | ||
type = RunException | ||
input = warehouse_access.i | ||
cli_args = 'Outputs/test/test_type=getOutput' | ||
expect_err = "getOutput test passed" | ||
max_parallel = 1 | ||
[../] | ||
[./getOutputs] | ||
type = RunException | ||
input = warehouse_access.i | ||
cli_args = 'Outputs/test/test_type=getOutputs' | ||
expect_err = "getOutputs test passed" | ||
max_parallel = 1 | ||
[../] | ||
[./getOutputs_with_names] | ||
type = RunException | ||
input = warehouse_access.i | ||
cli_args = 'Outputs/test/test_type=getOutputs-names' | ||
expect_err = "getOutputs-names test passed" | ||
max_parallel = 1 | ||
[../] | ||
[./getOutputNames] | ||
type = RunException | ||
input = warehouse_access.i | ||
cli_args = 'Outputs/test/test_type=getOutputNames' | ||
expect_err = "getOutputsNames test passed" | ||
max_parallel = 1 | ||
[../] | ||
[] |
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,56 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 2 | ||
nx = 10 | ||
ny = 10 | ||
[] | ||
|
||
[Variables] | ||
[./u] | ||
[../] | ||
[] | ||
|
||
[Kernels] | ||
[./diff] | ||
type = Diffusion | ||
variable = u | ||
[../] | ||
[] | ||
|
||
[BCs] | ||
[./left] | ||
type = DirichletBC | ||
variable = u | ||
boundary = left | ||
value = 0 | ||
[../] | ||
[./right] | ||
type = DirichletBC | ||
variable = u | ||
boundary = right | ||
value = 1 | ||
[../] | ||
[] | ||
|
||
[Executioner] | ||
type = Steady | ||
|
||
# Preconditioned JFNK (default) | ||
solve_type = 'PJFNK' | ||
|
||
|
||
petsc_options_iname = '-pc_type -pc_hypre_type' | ||
petsc_options_value = 'hypre boomeramg' | ||
[] | ||
|
||
[Outputs] | ||
exodus = true | ||
vtk = true | ||
[./exodus2] | ||
type = Exodus | ||
file_base = exodus2 | ||
[../] | ||
[./test] | ||
type = OutputObjectTest | ||
[../] | ||
[] |
This is what I need, works for me.