Skip to content

Commit

Permalink
Generate new output file only if mesh has changed
Browse files Browse the repository at this point in the history
Previously, once adaptivity happened, a new output file would get
generated for every single output step.  With this change, new files
are created only if the mesh changes.

closes #1755

r17576
  • Loading branch information
bwspenc authored and permcody committed Feb 14, 2014
1 parent 2763d7c commit a3f760f
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 15 deletions.
4 changes: 3 additions & 1 deletion framework/include/base/Adaptivity.h
Expand Up @@ -100,8 +100,10 @@ class Adaptivity

/**
* Adapts the mesh based on the error estimator used
*
* @return a boolean that indicates whether the mesh was changed
*/
void adaptMesh();
bool adaptMesh();

/**
* Used during initial adaptivity.
Expand Down
15 changes: 11 additions & 4 deletions framework/src/base/Adaptivity.C
Expand Up @@ -111,9 +111,10 @@ Adaptivity::setErrorNorm(SystemNorm & sys_norm)
_error_estimator->error_norm = sys_norm;
}

void
bool
Adaptivity::adaptMesh()
{
bool meshChanged = false;
if (_mesh_refinement_on && (_start_time <= _t && _t < _stop_time))
{
if(_use_new_system)
Expand Down Expand Up @@ -147,17 +148,23 @@ Adaptivity::adaptMesh()
}

// Perform refinement and coarsening
_mesh_refinement->refine_and_coarsen_elements();
meshChanged = _mesh_refinement->refine_and_coarsen_elements();

if (_displaced_problem)
_displaced_mesh_refinement->refine_and_coarsen_elements();
{
bool dispMeshChanged = _displaced_mesh_refinement->refine_and_coarsen_elements();
if ((meshChanged && !dispMeshChanged) ||
(!meshChanged && dispMeshChanged))
mooseError("If either undisplaced mesh or displaced mesh changes due to adaptivity, both must change");
}

if (_print_mesh_changed)
if (meshChanged && _print_mesh_changed)
{
std::cout << "\nMesh Changed:\n";
_mesh.printInfo();
}
}
return meshChanged;
}

void
Expand Down
7 changes: 4 additions & 3 deletions framework/src/base/FEProblem.C
Expand Up @@ -3018,15 +3018,15 @@ FEProblem::adaptMesh()
unsigned int cycles_per_step = _adaptivity.getCyclesPerStep();
for (unsigned int i=0; i < cycles_per_step; ++i)
{
_adaptivity.adaptMesh();
meshChanged();
if (_adaptivity.adaptMesh())
meshChanged();
}
}
#endif //LIBMESH_ENABLE_AMR

void
FEProblem::meshChanged()
{
{
if (_material_props.hasStatefulProperties())
_mesh.cacheChangedLists(); // Currently only used with adaptivity and stateful material properties

Expand Down Expand Up @@ -3062,6 +3062,7 @@ FEProblem::meshChanged()
}

}
_out.meshChanged();
}

void
Expand Down
1 change: 0 additions & 1 deletion framework/src/executioners/Steady.C
Expand Up @@ -91,7 +91,6 @@ Steady::execute()
if(r_step != steps)
{
_problem.adaptMesh();
_problem.out().meshChanged();
}

_time_step++;
Expand Down
1 change: 0 additions & 1 deletion framework/src/executioners/Transient.C
Expand Up @@ -306,7 +306,6 @@ Transient::endStep()
if (_problem.adaptivity().isOn())
{
_problem.adaptMesh();
_problem.out().meshChanged();
}
#endif

Expand Down
1 change: 0 additions & 1 deletion framework/src/executioners/TransientAdaptive.C
Expand Up @@ -314,7 +314,6 @@ TransientAdaptive::execute()
if (_fe_problem.adaptivity().isOn())
{
_fe_problem.adaptMesh();
_fe_problem.out().meshChanged();
}
#endif
}
Expand Down
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion test/tests/adaptivity/initial_adapt/tests
Expand Up @@ -2,6 +2,6 @@
[./test]
type = 'Exodiff'
input = 'initial_adapt.i'
exodiff = 'initial_adapt_out.e-s004'
exodiff = 'initial_adapt_out.e'
[../]
[]
Binary file not shown.
2 changes: 1 addition & 1 deletion test/tests/adaptivity/initial_marker/tests
Expand Up @@ -2,6 +2,6 @@
[./test]
type = 'Exodiff'
input = 'initial_marker.i'
exodiff = 'initial_marker_out.e-s004'
exodiff = 'initial_marker_out.e-s003'
[../]
[]
Binary file not shown.
2 changes: 1 addition & 1 deletion test/tests/adaptivity/max_h_level/tests
Expand Up @@ -2,6 +2,6 @@
[./test]
type = 'Exodiff'
input = 'max_h_level.i'
exodiff = 'max_h_level_out.e-s004'
exodiff = 'max_h_level_out.e-s003'
[../]
[]
Binary file added test/tests/mesh/adapt/gold/out_time.e-s002
Binary file not shown.
Binary file removed test/tests/mesh/adapt/gold/out_time.e-s007
Binary file not shown.
2 changes: 1 addition & 1 deletion test/tests/mesh/adapt/tests
Expand Up @@ -10,7 +10,7 @@
[./test_time]
type = 'Exodiff'
input = 'adapt_time_test.i'
exodiff = 'out_time.e-s007'
exodiff = 'out_time.e-s002'
group = 'adaptive'
[../]

Expand Down

0 comments on commit a3f760f

Please sign in to comment.