Merge lp:~asc/fluidity/extrudeup into lp:~asc/fluidity/fluidity_for_extrude

Proposed by Adam Candy
Status: Work in progress
Proposed branch: lp:~asc/fluidity/extrudeup
Merge into: lp:~asc/fluidity/fluidity_for_extrude
Diff against target: 1124361 lines
To merge this branch: bzr merge lp:~asc/fluidity/extrudeup
Reviewer Review Type Date Requested Status
Adam Candy Approve
Matthew Piggott Pending
Stephan Kramer Pending
Review via email: mp+80809@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Adam Candy (asc) wrote :

Requires documenting in the manual.

lp:~asc/fluidity/extrudeup updated
3770. By j-bull08 <email address hidden>

small change to 3d BFS example to improve the mesh.
Removing unnecessary mesh files.
Sorry for lateness - usual internet problems up here. I have tested these changes.

3771. By j-bull08 <email address hidden>

missing image. Thanks Hannah.

3772. By Hannah Hiester

Manual and example Makefile updates
- Makefiles just edited to clean up pdf generated in post processing
- Link between metric advection in adaptivity chapter and examples chapter put it
- Tidying up vtktools table (if someone could have a quick scan that would be helpful)

3773. By Tim Bond

Commenting out request for missing PDF file so that mediumtests will run;
please could this be supplied and the line uncommented.

3774. By j-bull08 <email address hidden>

Last missing image file. Thanks Tim for bringng this to my attention.

3775. By j-bull08 <email address hidden>

undoing Tim's commenting-out of image file; this has been committed.

3776. By Matthew Piggott

Fix a figure reference.

Revision history for this message
Adam Candy (asc) wrote :

The calculation of top_max in the extrude routines needs to be the max across all partitions - how can I ensure this is negotiated across all nodes?

review: Needs Information
Revision history for this message
Stephan Kramer (s-kramer) wrote :

What about:

  use parallel_tools
  call allmax(top_max)

lp:~asc/fluidity/extrudeup updated
3777. By Jon Hill

Getting rid of the undefined references in the param section of the manual

Revision history for this message
Adam Candy (asc) wrote :

Perfect - thanks.

Revision history for this message
Adam Candy (asc) wrote :

The extrude branch has been updated.

- Added back in the removed preprocessing step
- Ensured the align_with_geoid option works when the domain is spread over multiple partitions
- Added more accurate control over the position of the horizontal layers
- Removed some debugging ewrites

This is now complete, except for a description in the manual.
I'll send out an update of developments to everyone.

review: Needs Resubmitting
Revision history for this message
Adam Candy (asc) wrote :

That previous comment was obviously supposed to be an 'Approve' from me.

review: Approve
Revision history for this message
Adam Candy (asc) wrote :

OK, parallel_tools added and the dependencies regenerated - just a manual entry left now, and that can wait.

review: Approve
lp:~asc/fluidity/extrudeup updated
3778. By Jon Hill

Fixing missing citations. This should make medium tests green now

3779. By Alexandros Avdis

Adding book title to the sagaut1998 bibliography entry.

3780. By Patrick Farrell

Merge the Debian packaging branch. If you want to try it out, go to your source
tree and type

debuild -uc -us

and then the packages will be in the parent directory.

Approved by our man in Amsterdam, S. C. Kramer:
https://code.launchpad.net/~pefarrell/fluidity/debian-packaging/+merge/81048

3781. By Stephan Kramer

Some updates on the meshes chapter.

3782. By Alexandros Avdis

Added link to the Gmsh tutorial in the ``Meshes for Fluidity'' chapter of the manual. Corrected a few typos.

3783. By Adam Candy

Update to the serialtest make directive so that 'make serialtest' on a fresh checkout passes.

3784. By Adam Candy

The backward_facing_step_3d example postprocess make directive failed for me.
It assumes the folder numpy_data exists - this change to the makefile should fix it.

3785. By Adam Candy

Reinstated version numbering for trunk checkouts.

3786. By Tim Bond

Small update adding a clean-debian target to Makefile.in to remove files
generated by the debian 'debuild' process.

3787. By j-bull08 <email address hidden>

Missing reference data for BFS 2d

3788. By Tim Bond

Thanks to Lawrence for spotting this bug.

Where there is a line such as:

 [ -f foo ] && bar

in the makefile, and foo doesn't exist, [ -f foo ] returns an error
which gets passed through to the end of the command and which make
then interprets as a build error, and exists. Adding in a || true at
the end of the line fixes this.

3789. By Stephan Kramer

The final version of the fluidity version saga?

The version information is obtained from bzr as before except when
FLUIDITY_VERSION is passed to configure (used in debian/rules of the debian
package) in which case it is simply set to that value.

3790. By Patrick Farrell

python setup.py install now installs fluidity.diagnostics too. Fixes
lp:885642.

3791. By Patrick Farrell

Make install should depend on fltools.

3792. By Simon Mouradian

Removes warning when 'make clean' with python 2.7.2

3793. By Patrick Farrell

Don't pass --install-layout=deb unless we're building the Debian package.

3794. By Patrick Farrell

When building the Debian package, only use one processor.

3795. By Tim Bond

We want, ultimately, to release a package as '4.1'. Since we suspect that
newness of packages is based on a standard sort, anything appended to 4.1
as a version will probably end up superceding rather than being superceded
by 4.1. Thus, 4.1beta1 wouldn't upgrade as intended when release happens.

Thus, renumbering the changelog to base it on 4.0.999 for the moment, which
can be neatly bumped to 4.1 at release. Note that this also has the 'maverick'
change in, which is required by launchpad so it knows which builder to send the
package to.

3796. By Stephan Kramer

Adding fluidity_tools.py to python-fluidity package.

3797. By Patrick Farrell

Several changes to the Debian packaging:
 * configure --enable-2d-adaptivity
 * install the fluidity schemas into /usr/share/fluidity/schemas
 * register that schema with diamond in /usr/share/diamond/schemata/flml

This means that Diamond should Just Work for users of the binary package.

3798. By Stephan Kramer

Fix of fluidity_tools commit.

3799. By Hannah Hiester

Small edits to the adaptivity chapter and including publishers for some of the citations that were making bibtex complain

3800. By Jonathan Bull

Switching to strong Dirichlet BC, as the weak log law sometimes blows up.

3801. By Alexandros Avdis

Making notations in Parameterisations (LES) chapter consistent.

3802. By Tim Bond

The debian package depended on fluidity-dev for both build *and* runtime,
which meant that an install of runtime fluidity required a huge overhead
of dev packages. Since libraries should be handled by the shlib directive
and we *probably* only want to load enough that the standard examples can
be run, this is a first attempt at a (relatively) minimal set of pacakges
for the runtime fluidity to depend on.

I'm taking 'dependencies' a little bit loosely here, namely assuming:

* gmsh and triangle[-bin] are depended on for mesh handling
* diamond is depended on for configuration
* python is depended on for runtime examples, including python-lxml,
    python-scipy, python-numpy, python-vtk, python-matplotlib,
    python-sympy, and python-fluidity. This list was compiled from
    working through all the python calls in the examples directory.

Going with this as an initial attempt at a good set, I'll push the new
package through launchpad and take a 'suck it and see' approach with the
examples on a clean maverick workstation build.

3803. By Jonathan Bull

capping the run at 100s to prevent blow-up.

3804. By Patrick Farrell

Make the package install shallow_water and burgers_equation too

3805. By Patrick Farrell

Apply Lawrence's fix for bug lp:886062. It is utterly daft
that Python changed the behaviour of one of the core methods of
the elementtree module sometime between maverick and natty.

3806. By Tim Bond

For the purposes of buildbot, and testing of the make install, we want
testharness to be part of the make install process. Noted, though, that
this is a fairly location-specific program which isn't of particular use
in the debian package, so a neater way of including it for buildbot but
excluding it for debian might be beneficial.

3807. By Tim Bond

We now generate a schemas/flml which needs to be cleaned up by make distclean

3808. By Adam Candy

Fixes to the backward-facing step 2d reference simulation, as it was still crashing.
With this, preprocess, run and postprocess all run without error.

Still waiting on the other two backward-facing step runs.

3809. By Simon Funke

Merge the python interface from the libspud trunk which fixes "set_option".
In addition this commit updates optimality.py to be compatible with these libspud changes.

3810. By David Ham

Cause FLLINKER to be used for the hybridized helmholz solver so as to hopefully placate ifort.

3811. By Hannah Hiester

Manual and example postprocessing script updates

For the tides_in_the_Mediterranean_Sea example renaming the vtu produced is postprocessing to reflect the sea which it is modelling.

Manual updates:
- Adaptivity chapter are mostly minor or references to other sections. A section on the cost of adaptivity has also been included - would be useful if someone could have a quick scan.

- Configuring fluidity chapter are again mostly minor and also included remaining general adaptivity options.

- Examples chapter are to the timings for flow past a sphere (now takes a little longer) and tides in the Mediterranean Sea (now is much faster). Also updated the RMS differences in tides in the Mediterranean Sea example to the current values (the change is very small but figured it was best to have as much consistency as posible between the numbers that come out of the postprocessing and the manual)

3812. By Alexandros Avdis

Improvements to the LES documentation in the fluidity manual, notation is now
consistent, the manual lists and explains the options of the SGS models.

3813. By Christian Jacobs

Minor improvements to the diagnostic algorithms section in visualisation_and_diagnostics.tex.

3814. By Alexandros Avdis

minor corrections to LES documentation in the Fluidity manual.

3815. By Tim Bond

r3810 went half way to fixing the Intel compiler issues with hybridized
helmholz. This is built twice, so needs an additional fix as per this commit.

3816. By Tim Bond

Mirroring the previous commit to hybridized helmholz with shallow_water also
needing fixing for the Intel build.

3817. By Tim Bond

Removing a large amount of rogue whitespace in an attempt to placate Intel.

3818. By Tim Bond

Adding .msh files to the k-epsilon_mms_cg_p1p1 test to remedy failures
resulting from sensitivity to gmsh versions. Tested on oneiric where there were
failures, and appears to do the trick.

3819. By Hannah Hiester

Updating to rm -f Sphere_drag.pdf to ensure it doesn't complain if the file doesn't exist

3820. By Tim Bond

Bringing in the examples as a tarball to 'make install' so they can be shipped
with the binary package. This also requires a little bit of munging before they
are tarred up, changing relative paths to binaries/scripts into just the names
in the assumption that they will be on the path once installed.

Also adding in vtktools to the install process as it's required by the
examples.

3821. By Tim Bond

Adding a one-page-primer for Fluidity. This describes how to add the Fluidity
repository, apt-get Fluidity, uncompress the examples, and run top_hat.

It's presently inserted as a single page following the Overview.

Someone casting a quick eye over this page would be appreciated.

3822. By Tim Bond

Adding to commit of r3821, it's helpful if I remember to add the relevant new
LaTeX file having for the one page primer.

3823. By Tim Bond

Manual updates to:

* Add -y to apt commands so the user does not have to respond to prompts
* Add in binary package instructions to the 'getting started' chapter
* Remove some of the verbosity from the 'getting started' chapter

3824. By Tim Bond

Version updates, reflecting the upgrade of fluidity itself from 4.0 to 4.1 and
an associated overhaul of the external libraries chapter to reflect supporting
software which has been upgraded since our last release. Build information for
supporting software has been brought up to date with the wiki page, and
software versions have been updated to reflect Ubuntu Natty versions and
versions as tested through buildbot or at partner institutions.

3825. By Adam Candy

Update to the run times for the backward-facing step exmaples.
(Changes limited to the manual only).

3826. By Adam Candy

Fix the spacing in the \fluidity command.

3827. By Axelle Vire

Correct typo in getting started: source code should be two words.

3828. By Axelle Vire

Fix typo and line cut in Appendix C.

3829. By Hannah Hiester

Updates to example xmls to ensure they pass with testharness (donein agreement with example maintainers)

- flow_past_sphere_Re1000: relaxing tolerances by 1%
- lock_exchange: error in the python corrected
- top_hat: relaxing tolerance on DG bounds

3830. By Axelle Vire

Fix \fluidity spacing in Appendix D. An mbox was using, hence creating double spacing.

3831. By Tim Bond

Updating package changelog in preparation for 4.1-release

3832. By Stephan Kramer

Adding explanation for 2+1D configuration options.

3833. By Tim Bond

Small update to the tarball information to reflect merging examples into the
main tarball (to make life easier for people).

3834. By Axelle Vire

Make chapter 2 (UK) correct.

3835. By Axelle Vire

Fix a couple of typos in chapters 2 and 9.

3836. By Florian Rathgeber

Fixes to section 1.2 of the manual

3837. By Florian Rathgeber

Suggest manual readers to run make -jN rather than make -j

3838. By Stephan Kramer

In the exercises for the 1d advection example, suggest a different alternative cg configuration that beats the crap out of dg. Thanks to CianW.

3839. By Axelle Vire

Various corrections to chapter 4.

3840. By Axelle Vire

Fix typo in chapter 5.

3841. By Axelle Vire

Various corrections to chapters 8 and 10.

3842. By Axelle Vire

Tiny fixes in chapter 10.

3843. By Tim Bond

Clarifying our support policy of aiming to maintain packages and support for
Ubuntu releases for 18 months. This is mandated for non-LTS by the timescale of
Ubuntu support, but given rapid ageing of software is reckoned in Fluidity time
to be reasonable for LTS as well.

3844. By Axelle Vire

Fix some capital letters in the bib.

3845. By Axelle Vire

One more for the bib.

3846. By Tim Bond

Commit purely addressing documentation, orthogonal to functional codebase.

Adding in a short paragraph to the 'Getting Started' chapter noting that unit
testing is broken under Intel as a result of compiler issues, and that we have
no intention of fixing this at our end. Since Intel seem to have no intention
of fixing it at their end either, users are hereby advised not to make unittest
on an Intel build of Fluidity.

3847. By Patrick Farrell

This test has been broken since r3671, but failing silently. The test
Makefile had

input: meshes clean

where meshes made the meshes, and then clean deleted them straight after!

3848. By Patrick Farrell

And the same again for python_shape_dshape_test_2d.

3849. By Patrick Farrell

galerkin -> Galerkin in the text.

3850. By Axelle Vire

When constructing the supermesh, the region_ids allocated the intersections need to be explicitely deallocated. This fix a memory leak that was becoming significant when modelling fluid-solid interactions, where the supermesh is constructed at every timestep.

3851. By Axelle Vire

This will revert my previous commit, which I meant to do on a branch. Even if this is a small fix, let's do it the Right Way.

3852. By Axelle Vire

Merge branch. This is a small change in femtools/Supermesh.F90 that deallocates the region_ids associated to each intersection when constructing the supermesh. This fixes a memory leak that was becoming significant when modelling fluid-solid interactions, where the supermesh is constructed at every timestep. This passes all tests locally.

Revision history for this message
Adam Candy (asc) wrote :

Test failures fixed.
Now builds and passes on buildbot:
http://buildbot-ocean.ese.ic.ac.uk:8080/builders/x86_64-extrudeup-gcc4

lp:~asc/fluidity/extrudeup updated
3853. By Paul Woodhams

Tidying up the edge-list callback. Removed some redundant code, fixed some MPI data types and added a global calculation of the minimum edge weight.

3854. By Stephan Kramer

Bug fix in petsc_readnsolve, for the case where no mesh needs to be read. A dummy mesh is created, but this was done with a bit of a broken hack, now fixed.

3855. By Cian Wilson

Improved error handling for remaps.

3856. By Tim Bond

Fix for bug lp:892228 making the schemata install honour prefix and datadir.

3857. By Cian Wilson

Remove spurious allocate that introduced a memory leak in r3855.

3858. By Patrick Farrell

Merge the dont-install-diamond branch.

3859. By Tim Bond

A one-line build-system-only fix adding a '-f' to an rm in make install, a
direct bug leading on from r3858 and highlighted by the Intel builder.

3860. By Brendan Tollit

Summary:

This merge will correct the sign and number of additions of the weak velocity Dirichlet BC integrals when using a CV tested continuity equation for incompressible flow.

Code Changes:

- assemble/Divergence_Matrix_CV.F90. The variable ct_rhs_local is formed and added (with a minus) for each dimension in the procedure assemble_divergence_matrix_cv.

- schemas/prognostic_field_options.rnc and .rng. A mesh choice is permitted for the Diffusivity of a scalar field. Required for the some of the tests of the fix above and is a useful general addition.

Test Cases Removed:

- tests/darcy_p1dgp2_pressBCinlet_1d

- tests/darcy_p1dgp2_velBCinlet_1d

Test Cases Added:

- tests/darcy_p1dgp2_pressBCinlet. The one removed but now in 1,2 and 3d.

- tests/darcy_p1dgp2_velBCinlet. The one removed but now in 1,2 and 3d.

- tests/darcy_p0p1cv_velBCinlet. Checks the sign of the weak velocity Dirichlet BC aligned with cartesian axis. Single phase.

- tests/darcy_p0p1cv_velBCinlet_1solidphase. Checks the sign of the weak velocity Dirichlet BC aligned with cartesian axis. Two phase with the second representing the solid porosity.

- tests/darcy_p0p1cv_velBCinlet_rotated_domain. Checks the sign of the weak velocity Dirichlet BC NOT aligned with cartesian axis. Single phase.

- tests/mms_ns_p0p1cv_weak_velBC_steady. A mimic of the standard mms_ns test cases using p0p1cv with a weak velocity Dirichlet BC. Here the domain was rotated from a square to a diamond such as to have non Cartesian aligned velocity Dirichlet BC on all surfaces. Checks L2 velocity and pressure convergence is between 0.8 and 1.0. This is a short test.

- tests/mms_ns_p1dgp1cv_weak_velBC_steady. Similar to above but using p1dgp1cv. Checks L2 velocity and pressure convergence is between 1.5 and 2.15. This is a medium test.

3861. By Stephan Kramer

Using get_coordinates_remapped_to_surface() to fix https://bugs.launchpad.net/bugs/893893

3862. By Brendan Tollit

This merge will add the capability when discretising the pressure
with continuous galerkin to test the continuity equation with the
control volume dual function space (rather than the CG function space).

This is tested on a range of cases checking for capturing balances and
getting the correct order of convergence.

This is documented in the manual (theory and usage).

It is described in the manual and schema that this will only work
for incompressible flow and not work with the free surface,
wetting and drying and implicit solids two way coupling models.
Also the pressure mesh must use the Lagranian element type. This is
also restricted to only work with the available control volume shape
functions.

This will produce a non symmetric pressure correction matrix which
must be considered when selecting the pressure solver options.

3863. By j-bull08 <email address hidden>

removing irritating ewrite in smoothing module (used for dynamic LES and Helmholtz smoothing algorithms)

3864. By Tim Bond

Commit entirely in documentation targetting bug lp:891733 and bringing in the
revision format from the root Makefile.in to the manual Makefile. Also updating
the front page to refer to 'branch' rather than 'trunk version'.

3865. By Tim Bond

Commit purely in documentation, providing fixes for the errors noted in
bug lp:885261. Some duplicate bibliography entries removed, some missing
fields inserted, a pair of missing braces added, and one entry reclassified
from article to book.

3866. By Tim Bond

Commit entirely in documentation targetting bug lp:891733 and in addition to
commit for r3864; I had failed to note that LaTeX could complain about the
presence of non-alnum characters. Thus, adding the 'tr' back in to strip all
punctuation. Thanks to Brendan for spotting this one.

3867. By Christian Jacobs

Minor updates to the mphase_rising_body test case. Changed the length from 'special' to 'short'. Passes testing on the ctjacobs-multiphase buildbot queue.

3868. By Cian Wilson

Remove erroneous dimension from Velocity. Wasn't affecting the test in any way.

3869. By Tim Bond

Addressing bug lp:894770 by removing unused tests (either marked 'special'
or which don't have a .xml).

3870. By Jon Hill

Fixing the FLML fiels for the GLS KP test such that the wind surface stress returned from python is the correct dimension (1 not 2)

3871. By Patrick Farrell

When setting a vector field from Python, check the length of the iterable
returned by the user, and check that it is the length we expect. Fixes
lp:800694.

3872. By Tim Bond

Change to documentation only - preparatory manual work for the changes to
Diamond build and install methods.

Note that this does not address (and we have not in the past addressed) the
needs of diamond for supporting software to exist on the system. This probably
needs to be added to one of the appendices at some point; specifically libxml2
and python-lxml, assuming I'm remembering correctly that they are hard
dependencies.

3873. By Brendan Tollit

Add an option to include the Source field directly to the right hand side
for prognostic scalar fields. Adjust CG, DG, FV and CV to
act on this as necessary. Include a very simple two field eigenvalue
(using the time step loop as a power iteration loop) 1d test
case for each discretisation checking order of converegence to test
this new functionality.

This also includes a comment in the schema that variations in
the Source field across subcycled time steps is not considered,
a constant value across the whole time step is assumed (whether
added directly or tested with shape_rhs).

In assemble/Advection_Diffusion_CG.F90 a redundant optional
variable passed in called extra_discretised_source is removed, as
well as the code that added it to the rhs.

3874. By Tim Bond

This merge supplies:

* An updated version of libspud
* An install target for diamond in the root fluidity makefile
* A target in the root fluidity makefile to install user schemata

3875. By Cian Wilson

Loosen tolerances on this test to hopefully make buildbot green again. Still curious why Gerard's changes made a test that's been stable for years change.

3876. By Cian Wilson

Cleaning up and making consistent the exclusion of tags in make test and make mediumtest (also deleting make mediumzoltantest as buildbot didn't use it anymore). Most importantly adding an algencan tag and 2dadapt tags where appropriate to medium tests so that they don't fail when fluidity is not configured with algencan (the norm) or 2d adaptivity (unusual).

3877. By Cian Wilson

This missed out on a 2dadapt flag in the merge.

3878. By Tim Bond

Minor relaxation on tolerance to allow for Precise.

3879. By Tim Bond

A slight relaxation of the tolerance on this test to cater for Precise.

3880. By Jon Hill

Editing geopressure_conv test Makefile to use fldecomp in the current checkout, not the centrally installed one

3881. By Brendan Tollit

This merge will add the capability for the enforce discrete property solenoidal projection when
the lagrange multiplier is CG to test the divergence of the interpolated field with the CV dual.
This is akin to what was added for the velocity-pressure solve previously via this branch.
This adds an option to the schema, commenting that this will make the matrix non symmetric.

There is also a small correction to an addition of the known velocity divergence to the projection
rhs to use ctp_m rather than ct_m (in this solenoidal projection routine).

This is tested via the solenoidal unittest, with an extra case added to check for CV divergence.
Non used code was also removed from here.

3882. By Brendan Tollit

This merge will add a procedure to be able to have non zero pressure Dirichlet
boundary conditions when using a CV discretisation for pressure. As for the CG
pressure BCs the integrals are included for both weak and strong Dirichlet.
For multiphase the phase volume fraction is included via a FE spatial
interpolation, akin to their inclusion in interior domain terms.

Code Additions:

- assemble/Pressure_Dirichlet_BCS_CV.F90. Adds the BC integrals via forming
the same local matrix as the weak velocity BCs but uses it transposed,
which is similar to pressure CG version(s).

Code Changes:

- assemble/Momentum_Equation.F90. If cv_pressure calls the above routine
after assembling the main momentum equation terms.

- assemble/Makefile.in. Update for new file/module (using .o rather than .F90
as spotted by Cian)

- assemble/Makefile.dependencies. Update for new file/module.

Test Cases Added:

- tests/darcy_p0p1cv_pressBCinlet. Simple channel flow model using darcy
flow with a pressure gradient using p0p1cv for 1,2 and 3d. Analytic
and very fast.

- tests/darcy_p0p1cv_pressBCinlet_1solidphase. Same as above but with an
extra phase to represent the porous media for darcy flow. Analytic
and very fast.

- tests/darcy_p0p1cv_pressBCinlet_rotated_domain. Similar to the above
but with a rotated domain as the pressure BCs have a normal component
so worth checking non axis aligned integrals. Analytic and very fast.

- tests/darcy_p0p1_test_cty_cv_pressBCinlet. Similar to above but with
CG pressure and CV continuity. This is added as not many CG pressure
BC test cases appear to exist. Analytic and very fast.

- tests/darcy_p0p1_test_cty_cv_pressBCinlet_rotated_domain. Same as
above but rotated. Analytic and very fast.

- tests/darcy_p0p1_test_cty_cv_velBCinlet. Similar to above but with
weak velocity BC instead. Just to test a combination of two previously
merged branches and the test case is very similar to above.

3883. By Rhodri Davies

Merging Stokes Options Check branch into trunk. Thanks to skramer for review.

Happy New Year to all!

3884. By Rhodri Davies

Some string continuation fixes which will hopefully placate the cx1 build. Also removed unused variable ncars from populate state.

3885. By Brendan Tollit

Relax two tolerances (1.0e-09 to 2.0e-09) from a previous merge that seems to affect the i386 builds
for the 3D cases of these tests.

No idea why this is a problem for 3D (and not 1D or 2D) and for i386 and not gcc.

3886. By Jon Hill

Adding a try block around the import of scipy in fluidity state_types.py. This allows use of the majority of state_types functionality without scipy being installed, which is useful for HECToR

3887. By Jon Hill

Fix for geopressure_convergence test. This works on my 32 bit laptop

3888. By Patrick Farrell

Cian pointed out in lp:904816 that running the Burgers equation and
shallow water adjoint tests modifies some files that exist in bzr.
This commit should hopefully fix this. The issue is very minor (utf8
vs. utf-8 in the header of XML files, and minor variations in gmsh
versions).

3889. By Gerard

Bugfix for Bug #900774.

This is a work around for a known bug in the advance option when using stream IO for formatted reads:
http://software.intel.com/en-us/forums/showthread.php?t=101333

The exact intel compiler version may have to be tweaked as the Intel fix has not yet been released.

3890. By Axelle Vire

Merge from lp:~avire/fluidity/fix-absorption-cg-bug.
This fixes the bug https://bugs.launchpad.net/fluidity/+bug/897358 and tests it.

3891. By Axelle Vire

Change the test_source_absorption from short to medium.

3892. By Simon Funke

Loosing tolerance for the turbine tests a bit to make buildbot happy.

3893. By Patrick Farrell

Remove the time_averaged_vector_squared tensor diagnostic algorithm, as it
was broken for a while and didn't error; it is untested. Resolves lp:788620.

3894. By Simon Mouradian

merge salt finger fix

3895. By Jon Hill

Relaxing tolerences for two tests for the 32-bit issue.

3896. By Jon Hill

Adding back in a bug fix I did ages ago. It was removed when I incorporated changes from a 3rd party into the biology python module. Must be more careful in future and construct a test of this

3897. By Patrick Farrell

Rename libadapt's fdebug.h => fdebug_adapt.h. This fixes the build error caused when
a user has -Ifluidity/include in front of libadapt's -I../include. Fixes lp:915907.

3898. By Patrick Farrell

Forgot to commit the Makefile.in.

3899. By Tim Bond

DOCUMENTATION CHANGE ONLY.

Updating the manual to reflect the new system of versioning, the new system
of tarball generation, and new system of obtaining tarballs. This removes
references to the stable release, replacing them with 4.1, which will be
formally implemented as of 4.1.3.

3900. By Adam Candy

Removal of the named solver reordering options.
Notes have been added to both the schema and Solvers.F90 stating the reordering mechanisms have not been tested, and how to use them if you want to try them out.
This addresses bug lp:818015.

3901. By Tim Bond

One-line fix in build system only, targetting bug lp:921464 by adding an
extra install line in the 'make install-diamond' target of Makefile.in
to install dxdiff.

3902. By Patrick Farrell

Incorporate the libtool config files from Fedora 15, to update libtool
to a more recent version. Our old libtool was too old to correctly
recognise gfortran 4.6. Fixes lp:918235.

3903. By Gerard

Should return 0 rather than non-zero when the -V option is specified.

3904. By Adam Candy

A help call to Fluidity also does not now complete with a non-zero error.

3905. By Florian Rathgeber

Sync libspud with spud trunk r512.

3906. By Tim Greaves

Fix in build-system only - targetting bug lp:921608 filed against
spud but also affecting Fluidity, which should fix the install-diamond
target in the Fluidity makefile. This brings libspud in Fluidity in
sync with r513 of lp:spud.

3907. By Tim Greaves

Commit purely in build system, reverting the growing untidyness of conflicting
prefixes trying to make a diamond install work from the libspud in Fluidity.
This goes back to a reconfigure with the user's prefix, then installs, then
reconfigures with the prefix that Fluidity expects to be used internally. This
ought to resolve problems with the spud schemas not getting installed.

3908. By Christian Jacobs

Merging fix-multiple-material-phase-python-diagnostic branch revisions r3897 to r3902 inclusive into trunk.

Summary of change:
==================
We now pass the whole states array to calculate_diagnostic_variable if a Python diagnostic algorithm is used to compute the VelocityAbsorption, VelocitySource or Viscosity diagnostic fields. Otherwise, we just pass the submaterials array. Brendan has created a test case for this (pydiag_material_phase_support_multiple_velocity_children).

This resolves bug lp:800126.

3909. By Tim Greaves

Commit purely in build system. A path error in the Makefile.in spotted by Simon
Mouradian means that the flml schema was being installed in ~/.schemata rather
than into ~/.diamond/schemata. This fix modifies the path to point to the
correct location.

3910. By Brendan Tollit

Summary:

This merge will permit the use of P2 control volumes for a tetrahedral mesh.
This extends the CV faces routine to add the p2cv tet shape functions.
The method to form the CV mass matrix is then changed to use a sub CV
analytic approach (for p1 and p2 elements one can calculate by hand the
sub CV fraction of the parent element) rather than lumping a FEM mass
matrix. Routines are added to get the cv mass and compute the cv mass.
Everywhere we could find that required a cv mass matrix now calls these
routines. Diagnostic routines to output the CV mass and the lumped FE mass
have been added. The capability to include the density in the
GridReynoldsNumber diagnostic has also been added. These last two
changes are included in the manual.

11 test cases are added (basic, advection, darcy, mmat, mms). A couple
of test cases where changed to not output cv stats as they didnt need it.

This permits p1dgp2 for multimaterial (although may well be buggy linked to
other features) and is known to not work with conservative bounded mesh
to mesh interpolation.

This was worked on by Cian Wilson and myself and reviewed/checked by Axelle.

3911. By Tim Greaves

Fix for lp:928771 , making an install of libspud's spudtools into the root
Fluidity directory a depenency of 'make mediumtest', and adding a rule to the
root Fluidity Makefile.in to this end.

3912. By Jon Hill

Trivial fix to the two sinking velocity test so that the user is not asked which algorithm GMSH uses. Simple command line fix is all that is requried.

3913. By Jon Hill

Reverting accidental changes to ocean biology

3914. By Brendan Tollit

Relax two tolerances for the max GridReynoldsNumber from 1.0e-02 to
2.0e-02 for these two medium test multimaterial cases, to hopefully
make the i386-gcc4 build green.

3915. By Brendan Tollit

Relax tolerances on these two test cases slightly more again from
2.0e-02 to 2.5e-02.

3916. By Tim Greaves

One-line fix to build system only; correcting 'FLINKER' to 'FLLINKER'. Thanks
to Zhenhua Lin for spotting this one!

3917. By Adam Candy

A fix to ensure 'make schema' succeeds on a fresh checkout.

This commit adds a Makefile directive to install spud-preprocess, which is required by the 'schema' directive.
Note that this new directive does not interfere with the build of libspud, which is performed within its own directory.
It is only called when required by 'make schema'.

3918. By Tim Greaves

One-line fix in build system only, replacing a plain copy of bin/ in the
install target of the root makefile with a find-based copy to deal with
the appearance of subdirectories which are not wanted in the final install
but which cause non-zero exit states of the install.

The specific case being dealt with here is the tests/ directory made by the
unittest target of the makefile, as spotted by Lin Zhenhua.

3919. By Tim Greaves

(Hopefully) minor fixes to the diamond_validation test, removing the dependency
on gtk.gdk which doesn't look to be necessary in the test (and which breaks on
systems with no DISPLAY available), and adding the local copy of the diamond
source to sys.path to allow diamond.debug and diamond.schema to be imported in
situations where the system doesn't have a central diamond install.

3920. By Tim Greaves

Bringing Fluidity's version of libspud up to date with r.515 of the
libspud trunk.

3921. By Adam Candy

Correction of a mistake in a logging message of the gyre_2d test.

3922. By Adam Candy

A new test case: a P1DG-P2 version of the 2d gyre (gyre_2d).

Fangxin asked me how to set this up yesterday for Travers, so I thought it's worth adding it to the tests.
The diagnostic needed adjusting to account for the existance of negative velocities in the y-coordinate direction along the Western boundary (since we apply the Dirichlet no-slip conditions weakly here).

3923. By Adam Candy

Contributes to fixing bug lp:920944.
The netCDF reader used when reading a file specified under ../from_netcdf/file options now gives more feedback when the point requested is not present. It reports the coordinates and filename to facilitate easier debugging.

This fixes the problem reported by Yi HanSoo, where the error from the reader was ambiguous as to which points could not be located in which file. We may need to make similar changes to other instances of NetCDF reads in the code, or better, unify them all into one routine.

Merge request made and approved at:
https://code.launchpad.net/~fluidity-core/fluidity/netcdferrorreporting/+merge/92443

3924. By Adam Candy

Further contributions to fixing bug lp:920944 (so it can be closed).
Two further instances of NetCDF readers now error more verbosely when the required data is not found. The reports include the coordinates (in both Cartesian and spherical, where applicable) and filename to facilitate easier debugging.

These additional changes are very similar to the change that has already gone in with the approved merge request at:
https://code.launchpad.net/~fluidity-core/fluidity/netcdferrorreporting/+merge/92443
so I have pushed them straight to the trunk.

3925. By Adam Candy

Fix to bug lp:922025. This tidies up the manner in which the pressure initial condition is set from a free-surface height field provided in a netCDF file.

Summary of changes:
 - The special case, legacy method has been removed.
 - If the input format is not recognised, the code will abort with an error detailing the problematic field and the schema path of the invalid format.
 - The 'standard' format is now named 'raw' (instead of 'other'). This is the case where no post-processing is performed on the source data, and the field is initialised by the raw data present in the netCDF file.
 - Included logging messages to indicate which field is being populated and the source netCDF file (logging level 1).
 - Logging of the post-processing applied (logging level 3).
 - For the pressure boundary condition set from a free-surface field in particular, logging level 3 will report the min and max values of the field before and after the conversion.
 - A new section in the manual describing how to initialise the pressure field by specifying the free surface height. Removal of the description of the legacy method to achieve this. Other corrections to nearby sections.

There are currently no tests, examples or longtests that are affected by the above change, but possibly user-generated initialisation flml files that do use the legacy implementation of the pressure initial condition set from free-surface netCDF. In this case, the additional logging added with this change should make it easy to identify the change required to adopt the improved version of this import.

In short, the following example highlights the change necessary:
  The option path:
    /material_phase::Ocean/scalar_field::Pressure/prognostic/initial_condition::WholeMesh/from_netcdf/format/Free-surface height

  should become:
    /material_phase::Ocean/scalar_field::Pressure/prognostic/initial_condition::WholeMesh/free_surface/from_netcdf/format/raw

  (where the file location is specified under the 'from_netcdf' node in each case).

3926. By Adam Candy

New test case: netcdf_read_free_surface
This creates a valid netCDF file containing a free surface height in the domain x,y in [-1.2,1.2]. This is read in by Fluidity as a free surface and applied as an initial condition on pressure. From this, Fluidity calculates the free surface as a diagnostic, which is provided in the outputted VTU file, alongside a field containing the analytic function used to create the netCDF file in the first place (here described in height.py). The test compares the difference between these two fields, which should be small, due to the interpolation of the netCDF file.

In summary this case tests:
 - NetCDF reader
 - Reading of a free surface and conversion into a pressure initial condition
 - Creation of the free surface diagnostic from the pressure field (including its extrapolation down from the top surface)
 - Creation of prescribed scalar fields from Python

3927. By Adam Candy

A new test case: netcdf_read_errors
This checks the errors reported when an attempt to read an invalid NetCDF file is made. Here 'invalid' refers to a file that is itself an invalid, non-conforming NetCDF file, or is of a format not supported by Fluidity.

Five types of NetCDF files are checked:
 - One which does not provide all the data requested,
 - One is missing a dimension (i.e. it provides only a 1d field),
 - One is missing the main variable,
 - One contains an incorrectly-labelled dimension (as 'lat', not 'x'), and
 - One has the variable incorrectly labelled (as 'height', not 'z').

3928. By Brendan Tollit

This merge will tidy up, improve, test and document the single phase porous
media Darcy flow model. This will sync the porous_media options model with
all the darcy_... test cases that have appeared over the past couple of months.
The model that used to be initiated by the porous_media option is effectively
removed as it contained code that was never finished, consistent, tested or
documented and was made by people that are not involved in Fluidity any more.
It is now favoured to define the Darcy velocity absorption field via python
diagnostics rather than a hard coded internal algorithm. Sections are added
to the manual to explain the model equations, discretisation and necessary
options.

Old tests cases are removed and new ones added.

3929. By Brendan Tollit

Correct a variable name in a ele_ngi check that was in a #ifdef DDEBUG
in assemble/Advection_Diffusion_CG.F90

3930. By Tim Greaves

Minor Intel-specific fixes, reducing line lengths which overrun in the
middle of quoted strings.

3931. By Stephan Kramer

Bug-fix for SampleNetCDF which is used in tidal boundary conditions. This bug would occur whenever a node was interpolated that is located exactly on one any of the constant longitutde or latitude lines of the input netcdf grid. In this case instead of interpolating between the value of the 2 nearest nodes, the value was extrapolated.

This code clearly needs some more tests. Coming up...

3932. By Axelle Vire

Loose the tolerance on this test slightly (with Brendan's consent) since it makes the trunk fails locally on my Maverick machine.

3933. By Axelle Vire

Relax a tolerance on this test with Brendan's consent. The test was passing locally but failed on independent buildbot branches.

3934. By Axelle Vire

Correct Brendan's option check regarding the use of CV for continuity with two-way coupling. Apologies that it hasn't been done before the merge.

3935. By Axelle Vire

Forgot an option check. Sorry for the noise.

3936. By Patrick Farrell

Remove the finest simulation (_E) from the Burgers MMS replay test.
This should hopefully speed up the test so that it falls within
buildbot's 20-minute limit ..

3937. By Brendan Tollit

Remove the porosity from the DG_CourantNumber and ControlVolumeCFLNumber
diagnostic fields. Add three new diagnostic fields being
InterstitialVelocityCGCourantNumber, InterstitialVelocityCVCourantNumber
and InterstitialVelocityDGCourantNumber which are only for porous media
flow where the Darcy velocity (= porosity * interstitial velocity) is
solved for.

These are magic named diagnostic fields rather than algorithm names due to
the way the courant number fields are already used.

Everywhere in the options where ControlVolumeCFLNumber can be selected
(such as CV face value schemes) permit the selection of
InterstitialVelocityCVCourantNumber.

For CV (or coupled CV) discretised fields there is a restriction that all
the 'porosity' fields used must be the same with the same theta averaging
also, due to the way this is obtained from one call in Field_Equations_CV.
The default options when used satisfy this constraint.

For adaptive time stepping also permit the selection of
InterstitialVelocityCGCourantNumber. If an InterstitialVelocityCG/CV
CourantNumber is used for adaptive time stepping then always force its
calculation in this routine as the options here may be different to a
field that may exist in the state.

For a scalar field discretised with DG add the small new capability to
select which Courant number field to use for the temporal sub cycling
with the available selections being DG_CourantNumber and
InterstitialVelocityDGCourantNumber. To avoid changing all the test cases,
by default if not activated this option will do as before and use
DG_CourantNumber.

Add a copy of a short darcy flow test case that now discretises the tracer
with DG using subcycling and adaptive time stepping related to the new
interstitial velocity courant number fields.

Adjust all relevant darcy test cases to also test this.

Add a routine in assemble/Porous_Media.F90 to find the theta averaged
porosity field, to avoid a code copy in the adv-diff CG/CV/DG routines.

Add to the manual a description of the three new diagnostic fields and
adjust the configuring Porous media flow section as required.

3938. By Brendan Tollit

Small correction to last merge. Only use the relevant variables from
Global parameters and correct some repetetive English in a couple of
FLExit's.

3939. By Brendan Tollit

Relax two tolerances for the intel build for this recently added test.

5.0e-03 --> 8.0e-03 (integral of tracer)

5.0e-04 --> 6.0e-04 (min of tracer)

3940. By Jon Hill

Shortening gls-KP test by remove one of the four tests within this

3941. By Rhodri Davies

Change solver and steady state tolerances to speed this test up. Now runs in less than 1 minute on my system.

3942. By Jon Hill

And four became two. Hopefully this passes in less than 10 mins on buildbot

3943. By Tim Greaves

One-line fix in buildsystem only targetting bug lp:920446.

This checks for an empty DESTDIR and replaces such with / rather than supplying
an empty --root= which was causing problems with distutils.

Thanks to Patrick, Florian, and Stephan for input.

3944. By Jon Hill

Shortening the test again. Should be half the time now

3945. By Christian Jacobs

Small changes to the mphase_tephra_settling test to reduce the runtime. Passes locally.

3946. By Tim Greaves

Merging upstream updates to spud into the Fluidity trunk; this brings
the local copy in Fluidity in sync with r.520 of the spud trunk.

3947. By Tim Greaves

Following the update of spud in Fluidity to r.520 of lp:spud, this commit
updates all options files in the Fluidity trunk, resulting from running
tools/update_options.py.

3948. By Tim Greaves

r.3947 failed; the system it ran on had an old version of spud/diamond
installed. The Spud 1.1.4 (lp:spud r.520) packages are now out and this is the
result of running tools/update_options.py on a system with those packages
installed.

3949. By Lawrence Mitchell

Avoid memory blowup in update_options

When schema files are read in diamond, the tree-structure is memoised
internally to improve performance. But this comes at the expense of
additional memory use. Previously in update_options we would read the
relevant schema file for every file we were checking. This would
never hit the previously memoised values, since object ids were
different. Instead, build a dictionary of pre-parsed schemas and
just grab the relevant one when checking a file.

3950. By Stephan Kramer

This deals with bug https://bugs.launchpad.net/fluidity/+bug/947049

"The script gmsh2triangle tries to identify isolated nodes that are not attached to any elements (isolated nodes) and leaves these out of the output triangle files. This requires a renumbering of the nodes. However this renumbering is only applied to the .ele file but not .edge/.face file. Thus this renumbering only works correctly when the isolated nodes have node numbers that are bigger than any of the boundary nodes. Otherwise the node numbering of the surface mesh and the interior mesh no longer correspond leading to very onobvious errors in fluidity."

Fixed by no longer applying any renumbering. This was decided to be the best fix as gmsh meshes are now also be readable directly by fluidity, in which case isolated nodes would be read as well. So if isolated nodes are present in the input gmsh .msh it's up to the user to fix.

3951. By Simon Mouradian

A tool to radially scale .vtu files on the sphere.

3952. By Cian Wilson

Updating to new base schema.

3953. By Simon Mouradian

fix for create_param_sweep

3954. By Brendan Tollit

Precise build fix for the cv_mass_matrix_check_p1 and
cv_mass_matrix_check_p2 test cases.

Issue was actually gmsh. These test cases require a one
element mesh to do some very basic checks of the CV mass
matrix. The gmsh with the precise buildbot doesnt seem to
be able to do that anymore with these .geo files. Therefore
commit the very simple .msh files that do work.

Adjust the test Makefile's as required.

3955. By Brendan Tollit

Remove options to use the CV Ultimate limiter from metric advection as the
code does not permit it. Add 2 tests for the advection of a scalar field
using the CV Ultimate limiter as there were none. Both use a P1 FE face
value before limiting. One advects a step change, the other is a copy of
an mms case. Also add the mms case for the CV Sweby limiter for comparison.
For the step advection Ultimate is far better than Sweby but not quite as
sharp as HyperC, which is expected. For the mms test case it was found
necessary to apply a strong BC for the Ultimate limiter case so that
it will converge to a steady state - this however reduces the order
of convergence achieved.

No actual code changed, only options schema and test cases.

tests/mms_tracer_cv_adv_steady/MMS_E_cv.flml is removed as it is not used.

Linked to bugs:

https://bugs.launchpad.net/fluidity/+bug/934250
https://bugs.launchpad.net/fluidity/+bug/934259

3956. By Brendan Tollit

Remove two test cases that have a memory leak on Precise. This is
linked to bug report:

https://bugs.launchpad.net/fluidity/+bug/963989

and branch:

lp:~btollit/fluidity/3mat_p1dgp2_test_cty_cv_memory_leak

3957. By Jon Hill

Minor chnage to configure to get the HECToR build working

3958. By Stephan Kramer

Fix for parallel scalar dg subcycling when configured with debugging. It tried to invert the local mass matrix of non-owned elements, which have not been assembled. Fixed by telling it not to do so. Added further asserts so that similar bugs will also be catched in 2d.

3959. By Stephan Kramer

Fix for precisison issues on precise. Cian helpfully provided a robust fix by reverting to an earlier version, but since I'm impatient as ever I preferred to keep the non-quadratic algorithm using lexsort. This means Cian may forever blame me if this breaks again.

3960. By Jon Hill

Minor fix to the recent dg subcycling merge. mass should not be altered in this routine, so the last if block should be inv_mass. Will fix HECToR and precise builds

3961. By Jon Hill

Loosening tolerences on this test to make it pass on Natty and Precise. A note in the XML says what the tolerences should be

3962. By Simon Funke

Loosen test tolerance for turbine_flux_dg_2d to make it pass with precise

3963. By Simon Funke

Fix the turbine_flux_dg_2plus1 test by loosing the tolerance slightly.

3964. By Simon Funke

Fix turbine_flux_penalty_2plus1 test by slightly loosing the tolerances

3965. By Simon Funke

Fix the turbine_flux_penalty_2d test by slightly loosing the tolerances.

3966. By Simon Funke

Fix shallow_water_adjoint_default_controls_2d by slightly loosing the tolerance.

3967. By Simon Funke

Fixing the wetting_and_drying_balzano1_cg test by choosing a slightly smaller timestep.

3968. By Simon Funke

Now this is annoying: Apparently I need to reduce the timestep from 600s to 300s to get the test that worked before running on precise!

3969. By Simon Funke

Some more tolerance loosening for turbine_flux_penalty_2plus1 and turbine_flux_dg_2plus1

3970. By Tim Greaves

Updating the femtools Makefile.dependencies which appears to have been missed
at r3958

3971. By Tim Greaves

Minor commit in build system and tests to ensure that 'make distclean' does in
fact return the build tree to a fully clean state.

3972. By Tim Greaves

One-line fix targetting bug lp:850727 which had only been partially
implemented. This should complete the fix.

3973. By Jon Hill

One of the MPI_AllReduces is only necessary when using additional adapt iterations. This commit fixes the code so that it only does the collective communication when the additional adapt iterations option is being used.

3974. By Jon Hill

Move all C/Fortran tools to using the c_iso_binding module. This prevents random errors that have been occurring on some build tests

3975. By Jon Hill

Fixing bug in vertical integration - wrong types being passed over from C

3976. By Rhodri Davies

Speed this test up further

3977. By Rhodri Davies

Merge in branch that remove leading whitespace in diagnistic dependency lists

3978. By Christian Jacobs

Merging lp:~fluidity-core/fluidity/bc_from_field branch revisions r3962 to r3975 inclusive into trunk.

Summary of change:
==================
Users can now enforce boundary conditions that use boundary data from another field. This can be done by selecting "from_field" (from the list of "constant", "python", ..., and "from_field" input types for the BC) and specifying the name of the 'parent' field which contains the boundary data.

A short test case called bc_from_field is included.

3979. By dujuan

Combining EnKF framework with ReducedModel

3980. By Tim Greaves

Reverting r.3979 until it's been through the review and test process; Juan Du,
please could you make a branch and commit these changes to that branch, then
let me know to make you a buildbot queue for it, and put in a merge request.

Thanks!

3981. By David Robinson <email address hidden>

A small edit to include velocity in GetFieldNames

3982. By Alexandros Avdis

Correction to rotate2ll.

3983. By Tim Greaves

Two minor fixes on the move to precise, entirely in test framework:

* netcdf_read_errors had a bashâ‚‹specific construct; making generic to
   allow it to be parsed with dash
* sloshing_tank needs a very small relaxing of one check; confirmed
   with the test owner (Simon Funke)

3984. By Lawrence Mitchell

Make linear system assembly local (non-communicating)

This merge brings in non-communicating assembly routines for all
equation forms. It also adds OpenMP threaded assembly for DG and CG
Momentum and CG advection diffusion. To enable the latter, configure
--with-openmp.

For non-communicating assembly, we assemble in halo elements for DG as
well as CG such that each process has complete information for its
local dofs. PETSc matrices are then assembled with the option
MAT_IGNORE_OFF_PROC_ENTRIES, which makes the PETSc assembly a no-op.

OpenMP threading makes the assembly loops iterate in colour order.
The correct colouring is stashed on the topology mesh between adapts.
A number of routines are not thread-safe. If you call them in
threaded code they will now abort, fix it!

3985. By Lawrence Mitchell

Fix null dereference when checking halo types

Logical evaluations aren't necessarily short-circuited when an
argument evaluates to .false., so

   if (associated(foo) .and. (foo%bar == baz))

may dereference foo even if it is unassociated. So don't do it.

3986. By Stephan Kramer

Removing three places with hard-coded values (two different ones) for the radius of the earth. This was all in dead code. Hard-coding this is not a good idea, as the mesh generator may have used another one.

Two more places remain: femtools/projection.cpp and ocean_forcing/climate_reader.cpp, these are used in determining what layer of 3D input data to use. This will be fixed (instead using the outer radius
of the original input mesh coordinates) in the rewrite of the netcdf readers.

3987. By Stephan Kramer

Fixing gmsh reader to read meshes on the sphere (i.e. meshes with topological dimension 2, and coordinate dimension 3).

Also adding a parallel spherical_patch test case that tests this reading, writing out to a checkpoint, and flredecomping to a different number of processes.

Some optimisation and cleaning up of Read_GMSH.F90:
- prevent reading of the gmsh file twice. This was because read_gmsh_simple() called identify_gmsh_file() to establish
various dimensions, which it can only do by reading the entire file. Then an appropriate shape functon was allocated
and read_gmsh_to_field was called which read the file again.
- the only version of read_gmsh_files to remain is the _simple version (as this was the only one in use). It
first reads in all the data, then establishes the necessary dimensions and then allocates the appropriate femtools
objects.
- the dimension of the read gmsh mesh is now established from the topology of the mesh, basically looking at the
highest dimension elements present, i.e. if there's tets or hexes it's 3d, otherwise 2d (1d gmsh reading is untested)
Previously this was done by looking at the z coordinate and seeing if it was small using some arbitray, hard-coded definition
of small. This is obviously not a good idea.
- the dimension of the coordinate field that is returned (X%dim) is in most cases chosen to be the same as
the topological dimension. Only with the /geometry/spherical_earth option this is always 3 so that a 2d spherical
horizontal mesh (to be extruded inside fluidity) can be read. This was broken before. The other codes that use
embedded meshes (shallow water) use a specific option that only works for triangle, so that functionality should
remain unchanged.
- remove identify_gmsh_files()
- because of this remove identify_mesh_files() from the mesh_files module
- in all subroutines of the mesh_files module make format a required argument. Before, if the argument was not present
a "guess" would be made. In some tools where no option tree is present (e.g. test_laplacian) this would always default
to "triangle". These therefore now directly call read_triangle_files. In all other cases the format should be worked
out. For output this can be a bit tricky. For checkpointing the same logic is followed as before (look at the option
under the external mesh). For adaptivity debugging meshes it now always uses gmsh.
- identify_mesh_files() was only used in populate_state, in the case of inactive process (flredecomp from less
to more processes), where inactive processed needed to know the dimensions of the mesh. This is now communicated
via a MPI_Scatter()

3988. By Jon Hill

Minor change to fldecomp makefile.in to get fldecomp to compile on HECToR. Almost got a fully working build...

3989. By Stephan Kramer

Fixing changed dependencies ('make makefiles') since my gmsh commit.

3990. By Stephan Kramer

This adds the -fno-realloc-lhs flag to FCFLAGS and FFLAGS during configure, when using a gfortran that accepts it. This is a work-around for memory leaks caused by gfortran >=4.6, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53389

3991. By Jon Hill

Adding the SVG Fluidity logo to the repository. Same license as the rest of Fluidity

3992. By Brendan Tollit

Add back two multimaterial test cases that are set up to test p1dgp2, with checks for volume fractions and velocity divergence.

These were removed because of a memory leak caused by gfortran which now has a fix in the trunk thanks to Sam and Stephan.

3993. By Jon Hill

Adding ability to run psuedo-1D columns in parallel by decmping in the vertical. Note that the user must supply the DistanceToTop and Bottom fields of they want them

3994. By Jon Hill

Removing warnings from FLML

3995. By Florian Rathgeber

Fix the with_zoltan=no configure option, which was without effect

3996. By Cian Wilson

Bug fix for intel compilers that now object to converting null pointers into objects in subroutine calls. Specifically in this case the ct_m divergence matrix.

3997. By Lawrence Mitchell

Further reduce recompilations in already built trees

include/version.h is now built with a new script bin/version-info.
Makefiles are updated to take advantage of this, and reworked such
that include/version.h is no longer a .PHONY target.

Version is determined in the following ways (in order of preference):

  - make PACKAGE_VERSION=foo
  - ./configure FLUIDITY_VERSION=foo
  - bzr version-info

Additionally, to avoid spurious rebuilds due to
Diagnostic_Fields_New.F90 changing, only overwrite it if the hash of
the existing version differs from the hash of the putative new
version.

3998. By Tim Greaves

One-line fix in build system only; the packager was giving unwanted
leading-path entries in the examples tarball, which this commit addresses.

3999. By Alexandros Avdis

Correction of errors affected by an earlier commit - Sould have been experimenting on unbound branch.

4000. By Jon Hill

Bug fix to period_averaged_scalar field diagnostic to work with adaptivity

4001. By Tim Greaves

Change in test tolerance only to relax for 32-bit Precise test platform.

4002. By Stephan Kramer

Loosing tolerance: maximum fs may occur one timestep later. Also corrected fs_right_max test.

4003. By Tim Greaves

Changes in documentation only: Updating manual to recent versions of the
supporting software documentation, drawn from the AMCG Wiki at:

 http://amcg.ese.ic.ac.uk/index.php?title=Fluidity_Supporting_Software

4004. By Samuel Parkinson

merge LES_fix branch into trunk into trunk - fixes bug #1000813

4005. By Tim Greaves

Commit purely in build system, adding a fluidity binary package dependency
on libspud-dev

4006. By Brendan Tollit

Add the capability to associate any scalar field with the perturbation density for a
fluids linear EoS to complement the Temperature and Salinity components. This is an
added generalisation of the coding and is useful for collapsed multiphase models
involving bubbles, perhaps other applications also.

The options for EoS are added to their own .rnc/g file and new options added.

The manual is slightly changed to include a description of the new functionality.

A test case is added which copies the case buoyancy_adjustment_dg_two_element and
uses a generic scalar field for the EoS rather than Temperature - gets the same
answer as expected.

4007. By Alexandros Avdis

Removed some hard coded instances of the Earth radius. The Earth geoid surface radius is now calculated from the mesh.

4008. By Simon Funke

Loosening the tolerance for the shallow_water_adjoint_default_controls_2d will hopefully make buildbot happy

4009. By Stephan Kramer

Change assert for descending node order with 1d adaptivity, to a check that is also run without debugging and add a helpful error message.

The descending node order for 1d adaptivity is a bit silly, that could easily be fixed if somebody's up for it.

4010. By Stephan Kramer

Fixing a few issues with cdisk_2d:
* the test advects a tracer under a prescribed velocity field. The velocity field however does not satisfy no-normal flow at the boundary, so boundary conditions for the tracer are needed.
* only testing for something that is also satisfied by the initial condition is never a good idea. Next to conservation, we now also test the tracer has moved by the right amount.
* adding a 'solvers converged' check pending a more general solution for this.

4011. By Lawrence Mitchell

Add checks for solver convergence to most tests

Tests that run fluidity in a meaningful manner should always test for
convergence of the solvers. This merge attempts to do that for most
short and mediumtests.

4012. By Jon Hill

Fix bug in libspud's python interface. Same fix has been applied in libspud trunk also

4013. By Lawrence Mitchell

Make petsc libs come before system libs in link line

When we discover a set of library flags in configure, we should
prepend, not append to LIBS. The linker looks at library paths in L2R
order on the command line, so the more specific the path we discover,
the closer to the front of the command line it should be.

4014. By Tim Greaves

Changes purely in tests reassigning tests from hhiester to new owners.

4015. By Gerard

bugfix: FCFLAGS was being clobbered with non-existent OLD_FCLAGS

4016. By Tim Greaves

Changes purely in example XMLs: changing length to 'long' in all tests to
  allow them to successfully run as 'longtests' in buildbot.

4017. By Tim Greaves

Small change in the makefile of this example to bring the default
 'make input' called by the testing process in line with the rest
 of the example running on 32 cores.

4018. By Tim Greaves

Change purely in build infrastructure of an example: for automated running of
  the BFS3D example, a default NPROCS=8 is supplied.

4019. By Brendan Tollit

Add the capability for robin BC for control_volume discretisation
(not coupled_cv) only if the diffusion term uses ElementGradient.

Add a simple analytic test case that need only be 1d as the added
code is independent of dimension.

Adjust comments in the schema for this.

Add small sections to the manual.

4020. By Rhodri Davies

Bug fix for cases using P2CV and limit theta. Supplied by Cian.

4021. By Jon Hill

New GLS updates which include:
 - Ocean parameterisation which parameterises internal wave breaking, adding some surface TKE into deeper water
 - Updates to assembly routines which are now mostly element-wise
 - Updates to tests
 - Manual updates

4022. By Jon Hill

Adding tests for PAR and updating manual

4023. By Rhodri Davies

Bug fix for CV, when a diffusion term is present. Again supplied by Cian.

4024. By Christian Jacobs

Merging compressible-multiphase branch revisions r3955 to r4067 (inclusive) into trunk.

Summary of changes:
===================

- Added multiphase support for the compressible projection method (currently only for CG Pressure).

- Small changes to the logic in Momentum_Equation.F90. Replaced the use_compressible_projection logical with compressible_eos which is .true. if option_count("/material_phase/equation_of_state/compressible") > 0, and .false. otherwise.

- Added multiphase support for the InternalEnergy equation. Note that the whole state array is now passed to solve_field_equation_cg.

- Implemented the heat transfer term by Gunn (1978).

- Added three P2-P1 multiphase MMS tests for model verification: one without InternalEnergy fields, one with InternalEnergy fields, and one with InternalEnergy fields and heat transfer. The tests will become longtests after merging into the trunk.

- The manual now has documentation on the compressible multiphase model, including the multiphase version of the InternalEnergy equation.

- Added a diagnostic field called CompressibleContinuityResidual which computes the residual of the compressible multiphase continuity equation. This is similar to the SumVelocityDivergence field for incompressible multiphase flow which computes \sum{div(vfrac*u)}.

- Added two gas-solid shock tube tests to help to validate the model: mphase_rogue_shock_tube_dense_bed_glass and mphase_rogue_shock_tube_dense_bed_nylon.

- Added another gas-solid shock tube test (mphase_dusty_gas_shock_tube) which uses the setup by Miura & Glass (1982).

- Implemented two new correlations for fluid-particle drag. The one by Wen & Yu (1966) can support higher Reynolds numbers (compared to the existing Stokes' law correlation). The one by Ergun (1952) can support dense flows where the volume fraction of the particle phase is greater than 0.2, like in the dense bed shock tube tests (and in the pyroclastic flow tests which will hopefully come later).

- Changed the structure of the schema. Users now explicitly select which interaction terms they wish to include, as well as the drag correlation, under "/multiphase_interaction" in Diamond. These options are stored in the new files multiphase_interaction.rnc and multiphase_interaction.rng.

- Added a test for the Wen & Yu (1966) drag correlation. This is similar to mphase_stokes_law.

- Added a test to check if inlet velocity boundary conditions work with the incompressible multiphase flow model.

- Added a test for the flux boundary condition.

4025. By Christian Jacobs

Moved the compressible multiphase MMS tests to the longtests directory.

4026. By Christian Jacobs

- Updated the tephra_settling example's .flml file to use the new multiphase_interaction schema structure.
- Corrected a small typo in the manual.

4027. By Lawrence Mitchell

Fix DG momentum assembly corner case

Since r3984 we would assemble elements in DG momentum if
element_neighbour_owned returned true. However, for some corner cases
element_neighbour_owned need not return true if the element is owned
(consider the case of a process with one owned element). In this
situation we would not correctly assemble all elements. To fix this,
change the test for element assembly to directly check for element
ownership.

At the same time, update the documentation for element_neighbour_owned
to note this issue.

4028. By Rhodri Davies

Merge relax_halo_verifies branch into trunk. Thanks to dham for review.

4029. By j-bull08 <email address hidden>

Removing duplicate file in 3D BFS example.

4030. By Lawrence Mitchell

Fix CG momentum assembly on intel fortran

This only affects the have_les and .not. dynamic_les code path.

4031. By Rhodri Davies

Merge zoltan configure check for .mod files into trunk. Thanks to steph for help and jon for review.

4032. By Christian Jacobs

Added solvers_converged pass_tests to all multiphase tests.

4033. By Christian Jacobs

Added a solvers_converged pass_test to the tephra_settling example.

4034. By Samuel Parkinson

Updated Momentum_CG.F90 so that upwind stabilisation can be used with partial or full stress form. The issue is that when using partial or full stress form we tend to set all components of viscosity to the same value. This makes the tensor determinant zero and we cannot invert it. This fix simply sets all non-diagonal terms to zero for the purpose of handling stabilisation when using partial or full stress forms. This isn't ideal as it ignores the fact that we may have non-isotropic viscosities, but these aren't handled properly for these stress forms anyway - so this is a bigger issue that may need fixing later.

The same issue arises when we try to calculate the GridReynoldsNumber diagnostic field and the same fix has been applied here.

4035. By Samuel Parkinson

bug fix of SUPG stabilisation in Momentum_CG.F90

4036. By Tim Greaves

One-line fix, setting the correct flml filename in the test xml.

4037. By Adam Candy

Removal of a runtime-generated test file.
jhill - please check!

4038. By Samuel Parkinson

Added options for how the bed shear stress is calculated. Yuo can now either:
- use drag formulation as before
- calculate the shear stress based upon the gradient of the velocity field at the bed
- use the shear stress estimate generated by the wall boundary layer boundary condition algorithm

4039. By Samuel Parkinson

change to lock_exchange example so that, when run as a test, it runs to 30 seconds so that the tests are checked properly

4040. By Christian Jacobs

Merging compressible-multiphase branch revisions r4068 to r4077 (inclusive) into trunk.

Summary of changes:
===================

- Added multiphase support for stress_form, partial_stress_form and isotropic diagonal_viscosity in Momentum_CG.F90. The stress_form will be important in compressible multiphase flow simulations.

- Added an MMS test (mphase_mms_p2p1_stress_form) for the stress_form changes.

4041. By Christian Jacobs

Small edit to the manual to generalise the form of the multiphase stress term.

4042. By Xiaohu Guo

  1. thread matrix assembly part for Advection_Diffusion_DG.F90
  2. MASSLUMPED_RT0 diffusion scheme is not supported, simply set threads back to 1 if MASSLUMPED_RT0 diffusion scheme is being used, and there will be a warning message.
  3. thread matrix assembly part for Advection_Diffusion_FV.F90

4043. By Christian Jacobs

Merging k_epsilon_extend_and_fix branch into trunk.

Changes to k-epsilon model:
===========================
- The code no longer lumps the mass matrix when calculating source terms for the k and epsilon fields, allowing element pairs other than P1-P1 to be used.
- k-epsilon field calculation moved to the beginning of the time-step and calculated with all other diagnostic fields.
- Added source term to momentum equation (-2/3 grad(rho*k)).
- Updated the manual documentation for the k-epsilon model.
- Users must now use partial-stress or full-stress form for the stress term in the momentum equation. This is the correct formulation when using spatially
varying viscosities. The ScalarEddyViscosity from the model is added to all components of the stress tensor to reflect this.
- Fixed calculation of c_eps_3.
- Added lots of debugging options.
- Improved the options_check subroutine.
- Changed how prescribed source terms are implemented for the k and epsilon fields so that multiple non-linear iterations can be carried out
with prescribed source terms.
- Altered calculation of Reynolds Stresses.
- Added a new equation_type (KEpsilon) for the k-epsilon equation. This includes the density in the advection-diffusion equation for the k and epsilon fields. Also made many other changes to the code to take account of density variations. Supports CG and CV discretisations.
- Made a few preliminary steps for adding multiphase support to the k-epsilon model.
- k and epsilon fields are now clipped at Gauss points rather than nodes.
- Moved element assembly to its own subroutine to avoid dynamic memory assignment.
- Changed k and epsilon diffusivity tensor to (nu + nu_t/sigma_*) instead of (nu_t/sigma_*)
- The turbulent buoyancy term is now calculated from the VelocityBuoyancyDensity rather than a summation of scalar fields that have been identified as
being buoyant. This means that any buoyant field will automatically result in a buoyancy term in the k-epsilon model (unless the entire term
is disabled in debugging_options)
- Removed several unused variables.
- Added the buoyancy term to the k-epsilon model.
- Added damping functions for the low_Re k-epsilon model.
- Changed epsilon low_Re boundary condition to d(eps)/dx = 0 as it's simpler than what we had before and still valid (Wilcox 1998).
- Fixes to high-Re boundary conditions.
- Removed length scale limiting.

Changes to tests and examples:
==============================
- The existing k-epsilon MMS test (k-epsilon_mms_cg_p1p1) has been removed and replaced with one that uses a P2-P1 discretisation and runs to steady state.
- Three additional tests have been added for the low_Re boundary condition, and the LinearMomentum Velocity equation_type with CG and CV discretisations.
- Tests include the turbulent buoyancy term and scalar field turbulent diffusion.
- A unit test has been added for the tensor_inner_product function.
- Fixed the backward facing step 2D example based on the changes to the k-epsilon model.

4044. By Christian Jacobs

Moved tests/mms_rans_p2p1_keps_linearmomentum and tests/mms_rans_p2p1_keps_linearmomentum_cv to the longtests directory.

4045. By Christian Jacobs

Buildbot's makefiles-x86_64 queue has been failing since r4042. These updates from make makefiles will hopefully fix this.

4046. By Adam Candy

Wetting and Drying bug fix - the material phase had an assumed name of 'water'.
(It is now just assumed to be the first material phase)

4047. By Christian Jacobs

Bug fix following the merge of k_epsilon_extend_and_fix. k-epsilon boundary conditions are now applied to all states that have k-epsilon enabled, not just to state(1).

4048. By Tim Greaves

As discussed in today's Fluidity developer meeting, changing this example to
default to using 64 cores to reduce runtimes for automated testing.

4049. By Rhodri Davies

Merge python_state_csr_matrices branch into trunk. Thanks to Stephan and Cian for help and to Patrick for review.

4050. By Florian Rathgeber

Purge empty directories from the repository and create them as needed.

There are a few empty directories in the repository, which bzr tracks,
other DVCs do not (git, hg). Instead of relying on those directories
being present, these are created by the respective Makefiles.

4051. By Adam Candy

Bug fix for the buoyancy adjustment by vertical mixing scheme.
The Galerkin projection to a continuous space is now honoured.

4052. By Adam Candy

Compatibility fix for a newer Gmsh version - for the buoyancy adjustment test cases.

4053. By Adam Candy

Tagging of the buoyancy adjustment test cases.

4054. By Samuel Parkinson

- added new reentrainment boundary condition based on Garcia's paper from 1991 which is the most generally used relationship.
- added hindered settling and sediment concentration dependent viscosity.
- changed how sediment fields are initialised so that they fit more generally with how other fields work in Fluidity.
- manual updates.
- new mms test for all sediment related code.

4055. By Rhodri Davies

Merge field weighted partition branch into trunk. As usual, thanks to Stephan for help and advice. Thanks to Jon for review.

4056. By Alexandros Avdis

Merge-in of DG_Neumann branch.

4057. By Tim Greaves

A commit which should be entirely limited to the build system within the tests
hierarchy and the 'clean' subsystem, attempting to catch up with housekeeping
and ensuring that 'make distclean' from the fluidity base directory reverts any
changes made by the build and testing process.

Major changes here relate to adding/correcting 'make clean' entries, and moving
some tests from copying/changing committed .bml/.oml/.swml files to copying
templates and then modifying the copies.

4058. By Mark Goffin <email address hidden>

This commit fixes local edge numbering for quad elements.

4059. By Tim Greaves

Having added in a clean-up line for the generated 'version-info' file, it
appears that tools/Makefile requires version-info to exist for the
install-version-info target, but doesn't know how to make it itself.

For the moment, I've backed out the cleaning line and will leave this for a
more comprehensive fix.

4060. By Tim Greaves

Thanks to Lawrence for spotting this; my error in r4057 was removing
tools/version-info with 'make clean' whereas it should only be removed
with 'make distclean'. This commit fixes that, adding a 'distclean' target
to the tools makefile to handle removal of version-info.

4061. By Adam Candy

Introduces a diagnostic for the buoyancy adjustment by vertical mixing scheme.
Logging for the scheme has been tightened up and generally improved.

4062. By Mark Goffin <email address hidden>

This should fix the tests hh_bdfm1 and hybridized_helmholtz that broke after revision 4058.

4063. By Mark Goffin <email address hidden>

A minor fix for degree zero quad elements to fix the test - Stokes_mms_q1p0.

4064. By Samuel Parkinson

Hopefully these updates will mean that the make makfiles test passes

4065. By Adam Candy

New option in gmsh2triangle to interpret a 3d input mesh as a 2d mesh on a spherical shell.
This avoids having to apply sed to the node file.

An improvement would be to have Fluidity detect this independent of the dimension in the node file.
(as it does with the binary gmsh format?)

4066. By Adam Candy

Restrict which pylab functions are loaded in the the radial scale tool.

4067. By Adam Candy

radial scale tool - no need for pylab dependencies, available in math.

4068. By Simon Mouradian

Updates to the manual for changes to gmsh2triangle

4069. By Adam Candy

Bug fix to buoyancy adjustment diagnostic.

4070. By Adam Candy

Additional documentation and optimisation for the buoyancy adjustment diffusion diagnostic.

4071. By Adam Candy

Optimisation in the previous commit requires this set operation.

4072. By Simon Mouradian

Fix for rotating channel example

4073. By Simon Mouradian

If dev version of libadjoint is installed, the configure script is now smart enough to realise and fluidity is built without adjoint support.

4074. By Matthew Piggott

Update the adaptive driven cavity test flml so it is (more) consistent with the fixed mesh driven cavity example.

4075. By Rhodri Davies

Stokes example and place holder in manual.

4076. By Samuel Parkinson

Tidied up time discretisation of the k-epsilon model and some other bits. See the manual edits for details on this. The main changes to the code are:

- Calculation of keps diagnostic now done twice during each non-linear iteration. First before advection diffusion of scalar fields, then again before the momentum solve. This makes it possible to have a consistent time-discretisation across the equations.
- Non-linear velocities are used in diagnostics and k and epsilon values are averaged between the most recent value and the value at the end of the last time step using a user defined theta value
- changes to how the isotropic Reynolds stresses are calculated. They are now absorbed in to the modified pressure.
- rewritten low-reynolds model which was wrong before

4077. By Matthew Piggott

Example failing with a GMYBAD error. Fiddle with adaptivity and zoltan options based on the TEST version of this flml file.

4078. By Matthew Piggott

Update the title of the streamfunction diagnostic in the pass chacks.

4079. By Rhodri Davies

Merge in changes to scaled pressure mass matrix assembly.

4080. By Christian Jacobs

Small bug fix. Removed the requirement to have a VelocitySource field when using the k-epsilon model. The field was previously needed to add in -(2/3)*rho*k, but this is now part of the pressure term.

4081. By Rhodri Davies

Merge Full Projection fix into trunk. Thanks to Stephan for review.

4082. By Michael Lange

Adding PETSs 3.3 support and dropping support for 3.0.

4083. By Rhodri Davies

XML for stokes example. Should be good to go.

4084. By Matthew Piggott

Fix my diamond validation error.

4085. By Rhodri Davies

Commit mesh files for debugging purposes only.

4086. By Rhodri Davies

Change mesh format to triangle. This should fix test.

4087. By Christian Jacobs

The use of pylab.grid("True") in plot_data.py causes errors when a user tries to "make postprocess". Changing this to pylab.grid('on') seems to fix the problem. Thanks to Liping for reporting this problem.

4088. By Matthew Piggott

Weaken warn tolerances a little.

4089. By Matthew Piggott

Weaken one, but strengthen the other pass test tolerances on this - most quantities comfortably converging at second order but going from 64 squared to 128 squared the erturk_v error convergence rate is only 1.4

4090. By Lawrence Mitchell

Add --from-file option to testharness

`testharness --from-file=foo' tells testharness to read the list of
tests to run from `foo' (one per line). Useful for debugging failures
in a small number of related tests.

Unmerged revisions

4090. By Lawrence Mitchell

Add --from-file option to testharness

`testharness --from-file=foo' tells testharness to read the list of
tests to run from `foo' (one per line). Useful for debugging failures
in a small number of related tests.

4089. By Matthew Piggott

Weaken one, but strengthen the other pass test tolerances on this - most quantities comfortably converging at second order but going from 64 squared to 128 squared the erturk_v error convergence rate is only 1.4

4088. By Matthew Piggott

Weaken warn tolerances a little.

4087. By Christian Jacobs

The use of pylab.grid("True") in plot_data.py causes errors when a user tries to "make postprocess". Changing this to pylab.grid('on') seems to fix the problem. Thanks to Liping for reporting this problem.

4086. By Rhodri Davies

Change mesh format to triangle. This should fix test.

4085. By Rhodri Davies

Commit mesh files for debugging purposes only.

4084. By Matthew Piggott

Fix my diamond validation error.

4083. By Rhodri Davies

XML for stokes example. Should be good to go.

4082. By Michael Lange

Adding PETSs 3.3 support and dropping support for 3.0.

4081. By Rhodri Davies

Merge Full Projection fix into trunk. Thanks to Stephan for review.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2011-04-15 16:18:30 +0000
3+++ .bzrignore 2012-10-16 13:22:44 +0000
4@@ -2,3 +2,4 @@
5 backward_facing_step_2d-high.flml
6 examples/backward_facing_step_2d/coarse
7 coarse
8+matrixdump
9
10=== modified file 'AUTHORS'
11--- AUTHORS 2011-10-21 17:23:47 +0000
12+++ AUTHORS 2012-10-16 13:22:44 +0000
13@@ -6,6 +6,7 @@
14 ------------
15
16 Imperial College London
17+University of Edinburgh
18 University of Oxford
19 University of Reading
20 National Oceanography Centre Southampton
21@@ -48,6 +49,7 @@
22 Frank Milthaler
23 Julian Mindel
24 Andrew Mitchell
25+Lawrence Mitchell <lawrence.mitchell@ed.ac.uk>
26 Rhodri Nelson
27 Dimitrios Pavlidis
28 Ralph Perpeet
29@@ -60,6 +62,7 @@
30 Brendan Tollit
31 Axelle Vire <a.vire@imperial.ac.uk>
32 Hongbin Wang
33+Michele Weiland <m.weiland@epcc.ed.ac.uk>
34 Martin Wells
35 Matthew Whitworth
36 Cian Wilson
37
38=== modified file 'Makefile.in'
39--- Makefile.in 2011-10-26 13:12:13 +0000
40+++ Makefile.in 2012-10-16 13:22:44 +0000
41@@ -27,7 +27,6 @@
42 SHELL = @SHELL@
43
44 PACKAGE_NAME = @PACKAGE_NAME@
45-PACKAGE_VERSION = @PACKAGE_VERSION@
46
47 FLUIDITY = $(PACKAGE_NAME)
48
49@@ -63,9 +62,11 @@
50
51 LINKER = @LINKER@ @LDFLAGS@
52
53-LIBS = -L./lib -l$(FLUIDITY) @BLAS_LIBS@ @LIB_FEMDEM@ ./lib/libadaptivity.a \
54+FLLINKER = @FLLINKER@ @LDFLAGS@ $(FCFLAGS)
55+
56+LIBS = -L./lib -l$(FLUIDITY) @LIB_FEMDEM@ ./lib/libadaptivity.a \
57 ./lib/libvtkfortran.a ./lib/libspatialindex.a ./lib/libspud.a ./lib/libjudy.a \
58- @LIBS@
59+ @LIBS@ @BLAS_LIBS@
60
61 OBJS = $(shell find . -mindepth 2 -maxdepth 2 -name '*.c' -o -name '*.cpp' -o -name '*.[fF]' -o -name '*.F90' | grep -v ^./lib | xargs)
62 MAKE = @MAKE@ -s
63@@ -76,8 +77,6 @@
64
65 EVAL = tools/silenteval.sh
66
67-VERSION = $(shell bzr revision-info)
68-
69 ifeq (@MBA2D@,yes)
70 LIBMBA2D = lib/libmba2d.a
71 endif
72@@ -94,10 +93,18 @@
73 EXCLUDE_TAGS =
74 ifneq (@ZOLTAN@,yes)
75 EXCLUDE_TAGS := $(EXCLUDE_TAGS) -e zoltan
76+else
77+ EXCLUDE_TAGS := $(EXCLUDE_TAGS) -e nozoltan
78 endif
79 ifneq (@HAVE_ADJOINT@,yes)
80 EXCLUDE_TAGS := $(EXCLUDE_TAGS) -e adjoint
81 endif
82+ifneq (@ALGENCAN@,yes)
83+ EXCLUDE_TAGS := $(EXCLUDE_TAGS) -e algencan
84+endif
85+ifneq (@MBA2D@,yes)
86+ EXCLUDE_TAGS := $(EXCLUDE_TAGS) -e 2dadapt
87+endif
88
89 .SUFFIXES: .f90 .F90 .c .cpp .o .a
90
91@@ -110,7 +117,7 @@
92 sub_system: $(LIBMBA2D) $(LIBMBA3D) $(LIBALGENCAN) @LIB_FEMDEM@ \
93 lib/libadaptivity.a lib/libvtkfortran.a lib/libspatialindex.a \
94 lib/libspud.a lib/libjudy.a include/version.h
95-
96+
97 lib/libjudy.a:
98 @echo ' MKDIR lib'; mkdir -p lib
99 @cd libjudy; echo ' MAKE libjudy'; $(MAKE) > make.log ; $(MAKE) install >> make.log ; cd ..
100@@ -144,7 +151,7 @@
101 ifeq (@SPUD_ONLY@,yes)
102 @cd libspud; echo ' MAKE libspud'; $(MAKE) ; $(MAKE) install-libspud
103 else
104- @cd libspud; echo ' MAKE libspud'; $(MAKE) ; $(MAKE) install; cd ..; cp lib*/python*/site-packages/libspud.so python/
105+ @cd libspud; echo ' MAKE libspud'; $(MAKE) ; $(MAKE) install-libspud; cd python; python setup.py build; cd ../..; cp libspud/python/build/lib*/libspud.so python/
106 endif
107
108 libfemtools: sub_system
109@@ -160,19 +167,17 @@
110 @cd @FLFEMDEM_PATH@;$(MAKE)
111 endif
112
113-include/libspud.h: lib/libspud.a
114-
115-main.o: include/version.h include/libspud.h
116-
117-include/version.h:
118- @echo "DEFINE __FLUIDITY_VERSION__"
119- @grep "$(VERSION)" include/version.h >/dev/null 2>&1 || \
120- printf "#ifndef _FLUIDITY_VERSION_H\n\
121- #define _FLUIDITY_VERSION_H\n\
122- #define __FLUIDITY_VERSION__ \"$(VERSION)\"\n\
123- #endif /* _FLUIDITY_VERSION_H */\n" > include/version.h
124-
125-.PHONY: include/version.h
126+include/spud.h: lib/libspud.a
127+
128+main.o: include/version.h include/spud.h
129+
130+include/version.h: version-info
131+ @bin/version-info $@
132+
133+version-info:
134+ @$(MAKE) -C tools install-version-info
135+
136+.PHONY: version-info
137
138 bin/$(FLUIDITY): main.o lib/lib$(FLUIDITY).a
139 @echo "BUILD fluidity"
140@@ -191,8 +196,8 @@
141 @echo " MKDIR bin"
142 @mkdir -p bin
143 @echo " LD shallow_water"
144- @$(EVAL) $(LINKER) -o bin/hybridized_helmholtz_solver main/Hybridized_Helmholtz_Solver.o $(LIBS)
145- @$(EVAL) $(LINKER) -o bin/shallow_water main/Shallow_Water.o $(LIBS)
146+ @$(EVAL) $(FLLINKER) -o bin/hybridized_helmholtz_solver main/Hybridized_Helmholtz_Solver.o $(LIBS)
147+ @$(EVAL) $(FLLINKER) -o bin/shallow_water main/Shallow_Water.o $(LIBS)
148
149 bin/hybridized_helmholtz_solver: fluidity_library main/Hybridized_Helmholtz_Solver.F90
150 @cd main; $(MAKE) Hybridized_Helmholtz_Solver.o
151@@ -200,7 +205,7 @@
152 @echo " MKDIR bin"
153 @mkdir -p bin
154 @echo " LD hybridized_helmholtz_solver"
155- @$(EVAL) $(LINKER) -o bin/hybridized_helmholtz_solver main/Hybridized_Helmholtz_Solver.o $(LIBS)
156+ @$(EVAL) $(FLLINKER) -o bin/hybridized_helmholtz_solver main/Hybridized_Helmholtz_Solver.o $(LIBS)
157
158 bin/burgers_equation: fluidity_library main/Burgers_Equation.F90
159 @cd main; $(MAKE) Burgers_Equation.o
160@@ -396,6 +401,9 @@
161 @cd horizontal_adaptivity/tests; $(MAKE) clean
162 @echo " CLEAN tools"
163 @cd tools; $(MAKE) clean
164+ @echo " CLEAN adjoint"
165+ @cd adjoint; $(MAKE) clean
166+ @cd adjoint/tests; $(MAKE) clean
167 @echo " CLEAN bathymetry"
168 @cd bathymetry; $(MAKE) clean
169 @echo " CLEAN ocean_forcing"
170@@ -415,9 +423,9 @@
171 @cd adjoint; $(MAKE) clean
172 @echo " CLEAN main"
173 @cd main; $(MAKE) clean
174- @rm -fr bin/* lib
175+ @rm -fr bin lib
176
177-clean: clean-light clean-test python_clean
178+clean: clean-light clean-test python_clean clean-debian
179 @echo " CLEAN libvtkfortran"
180 @cd libvtkfortran; $(MAKE) clean
181 @echo " CLEAN libjudy"
182@@ -434,17 +442,24 @@
183 @cd libalgencan; $(MAKE) clean
184 @echo " CLEAN libwm"
185 @cd libwm; $(MAKE) clean
186+ @echo " CLEAN manual"
187+ @cd manual; $(MAKE) clean
188 @CLEAN_LIBADAPT@
189- @rm -fr include/*.mod *.cache core *.o config.status
190+ @rm -fr lib*/configure.lineno include/*.mod *.cache core *.o config.status
191 @find ./ \( -name work.pc \) -exec rm {} \;
192 @find ./ \( -name work.pcl \) -exec rm {} \;
193
194+clean-debian:
195+ @echo " CLEAN debian"
196+ @cd debian; rm -rf files tmp fluidity python-fluidity *.substvars *.debhelper*
197+
198 clean-test:
199 @echo " CLEAN tests"
200- @cd tests; ../tools/testharness.py --clean >/dev/null
201+ @cd tests; PYTHONPATH=../python ../tools/testharness.py --clean >/dev/null
202+ @cd tests/data; $(MAKE) clean
203
204 distclean: clean
205- @echo " DISTCLEAN"
206+ @echo " DISTCLEAN"
207 @cd spatialindex-1.5 ; make distclean > /dev/null ; rm -rf \
208 make.log regressiontest/mvrtree/.deps \
209 regressiontest/rtree/.deps regressiontest/tprtree/.deps > \
210@@ -454,6 +469,7 @@
211 @cd libvtkfortran ; make distclean > /dev/null
212 @cd libspud ; make distclean > /dev/null ; rm -rf \
213 libspud.so.0 libtool diamond/build python/build > /dev/null
214+ @cd tools ; make distclean > /dev/null
215 @rm -fr `find ./ -name config.status` `find ./ -name \
216 config.log` share include/Judy.h include/Wm4Command.h \
217 include/Wm4FoundationLIB.h include/Wm4FoundationPCH.h \
218@@ -474,7 +490,7 @@
219 include/spatialindex include/spud include/spud.h \
220 include/spud_enums.h include/tinystr.h include/tinyxml.h \
221 include/version.h include/vtk.h \
222- preprocessor/check_options.F90 \
223+ preprocessor/check_options.F90 schemas/flml \
224 preprocessor/register_diagnostics.F90 python/setup.py > \
225 /dev/null
226 @for i in `find ./*/ -name Makefile.in`; do rm -f `echo $$i | sed 's/.in$$//'`; done > /dev/null
227@@ -483,30 +499,17 @@
228
229 test: fltools bin/$(FLUIDITY) bin/shallow_water serialtest bin/burgers_equation
230
231-serialtest:
232-ifeq (@MBA2D@,yes)
233- ifeq (@ZOLTAN@,yes)
234- @cd tests; ../bin/testharness -l short -p serial -e nozoltan -n $(THREADS)
235- else
236- @cd tests; ../bin/testharness -l short -p serial -e zoltan -n $(THREADS)
237- endif
238-else
239- ifeq (@ZOLTAN@,yes)
240- @cd tests; ../bin/testharness -l short -p serial -e "2dadapt nozoltan" -n $(THREADS)
241- else
242- @cd tests; ../bin/testharness -l short -p serial -e "2dadapt zoltan" -n $(THREADS)
243- endif
244-endif
245+serialtest: fltools bin/$(FLUIDITY) bin/shallow_water
246+ @cd tests; ../bin/testharness -l short -p serial $(EXCLUDE_TAGS) -n $(THREADS)
247
248-mediumtest: bin/burgers_equation
249+mediumtest: fltools bin/$(FLUIDITY) manual bin/burgers_equation bin/shallow_water spudtools
250 @cd tests; ../bin/testharness -l medium $(EXCLUDE_TAGS) -n $(THREADS)
251
252-mediumzoltantest:
253-ifeq (@ZOLTAN@,yes)
254- @cd tests; ../bin/testharness -l medium -t zoltan -n $(THREADS)
255-else
256- @echo "Warning: build did not have zoltan enabled, make mediumzoltantest will not run" -n $(THREADS)
257-endif
258+.PHONY: spudtools
259+
260+spudtools:
261+ @cd libspud ; $(MAKE) install-spudtools
262+ @echo " INSTALL spudtools"
263
264 setuputs:
265 @echo "SETUP tests"
266@@ -516,7 +519,6 @@
267 @mkdir -p bin/tests
268 @ln -sf ../../tests/data bin/tests/data
269
270-
271 build_unittest: fluidity_library libfemtools setuputs
272 @echo " UNITTEST libspud"
273 @cd libspud/src/tests; $(MAKE) test-binaries; find bin/* -maxdepth 1 -type f -exec ln -sf ../../libspud/src/tests/{} ../../../bin/tests \;
274@@ -540,7 +542,11 @@
275 @echo "RUN bin/tests"
276 @bin/unittestharness bin/tests
277
278-schema:
279+bin/spud-preprocess:
280+ @echo "Installing spudtools"
281+ @$(MAKE) -C libspud install-spudtools
282+
283+schema: bin/spud-preprocess
284 @echo "Rebuilding schema fluidity_options.rng"
285 @./bin/spud-preprocess schemas/fluidity_options.rnc
286
287@@ -600,7 +606,31 @@
288 $(MAKE) clean-light
289 @echo " Congratulations, make makefiles succeeded!"
290
291-install:
292- @mkdir -p $(DESTDIR)$(bindir)
293- cp bin/* $(DESTDIR)$(bindir)
294- cd python ; python setup.py install --root="${DESTDIR}" --prefix="$(prefix)"
295+install: default fltools bin/shallow_water bin/burgers_equation
296+ @mkdir -p $(DESTDIR)$(bindir) $(DESTDIR)$(docdir)/fluidity
297+ find bin/ -maxdepth 1 -type f -exec cp '{}' $(DESTDIR)$(bindir) \;
298+ rm -f $(DESTDIR)$(bindir)/spud-* $(DESTDIR)$(bindir)/diamond $(DESTDIR)$(bindir)/silenteval $(DESTDIR)$(bindir)/runut
299+ [ -f manual/fluidity_manual.pdf ] && cp manual/fluidity_manual.pdf $(DESTDIR)$(docdir)/fluidity || true
300+ mkdir -p $(DESTDIR)$(datadir)/fluidity
301+ cp -r schemas/ $(DESTDIR)$(datadir)/fluidity/
302+ mkdir -p $(DESTDIR)$(datadir)/diamond/schemata
303+ cp schemas/flml $(DESTDIR)$(datadir)/diamond/schemata
304+ cd python ; python setup.py install --root=$(shell echo ${DESTDIR} | sed 's/^$$/\//') --prefix="$(prefix)" $$FLUIDITY_PYTHON_INSTALL_ARGS
305+ cp -r examples/ $(DESTDIR)$(docdir)/fluidity
306+ find $(DESTDIR)$(docdir)/fluidity/examples -type f -exec sed -i "s/\.\.\/\.\.\/\.\.\/bin\///" '{}' \;
307+ find $(DESTDIR)$(docdir)/fluidity/examples -type f -exec sed -i "s/\.\.\/\.\.\/bin\///" '{}' \;
308+ cd $(DESTDIR)$(docdir)/fluidity ; tar -czvf $(DESTDIR)$(docdir)/fluidity/examples.tar.gz examples/
309+ rm -rf $(DESTDIR)$(docdir)/fluidity/examples/
310+
311+install-diamond:
312+ cd libspud; ./configure --prefix=$(DESTDIR)@prefix@; cd ../..
313+ cd libspud; $(MAKE) clean; cd ../..
314+ cd libspud; $(MAKE) install-diamond; cd ../..
315+ cd libspud; $(MAKE) install-dxdiff; cd ../..
316+ cd libspud; $(MAKE) install-spudtools; cd ../..
317+ cd libspud; ./configure --prefix=$(PWD); cd ../..
318+
319+install-user-schemata:
320+ mkdir -p $(HOME)/.diamond/schemata/
321+ echo "Fluidity Markup Language" > $(HOME)/.diamond/schemata/flml
322+ echo "$(PWD)/schemas/fluidity_options.rng" >> $(HOME)/.diamond/schemata/flml
323
324=== modified file 'aclocal.m4'
325--- aclocal.m4 2011-10-03 17:24:46 +0000
326+++ aclocal.m4 2012-10-16 13:22:44 +0000
327@@ -319,9 +319,6 @@
328 acx_lapack_ok=noblas
329 fi
330
331-# add BLAS to libs
332-LIBS="$BLAS_LIBS $LIBS"
333-
334 # Are we linking from C?
335 case "$ac_ext" in
336 f*|F*) dsyev="dsyev" ;;
337@@ -415,10 +412,8 @@
338 AC_MSG_ERROR( [You need to set PETSC_DIR to point at your PETSc installation... exiting] )
339 fi
340
341-
342-
343 PETSC_LINK_LIBS=`make -s -f petsc_makefile getlinklibs`
344-LIBS="$LIBS $PETSC_LINK_LIBS"
345+LIBS="$PETSC_LINK_LIBS $LIBS"
346
347 PETSC_INCLUDE_FLAGS=`make -s -f petsc_makefile getincludedirs`
348 CPPFLAGS="$CPPFLAGS $PETSC_INCLUDE_FLAGS"
349@@ -470,37 +465,26 @@
350 # petsc tutorial - using the headers in the same way as we do in the code
351 AC_LINK_IFELSE(
352 [AC_LANG_SOURCE([
353-program test
354+program test_petsc
355 #include "petscversion.h"
356 #ifdef HAVE_PETSC_MODULES
357 use petsc
358-#if PETSC_VERSION_MINOR==0
359- use petscvec
360- use petscmat
361- use petscksp
362- use petscpc
363-#endif
364 #endif
365 implicit none
366 #ifdef HAVE_PETSC_MODULES
367-#include "finclude/petscvecdef.h"
368-#include "finclude/petscmatdef.h"
369-#include "finclude/petsckspdef.h"
370-#include "finclude/petscpcdef.h"
371+#include "finclude/petscdef.h"
372 #else
373 #include "finclude/petsc.h"
374-#if PETSC_VERSION_MINOR==0
375-#include "finclude/petscvec.h"
376-#include "finclude/petscmat.h"
377-#include "finclude/petscksp.h"
378-#include "finclude/petscpc.h"
379-#endif
380 #endif
381 double precision norm
382 PetscInt i,j,II,JJ,m,n,its
383 PetscInt Istart,Iend,ione
384 PetscErrorCode ierr
385+#if PETSC_VERSION_MINOR>=2
386+ PetscBool flg
387+#else
388 PetscTruth flg
389+#endif
390 PetscScalar v,one,neg_one
391 Vec x,b,u
392 Mat A
393@@ -573,25 +557,26 @@
394 call MatDestroy(A,ierr)
395
396 call PetscFinalize(ierr)
397-end program test
398+end program test_petsc
399 ])],
400 [
401 AC_MSG_NOTICE([PETSc program succesfully compiled and linked.])
402 ],
403 [
404-cp conftest.F90 test.F90
405+cp conftest.F90 test_petsc.F90
406 AC_MSG_FAILURE([Failed to compile and link PETSc program.])])
407
408 AC_LANG_RESTORE
409
410 # finally check we have the right petsc version
411 AC_COMPUTE_INT(PETSC_VERSION_MAJOR, "PETSC_VERSION_MAJOR", [#include "petscversion.h"],
412- [AC_MSG_ERROR([Unknown petsc version])])
413-if test "x$PETSC_VERSION_MAJOR" == "x3" ; then
414- AC_MSG_NOTICE([Detected PETSc version 3])
415-else
416- AC_MSG_NOTICE([Detected PETSc version "$PETSC_VERSION_MAJOR"])
417- AC_MSG_ERROR([Fluidity needs PETSc version 3])
418+ [AC_MSG_ERROR([Unknown petsc major version])])
419+AC_COMPUTE_INT(PETSC_VERSION_MINOR, "PETSC_VERSION_MINOR", [#include "petscversion.h"],
420+ [AC_MSG_ERROR([Unknown petsc minor version])])
421+AC_MSG_NOTICE([Detected PETSc version "$PETSC_VERSION_MAJOR"."$PETSC_VERSION_MINOR"])
422+# if major<3 or minor<1
423+if test "0$PETSC_VERSION_MAJOR" -lt 3 -o "0$PETSC_VERSION_MINOR" -lt 1; then
424+ AC_MSG_ERROR([Fluidity needs PETSc version >=3.1])
425 fi
426
427 AC_DEFINE(HAVE_PETSC,1,[Define if you have the PETSc library.])
428@@ -617,7 +602,7 @@
429 tmpCPPFLAGS=$CPPFLAGS
430 AC_LANG_SAVE
431 AC_LANG_C
432-LIBS="$tmpLIBS -L$ParMetis_LIBS_PATH -lparmetis -lmetis -lm"
433+LIBS="$tmpLIBS -L$ParMetis_LIBS_PATH -lparmetis -lmetis -lm $ZOLTAN_DEPS"
434 AC_CHECK_LIB(
435 [parmetis],
436 [ParMETIS_V3_AdaptiveRepart],
437@@ -1005,7 +990,6 @@
438 echo "note: using $zoltan_INCLUDES_PATH/zoltan.mod"
439 fi
440
441-
442 AC_LANG_SAVE
443 AC_LANG_C
444 AC_CHECK_LIB(
445@@ -1013,7 +997,28 @@
446 [Zoltan_Initialize],
447 [AC_DEFINE(HAVE_ZOLTAN,1,[Define if you have zoltan library.])],
448 [AC_MSG_ERROR( [Could not link in the zoltan library... exiting] )] )
449-# Save variables...
450+
451+# Small test for zoltan .mod files:
452+AC_LANG(Fortran)
453+ac_ext=F90
454+# In fluidity's makefile we explicitly add CPPFLAGS, temporarily add it to
455+# FCFLAGS here for this zoltan test:
456+tmpFCFLAGS="$FCFLAGS"
457+FCFLAGS="$FCFLAGS $CPPFLAGS"
458+AC_LINK_IFELSE(
459+[AC_LANG_SOURCE([
460+program test_zoltan
461+ use zoltan
462+end program test_zoltan
463+])],
464+[
465+AC_MSG_NOTICE([Great success! Zoltan .mod files exist and are usable])
466+],
467+[
468+cp conftest.F90 test_zoltan.F90
469+AC_MSG_FAILURE([Failed to find zoltan.mod files])])
470+# And now revert FCFLAGS
471+FCFLAGS="$tmpFCFLAGS"
472 AC_LANG_RESTORE
473
474 ZOLTAN="yes"
475@@ -1051,7 +1056,7 @@
476 AC_LANG_C
477 AC_CHECK_LIB(
478 [adjoint],
479- [adj_register_equation],
480+ [adj_register_forward_source_callback],
481 [AC_DEFINE(HAVE_ADJOINT,1,[Define if you have libadjoint.])HAVE_ADJOINT=yes],
482 [AC_MSG_WARN( [Could not link in libadjoint ... ] );HAVE_ADJOINT=no;LIBS=$bakLIBS] )
483 # Save variables...
484
485=== modified file 'assemble/Adapt_State.F90'
486--- assemble/Adapt_State.F90 2011-09-28 13:38:45 +0000
487+++ assemble/Adapt_State.F90 2012-10-16 13:22:44 +0000
488@@ -73,13 +73,12 @@
489 use diagnostic_variables
490 use diagnostic_fields_wrapper_new, only : calculate_diagnostic_variables_new => calculate_diagnostic_variables
491 use pickers
492+ use write_gmsh
493 #ifdef HAVE_ZOLTAN
494 use zoltan_integration
495 use mpi_interfaces
496 #endif
497
498- use mesh_files
499-
500 implicit none
501
502 private
503@@ -923,10 +922,10 @@
504 output_positions => extract_vector_field(states(1), "Coordinate")
505
506 if(isparallel()) then
507- call write_mesh_files(parallel_filename("first_timestep_adapted_mesh"), output_positions)
508+ call write_gmsh_file(parallel_filename("first_timestep_adapted_mesh"), output_positions)
509 call write_halos("first_timestep_adapted_mesh", output_positions%mesh)
510 else
511- call write_mesh_files("first_timestep_adapted_mesh", output_positions)
512+ call write_gmsh_file("first_timestep_adapted_mesh", output_positions)
513 end if
514
515 end if
516@@ -1003,13 +1002,9 @@
517 call get_option("/mesh_adaptivity/hr_adaptivity/zoltan_options/element_quality_cutoff", &
518 & quality_tolerance, default = 0.6)
519
520- if (max_adapt_iteration .ne. 1) then
521- zoltan_min_adapt_iterations = adapt_iterations()
522- zoltan_max_adapt_iterations = zoltan_min_adapt_iterations + zoltan_additional_adapt_iterations
523- else
524- zoltan_min_adapt_iterations = adapt_iterations()
525- zoltan_max_adapt_iterations = zoltan_min_adapt_iterations
526- end if
527+ zoltan_min_adapt_iterations = adapt_iterations()
528+ zoltan_max_adapt_iterations = zoltan_min_adapt_iterations + zoltan_additional_adapt_iterations
529+
530 #endif
531
532 finished_adapting = .false.
533@@ -1238,7 +1233,11 @@
534 ! call zoltan now but we need to pass in both the 2d metric (metric) and the 3d full metric (full_metric)
535 ! the first is needed to define the element qualities while the second must be interpolated to the newly
536 ! decomposed mesh
537- call zoltan_drive(states, final_adapt_iteration, global_min_quality, metric = metric, full_metric = full_metric)
538+ if (zoltan_additional_adapt_iterations .gt. 0) then
539+ call zoltan_drive(states, final_adapt_iteration, global_min_quality = global_min_quality, metric = metric, full_metric = full_metric)
540+ else
541+ call zoltan_drive(states, final_adapt_iteration, metric = metric, full_metric = full_metric)
542+ end if
543 default_stat%zoltan_drive_call=.true.
544
545 ! now we can deallocate the horizontal metric and point metric back at the full metric again
546@@ -1246,7 +1245,11 @@
547 metric = full_metric
548 else
549
550- call zoltan_drive(states, final_adapt_iteration, global_min_quality, metric = metric)
551+ if (zoltan_additional_adapt_iterations .gt. 0) then
552+ call zoltan_drive(states, final_adapt_iteration, global_min_quality = global_min_quality, metric = metric)
553+ else
554+ call zoltan_drive(states, final_adapt_iteration, metric = metric)
555+ end if
556 default_stat%zoltan_drive_call=.true.
557
558 end if
559@@ -1303,10 +1306,12 @@
560 ewrite(2,*) "The next iteration will be final adapt iteration else we'll go over the maximum adapt iterations."
561 end if
562
563- if (global_min_quality .le. quality_tolerance) then
564- ewrite(-1,*) "Mesh contains elements with quality below element quality tolerance. May need to increase number of adapt iterations to ensure good quality mesh."
565- ewrite(-1,*) "min_quality = ", global_min_quality
566- ewrite(-1,*) "quality_tolerance = ", quality_tolerance
567+ if (zoltan_additional_adapt_iterations .gt. 0) then
568+ if (global_min_quality .le. quality_tolerance) then
569+ ewrite(-1,*) "Mesh contains elements with quality below element quality tolerance. May need to increase number of adapt iterations to ensure good quality mesh."
570+ ewrite(-1,*) "min_quality = ", global_min_quality
571+ ewrite(-1,*) "quality_tolerance = ", quality_tolerance
572+ end if
573 end if
574
575 final_adapt_iteration = .true.
576@@ -1607,7 +1612,7 @@
577 file_name = adapt_state_debug_file_name("adapted_mesh", mesh_dump_no)
578 call find_mesh_to_adapt(states(1), mesh)
579 positions = get_coordinate_field(states(1), mesh)
580- call write_mesh_files(file_name, positions)
581+ call write_gmsh_file(file_name, positions)
582 if(isparallel()) then
583 file_name = adapt_state_debug_file_name("adapted_mesh", mesh_dump_no, add_parallel = .false.) ! parallel extension is added by write_halos
584 call write_halos(file_name, positions%mesh)
585
586=== modified file 'assemble/Adapt_State_Prescribed.F90'
587--- assemble/Adapt_State_Prescribed.F90 2011-07-22 15:34:14 +0000
588+++ assemble/Adapt_State_Prescribed.F90 2012-10-16 13:22:44 +0000
589@@ -109,8 +109,8 @@
590 if(have_option(base_path // "/mesh/from_file")) then
591 call get_option(base_path // "/mesh/from_file/format/name", format)
592 call get_option("/geometry/quadrature/degree", quad_degree)
593-
594- new_positions = read_mesh_files(mesh_name, quad_degree = quad_degree)
595+
596+ new_positions = read_mesh_files(mesh_name, quad_degree = quad_degree, format = format)
597 else
598 ewrite(2, *) "Extracting new mesh from state"
599
600
601=== modified file 'assemble/Adaptivity_1D.F90'
602--- assemble/Adaptivity_1D.F90 2010-11-09 14:08:19 +0000
603+++ assemble/Adaptivity_1D.F90 2012-10-16 13:22:44 +0000
604@@ -95,7 +95,12 @@
605
606 call deallocate(sizing)
607
608- assert(descending_coordinate_ordered(new_positions))
609+ if (.not. descending_coordinate_ordered(new_positions)) then
610+ ewrite(-1,*) "To use 1D adaptivity you need an input mesh for which the ordering of the nodes is such that " // &
611+ "their coordinates decrease with increasing node number. If you use the 'interval' script to produce a " // &
612+ "mesh, you can achieve this by adding the '--reverse' option."
613+ FLExit("To be adapted 1D mesh not in descending order.")
614+ end if
615
616 ! adapt_1d doesn't build a complete mesh. Build the rest of the mesh.
617 assert(ele_count(new_positions) == node_count(new_positions) - 1)
618
619=== modified file 'assemble/Advection_Diffusion_CG.F90'
620--- assemble/Advection_Diffusion_CG.F90 2011-09-15 13:37:20 +0000
621+++ assemble/Advection_Diffusion_CG.F90 2012-10-16 13:22:44 +0000
622@@ -39,13 +39,20 @@
623 use boundary_conditions_from_options
624 use field_options
625 use fldebug
626- use global_parameters, only : FIELD_NAME_LEN, OPTION_PATH_LEN
627+ use global_parameters, only : FIELD_NAME_LEN, OPTION_PATH_LEN, COLOURING_CG1
628 use profiler
629 use spud
630 use petsc_solve_state_module
631 use state_module
632 use upwind_stabilisation
633 use sparsity_patterns_meshes
634+ use porous_media
635+ use multiphase_module
636+ use sparse_tools_petsc
637+ use colouring
638+#ifdef _OPENMP
639+ use omp_lib
640+#endif
641
642 implicit none
643
644@@ -99,6 +106,8 @@
645 logical :: integrate_advection_by_parts
646 ! Source?
647 logical :: have_source
648+ ! Add source directly to the right hand side?
649+ logical :: add_src_directly_to_rhs
650 ! Absorption?
651 logical :: have_absorption
652 ! Diffusivity?
653@@ -107,20 +116,23 @@
654 logical :: isotropic_diffusivity
655 ! Is the mesh moving?
656 logical :: move_mesh
657+ ! Include porosity?
658+ logical :: include_porosity
659+ ! Are we running a multiphase flow simulation?
660+ logical :: multiphase
661
662 contains
663
664- subroutine solve_field_equation_cg(field_name, state, dt, velocity_name, &
665- extra_discretised_source, iterations_taken)
666+ subroutine solve_field_equation_cg(field_name, state, istate, dt, velocity_name, iterations_taken)
667 !!< Construct and solve the advection-diffusion equation for the given
668 !!< field using a continuous Galerkin discretisation. Based on
669 !!< Advection_Diffusion_DG and Momentum_CG.
670
671 character(len = *), intent(in) :: field_name
672- type(state_type), intent(inout) :: state
673+ type(state_type), dimension(:), intent(inout) :: state
674+ integer, intent(in) :: istate
675 real, intent(in) :: dt
676 character(len = *), optional, intent(in) :: velocity_name
677- type(scalar_field), intent(in), optional :: extra_discretised_source
678 integer, intent(out), optional :: iterations_taken
679
680 type(csr_matrix) :: matrix
681@@ -130,17 +142,22 @@
682 ewrite(1, *) "In solve_field_equation_cg"
683
684 ewrite(2, *) "Solving advection-diffusion equation for field " // &
685- & trim(field_name) // " in state " // trim(state%name)
686+ & trim(field_name) // " in state " // trim(state(istate)%name)
687
688- call initialise_advection_diffusion_cg(field_name, t, delta_t, matrix, rhs, state)
689+ call initialise_advection_diffusion_cg(field_name, t, delta_t, matrix, rhs, state(istate))
690
691 call profiler_tic(t, "assembly")
692- call assemble_advection_diffusion_cg(t, matrix, rhs, state, dt, velocity_name = velocity_name, &
693- extra_discretised_source = extra_discretised_source)
694+ call assemble_advection_diffusion_cg(t, matrix, rhs, state(istate), dt, velocity_name = velocity_name)
695+
696+ ! Note: the assembly of the heat transfer term is done here to avoid
697+ ! passing in the whole state array to assemble_advection_diffusion_cg.
698+ if(have_option("/multiphase_interaction/heat_transfer")) then
699+ call add_heat_transfer(state, istate, t, matrix, rhs)
700+ end if
701 call profiler_toc(t, "assembly")
702-
703+
704 call profiler_tic(t, "solve_total")
705- call solve_advection_diffusion_cg(t, delta_t, matrix, rhs, state, &
706+ call solve_advection_diffusion_cg(t, delta_t, matrix, rhs, state(istate), &
707 iterations_taken = iterations_taken)
708 call profiler_toc(t, "solve_total")
709
710@@ -206,31 +223,43 @@
711
712 end subroutine set_advection_diffusion_cg_initial_guess
713
714- subroutine assemble_advection_diffusion_cg(t, matrix, rhs, state, dt, velocity_name, &
715- extra_discretised_source)
716+ subroutine assemble_advection_diffusion_cg(t, matrix, rhs, state, dt, velocity_name)
717 type(scalar_field), intent(inout) :: t
718 type(csr_matrix), intent(inout) :: matrix
719 type(scalar_field), intent(inout) :: rhs
720- type(state_type), intent(in) :: state
721+ type(state_type), intent(inout) :: state
722 real, intent(in) :: dt
723 character(len = *), optional, intent(in) :: velocity_name
724- type(scalar_field), intent(in), optional :: extra_discretised_source
725
726- character(len = FIELD_NAME_LEN) :: lvelocity_name
727+ character(len = FIELD_NAME_LEN) :: lvelocity_name, velocity_equation_type
728 integer :: i, j, stat
729 integer, dimension(:), allocatable :: t_bc_types
730 type(scalar_field) :: t_bc, t_bc_2
731 type(scalar_field), pointer :: absorption, sinking_velocity, source
732 type(tensor_field), pointer :: diffusivity
733 type(vector_field) :: velocity
734- type(vector_field), pointer :: gravity_direction, velocity_ptr, grid_velocity
735+ type(vector_field), pointer :: gravity_direction, temp_velocity_ptr, velocity_ptr, grid_velocity
736 type(vector_field), pointer :: positions, old_positions, new_positions
737 type(scalar_field), target :: dummydensity
738 type(scalar_field), pointer :: density, olddensity
739 character(len = FIELD_NAME_LEN) :: density_name
740 type(scalar_field), pointer :: pressure
741-
742- type(element_type) :: supg_element
743+
744+ ! Volume fraction fields for multiphase flow simulation
745+ type(scalar_field), pointer :: vfrac
746+ type(scalar_field) :: nvfrac ! Non-linear version
747+
748+ ! Porosity field
749+ type(scalar_field) :: porosity_theta
750+
751+ !! Coloring data structures for OpenMP parallization
752+ type(integer_set), dimension(:), pointer :: colours
753+ integer :: clr, nnid, len, ele
754+ integer :: num_threads, thread_num
755+ !! Did we successfully prepopulate the transform_to_physical_cache?
756+ logical :: cache_valid
757+
758+ type(element_type), dimension(:), allocatable :: supg_element
759
760 ewrite(1, *) "In assemble_advection_diffusion_cg"
761
762@@ -242,7 +271,12 @@
763 else
764 lvelocity_name = "NonlinearVelocity"
765 end if
766-
767+
768+#ifdef _OPENMP
769+ num_threads = omp_get_max_threads()
770+#else
771+ num_threads = 1
772+#endif
773 ! Step 1: Pull fields out of state
774
775 ! Coordinate
776@@ -281,10 +315,19 @@
777 if(have_source) then
778 assert(mesh_dim(source) == mesh_dim(t))
779 assert(ele_count(source) == ele_count(t))
780-
781+
782+ add_src_directly_to_rhs = have_option(trim(source%option_path)//'/diagnostic/add_directly_to_rhs')
783+
784+ if (add_src_directly_to_rhs) then
785+ ewrite(2, *) "Adding Source field directly to the right hand side"
786+ assert(node_count(source) == node_count(t))
787+ end if
788+
789 ewrite_minmax(source)
790 else
791 ewrite(2, *) "No source"
792+
793+ add_src_directly_to_rhs = .false.
794 end if
795
796 ! Absorption
797@@ -333,6 +376,19 @@
798 isotropic_diffusivity = .false.
799 ewrite(2, *) "No diffusivity"
800 end if
801+
802+ ! Porosity
803+ if (have_option(trim(complete_field_path(t%option_path))//'/porosity')) then
804+ include_porosity = .true.
805+
806+ ! get the porosity theta averaged field - this will allocate it
807+ call form_porosity_theta(porosity_theta, state, option_path = trim(complete_field_path(t%option_path))//'/porosity')
808+ else
809+ include_porosity = .false.
810+ call allocate(porosity_theta, t%mesh, field_type=FIELD_TYPE_CONSTANT)
811+ call set(porosity_theta, 1.0)
812+ end if
813+
814
815 ! Step 2: Pull options out of the options tree
816
817@@ -375,6 +431,9 @@
818 ! are we moving the mesh?
819 move_mesh = (have_option("/mesh_adaptivity/mesh_movement") .and. have_mass)
820 if(move_mesh) then
821+ if (include_porosity) then
822+ FLExit('Cannot include porosity in CG advection diffusion of a field with a moving mesh')
823+ end if
824 ewrite(2,*) "Moving the mesh"
825 old_positions => extract_vector_field(state, "OldCoordinate")
826 ewrite_minmax(old_positions)
827@@ -392,6 +451,7 @@
828 ewrite(2,*) "Not moving the mesh"
829 end if
830
831+ allocate(supg_element(num_threads))
832 if(have_option(trim(t%option_path) // "/prognostic/spatial_discretisation/continuous_galerkin/stabilisation/streamline_upwind")) then
833 ewrite(2, *) "Streamline upwind stabilisation"
834 stabilisation_scheme = STABILISATION_STREAMLINE_UPWIND
835@@ -406,8 +466,10 @@
836 call get_upwind_options(trim(t%option_path) // "/prognostic/spatial_discretisation/continuous_galerkin/stabilisation/streamline_upwind_petrov_galerkin", &
837 & nu_bar_scheme, nu_bar_scale)
838 ! Note this is not mixed mesh safe (but then nothing really is)
839- ! You actually need 1 supg_element per thread.
840- supg_element=make_supg_element(ele_shape(t,1))
841+ ! You need 1 supg_element per thread.
842+ do i = 1, num_threads
843+ supg_element(i)=make_supg_element(ele_shape(t,1))
844+ end do
845 if(move_mesh) then
846 FLExit("Haven't thought about how mesh movement works with stabilisation yet.")
847 end if
848@@ -416,6 +478,21 @@
849 stabilisation_scheme = STABILISATION_NONE
850 end if
851
852+ ! PhaseVolumeFraction for multiphase flow simulations
853+ if(option_count("/material_phase/vector_field::Velocity/prognostic") > 1) then
854+ multiphase = .true.
855+ vfrac => extract_scalar_field(state, "PhaseVolumeFraction")
856+ call allocate(nvfrac, vfrac%mesh, "NonlinearPhaseVolumeFraction")
857+ call zero(nvfrac)
858+ call get_nonlinear_volume_fraction(state, nvfrac)
859+
860+ ewrite_minmax(nvfrac)
861+ else
862+ multiphase = .false.
863+ call allocate(nvfrac, t%mesh, "DummyNonlinearPhaseVolumeFraction", field_type=FIELD_TYPE_CONSTANT)
864+ call set(nvfrac, 1.0)
865+ end if
866+
867 call allocate(dummydensity, t%mesh, "DummyDensity", field_type=FIELD_TYPE_CONSTANT)
868 call set(dummydensity, 1.0)
869 ! find out equation type and hence if density is needed or not
870@@ -428,24 +505,62 @@
871 olddensity => dummydensity
872 density_theta = 1.0
873 pressure => dummydensity
874+
875 case(FIELD_EQUATION_INTERNALENERGY)
876 ewrite(2,*) "Solving internal energy equation"
877 if(move_mesh) then
878 FLExit("Haven't implemented a moving mesh energy equation yet.")
879 end if
880+
881+ ! Get old and current densities
882 call get_option(trim(t%option_path)//'/prognostic/equation[0]/density[0]/name', &
883 density_name)
884 density=>extract_scalar_field(state, trim(density_name))
885 ewrite_minmax(density)
886-
887 olddensity=>extract_scalar_field(state, "Old"//trim(density_name))
888 ewrite_minmax(olddensity)
889
890- call get_option(trim(density%option_path)//"/prognostic/temporal_discretisation/theta", &
891- density_theta)
892+ if(.not.multiphase .or. have_option('/material_phase::'//trim(state%name)//&
893+ &'/equation_of_state/compressible')) then
894+ call get_option(trim(density%option_path)//"/prognostic/temporal_discretisation/theta", &
895+ density_theta)
896+ else
897+ ! Since the particle phase is always incompressible then its Density
898+ ! will not be prognostic. Just use a fixed theta value of 1.0.
899+ density_theta = 1.0
900+ end if
901
902 pressure=>extract_scalar_field(state, "Pressure")
903 ewrite_minmax(pressure)
904+
905+ case(FIELD_EQUATION_KEPSILON)
906+ ewrite(2,*) "Solving k-epsilon equation"
907+ if(move_mesh) then
908+ FLExit("Haven't implemented a moving mesh k-epsilon equation yet.")
909+ end if
910+
911+ ! Depending on the equation type, extract the density or set it to some dummy field allocated above
912+ temp_velocity_ptr => extract_vector_field(state, "Velocity")
913+ call get_option(trim(temp_velocity_ptr%option_path)//"/prognostic/equation[0]/name", velocity_equation_type)
914+ select case(velocity_equation_type)
915+ case("LinearMomentum")
916+ density=>extract_scalar_field(state, "Density")
917+ olddensity => dummydensity
918+ density_theta = 1.0
919+ case("Boussinesq")
920+ density=>dummydensity
921+ olddensity => dummydensity
922+ density_theta = 1.0
923+ case("Drainage")
924+ density=>dummydensity
925+ olddensity => dummydensity
926+ density_theta = 1.0
927+ case default
928+ ! developer error... out of sync options input and code
929+ FLAbort("Unknown equation type for velocity")
930+ end select
931+ ewrite_minmax(density)
932+
933 case default
934 FLExit("Unknown field equation type for cg advection diffusion.")
935 end select
936@@ -455,19 +570,51 @@
937 call zero(matrix)
938 call zero(rhs)
939
940- do i = 1, ele_count(t)
941- call assemble_advection_diffusion_element_cg(i, t, matrix, rhs, &
942- positions, old_positions, new_positions, &
943- velocity, grid_velocity, &
944- source, absorption, diffusivity, &
945- density, olddensity, pressure,&
946- supg_element)
947- end do
948-
949- ! as part of assembly include the already discretised optional source
950- ! needed before applying direchlet boundary conditions
951- call addto_rhs_extra_discretised_source(rhs, extra_discretised_source = extra_discretised_source)
952-
953+ call profiler_tic(t, "advection_diffusion_loop_overhead")
954+
955+#ifdef _OPENMP
956+ cache_valid = prepopulate_transform_cache(positions)
957+ assert(cache_valid)
958+#endif
959+
960+ call get_mesh_colouring(state, t%mesh, COLOURING_CG1, colours)
961+ call profiler_toc(t, "advection_diffusion_loop_overhead")
962+
963+ call profiler_tic(t, "advection_diffusion_loop")
964+
965+ !$OMP PARALLEL DEFAULT(SHARED) &
966+ !$OMP PRIVATE(clr, len, nnid, ele, thread_num)
967+
968+#ifdef _OPENMP
969+ thread_num = omp_get_thread_num()
970+#else
971+ thread_num=0
972+#endif
973+ colour_loop: do clr = 1, size(colours)
974+
975+ len = key_count(colours(clr))
976+ !$OMP DO SCHEDULE(STATIC)
977+ element_loop: do nnid = 1, len
978+ ele = fetch(colours(clr), nnid)
979+ call assemble_advection_diffusion_element_cg(ele, t, matrix, rhs, &
980+ positions, old_positions, new_positions, &
981+ velocity, grid_velocity, &
982+ source, absorption, diffusivity, &
983+ density, olddensity, pressure, porosity_theta, nvfrac, &
984+ supg_element(thread_num+1))
985+ end do element_loop
986+ !$OMP END DO
987+
988+ end do colour_loop
989+ !$OMP END PARALLEL
990+
991+ call profiler_toc(t, "advection_diffusion_loop")
992+
993+ ! Add the source directly to the rhs if required
994+ ! which must be included before dirichlet BC's.
995+ if (add_src_directly_to_rhs) call addto(rhs, source)
996+
997+
998 ! Step 4: Boundary conditions
999
1000 if( &
1001@@ -494,7 +641,7 @@
1002 call assemble_advection_diffusion_face_cg(i, t_bc_types(i), t, t_bc, t_bc_2, &
1003 matrix, rhs, &
1004 positions, velocity, grid_velocity, &
1005- density, olddensity)
1006+ density, olddensity, nvfrac)
1007 end do
1008
1009 call deallocate(t_bc)
1010@@ -509,10 +656,17 @@
1011 ewrite_minmax(rhs)
1012
1013 call deallocate(velocity)
1014+ call deallocate(nvfrac)
1015 call deallocate(dummydensity)
1016- if (stabilisation_scheme == STABILISATION_SUPG) &
1017- call deallocate(supg_element)
1018+ if (stabilisation_scheme == STABILISATION_SUPG) then
1019+ do i = 1, num_threads
1020+ call deallocate(supg_element(i))
1021+ end do
1022+ end if
1023+ deallocate(supg_element)
1024
1025+ call deallocate(porosity_theta)
1026+
1027 ewrite(1, *) "Exiting assemble_advection_diffusion_cg"
1028
1029 end subroutine assemble_advection_diffusion_cg
1030@@ -562,7 +716,7 @@
1031 positions, old_positions, new_positions, &
1032 velocity, grid_velocity, &
1033 source, absorption, diffusivity, &
1034- density, olddensity, pressure, supg_shape)
1035+ density, olddensity, pressure, porosity_theta, nvfrac, supg_shape)
1036 integer, intent(in) :: ele
1037 type(scalar_field), intent(in) :: t
1038 type(csr_matrix), intent(inout) :: matrix
1039@@ -577,6 +731,8 @@
1040 type(scalar_field), intent(in) :: density
1041 type(scalar_field), intent(in) :: olddensity
1042 type(scalar_field), intent(in) :: pressure
1043+ type(scalar_field), intent(in) :: porosity_theta
1044+ type(scalar_field), intent(in) :: nvfrac
1045 type(element_type), intent(inout) :: supg_shape
1046
1047 integer, dimension(:), pointer :: element_nodes
1048@@ -585,6 +741,9 @@
1049 real, dimension(ele_loc(density, ele), ele_ngi(density, ele), mesh_dim(density)) :: drho_t
1050 real, dimension(ele_loc(velocity, ele), ele_ngi(velocity, ele), mesh_dim(t)) :: du_t
1051 real, dimension(ele_loc(positions, ele), ele_ngi(velocity, ele), mesh_dim(t)) :: dug_t
1052+ ! Derivative of shape function for nvfrac field
1053+ real, dimension(ele_loc(nvfrac, ele), ele_ngi(nvfrac, ele), mesh_dim(nvfrac)) :: dnvfrac_t
1054+
1055 real, dimension(mesh_dim(t), mesh_dim(t), ele_ngi(t, ele)) :: j_mat
1056 type(element_type) :: test_function
1057 type(element_type), pointer :: t_shape
1058@@ -611,6 +770,9 @@
1059 assert(ele_loc(grid_velocity, ele) == ele_loc(positions, ele))
1060 assert(ele_ngi(grid_velocity, ele) == ele_ngi(velocity, ele))
1061 end if
1062+ if (include_porosity) then
1063+ assert(ele_ngi(porosity_theta, ele) == ele_ngi(t, ele))
1064+ end if
1065 #endif
1066
1067 matrix_addto = 0.0
1068@@ -630,7 +792,7 @@
1069 & dshape = dt_t, detwei = detwei)
1070 end if
1071
1072- if(have_advection.or.(equation_type==FIELD_EQUATION_INTERNALENERGY)) then
1073+ if(have_advection.or.(equation_type==FIELD_EQUATION_INTERNALENERGY).or.equation_type==FIELD_EQUATION_KEPSILON) then
1074 call transform_to_physical(positions, ele, &
1075 & ele_shape(velocity, ele), dshape = du_t)
1076 end if
1077@@ -645,7 +807,7 @@
1078 call transform_to_physical(new_positions, ele, detwei=detwei_new)
1079 end if
1080
1081- if(have_advection.and.(equation_type==FIELD_EQUATION_INTERNALENERGY)) then
1082+ if(have_advection.and.(equation_type==FIELD_EQUATION_INTERNALENERGY .or. equation_type==FIELD_EQUATION_KEPSILON)) then
1083 if(ele_shape(density, ele)==t_shape) then
1084 drho_t = dt_t
1085 else
1086@@ -654,6 +816,16 @@
1087 end if
1088 end if
1089
1090+ if(have_advection .and. multiphase .and. (equation_type==FIELD_EQUATION_INTERNALENERGY)) then
1091+ ! If the field and nvfrac meshes are different, then we need to
1092+ ! compute the derivatives of the nvfrac shape functions.
1093+ if(ele_shape(nvfrac, ele) == t_shape) then
1094+ dnvfrac_t = dt_t
1095+ else
1096+ call transform_to_physical(positions, ele, ele_shape(nvfrac, ele), dshape=dnvfrac_t)
1097+ end if
1098+ end if
1099+
1100 ! Step 2: Set up test function
1101
1102 select case(stabilisation_scheme)
1103@@ -661,7 +833,6 @@
1104 if(have_diffusivity) then
1105 call supg_test_function(supg_shape, t_shape, dt_t, ele_val_at_quad(velocity, ele), j_mat, diff_q = ele_val_at_quad(diffusivity, ele), &
1106 & nu_bar_scheme = nu_bar_scheme, nu_bar_scale = nu_bar_scale)
1107- test_function = supg_shape
1108 else
1109 call supg_test_function(supg_shape, t_shape, dt_t, ele_val_at_quad(velocity, ele), j_mat, &
1110 & nu_bar_scheme = nu_bar_scheme, nu_bar_scale = nu_bar_scale)
1111@@ -677,13 +848,13 @@
1112 ! Step 3: Assemble contributions
1113
1114 ! Mass
1115- if(have_mass) call add_mass_element_cg(ele, test_function, t, density, olddensity, detwei, detwei_old, detwei_new, matrix_addto, rhs_addto)
1116+ if(have_mass) call add_mass_element_cg(ele, test_function, t, density, olddensity, porosity_theta, nvfrac, detwei, detwei_old, detwei_new, matrix_addto, rhs_addto)
1117
1118 ! Advection
1119 if(have_advection) call add_advection_element_cg(ele, test_function, t, &
1120 velocity, grid_velocity, diffusivity, &
1121- density, olddensity, &
1122- dt_t, du_t, dug_t, drho_t, detwei, j_mat, matrix_addto, rhs_addto)
1123+ density, olddensity, nvfrac, &
1124+ dt_t, du_t, dug_t, drho_t, dnvfrac_t, detwei, j_mat, matrix_addto, rhs_addto)
1125
1126 ! Absorption
1127 if(have_absorption) call add_absorption_element_cg(ele, test_function, t, absorption, detwei, matrix_addto, rhs_addto)
1128@@ -692,12 +863,14 @@
1129 if(have_diffusivity) call add_diffusivity_element_cg(ele, t, diffusivity, dt_t, detwei, matrix_addto, rhs_addto)
1130
1131 ! Source
1132- if(have_source) call add_source_element_cg(ele, test_function, t, source, detwei, rhs_addto)
1133+ if(have_source .and. (.not. add_src_directly_to_rhs)) then
1134+ call add_source_element_cg(ele, test_function, t, source, detwei, rhs_addto)
1135+ end if
1136
1137 ! Pressure
1138 if(equation_type==FIELD_EQUATION_INTERNALENERGY) call add_pressurediv_element_cg(ele, test_function, t, &
1139- velocity, pressure, &
1140- du_t, detwei, rhs_addto)
1141+ velocity, pressure, nvfrac, &
1142+ du_t, dnvfrac_t, detwei, rhs_addto)
1143
1144 ! Step 4: Insertion
1145
1146@@ -707,11 +880,13 @@
1147
1148 end subroutine assemble_advection_diffusion_element_cg
1149
1150- subroutine add_mass_element_cg(ele, test_function, t, density, olddensity, detwei, detwei_old, detwei_new, matrix_addto, rhs_addto)
1151+ subroutine add_mass_element_cg(ele, test_function, t, density, olddensity, porosity_theta, nvfrac, detwei, detwei_old, detwei_new, matrix_addto, rhs_addto)
1152 integer, intent(in) :: ele
1153 type(element_type), intent(in) :: test_function
1154 type(scalar_field), intent(in) :: t
1155 type(scalar_field), intent(in) :: density, olddensity
1156+ type(scalar_field), intent(in) :: porosity_theta
1157+ type(scalar_field), intent(in) :: nvfrac
1158 real, dimension(ele_ngi(t, ele)), intent(in) :: detwei, detwei_old, detwei_new
1159 real, dimension(ele_loc(t, ele), ele_loc(t, ele)), intent(inout) :: matrix_addto
1160 real, dimension(ele_loc(t, ele)), intent(inout) :: rhs_addto
1161@@ -720,9 +895,12 @@
1162 real, dimension(ele_loc(t, ele), ele_loc(t, ele)) :: mass_matrix
1163
1164 real, dimension(ele_ngi(density,ele)) :: density_at_quad
1165+ real, dimension(ele_ngi(porosity_theta,ele)) :: porosity_theta_at_quad
1166
1167 assert(have_mass)
1168
1169+ if (include_porosity) porosity_theta_at_quad = ele_val_at_quad(porosity_theta, ele)
1170+
1171 select case(equation_type)
1172 case(FIELD_EQUATION_INTERNALENERGY)
1173 assert(ele_ngi(density, ele)==ele_ngi(olddensity, ele))
1174@@ -733,15 +911,28 @@
1175 ! needs to be evaluated at t+dt
1176 mass_matrix = shape_shape(test_function, ele_shape(t, ele), detwei_new*density_at_quad)
1177 else
1178- mass_matrix = shape_shape(test_function, ele_shape(t, ele), detwei*density_at_quad)
1179+ if (include_porosity) then
1180+ mass_matrix = shape_shape(test_function, ele_shape(t, ele), detwei*density_at_quad*porosity_theta_at_quad)
1181+ else if(multiphase) then
1182+ mass_matrix = shape_shape(test_function, ele_shape(t, ele), detwei*density_at_quad*ele_val_at_quad(nvfrac, ele))
1183+ else
1184+ mass_matrix = shape_shape(test_function, ele_shape(t, ele), detwei*density_at_quad)
1185+ end if
1186 end if
1187+ case(FIELD_EQUATION_KEPSILON)
1188+ density_at_quad = ele_val_at_quad(density, ele)
1189+ mass_matrix = shape_shape(test_function, ele_shape(t, ele), detwei*density_at_quad)
1190 case default
1191
1192 if(move_mesh) then
1193 ! needs to be evaluated at t+dt
1194 mass_matrix = shape_shape(test_function, ele_shape(t, ele), detwei_new)
1195 else
1196- mass_matrix = shape_shape(test_function, ele_shape(t, ele), detwei)
1197+ if (include_porosity) then
1198+ mass_matrix = shape_shape(test_function, ele_shape(t, ele), detwei*porosity_theta_at_quad)
1199+ else
1200+ mass_matrix = shape_shape(test_function, ele_shape(t, ele), detwei)
1201+ end if
1202 end if
1203
1204 end select
1205@@ -777,8 +968,8 @@
1206
1207 subroutine add_advection_element_cg(ele, test_function, t, &
1208 velocity, grid_velocity, diffusivity, &
1209- density, olddensity, &
1210- dt_t, du_t, dug_t, drho_t, detwei, j_mat, matrix_addto, rhs_addto)
1211+ density, olddensity, nvfrac, &
1212+ dt_t, du_t, dug_t, drho_t, dnvfrac_t, detwei, j_mat, matrix_addto, rhs_addto)
1213 integer, intent(in) :: ele
1214 type(element_type), intent(in) :: test_function
1215 type(scalar_field), intent(in) :: t
1216@@ -786,10 +977,12 @@
1217 type(vector_field), pointer :: grid_velocity
1218 type(tensor_field), intent(in) :: diffusivity
1219 type(scalar_field), intent(in) :: density, olddensity
1220+ type(scalar_field), intent(in) :: nvfrac
1221 real, dimension(ele_loc(t, ele), ele_ngi(t, ele), mesh_dim(t)), intent(in) :: dt_t
1222 real, dimension(ele_loc(velocity, ele), ele_ngi(velocity, ele), mesh_dim(t)) :: du_t
1223 real, dimension(:, :, :) :: dug_t
1224 real, dimension(ele_loc(density, ele), ele_ngi(density, ele), mesh_dim(density)), intent(in) :: drho_t
1225+ real, dimension(:, :, :), intent(in) :: dnvfrac_t
1226 real, dimension(ele_ngi(t, ele)), intent(in) :: detwei
1227 real, dimension(mesh_dim(t), mesh_dim(t), ele_ngi(t, ele)), intent(in) :: j_mat
1228 real, dimension(ele_loc(t, ele), ele_loc(t, ele)), intent(inout) :: matrix_addto
1229@@ -804,6 +997,10 @@
1230 real, dimension(velocity%dim, ele_ngi(density, ele)) :: densitygrad_at_quad
1231 real, dimension(ele_ngi(density, ele)) :: udotgradrho_at_quad
1232
1233+ real, dimension(ele_ngi(t, ele)) :: nvfrac_at_quad
1234+ real, dimension(velocity%dim, ele_ngi(t, ele)) :: nvfracgrad_at_quad
1235+ real, dimension(ele_ngi(t, ele)) :: udotgradnvfrac_at_quad
1236+
1237 assert(have_advection)
1238
1239 t_shape => ele_shape(t, ele)
1240@@ -822,6 +1019,15 @@
1241 densitygrad_at_quad = density_theta*ele_grad_at_quad(density, ele, drho_t) &
1242 +(1.-density_theta)*ele_grad_at_quad(olddensity, ele, drho_t)
1243 udotgradrho_at_quad = sum(densitygrad_at_quad*velocity_at_quad, 1)
1244+
1245+ if(multiphase) then
1246+ nvfrac_at_quad = ele_val_at_quad(nvfrac, ele)
1247+ end if
1248+
1249+ case(FIELD_EQUATION_KEPSILON)
1250+ density_at_quad = ele_val_at_quad(density, ele)
1251+ densitygrad_at_quad = ele_grad_at_quad(density, ele, drho_t)
1252+ udotgradrho_at_quad = sum(densitygrad_at_quad*velocity_at_quad, 1)
1253 end select
1254
1255 if(integrate_advection_by_parts) then
1256@@ -831,6 +1037,28 @@
1257 ! / /
1258 select case(equation_type)
1259 case(FIELD_EQUATION_INTERNALENERGY)
1260+ if(multiphase) then
1261+ advection_mat = -dshape_dot_vector_shape(dt_t, velocity_at_quad, t_shape, detwei*density_at_quad*nvfrac_at_quad)
1262+ else
1263+ advection_mat = -dshape_dot_vector_shape(dt_t, velocity_at_quad, t_shape, detwei*density_at_quad)
1264+ end if
1265+
1266+ if(abs(1.0 - beta) > epsilon(0.0)) then
1267+ velocity_div_at_quad = ele_div_at_quad(velocity, ele, du_t)
1268+
1269+ if(multiphase) then
1270+
1271+ nvfracgrad_at_quad = ele_grad_at_quad(nvfrac, ele, dnvfrac_t)
1272+ udotgradnvfrac_at_quad = sum(nvfracgrad_at_quad*velocity_at_quad, 1)
1273+
1274+ advection_mat = advection_mat - (1.0-beta) * ( shape_shape(test_function, t_shape, detwei*velocity_div_at_quad*density_at_quad*nvfrac_at_quad) &
1275+ + shape_shape(test_function, t_shape, detwei*nvfrac_at_quad*udotgradrho_at_quad) &
1276+ + shape_shape(test_function, t_shape, detwei*density_at_quad*udotgradnvfrac_at_quad) )
1277+ else
1278+ advection_mat = advection_mat - (1.0-beta) * shape_shape(test_function, t_shape, (velocity_div_at_quad*density_at_quad + udotgradrho_at_quad)*detwei)
1279+ end if
1280+ end if
1281+ case(FIELD_EQUATION_KEPSILON)
1282 advection_mat = -dshape_dot_vector_shape(dt_t, velocity_at_quad, t_shape, detwei*density_at_quad)
1283 if(abs(1.0 - beta) > epsilon(0.0)) then
1284 velocity_div_at_quad = ele_div_at_quad(velocity, ele, du_t)
1285@@ -853,6 +1081,33 @@
1286 ! / /
1287 select case(equation_type)
1288 case(FIELD_EQUATION_INTERNALENERGY)
1289+
1290+ if(multiphase) then
1291+ ! vfrac*rho*nu*grad(internalenergy)
1292+ advection_mat = shape_vector_dot_dshape(test_function, velocity_at_quad, dt_t, detwei*density_at_quad*nvfrac_at_quad)
1293+ else
1294+ advection_mat = shape_vector_dot_dshape(test_function, velocity_at_quad, dt_t, detwei*density_at_quad)
1295+ end if
1296+
1297+ if(abs(beta) > epsilon(0.0)) then
1298+ velocity_div_at_quad = ele_div_at_quad(velocity, ele, du_t)
1299+
1300+ if(multiphase) then
1301+ ! advection_mat + internalenergy*div(vfrac*rho*nu)
1302+ ! Split up div(vfrac*rho*nu) = vfrac*rho*div(nu) + nu*grad(vfrac*rho) = vfrac*rho*div(nu) + nu*(vfrac*grad(rho) + rho*grad(nvfrac))
1303+
1304+ nvfracgrad_at_quad = ele_grad_at_quad(nvfrac, ele, dnvfrac_t)
1305+ udotgradnvfrac_at_quad = sum(nvfracgrad_at_quad*velocity_at_quad, 1)
1306+
1307+ advection_mat = advection_mat + beta * ( shape_shape(test_function, t_shape, detwei*velocity_div_at_quad*density_at_quad*nvfrac_at_quad) &
1308+ + shape_shape(test_function, t_shape, detwei*nvfrac_at_quad*udotgradrho_at_quad) &
1309+ + shape_shape(test_function, t_shape, detwei*density_at_quad*udotgradnvfrac_at_quad) )
1310+ else
1311+ advection_mat = advection_mat + beta*shape_shape(test_function, t_shape, (velocity_div_at_quad*density_at_quad &
1312+ +udotgradrho_at_quad)*detwei)
1313+ end if
1314+ end if
1315+ case(FIELD_EQUATION_KEPSILON)
1316 advection_mat = shape_vector_dot_dshape(test_function, velocity_at_quad, dt_t, detwei*density_at_quad)
1317 if(abs(beta) > epsilon(0.0)) then
1318 velocity_div_at_quad = ele_div_at_quad(velocity, ele, du_t)
1319@@ -960,26 +1215,39 @@
1320
1321 end subroutine add_diffusivity_element_cg
1322
1323- subroutine add_pressurediv_element_cg(ele, test_function, t, velocity, pressure, du_t, detwei, rhs_addto)
1324+ subroutine add_pressurediv_element_cg(ele, test_function, t, velocity, pressure, nvfrac, du_t, dnvfrac_t, detwei, rhs_addto)
1325
1326 integer, intent(in) :: ele
1327 type(element_type), intent(in) :: test_function
1328 type(scalar_field), intent(in) :: t
1329 type(vector_field), intent(in) :: velocity
1330 type(scalar_field), intent(in) :: pressure
1331- real, dimension(ele_loc(velocity, ele), ele_ngi(velocity, ele), mesh_dim(t)) :: du_t
1332+ type(scalar_field), intent(in) :: nvfrac
1333+ real, dimension(ele_loc(velocity, ele), ele_ngi(velocity, ele), mesh_dim(t)), intent(in) :: du_t
1334+ real, dimension(:, :, :), intent(in) :: dnvfrac_t
1335 real, dimension(ele_ngi(t, ele)), intent(in) :: detwei
1336 real, dimension(ele_loc(t, ele)), intent(inout) :: rhs_addto
1337
1338+ real, dimension(velocity%dim, ele_ngi(t, ele)) :: nvfracgrad_at_quad
1339+ real, dimension(ele_ngi(t, ele)) :: udotgradnvfrac_at_quad
1340+
1341 assert(equation_type==FIELD_EQUATION_INTERNALENERGY)
1342 assert(ele_ngi(pressure, ele)==ele_ngi(t, ele))
1343
1344- rhs_addto = rhs_addto - &
1345- shape_rhs(test_function, ele_div_at_quad(velocity, ele, du_t) * ele_val_at_quad(pressure, ele) * detwei)
1346+ if(multiphase) then
1347+ ! -p * (div(vfrac*nu))
1348+ nvfracgrad_at_quad = ele_grad_at_quad(nvfrac, ele, dnvfrac_t)
1349+ udotgradnvfrac_at_quad = sum(nvfracgrad_at_quad*ele_val_at_quad(velocity, ele), 1)
1350+
1351+ rhs_addto = rhs_addto - ( shape_rhs(test_function, ele_div_at_quad(velocity, ele, du_t) * ele_val_at_quad(nvfrac, ele) * ele_val_at_quad(pressure, ele) * detwei) &
1352+ + shape_rhs(test_function, udotgradnvfrac_at_quad * ele_val_at_quad(pressure, ele) * detwei) )
1353+ else
1354+ rhs_addto = rhs_addto - shape_rhs(test_function, ele_div_at_quad(velocity, ele, du_t) * ele_val_at_quad(pressure, ele) * detwei)
1355+ end if
1356
1357 end subroutine add_pressurediv_element_cg
1358
1359- subroutine assemble_advection_diffusion_face_cg(face, bc_type, t, t_bc, t_bc_2, matrix, rhs, positions, velocity, grid_velocity, density, olddensity)
1360+ subroutine assemble_advection_diffusion_face_cg(face, bc_type, t, t_bc, t_bc_2, matrix, rhs, positions, velocity, grid_velocity, density, olddensity, nvfrac)
1361 integer, intent(in) :: face
1362 integer, intent(in) :: bc_type
1363 type(scalar_field), intent(in) :: t
1364@@ -992,6 +1260,7 @@
1365 type(vector_field), pointer :: grid_velocity
1366 type(scalar_field), intent(in) :: density
1367 type(scalar_field), intent(in) :: olddensity
1368+ type(scalar_field), intent(in) :: nvfrac
1369
1370 integer, dimension(face_loc(t, face)) :: face_nodes
1371 real, dimension(face_ngi(t, face)) :: detwei
1372@@ -1025,7 +1294,7 @@
1373
1374 ! Advection
1375 if(have_advection .and. integrate_advection_by_parts) &
1376- call add_advection_face_cg(face, bc_type, t, t_bc, velocity, grid_velocity, density, olddensity, detwei, normal, matrix_addto, rhs_addto)
1377+ call add_advection_face_cg(face, bc_type, t, t_bc, velocity, grid_velocity, density, olddensity, nvfrac, detwei, normal, matrix_addto, rhs_addto)
1378
1379 ! Diffusivity
1380 if(have_diffusivity) call add_diffusivity_face_cg(face, bc_type, t, t_bc, t_bc_2, detwei, matrix_addto, rhs_addto)
1381@@ -1038,7 +1307,7 @@
1382
1383 end subroutine assemble_advection_diffusion_face_cg
1384
1385- subroutine add_advection_face_cg(face, bc_type, t, t_bc, velocity, grid_velocity, density, olddensity, detwei, normal, matrix_addto, rhs_addto)
1386+ subroutine add_advection_face_cg(face, bc_type, t, t_bc, velocity, grid_velocity, density, olddensity, nvfrac, detwei, normal, matrix_addto, rhs_addto)
1387 integer, intent(in) :: face
1388 integer, intent(in) :: bc_type
1389 type(scalar_field), intent(in) :: t
1390@@ -1047,6 +1316,7 @@
1391 type(vector_field), pointer :: grid_velocity
1392 type(scalar_field), intent(in) :: density
1393 type(scalar_field), intent(in) :: olddensity
1394+ type(scalar_field), intent(in) :: nvfrac
1395 real, dimension(face_ngi(t, face)), intent(in) :: detwei
1396 real, dimension(mesh_dim(t), face_ngi(t, face)), intent(in) :: normal
1397 real, dimension(face_loc(t, face), face_loc(t, face)), intent(inout) :: matrix_addto
1398@@ -1071,8 +1341,12 @@
1399 case(FIELD_EQUATION_INTERNALENERGY)
1400 density_at_quad = density_theta*face_val_at_quad(density, face) &
1401 +(1.0-density_theta)*face_val_at_quad(olddensity, face)
1402-
1403- advection_mat = shape_shape(t_shape, t_shape, detwei * sum(velocity_at_quad * normal, 1) * density_at_quad)
1404+
1405+ if(multiphase) then
1406+ advection_mat = shape_shape(t_shape, t_shape, detwei * sum(velocity_at_quad * normal, 1) * density_at_quad * face_val_at_quad(nvfrac, face))
1407+ else
1408+ advection_mat = shape_shape(t_shape, t_shape, detwei * sum(velocity_at_quad * normal, 1) * density_at_quad)
1409+ end if
1410 case default
1411
1412 advection_mat = shape_shape(t_shape, t_shape, detwei * sum(velocity_at_quad * normal, 1))
1413@@ -1125,22 +1399,6 @@
1414 end if
1415
1416 end subroutine add_diffusivity_face_cg
1417-
1418- subroutine addto_rhs_extra_discretised_source(rhs, extra_discretised_source)
1419- type(scalar_field), intent(inout) :: rhs
1420- type(scalar_field), intent(in),optional :: extra_discretised_source
1421-
1422- ! include the already discretised source into rhs
1423- add_extra_source: if (present(extra_discretised_source)) then
1424-
1425- ! assert that the rhs and extra_discretised_source have the same mesh
1426- assert(trim(rhs%mesh%name) == trim(extra_discretised_source%mesh%name))
1427-
1428- call addto(rhs, extra_discretised_source)
1429-
1430- end if add_extra_source
1431-
1432- end subroutine addto_rhs_extra_discretised_source
1433
1434 subroutine solve_advection_diffusion_cg(t, delta_t, matrix, rhs, state, iterations_taken)
1435 type(scalar_field), intent(in) :: t
1436
1437=== modified file 'assemble/Advection_Diffusion_DG.F90'
1438--- assemble/Advection_Diffusion_DG.F90 2011-10-19 10:46:35 +0000
1439+++ assemble/Advection_Diffusion_DG.F90 2012-10-16 13:22:44 +0000
1440@@ -52,7 +52,14 @@
1441 use sparse_matrices_fields
1442 use sparsity_patterns_meshes
1443 use diagnostic_fields, only: calculate_diagnostic_variable
1444- use global_parameters, only : FIELD_NAME_LEN
1445+ use global_parameters, only: OPTION_PATH_LEN, FIELD_NAME_LEN, COLOURING_DG2, &
1446+ COLOURING_DG0
1447+ use porous_media
1448+ use colouring
1449+ use Profiler
1450+#ifdef _OPENMP
1451+ use omp_lib
1452+#endif
1453
1454 implicit none
1455
1456@@ -96,12 +103,15 @@
1457 ! Boundary condition types:
1458 ! (the numbers should match up with the order in the
1459 ! get_entire_boundary_condition call)
1460- integer :: BCTYPE_WEAKDIRICHLET=1, BCTYPE_DIRICHLET=2
1461+ integer :: BCTYPE_WEAKDIRICHLET=1, BCTYPE_DIRICHLET=2, BCTYPE_NEUMANN=3
1462
1463 logical :: include_mass
1464 ! are we moving the mesh?
1465 logical :: move_mesh
1466
1467+ ! Include porosity?
1468+ logical :: include_porosity
1469+
1470 ! Stabilisation schemes.
1471 integer :: stabilisation_scheme
1472 integer, parameter :: NONE=0
1473@@ -133,6 +143,7 @@
1474 logical :: on_sphere
1475 ! Vertical diffusion by mixing option
1476 logical :: have_buoyancy_adjustment_by_vertical_diffusion
1477+ logical :: have_buoyancy_adjustment_diffusivity
1478
1479 contains
1480
1481@@ -483,6 +494,9 @@
1482
1483 character(len=FIELD_NAME_LEN) :: limiter_name
1484 integer :: i
1485+
1486+ !! Courant number field name used for temporal subcycling
1487+ character(len=FIELD_NAME_LEN) :: Courant_number_name
1488
1489 T=>extract_scalar_field(state, field_name)
1490 T_old=>extract_scalar_field(state, "Old"//field_name)
1491@@ -521,10 +535,12 @@
1492 call allocate(rhs_diff, T%mesh, trim(field_name)//" Diffusion RHS")
1493
1494 call construct_advection_diffusion_dg(matrix, rhs, field_name, state, &
1495- mass, matrix_diff, rhs_diff, semidiscrete=.true., &
1496+ mass=mass, diffusion_m=matrix_diff, diffusion_rhs=rhs_diff, semidiscrete=.true., &
1497 velocity_name=velocity_name)
1498
1499- call get_dg_inverse_mass_matrix(inv_mass, mass)
1500+ ! mass has only been assembled only for owned elements, so we can only compute
1501+ ! its inverse for owned elements
1502+ call get_dg_inverse_mass_matrix(inv_mass, mass, only_owned_elements=.true.)
1503
1504 ! Note that since theta and dt are module global, these lines have to
1505 ! come after construct_advection_diffusion_dg.
1506@@ -543,9 +559,17 @@
1507 &"/prognostic/temporal_discretisation/discontinuous_galerkin"//&
1508 &"/maximum_courant_number_per_subcycle", Max_Courant_number)
1509
1510- s_field => extract_scalar_field(state, "DG_CourantNumber")
1511- call calculate_diagnostic_variable(state, "DG_CourantNumber", &
1512- & s_field)
1513+ ! Determine the courant field to use to find the max
1514+ call get_option(trim(T%option_path)//&
1515+ &"/prognostic/temporal_discretisation/discontinuous_galerkin"//&
1516+ &"/maximum_courant_number_per_subcycle/courant_number/name", &
1517+ &Courant_number_name, default="DG_CourantNumber")
1518+
1519+ s_field => extract_scalar_field(state, trim(Courant_number_name))
1520+ call calculate_diagnostic_variable(state, trim(Courant_number_name), &
1521+ & s_field, option_path=trim(T%option_path)//&
1522+ &"/prognostic/temporal_discretisation/discontinuous_galerkin"//&
1523+ &"/courant_number")
1524
1525 subcycles = ceiling( maxval(s_field%val)/Max_Courant_number)
1526 call allmax(subcycles)
1527@@ -714,6 +738,22 @@
1528 integer, dimension(:), allocatable :: bc_type
1529
1530 type(mesh_type), pointer :: mesh_cg
1531+
1532+ ! Porosity field
1533+ type(scalar_field) :: porosity_theta
1534+
1535+ !! Add the Source directly to the right hand side?
1536+ logical :: add_src_directly_to_rhs
1537+
1538+
1539+ type(integer_set), dimension(:), pointer :: colours
1540+ integer :: len, clr, nnid
1541+ !! Is the transform_to_physical cache we prepopulated valid
1542+ logical :: cache_valid
1543+ integer :: num_threads
1544+
1545+ !! Diffusivity to add due to the buoyancy adjustment by vertical mixing scheme
1546+ type(scalar_field) :: buoyancy_adjustment_diffusivity
1547
1548 ewrite(1,*) "Writing advection-diffusion equation for "&
1549 &//trim(field_name)
1550@@ -797,9 +837,19 @@
1551 call allocate(Source, T%mesh, trim(field_name)//"Source",&
1552 FIELD_TYPE_CONSTANT)
1553 call zero(Source)
1554+
1555+ add_src_directly_to_rhs = .false.
1556 else
1557 ! Grab an extra reference to cause the deallocate below to be safe.
1558 call incref(Source)
1559+
1560+ add_src_directly_to_rhs = have_option(trim(Source%option_path)//'/diagnostic/add_directly_to_rhs')
1561+
1562+ if (add_src_directly_to_rhs) then
1563+ ewrite(2, *) "Adding Source field directly to the right hand side"
1564+ assert(node_count(Source) == node_count(T))
1565+ end if
1566+
1567 end if
1568
1569 Absorption=extract_scalar_field(state, trim(field_name)//"Absorption"&
1570@@ -825,6 +875,18 @@
1571 include_advection=.true.
1572 end if
1573
1574+ ! Porosity
1575+ if (have_option(trim(T%option_path)//'/prognostic/porosity')) then
1576+ include_porosity = .true.
1577+
1578+ ! get the porosity theta averaged field - this will allocate it
1579+ call form_porosity_theta(porosity_theta, state, option_path = trim(T%option_path)//'/prognostic/porosity')
1580+ else
1581+ include_porosity = .false.
1582+ call allocate(porosity_theta, T%mesh, field_type=FIELD_TYPE_CONSTANT)
1583+ call set(porosity_theta, 1.0)
1584+ end if
1585+
1586 ! Retrieve scalar options from the options dictionary.
1587 if (.not.semi_discrete) then
1588 call get_option(trim(T%option_path)//&
1589@@ -842,6 +904,9 @@
1590
1591 move_mesh = (have_option("/mesh_adaptivity/mesh_movement").and.include_mass)
1592 if(move_mesh) then
1593+ if (include_porosity) then
1594+ FLExit('Cannot include porosity in DG advection diffusion of a field with a moving mesh')
1595+ end if
1596 ewrite(2,*) 'Moving mesh'
1597 X_old => extract_vector_field(state, "OldCoordinate")
1598 X_new => extract_vector_field(state, "IteratedCoordinate")
1599@@ -875,7 +940,9 @@
1600 ! BCTYPE_WEAKDIRICHLET=1)
1601 allocate( bc_type(1:surface_element_count(T)) )
1602 call get_entire_boundary_condition(T, &
1603- & (/"weakdirichlet"/), &
1604+ & (/"weakdirichlet", &
1605+ & "dirichlet ", &
1606+ & "neumann "/), &
1607 & bc_value, bc_type)
1608
1609 call zero(big_m)
1610@@ -884,7 +951,8 @@
1611 if (present(diffusion_m)) call zero(diffusion_m)
1612 if (present(diffusion_RHS)) call zero(diffusion_RHS)
1613 if (have_buoyancy_adjustment_by_vertical_diffusion) then
1614- if (have_option(trim(T%option_path)//"/prognostic/buoyancy_adjustment"&
1615+ ewrite(3,*) "Buoyancy adjustment by vertical mixing: enabled"
1616+ if (have_option(trim(T%option_path)//"/prognostic/buoyancy_adjustment"//&
1617 &"/by_vertical_diffusion/project_buoyancy_to_continuous_space")) then
1618 buoyancy_from_state = extract_scalar_field(state, "VelocityBuoyancyDensity", stat)
1619 if (stat/=0) FLAbort('Error extracting buoyancy field.')
1620@@ -895,7 +963,9 @@
1621 ! Grab an extra reference to cause the deallocate below to be safe.
1622 ! Check this is OK
1623 call lumped_mass_galerkin_projection_scalar(state, buoyancy, buoyancy_from_state)
1624+ ewrite(3,*) "Buoyancy adjustment by vertical mixing: projecting to continuous space"
1625 else
1626+ ewrite(3,*) "Buoyancy adjustment by vertical mixing: no projection"
1627 buoyancy = extract_scalar_field(state, "VelocityBuoyancyDensity", stat)
1628 if (stat/=0) FLAbort('Error extracting buoyancy field.')
1629 call incref(buoyancy)
1630@@ -915,16 +985,64 @@
1631 end if
1632 ! Set direction of mixing diffusion, default is in the y- and z-direction for 2- and 3-d spaces respectively
1633 ! TODO: Align this direction with gravity local to an element
1634- end if
1635-
1636- element_loop: do ELE=1,element_count(T)
1637-
1638+
1639+ ! Check if the diagnostic associated with the buoyancy adjustment by vertical mixing scheme is required
1640+ buoyancy_adjustment_diffusivity = extract_scalar_field(state, "BuoyancyAdjustmentDiffusivity", stat)
1641+ if (stat==0) then
1642+ have_buoyancy_adjustment_diffusivity = .true.
1643+ ewrite(3,*) "Buoynacy adjustment by vertical mixing: Updating BuoyancyAdjustmentDiffusivity field."
1644+ else
1645+ have_buoyancy_adjustment_diffusivity = .false.
1646+ end if
1647+
1648+ end if
1649+
1650+ if (include_diffusion) then
1651+ call get_mesh_colouring(state, T%mesh, COLOURING_DG2, colours)
1652+#ifdef _OPENMP
1653+ if(diffusion_scheme == MASSLUMPED_RT0) then
1654+ call omp_set_num_threads(1)
1655+ ewrite(1,*) "WARNING: hybrid assembly can't support The MASSLUMPED_RT0 scheme yet, &
1656+ set threads back to 1"
1657+ endif
1658+#endif
1659+ else
1660+ call get_mesh_colouring(state, T%mesh, COLOURING_DG0, colours)
1661+ end if
1662+
1663+#ifdef _OPENMP
1664+ cache_valid = prepopulate_transform_cache(X)
1665+ assert(cache_valid)
1666+#endif
1667+
1668+ call profiler_tic(t, "advection_diffusion_dg_loop")
1669+
1670+ !$OMP PARALLEL DEFAULT(SHARED) &
1671+ !$OMP PRIVATE(clr, nnid, ele, len)
1672+
1673+ colour_loop: do clr = 1, size(colours)
1674+ len = key_count(colours(clr))
1675+
1676+ !$OMP DO SCHEDULE(STATIC)
1677+ element_loop: do nnid = 1, len
1678+ ele = fetch(colours(clr), nnid)
1679 call construct_adv_diff_element_dg(ele, big_m, rhs, big_m_diff,&
1680 & rhs_diff, X, X_old, X_new, T, U_nl, U_mesh, Source, &
1681- Absorption, Diffusivity, bc_value, bc_type, q_mesh, mass, &
1682- & buoyancy, gravity, gravity_magnitude, mixing_diffusion_amplitude)
1683+ & Absorption, Diffusivity, bc_value, bc_type, q_mesh, mass, &
1684+ & buoyancy, gravity, gravity_magnitude, mixing_diffusion_amplitude, &
1685+ & buoyancy_adjustment_diffusivity, &
1686+ & add_src_directly_to_rhs, porosity_theta)
1687
1688- end do element_loop
1689+ end do element_loop
1690+ !$OMP END DO
1691+
1692+ end do colour_loop
1693+ !$OMP END PARALLEL
1694+
1695+ call profiler_toc(t, "advection_diffusion_dg_loop")
1696+ ! Add the source directly to the rhs if required
1697+ ! which must be included before dirichlet BC's.
1698+ if (add_src_directly_to_rhs) call addto(rhs, Source)
1699
1700 ! Drop any extra field references.
1701 if (have_buoyancy_adjustment_by_vertical_diffusion) call deallocate(buoyancy)
1702@@ -934,7 +1052,8 @@
1703 call deallocate(U_nl)
1704 call deallocate(U_nl_backup)
1705 call deallocate(bc_value)
1706-
1707+ call deallocate(porosity_theta)
1708+
1709 end subroutine construct_advection_diffusion_dg
1710
1711 subroutine lumped_mass_galerkin_projection_scalar(state, field, projected_field)
1712@@ -1023,14 +1142,13 @@
1713
1714 end subroutine lumped_mass_galerkin_projection_scalar
1715
1716-
1717-
1718-
1719- subroutine construct_adv_diff_element_dg(ele, big_m, rhs, big_m_diff,&
1720+ subroutine construct_adv_diff_element_dg(ele, big_m, rhs, big_m_diff,&
1721 & rhs_diff, &
1722 & X, X_old, X_new, T, U_nl, U_mesh, Source, Absorption, Diffusivity,&
1723 & bc_value, bc_type, &
1724- & q_mesh, mass, buoyancy, gravity, gravity_magnitude, mixing_diffusion_amplitude)
1725+ & q_mesh, mass, buoyancy, gravity, gravity_magnitude, mixing_diffusion_amplitude, &
1726+ & buoyancy_adjustment_diffusivity, &
1727+ & add_src_directly_to_rhs, porosity_theta)
1728 !!< Construct the advection_diffusion equation for discontinuous elements in
1729 !!< acceleration form.
1730 implicit none
1731@@ -1058,6 +1176,16 @@
1732 !! Diffusivity
1733 type(tensor_field), intent(in) :: Diffusivity
1734
1735+ !! Diffusivity to add due to the buoyancy adjustment by vertical mixing scheme
1736+ type(scalar_field), intent(inout) :: buoyancy_adjustment_diffusivity
1737+
1738+ !! If adding Source directly to rhs then
1739+ !! do nothing with it here
1740+ logical, intent(in) :: add_src_directly_to_rhs
1741+
1742+ !! Porosity theta averaged field
1743+ type(scalar_field), intent(in) :: porosity_theta
1744+
1745 !! Flag for a periodic boundary
1746 logical :: Periodic_neigh
1747
1748@@ -1203,15 +1331,16 @@
1749 assert(ele_loc(U_mesh, ele)==ele_loc(X, ele))
1750 assert(ele_ngi(U_mesh, ele)==ele_ngi(U_nl, ele))
1751 end if
1752-
1753+
1754 dg=continuity(T)<0
1755 primal = .not.dg
1756 if(diffusion_scheme == CDG) primal = .true.
1757 if(diffusion_scheme == IP) primal =.true.
1758
1759- ! In parallel, we only construct the equations on elements we own.
1760+ ! In parallel, we only construct the equations on elements we own, or
1761+ ! those in the L1 halo.
1762 if (dg) then
1763- if (.not.element_owned(T,ele)) then
1764+ if (.not.(element_owned(T, ele).or.element_neighbour_owned(T, ele))) then
1765 return
1766 end if
1767 end if
1768@@ -1318,12 +1447,18 @@
1769 &* gravity_magnitude * dr**2 * gravity_at_node(i) * drho_dz(:)
1770 end do
1771 end if
1772-
1773- !ewrite(3,*) "mixing_density_values", buoyancysample
1774- ewrite(3,*) "mixing_grad_rho", minval(grad_rho(:,:)), maxval(grad_rho(:,:))
1775- ewrite(3,*) "mixing_drho_dz", minval(drho_dz(:)), maxval(drho_dz(:))
1776- ewrite(3,*) "mixing_coeffs amp dt g dr", mixing_diffusion_amplitude, dt, gravity_magnitude, dr**2
1777- ewrite(3,*) "mixing_diffusion", minval(mixing_diffusion(2,2,:)), maxval(mixing_diffusion(2,2,:))
1778+
1779+ if(have_buoyancy_adjustment_diffusivity) then
1780+ call set(buoyancy_adjustment_diffusivity, T_ele, mixing_diffusion_amplitude * dt&
1781+ &* gravity_magnitude * dr**2 * maxval(drho_dz(:)))
1782+ ewrite(4,*) "Buoynacy adjustment diffusivity, ele:", ele, "diffusivity:", mixing_diffusion_amplitude * dt * gravity_magnitude * dr**2 * maxval(drho_dz(:))
1783+ end if
1784+
1785+ !! Buoyancy adjustment by vertical mixing scheme debugging statements
1786+ ewrite(4,*) "mixing_grad_rho", minval(grad_rho(:,:)), maxval(grad_rho(:,:))
1787+ ewrite(4,*) "mixing_drho_dz", minval(drho_dz(:)), maxval(drho_dz(:))
1788+ ewrite(4,*) "mixing_coeffs amp dt g dr", mixing_diffusion_amplitude, dt, gravity_magnitude, dr**2
1789+ ewrite(4,*) "mixing_diffusion", minval(mixing_diffusion(2,2,:)), maxval(mixing_diffusion(2,2,:))
1790
1791 mixing_diffusion_rhs=shape_tensor_rhs(T%mesh%shape, mixing_diffusion, detwei_rho)
1792 t_mass=shape_shape(T%mesh%shape, T%mesh%shape, detwei_rho)
1793@@ -1352,7 +1487,12 @@
1794 if(move_mesh) then
1795 mass_mat = shape_shape(T_shape, T_shape, detwei_new)
1796 else
1797- mass_mat = shape_shape(T_shape, T_shape, detwei)
1798+ if (include_porosity) then
1799+ assert(ele_ngi(T, ele)==ele_ngi(porosity_theta, ele))
1800+ mass_mat = shape_shape(T_shape, T_shape, detwei*ele_val_at_quad(porosity_theta, ele))
1801+ else
1802+ mass_mat = shape_shape(T_shape, T_shape, detwei)
1803+ end if
1804 end if
1805
1806 if (include_advection) then
1807@@ -1513,9 +1653,11 @@
1808 end if
1809
1810 ! Source term
1811- l_T_rhs=l_T_rhs &
1812- + shape_rhs(T_shape, detwei*ele_val_at_quad(Source, ele))
1813-
1814+ if (.not. add_src_directly_to_rhs) then
1815+ l_T_rhs=l_T_rhs &
1816+ + shape_rhs(T_shape, detwei*ele_val_at_quad(Source, ele))
1817+ end if
1818+
1819 if(move_mesh) then
1820 l_T_rhs=l_T_rhs &
1821 -shape_rhs(T_shape, ele_val_at_quad(t, ele)*(detwei_new-detwei_old)/dt)
1822@@ -1627,7 +1769,7 @@
1823 if(primal) then
1824 call construct_adv_diff_interface_dg(ele, face, face_2, ni,&
1825 & centre_vec,&
1826- & big_m, rhs, Grad_T_mat, Div_T_mat, X, T, U_nl,&
1827+ & big_m, rhs, rhs_diff, Grad_T_mat, Div_T_mat, X, T, U_nl,&
1828 & bc_value, bc_type, &
1829 & U_mesh, q_mesh, cdg_switch_in, &
1830 & primal_fluxes_mat, ele2grad_mat,diffusivity, &
1831@@ -1646,7 +1788,7 @@
1832 else
1833 call construct_adv_diff_interface_dg(ele, face, face_2, ni,&
1834 & centre_vec,&
1835- & big_m, rhs, Grad_T_mat, Div_T_mat, X, T, U_nl,&
1836+ & big_m, rhs, rhs_diff, Grad_T_mat, Div_T_mat, X, T, U_nl,&
1837 & bc_value, bc_type, &
1838 & U_mesh, q_mesh)
1839 end if
1840@@ -1716,18 +1858,18 @@
1841 finish=start+face_loc(T, face)-1
1842
1843 if (i==1) then
1844- ! Wipe out boundary condition's coupling to itself.
1845- Diffusivity_mat(start:finish,:)=0.0
1846+ ! Wipe out boundary condition's coupling to itself.
1847+ Diffusivity_mat(start:finish,:)=0.0
1848 else
1849
1850- ! Add BC into RHS
1851- !
1852- call addto(RHS_diff, local_glno, &
1853- & -matmul(Diffusivity_mat(:,start:finish), &
1854- & ele_val( bc_value, face )))
1855-
1856- ! Ensure it is not used again.
1857- Diffusivity_mat(:,start:finish)=0.0
1858+ ! Add BC into RHS
1859+ !
1860+ call addto(RHS_diff, local_glno, &
1861+ & -matmul(Diffusivity_mat(:,start:finish), &
1862+ & ele_val( bc_value, face )))
1863+
1864+ ! Ensure it is not used again.
1865+ Diffusivity_mat(:,start:finish)=0.0
1866
1867 end if
1868
1869@@ -1753,7 +1895,7 @@
1870 if (include_diffusion.or.have_buoyancy_adjustment_by_vertical_diffusion) then
1871 call addto(Big_m_diff, local_glno, local_glno,&
1872 & Diffusivity_mat*theta*dt)
1873-
1874+
1875 if (.not.semi_discrete) then
1876 call addto(RHS_diff, local_glno, &
1877 & -matmul(Diffusivity_mat, node_val(T, local_glno)))
1878@@ -2211,7 +2353,7 @@
1879 end subroutine construct_adv_diff_element_dg
1880
1881 subroutine construct_adv_diff_interface_dg(ele, face, face_2, &
1882- ni, centre_vec,big_m, rhs, Grad_T_mat, Div_T_mat, &
1883+ ni, centre_vec,big_m, rhs, rhs_diff, Grad_T_mat, Div_T_mat, &
1884 & X, T, U_nl,&
1885 & bc_value, bc_type, &
1886 & U_mesh, q_mesh, CDG_switch_in, &
1887@@ -2224,7 +2366,7 @@
1888
1889 integer, intent(in) :: ele, face, face_2, ni
1890 type(csr_matrix), intent(inout) :: big_m
1891- type(scalar_field), intent(inout) :: rhs
1892+ type(scalar_field), intent(inout) :: rhs, rhs_diff
1893 real, dimension(:,:,:), intent(inout) :: Grad_T_mat, Div_T_mat
1894 ! We pass these additional fields to save on state lookups.
1895 type(vector_field), intent(in) :: X, U_nl
1896@@ -2275,7 +2417,7 @@
1897 real, dimension(:,:,:), allocatable :: kappa_gi
1898
1899 integer :: dim, start, finish
1900- logical :: boundary, dirichlet
1901+ logical :: boundary, dirichlet, neumann
1902
1903 logical :: do_primal_fluxes
1904
1905@@ -2318,9 +2460,12 @@
1906 ! Boundary nodes have both faces the same.
1907 boundary=(face==face_2)
1908 dirichlet=.false.
1909+ neumann=.false.
1910 if (boundary) then
1911 if (bc_type(face)==BCTYPE_WEAKDIRICHLET) then
1912 dirichlet=.true.
1913+ elseif (bc_type(face)==BCTYPE_NEUMANN) then
1914+ neumann=.true.
1915 end if
1916 end if
1917
1918@@ -2504,13 +2649,13 @@
1919 end if
1920
1921 ! Insert advection in RHS.
1922-
1923+
1924 if (.not.dirichlet) then
1925 ! For interior interfaces this is the upwinding term. For a Neumann
1926 ! boundary it's necessary to apply downwinding here to maintain the
1927 ! surface integral. Fortunately, since face_2==face for a boundary
1928 ! this is automagic.
1929-
1930+
1931 if (.not.semi_discrete) then
1932 call addto(RHS, T_face, &
1933 ! Outflow boundary integral.
1934@@ -2525,7 +2670,7 @@
1935 call addto(RHS, T_face, &
1936 -matmul(nnAdvection_in,&
1937 ele_val(bc_value, face)))
1938-
1939+
1940 if(.not.semi_discrete) then
1941 ! The interior integral is still interior!
1942 call addto(RHS, T_face, &
1943@@ -2533,9 +2678,14 @@
1944 end if
1945
1946 end if
1947-
1948+
1949 end if
1950
1951+ ! Add non-zero contributions from Neumann boundary conditions (if present)
1952+ if (neumann) then
1953+ call addto(RHS_diff, T_face, shape_rhs(T_shape, detwei * ele_val_at_quad(bc_value, face)))
1954+ end if
1955+
1956 contains
1957
1958 subroutine arbitrary_upwind_diffusion
1959
1960=== modified file 'assemble/Advection_Diffusion_FV.F90'
1961--- assemble/Advection_Diffusion_FV.F90 2011-04-22 17:28:48 +0000
1962+++ assemble/Advection_Diffusion_FV.F90 2012-10-16 13:22:44 +0000
1963@@ -45,8 +45,12 @@
1964 use spud
1965 use field_options
1966 use sparsity_patterns_meshes
1967- use global_parameters, only : FIELD_NAME_LEN, OPTION_PATH_LEN
1968+ use global_parameters, only : FIELD_NAME_LEN, OPTION_PATH_LEN, COLOURING_DG1
1969 use profiler
1970+ use colouring
1971+#ifdef _OPENMP
1972+ use omp_lib
1973+#endif
1974
1975 implicit none
1976
1977@@ -59,6 +63,8 @@
1978 logical :: have_advection
1979 ! Source?
1980 logical :: have_source
1981+ ! Add source directly to the right hand side?
1982+ logical :: add_src_directly_to_rhs
1983 ! Absorption?
1984 logical :: have_absorption
1985 ! Diffusivity?
1986@@ -138,7 +144,7 @@
1987 type(scalar_field), intent(inout) :: t
1988 type(csr_matrix), intent(inout) :: matrix
1989 type(scalar_field), intent(inout) :: rhs
1990- type(state_type), intent(in) :: state
1991+ type(state_type), intent(inout) :: state
1992
1993 type(vector_field), pointer :: coordinate, &
1994 old_coordinate, new_coordinate, &
1995@@ -147,7 +153,14 @@
1996 type(scalar_field), pointer :: source, absorption
1997 type(tensor_field), pointer :: diffusivity
1998
1999- integer :: i, j, ele, stat
2000+ integer :: i, j, stat
2001+
2002+ !! Coloring data structures for OpenMP parallization
2003+ type(integer_set), dimension(:), pointer :: colours
2004+ integer :: clr, nnid, len, ele
2005+ integer :: thread_num
2006+ !! Did we successfully prepopulate the transform_to_physical_cache?
2007+ logical :: cache_valid
2008
2009 ewrite(1,*) "In assemble_advection_diffusion_fv"
2010
2011@@ -160,10 +173,19 @@
2012 if(have_source) then
2013 assert(mesh_dim(source) == mesh_dim(t))
2014 assert(ele_count(source) == ele_count(t))
2015+
2016+ add_src_directly_to_rhs = have_option(trim(source%option_path)//'/diagnostic/add_directly_to_rhs')
2017+
2018+ if (add_src_directly_to_rhs) then
2019+ ewrite(2, *) "Adding Source field directly to the right hand side"
2020+ assert(node_count(source) == node_count(t))
2021+ end if
2022
2023 ewrite_minmax(source)
2024 else
2025 ewrite(2,*) 'No source'
2026+
2027+ add_src_directly_to_rhs = .false.
2028 end if
2029
2030 ! Absorption
2031@@ -250,11 +272,45 @@
2032 call zero(matrix)
2033 call zero(rhs)
2034
2035- do ele = 1, ele_count(t)
2036- call assemble_advection_diffusion_element_fv(ele, t, matrix, rhs, &
2037+
2038+#ifdef _OPENMP
2039+ cache_valid = prepopulate_transform_cache(coordinate)
2040+ assert(cache_valid)
2041+#endif
2042+
2043+ call get_mesh_colouring(state, T%mesh, COLOURING_DG1, colours)
2044+
2045+ call profiler_tic(t, "advection_diffusion_fv_loop")
2046+
2047+ !$OMP PARALLEL DEFAULT(SHARED) &
2048+ !$OMP PRIVATE(clr, len, nnid, ele, thread_num)
2049+
2050+#ifdef _OPENMP
2051+ thread_num = omp_get_thread_num()
2052+#else
2053+ thread_num=0
2054+#endif
2055+
2056+
2057+ colour_loop: do clr = 1, size(colours)
2058+ len = key_count(colours(clr))
2059+ !$OMP DO SCHEDULE(STATIC)
2060+ element_loop: do nnid = 1, len
2061+ ele = fetch(colours(clr), nnid)
2062+ call assemble_advection_diffusion_element_fv(ele, t, matrix, rhs, &
2063 coordinate, t_coordinate, &
2064 source, absorption, diffusivity)
2065- end do
2066+ end do element_loop
2067+ !$OMP END DO
2068+
2069+ end do colour_loop
2070+ !$OMP END PARALLEL
2071+
2072+ call profiler_toc(t, "advection_diffusion_fv_loop")
2073+
2074+ ! Add the source directly to the rhs if required
2075+ ! which must be included before dirichlet BC's.
2076+ if (add_src_directly_to_rhs) call addto(rhs, source)
2077
2078 ewrite(2, *) "Applying strong Dirichlet boundary conditions"
2079 call apply_dirichlet_conditions(matrix, rhs, t, dt)
2080@@ -314,7 +370,9 @@
2081 if(have_absorption) call add_absorption_element_fv(ele, t_shape, t, absorption, detwei, matrix_addto(:loc,:loc), rhs_addto(:loc))
2082
2083 ! Source
2084- if(have_source) call add_source_element_fv(ele, t_shape, t, source, detwei, rhs_addto(:loc))
2085+ if(have_source .and. (.not. add_src_directly_to_rhs)) then
2086+ call add_source_element_fv(ele, t_shape, t, source, detwei, rhs_addto(:loc))
2087+ end if
2088
2089 if(have_diffusivity.or.have_advection) then
2090
2091
2092=== modified file 'assemble/Assemble_CMC.F90'
2093--- assemble/Assemble_CMC.F90 2011-04-22 17:28:48 +0000
2094+++ assemble/Assemble_CMC.F90 2012-10-16 13:22:44 +0000
2095@@ -172,25 +172,28 @@
2096
2097 subroutine assemble_scaled_pressure_mass_matrix(state,scaled_pressure_mass_matrix)
2098
2099- ! This routine assembles the scaled_pressure_mass_matrix. It is scaled
2100- ! by the inverse of viscosity.
2101+ ! This routine assembles the scaled_pressure_mass_matrix at the
2102+ ! quadrature points. It is scaled by the inverse of viscosity.
2103
2104 type(state_type), intent(in) :: state
2105-
2106 ! Scaled pressure mass matrix - already allocated in Momentum_Eq:
2107 type(csr_matrix), intent(inout) :: scaled_pressure_mass_matrix
2108-
2109 ! Pressure field:
2110 type(scalar_field), pointer :: pressure
2111 ! Viscosity tensor:
2112 type(tensor_field), pointer :: viscosity
2113 ! Viscosity component:
2114 type(scalar_field) :: viscosity_component
2115- ! Inverse of Viscosity component
2116- type(scalar_field) :: inverse_viscosity_component
2117 ! Positions:
2118 type(vector_field), pointer :: positions
2119-
2120+
2121+ ! Relevant declerations for mass matrix calculation:
2122+ integer :: ele
2123+ real, dimension(:), allocatable :: detwei
2124+ type(element_type), pointer :: p_shape
2125+ real, dimension(:,:), allocatable :: mass_matrix
2126+ real, dimension(:), allocatable :: mu_gi
2127+
2128 ewrite(1,*) 'Entering assemble_scaled_pressure_mass_matrix'
2129
2130 ! Positions:
2131@@ -205,20 +208,24 @@
2132 ! Extract first component of viscosity tensor from full tensor:
2133 viscosity_component = extract_scalar_field(viscosity,1,1)
2134
2135- ! Allocate memory for inverse viscosity component scalar field:
2136- call allocate(inverse_viscosity_component, viscosity_component%mesh, name="inverse_viscosity_component")
2137-
2138- ! Invert viscosity:
2139- call invert(viscosity_component,inverse_viscosity_component)
2140-
2141- ! Compute pressure mass matrix, scaled by inverse viscosity - note that the
2142- ! inverse viscosity is supplied as density here:
2143- call compute_mass(positions,pressure%mesh,scaled_pressure_mass_matrix,density=inverse_viscosity_component)
2144+ ! Initialise and assemble scaled pressure mass matrix:
2145+ allocate(detwei(ele_ngi(pressure, 1)), &
2146+ mass_matrix(ele_loc(pressure, 1), ele_loc(pressure, 1)), &
2147+ mu_gi(ele_ngi(viscosity_component, 1)))
2148+
2149+ call zero(scaled_pressure_mass_matrix)
2150+ do ele = 1, ele_count(pressure)
2151+ p_shape => ele_shape(pressure, ele)
2152+ mu_gi = ele_val_at_quad(viscosity_component, ele)
2153+ call transform_to_physical(positions, ele, detwei=detwei)
2154+ mass_matrix = shape_shape(p_shape, p_shape, detwei/mu_gi)
2155+ call addto(scaled_pressure_mass_matrix, ele_nodes(pressure, ele),&
2156+ ele_nodes(pressure, ele), mass_matrix)
2157+ end do
2158
2159 ewrite_minmax(scaled_pressure_mass_matrix)
2160
2161- ! Deallocate inverse viscosity component scalar field:
2162- call deallocate(inverse_viscosity_component)
2163+ deallocate(detwei, mass_matrix, mu_gi)
2164
2165 end subroutine assemble_scaled_pressure_mass_matrix
2166
2167
2168=== modified file 'assemble/Biology.F90'
2169--- assemble/Biology.F90 2011-10-19 17:55:20 +0000
2170+++ assemble/Biology.F90 2012-10-16 13:22:44 +0000
2171@@ -39,6 +39,9 @@
2172 use solvers
2173 use python_state
2174 use sparsity_patterns_meshes
2175+ use fefields
2176+ use field_options
2177+
2178 implicit none
2179
2180 private
2181@@ -66,6 +69,14 @@
2182 type(state_type), intent(inout) :: state
2183
2184 character(len=OPTION_PATH_LEN) :: prefix, algorithm
2185+ ! This is the photosynthetic radiation projected onto the
2186+ ! same mesh as the biology fields
2187+ ! It also takes into account the "active" part of the solar radiation
2188+ type(scalar_field) :: par_bio
2189+ ! we use the phytoplankton as the "bio" mesh
2190+ type(scalar_field), pointer :: phytoplankton, PhotosyntheticRadiation
2191+ type(vector_field) :: coords
2192+ integer :: stat
2193
2194 call backup_source_terms(state)
2195
2196@@ -91,6 +102,24 @@
2197 ! Calculate the light field at every point.
2198 call solve_light_equation(state, prefix)
2199
2200+ par_bio = extract_scalar_field(state, "_PAR", stat)
2201+ phytoplankton => extract_scalar_field(state, "Phytoplankton")
2202+ if (stat /= 0) then
2203+ ! field does not yet exist: create it
2204+ call allocate(par_bio,phytoplankton%mesh, name="_PAR")
2205+ call zero(par_bio)
2206+ call insert(state, par_bio, par_bio%name)
2207+ call deallocate(par_bio)
2208+ par_bio = extract_scalar_field(state, "_PAR", stat)
2209+ end if
2210+ PhotosyntheticRadiation => extract_scalar_field(state, "PhotosyntheticRadiation")
2211+ coords = get_coordinate_field(state, par_bio%mesh)
2212+ ! project the Photosynthetic radaition field onto the _PAR field
2213+ call project_field(PhotosyntheticRadiation, par_bio, coords)
2214+ ! scale it to get the active part
2215+ call scale(par_bio, 0.43)
2216+ call deallocate(coords)
2217+
2218 ! Calculate the sources and sinks at every point.
2219 call calculate_biology_from_python(state, prefix, algorithm)
2220
2221@@ -210,13 +239,9 @@
2222 g=extract_vector_field(state, "GravityDirection")
2223 light=extract_scalar_field(state, "PhotosyntheticRadiation")
2224 P=extract_scalar_field(state, "Phytoplankton")
2225-
2226- if(continuity(light)<0) then
2227- ! could be cleverer with this and check if diffusion is assembled
2228- sparsity=>get_csr_sparsity_secondorder(state, light%mesh, light%mesh)
2229- else
2230- sparsity=>get_csr_sparsity_firstorder(state, light%mesh, light%mesh)
2231- end if
2232+
2233+ ! Only need first order sparsity as we have no diffusion
2234+ sparsity=>get_csr_sparsity_firstorder(state, light%mesh, light%mesh)
2235
2236 call get_option(trim(light%option_path)//&
2237 "/prognostic/absorption_coefficients/water", k_w)
2238@@ -369,23 +394,22 @@
2239 ! External face.
2240 face_2=face
2241 end if
2242-
2243- call construct_light_interface(ele, ele_2, face, face_2, ni,&
2244+
2245+ call construct_light_interface(face, face_2,&
2246 & light_mat, rhs, X, g, light, &
2247 & bc_value, bc_type)
2248-
2249 end do neighbourloop
2250
2251 end subroutine construct_light_element
2252
2253- subroutine construct_light_interface(ele, ele_2, face, face_2, ni,&
2254+ subroutine construct_light_interface(face, face_2,&
2255 & light_mat, rhs, X, g, light, bc_value, bc_type)
2256 !!< Construct the element boundary integrals on the ni-th face of
2257 !!< element ele. For continuous discretisation, this is only boundary
2258 !!< faces. For DG it's all of them.
2259 implicit none
2260
2261- integer, intent(in) :: ele, ele_2, face, face_2, ni
2262+ integer, intent(in) :: face, face_2
2263 type(csr_matrix), intent(inout) :: light_mat
2264 type(scalar_field), intent(inout) :: rhs
2265 ! We pass these additional fields to save on state lookups.
2266@@ -399,7 +423,7 @@
2267
2268 ! Face objects and numberings.
2269 type(element_type), pointer ::l_shape, l_shape_2
2270- integer, dimension(face_loc(light,face)) :: l_face, l_face_l
2271+ integer, dimension(face_loc(light,face)) :: l_face
2272 integer, dimension(face_loc(light,face_2)) :: l_face_2
2273
2274 ! Note that both sides of the face can be assumed to have the same
2275@@ -428,7 +452,7 @@
2276 ! Boundary nodes have both faces the same.
2277 boundary=(face==face_2)
2278 dirichlet=.false.
2279- if (boundary) then
2280+ if (boundary .and. face < size(bc_type)) then
2281 if (bc_type(face)==BCTYPE_WEAKDIRICHLET) then
2282 dirichlet=.true.
2283 end if
2284
2285=== modified file 'assemble/Compressible_Projection.F90'
2286--- assemble/Compressible_Projection.F90 2011-07-18 17:11:34 +0000
2287+++ assemble/Compressible_Projection.F90 2012-10-16 13:22:44 +0000
2288@@ -36,9 +36,10 @@
2289 use field_options
2290 use equation_of_state, only: compressible_eos, compressible_material_eos
2291 use global_parameters, only: OPTION_PATH_LEN
2292- use fefields, only: compute_lumped_mass
2293+ use fefields, only: compute_cv_mass
2294 use state_fields_module
2295 use upwind_stabilisation
2296+ use multiphase_module
2297 implicit none
2298
2299 ! Buffer for output messages.
2300@@ -56,7 +57,10 @@
2301 integer :: nu_bar_scheme
2302 real :: nu_bar_scale
2303
2304-contains
2305+ !! Are we running a multiphase flow simulation?
2306+ logical :: multiphase
2307+
2308+ contains
2309
2310 subroutine assemble_compressible_projection_cv(state, cmc, rhs, dt, theta_pg, theta_divergence, cmcget)
2311
2312@@ -107,7 +111,7 @@
2313 type(scalar_field), pointer :: normalisation, &
2314 density, olddensity
2315 type(scalar_field), pointer :: pressure
2316- type(scalar_field), pointer :: p_lumpedmass
2317+ type(scalar_field), pointer :: p_cvmass
2318 type(scalar_field) :: lhsfield, invnorm, absrhs
2319
2320 type(scalar_field), pointer :: source, absorption
2321@@ -126,14 +130,10 @@
2322 call get_option(trim(pressure%option_path)//'/prognostic/atmospheric_pressure', &
2323 atmospheric_pressure, default=0.0)
2324
2325- if(pressure%mesh%shape%degree>1) then
2326- ! try lumping on the submesh
2327- p_lumpedmass => get_lumped_mass_on_submesh(state, pressure%mesh)
2328- else
2329- ! find the lumped mass
2330- p_lumpedmass => get_lumped_mass(state, pressure%mesh)
2331- end if
2332- ewrite_minmax(p_lumpedmass)
2333+ ! find the cv mass
2334+ p_cvmass => get_cv_mass(state, pressure%mesh)
2335+
2336+ ewrite_minmax(p_cvmass)
2337
2338 call get_option(trim(pressure%option_path)//"/prognostic/scheme/use_compressible_projection_method/normalisation/name", &
2339 normalisation_field, stat=norm_stat)
2340@@ -170,12 +170,12 @@
2341
2342 call get_option(trim(density%option_path)//"/prognostic/temporal_discretisation/theta", theta)
2343
2344- call set(lhsfield, p_lumpedmass)
2345+ call set(lhsfield, p_cvmass)
2346 call scale(lhsfield, drhodp)
2347 call scale(lhsfield, invnorm)
2348 call addto_diag(cmc, lhsfield, scale=1./(dt*dt*theta_divergence*theta_pg))
2349
2350-! rhs = invnorm*p_lumpedmass* &
2351+! rhs = invnorm*p_cvmass* &
2352 ! ( (1./dt)*(olddensity - density + drhodp*(eospressure - (pressure + atmospheric_pressure)))
2353 ! +(absorption)*(drhodp*theta_pg*(eospressure - (pressure + atmospheric_pressure)) - theta_pg*density - (1-theta_pg)*olddensity)
2354 ! +source)
2355@@ -215,7 +215,7 @@
2356 call addto_diag(cmc, lhsfield, scale=(theta/(dt*theta_divergence*theta_pg)))
2357 end if
2358
2359- call scale(rhs, p_lumpedmass)
2360+ call scale(rhs, p_cvmass)
2361 call scale(rhs, invnorm)
2362
2363 call deallocate(eospressure)
2364@@ -253,7 +253,7 @@
2365
2366 type(scalar_field), pointer :: pressure
2367 type(vector_field), pointer :: positions
2368- type(scalar_field) :: lumped_mass, tempfield
2369+ type(scalar_field) :: cv_mass, tempfield
2370
2371 real :: atmospheric_pressure
2372
2373@@ -274,9 +274,9 @@
2374 if(cmcget) then
2375
2376 positions=>extract_vector_field(state(1), "Coordinate")
2377- call allocate(lumped_mass, pressure%mesh, "LumpedMassField")
2378+ call allocate(cv_mass, pressure%mesh, "CVMassField")
2379 call allocate(tempfield, pressure%mesh, "TemporaryAssemblyField")
2380- call compute_lumped_mass(positions, lumped_mass)
2381+ call compute_cv_mass(positions, cv_mass)
2382
2383 allocate(dummy_ones)
2384 call allocate(dummy_ones, pressure%mesh, "DummyOnesField")
2385@@ -337,16 +337,16 @@
2386 end do
2387
2388 call zero(tempfield)
2389- tempfield%val = (1./(dt*dt))*lumped_mass%val*normdrhodp%val
2390+ tempfield%val = (1./(dt*dt))*cv_mass%val*normdrhodp%val
2391
2392 call addto_diag(cmc, tempfield)
2393
2394- rhs%val = (1./dt)*lumped_mass%val* &
2395+ rhs%val = (1./dt)*cv_mass%val* &
2396 ( &
2397 normolddensity%val &
2398 - normdensity%val &
2399 ) &
2400- +(1./dt)*lumped_mass%val* &
2401+ +(1./dt)*cv_mass%val* &
2402 ( &
2403 normmatdrhodpp%val &
2404 - normdrhodp%val*(pressure%val+atmospheric_pressure) &
2405@@ -360,7 +360,7 @@
2406 call deallocate(materialpressure)
2407 call deallocate(materialdrhodp)
2408
2409- call deallocate(lumped_mass)
2410+ call deallocate(cv_mass)
2411 call deallocate(tempfield)
2412 call deallocate(dummy_ones)
2413 deallocate(dummy_ones)
2414@@ -371,11 +371,12 @@
2415
2416 end subroutine assemble_mmat_compressible_projection_cv
2417
2418- subroutine assemble_compressible_projection_cg(state, cmc, rhs, dt, theta_pg, theta_divergence, cmcget)
2419+ subroutine assemble_compressible_projection_cg(state, istate, cmc, rhs, dt, theta_pg, theta_divergence, cmcget)
2420
2421 ! inputs:
2422 ! bucket full of fields
2423 type(state_type), dimension(:), intent(inout) :: state
2424+ integer, intent(in) :: istate
2425
2426 type(csr_matrix), intent(inout) :: cmc
2427 type(scalar_field), intent(inout) :: rhs
2428@@ -384,17 +385,25 @@
2429 real, intent(in) :: theta_pg, theta_divergence
2430 logical, intent(in) :: cmcget
2431
2432- if((size(state)==1).and.(.not.has_scalar_field(state(1), "MaterialVolumeFraction"))) then
2433-
2434- call assemble_1mat_compressible_projection_cg(state(1), cmc, rhs, dt, &
2435- theta_pg, theta_divergence, cmcget)
2436-
2437+ if(option_count("/material_phase/vector_field::Velocity/prognostic") > 1) then
2438+ multiphase = .true.
2439+ call assemble_1mat_compressible_projection_cg(state(istate), cmc, rhs, dt, &
2440+ theta_pg, theta_divergence, cmcget)
2441 else
2442-
2443- FLExit("Multimaterial compressible continuous_galerkin pressure not possible.")
2444-
2445- end if
2446-
2447+ multiphase = .false.
2448+
2449+ if((size(state)==1).and.(.not.has_scalar_field(state(1), "MaterialVolumeFraction"))) then
2450+
2451+ call assemble_1mat_compressible_projection_cg(state(1), cmc, rhs, dt, &
2452+ theta_pg, theta_divergence, cmcget)
2453+
2454+ else
2455+
2456+ FLExit("Multimaterial compressible continuous_galerkin pressure not possible.")
2457+
2458+ end if
2459+
2460+ end if
2461
2462 end subroutine assemble_compressible_projection_cg
2463
2464@@ -445,6 +454,11 @@
2465 logical :: have_absorption, have_source
2466 integer :: stat
2467
2468+ !! Multiphase variables
2469+ ! Volume fraction fields
2470+ type(scalar_field), pointer :: vfrac
2471+ type(scalar_field) :: nvfrac
2472+
2473 ! =============================================================
2474 ! Subroutine to construct the matrix CT_m (a.k.a. C1/2/3T).
2475 ! =============================================================
2476@@ -474,6 +488,15 @@
2477
2478 velocity=>extract_vector_field(state, "Velocity")
2479 nonlinearvelocity=>extract_vector_field(state, "NonlinearVelocity") ! maybe this should be updated after the velocity solve?
2480+
2481+ ! Get the non-linear PhaseVolumeFraction field if multiphase
2482+ if(multiphase) then
2483+ vfrac => extract_scalar_field(state, "PhaseVolumeFraction")
2484+ call allocate(nvfrac, vfrac%mesh, "NonlinearPhaseVolumeFraction")
2485+ call zero(nvfrac)
2486+ call get_nonlinear_volume_fraction(state, nvfrac)
2487+ ewrite_minmax(nvfrac)
2488+ end if
2489
2490 pressure => extract_scalar_field(state, "Pressure")
2491
2492@@ -556,7 +579,11 @@
2493 ! Important note: with SUPG the test function derivatives have not been
2494 ! modified.
2495
2496- ele_mat = (1./(dt*dt*theta_divergence*theta_pg))*shape_shape(test_shape, test_shape_ptr, detwei*drhodp_at_quad)
2497+ if(multiphase) then
2498+ ele_mat = (1./(dt*dt*theta_divergence*theta_pg))*shape_shape(test_shape, test_shape_ptr, detwei*ele_val_at_quad(nvfrac, ele)*drhodp_at_quad)
2499+ else
2500+ ele_mat = (1./(dt*dt*theta_divergence*theta_pg))*shape_shape(test_shape, test_shape_ptr, detwei*drhodp_at_quad)
2501+ end if
2502 ! /
2503 ! rhs = |test_shape* &
2504 ! /
2505@@ -564,8 +591,14 @@
2506 ! +(absorption)*(drhodp*theta*(eospressure - (pressure + atmospheric_pressure))
2507 ! - theta*density - (1-theta)*olddensity)
2508 ! +source)dV
2509- ele_rhs = (1./dt)*shape_rhs(test_shape, detwei*((drhodp_at_quad*(eosp_at_quad - p_at_quad)) &
2510- +(olddensity_at_quad - density_at_quad)))
2511+
2512+ if(multiphase) then
2513+ ele_rhs = (1./dt)*shape_rhs(test_shape, detwei*(ele_val_at_quad(nvfrac, ele))*((drhodp_at_quad*(eosp_at_quad - p_at_quad)) &
2514+ +(olddensity_at_quad - density_at_quad)))
2515+ else
2516+ ele_rhs = (1./dt)*shape_rhs(test_shape, detwei*((drhodp_at_quad*(eosp_at_quad - p_at_quad)) &
2517+ +(olddensity_at_quad - density_at_quad)))
2518+ end if
2519
2520 if(have_source) then
2521 ele_rhs = ele_rhs + shape_rhs(test_shape, detwei*ele_val_at_quad(source, ele))
2522@@ -591,6 +624,10 @@
2523
2524 call deallocate(drhodp)
2525 call deallocate(eospressure)
2526+
2527+ if(multiphase) then
2528+ call deallocate(nvfrac)
2529+ end if
2530
2531 end if
2532
2533@@ -601,17 +638,29 @@
2534 type(state_type), dimension(:), intent(inout) :: state
2535
2536 type(scalar_field), pointer :: density
2537-
2538- if((size(state)==1).and.(.not.has_scalar_field(state(1), "MaterialVolumeFraction"))) then
2539-
2540- density=>extract_scalar_field(state(1),'Density')
2541-
2542- if(have_option(trim(density%option_path)//"/prognostic")) then
2543-
2544- call compressible_eos(state(1), density=density)
2545-
2546- end if
2547-
2548+
2549+ integer :: istate
2550+
2551+ if(option_count("/material_phase/vector_field::Velocity/prognostic") > 1) then
2552+ do istate=1,size(state)
2553+ density=>extract_scalar_field(state(istate),'Density')
2554+
2555+ if(have_option(trim(density%option_path)//"/prognostic")) then
2556+ call compressible_eos(state(istate), density=density)
2557+ end if
2558+ end do
2559+ else
2560+ if((size(state)==1).and.(.not.has_scalar_field(state(1), "MaterialVolumeFraction"))) then
2561+
2562+ density=>extract_scalar_field(state(1),'Density')
2563+
2564+ if(have_option(trim(density%option_path)//"/prognostic")) then
2565+
2566+ call compressible_eos(state(1), density=density)
2567+
2568+ end if
2569+
2570+ end if
2571 end if
2572
2573 end subroutine update_compressible_density
2574@@ -624,8 +673,8 @@
2575 do i=0, option_count("/material_phase")-1
2576 prognostic_pressure_path="/material_phase"//int2str(i)//"/scalar_field::Pressure/prognostic"
2577 if (have_option(trim(prognostic_pressure_path)//"/spatial_discretisation/discontinuous_galerkin") &
2578- .and. have_option(trim(prognostic_pressure_path)//"/scheme/use_compressible_projection")) then
2579- FLExit("With a DG pressure you cannot have use_compressible_projection")
2580+ .and. have_option(trim(prognostic_pressure_path)//"/scheme/use_compressible_projection_method")) then
2581+ FLExit("With a DG pressure you cannot have use_compressible_projection_method")
2582 end if
2583 end do
2584
2585
2586=== modified file 'assemble/Coriolis.F90'
2587--- assemble/Coriolis.F90 2011-03-15 22:19:21 +0000
2588+++ assemble/Coriolis.F90 2012-10-16 13:22:44 +0000
2589@@ -31,6 +31,7 @@
2590
2591 use embed_python
2592 use fldebug
2593+ use parallel_tools, only: abort_if_in_parallel_region
2594 use global_parameters, only : current_time, PYTHON_FUNC_LEN
2595 use spud
2596
2597@@ -145,7 +146,9 @@
2598 real:: omega
2599
2600 if (coriolis_option/=NOT_INITIALISED) return
2601-
2602+
2603+ call abort_if_in_parallel_region
2604+
2605 ewrite(1, *) "Initialising Coriolis"
2606
2607 call get_option("/geometry/dimension", coriolis_dim)
2608
2609=== modified file 'assemble/Diagnostic_Fields_Matrices.F90'
2610--- assemble/Diagnostic_Fields_Matrices.F90 2011-04-28 11:10:02 +0000
2611+++ assemble/Diagnostic_Fields_Matrices.F90 2012-10-16 13:22:44 +0000
2612@@ -40,7 +40,7 @@
2613 use spud
2614 use parallel_fields, only: zero_non_owned
2615 use divergence_matrix_cv, only: assemble_divergence_matrix_cv
2616- use divergence_matrix_cg, only: assemble_divergence_matrix_cg
2617+ use divergence_matrix_cg, only: assemble_divergence_matrix_cg, assemble_compressible_divergence_matrix_cg
2618 use gradient_matrix_cg, only: assemble_gradient_matrix_cg
2619 use parallel_tools
2620 use sparsity_patterns, only: make_sparsity
2621@@ -58,7 +58,8 @@
2622
2623 public :: calculate_divergence_cv, calculate_divergence_fe, &
2624 calculate_div_t_cv, calculate_div_t_fe, &
2625- calculate_grad_fe, calculate_sum_velocity_divergence
2626+ calculate_grad_fe, calculate_sum_velocity_divergence, &
2627+ calculate_compressible_continuity_residual
2628
2629 contains
2630
2631@@ -73,8 +74,8 @@
2632
2633 character(len=FIELD_NAME_LEN) :: field_name
2634
2635- type(scalar_field), pointer :: lumpedmass
2636- type(scalar_field) :: inverse_lumpedmass
2637+ type(scalar_field), pointer :: cvmass
2638+ type(scalar_field) :: inverse_cvmass
2639 type(scalar_field) :: ctfield, ct_rhs
2640
2641 call get_option(trim(div%option_path)//"/diagnostic/field_name", field_name)
2642@@ -85,23 +86,19 @@
2643 call allocate(ctfield, div%mesh, name="CTField")
2644 call allocate(ct_rhs, div%mesh, name="CTRHS")
2645
2646- if(element_degree(div, 1)>1) then
2647- lumpedmass => get_lumped_mass_on_submesh(state, div%mesh)
2648- else
2649- lumpedmass => get_lumped_mass(state, div%mesh)
2650- end if
2651+ cvmass => get_cv_mass(state, div%mesh)
2652
2653 CT_m => get_divergence_matrix_cv(state, test_mesh=div%mesh, field=field, div_rhs=ct_rhs)
2654
2655 call mult(ctfield, CT_m, field)
2656 call addto(ctfield, ct_rhs, -1.0)
2657
2658- call allocate(inverse_lumpedmass, lumpedmass%mesh, "InverseLumpedMass")
2659- call invert(lumpedmass, inverse_lumpedmass)
2660+ call allocate(inverse_cvmass, cvmass%mesh, "InverseCVMass")
2661+ call invert(cvmass, inverse_cvmass)
2662 call set(div, ctfield)
2663- call scale(div, inverse_lumpedmass)
2664+ call scale(div, inverse_cvmass)
2665
2666- call deallocate(inverse_lumpedmass)
2667+ call deallocate(inverse_cvmass)
2668 call deallocate(ctfield)
2669 call deallocate(ct_rhs)
2670
2671@@ -188,7 +185,7 @@
2672 type(vector_field), pointer :: field, x
2673
2674 type(csr_sparsity) :: divergence_sparsity
2675- type(block_csr_matrix) :: CT_m
2676+ type(block_csr_matrix), pointer :: CT_m
2677
2678 character(len=FIELD_NAME_LEN) :: field_name
2679
2680@@ -204,6 +201,7 @@
2681 call allocate(ctfield, div%mesh, name="CTField")
2682
2683 divergence_sparsity=make_sparsity(div%mesh, field%mesh, "DivergenceSparsity")
2684+ allocate(CT_m)
2685 call allocate(CT_m, divergence_sparsity, (/1, field%dim/), name="DivergenceMatrix" )
2686 call allocate(ct_rhs, div%mesh, name="CTRHS")
2687
2688@@ -223,6 +221,7 @@
2689 call petsc_solve(div, mass, ctfield)
2690
2691 call deallocate(CT_m)
2692+ deallocate(CT_m)
2693 call deallocate(ct_rhs)
2694 call deallocate(ctfield)
2695 call deallocate(divergence_sparsity)
2696@@ -239,7 +238,7 @@
2697 type(scalar_field), pointer :: field
2698
2699 type(csr_sparsity) :: divergence_sparsity
2700- type(block_csr_matrix) :: CT_m
2701+ type(block_csr_matrix), pointer :: CT_m
2702
2703 character(len=FIELD_NAME_LEN) :: field_name
2704
2705@@ -256,6 +255,7 @@
2706
2707 ! Sparsity of C^T - the transpose of the gradient operator.
2708 divergence_sparsity=make_sparsity(field%mesh, grad%mesh, "DivergenceSparsity")
2709+ allocate(CT_m)
2710 call allocate(CT_m, divergence_sparsity, (/1, grad%dim/), name="DivergenceMatrix" )
2711
2712 mass_sparsity=make_sparsity(grad%mesh, grad%mesh, "MassSparsity")
2713@@ -273,6 +273,7 @@
2714
2715 call deallocate(divergence_sparsity)
2716 call deallocate(CT_m)
2717+ deallocate(CT_m)
2718 call deallocate(mass_sparsity)
2719 call deallocate(mass)
2720 call deallocate(cfield)
2721@@ -340,23 +341,32 @@
2722 integer :: i, stat
2723
2724 type(csr_sparsity) :: divergence_sparsity
2725- type(block_csr_matrix) :: ct_m
2726+ type(block_csr_matrix), pointer :: ct_m
2727
2728 type(csr_sparsity) :: mass_sparsity
2729 type(csr_matrix) :: mass
2730 type(scalar_field) :: ctfield, ct_rhs, temp
2731+ type(scalar_field), pointer :: cv_mass
2732+
2733+ logical :: test_with_cv_dual
2734
2735 ewrite(1,*) 'Entering calculate_sum_velocity_divergence'
2736+
2737+ ! Are we testing the divergence with the CV dual mesh
2738+ test_with_cv_dual = have_option(trim(sum_velocity_divergence%option_path)//'/diagnostic/test_with_cv_dual')
2739
2740 ! Allocate memory for matrices and sparsity patterns
2741 call allocate(ctfield, sum_velocity_divergence%mesh, name="CTField")
2742- call zero (ctfield)
2743+ call zero(ctfield)
2744 call allocate(temp, sum_velocity_divergence%mesh, name="Temp")
2745
2746- mass_sparsity=make_sparsity(sum_velocity_divergence%mesh, sum_velocity_divergence%mesh, "MassSparsity")
2747- call allocate(mass, mass_sparsity, name="MassMatrix")
2748- call zero(mass)
2749-
2750+ ! Require a mass matrix type if not CV tested equation.
2751+ if (.not. test_with_cv_dual) then
2752+ mass_sparsity=make_sparsity(sum_velocity_divergence%mesh, sum_velocity_divergence%mesh, "MassSparsity")
2753+ call allocate(mass, mass_sparsity, name="MassMatrix")
2754+ call zero(mass)
2755+ end if
2756+
2757 ! Sum up over the div's
2758 do i = 1, size(state)
2759 u => extract_vector_field(state(i), "Velocity", stat)
2760@@ -373,21 +383,29 @@
2761
2762 ! Allocate sparsity patterns, C^T matrix and C^T RHS for current state
2763 divergence_sparsity=make_sparsity(sum_velocity_divergence%mesh, u%mesh, "DivergenceSparsity")
2764+
2765+ allocate(ct_m)
2766 call allocate(ct_m, divergence_sparsity, (/1, u%dim/), name="DivergenceMatrix" )
2767 call allocate(ct_rhs, sum_velocity_divergence%mesh, name="CTRHS")
2768
2769 ! Reassemble C^T matrix here
2770- if(i==1) then ! Construct the mass matrix (just do this once)
2771- call assemble_divergence_matrix_cg(ct_m, state(i), ct_rhs=ct_rhs, &
2772+ if (test_with_cv_dual) then
2773+ call assemble_divergence_matrix_cv(ct_m, state(i), ct_rhs=ct_rhs, &
2774+ test_mesh=sum_velocity_divergence%mesh, field=u)
2775+ else
2776+ if(i==1) then ! Construct the mass matrix (just do this once)
2777+ call assemble_divergence_matrix_cg(ct_m, state(i), ct_rhs=ct_rhs, &
2778 test_mesh=sum_velocity_divergence%mesh, field=u, &
2779 option_path=sum_velocity_divergence%option_path, div_mass=mass)
2780- else
2781- call assemble_divergence_matrix_cg(ct_m, state(i), ct_rhs=ct_rhs, &
2782+ else
2783+ call assemble_divergence_matrix_cg(ct_m, state(i), ct_rhs=ct_rhs, &
2784 test_mesh=sum_velocity_divergence%mesh, field=u, &
2785 option_path=sum_velocity_divergence%option_path)
2786+ end if
2787+
2788 end if
2789
2790- ! Construct the linear system of equations to solve for \sum{div(vfrac*u)}
2791+ ! Construct the linear system of equations
2792 call zero(temp)
2793 call mult(temp, ct_m, u)
2794 call addto(temp, ct_rhs, -1.0)
2795@@ -396,23 +414,180 @@
2796 call addto(ctfield, temp)
2797
2798 call deallocate(ct_m)
2799+ deallocate(ct_m)
2800 call deallocate(ct_rhs)
2801 call deallocate(divergence_sparsity)
2802
2803 end do
2804
2805- ! Solve for sum_velocity_divergence ( = \sum{div(vfrac*u)} )
2806- call zero(sum_velocity_divergence)
2807- call petsc_solve(sum_velocity_divergence, mass, ctfield)
2808-
2809+ ! Solve for sum_velocity_divergence
2810+ ! ( = \sum{div(vfrac*u)} for incompressible multiphase flows )
2811+ if (test_with_cv_dual) then
2812+ ! get the cv mass matrix
2813+ cv_mass => get_cv_mass(state(1), sum_velocity_divergence%mesh)
2814+ call set(sum_velocity_divergence, cv_mass)
2815+ call invert(sum_velocity_divergence)
2816+ call scale(sum_velocity_divergence, ctfield)
2817+ else
2818+ call zero(sum_velocity_divergence)
2819+ call petsc_solve(sum_velocity_divergence, mass, ctfield)
2820+ end if
2821+
2822 ! Deallocate memory
2823- call deallocate(mass_sparsity)
2824- call deallocate(mass)
2825 call deallocate(ctfield)
2826 call deallocate(temp)
2827+
2828+ if (.not. test_with_cv_dual) then
2829+ call deallocate(mass_sparsity)
2830+ call deallocate(mass)
2831+ end if
2832
2833 ewrite(1,*) 'Exiting calculate_sum_velocity_divergence'
2834
2835 end subroutine calculate_sum_velocity_divergence
2836
2837+
2838+ subroutine calculate_compressible_continuity_residual(state, compressible_continuity_residual)
2839+ !!< Calculates the residual of the continity equation used in compressible multiphase flow simulations:
2840+ !!< vfrac_c*d(rho_c)/dt + div(rho_c*vfrac_c*u_c) + \sum_i{ rho_c*div(vfrac_i*u_i) }
2841+
2842+ type(state_type), dimension(:), intent(inout) :: state
2843+ type(scalar_field), pointer :: compressible_continuity_residual, density, olddensity, vfrac
2844+ type(scalar_field) :: drhodt
2845+
2846+ ! Local variables
2847+ type(vector_field), pointer :: u, x
2848+ integer :: i, stat, ele
2849+ logical :: dg
2850+
2851+ type(csr_sparsity) :: divergence_sparsity
2852+ type(block_csr_matrix), pointer :: ct_m
2853+
2854+ type(csr_sparsity) :: mass_sparsity
2855+ type(csr_matrix) :: mass
2856+ type(scalar_field) :: ctfield, ct_rhs, temp
2857+
2858+ type(element_type) :: test_function
2859+ type(element_type), pointer :: compressible_continuity_residual_shape
2860+ integer, dimension(:), pointer :: compressible_continuity_residual_nodes
2861+ real, dimension(:), allocatable :: detwei
2862+ real, dimension(:), allocatable :: drhodt_addto
2863+
2864+ real :: dt
2865+
2866+ ewrite(1,*) 'Entering calculate_compressible_continuity_residual'
2867+
2868+ ! Allocate memory for matrices and sparsity patterns
2869+ call allocate(ctfield, compressible_continuity_residual%mesh, name="CTField")
2870+ call zero(ctfield)
2871+ call allocate(temp, compressible_continuity_residual%mesh, name="Temp")
2872+
2873+ mass_sparsity=make_sparsity(compressible_continuity_residual%mesh, compressible_continuity_residual%mesh, "MassSparsity")
2874+ call allocate(mass, mass_sparsity, name="MassMatrix")
2875+ call zero(mass)
2876+
2877+ call get_option("/timestepping/timestep", dt)
2878+
2879+ ! Sum up over the div's
2880+ do i = 1, size(state)
2881+ u => extract_vector_field(state(i), "Velocity", stat)
2882+
2883+ ! If there's no velocity then cycle
2884+ if(stat/=0) cycle
2885+ ! If this is an aliased velocity then cycle
2886+ if(aliased(u)) cycle
2887+ ! If the velocity isn't prognostic then cycle
2888+ if(.not.have_option(trim(u%option_path)//"/prognostic")) cycle
2889+
2890+ ! If velocity field is prognostic, begin calculations below
2891+ x => extract_vector_field(state(i), "Coordinate")
2892+
2893+ ! Allocate sparsity patterns, C^T matrix and C^T RHS for current state
2894+ divergence_sparsity=make_sparsity(compressible_continuity_residual%mesh, u%mesh, "DivergenceSparsity")
2895+ allocate(ct_m)
2896+ call allocate(ct_m, divergence_sparsity, (/1, u%dim/), name="DivergenceMatrix")
2897+ call allocate(ct_rhs, compressible_continuity_residual%mesh, name="CTRHS")
2898+
2899+ ! Reassemble C^T matrix here
2900+ if(i==1) then ! Construct the mass matrix (just do this once)
2901+ call assemble_compressible_divergence_matrix_cg(ct_m, state, i, ct_rhs, div_mass=mass)
2902+ else
2903+ call assemble_compressible_divergence_matrix_cg(ct_m, state, i, ct_rhs)
2904+ end if
2905+
2906+ if(have_option("/material_phase::"//trim(state(i)%name)//"/equation_of_state/compressible")) then
2907+ ! Get the time derivative term for the compressible phase's density, vfrac_c * d(rho_c)/dt
2908+
2909+ call allocate(drhodt, compressible_continuity_residual%mesh, name="drhodt")
2910+
2911+ density => extract_scalar_field(state(i), "Density", stat)
2912+ olddensity => extract_scalar_field(state(i), "OldDensity", stat)
2913+ vfrac => extract_scalar_field(state(i), "PhaseVolumeFraction")
2914+
2915+ ! Assumes Density and OldDensity are on the same mesh as Pressure,
2916+ ! as it should be according to the manual.
2917+ call zero(drhodt)
2918+
2919+ dg = continuity(compressible_continuity_residual) < 0
2920+
2921+ element_loop: do ele = 1, element_count(compressible_continuity_residual)
2922+
2923+ if(.not.dg .or. (dg .and. element_owned(compressible_continuity_residual,ele))) then
2924+
2925+ allocate(detwei(ele_ngi(compressible_continuity_residual, ele)))
2926+ allocate(drhodt_addto(ele_loc(compressible_continuity_residual, ele)))
2927+
2928+ compressible_continuity_residual_nodes => ele_nodes(compressible_continuity_residual, ele)
2929+ compressible_continuity_residual_shape => ele_shape(compressible_continuity_residual, ele)
2930+ test_function = compressible_continuity_residual_shape
2931+
2932+ call transform_to_physical(x, ele, detwei=detwei)
2933+
2934+ drhodt_addto = shape_rhs(test_function, detwei*(ele_val_at_quad(vfrac,ele)*(ele_val_at_quad(density,ele) - ele_val_at_quad(olddensity,ele))/dt))
2935+
2936+ call addto(drhodt, compressible_continuity_residual_nodes, drhodt_addto)
2937+
2938+ deallocate(detwei)
2939+ deallocate(drhodt_addto)
2940+ end if
2941+
2942+ end do element_loop
2943+
2944+ call addto(ctfield, drhodt)
2945+
2946+ call deallocate(drhodt)
2947+
2948+ end if
2949+
2950+ ! Construct the linear system of equations
2951+ call zero(temp)
2952+ call mult(temp, ct_m, u)
2953+ call addto(temp, ct_rhs, -1.0)
2954+
2955+ ! Now add it to the sum
2956+ call addto(ctfield, temp)
2957+
2958+ call deallocate(ct_m)
2959+ deallocate(ct_m)
2960+ call deallocate(ct_rhs)
2961+ call deallocate(divergence_sparsity)
2962+
2963+ end do
2964+
2965+ ! Solve for compressible_continuity_residual
2966+ call zero(compressible_continuity_residual)
2967+ call petsc_solve(compressible_continuity_residual, mass, ctfield)
2968+ ewrite_minmax(compressible_continuity_residual)
2969+
2970+ ! Deallocate memory
2971+ call deallocate(ctfield)
2972+ call deallocate(temp)
2973+ call deallocate(mass_sparsity)
2974+ call deallocate(mass)
2975+
2976+ ewrite(1,*) 'Exiting calculate_compressible_continuity_residual'
2977+
2978+ end subroutine calculate_compressible_continuity_residual
2979+
2980+
2981 end module diagnostic_fields_matrices
2982
2983=== modified file 'assemble/Diagnostic_fields_wrapper.F90'
2984--- assemble/Diagnostic_fields_wrapper.F90 2011-04-28 11:10:02 +0000
2985+++ assemble/Diagnostic_fields_wrapper.F90 2012-10-16 13:22:44 +0000
2986@@ -30,7 +30,7 @@
2987 module diagnostic_fields_wrapper
2988 !!< A module to link to diagnostic variable calculations.
2989
2990- use global_parameters, only:FIELD_NAME_LEN
2991+ use global_parameters, only: FIELD_NAME_LEN, timestep
2992 use fields
2993 use sparse_matrices_fields
2994 use field_derivatives
2995@@ -52,7 +52,6 @@
2996 use diagnostic_fields_matrices
2997 use equation_of_state
2998 use momentum_diagnostic_fields
2999- use porous_media, only: calculate_porous_media_absorption
3000 use spontaneous_potentials, only: calculate_formation_conductivity
3001 use sediment_diagnostics
3002 use geostrophic_pressure
3003@@ -135,6 +134,30 @@
3004 end if
3005 end if
3006
3007+ s_field => extract_scalar_field(state(i), "InterstitialVelocityCGCourantNumber", stat)
3008+ if(stat == 0) then
3009+ if(recalculate(trim(s_field%option_path))) then
3010+ call calculate_diagnostic_variable(state(i), "InterstitialVelocityCGCourantNumber", &
3011+ & s_field)
3012+ end if
3013+ end if
3014+
3015+ s_field => extract_scalar_field(state(i), "InterstitialVelocityDGCourantNumber", stat)
3016+ if(stat == 0) then
3017+ if(recalculate(trim(s_field%option_path))) then
3018+ call calculate_diagnostic_variable(state(i), "InterstitialVelocityDGCourantNumber", &
3019+ & s_field)
3020+ end if
3021+ end if
3022+
3023+ s_field => extract_scalar_field(state(i), "InterstitialVelocityCVCourantNumber", stat)
3024+ if(stat == 0) then
3025+ if(recalculate(trim(s_field%option_path))) then
3026+ call calculate_diagnostic_variable(state(i), "InterstitialVelocityCVCourantNumber", &
3027+ & s_field)
3028+ end if
3029+ end if
3030+
3031 s_field => extract_scalar_field(state(i), "KineticEnergyDensity", stat)
3032 if(stat == 0) then
3033 if(recalculate(trim(s_field%option_path))) then
3034@@ -519,17 +542,6 @@
3035 end if
3036 ! End of vorticity diagnostics
3037
3038- ! Start of porous media diagnostics
3039- if (have_option("/porous_media")) then
3040- v_field => extract_vector_field(state(i), "VelocityAbsorption", stat)
3041- if(stat == 0) then
3042- if(recalculate(trim(v_field%option_path))) then
3043- call calculate_porous_media_absorption(state, i, v_field, stat)
3044- end if
3045- end if
3046- end if
3047- ! End of porous media diagnostics
3048-
3049 ! Start of spontaneous potentials diagnostics
3050 if(i == 1) then
3051 s_field => extract_scalar_field(state(i), "ElectricalConductivity", stat)
3052@@ -544,7 +556,11 @@
3053
3054 ! Start of sediment diagnostics.
3055 if (have_option("/material_phase[0]/sediment")) then
3056+ call calculate_sediment_sinking_velocity(state(i))
3057 call calculate_sediment_flux(state(i))
3058+ call calculate_sediment_active_layer_d50(state(i))
3059+ call calculate_sediment_active_layer_sigma(state(i))
3060+ call calculate_sediment_active_layer_volume_fractions(state(i))
3061 end if
3062 ! End of sediment diagnostics.
3063
3064@@ -573,6 +589,21 @@
3065 FLExit("The SumVelocityDivergence field is only used in multiphase simulations.")
3066 end if
3067 end if
3068+
3069+ s_field => extract_scalar_field(state(i), "CompressibleContinuityResidual", stat)
3070+ if(stat == 0) then
3071+ ! Check that we are running a compressible multiphase simulation
3072+ if(option_count("/material_phase/vector_field::Velocity/prognostic") > 1 .and. option_count("/material_phase/equation_of_state/compressible") > 0) then
3073+ diagnostic = have_option(trim(s_field%option_path)//"/diagnostic")
3074+ if(diagnostic .and. .not.(aliased(s_field))) then
3075+ if(recalculate(trim(s_field%option_path))) then
3076+ call calculate_compressible_continuity_residual(state, s_field)
3077+ end if
3078+ end if
3079+ else
3080+ FLExit("The CompressibleContinuityResidual field is only used in compressible multiphase simulations.")
3081+ end if
3082+ end if
3083
3084 ! end of fields that cannot be called through the generic
3085 ! calculate_diagnostic_variable interface, i.e. - those that need things
3086
3087=== modified file 'assemble/Divergence_Matrix_CG.F90'
3088--- assemble/Divergence_Matrix_CG.F90 2011-09-17 01:24:08 +0000
3089+++ assemble/Divergence_Matrix_CG.F90 2012-10-16 13:22:44 +0000
3090@@ -58,7 +58,10 @@
3091 integer :: nu_bar_scheme
3092 real :: nu_bar_scale
3093
3094-contains
3095+ !! Are we running a multiphase flow simulation?
3096+ logical :: multiphase
3097+
3098+ contains
3099
3100 subroutine assemble_divergence_matrix_cg(CT_m, state, ct_rhs, &
3101 test_mesh, field, option_path, &
3102@@ -71,7 +74,7 @@
3103 type(state_type), intent(inout) :: state
3104
3105 ! the velocity divergence gradient matrices
3106- type(block_csr_matrix), intent(inout) :: CT_m
3107+ type(block_csr_matrix), pointer :: CT_m
3108
3109 type(scalar_field), intent(inout), optional :: ct_rhs
3110
3111@@ -119,7 +122,6 @@
3112 logical :: l_get_ct
3113
3114 !! Multiphase variables
3115- logical :: multiphase
3116 ! Volume fraction fields
3117 type(scalar_field), pointer :: vfrac
3118 type(scalar_field) :: nvfrac
3119@@ -355,40 +357,55 @@
3120
3121 end subroutine assemble_divergence_matrix_cg
3122
3123- subroutine assemble_compressible_divergence_matrix_cg(ctp_m, state, ct_rhs)
3124+ subroutine assemble_compressible_divergence_matrix_cg(ctp_m, state, istate, ct_rhs, div_mass)
3125
3126 ! inputs/outputs
3127 ! bucket full of fields
3128 type(state_type), dimension(:), intent(inout) :: state
3129-
3130+ integer, intent(in) :: istate
3131 ! the compressible divergence matrix
3132- type(block_csr_matrix), intent(inout) :: ctp_m
3133+ type(block_csr_matrix), pointer :: ctp_m
3134
3135 type(scalar_field), intent(inout), optional :: ct_rhs
3136
3137- if((size(state)==1).and.(.not.has_scalar_field(state(1), "MaterialVolumeFraction"))) then
3138-
3139- call assemble_1mat_compressible_divergence_matrix_cg(ctp_m, state(1), ct_rhs)
3140-
3141+ type(csr_matrix), intent(inout), optional :: div_mass
3142+
3143+ if(option_count("/material_phase/vector_field::Velocity/prognostic") > 1) then
3144+ multiphase = .true.
3145+ call assemble_1mat_compressible_divergence_matrix_cg(ctp_m, state, istate, ct_rhs, div_mass)
3146 else
3147-
3148- FLExit("Multimaterial compressible continuous_galerkin pressure not possible.")
3149-
3150+ multiphase = .false.
3151+
3152+ if((size(state)==1).and.(.not.has_scalar_field(state(1), "MaterialVolumeFraction"))) then
3153+
3154+ call assemble_1mat_compressible_divergence_matrix_cg(ctp_m, state, 1, ct_rhs, div_mass)
3155+
3156+ else
3157+
3158+ FLExit("Multimaterial compressible continuous_galerkin pressure not possible.")
3159+
3160+ end if
3161+
3162 end if
3163+
3164+
3165
3166 end subroutine assemble_compressible_divergence_matrix_cg
3167
3168- subroutine assemble_1mat_compressible_divergence_matrix_cg(ctp_m, state, ct_rhs)
3169+ subroutine assemble_1mat_compressible_divergence_matrix_cg(ctp_m, state, istate, ct_rhs, div_mass)
3170
3171 ! inputs/outputs
3172 ! bucket full of fields
3173- type(state_type), intent(inout) :: state
3174+ type(state_type), dimension(:), intent(inout) :: state
3175+ integer, intent(in) :: istate
3176
3177 ! the compressible divergence matrix
3178- type(block_csr_matrix), intent(inout) :: ctp_m
3179+ type(block_csr_matrix), pointer :: ctp_m
3180
3181 type(scalar_field), intent(inout), optional :: ct_rhs
3182
3183+ type(csr_matrix), intent(inout), optional :: div_mass
3184+
3185 ! local
3186 type(mesh_type), pointer :: test_mesh
3187
3188@@ -408,6 +425,8 @@
3189 real, dimension(:), allocatable :: density_at_quad, olddensity_at_quad
3190 real, dimension(:,:), allocatable :: density_grad_at_quad, nlvelocity_at_quad
3191
3192+ real, dimension(:,:), allocatable :: div_mass_mat
3193+
3194 ! loop integers
3195 integer :: ele, sele, dim
3196
3197@@ -425,7 +444,16 @@
3198 integer, dimension(:), allocatable :: density_bc_type
3199 type(scalar_field) :: density_bc
3200
3201- integer :: stat
3202+ integer :: i, stat
3203+
3204+ !! Multiphase variables
3205+ ! Volume fraction fields
3206+ type(scalar_field), pointer :: vfrac
3207+ type(scalar_field) :: nvfrac
3208+ type(element_type), pointer :: nvfrac_shape
3209+ ! Transformed gradient function for the non-linear PhaseVolumeFraction.
3210+ real, dimension(:, :, :), allocatable :: dnvfrac_t
3211+ logical :: is_compressible_phase ! Is this the (single) compressible phase in a multiphase simulation?
3212
3213 ! =============================================================
3214 ! Subroutine to construct the matrix ctp_m (a.k.a. C1/2/3TP).
3215@@ -433,16 +461,42 @@
3216
3217 ewrite(2,*) 'In assemble_1mat_compressible_divergence_matrix_cg'
3218
3219- coordinate=> extract_vector_field(state, "Coordinate")
3220-
3221- density => extract_scalar_field(state, "Density")
3222- olddensity => extract_scalar_field(state, "OldDensity")
3223-
3224- pressure => extract_scalar_field(state, "Pressure")
3225-
3226- velocity=>extract_vector_field(state, "Velocity")
3227- nonlinearvelocity=>extract_vector_field(state, "NonlinearVelocity") ! maybe this should be updated after the velocity solve?
3228-
3229+ coordinate=> extract_vector_field(state(istate), "Coordinate")
3230+
3231+ density => extract_scalar_field(state(istate), "Density")
3232+ olddensity => extract_scalar_field(state(istate), "OldDensity")
3233+
3234+ if(have_option(trim(state(istate)%option_path)//"/equation_of_state/compressible")) then
3235+ is_compressible_phase = .true.
3236+ else
3237+ is_compressible_phase = .false.
3238+
3239+ ! Find the compressible phase and extract it's density to form rho_c * div(vfrac_i*u_i), where _c and _i represent
3240+ ! the compressible and incompressible phases respectively.
3241+ do i = 1, size(state)
3242+ if(have_option(trim(state(i)%option_path)//"/equation_of_state/compressible")) then
3243+ density => extract_scalar_field(state(i), "Density")
3244+ olddensity => extract_scalar_field(state(i), "OldDensity")
3245+ end if
3246+ end do
3247+ end if
3248+
3249+ pressure => extract_scalar_field(state(istate), "Pressure")
3250+
3251+ velocity=>extract_vector_field(state(istate), "Velocity")
3252+ nonlinearvelocity=>extract_vector_field(state(istate), "NonlinearVelocity") ! maybe this should be updated after the velocity solve?
3253+
3254+ ! Get the non-linear PhaseVolumeFraction field if multiphase
3255+ if(multiphase) then
3256+ vfrac => extract_scalar_field(state(istate), "PhaseVolumeFraction")
3257+ call allocate(nvfrac, vfrac%mesh, "NonlinearPhaseVolumeFraction")
3258+ call zero(nvfrac)
3259+ call get_nonlinear_volume_fraction(state(istate), nvfrac)
3260+ ewrite_minmax(nvfrac)
3261+ else
3262+ nullify(vfrac)
3263+ end if
3264+
3265 integrate_by_parts=have_option(trim(complete_field_path(density%option_path, stat=stat))//&
3266 &"/spatial_discretisation/continuous_galerkin/advection_terms/integrate_advection_by_parts")&
3267 .or. have_option(trim(complete_field_path(velocity%option_path, stat=stat))//&
3268@@ -474,7 +528,7 @@
3269 end if
3270
3271 call get_option(trim(complete_field_path(density%option_path, stat=stat))//&
3272- &"/temporal_discretisation/theta", theta)
3273+ &"/temporal_discretisation/theta", theta)
3274 call get_option("/timestepping/timestep", dt)
3275
3276 test_mesh => pressure%mesh
3277@@ -494,8 +548,14 @@
3278 olddensity_at_quad(ele_ngi(density, 1)), &
3279 nlvelocity_at_quad(nonlinearvelocity%dim, ele_ngi(nonlinearvelocity, 1)), &
3280 density_grad_at_quad(field%dim, ele_ngi(density,1)), &
3281- j_mat(field%dim, field%dim, ele_ngi(density, 1)))
3282+ j_mat(field%dim, field%dim, ele_ngi(density, 1)), &
3283+ div_mass_mat(ele_loc(test_mesh, 1), ele_loc(test_mesh, 1)))
3284
3285+ if(multiphase) then
3286+ ! We will need grad(nvfrac) if we are not integrating by parts below
3287+ allocate(dnvfrac_t(ele_loc(nvfrac,1), ele_ngi(nvfrac,1), field%dim))
3288+ end if
3289+
3290 do ele=1, element_count(test_mesh)
3291
3292 test_nodes=>ele_nodes(test_mesh, ele)
3293@@ -509,7 +569,7 @@
3294 olddensity_at_quad = ele_val_at_quad(olddensity, ele)
3295
3296 nlvelocity_at_quad = ele_val_at_quad(nonlinearvelocity, ele)
3297-
3298+
3299 if(any(stabilisation_scheme == (/STABILISATION_STREAMLINE_UPWIND, STABILISATION_SUPG/))) then
3300 call transform_to_physical(coordinate, ele, test_shape_ptr, dshape = dtest_t, &
3301 detwei = detwei, j = j_mat)
3302@@ -517,7 +577,7 @@
3303 call transform_to_physical(coordinate, ele, test_shape_ptr, dshape = dtest_t, detwei=detwei)
3304 end if
3305
3306- if(.not.integrate_by_parts) then
3307+ if(.not.integrate_by_parts .or. (multiphase .and. integrate_by_parts .and. .not.is_compressible_phase)) then
3308 ! transform the field (velocity) derivatives into physical space
3309 call transform_to_physical(coordinate, ele, field_shape, dshape=dfield_t)
3310
3311@@ -545,16 +605,53 @@
3312
3313
3314 if(integrate_by_parts) then
3315+
3316 ! if SUPG is fixed for P>1 then this dtest_t should be updated
3317- ele_mat = -dshape_shape(dtest_t, field_shape, &
3318- detwei*(theta*density_at_quad + (1-theta)*olddensity_at_quad))
3319+ if(multiphase .and. .not.is_compressible_phase) then
3320+ density_grad_at_quad = theta*(ele_grad_at_quad(density, ele, ddensity_t))+&
3321+ (1-theta)*(ele_grad_at_quad(olddensity, ele, ddensity_t))
3322+
3323+ ele_mat = -dshape_shape(dtest_t, field_shape, detwei*ele_val_at_quad(nvfrac, ele)*(theta*density_at_quad + (1-theta)*olddensity_at_quad)) - shape_shape_vector(test_shape, field_shape, detwei*ele_val_at_quad(nvfrac, ele), density_grad_at_quad)
3324+
3325+ else if(multiphase .and. is_compressible_phase) then
3326+ ele_mat = -dshape_shape(dtest_t, field_shape, detwei*ele_val_at_quad(nvfrac, ele)*(theta*density_at_quad + (1-theta)*olddensity_at_quad))
3327+
3328+ else
3329+
3330+ ele_mat = -dshape_shape(dtest_t, field_shape, detwei*(theta*density_at_quad + (1-theta)*olddensity_at_quad))
3331+ end if
3332 else
3333 density_grad_at_quad = theta*(ele_grad_at_quad(density, ele, ddensity_t))+&
3334 (1-theta)*(ele_grad_at_quad(olddensity, ele, ddensity_t))
3335
3336- ele_mat = shape_dshape(test_shape, dfield_t, &
3337+ if(multiphase) then
3338+
3339+ ! If the field and nvfrac meshes are different, then we need to
3340+ ! compute the derivatives of the nvfrac shape functions.
3341+ if(.not.(nvfrac%mesh == field%mesh)) then
3342+ nvfrac_shape => ele_shape(nvfrac%mesh, ele)
3343+ call transform_to_physical(coordinate, ele, nvfrac_shape, dshape=dnvfrac_t)
3344+ else
3345+ dnvfrac_t = dfield_t
3346+ end if
3347+
3348+ ! Split up the divergence term div(rho*vfrac*u) = rho*div(u*vfrac) + vfrac*u*grad(rho)
3349+ ! = (rho*vfrac*div(u) + rho*u*grad(vfrac)) + u*vfrac*grad(rho)
3350+
3351+ ! First assemble rho*div(u*vfrac). This is the incompressible phase's divergence matrix.
3352+ ele_mat = shape_dshape(test_shape, dfield_t, detwei*(theta*density_at_quad + (1-theta)*olddensity_at_quad)*ele_val_at_quad(nvfrac, ele)) + shape_shape_vector(test_shape, field_shape, detwei*(theta*density_at_quad + (1-theta)*olddensity_at_quad), ele_grad_at_quad(nvfrac, ele, dnvfrac_t))
3353+
3354+ ! If the phase is compressible, then we now complete the assembly of div(rho*vfrac*u) below.
3355+ if(is_compressible_phase) then
3356+ ele_mat = ele_mat + shape_shape_vector(test_shape, field_shape, detwei*ele_val_at_quad(nvfrac, ele), density_grad_at_quad)
3357+ end if
3358+
3359+ else
3360+ ele_mat = shape_dshape(test_shape, dfield_t, &
3361 detwei*(theta*density_at_quad + (1-theta)*olddensity_at_quad)) + &
3362 shape_shape_vector(test_shape, field_shape, detwei, density_grad_at_quad)
3363+ end if
3364+
3365 end if
3366
3367 ! Stabilisation does not return the right shape for this operator!
3368@@ -568,6 +665,11 @@
3369 do dim = 1, field%dim
3370 call addto(ctp_m, 1, dim, test_nodes, field_nodes, ele_mat(dim,:,:))
3371 end do
3372+
3373+ if(present(div_mass)) then
3374+ div_mass_mat = shape_shape(test_shape, test_shape, detwei)
3375+ call addto(div_mass, test_nodes, test_nodes, div_mass_mat)
3376+ end if
3377
3378 call deallocate(test_shape)
3379
3380@@ -618,8 +720,14 @@
3381 & detwei_f=detwei_bdy,&
3382 & normal=normal_bdy)
3383
3384- ele_mat_bdy = shape_shape_vector(test_shape_ptr, field_shape, &
3385- detwei_bdy*density_bdy, normal_bdy)
3386+
3387+ if(multiphase) then
3388+ ele_mat_bdy = shape_shape_vector(test_shape_ptr, field_shape, &
3389+ detwei_bdy*density_bdy*face_val_at_quad(nvfrac, sele), normal_bdy)
3390+ else
3391+ ele_mat_bdy = shape_shape_vector(test_shape_ptr, field_shape, &
3392+ detwei_bdy*density_bdy, normal_bdy)
3393+ end if
3394
3395 do dim = 1, field%dim
3396 if((field_bc_type(dim, sele)==1).and.present(ct_rhs)) then
3397@@ -641,6 +749,11 @@
3398 deallocate(test_nodes_bdy, field_nodes_bdy)
3399
3400 end if
3401+
3402+ if(multiphase) then
3403+ deallocate(dnvfrac_t)
3404+ call deallocate(nvfrac)
3405+ end if
3406
3407 end subroutine assemble_1mat_compressible_divergence_matrix_cg
3408
3409
3410=== modified file 'assemble/Divergence_Matrix_CV.F90'
3411--- assemble/Divergence_Matrix_CV.F90 2011-09-16 21:18:56 +0000
3412+++ assemble/Divergence_Matrix_CV.F90 2012-10-16 13:22:44 +0000
3413@@ -107,7 +107,7 @@
3414 type(vector_field) :: field_bc
3415
3416 real, dimension(:,:,:), allocatable :: ct_mat_local, ct_mat_local_bdy
3417- real, dimension(:), allocatable :: ct_rhs_local
3418+ real, dimension(:,:), allocatable :: ct_rhs_local
3419
3420 logical :: l_get_ct
3421
3422@@ -316,7 +316,7 @@
3423 allocate(field_nodes_bdy(field%mesh%faces%shape%loc))
3424 allocate(test_nodes_bdy(test_mesh%faces%shape%loc))
3425 allocate(ct_mat_local_bdy(x%dim, test_mesh%faces%shape%loc, field%mesh%faces%shape%loc), &
3426- ct_rhs_local(test_mesh%faces%shape%loc))
3427+ ct_rhs_local(x%dim, test_mesh%faces%shape%loc))
3428
3429 surface_element_loop: do sele = 1, surface_element_count(test_mesh)
3430
3431@@ -366,11 +366,11 @@
3432 if((present(ct_rhs)).and.(field_bc_type(dim, sele)==BC_TYPE_WEAKDIRICHLET)) then
3433
3434 if(multiphase) then
3435- ct_rhs_local(iloc) = ct_rhs_local(iloc) + &
3436+ ct_rhs_local(dim, iloc) = ct_rhs_local(dim, iloc) - &
3437 field_cvbdyshape%n(jloc,ggi)*detwei_bdy(ggi)*nvfrac_gi_f(ggi)*&
3438 normal_bdy(dim,ggi)*field_bc_val(dim, jloc)
3439 else
3440- ct_rhs_local(iloc) = ct_rhs_local(iloc) + &
3441+ ct_rhs_local(dim, iloc) = ct_rhs_local(dim, iloc) - &
3442 field_cvbdyshape%n(jloc,ggi)*detwei_bdy(ggi)*normal_bdy(dim,ggi)*&
3443 field_bc_val(dim, jloc)
3444 end if
3445@@ -403,7 +403,7 @@
3446
3447 if((present(ct_rhs)).and.(field_bc_type(dim, sele)==BC_TYPE_WEAKDIRICHLET)) then
3448
3449- call addto(ct_rhs, test_nodes_bdy, ct_rhs_local)
3450+ call addto(ct_rhs, test_nodes_bdy, ct_rhs_local(dim,:))
3451
3452 elseif(l_get_ct) then
3453
3454
3455=== modified file 'assemble/Field_Equations_CV.F90'
3456--- assemble/Field_Equations_CV.F90 2011-10-10 21:03:46 +0000
3457+++ assemble/Field_Equations_CV.F90 2012-10-16 13:22:44 +0000
3458@@ -46,8 +46,8 @@
3459 use boundary_conditions
3460 use boundary_conditions_from_options
3461 use divergence_matrix_cv, only: assemble_divergence_matrix_cv
3462- use global_parameters, only: OPTION_PATH_LEN
3463- use fefields, only: compute_lumped_mass
3464+ use global_parameters, only: OPTION_PATH_LEN, FIELD_NAME_LEN
3465+ use fefields, only: compute_cv_mass
3466 use petsc_solve_state_module
3467 use transform_elements, only: transform_cvsurf_to_physical, &
3468 transform_cvsurf_facet_to_physical
3469@@ -55,6 +55,7 @@
3470 use halos
3471 use field_options
3472 use state_fields_module
3473+ use porous_media
3474
3475 implicit none
3476
3477@@ -73,8 +74,12 @@
3478 logical :: move_mesh = .false.
3479 ! are we including density?
3480 logical :: include_density = .false.
3481+ ! is the Density field prognostic?
3482+ logical :: prognostic_density = .false.
3483 ! are we including a souce?
3484 logical :: include_source = .false.
3485+ ! Add source directly to the right hand side?
3486+ logical :: add_src_directly_to_rhs = .false.
3487 ! are we including an absorption?
3488 logical :: include_absorption = .false.
3489 ! are we including diffusion?
3490@@ -127,15 +132,20 @@
3491 type(csr_sparsity), pointer :: mesh_sparsity_1, mesh_sparsity, &
3492 mesh_sparsity_x, grad_m_t_sparsity
3493
3494- ! Right hand side vector, lumped mass matrix,
3495+ ! Right hand side vector, cv mass matrix,
3496 ! locally iterated field (for advection iterations)
3497 ! and local old field (for subcycling)
3498- type(scalar_field), pointer :: t_lumpedmass, q_lumpedmass
3499- type(scalar_field) :: t_lumpedmass_old, t_lumpedmass_new
3500- type(scalar_field) :: rhs, lumpedmass, advit_tfield, l_old_tfield
3501+ type(scalar_field), pointer :: t_cvmass, q_cvmass, t_abs_src_cvmass
3502+ type(scalar_field) :: t_cvmass_old, t_cvmass_new
3503+ type(scalar_field) :: rhs, cvmass, advit_tfield, l_old_tfield
3504 ! Diffusion contribution to rhs
3505 type(scalar_field) :: diff_rhs
3506-
3507+
3508+ ! Porosity field
3509+ type(scalar_field) :: porosity_theta
3510+ type(scalar_field), target :: t_cvmass_with_porosity
3511+ logical :: include_porosity
3512+
3513 ! local copy of option_path for solution field
3514 character(len=OPTION_PATH_LEN) :: option_path, tdensity_option_path
3515
3516@@ -167,15 +177,15 @@
3517 type(cv_options_type) :: tfield_options, tdensity_options
3518
3519 ! a dummy density in case we're solving for Advection
3520- type(scalar_field), pointer :: dummyscalar
3521+ type(scalar_field), pointer :: dummyscalar, dummydensity
3522 type(vector_field), pointer :: dummyvector
3523 type(tensor_field), pointer :: dummytensor
3524 ! somewhere to put strings temporarily
3525 character(len=FIELD_NAME_LEN) :: tmpstring
3526 ! what equation type are we solving for?
3527 integer :: equation_type
3528- ! success indicator and iterators
3529- integer :: stat, i, j
3530+ ! success indicator
3531+ integer :: stat
3532 ! the courant number field
3533 type(scalar_field) :: cfl_no
3534 ! nonlinear and grid velocities
3535@@ -186,6 +196,9 @@
3536 type(scalar_field), pointer :: sink
3537 !! Direction of gravity
3538 type(vector_field), pointer :: gravity
3539+ !! Temporary pointer to the material_phase's Velocity field
3540+ type(vector_field), pointer :: temp_velocity_ptr
3541+ character(len=FIELD_NAME_LEN) :: velocity_equation_type
3542
3543 ! assume explicitness?
3544 logical :: explicit
3545@@ -233,6 +246,13 @@
3546 call allocate(dummytensor, tfield%mesh, name="DummyTensor", field_type=FIELD_TYPE_CONSTANT)
3547 call zero(dummytensor)
3548 dummytensor%option_path = " "
3549+
3550+ ! Allocate a dummy density field set to 1.0 in case we are using KEpsilon,
3551+ ! but have a Boussinesq or Drainage equation_type for Velocity.
3552+ allocate(dummydensity)
3553+ call allocate(dummydensity, tfield%mesh, name="DummyDensity", field_type=FIELD_TYPE_CONSTANT)
3554+ call set(dummydensity, 1.0)
3555+ dummydensity%option_path = " "
3556
3557 ! find out equation type and hence if density is needed or not
3558 equation_type=equation_type_index(trim(option_path))
3559@@ -244,6 +264,30 @@
3560 tdensity=>dummyscalar
3561 oldtdensity=>dummyscalar
3562
3563+ case(FIELD_EQUATION_KEPSILON)
3564+ ! Depending on the equation type, extract the density or set it to some dummy field allocated above
3565+ temp_velocity_ptr => extract_vector_field(state(1), "Velocity")
3566+ call get_option(trim(temp_velocity_ptr%option_path)//"/prognostic/equation[0]/name", velocity_equation_type)
3567+ select case(velocity_equation_type)
3568+ case("LinearMomentum")
3569+ include_density = .true.
3570+ tdensity=>extract_scalar_field(state(1), "Density")
3571+ oldtdensity=>extract_scalar_field(state(1), "OldDensity")
3572+
3573+ if(have_option(trim(tdensity%option_path)//"/prognostic")) then
3574+ prognostic_density = .true.
3575+ end if
3576+ case("Boussinesq")
3577+ tdensity => dummydensity
3578+ oldtdensity => dummydensity
3579+ case("Drainage")
3580+ tdensity => dummydensity
3581+ oldtdensity => dummydensity
3582+ case default
3583+ ! developer error... out of sync options input and code
3584+ FLAbort("Unknown equation type for velocity")
3585+ end select
3586+
3587 case(FIELD_EQUATION_CONSERVATIONOFMASS, FIELD_EQUATION_REDUCEDCONSERVATIONOFMASS, &
3588 FIELD_EQUATION_INTERNALENERGY, FIELD_EQUATION_HEATTRANSFER )
3589 call get_option(trim(option_path)//'/prognostic/equation[0]/density[0]/name', &
3590@@ -254,17 +298,28 @@
3591 ! careful with priority ordering
3592 tdensity=>extract_scalar_field(state(1), trim(tmpstring))
3593 ewrite_minmax(tdensity)
3594+
3595 ! halo exchange? - not currently necessary when suboptimal halo exchange if density
3596 ! is solved for with this subroutine and the correct priority ordering.
3597 oldtdensity=>extract_scalar_field(state(1), "Old"//trim(tmpstring))
3598 ewrite_minmax(oldtdensity)
3599+
3600+ if(have_option(trim(tdensity%option_path)//"/prognostic")) then
3601+ prognostic_density = .true.
3602+ end if
3603 end select
3604
3605 ! get the density option path
3606- if(have_option(trim(option_path)//'/prognostic/equation[0]/density[0]/discretisation_options')) then
3607- tdensity_option_path = trim(option_path)//'/prognostic/equation[0]/density[0]/discretisation_options'
3608- else
3609- tdensity_option_path = trim(tdensity%option_path)
3610+ if(include_density) then
3611+ if(prognostic_density) then
3612+ if(have_option(trim(option_path)//'/prognostic/equation[0]/density[0]/discretisation_options')) then
3613+ tdensity_option_path = trim(option_path)//'/prognostic/equation[0]/density[0]/discretisation_options'
3614+ else
3615+ tdensity_option_path = trim(tdensity%option_path)
3616+ end if
3617+ else
3618+ tdensity_option_path = trim(tfield%option_path)
3619+ end if
3620 end if
3621
3622 ! now we can get the options for these fields
3623@@ -333,6 +388,13 @@
3624 if(.not.include_source) then
3625 source=>dummyscalar
3626 else
3627+ add_src_directly_to_rhs = have_option(trim(source%option_path)//'/diagnostic/add_directly_to_rhs')
3628+
3629+ if (add_src_directly_to_rhs) then
3630+ ewrite(2, *) "Adding Source field directly to the right hand side"
3631+ assert(node_count(source) == node_count(tfield))
3632+ end if
3633+
3634 ewrite_minmax(source)
3635 end if
3636
3637@@ -344,7 +406,7 @@
3638 else
3639 ewrite_minmax(absorption)
3640 end if
3641-
3642+
3643 ! create control volume shape functions
3644 call get_option("/geometry/quadrature/controlvolume_surface_degree", &
3645 quaddegree, default=1)
3646@@ -470,9 +532,9 @@
3647 FLExit("Can't be explicit and exclude the mass terms.")
3648 end if
3649
3650- ! allocate a local lumpedmass field because it will get modified by bc etc.
3651- call allocate(lumpedmass, tfield%mesh, name=trim(field_name)//"LumpedMass")
3652- call zero(lumpedmass)
3653+ ! allocate a local cvmass field because it will get modified by bc etc.
3654+ call allocate(cvmass, tfield%mesh, name=trim(field_name)//"CVMass")
3655+ call zero(cvmass)
3656 end if
3657
3658 if(include_diffusion) then
3659@@ -485,35 +547,54 @@
3660
3661 ! allocate the rhs of the equation
3662 call allocate(rhs, tfield%mesh, name=trim(field_name)//"RHS")
3663-
3664- if(tfield%mesh%shape%degree>1) then
3665- ! try lumping on the submesh
3666- t_lumpedmass => get_lumped_mass_on_submesh(state, tfield%mesh)
3667- else
3668- ! then find the lumped mass
3669- ! (this replaces hart2/3d etc. in old code!!)
3670- t_lumpedmass => get_lumped_mass(state, tfield%mesh)
3671- end if
3672- ewrite_minmax(t_lumpedmass)
3673+
3674+ ! are we including a porosity coefficient on the time term?
3675+ if (have_option(trim(complete_field_path(tfield%option_path))//'/porosity')) then
3676+ include_porosity = .true.
3677+
3678+ ! get the porosity theta averaged field - this will allocate it
3679+ call form_porosity_theta(porosity_theta, state(1), &
3680+ &option_path = trim(complete_field_path(tfield%option_path))//'/porosity')
3681+
3682+ call allocate(t_cvmass_with_porosity, tfield%mesh, name="CVMassWithPorosity")
3683+ call compute_cv_mass(x, t_cvmass_with_porosity, porosity_theta)
3684+ ewrite_minmax(t_cvmass_with_porosity)
3685+
3686+ call deallocate(porosity_theta)
3687+ else
3688+ include_porosity = .false.
3689+ end if
3690+
3691+ ! find the cv mass that is used for the absorption and source terms
3692+ t_abs_src_cvmass => get_cv_mass(state, tfield%mesh)
3693+ ewrite_minmax(t_abs_src_cvmass)
3694+
3695+ ! find the cv mass that is used for the time term derivative
3696+ if (include_porosity) then
3697+ t_cvmass => t_cvmass_with_porosity
3698+ else
3699+ t_cvmass => t_abs_src_cvmass
3700+ end if
3701+ ewrite_minmax(t_cvmass)
3702
3703 move_mesh = have_option("/mesh_adaptivity/mesh_movement")
3704 if(move_mesh) then
3705 if(.not.include_advection) then
3706 FLExit("Moving the mesh but not including advection is not possible yet.")
3707 end if
3708+ if (include_porosity) then
3709+ FLExit("Moving mesh not set up to work when including porosity")
3710+ end if
3711 ewrite(2,*) "Moving mesh."
3712 x_old=>extract_vector_field(state(1), "OldCoordinate")
3713 x_new=>extract_vector_field(state(1), "IteratedCoordinate")
3714- call allocate(t_lumpedmass_old, tfield%mesh, name=trim(field_name)//"OldLumpedMass")
3715- call allocate(t_lumpedmass_new, tfield%mesh, name=trim(field_name)//"NewLumpedMass")
3716- if(tfield%mesh%shape%degree>1) then
3717- FLExit("Lumping on submesh while moving the mesh not set up.")
3718- else
3719- call compute_lumped_mass(x_old, t_lumpedmass_old)
3720- call compute_lumped_mass(x_new, t_lumpedmass_new)
3721- end if
3722- ewrite_minmax(t_lumpedmass_old)
3723- ewrite_minmax(t_lumpedmass_new)
3724+ call allocate(t_cvmass_old, tfield%mesh, name=trim(field_name)//"OldCVMass")
3725+ call allocate(t_cvmass_new, tfield%mesh, name=trim(field_name)//"NewCVMass")
3726+
3727+ call compute_cv_mass(x_old, t_cvmass_old)
3728+ call compute_cv_mass(x_new, t_cvmass_new)
3729+ ewrite_minmax(t_cvmass_old)
3730+ ewrite_minmax(t_cvmass_new)
3731
3732 ug=>extract_vector_field(state(1), "GridVelocity")
3733 ewrite_minmax(ug)
3734@@ -531,12 +612,12 @@
3735
3736 if(include_diffusion.and.(tfield_options%diffusionscheme==CV_DIFFUSION_BASSIREBAY)) then
3737 if(.not.(tfield%mesh==diffusivity%mesh)) then
3738- q_lumpedmass => get_lumped_mass(state, diffusivity%mesh)
3739+ q_cvmass => get_cv_mass(state, diffusivity%mesh)
3740 else
3741- q_lumpedmass => t_lumpedmass
3742+ q_cvmass => t_cvmass
3743 end if
3744 else
3745- q_lumpedmass => t_lumpedmass
3746+ q_cvmass => t_cvmass
3747 end if
3748
3749 ! allocate a field to store the locally iterated values in
3750@@ -576,6 +657,9 @@
3751 ! yes, we're subcycling
3752 ! we should have already calculated the courant number (or aborted in the attempt)
3753 no_subcycles=ceiling(max_cfl/max_sub_cfl)
3754+ if(include_diffusion.or.include_source.or.include_absorption) then
3755+ no_subcycles = max(no_subcycles, 1)
3756+ end if
3757 if(no_subcycles>1) then
3758 sub_dt=dt/real(no_subcycles)
3759 call scale(cfl_no, 1.0/real(no_subcycles))
3760@@ -626,25 +710,25 @@
3761 t_cvshape_full, t_cvbdyshape_full, &
3762 diff_cvshape_full, diff_cvbdyshape_full, &
3763 state, advu, ug, x, x_tfield, cfl_no, sub_dt, &
3764- diffusivity, q_lumpedmass, &
3765+ diffusivity, q_cvmass, &
3766 mesh_sparsity_x, grad_m_t_sparsity)
3767 end if
3768
3769 ! assemble it all into a coherent equation
3770- call assemble_field_eqn_cv(M, A_m, lumpedmass, rhs, &
3771+ call assemble_field_eqn_cv(M, A_m, cvmass, rhs, &
3772 tfield, l_old_tfield, &
3773 tdensity, oldtdensity, tdensity_options, &
3774 source, absorption, tfield_options%theta, &
3775 state, advu, sub_dt, explicit, &
3776- t_lumpedmass, t_lumpedmass_old, t_lumpedmass_new, &
3777+ t_cvmass, t_abs_src_cvmass, t_cvmass_old, t_cvmass_new, &
3778 D_m, diff_rhs)
3779
3780
3781 ! Solve for the change in tfield.
3782 if(explicit) then
3783- call apply_dirichlet_conditions(lumpedmass, rhs, tfield, sub_dt)
3784+ call apply_dirichlet_conditions(cvmass, rhs, tfield, sub_dt)
3785
3786- delta_tfield%val = rhs%val/lumpedmass%val
3787+ delta_tfield%val = rhs%val/cvmass%val
3788 else
3789 ! apply strong dirichlet boundary conditions (if any)
3790 ! note that weak conditions (known as control volume boundary conditions)
3791@@ -662,7 +746,7 @@
3792
3793 call halo_update(tfield) ! exchange the extended halos
3794
3795- call test_and_write_advection_convergence(tfield, advit_tfield, x, &
3796+ call test_and_write_advection_convergence(tfield, advit_tfield, x, t_cvmass, &
3797 filename=trim(state(1)%name)//"__"//trim(tfield%name), &
3798 time=time+sub_dt, dt=sub_dt, it=global_it, adv_it=adv_it, &
3799 subcyc=sub, error=error)
3800@@ -682,7 +766,7 @@
3801 call deallocate(rhs)
3802 if(.not.explicit) call deallocate(A_m)
3803 if(.not.explicit) call deallocate(M)
3804- if(explicit) call deallocate(lumpedmass)
3805+ if(explicit) call deallocate(cvmass)
3806 call deallocate(cfl_no)
3807 call deallocate(x_cvbdyshape)
3808 call deallocate(x_cvbdyshape_full)
3809@@ -706,29 +790,34 @@
3810 deallocate(dummyvector)
3811 call deallocate(dummytensor)
3812 deallocate(dummytensor)
3813+ call deallocate(dummydensity)
3814+ deallocate(dummydensity)
3815 if (include_diffusion) then
3816 call deallocate(D_m)
3817 call deallocate(diff_rhs)
3818 end if
3819 call deallocate(x_tfield)
3820 if(move_mesh) then
3821- call deallocate(t_lumpedmass_new)
3822- call deallocate(t_lumpedmass_old)
3823+ call deallocate(t_cvmass_new)
3824+ call deallocate(t_cvmass_old)
3825 end if
3826 call deallocate(ug_cvshape)
3827 call deallocate(ug_cvbdyshape)
3828+ if (include_porosity) then
3829+ call deallocate(t_cvmass_with_porosity)
3830+ end if
3831
3832 end subroutine solve_field_eqn_cv
3833 ! end of solution wrapping subroutines
3834 !************************************************************************
3835 !************************************************************************
3836 ! equation wrapping subroutines
3837- subroutine assemble_field_eqn_cv(M, A_m, m_lumpedmass, rhs, &
3838+ subroutine assemble_field_eqn_cv(M, A_m, m_cvmass, rhs, &
3839 tfield, oldtfield, &
3840 tdensity, oldtdensity, tdensity_options, &
3841 source, absorption, theta, &
3842 state, advu, dt, explicit, &
3843- lumpedmass, lumpedmass_old, lumpedmass_new, &
3844+ cvmass, abs_src_cvmass, cvmass_old, cvmass_new, &
3845 D_m, diff_rhs)
3846
3847 ! This subroutine assembles the equation
3848@@ -744,8 +833,8 @@
3849 ! matrix containing advective terms - to be incorporated
3850 ! into M during this subroutine
3851 type(csr_matrix), intent(inout) :: A_m
3852- ! rhs of equation
3853- type(scalar_field), intent(inout) :: m_lumpedmass, rhs
3854+ ! explicit lhs and rhs of equation
3855+ type(scalar_field), intent(inout) :: m_cvmass, rhs
3856 ! the field we are solving for
3857 type(scalar_field), intent(inout) :: tfield
3858 type(scalar_field), intent(inout) :: oldtfield, tdensity, oldtdensity
3859@@ -762,10 +851,14 @@
3860 real, intent(in) :: dt
3861 ! are we assuming this is a fully explicit equation?
3862 logical, intent(in) :: explicit
3863+ ! cv mass to use for time derivative term
3864+ type(scalar_field), intent(in) :: cvmass
3865 ! moving mesh stuff
3866- type(scalar_field), intent(in) :: lumpedmass
3867- type(scalar_field), intent(in) :: lumpedmass_old
3868- type(scalar_field), intent(in) :: lumpedmass_new
3869+ type(scalar_field), intent(in) :: cvmass_old
3870+ type(scalar_field), intent(in) :: cvmass_new
3871+ ! cv mass to use for absorption and source
3872+ type(scalar_field), intent(in) :: abs_src_cvmass
3873+
3874 ! diffusion:
3875 type(csr_matrix), intent(inout), optional :: D_m
3876 type(scalar_field), intent(inout), optional :: diff_rhs
3877@@ -809,7 +902,7 @@
3878
3879 ! zero the "matrices" being assembled
3880 if(explicit) then
3881- call zero(m_lumpedmass)
3882+ call zero(m_cvmass)
3883 else
3884 call zero(M)
3885 end if
3886@@ -818,36 +911,36 @@
3887 if(include_mass) then
3888 if(move_mesh) then
3889 if(explicit) then
3890- call set(m_lumpedmass, lumpedmass_new)
3891+ call set(m_cvmass, cvmass_new)
3892 else
3893- call addto_diag(M, lumpedmass_new)
3894+ call addto_diag(M, cvmass_new)
3895 end if
3896 else
3897 if(explicit) then
3898- call set(m_lumpedmass, lumpedmass)
3899+ call set(m_cvmass, cvmass)
3900 else
3901- call addto_diag(M, lumpedmass)
3902+ call addto_diag(M, cvmass)
3903 end if
3904 end if
3905 end if
3906
3907 ! allocate some memory for assembly
3908 call allocate(MT_old, rhs%mesh, name="MT_oldProduct" )
3909- if(include_source) then
3910+ if(include_source .and. (.not. add_src_directly_to_rhs)) then
3911 call allocate(masssource, rhs%mesh, name="MassSourceProduct" )
3912- call set(masssource, lumpedmass)
3913+ call set(masssource, abs_src_cvmass)
3914 call scale(masssource, source)
3915 end if
3916 if(include_absorption) then
3917 call allocate(massabsorption, rhs%mesh, name="MassAbsorptionProduct" )
3918- call set(massabsorption, lumpedmass)
3919+ call set(massabsorption, abs_src_cvmass)
3920 call scale(massabsorption, absorption)
3921 end if
3922
3923 if(move_mesh) then
3924 call allocate(massconservation, rhs%mesh, name="MovingMeshMassConservation")
3925- call set(massconservation, lumpedmass_old)
3926- call addto(massconservation, lumpedmass_new, scale=-1.0)
3927+ call set(massconservation, cvmass_old)
3928+ call addto(massconservation, cvmass_new, scale=-1.0)
3929 call scale(massconservation, 1./dt)
3930 call scale(massconservation, oldtfield)
3931 end if
3932@@ -875,7 +968,7 @@
3933 end if
3934
3935
3936- if(include_source) call addto(rhs, masssource)
3937+ if(include_source .and. (.not. add_src_directly_to_rhs)) call addto(rhs, masssource)
3938
3939 if(include_absorption) then
3940 ! massabsorption has already been added to the matrix so it can now be scaled
3941@@ -909,7 +1002,7 @@
3942 call addto(consterm, oldtdensity, -1.0)
3943 call scale(consterm, oldtfield)
3944 call scale(consterm, 1./dt)
3945- call scale(consterm, lumpedmass)
3946+ call scale(consterm, cvmass)
3947
3948 call addto(rhs, consterm, -1.0)
3949
3950@@ -920,7 +1013,7 @@
3951 ! multiply the diagonal of M by the up to date density
3952 if(explicit) then
3953 if(include_mass) then
3954- call scale(m_lumpedmass, tdensity)
3955+ call scale(m_cvmass, tdensity)
3956 end if
3957 else
3958 if(include_mass) then
3959@@ -936,7 +1029,7 @@
3960 end if
3961 end if
3962
3963- if(include_source) call addto(rhs, masssource)
3964+ if(include_source .and. (.not. add_src_directly_to_rhs)) call addto(rhs, masssource)
3965
3966 if(include_absorption) then
3967 ! massabsorption has already been added to the matrix so it can now be scaled
3968@@ -968,7 +1061,7 @@
3969 ! multiply the diagonal by the previous timesteps density
3970 if(explicit) then
3971 if(include_mass) then
3972- m_lumpedmass%val = m_lumpedmass%val*(tdensity_theta*tdensity%val+(1.0-tdensity_theta)*oldtdensity%val)
3973+ m_cvmass%val = m_cvmass%val*(tdensity_theta*tdensity%val+(1.0-tdensity_theta)*oldtdensity%val)
3974 end if
3975 else
3976 if(include_mass) then
3977@@ -984,7 +1077,7 @@
3978 end if
3979 end if
3980
3981- if(include_source) call addto(rhs, masssource)
3982+ if(include_source .and. (.not. add_src_directly_to_rhs)) call addto(rhs, masssource)
3983
3984 if(include_absorption) then
3985 ! massabsorption has already been added to the matrix so it can now be scaled
3986@@ -1016,7 +1109,7 @@
3987 ! multiply the diagonal by the previous timesteps density
3988 if(explicit) then
3989 if(include_mass) then
3990- m_lumpedmass%val = m_lumpedmass%val*(tdensity_theta*tdensity%val+(1.0-tdensity_theta)*oldtdensity%val)
3991+ m_cvmass%val = m_cvmass%val*(tdensity_theta*tdensity%val+(1.0-tdensity_theta)*oldtdensity%val)
3992 end if
3993 else
3994 if(include_mass) then
3995@@ -1032,7 +1125,7 @@
3996 end if
3997 end if
3998
3999- if(include_source) call addto(rhs, masssource)
4000+ if(include_source .and. (.not. add_src_directly_to_rhs)) call addto(rhs, masssource)
4001
4002 if(include_absorption) then
4003 ! massabsorption has already been added to the matrix so it can now be scaled
4004@@ -1087,22 +1180,67 @@
4005 ! construct M
4006 if(explicit) then
4007 if(include_mass) then
4008- call scale(m_lumpedmass, tdensity)
4009- end if
4010- else
4011- if(include_mass) then
4012- call mult_diag(M, tdensity)
4013- end if
4014- if(include_advection) call addto(M, A_m, dt)
4015- if(include_absorption) call addto_diag(M, massabsorption, theta*dt)
4016-
4017- if(include_advection) then
4018- call mult(MT_old, A_m, oldtfield)
4019- call addto(rhs, MT_old, -1.0)
4020- end if
4021- end if
4022-
4023- if(include_source) call addto(rhs, masssource)
4024+ call scale(m_cvmass, tdensity)
4025+ end if
4026+ else
4027+ if(include_mass) then
4028+ call mult_diag(M, tdensity)
4029+ end if
4030+ if(include_advection) call addto(M, A_m, dt)
4031+ if(include_absorption) call addto_diag(M, massabsorption, theta*dt)
4032+
4033+ if(include_advection) then
4034+ call mult(MT_old, A_m, oldtfield)
4035+ call addto(rhs, MT_old, -1.0)
4036+ end if
4037+ end if
4038+
4039+ if(include_source .and. (.not. add_src_directly_to_rhs)) call addto(rhs, masssource)
4040+
4041+ if(include_absorption) then
4042+ ! massabsorption has already been added to the matrix so it can now be scaled
4043+ ! by the old field value to add it to the rhs
4044+ call scale(massabsorption, oldtfield)
4045+ call addto(rhs, massabsorption, -1.0)
4046+ end if
4047+
4048+ if(include_diffusion) then
4049+ call mult(MT_old, D_m, oldtfield)
4050+ call addto(rhs, MT_old, -1.0)
4051+ call addto(rhs, diff_rhs, -1.0)
4052+
4053+ if(.not.explicit) then
4054+ call addto(M, D_m, theta*dt)
4055+ end if
4056+ end if
4057+
4058+ if(move_mesh) then
4059+ FLExit("Moving mesh with this equation type not yet supported.")
4060+ end if
4061+
4062+ case (FIELD_EQUATION_KEPSILON)
4063+
4064+ ! [\rho^{n+1}M + dt*A_m + dt*theta*D_m](T^{n+1}-T^{n})/dt = rhs - [A_m + D_m]*T^{n} - diff_rhs
4065+
4066+ ! construct M
4067+ if(explicit) then
4068+ if(include_mass) then
4069+ call scale(m_cvmass, tdensity)
4070+ end if
4071+ else
4072+ if(include_mass) then
4073+ call mult_diag(M, tdensity)
4074+ end if
4075+ if(include_advection) call addto(M, A_m, dt)
4076+ if(include_absorption) call addto_diag(M, massabsorption, theta*dt)
4077+
4078+ if(include_advection) then
4079+ call mult(MT_old, A_m, oldtfield)
4080+ call addto(rhs, MT_old, -1.0)
4081+ end if
4082+ end if
4083+
4084+ if(include_source .and. (.not. add_src_directly_to_rhs)) call addto(rhs, masssource)
4085
4086 if(include_absorption) then
4087 ! massabsorption has already been added to the matrix so it can now be scaled
4088@@ -1127,7 +1265,11 @@
4089
4090 end select
4091
4092- if(include_source) call deallocate(masssource)
4093+ ! Add the source directly to the rhs if required
4094+ ! which must be included before dirichlet BC's.
4095+ if (add_src_directly_to_rhs) call addto(rhs, source)
4096+
4097+ if(include_source .and. (.not. add_src_directly_to_rhs)) call deallocate(masssource)
4098 if(include_absorption) call deallocate(massabsorption)
4099 call deallocate(MT_old)
4100 if(move_mesh) call deallocate(massconservation)
4101@@ -1149,7 +1291,7 @@
4102 t_cvshape_full, t_cvbdyshape_full, &
4103 diff_cvshape_full, diff_cvbdyshape_full, &
4104 state, advu, ug, x, x_tfield, cfl_no, dt, &
4105- diffusivity, q_lumpedmass, &
4106+ diffusivity, q_cvmass, &
4107 mesh_sparsity, grad_m_t_sparsity)
4108
4109 ! This subroutine assembles the advection and diffusion matrices and rhs(s) for
4110@@ -1210,8 +1352,8 @@
4111
4112 ! the diffusivity tensor
4113 type(tensor_field), intent(in) :: diffusivity
4114- ! the lumped mass = the mass matrix for the auxilliary diffusion equation
4115- type(scalar_field), intent(in) :: q_lumpedmass
4116+ ! the cv mass = the mass matrix for the auxilliary diffusion equation
4117+ type(scalar_field), intent(in) :: q_cvmass
4118 ! sparsity pattern for the gradient transposed operator
4119 type(csr_sparsity), intent(inout) :: grad_m_t_sparsity
4120
4121@@ -1219,6 +1361,7 @@
4122 ! memory for coordinates, velocity, normals, determinants, nodes
4123 ! and the cfl number at the gauss pts and nodes
4124 real, dimension(x%dim,ele_loc(x,1)) :: x_ele
4125+ real, dimension(x%dim,ele_loc(tfield,1)) :: xt_ele
4126 real, dimension(x%dim,face_loc(x,1)) :: x_ele_bdy
4127 real, dimension(x%dim,x_cvshape%ngi) :: x_f
4128 real, dimension(advu%dim,u_cvshape%ngi) :: u_f
4129@@ -1268,7 +1411,7 @@
4130 ! the type of the bc if integrating over domain boundaries
4131 integer, dimension(:), allocatable :: tfield_bc_type, tdensity_bc_type
4132 ! fields for the bcs over the entire surface mesh
4133- type(scalar_field) :: tfield_bc, tdensity_bc
4134+ type(scalar_field) :: tfield_bc, tfield_bc2, tdensity_bc
4135
4136 ! local element matrices - allow the assembly of an entire face without multiple calls to csr_pos
4137 real, dimension(mesh_dim(tfield), ele_loc(tfield,1), ele_loc(tfield,1)) :: grad_mat_local
4138@@ -1277,6 +1420,11 @@
4139 real, dimension(mesh_dim(tfield), face_loc(tfield,1)) :: grad_mat_local_bdy, grad_rhs_local_bdy
4140 real, dimension(face_loc(tfield,1)) :: mat_local_bdy, rhs_local_bdy, div_rhs_local_bdy
4141 real, dimension(ele_loc(tfield,1)) :: rhs_local
4142+
4143+ ! Data associated with Robin BC's.
4144+ real, dimension(face_loc(tfield,1)) :: robin_diff_mat_local_bdy
4145+ real, dimension(face_loc(tfield,1)) :: robin_diff_rhs_local_bdy
4146+ real, dimension(face_loc(tfield,1)) :: robin_bc_val1_ele_bdy, robin_bc_val2_ele_bdy
4147
4148 ! the auxilliary gradient matrix (assembled as a divergence confusingly)
4149 type(block_csr_matrix) :: div_m
4150@@ -1293,7 +1441,7 @@
4151
4152 ! Boundary condition types
4153 integer, parameter :: BC_TYPE_WEAKDIRICHLET = 1, BC_TYPE_NEUMANN = 2, BC_TYPE_INTERNAL = 3, &
4154- BC_TYPE_ZEROFLUX = 4, BC_TYPE_FLUX = 5
4155+ BC_TYPE_ZEROFLUX = 4, BC_TYPE_FLUX = 5, BC_TYPE_ROBIN = 6
4156
4157 ewrite(1, *) "In assemble_advectiondiffusion_m_cv"
4158
4159@@ -1365,6 +1513,7 @@
4160 ! loop over elements
4161 element_loop: do ele=1, element_count(tfield)
4162 x_ele=ele_val(x, ele)
4163+ xt_ele=ele_val(x_tfield, ele)
4164 x_f=ele_val_at_quad(x, ele, x_cvshape)
4165 nodes=>ele_nodes(tfield, ele)
4166 ! the nodes in this element from the coordinate mesh projected
4167@@ -1477,7 +1626,7 @@
4168 tfield_face_val, &
4169 oldtfield_face_val, &
4170 tfield_options%theta, dt, udotn, &
4171- x_ele, tfield_options%limit_theta, &
4172+ xt_ele, tfield_options%limit_theta, &
4173 tfield_ele, oldtfield_ele, &
4174 ftheta=ftheta)
4175
4176@@ -1505,7 +1654,7 @@
4177 tdensity_face_val, &
4178 oldtdensity_face_val, &
4179 tdensity_options%theta, dt, udotn, &
4180- x_ele, tdensity_options%limit_theta, &
4181+ xt_ele, tdensity_options%limit_theta, &
4182 tdensity_ele, oldtdensity_ele)
4183
4184 if(assemble_advection_matrix) then
4185@@ -1637,7 +1786,8 @@
4186 "neumann ", &
4187 "internal ", &
4188 "zero_flux ", &
4189- "flux "/), tfield_bc, tfield_bc_type)
4190+ "flux ", &
4191+ "robin "/), tfield_bc, tfield_bc_type, boundary_second_value = tfield_bc2)
4192 if(include_density) then
4193 allocate(tdensity_bc_type(surface_element_count(tdensity)))
4194 call get_entire_boundary_condition(tdensity, (/"weakdirichlet"/), tdensity_bc, tdensity_bc_type)
4195@@ -1719,7 +1869,17 @@
4196 end if
4197
4198 if(assemble_diffusion) then
4199- ghost_gradtfield_ele_bdy = ele_val(tfield_bc, sele)
4200+ if (tfield_bc_type(sele)==BC_TYPE_ROBIN) then
4201+ if (.not. tfield_options%diffusionscheme == CV_DIFFUSION_ELEMENTGRADIENT) then
4202+ FLExit('Can only use CV robin BC with ElementGradient diffusion scheme')
4203+ end if
4204+ robin_bc_val1_ele_bdy = ele_val(tfield_bc, sele)
4205+ robin_bc_val2_ele_bdy = ele_val(tfield_bc2, sele)
4206+ robin_diff_mat_local_bdy = 0.0
4207+ robin_diff_rhs_local_bdy = 0.0
4208+ else
4209+ ghost_gradtfield_ele_bdy = ele_val(tfield_bc, sele)
4210+ end if
4211 end if
4212
4213 ! zero small matrices for assembly
4214@@ -1869,6 +2029,18 @@
4215 div_rhs_local_bdy(iloc) = div_rhs_local_bdy(iloc) &
4216 -detwei_bdy(ggi)*ghost_gradtfield_ele_bdy(iloc)
4217
4218+ else if (tfield_bc_type(sele)==BC_TYPE_ROBIN) then
4219+
4220+ ! Add first coeff term to rhs
4221+ robin_diff_rhs_local_bdy(iloc) = robin_diff_rhs_local_bdy(iloc) - &
4222+ detwei_bdy(ggi) * &
4223+ robin_bc_val1_ele_bdy(iloc)
4224+
4225+ ! Add implicit second coeff * tfield term to matrix
4226+ robin_diff_mat_local_bdy(iloc) = robin_diff_mat_local_bdy(iloc) + &
4227+ detwei_bdy(ggi) * &
4228+ robin_bc_val2_ele_bdy(iloc)
4229+
4230 else
4231
4232 ! because transform to physical doesn't give the full gradient at a face
4233@@ -1927,6 +2099,12 @@
4234
4235 call addto(diff_rhs, nodes_bdy, div_rhs_local_bdy)
4236
4237+ else if (tfield_bc_type(sele)==BC_TYPE_ROBIN) then
4238+
4239+ call addto(diff_rhs, nodes_bdy, robin_diff_rhs_local_bdy)
4240+
4241+ call addto_diag(D_m, nodes_bdy, robin_diff_mat_local_bdy)
4242+
4243 else
4244
4245 ! assume zero neumann for the moment
4246@@ -1948,21 +2126,23 @@
4247
4248 if(assemble_diffusion.and.(tfield_options%diffusionscheme==CV_DIFFUSION_BASSIREBAY)) then
4249
4250- ! assemble div_m and q_lumpedmass into the final D_m
4251+ ! assemble div_m and q_cvmass into the final D_m
4252 call assemble_bassirebay_diffusion_m_cv(D_m, diff_rhs, &
4253 div_m, grad_rhs, &
4254- diffusivity, q_lumpedmass)
4255+ diffusivity, q_cvmass)
4256 ! ElementGradient assembles D_m directly so no need for a step like this
4257
4258 end if
4259
4260 deallocate(tfield_bc_type)
4261 call deallocate(tfield_bc)
4262+ call deallocate(tfield_bc2)
4263 call deallocate(tfield_upwind)
4264 call deallocate(oldtfield_upwind)
4265 if(include_density) then
4266 deallocate(tdensity_bc_type)
4267 call deallocate(tdensity_bc)
4268+
4269 call deallocate(tdensity_upwind)
4270 call deallocate(oldtdensity_upwind)
4271 end if
4272@@ -1978,7 +2158,7 @@
4273
4274 subroutine assemble_bassirebay_diffusion_m_cv(D_m, diff_rhs, &
4275 div_m, grad_rhs, &
4276- diffusivity, q_lumpedmass)
4277+ diffusivity, q_cvmass)
4278
4279 type(csr_matrix), intent(inout) :: D_m
4280 type(scalar_field), intent(inout) :: diff_rhs
4281@@ -1987,7 +2167,7 @@
4282 type(vector_field), intent(inout) :: grad_rhs
4283
4284 type(tensor_field), intent(in) :: diffusivity
4285- type(scalar_field), intent(in) :: q_lumpedmass
4286+ type(scalar_field), intent(in) :: q_cvmass
4287
4288 logical :: isotropic
4289
4290@@ -1996,10 +2176,10 @@
4291 ! an optimisation that reduces the number of matrix multiplies if we're isotropic
4292 isotropic=isotropic_field(diffusivity)
4293
4294- call mult_div_tensorinvscalar_div_T(D_m, div_m, diffusivity, q_lumpedmass, div_m, &
4295+ call mult_div_tensorinvscalar_div_T(D_m, div_m, diffusivity, q_cvmass, div_m, &
4296 isotropic)
4297
4298- call mult_div_tensorinvscalar_vector(diff_rhs, div_m, diffusivity, q_lumpedmass, grad_rhs, &
4299+ call mult_div_tensorinvscalar_vector(diff_rhs, div_m, diffusivity, q_cvmass, grad_rhs, &
4300 isotropic)
4301
4302 end subroutine assemble_bassirebay_diffusion_m_cv
4303@@ -2115,14 +2295,20 @@
4304 ! sparsity structure to construct the matrices with
4305 type(csr_sparsity), pointer :: mesh_sparsity, mesh_sparsity_x
4306
4307- ! Right hand side vector, lumped mass matrix,
4308+ ! Right hand side vector, cv mass matrix,
4309 ! locally iterated field (for advection iterations)
4310 ! and local old field (for subcycling)
4311 type(scalar_field), dimension(nfields) :: rhs, advit_tfield
4312 type(scalar_field_pointer), dimension(nfields) :: l_old_tfield
4313- type(scalar_field), dimension(nfields) :: lumpedmass
4314- type(scalar_field), pointer :: t_lumpedmass
4315- type(scalar_field) :: t_lumpedmass_old, t_lumpedmass_new
4316+ type(scalar_field), dimension(nfields) :: cvmass
4317+ type(scalar_field), pointer :: t_abs_src_cvmass
4318+ type(scalar_field_pointer), dimension(nfields) :: t_cvmass
4319+ type(scalar_field) :: t_cvmass_old, t_cvmass_new
4320+
4321+ ! Porosity field
4322+ type(scalar_field) :: porosity_theta
4323+ type(scalar_field), dimension(nfields), target :: t_cvmass_with_porosity
4324+ logical, dimension(nfields) :: include_porosity
4325
4326 ! local copy of option_path for solution field
4327 character(len=OPTION_PATH_LEN), dimension(nfields) :: option_path
4328@@ -2281,6 +2467,9 @@
4329 source(f)%ptr=>extract_scalar_field(state(state_indices(f)), trim(field_name)//"Source", stat=stat)
4330 if(stat==0) then
4331 FLExit("Coupled CV broken with Sources")
4332+ ! If Coupled CV is ever fixed to work with Sources then the
4333+ ! option source(f)%option_path//'/diagnostic/add_directly_to_rhs'
4334+ ! should be accounted for.
4335 end if
4336 if(stat/=0) source(f)%ptr=>dummyscalar
4337 absorption(f)%ptr=>extract_scalar_field(state(state_indices(f)), trim(field_name)//"Absorption", stat=stat)
4338@@ -2358,23 +2547,40 @@
4339 call allocate(A_m(f), mesh_sparsity, name=trim(field_name)//int2str(f)//"AdvectionMatrix")
4340 call zero(A_m(f))
4341 else
4342- call allocate(lumpedmass(f), tfield(1)%ptr%mesh, name=trim(field_name)//"LocalLumpedMass")
4343- call zero(lumpedmass(f))
4344+ call allocate(cvmass(f), tfield(1)%ptr%mesh, name=trim(field_name)//"LocalCVMass")
4345+ call zero(cvmass(f))
4346 end if
4347
4348 ! allocate the rhs of the equation
4349 call allocate(rhs(f), tfield(f)%ptr%mesh, name=trim(field_name)//int2str(f)//"RHS")
4350 end do
4351
4352- if(element_degree(tfield(1)%ptr, 1)>1) then
4353- ! try lumping on the submesh
4354- t_lumpedmass => get_lumped_mass_on_submesh(state, tfield(1)%ptr%mesh)
4355- else
4356- ! then find the lumped mass
4357- ! (this replaces hart2/3d etc. in old code!!)
4358- t_lumpedmass => get_lumped_mass(state, tfield(1)%ptr%mesh)
4359- end if
4360- ewrite_minmax(t_lumpedmass)
4361+ ! find the cv mass that is used for the absorption and source terms
4362+ t_abs_src_cvmass => get_cv_mass(state, tfield(1)%ptr%mesh)
4363+ ewrite_minmax(t_abs_src_cvmass)
4364+
4365+ ! find the cv mass that is used for the time term derivative - which may include the porosity
4366+ do f = 1,nfields
4367+ if (have_option(trim(complete_field_path(tfield(f)%ptr%option_path))//'/porosity')) then
4368+ include_porosity(f) = .true.
4369+
4370+ ! get the porosity theta averaged field - this will allocate it
4371+ call form_porosity_theta(porosity_theta, state(state_indices(f)), &
4372+ &option_path = trim(complete_field_path(tfield(f)%ptr%option_path))//'/porosity')
4373+
4374+ call allocate(t_cvmass_with_porosity(f), tfield(f)%ptr%mesh, name="CVMassWithPorosity")
4375+ call compute_cv_mass(x, t_cvmass_with_porosity(f), porosity_theta)
4376+
4377+ call deallocate(porosity_theta)
4378+
4379+ t_cvmass(f)%ptr => t_cvmass_with_porosity(f)
4380+ else
4381+ include_porosity(f) = .false.
4382+
4383+ t_cvmass(f)%ptr => t_abs_src_cvmass
4384+ end if
4385+ ewrite_minmax(t_cvmass(f)%ptr)
4386+ end do
4387
4388 move_mesh = have_option("/mesh_adaptivity/mesh_movement")
4389 if(move_mesh) then
4390@@ -2382,19 +2588,19 @@
4391 if(.not.include_advection) then
4392 FLExit("Moving the mesh but not including advection is not possible yet.")
4393 end if
4394+ if (any(include_porosity)) then
4395+ FLExit("Moving mesh not set up to work when including porosity")
4396+ end if
4397 ewrite(2,*) "Moving mesh."
4398 x_old=>extract_vector_field(state(1), "OldCoordinate")
4399 x_new=>extract_vector_field(state(1), "IteratedCoordinate")
4400- call allocate(t_lumpedmass_old, tfield(1)%ptr%mesh, name=trim(field_name)//"OldLumpedMass")
4401- call allocate(t_lumpedmass_new, tfield(1)%ptr%mesh, name=trim(field_name)//"NewLumpedMass")
4402- if(tfield(1)%ptr%mesh%shape%degree>1) then
4403- FLExit("Lumping on submesh while moving the mesh not set up.")
4404- else
4405- call compute_lumped_mass(x_old, t_lumpedmass_old)
4406- call compute_lumped_mass(x_new, t_lumpedmass_new)
4407- end if
4408- ewrite_minmax(t_lumpedmass_old)
4409- ewrite_minmax(t_lumpedmass_new)
4410+ call allocate(t_cvmass_old, tfield(1)%ptr%mesh, name=trim(field_name)//"OldCVMass")
4411+ call allocate(t_cvmass_new, tfield(1)%ptr%mesh, name=trim(field_name)//"NewCVMass")
4412+
4413+ call compute_cv_mass(x_old, t_cvmass_old)
4414+ call compute_cv_mass(x_new, t_cvmass_new)
4415+ ewrite_minmax(t_cvmass_old)
4416+ ewrite_minmax(t_cvmass_new)
4417
4418 ug=>extract_vector_field(state(1), "GridVelocity")
4419 ewrite_minmax(ug)
4420@@ -2517,18 +2723,18 @@
4421 do f = 1, nfields
4422
4423 ! assemble it all into a coherent equation
4424- call assemble_field_eqn_cv(M(f), A_m(f), lumpedmass(f), rhs(f), &
4425+ call assemble_field_eqn_cv(M(f), A_m(f), cvmass(f), rhs(f), &
4426 tfield(f)%ptr, l_old_tfield(f)%ptr, &
4427 tdensity(f)%ptr, oldtdensity(f)%ptr, tdensity_options(f), &
4428 source(f)%ptr, absorption(f)%ptr, tfield_options(f)%theta, &
4429 state(state_indices(f):state_indices(f)), advu, sub_dt, explicit(f), &
4430- t_lumpedmass, t_lumpedmass_old, t_lumpedmass_new)
4431+ t_cvmass(f)%ptr, t_abs_src_cvmass, t_cvmass_old, t_cvmass_new)
4432
4433 ! Solve for the change in tfield.
4434 if(explicit(f)) then
4435- call apply_dirichlet_conditions(lumpedmass(f), rhs(f), tfield(f)%ptr, sub_dt)
4436+ call apply_dirichlet_conditions(cvmass(f), rhs(f), tfield(f)%ptr, sub_dt)
4437
4438- delta_tfield(f)%val = rhs(f)%val/lumpedmass(f)%val
4439+ delta_tfield(f)%val = rhs(f)%val/cvmass(f)%val
4440 else
4441 ! apply strong dirichlet boundary conditions (if any)
4442 ! note that weak conditions (known as control volume boundary conditions)
4443@@ -2548,7 +2754,7 @@
4444
4445 call halo_update(tfield(f)%ptr) ! exchange the extended halos
4446
4447- call test_and_write_advection_convergence(tfield(f)%ptr, advit_tfield(f), x, &
4448+ call test_and_write_advection_convergence(tfield(f)%ptr, advit_tfield(f), x, t_cvmass(f)%ptr, &
4449 filename=trim(state(state_indices(f))%name)//"__"//trim(tfield(f)%ptr%name), &
4450 time=time+sub_dt, dt=sub_dt, it=global_it, adv_it=adv_it, &
4451 subcyc=sub, error=error(f))
4452@@ -2574,7 +2780,7 @@
4453 deallocate(l_old_tfield(f)%ptr)
4454 call deallocate(rhs(f))
4455 if(.not.explicit(f)) call deallocate(A_m(f))
4456- if(explicit(f)) call deallocate(lumpedmass(f))
4457+ if(explicit(f)) call deallocate(cvmass(f))
4458 if(.not.explicit(f)) call deallocate(M(f))
4459 end do
4460 call deallocate(cfl_no)
4461@@ -2591,12 +2797,15 @@
4462 deallocate(dummyscalar)
4463 call deallocate(x_tfield)
4464 if(move_mesh) then
4465- call deallocate(t_lumpedmass_new)
4466- call deallocate(t_lumpedmass_old)
4467+ call deallocate(t_cvmass_new)
4468+ call deallocate(t_cvmass_old)
4469 end if
4470 call deallocate(ug_cvshape)
4471 call deallocate(ug_cvbdyshape)
4472-
4473+ do f = 1,nfields
4474+ if (include_porosity(f)) call deallocate(t_cvmass_with_porosity(f))
4475+ end do
4476+
4477 end subroutine solve_coupled_cv
4478
4479 ! coupled assembly:
4480@@ -3264,12 +3473,13 @@
4481
4482 end subroutine initialise_advection_convergence
4483
4484- subroutine test_and_write_advection_convergence(field, nlfield, coordinates, filename, &
4485+ subroutine test_and_write_advection_convergence(field, nlfield, coordinates, cv_mass, filename, &
4486 time, dt, it, subcyc, adv_it, &
4487 error)
4488
4489 type(scalar_field), intent(inout) :: field, nlfield
4490 type(vector_field), intent(in) :: coordinates
4491+ type(scalar_field), intent(in) :: cv_mass
4492 character(len=*), intent(in) :: filename
4493 real, intent(in) :: time, dt
4494 integer, intent(in) :: it, subcyc, adv_it
4495@@ -3287,7 +3497,7 @@
4496
4497 error = 0.0
4498 call field_con_stats(field, nlfield, error, &
4499- convergence_norm, coordinates)
4500+ convergence_norm, coordinates, cv_mass)
4501
4502 format='(e15.6e3)'
4503 iformat='(i4)'
4504
4505=== modified file 'assemble/Full_Projection.F90'
4506--- assemble/Full_Projection.F90 2011-04-06 15:37:23 +0000
4507+++ assemble/Full_Projection.F90 2012-10-16 13:22:44 +0000
4508@@ -44,37 +44,18 @@
4509 use petsc_solve_state_module
4510 use boundary_conditions_from_options
4511
4512-#ifdef HAVE_PETSC_MODULES
4513 #include "petscversion.h"
4514+#ifdef HAVE_PETSC_MODULES
4515 use petsc
4516-#if PETSC_VERSION_MINOR==0
4517- use petscvec
4518- use petscmat
4519- use petscksp
4520- use petscpc
4521-#endif
4522 #endif
4523
4524 implicit none
4525 ! Module to provide solvers, preconditioners etc... for full_projection Solver.
4526 ! Not this is currently tested for Full CMC solves and Stokes flow:
4527 #ifdef HAVE_PETSC_MODULES
4528-#if PETSC_VERSION_MINOR==0
4529-#include "finclude/petscvecdef.h"
4530-#include "finclude/petscmatdef.h"
4531-#include "finclude/petsckspdef.h"
4532-#include "finclude/petscpcdef.h"
4533-#else
4534 #include "finclude/petscdef.h"
4535-#endif
4536 #else
4537 #include "finclude/petsc.h"
4538-#if PETSC_VERSION_MINOR==0
4539-#include "finclude/petscvec.h"
4540-#include "finclude/petscmat.h"
4541-#include "finclude/petscksp.h"
4542-#include "finclude/petscpc.h"
4543-#endif
4544 #endif
4545
4546 private
4547@@ -85,8 +66,7 @@
4548
4549 !--------------------------------------------------------------------------------------------------------------------
4550 subroutine petsc_solve_full_projection(x,ctp_m,inner_m,ct_m,rhs,pmat,&
4551- state, inner_mesh, &
4552- auxiliary_matrix)
4553+ state, inner_mesh, auxiliary_matrix)
4554 !--------------------------------------------------------------------------------------------------------------------
4555
4556 ! Solve Schur complement problem the nice way (using petsc) !!
4557@@ -161,10 +141,8 @@
4558
4559 !--------------------------------------------------------------------------------------------------------
4560 subroutine petsc_solve_setup_full_projection(y,A,b,ksp,petsc_numbering_p,name,solver_option_path, &
4561- lstartfromzero,inner_m,div_matrix_comp, &
4562- div_matrix_incomp,option_path,preconditioner_matrix,rhs, &
4563- state, inner_mesh, &
4564- auxiliary_matrix)
4565+ lstartfromzero,inner_m,div_matrix_comp, div_matrix_incomp,option_path,preconditioner_matrix,rhs, &
4566+ state, inner_mesh, auxiliary_matrix)
4567
4568 !--------------------------------------------------------------------------------------------------------
4569
4570@@ -230,7 +208,7 @@
4571 character(len=OPTION_PATH_LEN) :: inner_option_path, inner_solver_option_path
4572
4573 integer reference_node, stat, i
4574- logical parallel, have_auxiliary_matrix
4575+ logical parallel, have_auxiliary_matrix, have_preconditioner_matrix
4576
4577 logical :: apply_reference_node, apply_reference_node_from_coordinates, reference_node_owned
4578
4579@@ -239,7 +217,7 @@
4580 inner_option_path= trim(option_path)//&
4581 "/prognostic/scheme/use_projection_method&
4582 &/full_schur_complement/inner_matrix[0]"
4583-
4584+
4585 if (have_option(trim(option_path)//'/name')) then
4586 call get_option(trim(option_path)//'/name', name)
4587 ewrite(1,*) 'Inside petsc_solve_(block_)csr, solving for: ', trim(name)
4588@@ -347,18 +325,10 @@
4589 ! Build Schur complement:
4590 ewrite(2,*) 'Building Schur complement'
4591 if(have_auxiliary_matrix) then
4592-#if PETSC_VERSION_MINOR==0
4593- call MatCreateSchurComplement(inner_M%M,G,G_t_comp,S,A,ierr)
4594-#else
4595 call MatCreateSchurComplement(inner_M%M,inner_M%M,G,G_t_comp,S,A,ierr)
4596-#endif
4597 else
4598 myPETSC_NULL_OBJECT=PETSC_NULL_OBJECT
4599-#if PETSC_VERSION_MINOR==0
4600- call MatCreateSchurComplement(inner_M%M,G,G_t_comp,PETSC_NULL_OBJECT,A,ierr)
4601-#else
4602 call MatCreateSchurComplement(inner_M%M,inner_M%M,G,G_t_comp,PETSC_NULL_OBJECT,A,ierr)
4603-#endif
4604 if (myPETSC_NULL_OBJECT/=PETSC_NULL_OBJECT) then
4605 FLAbort("PETSC_NULL_OBJECT has changed please report to skramer")
4606 end if
4607@@ -386,8 +356,14 @@
4608
4609 ! leaving out petsc_numbering and mesh, so "iteration_vtus" monitor won't work!
4610
4611- ! Assemble preconditioner matrix in petsc format:
4612- pmat=csr2petsc(preconditioner_matrix, petsc_numbering_p, petsc_numbering_p)
4613+ ! Assemble preconditioner matrix in petsc format (if required):
4614+ have_preconditioner_matrix=.not.(have_option(trim(option_path)//&
4615+ "/prognostic/scheme/use_projection_method&
4616+ &/full_schur_complement/preconditioner_matrix::NoPreconditionerMatrix"))
4617+
4618+ if(have_preconditioner_matrix) then
4619+ pmat=csr2petsc(preconditioner_matrix, petsc_numbering_p, petsc_numbering_p)
4620+ end if
4621
4622 ! Set up RHS and Solution vectors (note these are loaded later):
4623 b = PetscNumberingCreateVec(petsc_numbering_p)
4624@@ -398,8 +374,12 @@
4625
4626 parallel=IsParallel()
4627
4628- call SetupKSP(ksp,A,pmat,solver_option_path,parallel,&
4629- petsc_numbering_p, lstartfromzero)
4630+ if(have_preconditioner_matrix) then
4631+ call SetupKSP(ksp,A,pmat,solver_option_path,parallel,petsc_numbering_p, lstartfromzero)
4632+ else
4633+ ! If preconditioner matrix is not required, send in A instead:
4634+ call SetupKSP(ksp,A,A,solver_option_path,parallel,petsc_numbering_p, lstartfromzero)
4635+ end if
4636
4637 ! Destroy the matrices setup for the schur complement computation. While
4638 ! these matrices are destroyed here, they are still required for the inner solve,
4639@@ -410,7 +390,7 @@
4640 call MatDestroy(G_t_comp,ierr) ! Destroy Compressible Divergence Operator.
4641 call MatDestroy(G_t_incomp, ierr) ! Destroy Incompressible Divergence Operator.
4642 call MatDestroy(G, ierr) ! Destroy Gradient Operator (i.e. transpose of incompressible div).
4643- call MatDestroy(pmat,ierr) ! Destroy preconditioning matrix if allocated.
4644+ if(have_preconditioner_matrix) call MatDestroy(pmat,ierr) ! Destroy preconditioning matrix.
4645 if(have_auxiliary_matrix) call MatDestroy(S,ierr) ! Destroy stabilization matrix
4646
4647 call deallocate( petsc_numbering_u )
4648
4649=== modified file 'assemble/Geostrophic_Pressure.F90'
4650--- assemble/Geostrophic_Pressure.F90 2011-07-29 12:30:06 +0000
4651+++ assemble/Geostrophic_Pressure.F90 2012-10-16 13:22:44 +0000
4652@@ -110,7 +110,7 @@
4653 !! Mass option path
4654 character(len = OPTION_PATH_LEN) :: mass_option_path
4655 !! Divergence matrix
4656- type(block_csr_matrix) :: ct_m
4657+ type(block_csr_matrix), pointer :: ct_m
4658 !! RHS terms from integrating the divergence operator by parts
4659 type(scalar_field) :: ct_rhs
4660 !! Mass matrix. Only used when not lumping mass for continuous u_mesh.
4661@@ -785,6 +785,7 @@
4662 ewrite(2, *) "Boundary conditions field: ", trim(lbcfield%name)
4663
4664 ct_sparsity => get_csr_sparsity_firstorder(state, matrices%p_mesh, matrices%u_mesh)
4665+ allocate(matrices%ct_m)
4666 call allocate(matrices%ct_m, ct_sparsity, blocks = (/1, dim/), name = "CT")
4667 call allocate(matrices%ct_rhs, matrices%p_mesh, "CTRHS")
4668
4669@@ -1197,6 +1198,7 @@
4670 end select
4671 end if
4672 call deallocate(matrices%ct_m)
4673+ deallocate(matrices%ct_m)
4674 call deallocate(matrices%ct_rhs)
4675
4676 if(matrices%have_cmc_m) then
4677@@ -1434,7 +1436,7 @@
4678 !!< Compute the divergence of a field
4679
4680 type(vector_field), intent(in) :: field
4681- type(block_csr_matrix), intent(in) :: ct_m
4682+ type(block_csr_matrix), pointer :: ct_m
4683 type(csr_matrix), intent(in) :: mass
4684 type(scalar_field), intent(inout) :: div
4685
4686
4687=== modified file 'assemble/LES_viscosity.F90'
4688--- assemble/LES_viscosity.F90 2011-05-10 10:39:15 +0000
4689+++ assemble/LES_viscosity.F90 2012-10-16 13:22:44 +0000
4690@@ -54,17 +54,17 @@
4691 ewrite(2,*) "Initialising optional dynamic LES diagnostic fields"
4692 ! Filter width
4693 if(have_filter_width) then
4694- tensorfield => extract_tensor_field(state, "DynamicFilterWidth")
4695+ tensorfield => extract_tensor_field(state, "FilterWidth")
4696 call zero(tensorfield)
4697 end if
4698 ! Strain rate field S1
4699 if(have_strain) then
4700- tensorfield => extract_tensor_field(state, "DynamicStrainRate")
4701+ tensorfield => extract_tensor_field(state, "StrainRate")
4702 call zero(tensorfield)
4703 end if
4704 ! Filtered strain rate field S2
4705 if(have_filtered_strain) then
4706- tensorfield => extract_tensor_field(state, "DynamicFilteredStrainRate")
4707+ tensorfield => extract_tensor_field(state, "FilteredStrainRate")
4708 call zero(tensorfield)
4709 end if
4710 ! Eddy viscosity field m_ij
4711@@ -98,31 +98,31 @@
4712
4713 ! Strain rate field S1
4714 if(have_strain) then
4715- tensorfield => extract_tensor_field(state, "DynamicStrainRate")
4716+ tensorfield => extract_tensor_field(state, "StrainRate")
4717 tensor_loc=shape_tensor_rhs(ele_shape(nu, ele), strain_gi, detwei)
4718 call addto(tensorfield, ele_nodes(nu, ele), tensor_loc)
4719 end if
4720
4721 ! Filtered strain rate field S2
4722 if(have_filtered_strain) then
4723- tensorfield => extract_tensor_field(state, "DynamicFilteredStrainRate")
4724+ tensorfield => extract_tensor_field(state, "FilteredStrainRate")
4725 tensor_loc=shape_tensor_rhs(ele_shape(nu, ele), t_strain_gi, detwei)
4726 call addto(tensorfield, ele_nodes(nu, ele), tensor_loc)
4727 end if
4728
4729 ! Filter width
4730 if(have_filter_width) then
4731- tensorfield => extract_tensor_field(state, "DynamicFilterWidth")
4732+ tensorfield => extract_tensor_field(state, "FilterWidth")
4733 tensor_loc=shape_tensor_rhs(ele_shape(nu, ele), mesh_size_gi, detwei)
4734 call addto(tensorfield, ele_nodes(nu, ele), tensor_loc)
4735 end if
4736
4737 end subroutine les_set_diagnostic_tensor_fields
4738
4739- subroutine leonard_tensor(mnu, positions, tnu, leonard, alpha, path)
4740+ subroutine leonard_tensor(nu, positions, tnu, leonard, alpha, path)
4741
4742 ! Unfiltered velocity
4743- type(vector_field), pointer :: mnu
4744+ type(vector_field), pointer :: nu
4745 type(vector_field), intent(in) :: positions
4746 ! Filtered velocity
4747 type(vector_field), pointer :: tnu
4748@@ -140,31 +140,30 @@
4749
4750 ! Path is to level above solver options
4751 lpath = (trim(path)//"/dynamic_les")
4752- ewrite(2,*) "path: ", trim(lpath)
4753- ewrite(2,*) "alpha: ", alpha
4754+ ewrite(2,*) "filter factor alpha: ", alpha
4755
4756- ewrite_minmax(mnu)
4757+ ewrite_minmax(nu)
4758 ewrite_minmax(tnu)
4759
4760- call anisotropic_smooth_vector(mnu, positions, tnu, alpha, lpath)
4761+ call anisotropic_smooth_vector(nu, positions, tnu, alpha, lpath)
4762
4763- ewrite_minmax(mnu)
4764+ ewrite_minmax(nu)
4765 ewrite_minmax(tnu)
4766
4767 ! Velocity products (ui*uj)
4768 allocate(ui_uj); allocate(tui_tuj)
4769- call allocate(ui_uj, mnu%mesh, "NonlinearVelocityProduct")
4770- call allocate(tui_tuj, mnu%mesh, "TestNonlinearVelocityProduct")
4771+ call allocate(ui_uj, nu%mesh, "NonlinearVelocityProduct")
4772+ call allocate(tui_tuj, nu%mesh, "TestNonlinearVelocityProduct")
4773 call zero(ui_uj); call zero(tui_tuj)
4774
4775 ! Other local variables
4776- allocate(u_loc(mnu%dim)); allocate(t_loc(mnu%dim, mnu%dim))
4777+ allocate(u_loc(nu%dim)); allocate(t_loc(nu%dim, nu%dim))
4778 u_loc=0.0; t_loc=0.0
4779
4780 ! Get cross products of velocities
4781- do i=1, node_count(mnu)
4782+ do i=1, node_count(nu)
4783 ! Mesh filter ^r
4784- u_loc = node_val(mnu,i)
4785+ u_loc = node_val(nu,i)
4786 t_loc = outer_product(u_loc, u_loc)
4787 call set( ui_uj, i, t_loc )
4788 ! Test filter ^t
4789
4790=== modified file 'assemble/Makefile.dependencies'
4791--- assemble/Makefile.dependencies 2011-10-26 08:48:33 +0000
4792+++ assemble/Makefile.dependencies 2012-10-16 13:22:44 +0000
4793@@ -31,14 +31,14 @@
4794 ../include/interpolation_module.mod \
4795 ../include/intersection_finder_module.mod ../include/mba2d_integration.mod \
4796 ../include/mba3d_integration.mod ../include/mba_adapt_module.mod \
4797- ../include/mesh_files.mod ../include/metric_assemble.mod \
4798- ../include/mpi_interfaces.mod ../include/parallel_tools.mod \
4799- ../include/pickers.mod ../include/populate_state_module.mod \
4800+ ../include/metric_assemble.mod ../include/mpi_interfaces.mod \
4801+ ../include/parallel_tools.mod ../include/pickers.mod \
4802+ ../include/populate_state_module.mod \
4803 ../include/project_metric_to_surface_module.mod ../include/quadrature.mod \
4804 ../include/reserve_state_module.mod ../include/sam_integration.mod \
4805 ../include/sparse_tools.mod ../include/state_module.mod \
4806 ../include/tictoc.mod ../include/timeloop_utilities.mod \
4807- ../include/zoltan_integration.mod
4808+ ../include/write_gmsh.mod ../include/zoltan_integration.mod
4809
4810 ../include/adapt_state_prescribed_module.mod: Adapt_State_Prescribed.o
4811 @true
4812@@ -76,11 +76,13 @@
4813
4814 Advection_Diffusion_CG.o ../include/advection_diffusion_cg.mod: \
4815 Advection_Diffusion_CG.F90 ../include/boundary_conditions.mod \
4816- ../include/boundary_conditions_from_options.mod ../include/elements.mod \
4817- ../include/fdebug.h ../include/field_options.mod ../include/fields.mod \
4818- ../include/fldebug.mod ../include/global_parameters.mod \
4819- ../include/petsc_solve_state_module.mod ../include/profiler.mod \
4820- ../include/quadrature.mod ../include/sparse_tools.mod \
4821+ ../include/boundary_conditions_from_options.mod ../include/colouring.mod \
4822+ ../include/elements.mod ../include/fdebug.h ../include/field_options.mod \
4823+ ../include/fields.mod ../include/fldebug.mod \
4824+ ../include/global_parameters.mod ../include/multiphase_module.mod \
4825+ ../include/petsc_solve_state_module.mod ../include/porous_media.mod \
4826+ ../include/profiler.mod ../include/quadrature.mod \
4827+ ../include/sparse_tools.mod ../include/sparse_tools_petsc.mod \
4828 ../include/sparsity_patterns_meshes.mod ../include/spud.mod \
4829 ../include/state_module.mod ../include/upwind_stabilisation.mod
4830
4831@@ -89,11 +91,13 @@
4832
4833 Advection_Diffusion_DG.o ../include/advection_diffusion_dg.mod: \
4834 Advection_Diffusion_DG.F90 ../include/boundary_conditions.mod \
4835- ../include/boundary_conditions_from_options.mod ../include/coordinates.mod \
4836- ../include/dgtools.mod ../include/diagnostic_fields.mod \
4837- ../include/elements.mod ../include/fdebug.h ../include/fefields.mod \
4838- ../include/fetools.mod ../include/fields.mod ../include/fldebug.mod \
4839+ ../include/boundary_conditions_from_options.mod ../include/colouring.mod \
4840+ ../include/coordinates.mod ../include/dgtools.mod \
4841+ ../include/diagnostic_fields.mod ../include/elements.mod \
4842+ ../include/fdebug.h ../include/fefields.mod ../include/fetools.mod \
4843+ ../include/fields.mod ../include/fldebug.mod \
4844 ../include/global_parameters.mod ../include/petsc_solve_state_module.mod \
4845+ ../include/porous_media.mod ../include/profiler.mod \
4846 ../include/shape_functions.mod ../include/slope_limiters_dg.mod \
4847 ../include/sparse_matrices_fields.mod ../include/sparse_tools.mod \
4848 ../include/sparsity_patterns.mod ../include/sparsity_patterns_meshes.mod \
4849@@ -106,9 +110,9 @@
4850
4851 Advection_Diffusion_FV.o ../include/advection_diffusion_fv.mod: \
4852 Advection_Diffusion_FV.F90 ../include/boundary_conditions.mod \
4853- ../include/boundary_conditions_from_options.mod ../include/elements.mod \
4854- ../include/fdebug.h ../include/fetools.mod ../include/field_options.mod \
4855- ../include/fields.mod ../include/fldebug.mod \
4856+ ../include/boundary_conditions_from_options.mod ../include/colouring.mod \
4857+ ../include/elements.mod ../include/fdebug.h ../include/fetools.mod \
4858+ ../include/field_options.mod ../include/fields.mod ../include/fldebug.mod \
4859 ../include/global_parameters.mod ../include/petsc_solve_state_module.mod \
4860 ../include/profiler.mod ../include/quadrature.mod \
4861 ../include/shape_functions.mod ../include/sparse_tools.mod \
4862@@ -131,11 +135,11 @@
4863
4864 Biology.o ../include/biology.mod: Biology.F90 \
4865 ../include/boundary_conditions.mod ../include/fdebug.h \
4866- ../include/fetools.mod ../include/fields.mod \
4867- ../include/global_parameters.mod ../include/python_state.mod \
4868- ../include/solvers.mod ../include/sparse_tools.mod \
4869- ../include/sparsity_patterns_meshes.mod ../include/spud.mod \
4870- ../include/state_module.mod
4871+ ../include/fefields.mod ../include/fetools.mod ../include/field_options.mod \
4872+ ../include/fields.mod ../include/global_parameters.mod \
4873+ ../include/python_state.mod ../include/solvers.mod \
4874+ ../include/sparse_tools.mod ../include/sparsity_patterns_meshes.mod \
4875+ ../include/spud.mod ../include/state_module.mod
4876
4877 ../include/burgers_assembly.mod: Burgers_Assembly.o
4878 @true
4879@@ -151,17 +155,18 @@
4880 Compressible_Projection.F90 ../include/equation_of_state.mod \
4881 ../include/fdebug.h ../include/fefields.mod ../include/field_options.mod \
4882 ../include/fields.mod ../include/fldebug.mod \
4883- ../include/global_parameters.mod ../include/sparse_matrices_fields.mod \
4884- ../include/sparse_tools.mod ../include/spud.mod \
4885- ../include/state_fields_module.mod ../include/state_module.mod \
4886- ../include/upwind_stabilisation.mod
4887+ ../include/global_parameters.mod ../include/multiphase_module.mod \
4888+ ../include/sparse_matrices_fields.mod ../include/sparse_tools.mod \
4889+ ../include/spud.mod ../include/state_fields_module.mod \
4890+ ../include/state_module.mod ../include/upwind_stabilisation.mod
4891
4892 ../include/coriolis_module.mod: Coriolis.o
4893 @true
4894
4895 Coriolis.o ../include/coriolis_module.mod: Coriolis.F90 \
4896 ../include/embed_python.mod ../include/fdebug.h ../include/fldebug.mod \
4897- ../include/global_parameters.mod ../include/spud.mod
4898+ ../include/global_parameters.mod ../include/parallel_tools.mod \
4899+ ../include/spud.mod
4900
4901 ../include/diagnostic_children.mod: Diagnostic_Children.o
4902 @true
4903@@ -200,10 +205,9 @@
4904 ../include/geostrophic_pressure.mod ../include/global_parameters.mod \
4905 ../include/momentum_diagnostic_fields.mod \
4906 ../include/multimaterial_module.mod ../include/multiphase_module.mod \
4907- ../include/parallel_tools.mod ../include/porous_media.mod \
4908- ../include/sediment_diagnostics.mod ../include/sparse_matrices_fields.mod \
4909- ../include/spontaneous_potentials.mod ../include/spud.mod \
4910- ../include/state_module.mod ../include/tidal_module.mod \
4911+ ../include/parallel_tools.mod ../include/sediment_diagnostics.mod \
4912+ ../include/sparse_matrices_fields.mod ../include/spontaneous_potentials.mod \
4913+ ../include/spud.mod ../include/state_module.mod ../include/tidal_module.mod \
4914 ../include/vorticity_diagnostics.mod
4915
4916 ../include/discrete_properties_module.mod: Discrete_Properties.o
4917@@ -278,7 +282,7 @@
4918 ../include/fdebug.h ../include/fefields.mod ../include/field_options.mod \
4919 ../include/fields.mod ../include/global_parameters.mod ../include/halos.mod \
4920 ../include/parallel_tools.mod ../include/petsc_solve_state_module.mod \
4921- ../include/sparse_matrices_fields.mod \
4922+ ../include/porous_media.mod ../include/sparse_matrices_fields.mod \
4923 ../include/sparsity_patterns_meshes.mod ../include/spud.mod \
4924 ../include/state_fields_module.mod ../include/state_module.mod \
4925 ../include/transform_elements.mod
4926@@ -512,21 +516,23 @@
4927
4928 Momentum_CG.o ../include/momentum_cg.mod: Momentum_CG.F90 \
4929 ../include/boundary_conditions.mod \
4930- ../include/boundary_conditions_from_options.mod ../include/coordinates.mod \
4931- ../include/coriolis_module.mod ../include/edge_length_module.mod \
4932- ../include/elements.mod ../include/fdebug.h ../include/fefields.mod \
4933- ../include/fetools.mod ../include/field_derivatives.mod \
4934- ../include/field_options.mod ../include/fields.mod ../include/fldebug.mod \
4935+ ../include/boundary_conditions_from_options.mod ../include/colouring.mod \
4936+ ../include/coordinates.mod ../include/coriolis_module.mod \
4937+ ../include/edge_length_module.mod ../include/elements.mod \
4938+ ../include/fdebug.h ../include/fefields.mod ../include/fetools.mod \
4939+ ../include/field_derivatives.mod ../include/field_options.mod \
4940+ ../include/fields.mod ../include/fldebug.mod \
4941 ../include/global_parameters.mod ../include/halos.mod \
4942 ../include/les_viscosity_module.mod ../include/metric_tools.mod \
4943 ../include/multiphase_module.mod ../include/petsc_solve_state_module.mod \
4944- ../include/rotated_boundary_conditions.mod ../include/smoothing_module.mod \
4945- ../include/solvers.mod ../include/sparse_matrices_fields.mod \
4946- ../include/sparse_tools.mod ../include/sparse_tools_petsc.mod \
4947- ../include/sparsity_patterns_meshes.mod ../include/spud.mod \
4948- ../include/state_fields_module.mod ../include/state_matrices_module.mod \
4949- ../include/state_module.mod ../include/transform_elements.mod \
4950- ../include/upwind_stabilisation.mod ../include/vector_tools.mod
4951+ ../include/profiler.mod ../include/rotated_boundary_conditions.mod \
4952+ ../include/smoothing_module.mod ../include/solvers.mod \
4953+ ../include/sparse_matrices_fields.mod ../include/sparse_tools.mod \
4954+ ../include/sparse_tools_petsc.mod ../include/sparsity_patterns_meshes.mod \
4955+ ../include/spud.mod ../include/state_fields_module.mod \
4956+ ../include/state_matrices_module.mod ../include/state_module.mod \
4957+ ../include/transform_elements.mod ../include/upwind_stabilisation.mod \
4958+ ../include/vector_tools.mod
4959
4960 ../include/momentum_dg.mod: Momentum_DG.o
4961 @true
4962@@ -558,6 +564,7 @@
4963 ../include/equation_of_state.mod ../include/fdebug.h \
4964 ../include/field_priority_lists.mod ../include/fields.mod \
4965 ../include/fldebug.mod ../include/global_parameters.mod \
4966+ ../include/initialise_fields_module.mod ../include/k_epsilon.mod \
4967 ../include/multimaterial_module.mod ../include/multiphase_module.mod \
4968 ../include/spud.mod ../include/state_module.mod
4969
4970@@ -579,7 +586,8 @@
4971 ../include/momentum_cg.mod ../include/momentum_dg.mod \
4972 ../include/momentum_diagnostic_fields.mod ../include/multiphase_module.mod \
4973 ../include/oceansurfaceforcing.mod ../include/parallel_tools.mod \
4974- ../include/petsc_solve_state_module.mod ../include/profiler.mod \
4975+ ../include/petsc_solve_state_module.mod \
4976+ ../include/pressure_dirichlet_bcs_cv.mod ../include/profiler.mod \
4977 ../include/reduced_model_runtime.mod \
4978 ../include/rotated_boundary_conditions.mod ../include/slope_limiters_dg.mod \
4979 ../include/solvers.mod ../include/sparse_matrices_fields.mod \
4980@@ -642,7 +650,23 @@
4981 @true
4982
4983 Porous_Media.o ../include/porous_media.mod: Porous_Media.F90 \
4984- ../include/fdebug.h ../include/fields.mod ../include/fldebug.mod \
4985+ ../include/fdebug.h ../include/fields.mod ../include/futils.mod \
4986+ ../include/global_parameters.mod ../include/spud.mod \
4987+ ../include/state_module.mod
4988+
4989+../include/pressure_dirichlet_bcs_cv.mod: Pressure_Dirichlet_BCS_CV.o
4990+ @true
4991+
4992+Pressure_Dirichlet_BCS_CV.o ../include/pressure_dirichlet_bcs_cv.mod: \
4993+ Pressure_Dirichlet_BCS_CV.F90 ../include/boundary_conditions.mod \
4994+ ../include/cv_face_values.mod ../include/cv_faces.mod \
4995+ ../include/cv_fields.mod ../include/cv_options.mod \
4996+ ../include/cv_shape_functions.mod ../include/cv_upwind_values.mod \
4997+ ../include/cvtools.mod ../include/diagnostic_fields.mod ../include/fdebug.h \
4998+ ../include/fetools.mod ../include/field_derivatives.mod \
4999+ ../include/field_options.mod ../include/fields.mod ../include/futils.mod \
5000+ ../include/global_parameters.mod ../include/multiphase_module.mod \
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: