Skip to content

Commit

Permalink
Allow EventMarker to refine around sinks, added test for initial adap…
Browse files Browse the repository at this point in the history
…tivity, ref idaholab#42
  • Loading branch information
jessecarterMOOSE committed Sep 27, 2016
1 parent 61c889d commit 1673ed2
Show file tree
Hide file tree
Showing 8 changed files with 663 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/markers/EventMarker.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "Marker.h"
#include "EventInserter.h"
#include "GaussianUserObject.h"
#include "SinkMapUserObject.h"
#include "Coupleable.h"

// libmesh includes
Expand Down Expand Up @@ -71,6 +72,14 @@ class EventMarker : public Marker, public Coupleable

const bool _refine_by_ratio;

const bool _refine_sinks;

const Real _sink_radius;

const SinkMapUserObject * _sink_map_user_object_ptr;

const GaussianUserObject * _sink_gaussian_user_object_ptr;

bool _event_incoming;

Point _event_location;
Expand All @@ -80,6 +89,8 @@ class EventMarker : public Marker, public Coupleable
bool _coarsening_needed;

EventList _old_event_list;

Real _sink_refine_distance;
};

#endif /* EVENTMARKER_H */
31 changes: 31 additions & 0 deletions src/markers/EventMarker.C
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ InputParameters validParams<EventMarker>()
params.addCoupledVar("periodic_variable", "Use perodic boundary conditions of this variable to determine the distance to the function peak location");
params.addParam<bool>("coarsen_events", false, "Coarsen events at some later time. If true, set 'track_old_events=true' in EventInserter.");
params.addParam<Real>("event_sigma_mesh_ratio", 2.0, "Refine elements until ratio of event sigma to element size is equal to or greater than this value.");
params.addParam<bool>("refine_sinks", false, "Refine the area around sinks from SinkMapUserObject.");
params.addParam<Real>("sink_radius", 3.0, "How many sigmas to mark away from sink center.");
params.addParam<UserObjectName>("sink_map_user_object", "The name of the SinkMapUserObject.");
params.addParam<UserObjectName>("sink_gaussian_user_object", "The name of the GaussianUserObject to use for sink size.");

return params;
}
Expand All @@ -44,6 +48,10 @@ EventMarker::EventMarker(const InputParameters & parameters) :
_refine_distance(_marker_radius * _gaussian_uo.getSigma()),
_minimum_element_size(_gaussian_uo.getSigma() / _sigma_mesh_ratio),
_refine_by_ratio(parameters.isParamSetByUser("event_sigma_mesh_ratio")),
_refine_sinks(getParam<bool>("refine_sinks")),
_sink_radius(getParam<Real>("sink_radius")),
_sink_map_user_object_ptr(NULL),
_sink_gaussian_user_object_ptr(NULL),
_event_incoming(false),
_event_location(0),
_input_cycles_per_step(_adaptivity.getCyclesPerStep()),
Expand All @@ -53,6 +61,21 @@ EventMarker::EventMarker(const InputParameters & parameters) :
// Check input logic for coarsening events
if ((_coarsen_events) && (!_inserter.areOldEventsBeingTracked())) // need to tell EventInserter to track old events
mooseError("When coarsening old events ('coarsen_events = true'), EventInserter object needs to track old events. Please set 'track_old_events = true' in EventInserter block.");

// Check input logic for refining around sinks
if (_refine_sinks)
{
if ((parameters.isParamSetByUser("sink_map_user_object")) && (parameters.isParamSetByUser("sink_gaussian_user_object")))
{
_sink_map_user_object_ptr = &getUserObject<SinkMapUserObject>("sink_map_user_object");
_sink_gaussian_user_object_ptr = &getUserObject<GaussianUserObject>("sink_gaussian_user_object");
_sink_refine_distance = _sink_radius * _sink_gaussian_user_object_ptr->getSigma();
}
else if (!parameters.isParamSetByUser("sink_map_user_object"))
mooseError("To refine around sinks, need to set 'sink_map_user_object' to the name of the SinkMapUserObject.");
else
mooseError("To refine around sinks, need to set 'sink_gaussian_user_object' to the name of the GaussianUserObject for sinks.");
}
}

void
Expand Down Expand Up @@ -143,6 +166,14 @@ EventMarker::computeElementMarker()
return COARSEN;
}

if (_refine_sinks)
{
// refine if we are near a sink
Real r = _sink_map_user_object_ptr->getDistanceToNearestSink(centroid);
if (r < _sink_refine_distance)
return REFINE;
}

return DO_NOTHING; // satisfy compiler
}

Expand Down
Binary file added tests/markers/gold/sink_marker_inside_out.e
Binary file not shown.
Binary file added tests/markers/gold/sink_marker_out.e
Binary file not shown.
203 changes: 203 additions & 0 deletions tests/markers/sink_marker.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
###########################################################
# This is a simple test with a time-dependent problem
# demonstrating the use of a "Transient" Executioner.
#
# @Requirement F1.10
###########################################################


[Mesh]
type = GeneratedMesh
dim = 2
xmin = -1
xmax = 1
ymin = -1
ymax = 1
nx = 20
ny = 20
[]

[Variables]
active = 'u'

[./u]
order = FIRST
family = LAGRANGE

[./InitialCondition]
type = ConstantIC
value = 0
[../]
[../]
[]

[AuxVariables]
[./sink_strength]
order = CONSTANT
family = MONOMIAL
[../]
[]

[Functions]
[./forcing_fn]
type = ParsedFunction
# dudt = 3*t^2*(x^2 + y^2)
value = 3*t*t*((x*x)+(y*y))-(4*t*t*t)
[../]

[./exact_fn]
type = ParsedFunction
value = t*t*t*((x*x)+(y*y))
[../]
[]

[Kernels]
active = 'diff ie ffn'

[./ie]
type = TimeDerivative
variable = u
[../]

[./diff]
type = Diffusion
variable = u
[../]

[./ffn]
type = UserForcingFunction
variable = u
function = forcing_fn
[../]
[]

[AuxKernels]
[./sink_aux]
type = SinkMapAux
variable = sink_strength
sink_map_user_object = sink_map_user_object
execute_on = 'timestep_end'
[../]
[]

[BCs]
active = 'all'

[./all]
type = FunctionDirichletBC
variable = u
boundary = '0 1 2 3'
function = exact_fn
[../]

[./left]
type = DirichletBC
variable = u
boundary = 3
value = 0
[../]

[./right]
type = DirichletBC
variable = u
boundary = 1
value = 1
[../]
[]

[UserObjects]
[./random_point_uo]
type = RandomPointUserObject
seed = 1
[../]
[./inserter]
type = EventInserter
distribution = 'uniform'
mean = 0.4
insert_test = true
test_time = 0.15
test_location = '0.1 0.2 0.0'
random_point_user_object = random_point_uo
verbose = true
[../]
[./gaussian_uo]
type = GaussianUserObject
sigma = 0.1
peak_location = '0.1 0.2 0.0'
periodic_variable = u
[../]
[./sink_gaussian_uo]
type = GaussianUserObject
sigma = 0.05
[../]
[./sink_map_user_object]
type = SinkMapUserObject
spacing = 1.0
strength = 3.0
gaussian_user_object = sink_gaussian_uo
periodic_variable = u
[../]
[]

[Adaptivity]
initial_marker = event_marker
initial_steps = 10
max_h_level = 2
recompute_markers_during_cycles = true
[./Markers]
[./event_marker]
type = EventMarker
inserter = inserter
gaussian_user_object = gaussian_uo
marker_radius = 3.0
verbose = true
refine_sinks = true
sink_radius = 6.0
sink_map_user_object = sink_map_user_object
sink_gaussian_user_object = sink_gaussian_uo
[../]
[../]
[]

[Executioner]
type = Transient
scheme = 'implicit-euler'

solve_type = NEWTON
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'

#start_time = 0.0
#end_time = 0.39
num_steps = 1

verbose = true
[./TimeStepper]
type = EventTimeStepper
dt = 0.1
event_inserter = inserter
verbose = true
[../]
[]

[Postprocessors]
[./dt]
type = TimestepSize
[../]
[./sink_strength_integral]
type = ElementIntegralVariablePostprocessor
variable = sink_strength
[../]
[./sink_strength_average]
type = ElementAverageValue
variable = sink_strength
[../]
[]

[Outputs]
exodus = true
[./console]
type = Console
print_mesh_changed_info = true
[../]
[]
Loading

0 comments on commit 1673ed2

Please sign in to comment.