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.
reporter point marker to mark mesh for refinement around points given…
… by a reporter. closes idaholab#18886 included Logan and Daniels suggestions
- Loading branch information
1 parent
b640e74
commit ac15df5
Showing
9 changed files
with
306 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
framework/doc/content/source/markers/ReporterPointMarker.md
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,19 @@ | ||
# ReporterPointMarker | ||
|
||
!syntax description /Adaptivity/Markers/ReporterPointMarker | ||
|
||
## Description | ||
|
||
The `ReporterPointMarker` is a stand-alone marker that marks all | ||
elements containing points defined by coordinates given in a `Reporter`. | ||
|
||
|
||
## Example Input Syntax | ||
|
||
!listing test/tests/markers/reporter_point_marker/point_marker_test.i block=Adaptivity | ||
|
||
!syntax parameters /Adaptivity/Markers/ReporterPointMarker | ||
|
||
!syntax inputs /Adaptivity/Markers/ReporterPointMarker | ||
|
||
!syntax children /Adaptivity/Markers/ReporterPointMarker |
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,42 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "Marker.h" | ||
#include "ReporterInterface.h" | ||
|
||
/** | ||
* Marks all elements near a given boundary for refinement/coarsening | ||
*/ | ||
class ReporterPointMarker : public Marker, public ReporterInterface | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
ReporterPointMarker(const InputParameters & parameters); | ||
virtual void markerSetup() override; | ||
|
||
protected: | ||
virtual MarkerValue computeElementMarker() override; | ||
|
||
/// marker value to give elements containing a point | ||
const MarkerValue _inside; | ||
/// marker for elements not containing points | ||
const MarkerValue _empty; | ||
/// x coordinate | ||
const std::vector<Real> & _x_coord; | ||
/// y coordinate | ||
const std::vector<Real> & _y_coord; | ||
///z coordinate | ||
const std::vector<Real> & _z_coord; | ||
/// Pointer to PointLocatorBase object | ||
std::unique_ptr<PointLocatorBase> _pl; | ||
/// list of sort uniqued elements containing points | ||
std::set<dof_id_type> _point_elems; | ||
}; |
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,71 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#include "ReporterPointMarker.h" | ||
|
||
registerMooseObject("MooseApp", ReporterPointMarker); | ||
|
||
InputParameters | ||
ReporterPointMarker::validParams() | ||
{ | ||
InputParameters params = Marker::validParams(); | ||
params.addClassDescription("Marks the region inside or empty if it contains a reporter defined " | ||
"point for refinement or coarsening."); | ||
params.addRequiredParam<ReporterName>("x_coord_name", "reporter x-coordinate name"); | ||
params.addRequiredParam<ReporterName>("y_coord_name", "reporter y-coordinate name"); | ||
params.addRequiredParam<ReporterName>("z_coord_name", "reporter z-coordinate name"); | ||
MooseEnum marker_states = Marker::markerStates(); | ||
params.addRequiredParam<MooseEnum>( | ||
"inside", marker_states, "How to mark elements containing a point"); | ||
params.addRequiredParam<MooseEnum>( | ||
"empty", marker_states, "How to mark elements not containing a point"); | ||
return params; | ||
} | ||
|
||
ReporterPointMarker::ReporterPointMarker(const InputParameters & parameters) | ||
: Marker(parameters), | ||
ReporterInterface(this), | ||
_inside(parameters.get<MooseEnum>("inside").getEnum<MarkerValue>()), | ||
_empty(parameters.get<MooseEnum>("empty").getEnum<MarkerValue>()), | ||
_x_coord(getReporterValue<std::vector<Real>>("x_coord_name", REPORTER_MODE_REPLICATED)), | ||
_y_coord(getReporterValue<std::vector<Real>>("y_coord_name", REPORTER_MODE_REPLICATED)), | ||
_z_coord(getReporterValue<std::vector<Real>>("z_coord_name", REPORTER_MODE_REPLICATED)) | ||
{ | ||
} | ||
|
||
void | ||
ReporterPointMarker::markerSetup() | ||
{ | ||
_pl = _fe_problem.mesh().getPointLocator(); | ||
_pl->enable_out_of_mesh_mode(); | ||
const auto npoints = _x_coord.size(); | ||
if (npoints != _y_coord.size() || npoints != _z_coord.size()) | ||
mooseError("The coordinate vectors are a different size. \n", | ||
" x_coord size = ", | ||
npoints, | ||
"; y_coord size = ", | ||
_y_coord.size(), | ||
"; z_coord size = ", | ||
_z_coord.size()); | ||
|
||
_point_elems.clear(); | ||
for (std::size_t i = 0; i < npoints; ++i) | ||
{ | ||
Point pt(_x_coord[i], _y_coord[i], _z_coord[i]); | ||
const auto elem = (*_pl)(pt); | ||
if (elem) | ||
_point_elems.insert(elem->id()); | ||
} | ||
} | ||
|
||
Marker::MarkerValue | ||
ReporterPointMarker::computeElementMarker() | ||
{ | ||
return (_point_elems.count(_current_elem->id()) ? _inside : _empty); | ||
} |
Binary file not shown.
1 change: 1 addition & 0 deletions
1
test/tests/markers/reporter_point_marker/gold/point_marker_test_out.e
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 @@ | ||
../../box_marker/gold/box_marker_test_out.e |
8 changes: 8 additions & 0 deletions
8
test/tests/markers/reporter_point_marker/gold/reporter_marker_adapt_test_out.csv
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,8 @@ | ||
time,n_elements | ||
0,0 | ||
0.1,25 | ||
0.2,31 | ||
0.3,34 | ||
0.4,43 | ||
0.5,46 | ||
0.6,46 |
62 changes: 62 additions & 0 deletions
62
test/tests/markers/reporter_point_marker/point_marker_test.i
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,62 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 2 | ||
nx = 10 | ||
ny = 10 | ||
nz = 0 | ||
zmax = 0 | ||
elem_type = QUAD4 | ||
[] | ||
|
||
[Problem] | ||
solve = false | ||
[] | ||
|
||
[Executioner] | ||
type = Steady | ||
[] | ||
|
||
[Reporters] | ||
[coords] | ||
type=ConstantReporter | ||
real_vector_names = 'x y z' | ||
real_vector_values = '.31 .41 .51 .31 .41 .51 .31 .41 .51 .8; | ||
.31 .31 .31 .41 .41 .41 .51 .51 .51 .8; | ||
0 0 0 0 0 0 0 0 0 1;' | ||
outputs=none | ||
[] | ||
[bad_coords] | ||
type=ConstantReporter | ||
real_vector_names = 'x y z' | ||
real_vector_values = '.31 .41 .51; | ||
.31 .31 .31 .41 .41 .41 .51 .51; | ||
0 0 0 0 0 0 0 0 0 1;' | ||
outputs=none | ||
[] | ||
[] | ||
|
||
[Adaptivity] | ||
[Markers] | ||
active = 'box' | ||
[box] | ||
type = ReporterPointMarker | ||
x_coord_name = coords/x | ||
y_coord_name = coords/y | ||
z_coord_name = coords/z | ||
inside = refine | ||
empty = do_nothing | ||
[] | ||
[bad_coord] | ||
type = ReporterPointMarker | ||
x_coord_name = bad_coords/x | ||
y_coord_name = bad_coords/y | ||
z_coord_name = bad_coords/z | ||
inside = refine | ||
empty = do_nothing | ||
[] | ||
[] | ||
[] | ||
|
||
[Outputs] | ||
exodus=true | ||
[] |
76 changes: 76 additions & 0 deletions
76
test/tests/markers/reporter_point_marker/reporter_marker_adapt_test.i
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 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 2 | ||
nx = 5 | ||
ny = 5 | ||
[] | ||
|
||
[Problem] | ||
solve = false | ||
[] | ||
|
||
[Executioner] | ||
type = Transient | ||
num_steps = 6 | ||
dt = 0.1 | ||
[] | ||
|
||
[Reporters] | ||
[coords] | ||
type=ConstantReporter | ||
real_vector_names = 'y z' | ||
real_vector_values = '.51 .91; 0 0;' | ||
outputs=none | ||
[] | ||
[] | ||
[Functions] | ||
[xfcn] | ||
type = ParsedFunction | ||
value = t+0.01 #offset so marker is not on element edge | ||
[] | ||
[] | ||
|
||
[Postprocessors] | ||
[xfcn_pp] | ||
type = FunctionValuePostprocessor | ||
function = xfcn | ||
execute_on = timestep_end | ||
outputs = none | ||
[] | ||
[x_pp] | ||
type = Receiver | ||
default = .91 | ||
outputs = none | ||
[] | ||
[n_elements] | ||
type = NumElems | ||
execute_on = 'timestep_end' | ||
[] | ||
[] | ||
|
||
[VectorPostprocessors] | ||
[xfcn_vpp] | ||
type = VectorOfPostprocessors | ||
postprocessors = 'xfcn_pp x_pp' | ||
outputs = none | ||
[] | ||
[] | ||
|
||
[Adaptivity] | ||
marker = x_moving | ||
max_h_level = 2 | ||
[Markers] | ||
[x_moving] | ||
type = ReporterPointMarker | ||
x_coord_name = xfcn_vpp/xfcn_vpp | ||
y_coord_name = coords/y | ||
z_coord_name = coords/z | ||
inside = REFINE | ||
empty = COARSEN | ||
[] | ||
[] | ||
[] | ||
|
||
[Outputs] | ||
csv = true | ||
[] |
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,27 @@ | ||
[Tests] | ||
group = 'Reporter Point Marker' | ||
design = "/Markers/index.md /ReporterPointMarker.md" | ||
issues = '#18886' | ||
[mark_only] | ||
type = 'Exodiff' | ||
input = 'point_marker_test.i' | ||
exodiff = 'point_marker_test_out.e' | ||
scale_refine = 2 | ||
requirement = "The adaptivity system shall create an auxiliary field variable that marks " | ||
"elements containing the points from the reporter for refinement." | ||
[] | ||
[wrong_size_error] | ||
type = 'RunException' | ||
input = 'point_marker_test.i' | ||
cli_args = 'Adaptivity/Markers/active=bad_coord' | ||
expect_err = "x_coord size = 3; y_coord size = 8; z_coord size = 10" | ||
requirement = "The marker shall create an error if the coordinate vectors are not all the same size" | ||
[] | ||
[adaptivity] | ||
type = 'CSVDiff' | ||
input = 'reporter_marker_adapt_test.i' | ||
csvdiff = 'reporter_marker_adapt_test_out.csv' | ||
requirement = "The marker shall be used for adaptivity for a moving point, " | ||
"being able to coarsen elements the point moves out of but not coarsen elements if it contains point." | ||
[] | ||
[] |