本文整理汇总了C++中MooseApp类的典型用法代码示例。如果您正苦于以下问题:C++ MooseApp类的具体用法?C++ MooseApp怎么用?C++ MooseApp使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MooseApp类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mooseError
void
FullSolveMultiApp::initialSetup()
{
MultiApp::initialSetup();
if (_has_an_app)
{
MPI_Comm swapped = Moose::swapLibMeshComm(_my_comm);
_executioners.resize(_my_num_apps);
// Grab Executioner from each app
for (unsigned int i=0; i<_my_num_apps; i++)
{
MooseApp * app = _apps[i];
Executioner * ex = app->getExecutioner();
if (!ex)
mooseError("Executioner does not exist!");
ex->init();
_executioners[i] = ex;
}
// Swap back
Moose::swapLibMeshComm(swapped);
}
}
示例2: mooseError
void
TransientMultiApp::setupApp(unsigned int i, Real /*time*/) // FIXME: Should we be passing time?
{
MooseApp * app = _apps[i];
Transient * ex = dynamic_cast<Transient *>(app->getExecutioner());
if (!ex)
mooseError("MultiApp " << name() << " is not using a Transient Executioner!");
// Get the FEProblemBase for the current MultiApp
FEProblemBase & problem = appProblemBase(_first_local_app + i);
// Update the file numbers for the outputs from the parent application
app->getOutputWarehouse().setFileNumbers(_app.getOutputFileNumbers());
// Call initialization method of Executioner (Note, this preforms the output of the initial time step, if desired)
ex->init();
if (_interpolate_transfers)
{
AuxiliarySystem & aux_system = problem.getAuxiliarySystem();
System & libmesh_aux_system = aux_system.system();
// We'll store a copy of the auxiliary system's solution at the old time in here
libmesh_aux_system.add_vector("transfer_old", false);
// This will be where we'll transfer the value to for the "target" time
libmesh_aux_system.add_vector("transfer", false);
}
ex->preExecute();
problem.advanceState();
_transient_executioners[i] = ex;
}
示例3: mooseAssert
std::string
FileOutput::getOutputFileBase(MooseApp & app, std::string suffix)
{
// If the App has an outputfile, then use it (MultiApp scenario)
if (!app.getOutputFileBase().empty())
return app.getOutputFileBase();
// If the output base is not set it must be determined from the input file
/* This will only return a non-empty string if the setInputFileName() was called, which is
* generally not the case. One exception is when CoupledExecutioner is used */
std::string input_filename = app.getInputFileName();
if (input_filename.empty())
input_filename = app.getFileName();
// Assert that the filename is not empty
mooseAssert(!input_filename.empty(), "Input Filename is NULL");
// Determine location of "." in extension, assert if it is not found
size_t pos = input_filename.find_last_of('.');
mooseAssert(pos != std::string::npos, "Unable to determine suffix of input file name");
// Append the "_out" to the name and return it
size_t start = 0;
if (input_filename.find_last_of('/') != std::string::npos)
start = input_filename.find_last_of('/') + 1;
return input_filename.substr(start, pos - start) + suffix;
}
示例4: name
void
MultiApp::createApp(unsigned int i, Real start_time)
{
// Define the app name
std::ostringstream multiapp_name;
std::string full_name;
multiapp_name << name() << std::setw(std::ceil(std::log10(_total_num_apps)))
<< std::setprecision(0) << std::setfill('0') << std::right << _first_local_app + i;
// Only add parent name if it the parent is not the main app
if (_app.multiAppLevel() > 0)
full_name = _app.name() + "_" + multiapp_name.str();
else
full_name = multiapp_name.str();
InputParameters app_params = AppFactory::instance().getValidParams(_app_type);
app_params.set<FEProblem *>("_parent_fep") = _fe_problem;
app_params.set<MooseSharedPointer<CommandLine> >("_command_line") = _app.commandLine();
MooseApp * app = AppFactory::instance().create(_app_type, full_name, app_params, _my_comm);
_apps[i] = app;
std::string input_file = "";
if (_input_files.size() == 1) // If only one input file was provided, use it for all the solves
input_file = _input_files[0];
else
input_file = _input_files[_first_local_app+i];
std::ostringstream output_base;
// Create an output base by taking the output base of the master problem and appending
// the name of the multiapp + a number to it
if (!_app.getOutputFileBase().empty())
output_base << _app.getOutputFileBase() + "_";
else
{
std::string base = _app.getFileName();
size_t pos = base.find_last_of('.');
output_base << base.substr(0, pos) + "_out_";
}
// Append the sub app name to the output file base
output_base << multiapp_name.str();
app->setGlobalTimeOffset(start_time);
app->setInputFileName(input_file);
app->setOutputFileBase(output_base.str());
app->setOutputFileNumbers(_app.getOutputWarehouse().getFileNumbers());
if (getParam<bool>("output_in_position"))
app->setOutputPosition(_app.getOutputPosition() + _positions[_first_local_app + i]);
// Update the MultiApp level for the app that was just created
app->setMultiAppLevel(_app.multiAppLevel() + 1);
app->setupOptions();
app->runInputFile();
}
示例5: mooseError
void
TransientMultiApp::setupApp(unsigned int i, Real /*time*/, bool output_initial) // FIXME: Should we be passing time?
{
MooseApp * app = _apps[i];
Transient * ex = dynamic_cast<Transient *>(app->getExecutioner());
if (!ex)
mooseError("MultiApp " << _name << " is not using a Transient Executioner!");
// Get the FEProblem and OutputWarehouse for the current MultiApp
FEProblem * problem = appProblem(_first_local_app + i);
OutputWarehouse & output_warehouse = _apps[i]->getOutputWarehouse();
if (!output_initial)
{
ex->outputInitial(false);//\todo{Remove; handled within ex->init()}
output_warehouse.allowOutput(false);
}
// Set the file numbers of the i-th app to that of the parent app
output_warehouse.setFileNumbers(app->getOutputFileNumbers());
// Call initialization method of Executioner (Note, this preforms the output of the initial time step, if desired)
ex->init();
// Enable output after setup
output_warehouse.allowOutput(true);
if (_interpolate_transfers)
{
AuxiliarySystem & aux_system = problem->getAuxiliarySystem();
System & libmesh_aux_system = aux_system.system();
// We'll store a copy of the auxiliary system's solution at the old time in here
libmesh_aux_system.add_vector("transfer_old", false);
// This will be where we'll transfer the value to for the "target" time
libmesh_aux_system.add_vector("transfer", false);
}
ex->preExecute();
problem->copyOldSolutions();
_transient_executioners[i] = ex;
if (_detect_steady_state || _tolerate_failure)
{
_apps[i]->getOutputWarehouse().allowOutput(false);
ex->allowOutput(false);
}
}
示例6: outputOutputInformation
std::string
outputOutputInformation(MooseApp & app)
{
std::stringstream oss;
oss << std::left;
const std::vector<Output *> outputs = app.getOutputWarehouse().getOutputs<Output>();
oss << "Outputs:\n";
for (std::vector<Output *>::const_iterator it = outputs.begin(); it != outputs.end(); ++it)
{
// Display the "execute_on" settings
const MultiMooseEnum & execute_on = (*it)->executeOn();
oss << " " << std::setw(console_field_width-2) << (*it)->name() << "\"" << execute_on << "\"\n";
// Display the advanced "execute_on" settings, only if they are different from "execute_on"
if ((*it)->isAdvanced())
{
const OutputOnWarehouse & adv_on = (*it)->advancedExecuteOn();
for (std::map<std::string, MultiMooseEnum>::const_iterator adv_it = adv_on.begin(); adv_it != adv_on.end(); ++adv_it)
if (execute_on != adv_it->second)
oss << " " << std::setw(console_field_width-4) << adv_it->first + ":" << "\"" << adv_it->second << "\"\n";
}
}
return oss.str();
}
示例7: outputExecutionInformation
std::string
outputExecutionInformation(MooseApp & app, FEProblem & problem)
{
std::stringstream oss;
oss << std::left;
Executioner * exec = app.getExecutioner();
oss << "Execution Information:\n"
<< std::setw(console_field_width) << " Executioner: " << demangle(typeid(*exec).name()) << '\n';
std::string time_stepper = exec->getTimeStepperName();
if (time_stepper != "")
oss << std::setw(console_field_width) << " TimeStepper: " << time_stepper << '\n';
oss << std::setw(console_field_width) << " Solver Mode: " << Moose::stringify<Moose::SolveType>(problem.solverParams()._type) << '\n';
const std::string & pc_desc = problem.getPetscOptions().pc_description;
if (!pc_desc.empty())
oss << std::setw(console_field_width) << " Preconditioner: " << pc_desc << '\n';
oss << '\n';
return oss.str();
}
示例8: outputFrameworkInformation
std::string
outputFrameworkInformation(MooseApp & app)
{
std::stringstream oss;
oss << std::left;
if (app.getSystemInfo() != NULL)
oss << app.getSystemInfo()->getInfo();
oss << std::left
<< "Parallelism:\n"
<< std::setw(console_field_width) << " Num Processors: " << static_cast<std::size_t>(app.n_processors()) << '\n'
<< std::setw(console_field_width) << " Num Threads: " << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
<< '\n';
return oss.str();
}
示例9: main
// 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
HyraxApp::registerApps();
// This creates dynamic memory that we're responsible for deleting
MooseApp * app = AppFactory::createApp("HyraxApp", argc, argv);
// Execute the application
app->run();
// Free up the memory we created earlier
delete app;
return 0;
}
示例10: main
// 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
SolidMechanicsApp::registerApps();
// This creates dynamic memory that we're responsible for deleting
MooseApp * app = AppFactory::createApp("SolidMechanicsApp", argc, argv);
app->setCheckUnusedFlag(true);
app->setErrorOverridden();
// Execute the application
app->run();
// Free up the memory we created earlier
delete app;
return 0;
}
示例11: initPostprocessorOrVectorPostprocessorLists
void
initPostprocessorOrVectorPostprocessorLists(OutputData & output_data, warehouse_type & warehouse, bool & has_limited_pps, MooseApp & app, std::string & name, InputParameters & params)
{
// Loop through each of the execution flags
for (unsigned int i = 0; i < Moose::exec_types.size(); i++)
{
// Loop through each of the postprocessors
for (typename std::vector<postprocessor_type *>::const_iterator postprocessor_it = warehouse(Moose::exec_types[i])[0].all().begin();
postprocessor_it != warehouse(Moose::exec_types[i])[0].all().end();
++postprocessor_it)
{
// Store the name in the available postprocessors
postprocessor_type *pps = *postprocessor_it;
output_data.available.push_back(pps->PPName());
// Extract the list of outputs
std::set<OutputName> pps_outputs = pps->getOutputs();
// Check that the outputs are valid
app.getOutputWarehouse().checkOutputs(pps_outputs);
/* Hide the postprocessor if:
* (1) The "outputs" parameter is NOT empty and
* (2) 'all' is NOT found in the 'outputs' parameter and
* (3) 'none' is used within the 'outputs' parameter or
* (4) this output object name is not found in the list of output names
*/
if ( !pps_outputs.empty() && pps_outputs.find("all") == pps_outputs.end() &&
(pps_outputs.find("none") != pps_outputs.end() || pps_outputs.find(name) == pps_outputs.end()) )
output_data.hide.push_back(pps->PPName());
// Check that the output object allows postprocessor output, account for "all" keyword (if it is present assume "all" was desired)
if ( pps_outputs.find(name) != pps_outputs.end() || pps_outputs.find("all") != pps_outputs.end() )
{
if (!params.isParamValid("output_postprocessors"))
mooseWarning("Postprocessor '" << pps->PPName()
<< "' has requested to be output by the '" << name
<< "' output, but postprocessor output is not support by this type of output object.");
}
// Set the flag state for postprocessors that utilize 'outputs' parameter
if (!pps_outputs.empty() && pps_outputs.find("all") == pps_outputs.end())
has_limited_pps = true;
}
}
}
示例12:
void
MinimalApp::createMinimalAppTest()
{
const char *argv[1] = { "\0" };
MooseApp * app = AppFactory::createApp("MooseUnitApp", 1, (char**)argv);
app->parameters().set<bool>("minimal") = true;
app->run();
CPPUNIT_ASSERT(app->executioner()->name() == "Executioner");
CPPUNIT_ASSERT(app->executioner()->feProblem().name() == "MOOSE Problem");
CPPUNIT_ASSERT(app->executioner()->feProblem().mesh().nElem() == 1);
delete app;
}
示例13: main
// 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
LinearElasticityApp::registerApps();
// This creates dynamic memory that we're responsible for deleting
MooseApp * app = AppFactory::createApp("LinearElasticityApp", argc, argv);
app->setCheckUnusedFlag(true);
app->setErrorOverridden();
app->legacyUoInitializationDefault() = true;
app->legacyUoAuxComputationDefault() = false;
// Execute the application
app->run();
// Free up the memory we created earlier
delete app;
return 0;
}