Skip to content

Conversation

@krober10nd
Copy link
Collaborator

The automatic selection of the numerically stable timestep for which to CFL limit the mesh sizing function should be based on the max_cr not the min_cr.

This appears to fix #114 with a mesh that should be numerically stable at a timestep of roughly 1.34 seconds because of the high resolution zone near New York, e.g.,

Enforcing timestep of 1.1134 seconds with Courant number bounds of 2.2204e-16 to 0.5

The outer patch by itself is theoretically stable with:

Enforcing timestep of 6.2979 seconds with Courant number bounds of 2.2204e-16 to 0.5

Screen Shot 2020-09-12 at 1 38 30 PM

Copy link
Collaborator

@WPringle WPringle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, yes the fix seems correct.
There is this case where you choose obj.dt to be length 2 and maxCr will be infinity. I think this is mainly user problem but maybe we could have an error for length(obj.dt) = 2 and dt == 0? Saying that dt = 0 is only intended for restricting the upper bound of Cr?

                elseif length(obj.dt) == 2
                    % minimum Courant number bound 
                    minCr = obj.dt(2); 
                    maxCr = inf; 
```

@krober10nd
Copy link
Collaborator Author

krober10nd commented Sep 12, 2020

like this?

            % Determine Courant min. and max. bounds
                 if length(obj.dt) < 2
                     % default behavior if no bounds are passed
                     % for explicit type schemes we ensure the maxCr is
                     % bounded
                     minCr = eps; % Cannot be zero!!!
                     maxCr = 0.5;
                 elseif length(obj.dt) == 2
                     % minimum Courant number bound
                     minCr = obj.dt(2);
                     maxCr = inf;
                 elseif length(obj.dt) == 3
                     % minimum and maximum Courant bound
                     minCr = obj.dt(2);
                     maxCr = obj.dt(3);
                 elseif length(obj.dt) == 2 && obj.dt(1)==0.0
                     error('dt = 0 is only intended for restricting the upper bound of Cr')
                 else
                     error('Length of dt name-value pair should be <=3')
                 end

@WPringle
Copy link
Collaborator

Yeah except that wouldn't work because it would go into the elseif length(obj.dt) == 2 above, so like this:

            % Determine Courant min. and max. bounds
                 if length(obj.dt) < 2
                     % default behavior if no bounds are passed
                     % for explicit type schemes we ensure the maxCr is
                     % bounded
                     minCr = eps; % Cannot be zero!!!
                     maxCr = 0.5;
                 elseif length(obj.dt) == 2
                     if obj.dt(1)==0.0 
                         error('dt = 0 is only intended for restricting the upper bound of Cr')
                     end
                     % minimum Courant number bound
                     minCr = obj.dt(2);
                     maxCr = inf;
                 elseif length(obj.dt) == 3
                     % minimum and maximum Courant bound
                     minCr = obj.dt(2);
                     maxCr = obj.dt(3);
                 else
                     error('Length of dt name-value pair should be <=3')
                 end

@krober10nd
Copy link
Collaborator Author

ah yea. cool.

@krober10nd krober10nd merged commit 297ea32 into Projection Sep 12, 2020
@krober10nd krober10nd deleted the fixAutoDt branch September 12, 2020 19:43
Jiangchao3 added a commit to Jiangchao3/OceanMesh2D that referenced this pull request Sep 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Question about automatically determining the time step

3 participants