forked from idaholab/stork
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add example for sigma element size ratio adaptivity, closes idaholab#39
- Loading branch information
1 parent
11c4309
commit 9e99ba5
Showing
3 changed files
with
233 additions
and
0 deletions.
There are no files selected for viewing
188 changes: 188 additions & 0 deletions
188
examples/2d_sigma_ratio_adaptivity/2d_sigma_ratio_adaptivity.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,188 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 2 | ||
xmin = -1 | ||
xmax = 1 | ||
ymin = -1 | ||
ymax = 1.2 | ||
nx = 20 | ||
ny = 20 | ||
[] | ||
|
||
[Variables] | ||
[./u] | ||
order = FIRST | ||
family = LAGRANGE | ||
|
||
[./InitialCondition] | ||
type = ConstantIC | ||
value = 0 | ||
[../] | ||
[../] | ||
[] | ||
|
||
[Kernels] | ||
[./ie] | ||
type = TimeDerivative | ||
variable = u | ||
[../] | ||
|
||
[./diff] | ||
type = MaterialDiffusion | ||
variable = u | ||
diffusivity_name = diffusivity | ||
[../] | ||
|
||
[./sink] | ||
type = MaterialSinkKernel | ||
variable = u | ||
[../] | ||
|
||
[./event_inserter_source] | ||
type = EventInserterSource | ||
variable = u | ||
inserter = inserter | ||
gaussian_user_object = gaussian_uo | ||
[../] | ||
[] | ||
|
||
[BCs] | ||
[./Periodic] | ||
[./all] | ||
variable = u | ||
auto_direction = 'x y' | ||
[../] | ||
[../] | ||
[] | ||
|
||
[Materials] | ||
[./simple] | ||
type = GenericConstantMaterial | ||
block = 0 | ||
prop_names = 'diffusivity sink_strength' | ||
prop_values = '2.0 0.05' | ||
[../] | ||
[] | ||
|
||
[UserObjects] | ||
[./inserter_circle_average] | ||
type = CircleAverageMaterialProperty | ||
mat_prop = diffusivity | ||
periodic_variable = u | ||
inserter = inserter | ||
radius = 0.2 | ||
[../] | ||
[./circle_average] | ||
type = CircleAverageMaterialProperty | ||
mat_prop = diffusivity | ||
periodic_variable = u | ||
[../] | ||
[./random_point_uo] | ||
type = RandomPointUserObject | ||
seed = 1 | ||
[../] | ||
[./gaussian_uo] | ||
type = GaussianUserObject | ||
sigma = 0.05 | ||
use_random_points = true | ||
random_point_user_object = random_point_uo | ||
periodic_variable = u | ||
scale = 3 | ||
[../] | ||
[./circle_max_original_element_size_uo] | ||
type = CircleMaxOriginalElementSize | ||
periodic_variable = u | ||
[../] | ||
[./inserter] | ||
type = EventInserter | ||
insert_initial = true | ||
random_timing = false | ||
mean = 1.2 | ||
random_point_user_object = random_point_uo | ||
seed = 3 | ||
verbose = true | ||
track_old_events = true | ||
removal_method = sigma_element_size_ratio | ||
removal_sigma_element_size_ratio = 2.0 | ||
radius = 3.0 | ||
gaussian_user_object = gaussian_uo | ||
circle_average_material_property_user_object = circle_average | ||
inserter_circle_average_material_property_user_object = inserter_circle_average | ||
circle_max_original_element_size_user_object = circle_max_original_element_size_uo | ||
[../] | ||
[] | ||
|
||
[Adaptivity] | ||
initial_marker = event_marker | ||
initial_steps = 10 | ||
marker = event_marker | ||
cycles_per_step = 10 | ||
max_h_level = 0 | ||
recompute_markers_during_cycles = true | ||
[./Markers] | ||
[./event_marker] | ||
type = EventMarker | ||
inserter = inserter | ||
gaussian_user_object = gaussian_uo | ||
marker_radius = 6.0 | ||
coarsen_events = true | ||
verbose = true | ||
periodic_variable = u | ||
event_sigma_mesh_ratio = 2.0 | ||
[../] | ||
[../] | ||
[] | ||
|
||
[Executioner] | ||
type = Transient | ||
scheme = 'implicit-euler' | ||
|
||
solve_type = 'NEWTON' | ||
|
||
start_time = 0.0 | ||
end_time = 50.0 | ||
|
||
verbose = true | ||
|
||
petsc_options_iname = '-pc_type -pc_hypre_type' | ||
petsc_options_value = 'hypre boomeramg' | ||
|
||
nl_abs_tol = 1.0e-12 | ||
|
||
[./TimeStepper] | ||
type = EventTimeStepper | ||
dt = 0.01 | ||
event_inserter = inserter | ||
growth_factor = 2.0 | ||
[../] | ||
[] | ||
|
||
[Preconditioning] | ||
[./smp] | ||
type = SMP | ||
full = true | ||
[../] | ||
[] | ||
|
||
[Postprocessors] | ||
[./dt] | ||
type = TimestepSize | ||
[../] | ||
[./average] | ||
type = ElementAverageValue | ||
variable = u | ||
[../] | ||
[./num_elems] | ||
type = NumElems | ||
[../] | ||
[] | ||
|
||
[Outputs] | ||
exodus = true | ||
csv = true | ||
execute_on = 'initial timestep_end' | ||
[./console] | ||
type = Console | ||
print_mesh_changed_info = 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,29 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import os | ||
|
||
# enter values from simulation here | ||
diffusivity = 2.0 | ||
sink_strength = 0.05 | ||
mean = 1.2 # mean of EventInserter distribution | ||
Lx = 2.0 # length of problem in x | ||
Ly = 2.2 # length of problem in y | ||
scale = 3.0 # scale of Gaussian source term | ||
|
||
# postprocessor output should be the only csv file in directory | ||
for file in os.listdir("."): | ||
if file.endswith(".csv"): | ||
csvfile=file | ||
|
||
data=np.loadtxt(csvfile, delimiter=',', skiprows=1) | ||
|
||
plt.plot(data[:,0], data[:,1], 'r-', label='solution') | ||
plt.xlabel('time') | ||
plt.ylabel('average concentration') | ||
|
||
analytic = scale/diffusivity/sink_strength/mean/Lx/Ly*(1.0 - np.exp(-sink_strength*diffusivity*data[:,0])) | ||
plt.plot(data[:,0], analytic, 'k-', label='analytic') | ||
|
||
plt.legend(loc="lower right") | ||
|
||
plt.show() |
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,16 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import os | ||
|
||
# postprocessor output should be the only csv file in directory | ||
for file in os.listdir("."): | ||
if file.endswith(".csv"): | ||
csvfile=file | ||
|
||
data=np.loadtxt(csvfile, delimiter=',', skiprows=1) | ||
|
||
plt.plot(data[:,0], data[:,3], 'r-o') | ||
plt.xlabel('time') | ||
plt.ylabel('number of elements') | ||
|
||
plt.show() |