Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding 2-D tracer transport in thetis #122

Merged
merged 44 commits into from
Feb 22, 2018
Merged

Adding 2-D tracer transport in thetis #122

merged 44 commits into from
Feb 22, 2018

Conversation

thangel
Copy link
Contributor

@thangel thangel commented Jan 26, 2018

adding the option to solve advection diffusion equation in 2D

Athanasios Angeloudis and others added 30 commits January 26, 2018 13:34
* don't do `if logical_variable==True:`
* overshoot and conservation tests weren't actually run
@thangel thangel requested a review from tkarna January 26, 2018 13:47
Copy link
Contributor

@tkarna tkarna left a comment

Choose a reason for hiding this comment

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

This looks great! Only minor comments

@@ -212,6 +216,8 @@ def create_function_spaces(self):
raise Exception('Unsupported finite element family {:}'.format(self.options.element_family))
self.function_spaces.V_2d = MixedFunctionSpace([self.function_spaces.U_2d, self.function_spaces.H_2d])

self.function_spaces.Q_2d = FunctionSpace(self.mesh2d, 'DG', 1, name='Q_2d')
Copy link
Contributor

Choose a reason for hiding this comment

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

The tracer space is called H in the 3D model, we could use the same symbol for consistency?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, the reason I suggested a different symbol is that I interpreted H as the pressure/elevation space - which in 3D has to be same as the tracer space. For depth averaged tracers, I think we don't get strict conservation anyway, so perhaps we could be more flexible. Also strictly speaking I think the requirement is for the tracer space to be a subspace of the pressure space, so in the case of P1DG-P2 you could use P1 tracers.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, yes we already use H_2d for the elevation space.

self.fields.tracer_2d = Function(self.function_spaces.Q_2d, name='tracer_2d')
self.eq_tracer = tracer_eq_2d.TracerEquation2D(self.function_spaces.Q_2d, bathymetry=self.fields.bathymetry_2d,
use_lax_friedrichs=self.options.use_lax_friedrichs_tracer)
self.eq_tracer.bnd_functions = self.bnd_functions['tracer']
Copy link
Contributor

Choose a reason for hiding this comment

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

Assigning the bnd functions to the equation here. Is this being used? We also set the bnd functions in the coupled time integrator class.

"""
Testing 2D horizontal diffusion of tracers against analytical solution.

Tuomas Karna 2015-12-14, Athanasios Angeloudis 16/01/2018
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we keep these author tags in the source code? To me it's unclear if they're useful. Currently there are some from 2015 that mention me, but no others...

options.horizontal_viscosity_scale = Constant(horizontal_diffusivity)
options.update(model_options)
if hasattr(options.timestepper_options, 'use_automatic_timestep'):
options.timestepper_options.use_automatic_timestep = True
Copy link
Contributor

Choose a reason for hiding this comment

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

Related to setting the horizontal_viscosity_scale: it seems that solver2d.set_time_step does not take viscosity scale into account when computing the time step, therefore use_automatic_timestep is not really meaninful, especially here where we are testing diffusion only. See #79 . Doesn't have to be implemented in this PR.


# project analytical solultion on high order mesh
t_const.assign(t)
tracer_ana_ho.project(tracer_expr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment on high order projection.


# project analytical solultion on high order mesh
t_const.assign(t)
tracer_ana_ho.project(ana_tracer_expr)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think projection to high-order function space is no longer necessary if tracer_expr is pure UFL expression; errornorm should just work. This is a remnant of times when it didn't.

@@ -64,6 +64,12 @@
'unit': 'm s-1',
'filename': 'Velocity2d',
}
field_metadata['tracer_2d'] = {
'name': 'Tracer',
Copy link
Contributor

Choose a reason for hiding this comment

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

Depth averaged?


def _create_tracer_integrator(self):
"""
Create time integrator for salinity equation
Copy link
Contributor

Choose a reason for hiding this comment

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

tracer equation?


class TracerEquation2D(Equation):
"""
3D tracer advection-diffusion equation :eq:`tracer_eq` in conservative form
Copy link
Contributor

Choose a reason for hiding this comment

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

2D

"""
:arg function_space: :class:`FunctionSpace` where the solution belongs
:kwarg bathymetry: bathymetry of the domain
:type bathymetry: 3D :class:`Function` or :class:`Constant`
Copy link
Contributor

Choose a reason for hiding this comment

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

rm 3D

@tkarna
Copy link
Contributor

tkarna commented Feb 5, 2018

One missing bit is the documentation. At least 2D model formulation should be updated. Would also be nice to have a 2D demo with tracers. Can be in another PR.

Copy link
Contributor

@tkarna tkarna left a comment

Choose a reason for hiding this comment

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

I think the high order spaces could be removed altogether from the tests. Also remove thetis/.solver2d.py.swp file.

next_export_t += solverobj.options.simulation_export_time
iexport += 1

# project analytical solultion on high order mesh
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: solution

next_export_t += solverobj.options.simulation_export_time
iexport += 1

# project analytical solultion on high order mesh
Copy link
Contributor

Choose a reason for hiding this comment

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

typo


p1dg_ho = FunctionSpace(solverobj.mesh2d, 'DG', options.polynomial_degree + 2,
vfamily='DG', vdegree=options.polynomial_degree + 2)
tracer_ana_ho = Function(p1dg_ho, name='tracer analytical')
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess my point on the high order projection was that p1dg_ho and tracer_ana_ho are no longer needed. You can just compute the error as errornorm(tracer_ana_ufl_expr, tracer_sol). I think /test/pressure_grad has some examples (degree_rise option is also obsolete).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh now I see, yes I just realised that these do not make a difference! Updating it now

@tkarna
Copy link
Contributor

tkarna commented Feb 21, 2018

Thanks for the updates, looks good to me!

@thangel thangel merged commit 0e9f313 into master Feb 22, 2018
@thangel thangel deleted the than_tracer branch February 26, 2018 09:56
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.

3 participants