adaptive remesh + discontinuity = segfault

Clearly defined bug reports and their fixes
Post Reply
NJank
Posts: 99
Joined: 05 Dec 2009, 00:05
Location: Baltimore, MD, USA

adaptive remesh + discontinuity = segfault

Post by NJank »

was trying to see if elmer could tolerate both adaptive mesh refinement and a simple discontinuity (heat gap). Trying different versions of achieving a heat gap. several pairs of grd/sif files attached. several attempted combinations of discontinuity and mesh refinement produce repeatable SEGFAULTS.


1 - adapt1.grd / adapt1.sif
base case. simple rectangle, no discontinuity. heat on top, cold on bottom. coarse mesh. all good.
adapt1.grd:

Code: Select all

***** ElmerGrid input file for structured grid generation *****
Version = 210903

Coordinate System = Cartesian 2D
Subcell Divisions in 2D = 3 3 

Subcell Sizes 1 = 1e-3 1e-3 1e-3
Subcell Sizes 2 = 1e-3 1e-3 1e-3

Material Structure in 2D
  2 1 2
  2 2 2
  3 3 3
End

Materials Interval = 1 3

Boundary Definitions
! type     out      int      double   of the boundaries
  1        -1       3       1
  2        -3       1       1
End

Surface Elements = 10
Triangles = logical true  !needed for RGB adaptive meshing
Numbering = Horizontal
Element Degree = 1
adapt1.sif:

Code: Select all

Header
  CHECK KEYWORDS Warn
  Mesh DB "." "adapt1"
End

Simulation
  Max Output Level = 5
  Coordinate System = "Cartesian 2D"
  Coordinate Mapping(3) = 1 2 3
  Simulation Type = "Steady State"
  Steady State Max Iterations = 10
  Post File = file "adapt.ep"
End

Body 1
  Target Bodies(2) = 1 2
  Equation = 1
  Material = 1
  Initial Condition  = 1
End

Body 2
  Target Bodies(1) = 3
  Equation = 1
  Material = 1
  Initial Condition = 1
End

Equation 1
  Heat Equation = True
  Active Solvers(1) = 1
End

Solver 1
  Exec Solver = "Always"
  Equation = "Heat Equation"
  Procedure = "HeatSolve" "HeatSolver"
  Variable = "Temperature"
  Variable Dofs = 1
  Optimize Bandwidth = True
  Linear System Solver = "Direct"
  Linear System Direct Method = "umfpack"
  Steady State Convergence Tolerance = 1.0e-5
  Stabilize = True
  Nonlinear System Convergence Tolerance = 1.0e-4
  Nonlinear System Max Iterations = 3
  Nonlinear System Newton After Iterations = 2
  Nonlinear System Newton After Tolerance = 1.0e-3
  Nonlinear System Relaxation Factor = 1.0

  Adaptive Mesh Refinement = false 
  Adaptive Remesh = false
  Adaptive Save Mesh = true
  Adaptive Error Limit = 1e-4
End

Material 1
   Density = 1
   Heat Conductivity = 1
   Heat Capacity = 1
End

Boundary Condition 1
  Target Boundaries(1) = 1
  Name = COLD
  Temperature = 0
End

Boundary Condition 2
  Target Boundaries(1) = 2
  Name = HOT
  Heat Flux BC = True
  Heat Flux = 100
End
2 - enable mesh refinement (line 51 in sif to 'true'). no major change, all good.

3 - adapt2.grd / adapt2.sif
(adaptive mesh off) add a discontinuity to the grd file and sif using old method (discontinuous bc 3 in grd file, heat gap defined in sif as bc 3)
runs fine. temperatures look as expected with a jump at bc 3.

adapt2.grd

Code: Select all

***** ElmerGrid input file for structured grid generation *****
Version = 210903

Coordinate System = Cartesian 2D
Subcell Divisions in 2D = 3 3 

Subcell Sizes 1 = 1e-3 1e-3 1e-3
Subcell Sizes 2 = 1e-3 1e-3 1e-3

Material Structure in 2D
  2 1 2
  2 2 2
  3 3 3
End

Materials Interval = 1 3

Boundary Definitions
! type     out      int      double   of the boundaries
  1        -1       3       1
  2        -3       1       1
  3        -1       2       2
End

Surface Elements = 10
Triangles = logical true  !needed for RGB adaptive meshing
Numbering = Horizontal
Element Degree = 1
adapt2.sif

Code: Select all

Header
  CHECK KEYWORDS Warn
  Mesh DB "." "adapt2"
End

Simulation
  Max Output Level = 5
  Coordinate System = "Cartesian 2D"
  Coordinate Mapping(3) = 1 2 3
  Simulation Type = "Steady State"
  Steady State Max Iterations = 10
  Post File = file "adapt.ep"
End

Body 1
  Target Bodies(2) = 1 2
  Equation = 1
  Material = 1
  Initial Condition  = 1
End

Body 2
  Target Bodies(1) = 3
  Equation = 1
  Material = 1
  Initial Condition = 1
End

Equation 1
  Heat Equation = True
  Active Solvers(1) = 1
End

Solver 1
  Exec Solver = "Always"
  Equation = "Heat Equation"
  Procedure = "HeatSolve" "HeatSolver"
  Variable = "Temperature"
  Variable Dofs = 1
  Optimize Bandwidth = True
  Linear System Solver = "Direct"
  Linear System Direct Method = "umfpack"
  Steady State Convergence Tolerance = 1.0e-5
  Stabilize = True
  Nonlinear System Convergence Tolerance = 1.0e-4
  Nonlinear System Max Iterations = 3
  Nonlinear System Newton After Iterations = 2
  Nonlinear System Newton After Tolerance = 1.0e-3
  Nonlinear System Relaxation Factor = 1.0

  Adaptive Mesh Refinement = false 
  Adaptive Remesh = false
  Adaptive Save Mesh = true
  Adaptive Error Limit = 1e-4
End

Material 1
   Density = 1
   Heat Conductivity = 1
   Heat Capacity = 1
End

Boundary Condition 1
  Target Boundaries(1) = 1
  Name = COLD
  Temperature = 0
End

Boundary Condition 2
  Target Boundaries(1) = 2
  Name = HOT
  Heat Flux BC = True
  Heat Flux = 100
End

Boundary Condition 3
  Target Boundaries(1) = 3
  Name = heatgap
  Heat Gap = True
  Heat Transfer Coefficient = 1000
End

4. - enable mesh refinement (line 51 in sif to 'true'). SEGFAULT:

Code: Select all

WARNING:: CRS_AddToMatrixElement: Matrix element is to be added to a nonexistent position
WARNING:: CRS_AddToMatrixElement: Row: 333          Col: 58
WARNING:: CRS_AddToMatrixElement: Number of Matrix rows:516
WARNING:: CRS_AddToMatrixElement: Converting CRS to list
ListToCRSMatrix: Matrix format changed from CRS to List

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  ffffffffffffffff
5. - use newer discontinuous boundary model for heat gap. adapt3.grd / adapt3.sif
don't double nodes in grd, use new keywords in sif. all is good, jump as expected.
adapt3.grd:

Code: Select all

***** ElmerGrid input file for structured grid generation *****
Version = 210903

Coordinate System = Cartesian 2D
Subcell Divisions in 2D = 3 3 

Subcell Sizes 1 = 1e-3 1e-3 1e-3
Subcell Sizes 2 = 1e-3 1e-3 1e-3

Material Structure in 2D
  2 1 2
  2 2 2
  3 3 3
End

Materials Interval = 1 3

Boundary Definitions
! type     out      int      double   of the boundaries
  1        -1       3       1
  2        -3       1       1
  3        -1       2       1
End

Surface Elements = 10
Triangles = logical true  !needed for RGB adaptive meshing
Numbering = Horizontal
Element Degree = 1
adapt3.sif:

Code: Select all

Header
  CHECK KEYWORDS Warn
  Mesh DB "." "adapt3"
End

Simulation
  Max Output Level = 5
  Coordinate System = "Cartesian 2D"
  Coordinate Mapping(3) = 1 2 3
  Simulation Type = "Steady State"
  Steady State Max Iterations = 10
  Post File = file "adapt.ep"
End

Body 1
  Target Bodies(2) = 1 2
  Equation = 1
  Material = 1
  Initial Condition  = 1
End

Body 2
  Target Bodies(1) = 3
  Equation = 1
  Material = 1
  Initial Condition = 1
End

Equation 1
  Heat Equation = True
  Active Solvers(1) = 1
End

Solver 1
  Exec Solver = "Always"
  Equation = "Heat Equation"
  Procedure = "HeatSolve" "HeatSolver"
  Variable = "Temperature"
  Variable Dofs = 1
  Optimize Bandwidth = True
  Linear System Solver = "Direct"
  Linear System Direct Method = "umfpack"
  Steady State Convergence Tolerance = 1.0e-5
  Stabilize = True
  Nonlinear System Convergence Tolerance = 1.0e-4
  Nonlinear System Max Iterations = 3
  Nonlinear System Newton After Iterations = 2
  Nonlinear System Newton After Tolerance = 1.0e-3
  Nonlinear System Relaxation Factor = 1.0

  Adaptive Mesh Refinement = false
  Adaptive Remesh = false
  Adaptive Save Mesh = true
  Adaptive Error Limit = 1e-4
End

Material 1
   Density = 1
   Heat Conductivity = 1
   Heat Capacity = 1
End

Boundary Condition 1
  Target Boundaries(1) = 1
  Name = COLD
  Temperature = 0
End

Boundary Condition 2
  Target Boundaries(1) = 2
  Name = HOT
  Heat Flux BC = True
  Heat Flux = 100
End

Boundary Condition 3
  Target Boundaries(1) = 3
  Name = heatgap
  Discontinuous Boundary  = Logical True
  Discontinuous Target Bodies (2) =  2 3
  Heat Gap = True
  Heat Transfer Coefficient = 1000
End
6. - enable mesh refinement, same segfault

7. - adding "Discontinuous Bulk Greedy = Logical true", same segfault. set it to false, and it runs, but looking at the ep file in the final RefinedMesh folder, the temperature solution appears to ignore the heat gap even though mesh refinement was very refined around it. (perhaps the gap is there but the heat 'leaks' through it as was seen in other heat gap tests.


I'm guessing since triangle splitting involves putting new nodes on the boundary, somethnig about the discontinuity is unable to adjust both sides of the boundary? odd, then that the Greedy setting allows it to work. in any case, whether it should work or not, a Segfault rather than a controlled warning/error is probably not the desired outcome.
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: adaptive remesh + discontinuity = segfault

Post by raback »

Hi NJank,

This is a combination of two features that are difficult to combine. It is not a low hanging fruit since 1) the error indicator should consider the jump 2) the remeshing should be constrained to be the same over both sides of the BC 3) the refinement routine should be modified to create a new discontinuity. There could be even some non-trivial theoretical considerations.

So the best thing I could do is to add Fatal in the adaptive refinement in case it is being applied to discontinuous mesh. Implementing the combined feature would be a major undertaking.

Thanx anaways for reporting!

-Peter
NJank
Posts: 99
Joined: 05 Dec 2009, 00:05
Location: Baltimore, MD, USA

Re: adaptive remesh + discontinuity = segfault

Post by NJank »

was revisiting this to see if adaptive mesh + heat gap had been implemented yet. Noticed the situation is unchanged, but while most of the cases produced an error now instead of a SEGFAULT, still received a SEGFAULT for case #4 (using adapt2.grd/adapt2.sif and Line 51 Adaptive Mesh Refinement = true). Not sure if it's possible to catch that and throw an error.
Post Reply