17 #include "libmesh/distributed_mesh.h" 18 #include "libmesh/equation_systems.h" 19 #include "libmesh/mesh_function.h" 20 #include "libmesh/explicit_system.h" 30 params.
addParam<
unsigned int>(
"refinements",
32 "Number of uniform refinements for oversampling " 33 "(refinement levels beyond any level of " 34 "refinements already applied on the regular mesh)");
36 "Set a positional offset, this vector will get added to the " 37 "nodal coordinates to move the domain.");
38 params.
addParam<MeshFileName>(
"file",
"The name of the mesh file to read, for oversampling");
39 params.
addParam<std::vector<SubdomainName>>(
40 "sampling_blocks",
"The list of blocks to restrict the mesh sampling to");
44 "If set to true, all sampled output (see sampling parameters) will be done " 45 "on rank 0. This option is useful to debug suspected parallel output issues");
50 "Append '_oversample' to the output file base",
51 "This parameter is deprecated. To append '_oversample' utilize " 52 "the output block name or the 'file_base'");
56 "Modified Mesh Sampling");
63 _refinements(getParam<unsigned
int>(
"refinements")),
64 _using_external_sampling_file(isParamValid(
"file")),
65 _change_position(isParamValid(
"position")),
66 _use_sampled_output(_refinements > 0 || _using_external_sampling_file ||
67 isParamValid(
"sampling_blocks") || _change_position),
68 _position(_change_position ? getParam<
Point>(
"position") :
Point()),
69 _sampling_mesh_changed(true),
70 _mesh_subdomains_match(true),
71 _serialize(getParam<bool>(
"serialize_sampling"))
108 TIME_SECTION(
"outputStep", 2,
"Outputting Step");
182 for (
auto & elem : dist_mesh->active_local_element_ptr_range())
187 const auto num_systems = source_es.
n_systems();
198 for (
const auto sys_num :
make_range(num_systems))
201 const auto & source_sys = source_es.
get_system(sys_num);
207 const auto num_vars = source_sys.
n_vars();
208 unsigned int num_actual_vars = 0;
215 for (
const auto var_num :
make_range(num_vars))
218 const auto & var_name = source_sys.variable_name(var_num);
219 if (!nodal_data.count(var_name) && !elemental_data.count(var_name))
227 : &source_sys.variable(var_num).active_subdomains();
230 const FEType & fe_type = source_sys.variable_type(var_num);
233 dest_sys.
add_variable(source_sys.variable_name(var_num), fe_type, subdomains);
236 "Variables sampled as nodal currently require serialization with a " 237 "distributed mesh.");
241 const auto & var_name = source_sys.variable_name(var_num);
245 "' onto a constant monomial");
248 "Projection without serialization may fail with insufficient ghosting. " 249 "Consider setting 'serialize_sampling' to true.");
284 const auto num_systems = source_es.
n_systems();
287 for (
const auto sys_num :
make_range(num_systems))
346 if (node->n_dofs(sys_num, var_num) &&
352 dest_sys.
solution->set(node->dof_number(sys_num, var_num, 0),
value);
355 "Sampling at location ",
359 " was outside the problem mesh.\nThis message will not be repeated"));
368 for (
const auto & elem : elem_range)
370 if (elem->n_dofs(sys_num, var_num) &&
376 dest_sys.
solution->set(elem->dof_number(sys_num, var_num, 0),
value);
379 "Sampling at location ",
381 " was outside the problem mesh.\nThis message will not be repeated."));
405 mesh_params.
set<
bool>(
"nemesis") =
false;
415 mooseWarning(
"Recovering or Restarting with oversampling may not work (especially with " 416 "adapted meshes)!! Refs #2295");
424 const auto & blocks_to_keep_names = getParam<std::vector<SubdomainName>>(
"sampling_blocks");
425 const auto & blocks_to_keep =
_sampling_mesh_ptr->getSubdomainIDs(blocks_to_keep_names);
427 if (std::find(blocks_to_keep.begin(), blocks_to_keep.end(), elem_ptr->subdomain_id()) ==
428 blocks_to_keep.end())
447 "CopyMeshPartitioner",
"sampled_output_part", partition_params);
473 const std::vector<SubdomainID> initial_mesh_subdomain_ids_vec(
480 mooseInfoRepeated(
"Variable block restriction disabled in sampled output due to non-matching " 481 "subdomain names and ids");
489 if (getParam<bool>(
"append_oversample"))
497 const auto continuity = FEInterface::get_continuity(fe_type);
498 return (continuity ==
C_ZERO || continuity ==
C_ONE);
virtual void setFileBaseInternal(const std::string &file_base)
Internal function that sets the file_base.
bool _use_sampled_output
Flag indicating that the sampled output should be used to re-sample the underlying EquationSystem of ...
virtual void updateSample()
Performs the update of the solution vector for the sample/re-positioned mesh.
const bool _change_position
Flag for re-positioning.
unsigned int n_systems() const
virtual void outputStep(const ExecFlagType &type) override
A single call to this function should output all the necessary data for a single timestep.
const ExecFlagType EXEC_FORCED
void allow_renumbering(bool allow)
virtual bool onInterval()
Returns true if the output interval is satisfied.
void skip_partitioning(bool skip)
SampledOutput(const InputParameters ¶meters)
const bool _using_external_sampling_file
Flag indicating another file is being used for the sampling.
const ExecFlagType EXEC_NONE
virtual void gather_to_zero()
void mooseInfoRepeated(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
const Parallel::Communicator & comm() const
std::string _file_base
The base filename from the input paramaters.
virtual bool shouldOutput()
Handles logic for determining if a step should be output.
virtual void output()
A single call to this function should output all the necessary data for a single timestep.
const Parallel::Communicator & _communicator
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
bool _mesh_subdomains_match
A flag tracking whether the sampling and source meshes match in terms of subdomains.
virtual void add_extra_ghost_elem(Elem *e)
const T_sys & get_system(std::string_view name) const
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
bool _serialize
Flag indicating whether we are outputting in serial or parallel.
dof_id_type n_dofs() const
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
std::unique_ptr< EquationSystems > _sampling_es
Equation system holding the solution vectors for the sampled variables.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Factory & _factory
The Factory associated with the MooseApp.
processor_id_type size() const
Real & _last_output_simulation_time
last simulation time an output has occured
virtual std::unique_ptr< Base > create()=0
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
std::vector< std::vector< unsigned int > > _variable_numbers_in_system
A vector of vectors that keeps track of the variable numbers in each system for each mesh function...
std::unique_ptr< MooseMesh > _sampling_mesh_ptr
Mesh used for sampling. The Output class' _mesh_ptr will refer to this mesh if sampling is being used...
ExecFlagType _current_execute_flag
Current execute on flag.
void initSample()
Setups the output object to produce re-positioned and/or sampled results.
virtual libMesh::EquationSystems & es() override
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
std::unique_ptr< NumericVector< Number > > solution
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
bool _allow_output
Flag for disabling output.
const std::string & type() const
Get the type of this class.
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
virtual void meshChanged() override
Called on this object when the mesh changes.
MooseApp & _app
The MOOSE application this is associated with.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
std::vector< SubdomainName > getSubdomainNames(const std::vector< SubdomainID > &subdomain_ids) const
Get the associated subdomainNames for the subdomain ids that are passed in.
const unsigned int _refinements
The number of oversampling refinements.
Based class for output objects.
virtual void initialSetup()
Call init() method on setup.
const FEType & variable_type(const unsigned int i) const
Class for containing MooseEnum item information.
virtual std::unique_ptr< MooseMesh > safeClone() const =0
A safer version of the clone() method that hands back an allocated object wrapped in a smart pointer...
Point _position
When oversampling, the output is shift by this amount.
Base class for MOOSE partitioner.
libMesh::EquationSystems * _es_ptr
Reference the the libMesh::EquationSystems object that contains the data.
bool _sampling_mesh_changed
A flag indicating that the mesh has changed and the sampled mesh needs to be re-initialized.
const MeshBase & get_mesh() const
IntRange< T > make_range(T beg, T end)
virtual MooseMesh & mesh() override
MooseMesh * _mesh_ptr
A convenience pointer to the current mesh (reference or displaced depending on "use_displaced") ...
const std::set< std::string > & getElementalVariableOutput()
The list of elemental nonlinear variables names that are set for output.
std::unique_ptr< NumericVector< Number > > _serialized_solution
Sample solution vector.
const InputParameters & parameters() const
Get the parameters of the object.
const std::set< std::string > & getNodalVariableOutput()
The list of nodal nonlinear variables names that are set for output.
void paramWarning(const std::string ¶m, Args... args) const
Emits a warning prefixed with the file and line number of the given param (from the input file) along...
static InputParameters validParams()
bool isSampledAtNodes(const FEType &fe_type) const
Used to decide which variable is sampled at nodes, then output as a nodal variable for (over)sampling...
unsigned int n_vars() const
processor_id_type processor_id() const
std::vector< std::vector< std::unique_ptr< libMesh::MeshFunction > > > _mesh_functions
A vector of pointers to the mesh functions on the sampled mesh This is only populated when the initSa...
bool isRecovering() const
Whether or not this is a "recover" calculation.
const DofMap & get_dof_map() const
const ExecFlagType EXEC_FINAL
static InputParameters validParams()
Real & _time
The current time for output purposes.
void ErrorVector unsigned int
auto index_range(const T &sizable)
virtual void setFileBaseInternal(const std::string &file_base) override
Appends the base class's file base string.
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
void cloneMesh()
Clone mesh in preperation for re-positioning or oversampling.
virtual void initialSetup() override
Call init() method on setup.
const ExecFlagType EXEC_INITIAL