Commit 21bd7fcb authored by Cody Permann's avatar Cody Permann

Checking in start of NekTransfer

parent ed7b5f5a
......@@ -309,18 +309,10 @@
[Transfers]
[./u_to_sub]
type = MultiAppNearestNodeTransfer
type = MultiAppPolynomialToNek
direction = to_multiapp
multi_app = sub
source_variable = u
variable = aux
[../]
[./u_from_sub]
type = MultiAppNearestNodeTransfer
direction = from_multiapp
multi_app = sub
source_variable = u
variable = aux
source_variable = 'heat_flux_scalar_f_0_l heat_flux_scalar_f_1_l'
to_aux_scalar = 'foo'
[../]
[]
#ifndef MULTIAPPPOLYNOMIALTONEK_H
#define MULTIAPPPOLYNOMIALTONEK_H
// MOOSE includes
#include "MultiAppTransfer.h"
// Forward declerations
class MultiAppPolynomialToNek;
template<>
InputParameters validParams<MultiAppPolynomialToNek>();
/**
* Copies the value of a Postprocessor from one app to a scalar AuxVariable in another.
*/
class MultiAppPolynomialToNek :
public MultiAppTransfer
{
public:
MultiAppPolynomialToNek(const InputParameters & parameters);
/**
* Execute the transfer
*/
virtual void execute() override;
protected:
std::vector<VariableName> _source_variable_names;
std::vector<VariableName> _to_aux_names;
};
#endif /* MULTIAPPPOLYNOMIALTONEK_H */
......@@ -21,6 +21,7 @@
#include "MoonRevision.h"
#include "NekExecutioner.h"
#include "NekTimeStepper.h"
#include "MultiAppPolynomialToNek.h"
template<>
InputParameters validParams<MoonApp>()
......@@ -75,19 +76,19 @@ extern "C" void MoonApp__registerObjects(Factory & factory) { MoonApp::registerO
void
MoonApp::registerObjects(Factory & factory)
{
// AuxKernels registration
registerAuxKernel(CoupledGradAux);
// Functions registration
registerFunction(LegendrePolynomial);
registerFunction(FourierPolynomial);
registerFunction(FourierLegendreReconstruction);
// UserObjects registration
registerUserObject(NekSideIntegralVariableUserObject);
registerExecutioner(NekExecutioner);
registerTimeStepper(NekTimeStepper);
registerTransfer(MultiAppPolynomialToNek);
}
// External entry point for dynamic syntax association
......
#include "MultiAppPolynomialToNek.h"
// MOOSE includes
#include "MooseTypes.h"
#include "FEProblem.h"
#include "MultiApp.h"
// libMesh includes
#include "libmesh/meshfree_interpolation.h"
#include "libmesh/system.h"
// Define the input parameters
template<>
InputParameters validParams<MultiAppPolynomialToNek>()
{
InputParameters params = validParams<MultiAppTransfer>();
params.addRequiredParam<std::vector<VariableName> >("source_variable", "The auxiliary scalar variable to read values from");
params.addRequiredParam<std::vector<VariableName> >("to_aux_scalar", "The name of the scalar Aux variable in the MultiApp to transfer the value to.");
return params;
}
MultiAppPolynomialToNek::MultiAppPolynomialToNek(const InputParameters & parameters) :
MultiAppTransfer(parameters),
_source_variable_names(getParam<std::vector<VariableName> >("source_variable")),
_to_aux_names(getParam<std::vector<VariableName> >("to_aux_scalar"))
{
}
void
MultiAppPolynomialToNek::execute()
{
_console << "Beginning PolynomialToNekTransfer " << name() << std::endl;
// Perform action based on the transfer direction
switch (_direction)
{
// MasterApp -> SubApp
case TO_MULTIAPP:
{
FEProblem & from_problem = _multi_app->problem();
std::vector<MooseVariableScalar *> source_variables(_source_variable_names.size());
for (auto i = beginIndex(_source_variable_names); i < _source_variable_names.size(); ++i)
{
source_variables[i] = &from_problem.getScalarVariable(_tid, _source_variable_names[i]);
source_variables[i]->reinit();
}
// Loop through each of the sub apps
for (unsigned int i=0; i<_multi_app->numGlobalApps(); i++)
if (_multi_app->hasLocalApp(i))
{
// TODO: Access Nek Common blocks and write values
for (auto i = beginIndex(_source_variable_names); i < _source_variable_names.size(); ++i)
{
_console << _source_variable_names[i] << '\n';
auto & solution_values = source_variables[i]->sln();
for (auto j = beginIndex(solution_values); j < solution_values.size(); ++j)
_console << solution_values[j] << ' ';
_console << '\n';
}
}
break;
}
// SubApp -> MasterApp
case FROM_MULTIAPP:
{
// The number of sub applications
unsigned int num_apps = _multi_app->numGlobalApps();
// // The AuxVariable for storing the postprocessor values from the sub app
// MooseVariableScalar & scalar = _multi_app->problem().getScalarVariable(_tid, _to_aux_name);
//
// // Ensure that the variable is up to date
// scalar.reinit();
//
// // The dof indices for the scalar variable of interest
// std::vector<dof_id_type> & dof = scalar.dofIndices();
//
// // Error if there is a size mismatch between the scalar AuxVariable and the number of sub apps
// if (num_apps != scalar.sln().size())
// mooseError("The number of sub apps (" << num_apps << ") must be equal to the order of the scalar AuxVariable (" << scalar.order() << ")");
//
// // Loop over each sub-app and populate the AuxVariable values from the postprocessors
// for (unsigned int i=0; i<_multi_app->numGlobalApps(); i++)
// if (_multi_app->hasLocalApp(i) && _multi_app->isRootProcessor())
// // Note: This can't be done using MooseScalarVariable::insert() because different processors will be setting dofs separately.
// scalar.sys().solution().set(dof[i], _multi_app->appProblem(i).getPostprocessorValue(_from_pp_name));
//
// scalar.sys().solution().close();
break;
}
}
_console << "Finished PolynomialToNekTransfer" << name() << std::endl;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment