4 #include "UserObject.h"
5 #include "MaterialBase.h"
8 #include "moab/Core.hpp"
9 #include "moab/Skinner.hpp"
10 #include "moab/GeomTopoTool.hpp"
11 #include "MBTagConventions.hpp"
14 #include <libmesh/elem.h>
15 #include <libmesh/enum_io_package.h>
16 #include <libmesh/enum_order.h>
17 #include <libmesh/enum_fe_family.h>
18 #include <libmesh/equation_systems.h>
19 #include <libmesh/system.h>
20 #include <libmesh/mesh_tools.h>
21 #include <libmesh/mesh_function.h>
34 InputParameters validParams<MoabUserObject>();
62 throw std::logic_error(
"Problem passed is null");
85 bool setSolution(std::string var_now,std::vector< double > &results,
double scaleFactor=1.,
bool isErr=
false,
bool normToVol=
true);
89 std::vector<double>& initial_densities,
90 std::vector<std::string>& tails,
91 std::vector<MOABMaterialProperties>& properties);
101 enum Sense { BACKWARDS=-1, FORWARDS=1};
105 moab::EntityHandle vol;
118 System&
system(std::string var_now);
123 moab::ErrorCode
createNodes(std::map<dof_id_type,moab::EntityHandle>& node_id_to_handle);
125 void createElems(std::map<dof_id_type,moab::EntityHandle>& node_id_to_handle);
131 moab::ErrorCode
createGroup(
unsigned int id, std::string name,moab::EntityHandle& group_set);
134 moab::ErrorCode
createVol(
unsigned int id,moab::EntityHandle& volume_set,moab::EntityHandle group_set);
137 moab::ErrorCode
createSurf(
unsigned int id,moab::EntityHandle& surface_set, moab::Range& faces, std::vector<VolData> & voldata);
143 moab::ErrorCode
createSurfaceFromBox(
const BoundingBox& box,
VolData& voldata,
unsigned int& surf_id,
bool normalout,
double factor=1.0);
146 moab::ErrorCode
createNodesFromBox(
const BoundingBox& box,
double factor,std::vector<moab::EntityHandle>& vert_handles);
149 moab::ErrorCode
createCornerTris(
const std::vector<moab::EntityHandle> & verts,
150 unsigned int corner,
unsigned int v1,
151 unsigned int v2 ,
unsigned int v3,
152 bool normalout, moab::Range &surface_tris);
155 moab::ErrorCode
createTri(
const std::vector<moab::EntityHandle> & vertices,
unsigned int v1,
unsigned int v2 ,
unsigned int v3, moab::Range &surface_tris);
161 moab::ErrorCode
setTags(moab::EntityHandle ent,std::string name, std::string category,
unsigned int id,
int dim);
164 moab::ErrorCode
setTagData(moab::Tag tag, moab::EntityHandle ent, std::string data,
unsigned int SIZE);
167 moab::ErrorCode
setTagData(moab::Tag tag, moab::EntityHandle ent,
void* data);
170 bool getTetSets(ElemType type, std::vector< std::vector<unsigned int> > &perms);
173 moab::ErrorCode
buildGraveyard(
unsigned int & vol_id,
unsigned int & surf_id);
176 std::vector<Point>
boxCoords(
const BoundingBox& box,
double factor);
185 void addElem(dof_id_type
id,moab::EntityHandle ent);
188 void setSolution(
unsigned int iSysNow,
unsigned int iVarNow,std::vector< double > &results,
double scaleFactor,
bool isErr,
bool normToVol);
191 dof_id_type
elem_to_soln_index(
const Elem& elem,
unsigned int iSysNow,
unsigned int iVarNow);
204 std::shared_ptr<MeshFunction>
getMeshFunction(std::string var_name_in);
214 void groupLocalElems(std::set<dof_id_type> elems, std::vector<moab::Range>& localElems);
226 int getSortBin(
int iVarBin,
int iDenBin,
int iMat,
227 int nVarBinsIn,
int nDenBinsIn,
int nMatsIn);
235 int getMatBin(
int iVarBin,
int iDenBin,
int nVarBinsIn,
int nDenBinsIn);
252 void calcMidpointsLin(
double var_min_in,
double bin_width_in,
int nbins_in,std::vector<double>& midpoints_in);
264 bool findSurface(
const moab::Range& region,moab::EntityHandle group,
unsigned int & vol_id,
unsigned int & surf_id,moab::EntityHandle& volume_set);
279 std::unique_ptr< moab::GeomTopoTool >
gtt;
Convenience struct.
Definition: MoabUserObject.h:24
moab::ErrorCode setTagData(moab::Tag tag, moab::EntityHandle ent, std::string data, unsigned int SIZE)
Helper function to wrap moab::tag_set_data for a string.
Definition: MoabUserObject.C:680
double var_min
Minimum value of our variable.
Definition: MoabUserObject.h:302
moab::ErrorCode createCornerTris(const std::vector< moab::EntityHandle > &verts, unsigned int corner, unsigned int v1, unsigned int v2, unsigned int v3, bool normalout, moab::Range &surface_tris)
Create 3 tri faces stemming from one corner of a cude (an open tetrahedron)
Definition: MoabUserObject.C:1665
moab::ErrorCode setTags(moab::EntityHandle ent, std::string name, std::string category, unsigned int id, int dim)
Generic method to set the tags that DAGMC requires.
Definition: MoabUserObject.C:652
Point elemCentroid(Elem &elem)
Return the centroid position of an element.
Definition: MoabUserObject.C:1074
std::vector< std::set< SubdomainID > > mat_blocks
all element blocks assigned to mats
Definition: MoabUserObject.h:358
moab::EntityHandle meshset
An entitiy handle to represent the set of all tets.
Definition: MoabUserObject.h:363
moab::ErrorCode createNodesFromBox(const BoundingBox &box, double factor, std::vector< moab::EntityHandle > &vert_handles)
Create MOAB nodes from a bounding box.
Definition: MoabUserObject.C:1604
FEProblemBase * _problem_ptr
Pointer to the feProblem we care about.
Definition: MoabUserObject.h:273
std::map< dof_id_type, std::vector< moab::EntityHandle > > _id_to_elem_handles
Map from libmesh id to MOAB element entity handles.
Definition: MoabUserObject.h:288
std::vector< std::string > openmc_mat_names
OpenMC material names.
Definition: MoabUserObject.h:356
int getMatBin(int iVarBin, int iDenBin)
Definition: MoabUserObject.h:238
Encode MOAB information about volumes needed when creating surfaces.
Definition: MoabUserObject.h:104
moab::ErrorCode updateSurfData(moab::EntityHandle surface_set, VolData data)
Add parent-child metadata relating a surface to its volume.
Definition: MoabUserObject.C:633
unsigned int nPow
Number of powers of 10 to bin in for binning on a log scale.
Definition: MoabUserObject.h:314
bool logscale
Whether or not to bin in a log scale.
Definition: MoabUserObject.h:300
virtual void execute()
Override MOOSE virtual method to do nothing.
Definition: MoabUserObject.h:51
int getMatBin(int iVarBin, int iDenBin, int nVarBinsIn, int nDenBinsIn)
Map density and temp bin indices onto a linearised index.
Definition: MoabUserObject.C:1410
std::unique_ptr< moab::Skinner > skinner
Pointer to a moab skinner for finding temperature surfaces.
Definition: MoabUserObject.h:276
double densityscale
Convert MOOSE density units to openmc density units.
Definition: MoabUserObject.h:285
void getMaterialProperties(std::vector< std::string > &mat_names_out, std::vector< double > &initial_densities, std::vector< std::string > &tails, std::vector< MOABMaterialProperties > &properties)
Retrieve a list of original material names and properties.
Definition: MoabUserObject.C:800
bool sortElemsByResults()
Sort elems in to bins of a given temperature.
Definition: MoabUserObject.C:987
std::map< moab::EntityHandle, std::vector< VolData > > surfsToVols
Save some topological data: map from surface handle to vol handle and sense.
Definition: MoabUserObject.h:366
moab::ErrorCode createSurf(unsigned int id, moab::EntityHandle &surface_set, moab::Range &faces, std::vector< VolData > &voldata)
Helper method to create MOAB surface entity set.
Definition: MoabUserObject.C:606
bool write()
Write to file.
Definition: MoabUserObject.C:1168
MeshBase & mesh()
Get a modifyable reference to the underlying libmesh mesh.
Definition: MoabUserObject.C:174
PerfID _update_timer
Performance timer for update.
Definition: MoabUserObject.h:419
bool resetMOAB()
Clear MOAB entity sets.
moab::Tag faceting_tol_tag
Tag for faceting tolerance.
Definition: MoabUserObject.h:375
std::string output_base_full
Base name of full database output file.
Definition: MoabUserObject.h:406
void calcDenMidpoints()
Calculate the density evaluated at the bin midpoints.
Definition: MoabUserObject.C:1431
int getSortBin(int iVarBin, int iDenBin, int iMat, int nVarBinsIn, int nDenBinsIn, int nMatsIn)
Map material, density and temp bin indices onto a linearised index.
Definition: MoabUserObject.C:1383
unsigned int n_its
Store the number of times writeSurfaces is called.
Definition: MoabUserObject.h:414
unsigned int n_period
Period of writes (skip every n_period -1)
Definition: MoabUserObject.h:410
int getSortBin(int iVarBin, int iDenBin, int iMat)
Definition: MoabUserObject.h:230
void calcMidpointsLog()
Calculate the variable evaluated at the bin midpoints for log binning.
Definition: MoabUserObject.C:1364
void findMaterials()
Look for materials in the FE problem.
Definition: MoabUserObject.C:281
moab::Tag geometry_dimension_tag
Tag for dimension for geometry.
Definition: MoabUserObject.h:371
Sense
Encode the whether the surface normal faces into or out of the volume.
Definition: MoabUserObject.h:101
int getRelDensityBin(double value)
Return the bin index of a given relative density.
Definition: MoabUserObject.C:1377
moab::Tag name_tag
Tag for name of entity set.
Definition: MoabUserObject.h:381
std::vector< double > initialDensities
vector for initial densities if binning by density
Definition: MoabUserObject.h:360
moab::ErrorCode createSurfaceFromBox(const BoundingBox &box, VolData &voldata, unsigned int &surf_id, bool normalout, double factor=1.0)
Create a MOAB surface from a bounding box.
Definition: MoabUserObject.C:1575
PerfID _init_timer
Performance timer for initialisation.
Definition: MoabUserObject.h:417
EquationSystems & systems()
Get a modifyable reference to the underlying libmesh equation systems.
Definition: MoabUserObject.C:183
moab::ErrorCode createTags()
Helper method to create MOAB tags.
Definition: MoabUserObject.C:543
unsigned int nDenBins
Number of relative density bins.
Definition: MoabUserObject.h:335
std::vector< double > den_midpoints
Store the relative density corresponding to the bin mipoint.
Definition: MoabUserObject.h:320
const unsigned int nNodesPerTet
Const to encode that MOAB tets have 4 nodes.
Definition: MoabUserObject.h:384
bool binElems
Whether or not to perform binning.
Definition: MoabUserObject.h:298
bool hasProblem()
Check if problem has been set.
Definition: MoabUserObject.h:67
moab::EntityHandle offset
Save the first tet entity handle.
Definition: MoabUserObject.h:291
moab::Tag geometry_resabs_tag
Tag needed by DAGMC.
Definition: MoabUserObject.h:377
int powMin
Minimum power of 10.
Definition: MoabUserObject.h:308
FEProblemBase & problem()
Get a reference to the FE problem.
Definition: MoabUserObject.C:165
int getResultsBinLin(double value)
Find results bin if we have linear binning.
Definition: MoabUserObject.C:1322
void resetContainers()
Clear the containers of elements grouped into bins of constant temp.
Definition: MoabUserObject.C:1278
void initMOAB()
Initialise MOAB.
Definition: MoabUserObject.C:195
void initBinningData()
Intialise objects needed to perform binning of elements.
Definition: MoabUserObject.C:872
void groupLocalElems(std::set< dof_id_type > elems, std::vector< moab::Range > &localElems)
Definition: MoabUserObject.C:1207
int powMax
Maximum power of 10.
Definition: MoabUserObject.h:310
moab::ErrorCode createTri(const std::vector< moab::EntityHandle > &vertices, unsigned int v1, unsigned int v2, unsigned int v3, moab::Range &surface_tris)
Create MOAB tri surface element.
Definition: MoabUserObject.C:1694
double rel_den_max
Max relative density diff.
Definition: MoabUserObject.h:331
int getResultsBinLog(double value)
Find results bin if we have logarithmic.
Definition: MoabUserObject.C:1328
std::vector< Point > boxCoords(const BoundingBox &box, double factor)
Get the coords of the box back as an array (possibly scaled)
Definition: MoabUserObject.C:1632
moab::ErrorCode buildGraveyard(unsigned int &vol_id, unsigned int &surf_id)
Build the graveyard (needed by OpenMC)
Definition: MoabUserObject.C:1542
bool findSurface(const moab::Range ®ion, moab::EntityHandle group, unsigned int &vol_id, unsigned int &surf_id, moab::EntityHandle &volume_set)
Find the surfaces for the provided range and add to group.
Definition: MoabUserObject.C:1448
double lengthscale
Convert MOOSE units to dagmc length units.
Definition: MoabUserObject.h:282
double scalefactor_outer
Scalefactors applied to bounding box for outer surface of graveyard.
Definition: MoabUserObject.h:395
std::vector< std::string > mat_names
material names
Definition: MoabUserObject.h:354
void reset()
Clear mesh data.
Definition: MoabUserObject.C:1301
NumericVector< Number > & getSerialisedSolution(libMesh::System *sysPtr)
Get a serialised version of solution for a given system.
Definition: MoabUserObject.C:885
moab::ErrorCode createVol(unsigned int id, moab::EntityHandle &volume_set, moab::EntityHandle group_set)
Helper method to create MOAB volume entity set.
Definition: MoabUserObject.C:590
void clearElemMaps()
Clear the maps between entity handles and dof ids.
Definition: MoabUserObject.C:698
bool binByDensity
Switch to determine if we should bin by material density.
Definition: MoabUserObject.h:327
dof_id_type elem_to_soln_index(const Elem &elem, unsigned int iSysNow, unsigned int iVarNow)
Helper method to convert between elem / solution indices.
Definition: MoabUserObject.C:857
double bin_width
Fixed bin width for binning on a linear scale.
Definition: MoabUserObject.h:306
unsigned int n_output
Number of times to write to file.
Definition: MoabUserObject.h:408
std::shared_ptr< moab::Interface > moabPtr
Publically available pointer to MOAB interface.
Definition: MoabUserObject.h:94
unsigned int nVarBins
Number of variable bins to use.
Definition: MoabUserObject.h:312
double rel_den_min
Minimum relative density diff.
Definition: MoabUserObject.h:329
unsigned int nMatBins
Number of distinct subdomains (e.g. vols, mats)
Definition: MoabUserObject.h:337
bool setSolution(std::string var_now, std::vector< double > &results, double scaleFactor=1., bool isErr=false, bool normToVol=true)
Pass the OpenMC results into the libMesh systems solution.
Definition: MoabUserObject.C:251
virtual void finalize()
Override MOOSE virtual method to do nothing.
Definition: MoabUserObject.h:55
moab::ErrorCode createSurfaces(moab::Range &reversed, VolData &voldata, unsigned int &surf_id)
Helper method to create MOAB surfaces with no overlaps.
Definition: MoabUserObject.C:1481
std::vector< double > midpoints
Store the temperature corresponding to the bin mipoint.
Definition: MoabUserObject.h:318
moab::ErrorCode createGroup(unsigned int id, std::string name, moab::EntityHandle &group_set)
Helper method to create MOAB group entity set.
Definition: MoabUserObject.C:578
std::map< std::string, std::shared_ptr< MeshFunction > > meshFunctionPtrs
A map to store mesh functions against their variable name.
Definition: MoabUserObject.h:343
double var_max
Maximum value of our variable for binning on a linear scale.
Definition: MoabUserObject.h:304
UserObject class which wraps a moab::Interface pointer.
Definition: MoabUserObject.h:44
std::string output_base
Base name of skins output file.
Definition: MoabUserObject.h:404
bool output_full
Flag to control whether to output the full MOAB mesh database.
Definition: MoabUserObject.h:402
bool update()
Update MOAB with any results from MOOSE.
Definition: MoabUserObject.C:229
double evalMeshFunction(std::shared_ptr< MeshFunction > meshFunctionPtr, const Point &p)
Evaluate a mesh function at a point.
Definition: MoabUserObject.C:946
PerfID _setsolution_timer
Performance timer for setSolution.
Definition: MoabUserObject.h:421
std::shared_ptr< MeshFunction > getMeshFunction(std::string var_name_in)
Fetch the mesh function associated with a variable.
Definition: MoabUserObject.C:970
unsigned int nMinor
Number of minor divisions for binning on a log scale.
Definition: MoabUserObject.h:316
moab::Tag id_tag
Tag for entitiy set ID.
Definition: MoabUserObject.h:373
virtual void threadJoin(const UserObject &)
Override MOOSE virtual method to do nothing.
Definition: MoabUserObject.h:57
std::string den_var_name
Data members relating to binning in density.
Definition: MoabUserObject.h:325
int getResultsBin(double value)
Given a value of our variable, find what bin this corresponds to.
Definition: MoabUserObject.C:1315
void calcMidpointsLin()
Calculate the variable evaluated at the bin midpoints for linear binning.
Definition: MoabUserObject.C:1358
bool findSurfaces()
Group the binned elems into local temperature regions and find their surfaces.
Definition: MoabUserObject.C:1093
std::unique_ptr< moab::GeomTopoTool > gtt
Pointer for gtt for setting surface sense.
Definition: MoabUserObject.h:279
void createElems(std::map< dof_id_type, moab::EntityHandle > &node_id_to_handle)
Helper method to create MOAB elements.
Definition: MoabUserObject.C:409
void setMeshFunction(std::string var_name_in)
Create and save a mesh function for the provided variable.
Definition: MoabUserObject.C:912
virtual void initialize()
Override MOOSE virtual method to do nothing.
Definition: MoabUserObject.h:53
bool output_skins
Flag to control whether to save surface skins to file.
Definition: MoabUserObject.h:400
moab::ErrorCode createNodes(std::map< dof_id_type, moab::EntityHandle > &node_id_to_handle)
Helper method to create MOAB nodes.
Definition: MoabUserObject.C:364
std::string var_name
Name of the MOOSE variable.
Definition: MoabUserObject.h:296
void communicateDofSet(std::set< dof_id_type > &dofset)
MPI communication of DOFs of binned elements.
Definition: MoabUserObject.C:1087
void calcMidpoints()
Calculate the variable evaluated at the bin midpoints.
Definition: MoabUserObject.C:1350
void addElem(dof_id_type id, moab::EntityHandle ent)
Add an element to maps.
Definition: MoabUserObject.C:705
bool getTetSets(ElemType type, std::vector< std::vector< unsigned int > > &perms)
Return all sets of node indices for sub-tetrahedra if we have a second order mesh.
Definition: MoabUserObject.C:506
double geom_tol
Geometry tolerence needed by DAGMC.
Definition: MoabUserObject.h:390
std::vector< std::set< dof_id_type > > sortedElems
Container for elems sorted by variable bin and materials.
Definition: MoabUserObject.h:340
std::map< unsigned int, std::unique_ptr< NumericVector< Number > > > serial_solutions
A place to store the entire solution.
Definition: MoabUserObject.h:349
moab::Tag category_tag
Tag for type of entity set.
Definition: MoabUserObject.h:379
double faceting_tol
Faceting tolerence needed by DAGMC.
Definition: MoabUserObject.h:388
System & system(std::string var_now)
Get a modifyable reference to the underlying libmesh system.
Definition: MoabUserObject.C:189
double rel_den_bw
Relative density diff bin width.
Definition: MoabUserObject.h:333
void setProblem(FEProblemBase *problem)
Pass in the FE Problem.
Definition: MoabUserObject.h:60
double scalefactor_inner
Scalefactors applied to bounding box for inner surface of graveyard.
Definition: MoabUserObject.h:393
unsigned int n_write
Count number of times file has been written to.
Definition: MoabUserObject.h:412