MASA-0.44.0
|
The following sections detail all available manufactured solutions in MASA.
This chapter will introduce the user to the basics of the MASA library. This chapter assumes the user has already built and linked the MASA library into their codebase. Now, you desire to access the magic of MASA and begin the process of verification of your codebase.
This tutorial will detail the essential subroutines for any MASA program. The c++ MASA bindings are used throughout, but a tutorial using the Fotran90 or C-code would be essentially unchanged.
To begin, any MASA program will call masa_init
. This routine initalizes a manufactured solution class of some particular type. It requires two inputs: the manufactured solution class name as well as a unique name for this solution.
Thus, to initalize a one dimensional euler equation manufactured solution with the unique name of 'nick', the function call would look something like:
The unique name allows you to initalize several manufactured solutions of the same problem type, should you so desire. This can be useful if you want to access several manufactured solutions of the same type with different parameter sets. You cannot, of course, specify several manufactured solutions with the same unique name!
Please be careful when specifying the second string: this must match the unique identifier for that masa solution. Failing to match here will likely result in MASA aborting.
A logical question to ask at this juncture is where can you find a list of the available manufactured solutions? The available solutions can be found several ways:
masa_printid()
Having initalized the solution, you need to set the variables to some reasonable value. This will depend on your particular problem, but let's continue with the 1d euler example.
Firstly, let's determine what variables need to be set. A list of variables for your solution can be found by:
masa_display_param()
The output from masa_display_param() for our euler1d example will look something like:
Thus, euler_1d has 14 variables, all of which should be set to something. We can set a value of a parameter in MASA using the function, masa_set_param
.
masa_set_param
takes as input a string and a double. The string specifies the parameter we are setting and the double will become the parameter's new value. This overwrites the any previous value the paramter may have had.
Continuing our example, let's set a_rhox to 33.33 (repeating, of course). In our code, this would look like:
Now, checking masa_display_param
, we can see we have set the value of a_rhox:
At this point, we could continue the same process for each remaining variable.
To save you the tedium of doing this, MASA has graciously provided default values for all manufactured solution classes. In general, the default values have been selected to provide reasonable test conditions for verification and whenever possible, defauls correspond to some simple physical constraints (such as not producing negative energy, or density, etc.).
A user can invoke these defaults using the routine: masa_init_param()
. For our euler1d problem, the defaults look like:
Note that setting the defaults will overwrite all previously initalized values for the masa parameters! So if you desire to alter the default values, call masa_set_param
after masa_init_param
.
Finally, you have initalized all the parameters and you are ready to move on ... Or are you? Are you certain you initalized every parameter? Do you really want to verify this by checking masa_display_param()
? Luckily, MASA provides an alternative. The subroutine masa_sanity_check()
will check that every parameter has been set to something.
Now, we need to access the correct source and manufactured solution terms. Let us again use our euler1d solution example. Consulting our MASA documentation, we can see that the available source terms are:
The first three functions (containing "source") are the source terms for the momentum, the energy and the density. The functions containing "_exact_" are the manufactured solutions. Finally, the "_grad_" are the gradients of the manufactured solutions, useful for setting boundary conditions.
In this case, the call pattern is simply: (x), e.g. masa_eval_1d_source_rho_u(x), where x is a Scalar value for the location on the mesh you are evaluating at. In general, the rule for MASA is that the spatial components go first, followed by the temporal component (if applicable). Thus, a 2d unsteady solution would take the form: "foo(x,y,t)". The spatial indicies are always in the order: x,y,z.
For further examples (including c-code and fortran), the user is directed to the examples directory included in the MASA distribution.