diff --git a/.coveragerc b/.coveragerc index 0fa6bd98c4..922ba7b57a 100644 --- a/.coveragerc +++ b/.coveragerc @@ -9,5 +9,3 @@ omit = */proteus/WaveTools.py */proteus/BoundaryConditions.py */proteus/SpatialTools.py - */proteus/mprans/BoundaryConditions.py - */proteus/mprans/SpatialTools.py diff --git a/.github/coverage/cython_traced.py b/.github/coverage/cython_traced.py index 9ab5221e36..4bd63eca6b 100644 --- a/.github/coverage/cython_traced.py +++ b/.github/coverage/cython_traced.py @@ -21,7 +21,7 @@ from Cython.Coverage import Plugin as _CythonPlugin # relative to the package directory, '/'-separated -TRACED_MODULES = ('BoundaryConditions.py', 'mprans/BoundaryConditions.py', 'WaveTools.py') +TRACED_MODULES = ('BoundaryConditions.py', 'WaveTools.py') class Plugin(_CythonPlugin): diff --git a/.github/coverage/floors.json b/.github/coverage/floors.json index c2c254c9ca..65f2ef4a3c 100644 --- a/.github/coverage/floors.json +++ b/.github/coverage/floors.json @@ -1,12 +1,11 @@ { - "proteus/ADR.py": 90.6, "proteus/ADRProblem.py": 93.1, "proteus/AnalysisTools.py": 0.0, "proteus/AnalyticalSolutions.py": 89.3, "proteus/ArchiveFields.py": 98.3, "proteus/Archiver.py": 70.5, "proteus/AuxiliaryVariables.py": 16.5, - "proteus/BoundaryConditions.py": 96.6, + "proteus/BoundaryConditions.py": 70.7, "proteus/Comm.py": 97.0, "proteus/Context.py": 92.5, "proteus/DiagUtils.py": 11.4, @@ -22,10 +21,11 @@ "proteus/LatexReport.py": 7.3, "proteus/LinearAlgebraTools.py": 85.3, "proteus/LinearSolvers.py": 76.9, - "proteus/MeshAdaptPUMI/AdaptHelper.py": 83.8, + "proteus/MeshAdaptPUMI/AdaptHelper.py": 83.1, "proteus/MeshAdaptPUMI/Checkpoint.py": 14.1, "proteus/MeshAdaptPUMI/__init__.py": 100.0, "proteus/MeshTools.py": 65.9, + "proteus/MoveMeshMonitor.py": 65.9, "proteus/NonlinearSolvers.py": 46.4, "proteus/Norms.py": 18.5, "proteus/NumericalFlux.py": 55.3, @@ -40,7 +40,7 @@ "proteus/SWFlow/utils/SWEs_so.py": 0.0, "proteus/ShockCapturing.py": 36.1, "proteus/SimTools.py": 11.9, - "proteus/SpatialTools.py": 62.9, + "proteus/SpatialTools.py": 56.0, "proteus/SplitOperator.py": 46.1, "proteus/StepControl.py": 36.0, "proteus/SubgridError.py": 19.6, @@ -100,47 +100,41 @@ "proteus/default_so.py": 91.3, "proteus/defaults.py": 88.8, "proteus/deim_utils.py": 60.4, - "proteus/elastoplastic/ElastoPlastic.py": 82.0, - "proteus/elastoplastic/__init__.py": 100.0, "proteus/iproteus.py": 76.9, - "proteus/m_comp_co2/__init__.py": "test pending (deck from Arnob; not legacy, #1282)", - "proteus/m_comp_co2/m_comp_co2.py": "test pending (deck from Arnob; not legacy, #1282)", - "proteus/mprans/AddedMass.py": 76.2, - "proteus/mprans/ArchiveBeams.py": 7.8, - "proteus/mprans/BodyDynamics.py": 52.2, - "proteus/mprans/BoundaryConditions.py": 70.1, - "proteus/mprans/CLSVOF.py": 79.5, - "proteus/mprans/Dissipation.py": 56.5, - "proteus/mprans/EntropyViscosity.py": 100.0, - "proteus/mprans/GN_SW2DCV.py": 77.3, - "proteus/mprans/Kappa.py": 56.2, - "proteus/mprans/MCorr.py": 64.5, - "proteus/mprans/MCorr3P.py": 50.4, - "proteus/mprans/MoveMesh.py": 86.4, - "proteus/mprans/MoveMeshMonitor.py": 65.9, - "proteus/mprans/NCLS.py": 75.4, - "proteus/mprans/NCLS3P.py": 75.6, - "proteus/mprans/Pres.py": 76.1, - "proteus/mprans/PresInc.py": 76.2, - "proteus/mprans/PresInit.py": 23.2, - "proteus/mprans/PressureNormalization.py": 97.5, - "proteus/mprans/RANS2P.py": 87.1, - "proteus/mprans/RANS2P_IB.py": 2.4, - "proteus/mprans/RANS3PF.py": 88.0, - "proteus/mprans/RANS3PSed.py": 4.7, - "proteus/mprans/RDLS.py": 67.0, - "proteus/mprans/SW2D.py": 6.1, - "proteus/mprans/SW2DCV.py": 85.8, - "proteus/mprans/SpatialTools.py": 52.1, - "proteus/mprans/TADR.py": 88.4, - "proteus/mprans/VOF.py": 87.4, - "proteus/mprans/VOF3P.py": 83.5, - "proteus/mprans/VOS3P.py": 82.4, - "proteus/mprans/__init__.py": 100.0, - "proteus/mprans/beamFEM.py": 9.2, + "proteus/kernels/ADR.py": 90.6, + "proteus/kernels/AddedMass.py": 76.2, + "proteus/kernels/ArchiveBeams.py": 7.8, + "proteus/kernels/CLSVOF.py": 79.5, + "proteus/kernels/Dissipation.py": 56.5, + "proteus/kernels/ElastoPlastic.py": 82.0, + "proteus/kernels/EntropyViscosity.py": 100.0, + "proteus/kernels/GN_SW2DCV.py": 77.3, + "proteus/kernels/Kappa.py": 56.2, + "proteus/kernels/MCorr.py": 64.5, + "proteus/kernels/MCorr3P.py": 50.4, + "proteus/kernels/MoveMesh.py": 86.4, + "proteus/kernels/NCLS.py": 75.4, + "proteus/kernels/NCLS3P.py": 75.6, + "proteus/kernels/Pres.py": 76.1, + "proteus/kernels/PresInc.py": 76.2, + "proteus/kernels/PresInit.py": 23.2, + "proteus/kernels/PressureNormalization.py": 97.5, + "proteus/kernels/RANS2P.py": 87.1, + "proteus/kernels/RANS2P_IB.py": 2.4, + "proteus/kernels/RANS3PF.py": 88.0, + "proteus/kernels/RANS3PSed.py": 4.7, + "proteus/kernels/RDLS.py": 67.0, + "proteus/kernels/Richards.py": 78.9, + "proteus/kernels/SW2D.py": 6.1, + "proteus/kernels/SW2DCV.py": 85.8, + "proteus/kernels/TADR.py": 88.4, + "proteus/kernels/VOF.py": 87.4, + "proteus/kernels/VOF3P.py": 83.5, + "proteus/kernels/VOS3P.py": 82.4, + "proteus/kernels/__init__.py": 100.0, + "proteus/kernels/beamFEM.py": 9.2, + "proteus/kernels/m_comp_co2.py": "test pending (deck from Arnob; not legacy, #1282)", + "proteus/mbd/BodyDynamics.py": 52.2, "proteus/petsc_optional.py": 91.6, - "proteus/richards/ADR.py": 0.0, - "proteus/richards/Richards.py": 78.9, - "proteus/richards/__init__.py": 100.0, "proteus/runtime.py": 100.0 } diff --git a/.github/workflows/sdist.yml b/.github/workflows/sdist.yml index 5dc5502829..d782776a2a 100644 --- a/.github/workflows/sdist.yml +++ b/.github/workflows/sdist.yml @@ -230,7 +230,7 @@ jobs: # installs it with default build isolation, through pip run from this env, which finds the bundle. python -m build --sdist --no-isolation - # The coverage leg builds BoundaryConditions, mprans.BoundaryConditions and WaveTools (compiled by Cython from + # The coverage leg builds BoundaryConditions and WaveTools (compiled by Cython from # .py files, so coverage.py saw their lines never run: 0%) with line tracing; setup.py reads this variable. # Every other leg builds as before: tracing slows those modules down and nothing else needs it. - name: Install sdist with default build isolation @@ -241,7 +241,7 @@ jobs: # The Cython.Coverage plugin finds a traced module's executable lines in the C++ file Cython generated, which it # looks for next to the installed .so. pip builds in a temporary directory and keeps no generated source, so make - # the three files again here (the lines they map are the same ones) and put them there; the coverage job reads + # the two files again here (the lines they map are the same ones) and put them there; the coverage job reads # the same files from the artifact below. - name: Generate the Cython sources the coverage plugin reads (coverage leg) if: matrix.leg.coverage == 'yes' @@ -249,12 +249,12 @@ jobs: run: | PKG="$(cd "$(mktemp -d)" && python -c 'import os, proteus; print(os.path.dirname(proteus.__file__))')" echo "installed package: $PKG; cython $(cython --version 2>&1)" - for mod in BoundaryConditions mprans/BoundaryConditions WaveTools; do + for mod in BoundaryConditions WaveTools; do cython --cplus -3 -X linetrace=True -I . "proteus/$mod.py" -o "proteus/$mod.cpp" cp "proteus/$mod.cpp" "$PKG/$mod.cpp" done - ls "$PKG"/BoundaryConditions.* "$PKG"/mprans/BoundaryConditions.* "$PKG"/WaveTools.* - tar czf linetrace-sources.tgz proteus/BoundaryConditions.cpp proteus/mprans/BoundaryConditions.cpp proteus/WaveTools.cpp + ls "$PKG"/BoundaryConditions.* "$PKG"/WaveTools.* + tar czf linetrace-sources.tgz proteus/BoundaryConditions.cpp proteus/WaveTools.cpp - name: Smoke test shell: bash -l {0} @@ -580,7 +580,7 @@ jobs: - name: Combine and check against the floors shell: bash run: | - # Cython: the plugin that reads the line-traced modules' data (BoundaryConditions, mprans.BoundaryConditions, + # Cython: the plugin that reads the line-traced modules' data (BoundaryConditions, # WaveTools) has to be there to combine and report them pip install -q "coverage>=7.10" "cython>=3.0,<4" # the plugin looks for each module's generated C++ next to its .py diff --git a/.gitignore b/.gitignore index 7a41eda028..b60bcf7668 100644 --- a/.gitignore +++ b/.gitignore @@ -66,21 +66,20 @@ proteus/fenton/Fenton.cpp proteus/flcbdfWrappers.cpp proteus/mbd/CouplingFSI.cpp proteus/MeshAdaptPUMI/Adapter.cpp -proteus/mprans/BoundaryConditions.cpp -proteus/mprans/MeshSmoothing.cpp -proteus/mprans/cAddedMass.cpp -proteus/mprans/cCLSVOF.cpp -proteus/mprans/cGN_SW2DCV.cpp -proteus/mprans/cMCorr3P.cpp -proteus/mprans/cMoveMeshMonitor.cpp -proteus/mprans/cNCLS3P.cpp -proteus/mprans/cPres.cpp -proteus/mprans/cPresInc.cpp -proteus/mprans/cPresInit.cpp -proteus/mprans/cRANS3PF.cpp -proteus/mprans/cRANS3PSed.cpp -proteus/mprans/cVOF3P.cpp -proteus/mprans/cVOS3P.cpp +proteus/MeshSmoothing.cpp +proteus/kernels/cAddedMass.cpp +proteus/kernels/cCLSVOF.cpp +proteus/kernels/cGN_SW2DCV.cpp +proteus/kernels/cMCorr3P.cpp +proteus/cMoveMeshMonitor.cpp +proteus/kernels/cNCLS3P.cpp +proteus/kernels/cPres.cpp +proteus/kernels/cPresInc.cpp +proteus/kernels/cPresInit.cpp +proteus/kernels/cRANS3PF.cpp +proteus/kernels/cRANS3PSed.cpp +proteus/kernels/cVOF3P.cpp +proteus/kernels/cVOS3P.cpp proteus/superluWrappers.c proteus/MeshAdaptPUMI/MeshAdapt.cpp proteus/tests/ci/meshNoVessel.edge diff --git a/CLAUDE.md b/CLAUDE.md index 42bb31abc1..56578a4654 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -36,7 +36,7 @@ Verified on `main` at b9d98f5 (2026-11-17): 4 cores, 15 GB RAM, running as root. file. 4. **Check it:** ```bash - python -c "import proteus, proteus.superluWrappers, proteus.mprans.cRANS2P, proteus.MeshAdaptPUMI.MeshAdapt, proteus.mbd.CouplingFSI" + python -c "import proteus, proteus.superluWrappers, proteus.kernels.cRANS2P, proteus.MeshAdaptPUMI.MeshAdapt, proteus.mbd.CouplingFSI" ``` ## Making the tests pass diff --git a/Makefile b/Makefile index 6efecd4719..b5b377158e 100644 --- a/Makefile +++ b/Makefile @@ -110,6 +110,7 @@ else -rm -rf ${PROTEUS_PREFIX} endif -rm -rf build proteus/*.pyc proteus/*.so proteus/*.a proteus/MeshAdaptPUMI/*.so + -rm -rf build proteus/kernels/*.pyc proteus/kernels/*.so proteus/kernels/*.a -rm -rf build proteus/mprans/*.pyc proteus/mprans/*.so proteus/mprans/*.a -rm -rf build proteus/richards/*.pyc proteus/richards/*.so proteus/richards/*.a -rm -rf build proteus/elastoplastic/*.pyc proteus/elastoplastic/*.so proteus/elastoplastic/*.a diff --git a/README.md b/README.md index f57a2dc4c3..d83b036104 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ +

+ + + Proteus + +

+ # Proteus: Computational Methods and Simulation Toolkit [![Build Status](https://github.com/proteustoolkit/proteus/actions/workflows/sdist.yml/badge.svg?branch=main)](https://github.com/proteustoolkit/proteus/actions/workflows/sdist.yml) [![DOI](https://zenodo.org/badge/2212385.svg)](https://zenodo.org/badge/latestdoi/2212385) diff --git a/docs/Doxyfile b/docs/Doxyfile index 7b89d2a364..3053cd58b8 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = proteus # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 2.0.0rc1 +PROJECT_NUMBER = 2.0.0rc2 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -51,7 +51,7 @@ PROJECT_BRIEF = "C/C++/Fortran libraries" # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. -#PROJECT_LOGO = ./source/_static/corps_logo_cross_24.svg +#PROJECT_LOGO = ./source/_static/logo/primary/png/proteus-favicon-64.png # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is diff --git a/docs/source/_static/logo/Montserrat-OFL.txt b/docs/source/_static/logo/Montserrat-OFL.txt new file mode 100644 index 0000000000..a176d90de9 --- /dev/null +++ b/docs/source/_static/logo/Montserrat-OFL.txt @@ -0,0 +1,93 @@ +Copyright (c) 2011--2016, The Montserrat Project Authors (julieta.ulanovsky@gmail.com) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/docs/source/_static/logo/README.md b/docs/source/_static/logo/README.md new file mode 100644 index 0000000000..6d9e56e7cb --- /dev/null +++ b/docs/source/_static/logo/README.md @@ -0,0 +1,48 @@ +# Proteus logo + +Hand-written SVG (every file has a `viewBox`, no embedded rasters, no font references: the wordmark is outlined). +The trident was designed by cekees's daughter; the rest is built around it. + +## primary/ (the logos to use) + +Grey trident with no container; organization-agnostic. + +- `proteus-mark.svg`: trident `#898b8e`; works on light and dark backgrounds (3.4:1 on white, 4-5:1 on dark). +- `proteus-mark-light-background.svg`: trident `#5f6164`, for white backgrounds where more contrast is wanted (6.2:1). +- `proteus-mark-auto.svg`: `#5f6164` in light mode and `#898b8e` in dark mode (`prefers-color-scheme`; works through ``). +- `proteus-lockup-{h,v}-{light-background,dark-background,auto}.svg`: trident + PROTEUS, horizontal and stacked + (stacked: the stem sits over the T). The suffix names the background the file is meant for. +- `proteus-favicon.svg`, `proteus-favicon.ico` (16/32/48): square, trident alone, transparent; heavier than the mark (3-unit round stroke, `#767a7e`, fills the square) so it stays legible at 16 px in a browser tab. +- `png/`: transparent PNG renders (mark 512/1024, lockups 1200 and 800 wide, favicon 16 to 512). + +## lsu/ (secondary: LSU-affiliated uses) + +Purple `#592c82` chamfered-corner badge with a gold `#ffc72a` edge and the grey trident: `proteus-badge.svg`, +a square `proteus-favicon.svg`, lockups, `.ico`, `png/`. + +## Where each is used + +| Use | File | +| --- | --- | +| Sphinx sidebar (`html_logo`, `docs/source/conf.py`) | `primary/proteus-lockup-v-light-background.svg` | +| Sphinx favicon (`html_favicon`) | `primary/proteus-favicon.ico` | +| Top-level `README.md` | `primary/proteus-lockup-h-{light,dark}-background.svg` via `` | +| Commented-out Doxygen and LaTeX logos | `primary/png/proteus-favicon-64.png`, `primary/png/proteus-lockup-v-light-background-800.png` | + +## Colours and sources + +- The grey, purple and gold follow the swatches in the LSU CCT logo files: LSU Logo Grey 50% / PANTONE Cool Gray 8 C, + LSU Purple CMYK Coated 82/98/0/12 / PANTONE 268 C, LSU Gold CMYK Coated 0/19/89/0 / PANTONE 123 C. + The sRGB values are LAB-to-sRGB conversions of those swatches, not values published by LSU; check them against the + official LSU brand assets before print or formal use. +- `#5f6164` is a derived darker grey, not an LSU colour. +- Wordmark: Montserrat SemiBold (SIL Open Font License, see `Montserrat-OFL.txt`), outlined, letter-spaced, not kerned. +- The badge's polygonal outline echoes the angular LSU cap lettering without reproducing it. LSU marks belong to LSU: + confirm the badge is acceptable to LSU before using it outside this project. +- No CMYK, EPS or PDF exports exist yet. + +## Previous logo + +The old Army Corps castle-style logo (`../corps_logo_cross2.svg`) and the old icons (`../triton*.ico`, `../proteus*.png`, +`../proteusSimple.ico`, `../proteus.pdf`) are kept for the applications that need them; nothing in the docs build +references them any more. diff --git a/docs/source/_static/logo/lsu/png/proteus-badge-1024.png b/docs/source/_static/logo/lsu/png/proteus-badge-1024.png new file mode 100644 index 0000000000..4502f43599 Binary files /dev/null and b/docs/source/_static/logo/lsu/png/proteus-badge-1024.png differ diff --git a/docs/source/_static/logo/lsu/png/proteus-badge-512.png b/docs/source/_static/logo/lsu/png/proteus-badge-512.png new file mode 100644 index 0000000000..db5c11a1e9 Binary files /dev/null and b/docs/source/_static/logo/lsu/png/proteus-badge-512.png differ diff --git a/docs/source/_static/logo/lsu/png/proteus-favicon-16.png b/docs/source/_static/logo/lsu/png/proteus-favicon-16.png new file mode 100644 index 0000000000..4f40244734 Binary files /dev/null and b/docs/source/_static/logo/lsu/png/proteus-favicon-16.png differ diff --git a/docs/source/_static/logo/lsu/png/proteus-favicon-180.png b/docs/source/_static/logo/lsu/png/proteus-favicon-180.png new file mode 100644 index 0000000000..bc58e77781 Binary files /dev/null and b/docs/source/_static/logo/lsu/png/proteus-favicon-180.png differ diff --git a/docs/source/_static/logo/lsu/png/proteus-favicon-192.png b/docs/source/_static/logo/lsu/png/proteus-favicon-192.png new file mode 100644 index 0000000000..0d1207df4a Binary files /dev/null and b/docs/source/_static/logo/lsu/png/proteus-favicon-192.png differ diff --git a/docs/source/_static/logo/lsu/png/proteus-favicon-32.png b/docs/source/_static/logo/lsu/png/proteus-favicon-32.png new file mode 100644 index 0000000000..06541322d3 Binary files /dev/null and b/docs/source/_static/logo/lsu/png/proteus-favicon-32.png differ diff --git a/docs/source/_static/logo/lsu/png/proteus-favicon-48.png b/docs/source/_static/logo/lsu/png/proteus-favicon-48.png new file mode 100644 index 0000000000..d87a8706e9 Binary files /dev/null and b/docs/source/_static/logo/lsu/png/proteus-favicon-48.png differ diff --git a/docs/source/_static/logo/lsu/png/proteus-favicon-512.png b/docs/source/_static/logo/lsu/png/proteus-favicon-512.png new file mode 100644 index 0000000000..ab59f38b34 Binary files /dev/null and b/docs/source/_static/logo/lsu/png/proteus-favicon-512.png differ diff --git a/docs/source/_static/logo/lsu/png/proteus-favicon-64.png b/docs/source/_static/logo/lsu/png/proteus-favicon-64.png new file mode 100644 index 0000000000..f3014cdc09 Binary files /dev/null and b/docs/source/_static/logo/lsu/png/proteus-favicon-64.png differ diff --git a/docs/source/_static/logo/lsu/png/proteus-lockup-h-dark-background-1200.png b/docs/source/_static/logo/lsu/png/proteus-lockup-h-dark-background-1200.png new file mode 100644 index 0000000000..d793567861 Binary files /dev/null and b/docs/source/_static/logo/lsu/png/proteus-lockup-h-dark-background-1200.png differ diff --git a/docs/source/_static/logo/lsu/png/proteus-lockup-h-light-background-1200.png b/docs/source/_static/logo/lsu/png/proteus-lockup-h-light-background-1200.png new file mode 100644 index 0000000000..9a50adfd1b Binary files /dev/null and b/docs/source/_static/logo/lsu/png/proteus-lockup-h-light-background-1200.png differ diff --git a/docs/source/_static/logo/lsu/png/proteus-lockup-v-dark-background-800.png b/docs/source/_static/logo/lsu/png/proteus-lockup-v-dark-background-800.png new file mode 100644 index 0000000000..7f15bef1f0 Binary files /dev/null and b/docs/source/_static/logo/lsu/png/proteus-lockup-v-dark-background-800.png differ diff --git a/docs/source/_static/logo/lsu/png/proteus-lockup-v-light-background-800.png b/docs/source/_static/logo/lsu/png/proteus-lockup-v-light-background-800.png new file mode 100644 index 0000000000..1e33e87910 Binary files /dev/null and b/docs/source/_static/logo/lsu/png/proteus-lockup-v-light-background-800.png differ diff --git a/docs/source/_static/logo/lsu/proteus-badge.svg b/docs/source/_static/logo/lsu/proteus-badge.svg new file mode 100644 index 0000000000..930faa00d1 --- /dev/null +++ b/docs/source/_static/logo/lsu/proteus-badge.svg @@ -0,0 +1,4 @@ + +Proteus + + diff --git a/docs/source/_static/logo/lsu/proteus-favicon.ico b/docs/source/_static/logo/lsu/proteus-favicon.ico new file mode 100644 index 0000000000..02cd16b128 Binary files /dev/null and b/docs/source/_static/logo/lsu/proteus-favicon.ico differ diff --git a/docs/source/_static/logo/lsu/proteus-favicon.svg b/docs/source/_static/logo/lsu/proteus-favicon.svg new file mode 100644 index 0000000000..de059372f5 --- /dev/null +++ b/docs/source/_static/logo/lsu/proteus-favicon.svg @@ -0,0 +1,4 @@ + +Proteus + + diff --git a/docs/source/_static/logo/lsu/proteus-lockup-h-dark-background.svg b/docs/source/_static/logo/lsu/proteus-lockup-h-dark-background.svg new file mode 100644 index 0000000000..cf98d2ce98 --- /dev/null +++ b/docs/source/_static/logo/lsu/proteus-lockup-h-dark-background.svg @@ -0,0 +1,4 @@ + +Proteus + + diff --git a/docs/source/_static/logo/lsu/proteus-lockup-h-light-background.svg b/docs/source/_static/logo/lsu/proteus-lockup-h-light-background.svg new file mode 100644 index 0000000000..7c5ee11a0b --- /dev/null +++ b/docs/source/_static/logo/lsu/proteus-lockup-h-light-background.svg @@ -0,0 +1,4 @@ + +Proteus + + diff --git a/docs/source/_static/logo/lsu/proteus-lockup-v-dark-background.svg b/docs/source/_static/logo/lsu/proteus-lockup-v-dark-background.svg new file mode 100644 index 0000000000..c8215f23cf --- /dev/null +++ b/docs/source/_static/logo/lsu/proteus-lockup-v-dark-background.svg @@ -0,0 +1,4 @@ + +Proteus + + diff --git a/docs/source/_static/logo/lsu/proteus-lockup-v-light-background.svg b/docs/source/_static/logo/lsu/proteus-lockup-v-light-background.svg new file mode 100644 index 0000000000..f02f453701 --- /dev/null +++ b/docs/source/_static/logo/lsu/proteus-lockup-v-light-background.svg @@ -0,0 +1,4 @@ + +Proteus + + diff --git a/docs/source/_static/logo/primary/png/proteus-favicon-16.png b/docs/source/_static/logo/primary/png/proteus-favicon-16.png new file mode 100644 index 0000000000..b984e12e67 Binary files /dev/null and b/docs/source/_static/logo/primary/png/proteus-favicon-16.png differ diff --git a/docs/source/_static/logo/primary/png/proteus-favicon-180.png b/docs/source/_static/logo/primary/png/proteus-favicon-180.png new file mode 100644 index 0000000000..ded1afcf73 Binary files /dev/null and b/docs/source/_static/logo/primary/png/proteus-favicon-180.png differ diff --git a/docs/source/_static/logo/primary/png/proteus-favicon-192.png b/docs/source/_static/logo/primary/png/proteus-favicon-192.png new file mode 100644 index 0000000000..8aefc0d0ab Binary files /dev/null and b/docs/source/_static/logo/primary/png/proteus-favicon-192.png differ diff --git a/docs/source/_static/logo/primary/png/proteus-favicon-32.png b/docs/source/_static/logo/primary/png/proteus-favicon-32.png new file mode 100644 index 0000000000..b9b9223f5e Binary files /dev/null and b/docs/source/_static/logo/primary/png/proteus-favicon-32.png differ diff --git a/docs/source/_static/logo/primary/png/proteus-favicon-48.png b/docs/source/_static/logo/primary/png/proteus-favicon-48.png new file mode 100644 index 0000000000..b41dde899d Binary files /dev/null and b/docs/source/_static/logo/primary/png/proteus-favicon-48.png differ diff --git a/docs/source/_static/logo/primary/png/proteus-favicon-512.png b/docs/source/_static/logo/primary/png/proteus-favicon-512.png new file mode 100644 index 0000000000..3b7c95de5c Binary files /dev/null and b/docs/source/_static/logo/primary/png/proteus-favicon-512.png differ diff --git a/docs/source/_static/logo/primary/png/proteus-favicon-64.png b/docs/source/_static/logo/primary/png/proteus-favicon-64.png new file mode 100644 index 0000000000..f5b2661a6f Binary files /dev/null and b/docs/source/_static/logo/primary/png/proteus-favicon-64.png differ diff --git a/docs/source/_static/logo/primary/png/proteus-lockup-h-dark-background-1200.png b/docs/source/_static/logo/primary/png/proteus-lockup-h-dark-background-1200.png new file mode 100644 index 0000000000..d0951b2420 Binary files /dev/null and b/docs/source/_static/logo/primary/png/proteus-lockup-h-dark-background-1200.png differ diff --git a/docs/source/_static/logo/primary/png/proteus-lockup-h-light-background-1200.png b/docs/source/_static/logo/primary/png/proteus-lockup-h-light-background-1200.png new file mode 100644 index 0000000000..27b8a222f6 Binary files /dev/null and b/docs/source/_static/logo/primary/png/proteus-lockup-h-light-background-1200.png differ diff --git a/docs/source/_static/logo/primary/png/proteus-lockup-v-dark-background-800.png b/docs/source/_static/logo/primary/png/proteus-lockup-v-dark-background-800.png new file mode 100644 index 0000000000..73c78ec1a0 Binary files /dev/null and b/docs/source/_static/logo/primary/png/proteus-lockup-v-dark-background-800.png differ diff --git a/docs/source/_static/logo/primary/png/proteus-lockup-v-light-background-800.png b/docs/source/_static/logo/primary/png/proteus-lockup-v-light-background-800.png new file mode 100644 index 0000000000..edae4a9f14 Binary files /dev/null and b/docs/source/_static/logo/primary/png/proteus-lockup-v-light-background-800.png differ diff --git a/docs/source/_static/logo/primary/png/proteus-mark-1024.png b/docs/source/_static/logo/primary/png/proteus-mark-1024.png new file mode 100644 index 0000000000..96cb9c34c6 Binary files /dev/null and b/docs/source/_static/logo/primary/png/proteus-mark-1024.png differ diff --git a/docs/source/_static/logo/primary/png/proteus-mark-512.png b/docs/source/_static/logo/primary/png/proteus-mark-512.png new file mode 100644 index 0000000000..3d12c909b4 Binary files /dev/null and b/docs/source/_static/logo/primary/png/proteus-mark-512.png differ diff --git a/docs/source/_static/logo/primary/png/proteus-mark-light-background-1024.png b/docs/source/_static/logo/primary/png/proteus-mark-light-background-1024.png new file mode 100644 index 0000000000..8785bc22b9 Binary files /dev/null and b/docs/source/_static/logo/primary/png/proteus-mark-light-background-1024.png differ diff --git a/docs/source/_static/logo/primary/proteus-favicon.ico b/docs/source/_static/logo/primary/proteus-favicon.ico new file mode 100644 index 0000000000..52e3f59127 Binary files /dev/null and b/docs/source/_static/logo/primary/proteus-favicon.ico differ diff --git a/docs/source/_static/logo/primary/proteus-favicon.svg b/docs/source/_static/logo/primary/proteus-favicon.svg new file mode 100644 index 0000000000..cad934bddc --- /dev/null +++ b/docs/source/_static/logo/primary/proteus-favicon.svg @@ -0,0 +1,4 @@ + +Proteus + + diff --git a/docs/source/_static/logo/primary/proteus-lockup-h-auto.svg b/docs/source/_static/logo/primary/proteus-lockup-h-auto.svg new file mode 100644 index 0000000000..5572ea50f2 --- /dev/null +++ b/docs/source/_static/logo/primary/proteus-lockup-h-auto.svg @@ -0,0 +1,6 @@ + +Proteus + + + + diff --git a/docs/source/_static/logo/primary/proteus-lockup-h-dark-background.svg b/docs/source/_static/logo/primary/proteus-lockup-h-dark-background.svg new file mode 100644 index 0000000000..597ed8e8df --- /dev/null +++ b/docs/source/_static/logo/primary/proteus-lockup-h-dark-background.svg @@ -0,0 +1,5 @@ + +Proteus + + + diff --git a/docs/source/_static/logo/primary/proteus-lockup-h-light-background.svg b/docs/source/_static/logo/primary/proteus-lockup-h-light-background.svg new file mode 100644 index 0000000000..e44cf05653 --- /dev/null +++ b/docs/source/_static/logo/primary/proteus-lockup-h-light-background.svg @@ -0,0 +1,5 @@ + +Proteus + + + diff --git a/docs/source/_static/logo/primary/proteus-lockup-v-auto.svg b/docs/source/_static/logo/primary/proteus-lockup-v-auto.svg new file mode 100644 index 0000000000..8afa45a56e --- /dev/null +++ b/docs/source/_static/logo/primary/proteus-lockup-v-auto.svg @@ -0,0 +1,6 @@ + +Proteus + + + + diff --git a/docs/source/_static/logo/primary/proteus-lockup-v-dark-background.svg b/docs/source/_static/logo/primary/proteus-lockup-v-dark-background.svg new file mode 100644 index 0000000000..804c546983 --- /dev/null +++ b/docs/source/_static/logo/primary/proteus-lockup-v-dark-background.svg @@ -0,0 +1,5 @@ + +Proteus + + + diff --git a/docs/source/_static/logo/primary/proteus-lockup-v-light-background.svg b/docs/source/_static/logo/primary/proteus-lockup-v-light-background.svg new file mode 100644 index 0000000000..bd9e046c11 --- /dev/null +++ b/docs/source/_static/logo/primary/proteus-lockup-v-light-background.svg @@ -0,0 +1,5 @@ + +Proteus + + + diff --git a/docs/source/_static/logo/primary/proteus-mark-auto.svg b/docs/source/_static/logo/primary/proteus-mark-auto.svg new file mode 100644 index 0000000000..623b57eb32 --- /dev/null +++ b/docs/source/_static/logo/primary/proteus-mark-auto.svg @@ -0,0 +1,5 @@ + +Proteus + + + diff --git a/docs/source/_static/logo/primary/proteus-mark-light-background.svg b/docs/source/_static/logo/primary/proteus-mark-light-background.svg new file mode 100644 index 0000000000..742f8ab308 --- /dev/null +++ b/docs/source/_static/logo/primary/proteus-mark-light-background.svg @@ -0,0 +1,4 @@ + +Proteus + + diff --git a/docs/source/_static/logo/primary/proteus-mark.svg b/docs/source/_static/logo/primary/proteus-mark.svg new file mode 100644 index 0000000000..6a8b6e1c6d --- /dev/null +++ b/docs/source/_static/logo/primary/proteus-mark.svg @@ -0,0 +1,4 @@ + +Proteus + + diff --git a/docs/source/conf.py b/docs/source/conf.py index afc9b1f807..daef118cfb 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -197,12 +197,12 @@ def linkcode_resolve(domain, info): # The name of an image file (relative to this directory) to place at the top # of the sidebar. -html_logo = "_static/corps_logo_cross2.svg" +html_logo = "_static/logo/primary/proteus-lockup-v-light-background.svg" # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -html_favicon = "_static/tritonBorder.ico" +html_favicon = "_static/logo/primary/proteus-favicon.ico" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, @@ -284,7 +284,7 @@ def linkcode_resolve(domain, info): # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = '_static/tritonCorps.png' +#latex_logo = '_static/logo/primary/png/proteus-lockup-v-light-background-800.png' # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. diff --git a/docs/source/models/SWFlow.rst b/docs/source/models/SWFlow.rst index 0b33b51a14..68c5f5b8db 100644 --- a/docs/source/models/SWFlow.rst +++ b/docs/source/models/SWFlow.rst @@ -20,7 +20,7 @@ the action of gravity under the assumption that the deformations of the free sur are small compared to the water height. The implementation of the SWEs with source documentation is -available here: :py:mod:`proteus.mprans.SW2DCV`. +available here: :py:mod:`proteus.kernels.SW2DCV`. @@ -32,7 +32,7 @@ Green-Naghdi equations, where h is the mesh size. The Green-Naghdi equations are used to describe dispersive water waves. The implementation of the mGN equations with source documentation is -available here: :py:mod:`proteus.mprans.GN_SW2DCV`. +available here: :py:mod:`proteus.kernels.GN_SW2DCV`. Running the tests diff --git a/docs/source/models/adr.rst b/docs/source/models/adr.rst index 36c16ec91b..5a6a0225e2 100644 --- a/docs/source/models/adr.rst +++ b/docs/source/models/adr.rst @@ -7,7 +7,7 @@ Advection-Diffusion-Reaction with Unfitted Interfaces Description =========== -The ADR model (:py:mod:`proteus.ADR`) solves linear advection-diffusion-reaction equations +The ADR model (:py:mod:`proteus.kernels.ADR`) solves linear advection-diffusion-reaction equations .. math:: @@ -37,7 +37,7 @@ the optimal orders for :math:`p=1,2` and coefficient contrasts up to 1000: :math :math:`L^2` and :math:`p` in the broken :math:`H^1` seminorm. The :math:`L^\infty` error also decreases at order :math:`p+1` on average, with fluctuating rates at the highest contrast. -All options are arguments of :py:class:`proteus.ADR.Coefficients`; its documentation lists +All options are arguments of :py:class:`proteus.kernels.ADR.Coefficients`; its documentation lists them with the values used in the paper below. diff --git a/docs/source/models/body_dynamics.rst b/docs/source/models/body_dynamics.rst index a46dc8b11b..d0bb184f69 100644 --- a/docs/source/models/body_dynamics.rst +++ b/docs/source/models/body_dynamics.rst @@ -146,7 +146,7 @@ cable is desired, such as a catenary shape. ProtChAddedMass --------------- -A class to deal with the added mass model from proteus.mprans.AddedMass. This +A class to deal with the added mass model from proteus.kernels.AddedMass. This class should not be instantiated manually and will be automatically instantiating as a variable of `ProtChSystem` (accessible as `my_system.ProtChAddedMass`). It is used to build the added mass matrix for the diff --git a/docs/source/models/free_surface.rst b/docs/source/models/free_surface.rst index 29916b416a..d2bdf6bbd0 100644 --- a/docs/source/models/free_surface.rst +++ b/docs/source/models/free_surface.rst @@ -10,14 +10,14 @@ VOF - NCLS In this implementation, the following 4 models must be solved in order: -* Volume of Fluid (VOF): :py:mod:`proteus.mprans.VOF` -* Non-conservative level set (NCLS): :py:mod:`proteus.mprans.NCLS` -* Redistancing: :py:mod:`proteus.mprans.RDLS` -* Mass correction: :py:mod:`proteus.mprans.MCorr` +* Volume of Fluid (VOF): :py:mod:`proteus.kernels.VOF` +* Non-conservative level set (NCLS): :py:mod:`proteus.kernels.NCLS` +* Redistancing: :py:mod:`proteus.kernels.RDLS` +* Mass correction: :py:mod:`proteus.kernels.MCorr` CLSVOF ====== In this implementation, a conservative level set is used and only the following -model must be solved: :py:mod:`proteus.mprans.CLSVOF`. +model must be solved: :py:mod:`proteus.kernels.CLSVOF`. diff --git a/docs/source/models/navier_stokes.rst b/docs/source/models/navier_stokes.rst index bdb705525a..8f92a00c2b 100644 --- a/docs/source/models/navier_stokes.rst +++ b/docs/source/models/navier_stokes.rst @@ -17,14 +17,14 @@ Two-Phase ========= The two-phase implementation of Navier-Stokes, with source documentation -available here: :py:mod:`proteus.mprans.RANS2P`. +available here: :py:mod:`proteus.kernels.RANS2P`. Three-Phase =========== The three-phase implementation of Navier-Stokes, with source documentation -available here: :py:mod:`proteus.mprans.RANS3P`. +available here: :py:mod:`proteus.kernels.RANS3P`. Dealing with Moving Domains @@ -39,7 +39,7 @@ Moving (ALE) Mesh ----------------- In the current implementation, if a model for moving the mesh is used such as -:py:mod:`proteus.mprans.MoveMesh`, it should be the first model to be solved, +:py:mod:`proteus.kernels.MoveMesh`, it should be the first model to be solved, as the mesh velocity is calculated from the previous time step. @@ -47,5 +47,5 @@ Immersed Boundaries ------------------- The two-phase implementation of Navier-Stokes with immersed solid boundaries, with -source documentation available here: :py:mod:`proteus.mprans.RANS2P_IB`. This is a different +source documentation available here: :py:mod:`proteus.kernels.RANS2P_IB`. This is a different method from the immersed finite elements of the ADR model (:ref:`adr`). diff --git a/docs/source/tools/spatial_tools.rst b/docs/source/tools/spatial_tools.rst index a4079f4a09..0045ad111e 100644 --- a/docs/source/tools/spatial_tools.rst +++ b/docs/source/tools/spatial_tools.rst @@ -3,8 +3,7 @@ SpatialTools ************ -source: :py:mod:`proteus.SpatialTools` and -:py:mod:`proteus.mprans.SpatialTools` +source: :py:mod:`proteus.SpatialTools` Usage ===== @@ -13,8 +12,8 @@ Using spatial tools #. Create a domain from :py:mod:`proteus.Domain`. #. Create geometries that will be part of this domain from - :py:mod:`proteus.SpatialTools` or :py:mod:`proteus.mprans.SpatialTools`. -#. Assemble domain with :py:meth:`proteus.SpatialTools.assembleDomain` or :py:meth:`proteus.mprans.SpatialTools.assembleDomain`. + :py:mod:`proteus.SpatialTools`. +#. Assemble domain with :py:meth:`proteus.SpatialTools.assembleDomain` (two-phase flow boundary conditions when any shape is a ``ShapeRANS``). Import ------ @@ -25,12 +24,12 @@ The base `SpatialTools` module can be imported as follows: from proteus import SpatialTools as st -The `mprans` version of `SpatialTools`, adding functionality specific to +The two-phase flow part of `SpatialTools` (formerly `proteus.kernels.SpatialTools`, merged into `proteus.SpatialTools`; the old import path still works and warns), adding functionality specific to multi-phase flows, can be imported as follows: .. code-block:: python - from proteus.mprans import SpatialTools as st + from proteus import SpatialTools as st Choosing the domain ------------------- @@ -68,8 +67,8 @@ BoundaryConditions with SpatialTools Usage ^^^^^ -The mprans version of SpatialTools also associate geometry boundaries with -`BoundaryCondition` instances from mprans.BoundaryConditions. These +SpatialTools also associates geometry boundaries with +`BoundaryCondition` instances from BoundaryConditions. These `BoundaryCondition` instances are easily accessible through a dictionary with predefined names, e.g. for a `Rectangle` shape instance named `my_rectangle`, ``my_rectangle.BC['x-']`` is for accessing the boundary conditions of the left @@ -124,7 +123,7 @@ Complete Examples .. code-block:: python from proteus import Domain - from proteus.mprans import SpatialTools as st + from proteus import SpatialTools as st domain = Domain.PlanarStraightLineGraphDomain() @@ -159,7 +158,7 @@ Complete Examples .. code-block:: python from proteus import Domain - from proteus.mprans import SpatialTools as st + from proteus import SpatialTools as st domain = Domain.PiecewiseLinearComplexDomain() @@ -200,7 +199,7 @@ Complete Examples #See complete case in https://github.com/erdc/air-water-vv/tree/master/3d/STLShape from proteus import Domain - from proteus.mprans import SpatialTools as st + from proteus import SpatialTools as st from proteus.Profiling import logEvent as log domain = Domain.PiecewiseLinearComplexDomain() @@ -225,7 +224,7 @@ Complete Examples #See complete case in https://github.com/erdc/air-water-vv/tree/master/3d/STLShape_Zones from proteus import Domain - from proteus.mprans import SpatialTools as st + from proteus import SpatialTools as st from proteus.Profiling import logEvent as log domain = Domain.PiecewiseLinearComplexDomain() @@ -295,7 +294,7 @@ Base classes ------------ The following classes are accessible with an import from `proteus.SpatialTools` -and/or `proteus.mprans.SpatialTools`. Importing them from the mprans module +(the former `proteus.kernels.SpatialTools` is the same module). Importing it makes every shape a two-phase flow shape, which adds functionality such as the possibility to set multi-phase flow boundary conditions and relaxation zones. @@ -455,7 +454,7 @@ mprans specific --------------- The following classes are for use with multi-phase flow and can only be -imported from `proteus.mprans.SpatialTools`. +imported from `proteus.SpatialTools`. Tank2D diff --git a/experimental/adrh/vof_capture.py b/experimental/adrh/vof_capture.py index bdfd40f514..609f0a9fbd 100644 --- a/experimental/adrh/vof_capture.py +++ b/experimental/adrh/vof_capture.py @@ -107,7 +107,7 @@ def main(argv): from proteus import Comm Comm.init() - from proteus.mprans import cArgumentsDict + from proteus import cArgumentsDict base = cArgumentsDict.ArgumentsDict diff --git a/proteus/ArchiveFields.py b/proteus/ArchiveFields.py index e91c382839..12e9e2faf5 100644 --- a/proteus/ArchiveFields.py +++ b/proteus/ArchiveFields.py @@ -45,7 +45,7 @@ .. code-block:: python - # in proteus/mprans/SW2DCV.py, class Coefficients + # in proteus/kernels/SW2DCV.py, class Coefficients def archiveFields(self, lm): yield ArchiveField("bathymetry", self.b.dof) yield ArchiveField("eta", self.b.dof + lm.u[0].dof) diff --git a/proteus/mprans/ArgumentsDict.cpp b/proteus/ArgumentsDict.cpp similarity index 100% rename from proteus/mprans/ArgumentsDict.cpp rename to proteus/ArgumentsDict.cpp diff --git a/proteus/mprans/ArgumentsDict.h b/proteus/ArgumentsDict.h similarity index 100% rename from proteus/mprans/ArgumentsDict.h rename to proteus/ArgumentsDict.h diff --git a/proteus/BoundaryConditions.pxd b/proteus/BoundaryConditions.pxd index d191b2b97e..9dcb2d6b8b 100644 --- a/proteus/BoundaryConditions.pxd +++ b/proteus/BoundaryConditions.pxd @@ -22,3 +22,198 @@ cdef class BoundaryCondition: cpdef void resetBC(self) # cpdef void setConstantBC(self, double value) # cpdef void setLinearBC(self, double a0, double a1, int i) + +from libcpp cimport bool + +ctypedef double[:,:,:] double_memview3 +ctypedef double[:,:] double_memview2 +ctypedef double[:] double_memview1 +ctypedef int[:] int_memview1 + +# ctypedef double (*cpp_uOfXT) (BC_RANS, double[:], double) + +cdef class BC_RANS(BC_Base): + cdef double[:] zero_array + cdef double f + cdef __cppClass_WavesCharacteristics waves + cdef object body + cdef double[:] wind_speed + cdef double[:, :] body_python_rot_matrix + cdef double[:] body_python_last_pos + cdef double[:] body_python_h + cdef public: + # dirichlet + cdef BoundaryCondition p_dirichlet + cdef BoundaryCondition u_dirichlet + cdef BoundaryCondition v_dirichlet + cdef BoundaryCondition w_dirichlet + cdef BoundaryCondition phi_dirichlet + cdef BoundaryCondition vof_dirichlet + cdef BoundaryCondition k_dirichlet + cdef BoundaryCondition dissipation_dirichlet + cdef BoundaryCondition pAddedMass_dirichlet + # advective + cdef BoundaryCondition p_advective + cdef BoundaryCondition u_advective + cdef BoundaryCondition v_advective + cdef BoundaryCondition w_advective + cdef BoundaryCondition vof_advective + cdef BoundaryCondition k_advective + cdef BoundaryCondition dissipation_advective + #diffusive + cdef BoundaryCondition u_diffusive + cdef BoundaryCondition v_diffusive + cdef BoundaryCondition w_diffusive + cdef BoundaryCondition k_diffusive + cdef BoundaryCondition dissipation_diffusive + # mesh + cdef BoundaryCondition hx_dirichlet + cdef BoundaryCondition hy_dirichlet + cdef BoundaryCondition hz_dirichlet + cdef BoundaryCondition u_stress + cdef BoundaryCondition v_stress + cdef BoundaryCondition w_stress + # sediment solver + cdef BoundaryCondition us_dirichlet + cdef BoundaryCondition vs_dirichlet + cdef BoundaryCondition ws_dirichlet + cdef BoundaryCondition vos_dirichlet + cdef BoundaryCondition us_advective + cdef BoundaryCondition vs_advective + cdef BoundaryCondition ws_advective + cdef BoundaryCondition vos_advective + cdef BoundaryCondition us_diffusive + cdef BoundaryCondition vs_diffusive + cdef BoundaryCondition ws_diffusive + # projection scheme + cdef BoundaryCondition pInit_dirichlet + cdef BoundaryCondition pInc_dirichlet + cdef BoundaryCondition pInit_advective + cdef BoundaryCondition pInc_advective + cdef BoundaryCondition pInit_diffusive + cdef BoundaryCondition pInc_diffusive + # clsvof + cdef BoundaryCondition clsvof_dirichlet + cdef BoundaryCondition clsvof_advective + cdef BoundaryCondition clsvof_diffusive + + + # functions + # cpdef void reset(self) + # cpdef void setNonMaterial(self) + # cpdef void setTank(self) + # cpdef void setFixedNodes(self) + # cpdef void setNoSlip(self) + # cpdef void setFreeSlip(self) + # cpdef void setAtmosphere(self, double[:] orientation=*, double vof_air=*) + # cpdef void setMoveMesh(self, double[:] last_pos, double[:] h=*, double[:,:] rot_matrix=*) + @cython.locals(hx=np.ndarray) + cpdef double[:] __cpp_MoveMesh_h(self, double[:] x, double t) + cpdef double __cpp_MoveMesh_hx(self, double[:] x, double t) + cpdef double __cpp_MoveMesh_hy(self, double[:] x, double t) + cpdef double __cpp_MoveMesh_hz(self, double[:] x, double t) +# @cython.locals(waveHeight=double, wavePhi=double, +# water_speed=double_memview1, x_max=double_memview1, +# u=cython.p_double, H=double) + cdef double __cpp_UnsteadyTwoPhaseVelocityInlet_u_dirichlet(self, double[:] x, double t) + cdef double __cpp_UnsteadyTwoPhaseVelocityInlet_v_dirichlet(self, double[:] x, double t) + cdef double __cpp_UnsteadyTwoPhaseVelocityInlet_w_dirichlet(self, double[:] x, double t) + cdef double __cpp_UnsteadyTwoPhaseVelocityInlet_phi_dirichlet(self, double[:] x, double t) + cdef double __cpp_UnsteadyTwoPhaseVelocityInlet_vof_dirichlet(self, double[:] x, double t) + cdef double __cpp_UnsteadyTwoPhaseVelocityInlet_p_advective(self, double[:] x, double t) + +ctypedef double[:] (*cfvel) (double[3], double) # pointer to velocity function +ctypedef double (*cfeta) (double[3], double) # pointer to eta function +ctypedef double[:] (*cfvelrel) (RelaxationZone, double[3], double) # pointer to velocity function of RelaxationZone class +ctypedef double (*cfphirel) (RelaxationZone, double[3]) # pointer to phi function of RelaxationZone class +ctypedef double (*cfphiwave) (RelaxationZone, double[3]) # pointer to phi function of RelaxationZone class +ctypedef np.float64_t float64_t +ctypedef np.int64_t int64_t + +cdef class RelaxationZone: + cdef double[:] wind_speed + cdef double[:] u_calc # calculated velocity + # wave characteristics (if any) + cdef cfvelrel uu + cdef cfphirel phi + cdef double mwl + cdef cfeta eta + cdef double waveHeight + cdef double wavePhi + cdef double waterSpeed + cdef int nd + cdef double[:] zero_vel + cdef __cppClass_WavesCharacteristics waves + cdef public: + object Shape + str zone_type + double dragAlpha + double dragBeta + double porosity + double epsFact_solid + double epsFact_porous + double vert_axis + double[:] center + double[:] orientation + cpdef void calculate_init(self) + cdef double[:] calculate_vel(self, cython.p_double x, double t) + @cython.locals(xx=double_memview1, waveHeight=double, wavePhi=double, + waterSpeed=double_memview1, x_max=double_memview1, H=double, + u=cython.double[3], o1=double, o2=double, o3=double) + cdef double[:] __cpp_calculate_vel_wave(self, double* x, double t) + cdef double[:] __cpp_calculate_vel_zero(self, double* x, double t) + cdef double calculate_phi(self, double* x) + @cython.locals(d1=double, d2=double, d3=double, phi=double, + o1=double, o2=double, o3=double) + cdef double __cpp_calculate_phi_porous(self, double[3] x) + cdef double __cpp_calculate_phi_porous_sponge(self, double[3] x) + +cdef class RelaxationZoneWaveGenerator: + cdef int nd # dimension + cdef int max_flag # maximum region flag of relaxation zones (initialised in calculate_init) + cdef np.ndarray zones_array # zones array for fast access + cdef public: + dict zones # zones dictionary + object model # model attached to zone + object ar # + # cpdef RelaxationZoneWaveGenerator attachModel(self, dict, int) # needed + # cpdef void attachAuxiliaryVariables(self, dict) # needed + @cython.locals(zones=np.ndarray) + cpdef void calculate_init(self) + cpdef void calculate(self) + @cython.locals(m=object, zone=RelaxationZone, mType=int, nE=int, nk=int, + qx=double_memview3, x=cython.double[3], t=double, nl=int, + q_phi_porous=double_memview2, phi=double, + q_velocity_solid=double_memview3, u=double_memview1, mTypes=int_memview1) + cdef void __cpp_iterate(self) # main iteration loop + + +cdef class __cppClass_WavesCharacteristics: + cdef int vert_axis # vertical axis + # relaxation zone info (if any) + cdef double[:] center # center of zone + cdef double[:] orientation # orientation of zone + # zero array + cdef double[:] zero_vel + cdef double[:] _b_or + cdef double[:] wind_speed + cdef double vof_air + cdef double vof_water + cdef double smoothing + cdef public: + # wave class from WaveTools + object WT + @cython.locals(phi=double, waterSpeed=double_memview1, + H=double) + cdef double[:] __cpp_calculate_velocity(self, double* x, double t) + @cython.locals(ux=double_memview1, b0=double, b1=double, b2=double, u0=double, + u1=double, u2=double) + cdef double __cpp_calculate_pressure(self, double* x, double t) + @cython.locals(level=double) + cdef double __cpp_calculate_phi(self, double* x, double t) + @cython.locals(phi=double, H=double) + cdef double __cpp_calculate_vof(self, double* x, double t) + @cython.locals(H=double) + cdef double __cpp_calculate_smoothing_H(self, double phi) + +cdef double* __x_to_cpp(double[:]) diff --git a/proteus/BoundaryConditions.py b/proteus/BoundaryConditions.py index 7e0231653e..947ae3dfb1 100644 --- a/proteus/BoundaryConditions.py +++ b/proteus/BoundaryConditions.py @@ -6,16 +6,33 @@ # cython: initializedcheck=False # cython: language_level=3 import cython +import os, sys import numpy as np """ -Module for creating boundary conditions. Imported in SpatialTools.py +Module for creating boundary conditions: the generic classes (BC_Base, BoundaryCondition) and the two-phase +flow ones (BC_RANS, RelaxationZone, RelaxationZoneWaveGenerator, WallFunctions, kWall; formerly +proteus.kernels.BoundaryConditions, merged here by C49 R1). Imported in SpatialTools.py .. inheritance-diagram:: proteus.BoundaryConditions :parts: 1 """ +from proteus import AuxiliaryVariables, Comm +from proteus.ctransportCoefficients import (smoothedHeaviside, + smoothedHeaviside_integral) +from proteus import WaveTools as wt +from proteus.Profiling import logEvent +from math import cos, sin, sqrt, atan2, acos, asin +from mpi4py import MPI +from scipy import spatial __all__ = ['BC_Base', - 'BoundaryCondition'] + 'BoundaryCondition', + 'BC_RANS', + 'RelaxationZone', + 'RelaxationZoneWaveGenerator', + '_cppClass_WavesCharacteristics', + 'WallFunctions', + 'kWall'] class BC_Base: """ @@ -123,4 +140,1639 @@ def setLinearRamp(self,t1,value): value: float Variable value """ - self.uOfXT = lambda x, t, n=np.zeros(3,): min( t/t1, 1)*value \ No newline at end of file + self.uOfXT = lambda x, t, n=np.zeros(3,): min( t/t1, 1)*value + + +class BC_RANS(BC_Base): + """ + Class regrouping boundary conditions for two-phase flows + """ + + def __init__(self, shape=None, name=None, b_or=None, b_i=0., nd=None): + super(BC_RANS, self).__init__(shape=shape, name=name, b_or=b_or, b_i=b_i, nd=nd) + # _dirichlet + self.p_dirichlet = BoundaryCondition() # pressure + self.u_dirichlet = BoundaryCondition() # velocity u + self.v_dirichlet = BoundaryCondition() # velocity v + self.w_dirichlet = BoundaryCondition() # velocity w + self.phi_dirichlet = BoundaryCondition() # phi + self.vof_dirichlet = BoundaryCondition() # VOF + self.k_dirichlet = BoundaryCondition() # kappa + self.dissipation_dirichlet = BoundaryCondition() # dissipation + self.pAddedMass_dirichlet = BoundaryCondition() + # _advective + self.p_advective = BoundaryCondition() + self.u_advective = BoundaryCondition() + self.v_advective = BoundaryCondition() + self.w_advective = BoundaryCondition() + self.vof_advective = BoundaryCondition() + self.k_advective = BoundaryCondition() + self.dissipation_advective = BoundaryCondition() + # _diffusive + self.u_diffusive = BoundaryCondition() + self.v_diffusive = BoundaryCondition() + self.w_diffusive = BoundaryCondition() + self.k_diffusive = BoundaryCondition() + self.dissipation_diffusive = BoundaryCondition() + # moveMesh boundary conditions + self.hx_dirichlet = BoundaryCondition() + self.hy_dirichlet = BoundaryCondition() + self.hz_dirichlet = BoundaryCondition() + self.u_stress = BoundaryCondition() + self.v_stress = BoundaryCondition() + self.w_stress = BoundaryCondition() + self.u_stress.uOfXT = 0. + self.v_stress.uOfXT = 0. + self.w_stress.uOfXT = 0. + # sediment solver + self.us_dirichlet = BoundaryCondition() # sediment velocity u + self.vs_dirichlet = BoundaryCondition() # sediment velocity v + self.ws_dirichlet = BoundaryCondition() # sediment velocity w + self.vos_dirichlet = BoundaryCondition() # VOS + self.us_advective = BoundaryCondition() + self.vs_advective = BoundaryCondition() + self.ws_advective = BoundaryCondition() + self.vos_advective = BoundaryCondition() + self.us_diffusive = BoundaryCondition() + self.vs_diffusive = BoundaryCondition() + self.ws_diffusive = BoundaryCondition() + # projection scheme + self.pInit_dirichlet = BoundaryCondition() # initial pressure + self.pInc_dirichlet = BoundaryCondition() # pressure increment + self.pInit_advective = BoundaryCondition() + self.pInc_advective = BoundaryCondition() + self.pInit_diffusive = BoundaryCondition() + self.pInc_diffusive = BoundaryCondition() + # clsvof + self.clsvof_dirichlet = BoundaryCondition() + self.clsvof_advective = BoundaryCondition() + self.clsvof_diffusive = BoundaryCondition() + + def reset(self): + """ + Resets all BoundaryCondtion functions to None, apart from the BCs + affecting: moving mesh + """ + # self.BC_type = 'None' + self.p_dirichlet.resetBC() + self.pInit_dirichlet.resetBC() + self.pInc_dirichlet.resetBC() + self.u_dirichlet.resetBC() + self.v_dirichlet.resetBC() + self.w_dirichlet.resetBC() + self.phi_dirichlet.resetBC() + self.vof_dirichlet.resetBC() + self.k_dirichlet.resetBC() + self.dissipation_dirichlet.resetBC() + self.us_dirichlet.resetBC() + self.vs_dirichlet.resetBC() + self.ws_dirichlet.resetBC() + self.vos_dirichlet.resetBC() + self.p_advective.resetBC() + self.pInit_advective.resetBC() + self.pInc_advective.resetBC() + self.u_advective.resetBC() + self.v_advective.resetBC() + self.w_advective.resetBC() + self.vof_advective.resetBC() + self.k_advective.resetBC() + self.dissipation_advective.resetBC() + self.us_advective.resetBC() + self.vs_advective.resetBC() + self.ws_advective.resetBC() + self.vos_advective.resetBC() + self.pInit_diffusive.resetBC() + self.pInc_diffusive.resetBC() + self.u_diffusive.resetBC() + self.v_diffusive.resetBC() + self.w_diffusive.resetBC() + self.k_diffusive.resetBC() + self.dissipation_diffusive.resetBC() + self.us_diffusive.resetBC() + self.vs_diffusive.resetBC() + self.ws_diffusive.resetBC() + self.clsvof_dirichlet.resetBC() + self.clsvof_advective.resetBC() + self.clsvof_diffusive.resetBC() + + def setNonMaterial(self): + """ + Sets non-material boundary conditions (diffusive flux and advective vof + to 0.). + """ + self.reset() + self.BC_type = 'NonMaterial' + self.vof_advective.setConstantBC(0.) + self.vos_advective.setConstantBC(0.) + self.p_advective.setConstantBC(0.) + self.u_advective.setConstantBC(0.) + self.v_advective.setConstantBC(0.) + self.w_advective.setConstantBC(0.) + self.u_diffusive.setConstantBC(0.) + self.v_diffusive.setConstantBC(0.) + self.w_diffusive.setConstantBC(0.) + self.us_diffusive.setConstantBC(0.) + self.vs_diffusive.setConstantBC(0.) + self.ws_diffusive.setConstantBC(0.) + self.k_diffusive.setConstantBC(0.) + self.dissipation_diffusive.setConstantBC(0.) + self.pInc_diffusive.setConstantBC(0.) + + def setTank(self, b_or=None): + if b_or is None: + assert self._b_or is not None, 'Boundary orientation must be defined!' + b_or = self._b_or + self.u_stress.uOfXT = 0. + self.v_stress.uOfXT = 0. + self.w_stress.uOfXT = 0. + self.hx_dirichlet.resetBC() + self.hy_dirichlet.resetBC() + self.hz_dirichlet.resetBC() + if b_or[0] == 1 or b_or[0] == -1: + self.hx_dirichlet.setConstantBC(0.) + self.u_stress.uOfXT = None + elif b_or[1] == 1 or b_or[1] == -1: + self.hy_dirichlet.setConstantBC(0.) + self.v_stress.uOfXT = None + elif len(b_or) > 2 and (b_or[2] == 1 or b_or[2] == -1): + self.hz_dirichlet.setConstantBC(0.) + self.w_stress.uOfXT = None + + def setFixedNodes(self): + """ + For moving domains: fixes nodes/boundary + """ + self.hx_dirichlet.setConstantBC(0.) + self.hy_dirichlet.setConstantBC(0.) + self.hz_dirichlet.setConstantBC(0.) + self.u_stress.uOfXT = 0. + self.v_stress.uOfXT = 0. + self.w_stress.uOfXT = 0. + + def setNoSlip(self): + """ + Sets no slip conditions at the boundary + """ + self.reset() + self.BC_type = 'NoSlip' + # dirichlet + self.u_dirichlet.setConstantBC(0.) + self.v_dirichlet.setConstantBC(0.) + self.w_dirichlet.setConstantBC(0.) + self.us_dirichlet.setConstantBC(0.) + self.vs_dirichlet.setConstantBC(0.) + self.ws_dirichlet.setConstantBC(0.) + self.k_dirichlet.setConstantBC(1e-20) + self.dissipation_dirichlet.setConstantBC(1e-10) + # advective + self.p_advective.setConstantBC(0.) + self.pInit_advective.setConstantBC(0.) + self.pInc_advective.setConstantBC(0.) + self.vof_advective.setConstantBC(0.) + self.vos_advective.setConstantBC(0.) + # diffusive + self.pInc_diffusive.setConstantBC(0.) + self.k_diffusive.setConstantBC(0.) + self.dissipation_diffusive.setConstantBC(0.) + + def setFreeSlip(self): + """ + Sets free slip conditions at the boundary + """ + self.reset() + self.BC_type = 'FreeSlip' + # dirichlet + self.k_dirichlet.setConstantBC(1e-20) + self.dissipation_dirichlet.setConstantBC(1e-10) + # advective + self.p_advective.setConstantBC(0.) + self.pInit_advective.setConstantBC(0.) + self.pInc_advective.setConstantBC(0.) + self.u_advective.setConstantBC(0.) + self.v_advective.setConstantBC(0.) + self.w_advective.setConstantBC(0.) + self.us_advective.setConstantBC(0.) + self.vs_advective.setConstantBC(0.) + self.ws_advective.setConstantBC(0.) + self.vof_advective.setConstantBC(0.) + self.vos_advective.setConstantBC(0.) + # diffusive + self.u_diffusive.setConstantBC(0.) + self.v_diffusive.setConstantBC(0.) + self.w_diffusive.setConstantBC(0.) + self.us_diffusive.setConstantBC(0.) + self.vs_diffusive.setConstantBC(0.) + self.ws_diffusive.setConstantBC(0.) + self.pInc_diffusive.setConstantBC(0.) + self.k_diffusive.setConstantBC(0.) + self.dissipation_diffusive.setConstantBC(0.) + + def setConstantInletVelocity(self, U, ramp, kk, dd , b_or): + """ + Sets constant velocity in each inlet face with ramping up and turbulence properties + """ + self.reset() + self.BC_type = 'constantInletVelocity' + Uin = np.dot(U,b_or) + uu = U[0] + vv = U[1] + ww = U[2] + + # dirichlet + self.u_dirichlet.setLinearRamp(ramp, uu) + self.v_dirichlet.setLinearRamp(ramp ,vv) + self.w_dirichlet.setLinearRamp(ramp ,ww) + self.us_dirichlet.setConstantBC(0.) + self.vs_dirichlet.setConstantBC(0.) + self.ws_dirichlet.setConstantBC(0.) + self.k_dirichlet.setConstantBC(kk) + self.dissipation_dirichlet.setConstantBC(dd) + #advective + self.p_advective.setLinearRamp(ramp, Uin) + self.pInit_advective.setConstantBC(0.) + self.pInc_advective.setLinearRamp(ramp,Uin) + # diffusive + self.k_diffusive.setConstantBC(0.) + self.dissipation_diffusive.setConstantBC(0.) + self.us_diffusive.setConstantBC(0.) + self.vs_diffusive.setConstantBC(0.) + self.ws_diffusive.setConstantBC(0.) + def setConstantOutletPressure(self, p, rho, g ,kk, dd, b_or): + """ + Sets constant pressure in each outlet face for single phase flows + """ + self.reset() + self.BC_type = 'constantOutletPressure' + # dirichlet + a1 = rho*g + self.u_dirichlet.setConstantBC(0.) + self.v_dirichlet.setConstantBC(0.) + self.w_dirichlet.setConstantBC(0.) + self.us_dirichlet.setConstantBC(0.) + self.vs_dirichlet.setConstantBC(0.) + self.ws_dirichlet.setConstantBC(0.) + + self.p_dirichlet.setLinearBC(p,a1) + self.pInit_dirichlet.setLinearBC(p, a1) + self.pInc_dirichlet.setConstantBC(0.) + self.k_dirichlet.setConstantBC(kk) + self.dissipation_dirichlet.setConstantBC(dd) + + # diffusive + if b_or[0] == 1. or b_or[0] == -1.: + self.u_diffusive.setConstantBC(0.) + if b_or[1] == 1. or b_or[1] == -1.: + self.v_diffusive.setConstantBC(0.) + if b_or[2] == 1. or b_or[2] == -1.: + self.w_diffusive.setConstantBC(0.) + self.k_diffusive.setConstantBC(0.) + self.dissipation_diffusive.setConstantBC(0.) + self.us_diffusive.setConstantBC(0.) + self.vs_diffusive.setConstantBC(0.) + self.ws_diffusive.setConstantBC(0.) + + def setAtmosphere(self, orientation=None, vof_air=1.,kInflow=None,dInflow=None): + """ + Sets atmosphere boundary conditions (water can come out) + (!) pressure dirichlet set to 0 for this BC + + Parameters + ---------- + orientation: Optional[array_like] + orientation of the boundary. Optional if orientation was already + passed when creating the BC_RANS class instance. + vof_air: Optional[float] + VOF value of air (default is 1.) + """ + self.BC_type = 'Atmosphere' + if orientation is None and self._b_or is not None: + orientation = self._b_or + assert orientation is not None, 'oritentation must be set for BC' + self.reset() + self.p_dirichlet.setConstantBC(0.) + self.pInc_dirichlet.setConstantBC(0.) + self.pInit_dirichlet.setConstantBC(0.) + self.vof_dirichlet.setConstantBC(vof_air) # air + self.vos_dirichlet.setConstantBC(0.) + self.u_dirichlet.setConstantBC(0.) + self.v_dirichlet.setConstantBC(0.) + self.w_dirichlet.setConstantBC(0.) + self.us_dirichlet.setConstantBC(0.) + self.vs_dirichlet.setConstantBC(0.) + self.ws_dirichlet.setConstantBC(0.) + self.k_dirichlet.setConstantBC(1e-20) + self.k_diffusive.setConstantBC(0.) + self.dissipation_dirichlet.setConstantBC(1e-10) + self.dissipation_diffusive.setConstantBC(0.) + + if orientation[0] == 1. or orientation[0] == -1.: + self.u_diffusive.setConstantBC(0.) + self.us_diffusive.setConstantBC(0.) + if orientation[1] == 1. or orientation[1] == -1.: + self.v_diffusive.setConstantBC(0.) + self.vs_diffusive.setConstantBC(0.) + if orientation[2] == 1. or orientation[2] == -1.: + self.w_diffusive.setConstantBC(0.) + self.ws_diffusive.setConstantBC(0.) + + if kInflow is not None: + self.k_dirichlet.setConstantBC(kInflow) + else: + logEvent("WARNING: Dirichlet condition for k in "+str(self.BC_type)+" has not been set. Ignore if RANS is not used") + if dInflow is not None: + self.dissipation_dirichlet.setConstantBC(dInflow) + else: + logEvent("WARNING: Dirichlet condition for dissipation in "+str(self.BC_type)+" has not been set. Ignore if RANS is not used") + def setRigidBodyMoveMesh(self, body): + """ + Sets boundary conditions for moving the mesh with a rigid body + + Parameters + ---------- + last_pos: array_like + last position of rigig body + h: array_like + displacement of the body + rot_matrix: + rotation matrix describing displament due to rotation between last + position and new position (3x3 array) + + (!) if set manually, the input arrays should be updated externally + without loosing their memory address + """ + def get_DBC_h(i): + def DBC_h(x, t, n=None): + x_0 = x - body.last_position + new_x_0 = np.dot(x_0, body.rotation_matrix) + hx = new_x_0 - x_0 + body.h + return hx[i] + return DBC_h + self.hx_dirichlet.uOfXT = get_DBC_h(0) + self.hy_dirichlet.uOfXT = get_DBC_h(1) + if body.nd > 2: + self.hz_dirichlet.uOfXT = get_DBC_h(2) + + def setChMoveMesh(self, body): + self.hx_dirichlet.uOfXT = lambda x, t, n=None: body.hx(x, t) + self.hy_dirichlet.uOfXT = lambda x, t, n=None: body.hy(x, t) + self.hz_dirichlet.uOfXT = lambda x, t, n=None: body.hz(x, t) + + def setTurbulentDirichlet(self, kVal, dissipationVal): + """ + Sets only dirichlet conditions for turbulence at the boundary. + It's a rough approximation for evalueting the near wall turbulence + based on empirical assumptions. + More sophisticated wall functions are recommended to be used. + + Parameters + ---------- + kVal: float. + constant value applied on k. + dissipationVal: float. + constant value applied on dissipation. + """ + # turbulent boundary conditions + self.k_dirichlet.setConstantBC(kVal) + self.dissipation_dirichlet.setConstantBC(dissipationVal) + self.k_advective.resetBC() + self.dissipation_advective.resetBC() + self.k_diffusive.resetBC() + self.dissipation_diffusive.resetBC() + + def setTurbulentZeroGradient(self): + """ + Sets only zero-gradient conditions for turbulence at the boundary. + More sophisticated wall functions are recommended to be used. + """ + # turbulent boundary conditions + self.k_dirichlet.setConstantBC(0.) + self.dissipation_dirichlet.setConstantBC(0.) + self.k_advective.resetBC() + self.dissipation_advective.resetBC() + self.k_diffusive.setConstantBC(0.) + self.dissipation_diffusive.setConstantBC(0.) + + def setWallFunction(self, wall, shearStress=False): + """ + Sets turbulent boundaries for wall treatment. + Calculation made on nodes outside the viscous sublayer and based + on assumption on the velocity profile close to the wall in order to + impose the wall shear stress. + + Parameters + ---------- + wall: wall object. + BoundaryConditions class to be attached for setting up + all the turbulent parameters. + shearStress: True/False. + At the moment version with shearStress=False is the only one that + returns good results. + Keep it False at the moment! + + - When True, the wall function prescribes diffusive boundaries + for velocity and kappa. It's like imposing the shear stress. + - If False, the wall function prescribes dirichlet conditions. + """ + wf = wall + self.reset() + self.setNoSlip() + self.BC_type = "Wall function" + self.dissipation_diffusive.resetBC() + self.k_dirichlet.uOfXT = lambda x, t, n=None: wf.get_k_dirichlet(x, t, n) + self.dissipation_dirichlet.uOfXT = lambda x, t, n=None: wf.get_dissipation_dirichlet(x, t ,n) + self.u_dirichlet.uOfXT = lambda x, t, n=None: wf.get_u_dirichlet(x, t ,n) + self.v_dirichlet.uOfXT = lambda x, t, n=None: wf.get_v_dirichlet(x, t ,n) + self.w_dirichlet.uOfXT = lambda x, t, n=None: wf.get_w_dirichlet(x, t ,n) + """ + self.dissipation_dirichlet.uOfXT = lambda x, t: wf.get_dissipation_dirichlet(x, t) + self.vof_advective.setConstantBC(0.) + self.p_advective.setConstantBC(0.) + if shearStress: + #self.k_dirichlet.uOfXT = lambda x, t: wf.get_k_dirichlet(x, t) + self.k_advective.setConstantBC(0.) + self.u_diffusive.uOfXT = lambda x, t: wf.get_u_diffusive(x, t) + self.v_diffusive.uOfXT = lambda x, t: wf.get_v_diffusive(x, t) + self.w_diffusive.uOfXT = lambda x, t: wf.get_w_diffusive(x, t) + self.k_diffusive.setConstantBC(0.) + else: + self.u_dirichlet.uOfXT = lambda x, t: wf.get_u_dirichlet(x, t) + self.v_dirichlet.uOfXT = lambda x, t: wf.get_v_dirichlet(x, t) + self.w_dirichlet.uOfXT = lambda x, t: wf.get_w_dirichlet(x, t) + self.k_dirichlet.uOfXT = lambda x, t: wf.get_k_dirichlet(x, t) + """ + def setMoveMesh(self, last_pos, h=(0., 0., 0.), rot_matrix=None): + """ + Sets boundary conditions for moving the mesh with a rigid body + + Parameters + ---------- + last_pos: array_like + last position of rigig body + h: array_like + displacement of the body + rot_matrix: + rotation matrix describing displament due to rotation between last + position and new position (3x3 array) + + (!) if set manually, the input arrays should be updated externally + without loosing their memory address + """ + if rot_matrix is None: + rot_matrix = np.array([[1., 0., 0.], + [0., 1., 0.], + [0., 0., 1.]]) + self.body_python_rot_matrix = rot_matrix + self.body_python_last_pos = last_pos + self.body_python_h = h + self.hx_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_MoveMesh_hx(x, t) + self.hy_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_MoveMesh_hy(x, t) + self.hz_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_MoveMesh_hz(x, t) + + def __cpp_MoveMesh_h(self, x, t): + cython.declare(x_0=cython.double[3]) + cython.declare(new_x_0=cython.double[3]) + hx = np.zeros(3) + x_0[0] = x[0] - self.body_python_last_pos[0] + x_0[1] = x[1] - self.body_python_last_pos[1] + x_0[2] = x[2] - self.body_python_last_pos[2] + new_x_0 = np.dot(x_0, self.body_python_rot_matrix) + hx[0] = new_x_0[0] - x_0[0] + self.body_python_h[0] + hx[1] = new_x_0[1] - x_0[1] + self.body_python_h[1] + hx[2] = new_x_0[2] - x_0[2] + self.body_python_h[2] + return hx + + def __cpp_MoveMesh_hx(self, x, t): + return self.__cpp_MoveMesh_h(x, t)[0] + + def __cpp_MoveMesh_hy(self, x, t): + return self.__cpp_MoveMesh_h(x, t)[1] + + def __cpp_MoveMesh_hz(self, x, t): + return self.__cpp_MoveMesh_h(x, t)[2] + + def setUnsteadyTwoPhaseVelocityInlet(self, wave, smoothing, vert_axis=None,orientation=None, + wind_speed=None, vof_air=1., vof_water=0.,kInflow=1e-30, dInflow = 1e-10): + """ + Imposes a velocity profile on the fluid with input wave and wind + conditions. + + Parameters + ---------- + wave: proteus.WaveTools + class describing a wave (from proteus.WaveTools) + smoothing: float + smoothing distance (typically 3.*he) + vert_axis: Optional[int] + index of vertical position vector (x:0, y:1, z:2), must always be + aligned with gravity. If not set, will be 1 in 2D (y), 2 in 3D (z). + wind_speed: Optional[array_like] + speed of air phase + vof_air: Optional[float] + VOF value of air (default is 1.) + vof_water: Optional[float] + VOF value of water (default is 0.) + + Below the sea water level: fluid velocity to wave speed. + Above the sea water level: fluid velocity set to wind speed + (with smoothing). + """ + self.reset() + if vert_axis is None: + vert_axis = self.nd - 1 + if wind_speed is None: + wind_speed = np.zeros(3) + if orientation is not None: + b_or = orientation + else: + b_or=self._b_or + assert b_or is not None, "ERROR: Boundary orientation for Unsteady flow inlet is not defined" + self.waves = __cppClass_WavesCharacteristics(waves=wave, vert_axis=vert_axis, b_or=b_or, + wind_speed=wind_speed, smoothing=smoothing, vof_water=vof_water, vof_air=vof_air) + + self.u_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_u_dirichlet(x, t) + self.v_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_v_dirichlet(x, t) + self.w_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_w_dirichlet(x, t) + self.phi_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_phi_dirichlet(x, t) + self.vof_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_vof_dirichlet(x, t) + self.p_advective.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_p_advective(x, t) + self.pInc_advective.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_p_advective(x, t) + + self.pInc_diffusive.setConstantBC(0.0) + self.pInit_advective.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_p_advective(x, t)#setConstantBC(0.0) + self.vos_dirichlet.setConstantBC(0.0) + self.us_dirichlet.setConstantBC(0.0) + self.vs_dirichlet.setConstantBC(0.0) + self.ws_dirichlet.setConstantBC(0.0) + self.k_dirichlet.setConstantBC(kInflow) + self.dissipation_dirichlet.setConstantBC(dInflow) + self.dissipation_diffusive.setConstantBC(0.) + self.k_diffusive.setConstantBC(0.0) + + def __cpp_UnsteadyTwoPhaseVelocityInlet_u_dirichlet(self, x, t): + cython.declare(xx=cython.double[3]) + xx[0] = x[0] + xx[1] = x[1] + xx[2] = x[2] + return self.waves.__cpp_calculate_velocity(xx, t)[0] + + def __cpp_UnsteadyTwoPhaseVelocityInlet_v_dirichlet(self, x, t): + cython.declare(xx=cython.double[3]) + xx[0] = x[0] + xx[1] = x[1] + xx[2] = x[2] + return self.waves.__cpp_calculate_velocity(xx, t)[1] + + def __cpp_UnsteadyTwoPhaseVelocityInlet_w_dirichlet(self, x, t): + cython.declare(xx=cython.double[3]) + xx[0] = x[0] + xx[1] = x[1] + xx[2] = x[2] + return self.waves.__cpp_calculate_velocity(xx, t)[2] + + def __cpp_UnsteadyTwoPhaseVelocityInlet_p_advective(self, x, t): + cython.declare(xx=cython.double[3]) + xx[0] = x[0] + xx[1] = x[1] + xx[2] = x[2] + return self.waves.__cpp_calculate_pressure(xx, t) + + def __cpp_UnsteadyTwoPhaseVelocityInlet_phi_dirichlet(self, x, t): + cython.declare(xx=cython.double[3]) + xx[0] = x[0] + xx[1] = x[1] + xx[2] = x[2] + return self.waves.__cpp_calculate_phi(xx, t) + + def __cpp_UnsteadyTwoPhaseVelocityInlet_vof_dirichlet(self, x, t): + cython.declare(xx=cython.double[3]) + xx[0] = x[0] + xx[1] = x[1] + xx[2] = x[2] + return self.waves.__cpp_calculate_vof(xx, t) + + def setTwoPhaseVelocityInlet(self, U, waterLevel, smoothing, Uwind=None, + vert_axis=None, air=1., water=0., + kInflow=None, dissipationInflow=None, + kInflowAir=None, dissipationInflowAir=None): + """ + Imposes a velocity profile lower than the sea level and an open + boundary for higher than the sealevel. + + Parameters + ---------- + U: list. + Velocity vector at the global system. + Uwind: list. + Air velocity vector at the global system. + waterLevel: float. + water level at global coordinate system. + smoothing: float. + range within smoothing function is valid. + [3.0 times mesh element size can be a good value] + vert_axis: optional. + index of vertical in position vector, must always be + aligned with gravity, by default set to 1]. + air: optional. + Volume fraction for air (1.0 by default). + water: optional. + Volume fraction for water (0.0 by default). + kInflow: float (optional). + K inflow value for turbulent model imposed at the boundary. + dissipationInflow: float (optional). + Dissipation inflow value for turbulent model imposed at the boundary. + kInflowAir: float (optional). + Air K inflow value for turbulent model imposed at the boundary. + dissipationInflowAir: float (optional). + Air dissipation inflow value for turbulent model imposed at the boundary. + + Notes + ----- + Below the seawater level, the condition returns the _dirichlet and + p_advective condition according to the inflow velocity. + Above the sea water level, the condition returns the gravity as zero, + and sets _dirichlet condition to zero, only if there is a zero inflow + velocity component. + (!) This condition is best used for boundaries and gravity aligned with + one of the main axes. + """ + self.reset() + self.BC_type = 'TwoPhaseVelocityInlet' + + if vert_axis is None: + vert_axis = self.nd - 1 + if Uwind is None: + Uwind = np.zeros(3) + + U = np.array(U) + Uwind = np.array(Uwind) + + def get_inlet_ux_dirichlet(i): + def ux_dirichlet(x, t, n=None): + phi = x[vert_axis] - waterLevel + if phi <= 0.: + H = 0.0 + elif 0 < phi <= smoothing: + H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(smoothing/2., phi - smoothing/2.) + else: + H = 1.0 + u = H * Uwind[i] + (1 - H) * U[i] + return u + return ux_dirichlet + + def inlet_phi_dirichlet(x, t, n=None): + phi = x[vert_axis] - waterLevel + return phi + + def inlet_vof_dirichlet(x, t, n=None): + phi = x[vert_axis] - waterLevel + if phi >= smoothing: + H = 1. + elif smoothing > 0 and -smoothing < phi < smoothing: + H = smoothedHeaviside(smoothing, phi) + elif phi <= -smoothing: + H = 0. + vof = H * air + (1 - H) * water + return vof + + def inlet_p_advective(x, t, n=None): + b_or = self._b_or + phi = x[vert_axis] - waterLevel + if phi <= 0.: + H = 0.0 + elif 0 < phi <= smoothing: + H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(smoothing/2., phi - smoothing/2.) + else: + H = 1.0 + u = H * Uwind + (1 - H) * U + # This is the normal velocity, based on the inwards boundary + # orientation -b_or + u_p = np.sum(u * np.abs(b_or)) + return -u_p + + def inlet_k_dirichlet(x, t, n=None): + phi = x[vert_axis] - waterLevel + if phi <= 0.: + H = 0.0 + elif 0 < phi <= smoothing: + H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(smoothing/2., phi - smoothing/2.) + else: + H = 1.0 + return H * kInflowAir + (1 - H) * kInflow + + def inlet_dissipation_dirichlet(x, t, n=None): + phi = x[vert_axis] - waterLevel + if phi <= 0.: + H = 0.0 + elif 0 < phi <= smoothing: + H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(smoothing/2., phi - smoothing/2.) + else: + H = 1.0 + return H * dissipationInflowAir + (1 - H) * dissipationInflow + + self.u_dirichlet.uOfXT = get_inlet_ux_dirichlet(0) + self.v_dirichlet.uOfXT = get_inlet_ux_dirichlet(1) + self.w_dirichlet.uOfXT = get_inlet_ux_dirichlet(2) + self.phi_dirichlet.uOfXT = inlet_phi_dirichlet + self.vof_dirichlet.uOfXT = inlet_vof_dirichlet + self.p_advective.uOfXT = inlet_p_advective + if kInflow is not None: + self.k_dirichlet.uOfXT = inlet_k_dirichlet + self.k_advective.resetBC() + self.k_diffusive.resetBC() + if dissipationInflow is not None: + self.dissipation_dirichlet.uOfXT = inlet_dissipation_dirichlet + self.dissipation_advective.resetBC() + self.dissipation_diffusive.resetBC() + + def setHydrostaticPressureOutletWithDepth(self, seaLevel, rhoUp, rhoDown, g, + refLevel, smoothing, orientation=None,U=None, Uwind=None, + pRef=0.0, vert_axis=None, + air=1.0, water=0.0, + kInflow=None, dissipationInflow=None, + kInflowAir=None, dissipationInflowAir=None): + """ + Returns the pressure and vof profile based on the known depth. + If the boundary is aligned with one of the main axes, sets the tangential + velocity components to zero as well. + (!) This condition is best used for boundaries and gravity aligned with + one of the main axes. + + Parameters + ---------- + rhoUp: Phase density of the upper part. + rhoDown: Phase density of the lower part. + g: Gravitational acceleration vector. + refLevel: Level at which pressure = pRef. + pRef: Reference value for the pressure at x[vert_axis]=refLevel, by default set to 0. + vert_axis: index of vertical in position vector, must always be aligned with gravity, by default set to 1. + """ + self.reset() + + if vert_axis is None: + vert_axis = self.nd - 1 + + def hydrostaticPressureOutletWithDepth_p_dirichlet(x, t , n=None): + p_top = pRef + phi_top = refLevel - seaLevel + phi = x[vert_axis] - seaLevel + return p_top - g[vert_axis] * (rhoDown * (phi_top - phi) + + (rhoUp - rhoDown) * + (smoothedHeaviside_integral(smoothing, phi_top) + - + smoothedHeaviside_integral(smoothing, phi))) + + def hydrostaticPressureOutletWithDepth_phi_dirichlet(x, t, n=None): + phi = x[vert_axis] - seaLevel + return phi + + def hydrostaticPressureOutletWithDepth_vof_dirichlet(x, t, n=None): + phi = x[vert_axis] - seaLevel + if phi >= smoothing: + H = 1. + elif smoothing > 0 and -smoothing < phi < smoothing: + H = smoothedHeaviside(smoothing, phi) + elif phi <= -smoothing: + H = 0. + return H * air + (1 - H) * water + + def inlet_k_dirichlet(x, t, n=None): + phi = x[vert_axis] - seaLevel + if phi <= 0.: + H = 0.0 + elif 0 < phi <= smoothing: + H = smoothedHeaviside(smoothing/2., phi - smoothing/2.) + else: + H = 1.0 + return H * kInflowAir + (1 - H) * kInflow + + def inlet_dissipation_dirichlet(x, t, n=None): + phi = x[vert_axis] - seaLevel + if phi <= 0.: + H = 0.0 + elif 0 < phi <= smoothing: + H = smoothedHeaviside(smoothing/2., phi - smoothing/2.) + else: + H = 1.0 + return H * dissipationInflowAir + (1 - H) * dissipationInflow + + if orientation is not None: + b_or = orientation + else: + b_or=self._b_or + assert b_or is not None, "ERROR: Boundary orientation for Hydrostatic flow outlet is not defined" + if b_or[0] == 1. or b_or[0] == -1.: + self.v_dirichlet.setConstantBC(0.) + self.w_dirichlet.setConstantBC(0.) + self.u_diffusive.setConstantBC(0.) + if b_or[1] == 1. or b_or[1] == -1.: + self.u_dirichlet.setConstantBC(0.) + self.w_dirichlet.setConstantBC(0.) + self.v_diffusive.setConstantBC(0.) + if b_or[2] == 1. or b_or[2] == -1.: + self.u_dirichlet.setConstantBC(0.) + self.v_dirichlet.setConstantBC(0.) + self.w_diffusive.setConstantBC(0.) +#sediment + self.us_advective.setConstantBC(0.) + self.vs_advective.setConstantBC(0.) + self.ws_advective.setConstantBC(0.) + self.vos_advective.setConstantBC(0.) + self.us_diffusive.setConstantBC(0.) + self.vs_diffusive.setConstantBC(0.) +#end sediment + self.p_dirichlet.uOfXT = hydrostaticPressureOutletWithDepth_p_dirichlet + self.pInit_dirichlet.uOfXT = hydrostaticPressureOutletWithDepth_p_dirichlet + self.pInc_dirichlet.setConstantBC(0.) + self.phi_dirichlet.uOfXT = hydrostaticPressureOutletWithDepth_phi_dirichlet + self.vof_dirichlet.uOfXT = hydrostaticPressureOutletWithDepth_vof_dirichlet + self.k_diffusive.setConstantBC(0.) + self.dissipation_diffusive.setConstantBC(0.) + if U is not None: + def get_inlet_ux_dirichlet(i): + def ux_dirichlet(x, t, n=None): + phi = x[vert_axis] - seaLevel + if phi <= 0.: + H = 0.0 + elif 0 < phi <= smoothing: + H = smoothedHeaviside(smoothing/2., phi - smoothing/2.) + else: + H = 1.0 + return H * Uwind[i] + (1 - H) * U[i] + return ux_dirichlet + + if Uwind is None: + Uwind = np.zeros(3) + U = np.array(U) + Uwind = np.array(Uwind) + self.u_dirichlet.uOfXT = get_inlet_ux_dirichlet(0) + self.v_dirichlet.uOfXT = get_inlet_ux_dirichlet(1) + self.w_dirichlet.uOfXT = get_inlet_ux_dirichlet(2) + self.u_diffusive.resetBC() + + if kInflow is not None: + self.k_dirichlet.uOfXT = inlet_k_dirichlet + self.k_advective.resetBC() + self.k_diffusive.resetBC() + if dissipationInflow is not None: + self.dissipation_dirichlet.uOfXT = inlet_dissipation_dirichlet + self.dissipation_advective.resetBC() + self.dissipation_diffusive.resetBC() + +# for regions + +class RelaxationZone: + """ + Holds information about a relaxation zone (wave generation/absorption + or porous zone) + + Parameters + ---------- + zone_type: string + type of zone, can be set to 'absorption', 'generation', or 'porous' + center: array_like + coordinates of center of the zone + orientation: array_like + orientation for absorption/generation zones: from boundary to tank + epsFact_porous: float + half the zone length + waves: Optional[proteus.WaveTools] + class instance of a wave from proteus.WaveTools (must be set for + generation zone) + shape: Optional[proteus.SpatialTools.Shape] + shape class instance containing region + dragAlpha: Optional[float] + parameter for porous zones (default: 0.5/1.005e-6) + dragBeta: Optional[float] + parameter for porous zones (default: 0.) + porosity: Optional[float] + parameter for porous zone (default: 1.) + vert_axis: Optional[int] + index of vertical position vector (x:0, y:1, z:2), must always be + aligned with gravity. If not set, will be 1 in 2D (y), 2 in 3D (z). + smoothing: Optional[float] + smoothing distance from the free surface (usually 3*he) + vof_water: Optional[int] + VOF value of water (default: 0) + vof_air: Optional[int] + VOF value of air (default: 1) + """ + + def __cinit__(self, zone_type, center, orientation, epsFact_porous, + waves=None, shape=None, wind_speed=np.array([0., 0., 0.]), + dragAlpha=0.5/1.005e-6, dragBeta=0., porosity=1., vert_axis=None, smoothing=0., + vof_water=0., vof_air=1.): + self.Shape = shape + self.nd = self.Shape.Domain.nd + self.zone_type = zone_type + self.center = center + self.orientation = orientation + if vert_axis is None: + vert_axis = self.Shape.Domain.nd - 1 + self.vert_axis = vert_axis + if waves is not None: + self.waves = __cppClass_WavesCharacteristics(waves=waves, wind_speed=wind_speed, vert_axis=vert_axis, + smoothing=smoothing, vof_water=vof_water, vof_air=vof_air) + self.epsFact_porous = epsFact_porous + self.dragAlpha = dragAlpha + self.dragBeta = dragBeta + self.porosity = porosity + self.zero_vel = np.zeros(3) + + def calculate_init(self): + if self.zone_type == 'generation': + # self.u = &self.waves.u + # self.eta = &self.waves.eta + self.uu = self.__cpp_calculate_vel_wave + self.phi = self.__cpp_calculate_phi_porous_sponge + elif self.zone_type == 'absorption': + self.uu = self.__cpp_calculate_vel_zero + self.phi = self.__cpp_calculate_phi_porous_sponge + elif self.zone_type == 'porous': + self.uu = self.__cpp_calculate_vel_zero + self.phi = self.__cpp_calculate_phi_porous + + def calculate_phi(self, x): + return self.phi(self, x) + + def __cpp_calculate_phi_porous_sponge(self, x): + """ + Used for RelaxationZone only + """ + cython.declare(d=cython.double[3], o=cython.double[3]) + d[0] = self.center[0] - x[0] + d[1] = self.center[1] - x[1] + o[0] = self.orientation[0] + o[1] = self.orientation[1] + if self.nd > 2: + d[2] = self.center[2] - x[2] + o[2] = self.orientation[2] + else: + d[2] = 0 + o[2] = 0 + phi = o[0] * d[0] + o[1] * d[1] + o[2] * d[2] + return phi + + def __cpp_calculate_phi_porous(self, x): + IN_POROUS_ZONE=-10000.0 + return IN_POROUS_ZONE + + def calculate_vel(self, x, t): + cython.declare(d=cython.double[3], o=cython.double[3]) + d[0] = x[0] + d[1] = x[1] + d[2] = x[2] + return self.uu(self, d, t) + + def calculate_phi_python(self, x): + cython.declare(xx=cython.double[3], tt=cython.double) + xx[0] = x[0] + xx[1] = x[1] + xx[2] = x[2] + ph = self.phi(self, xx) + return ph + + def calculate_vel_python(self, x, t, n=None): + cython.declare(xx=cython.double[3], tt=cython.double) + xx[0] = x[0] + xx[1] = x[1] + xx[2] = x[2] + tt = t + return self.uu(self, xx, tt) + + def __cpp_calculate_vel_zero(self, x, t): + return self.zero_vel + + def __cpp_calculate_vel_wave(self, x, t): + return self.waves.__cpp_calculate_velocity(x, t) + + +class RelaxationZoneWaveGenerator: + """ + Prescribe a velocity penalty scaling in a material zone via a + Darcy-Forchheimer penalty + + Parameters + ---------- + zones: dict + dictionary with key as the region flag and values as a RelaxationZone + class + nd: int + number of dimensions of domain + """ + + def __init__(self, zones, nd): + self.zones = zones + self.nd = nd + + def attachModel(self, model, ar): + self.model = model + self.ar = ar + return self + + def attachAuxiliaryVariables(self, avDict): + pass + + def calculate_init(self): + max_key = 0 + for key, zone in list(self.zones.items()): + zone.calculate_init() + if key > max_key: + max_key = key + self.max_flag = max_key + self.zones_array = np.empty(self.max_flag + 1, dtype=RelaxationZone) + for key, zone in list(self.zones.items()): + self.zones_array[key] = zone + + def calculate(self): + self.__cpp_iterate() + + def __cpp_iterate(self): + nl = len(self.model.levelModelList) + for l in range(nl): # usually only 1 + # initialisation of variables before costly loop + m = self.model.levelModelList[l] + nE = m.coefficients.q_phi.shape[0] + nk = m.coefficients.q_phi.shape[1] + t = m.timeIntegration.t + qx = m.q['x'] + q_phi_porous = m.coefficients.q_phi_porous + q_velocity_porous = m.coefficients.q_velocity_porous + mTypes = m.mesh.elementMaterialTypes + # costly loop + for eN in range(nE): + mType = mTypes[eN] + if mType <= self.max_flag: + zone = self.zones_array[mType] + if zone is not None: + for k in range(nk): + x[0] = qx[eN, k, 0] + x[1] = qx[eN, k, 1] + x[2] = qx[eN, k, 2] + phi = zone.calculate_phi(x) + q_phi_porous[eN, k] = phi + u = zone.calculate_vel(x, t) + q_velocity_porous[eN, k, 0] = u[0] + q_velocity_porous[eN, k, 1] = u[1] + if self.nd > 2: + q_velocity_porous[eN, k, 2] = u[2] + m.q['phi_porous'] = q_phi_porous + m.q['velocity_porous'] = q_velocity_porous + + +class __cppClass_WavesCharacteristics: + """ + Class holding information from WaveTools waves and cnvering it to + boundary conditions to use for relaxation zones and wave inlet. + This class is created automatically when passing WaveTools class + instances to a relaxation zone or wave inlet BC. + + Parameters + ---------- + wave: proteus.WaveTools + class describing a wave (from proteus.WaveTools) + vert_axis: int + index of vertical position vector (x:0, y:1, z:2), must always be + aligned with gravity. If not set, will be 1 in 2D (y), 2 in 3D (z). + wind_speed: Optional[array_like] + speed of air phase + b_or: Optional[array_like] + boundary orientation. Necessary for pressure calculations. Used + for boundary conditions but not in relaxation zones. + smoothing: Optional[float] + smoothing distance from the free surface (usually 3*he) + vof_water: Optional[float] + VOF value of water (default: 0) + vof_air: Optional[float] + VOF value of air (default: 1) + """ + + def __init__(self, waves, vert_axis, wind_speed=None, b_or=None, + smoothing=0., vof_water=0., vof_air=1.): + self.WT = waves # wavetools wave + self.vert_axis = vert_axis + self.zero_vel = np.zeros(3) + self._b_or = b_or + self.smoothing = smoothing + self.vof_air = vof_air + self.vof_water = vof_water + if wind_speed is None: + self.wind_speed = self.zero_vel + else: + self.wind_speed = wind_speed + + def __cpp_calculate_velocity(self, x, t): + # u is returned as a memoryview (pxd: cdef double[:]); a C array declared here lives on this + # function's stack and the view dangles once it returns. Unnoticed until the module was built + # with line tracing, which reuses that stack: the caller then read 0.0. + u = np.empty(3) + cython.declare(xx=cython.double[3]) + cython.declare(x_max=cython.double[3]) + xx[0] = x[0] + xx[1] = x[1] + xx[2] = x[2] + phi = self.__cpp_calculate_phi(x, t) + if phi <= 0.: + # no smoothing below mwl, or wave peak could get chopped off + H = 0 + waterSpeed = self.WT.u(xx, t) + elif 0 < phi <= self.smoothing: + # smoothing on half the range of VOF (above wave crest) + H = smoothedHeaviside(self.smoothing/2., phi - self.smoothing/2.) + # use max velocity of wave for water + x_max[0] = x[0] + x_max[1] = x[1] + x_max[2] = x[2] + x_max[self.vert_axis] = x[self.vert_axis] - phi + waterSpeed = self.WT.u(x_max, t) + else: + H = 1. + waterSpeed = self.zero_vel + u[0] = H * self.wind_speed[0] + (1 - H) * waterSpeed[0] + u[1] = H * self.wind_speed[1] + (1 - H) * waterSpeed[1] + u[2] = H * self.wind_speed[2] + (1 - H) * waterSpeed[2] + return u + + def __cpp_calculate_pressure(self, x, t): + # This is the normal velocity, based on the outwards boundary + # orientation b_or + # needs to be equal to -ux_dirichlet + ux = self.__cpp_calculate_velocity(x, t) + b0, b1, b2 = self._b_or[0], self._b_or[1], self._b_or[2] + u0, u1, u2 = ux[0], ux[1], ux[2] + return b0 * u0 + b1 * u1 + b2 * u2 + + def __cpp_calculate_phi(self, x, t): + cython.declare(xx=cython.double[3]) + xx[0] = x[0] + xx[1] = x[1] + xx[2] = x[2] + level = self.WT.mwl + self.WT.eta(xx, t) + return x[self.vert_axis] - level + + def __cpp_calculate_vof(self, x, t): + phi = self.__cpp_calculate_phi(x, t) + H = self.__cpp_calculate_smoothing_H(phi) + return H + + def __cpp_calculate_smoothing_H(self, phi): + if phi >= self.smoothing: + H = 1. + elif self.smoothing > 0 and -self.smoothing < phi < self.smoothing: + H = smoothedHeaviside(self.smoothing, phi) + elif phi <= -self.smoothing: + H = 0. + return H + + +def __x_to_cpp(x): + cython.declare(xx=double[3]) + xx[0] = x[0] + xx[1] = x[1] + xx[2] = x[2] + return xx + + +class WallFunctions(AuxiliaryVariables.AV_base): + """ + Auxiliary variable used to calculate attributes of an associated shape + class instance acting as a wall. + """ + + def __init__(self, turbModel, kWall, Y, Yplus, U0, nu=1.004e-6, Cmu=0.09, K=0.41, B=5.57): + """ + Sets turbulent boundaries for wall treatment. + Calculation made on nodes outside the viscous sublayer and based + on assumption on the velocity profile close to the wall in order to + impose the wall shear stress. + + - k is assumed to be constant in the fully turbulent region close to the wall, + in this way kv = kp. + - dissipation is calculated. + + Parameters + ---------- + turbModel: string. + 'ke' or 'kw', for switching between k-epsilon or k-omega models. + kWall: object. + Class kWall object for extracting kappa from the model. + Y: float. + size of the nearest element to the boundary. + Yplus: float. + size of the nearest element to the boundary in terms of wall unit. + U0: array_like. + stream velocity. + nu: float. + fluid viscosity. + Cmu: float. + turbulent viscosity constant. + K: float. + von Karman coefficient. + B: float. + roughness coefficient for walls. + """ + self.turbModel = turbModel + self.Y = Y + self.Yplus = Yplus + self.U0 = U0 + self.nu = nu + self.Cmu = Cmu + self.K = K + self.B = B + # initialise variables + self.Ubound = np.zeros(3) + self.kappa = 1e-10 + self.tau_rho = 0. + self.utAbs = 1e-10 + self.ut = np.zeros(3) + self.x = np.zeros(3) + self.t = 0. + self.model = None + self.xi, self.element, self.rank = None, None, None + self.kWall = kWall + + def attachModel(self, model, ar): + """ + Attaches model to auxiliary variable + """ + self.model = model + self.ar = ar + self.nd = model.levelModelList[0].nSpace_global + self.Closure_0_model = model.levelModelList[0].coefficients.Closure_0_model + self.Closure_1_model = model.levelModelList[0].coefficients.Closure_1_model + return self + + def attachAuxiliaryVariables(self, avDict): + pass + + def calculate_init(self): + pass + + def calculate(self): + pass + + def getLocalNearestNode(self, coords, kdtree): + """ + Finds nearest node to coordinates (local) + Parameters + ---------- + coords: array_like + coordinates from which to find nearest node + kdtree: scipy.spatial.cKDTree + instance of scipy kdtree + Returns + ------- + node: int + nearest node index + distance: float + distance to nearest node + """ + # determine local nearest node distance + distance, node = kdtree.query(coords) + return node, distance + + def getLocalElement(self, femSpace, coords, node): + """ + Given coordinates and its nearest node, determine if it is on a + local element. + Parameters + ---------- + femSpace: object + finite element space + coords: array_like + coordinates from which to element + node: int + nearest node index + Returns + ------- + eN: int or None + local index of element (None if not found) + """ + patchBoundaryNodes = set() + checkedElements = [] + # nodeElementOffsets give the indices to get the elements sharing the node + statem1 = node + 1 < len(femSpace.mesh.nodeElementOffsets) + for eOffset in range(femSpace.mesh.nodeElementOffsets[node], femSpace.mesh.nodeElementOffsets[node + 1]): + eN = femSpace.mesh.nodeElementsArray[eOffset] + checkedElements.append(eN) + # union of set + patchBoundaryNodes |= set(femSpace.mesh.elementNodesArray[eN]) + # evaluate the inverse map for element eN (global to local) + xi = femSpace.elementMaps.getInverseValue(eN, coords) + #J = femSpace.elementMaps.getJacobianValues(eN, ) + # query whether xi lies within the reference element + if femSpace.elementMaps.referenceElement.onElement(xi): + return eN + # extra loop if case coords is in neighbour element + for node in patchBoundaryNodes: + for eOffset in range(femSpace.mesh.nodeElementOffsets[node], femSpace.mesh.nodeElementOffsets[node + 1]): + eN = femSpace.mesh.nodeElementsArray[eOffset] + if eN not in checkedElements: + checkedElements.append(eN) + # evaluate the inverse map for element eN + xi = femSpace.elementMaps.getInverseValue(eN, coords) + # query whether xi lies within the reference element + if femSpace.elementMaps.referenceElement.onElement(xi): + return eN + # no elements found + return None + + def findElementContainingCoords(self, coords): + """ + Given global coordinates of a point, returns + local coordinates and the owner of the point. + + Parameters + ---------- + coords: array_like + global coordinates to look for + Returns + ------- + xi: + local coordinates + eN: int + (local) element number + rank: int + processor rank containing element + """ + comm = Comm.get().comm.tompi4py() + xi = owning_proc = element = rank = None # initialised as None + self.xi, self.element, self.rank = xi, element, rank + # get nearest node on each processor + # comm.barrier() + self.u = self.model.levelModelList[0].u + self.femSpace_velocity = self.u[1].femSpace + nodes_kdtree = spatial.cKDTree(self.model.levelModelList[0].mesh.nodeArray) + nearest_node, nearest_node_distance = self.getLocalNearestNode(coords, nodes_kdtree) + # look for element containing coords on each processor (if it exists) + local_element = self.getLocalElement(self.femSpace_velocity, coords, nearest_node) + if local_element: + xi = self.femSpace_velocity.elementMaps.getInverseValue(local_element, coords) + rank = comm.rank + else: + xi = None + rank = None + #rank = comm.allreduce(rank, op=MPI.MAX) + return xi, local_element, rank + + def getFluidVelocityLocalCoords(self, xi, element, rank): + """ + Given local details, returns velocity field at those coordinates. + + Parameters + ---------- + xi: + local coords in element + element: int + element number (local to processor 'rank') + rank: int + rank of processor owning the element + """ + comm = Comm.get().comm.tompi4py() + if comm.rank == rank: + u = self.u[1].getValue(element, xi) + v = self.u[2].getValue(element, xi) + if self.nd > 2: + w = self.u[3].getValue(element, xi) + if self.nd <= 2: + w = 0. + else: + u = v = w = None + return u, v, w + + def setYplusNormalDirection(self, x, t,n, relax=1.0): + """ + Return the point at y+ distance in normal + direction from the boundary. + """ + # near wall point + if len(n) < 3: + nP = (relax * self.Y * (-n[:2])) + x[:2] + else: + nP = (relax * self.Y * (-n)) + x + return nP + + def extractVelocity(self, x, t, n): + """ + Extraction of the velocity at y+ distance from the boundary. + """ + coords = self.setYplusNormalDirection(x, t, n) + xi, element, rank = self.findElementContainingCoords(coords) + if rank is not None: + u, v, w = self.getFluidVelocityLocalCoords(xi, element, rank) + else: + relax = 0.5 + while rank is None: + coords_relax = self.setYplusNormalDirection(x, t, n ,relax) + xi, element, rank = self.findElementContainingCoords(coords_relax) + relax *= 0.5 + # just use the element containing the boundary quadrature point to interpolate to the y+ point + u, v, w = self.getFluidVelocityLocalCoords(self.femSpace_velocity.elementMaps.getInverseValue(element, coords), + element, + rank) + self.xi, self.element, self.rank = xi, element, rank + return u, v, w + + def tangentialVelocity(self, x, t, n, uInit=None): + """ + Given the velocity, calculates its + tangential component to the wall. + + Parameters + ---------- + uInit: True/False. + Switch for initializing the module. + True only during the first time step. + """ + n=np.pad(n,(0,3-n.shape[0]),mode='constant',constant_values=0.0) + if uInit is True or self.model is None: + u0, u1, u2 = self.U0 + else: + u0, u1, u2 = self.extractVelocity(x, t, n) + self.meanV = np.array([u0, u1, u2]) + # projection of u vector over an ortoganal plane to n + self.tanU = self.meanV - self.meanV * (n**2) + # tangential unit vector + self.tV = self.tanU/np.sqrt(np.sum(self.tanU**2)) + + def getVariables(self, x, t): + """ + Calculates velocity, gradient of the velocity and + kappa according with wall functions theory (see + S. B. Pope pg 442-443). + """ + comm = Comm.get().comm.tompi4py() + # Extraction of kappa + self.kappa = self.kWall.getKappa(x, t, self.xi, self.element, self.rank) + # Calculation of nominal friction velocity based on kappa + self.utStar = (self.kappa**0.5) * (self.Cmu**0.25) + self.Ystar = self.Y * self.utStar / self.nu + # Absolute value of the extracted velocity at y+ location. + Up = np.sqrt(np.sum(self.tanU**2)) + # viscous layer + if self.Ystar < 11.225: + self.Ustar = self.Ystar + self.uDir = (self.utStar*self.Ystar) * self.tV + self.gradU = ( (self.utStar**2)/self.nu ) * self.tV + # log-law layer + else: + # Wall function theory from S.B. Pope, page 442-443 + E = np.exp(self.B * self.K) + self.Ustar = self.utStar * np.log(E * self.Ystar) / self.K + self.utAbs = self.utStar * np.sqrt(Up/self.Ustar) + # Velocity vector and velocity gradient multiplied by the tangential vector unit + self.gradU = (self.utAbs/(self.K*self.Y)) * self.tV + # Linear approximation for velocity at the wall (using the gradU of the logLaw) + self.uDir = self.tanU - (self.gradU * self.Y) + + def get_u_dirichlet(self, x, t, n): + if t > 0.: + uInit = False + else: + uInit = True + self.tangentialVelocity(x, t, n, uInit) + self.getVariables(x, t) + return self.uDir[0] + + def get_v_dirichlet(self, x, t, n): + if t > 0.: + uInit = False + else: + uInit = True + self.tangentialVelocity(x, t, n, uInit) + self.getVariables(x, t) + return self.uDir[1] + + def get_w_dirichlet(self, x, t, n): + if t > 0.: + uInit = False + else: + uInit = True + self.tangentialVelocity(x, t, n, uInit) + self.getVariables(x, t) + return self.uDir[2] + + def get_k_dirichlet(self, x, t, n): + if t > 0.: + uInit = False + else: + uInit = True + self.tangentialVelocity(x, t,n, uInit) + self.getVariables(x, t) + return self.kappa + + def get_dissipation_dirichlet(self, x, t, n): + if t > 0.: + uInit = False + else: + uInit = True + self.tangentialVelocity(x, t, n, uInit) + self.getVariables(x, t) + d = 0. + if self.turbModel == 'ke': + d = (self.utStar**3)/(self.K*self.Y) + elif self.turbModel == 'kw' and self.kappa > 0.: + d = np.sqrt(self.kappa)/(self.K*self.Y*(self.Cmu**0.25)) + return d + + def get_u_diffusive(self, x, t, n): + if t > 0.: + uInit = False + else: + uInit = True + self.tangentialVelocity(x, t, n, uInit) + self.getVariables(x, t) + gradU = self.gradU[0] + return gradU + + def get_v_diffusive(self, x, t, n ): + if t > 0.: + uInit = False + else: + uInit = True + self.tangentialVelocity(x, t, n, uInit) + self.getVariables(x, t) + gradU = self.gradU[1] + return gradU + + def get_w_diffusive(self, x, t, n): + if t > 0.: + uInit = False + else: + uInit = True + self.tangentialVelocity(x, t, n, uInit) + self.getVariables(x, t) + gradU = self.gradU[2] + return gradU + + +class kWall(AuxiliaryVariables.AV_base): + """ + Auxiliary variable used to calculate attributes of an associated shape + class instance acting as a wall for the k variable. + """ + + def __init__(self, Y, Yplus, nu=1.004e-6, Cmu=0.09): + """ + Sets turbulent boundaries for wall treatment. + """ + self.kappa = 1e-10 + self.Y = Y + self.Yplus = Yplus + self.nu = nu + self.model = None + self.Cmu = Cmu + + def attachModel(self, model, ar): + """ + Attaches model to auxiliary variable + """ + self.model = model + self.ar = ar + self.nd = model.levelModelList[0].nSpace_global + return self + + def attachAuxiliaryVariables(self, avDict): + pass + + def calculate_init(self): + pass + + def calculate(self): + pass + + def getFluidKappaLocalCoords(self, xi, element, rank): + """ + + Parameters + ---------- + xi: + local coords in element + element: int + element number (local to processor 'rank') + rank: int + rank of processor owning the element + """ + comm = Comm.get().comm.tompi4py() + # solution of the selected model + self.u = self.model.levelModelList[0].u + #self.femSpace_kappa = self.u[0].femSpace + if comm.rank == rank: + kappa = self.u[0].getValue(element, xi) + else: + kappa = None + return kappa + + def kappaNearWall(self, xi, element, rank, kInit=None): + if kInit is True or self.model is None: + self.ut = self.Yplus * self.nu / self.Y + self.kappa = (self.ut**2)/np.sqrt(self.Cmu) + else: + self.kappa = self.getFluidKappaLocalCoords(xi, element, rank) + + def getKappa(self, x, t, xi, element, rank): + if t > 0.: + kInit = False + else: + kInit = True + self.kappaNearWall(xi, element, rank, kInit) + return abs(self.kappa) \ No newline at end of file diff --git a/proteus/DispatchRun.py b/proteus/DispatchRun.py index 327d4553d0..b7df3d3d51 100644 --- a/proteus/DispatchRun.py +++ b/proteus/DispatchRun.py @@ -362,7 +362,7 @@ def _surface_tension(doc, spec, found): raise RealizeError("the surface tension %s must be a number (value: ...) for the realizer" % name) sigma = float(value) if sigma != 0.0: - flow = [m for m in found if m.module == "proteus.mprans.RANS2P"] \ + flow = [m for m in found if m.module == "proteus.kernels.RANS2P"] \ if found is not None else [] if flow: raise RealizeError("the model states surface tension %s = %r, and %s computes none (only RANS3PF's " @@ -515,7 +515,7 @@ def _tank(split, he, name, outdir, comm): """The SpatialTools tank of the domain's box (Tank2D meshed by triangle, Tank3D by TetGen), its sides' BC_RANS set by :func:`tank_sides`, at element size ``he`` (Proteus's convention, ADRProblem.mesh_constraint), or its stored mesh.""" from proteus import Domain - from proteus.mprans import SpatialTools as st + from proteus import SpatialTools as st from proteus.ADRProblem import mesh_constraint sides = tank_sides(split) lower, upper = _box(split) diff --git a/proteus/DispatchTable.py b/proteus/DispatchTable.py index 378c58ff06..23e37756de 100644 --- a/proteus/DispatchTable.py +++ b/proteus/DispatchTable.py @@ -82,7 +82,7 @@ def _rans2p(cell, form, flag): "cell": cell, "family": "two_phase_level_set", "role": "velocity_pressure", - "module": "proteus.mprans.RANS2P", + "module": "proteus.kernels.RANS2P", "name": "rans2p", "formulation": form, "spaces": {"velocity": {"options": [("CG", 1)], "default": ("CG", 1)}, @@ -162,7 +162,7 @@ def _scalar_transport(cell, role, module, name, coefficients, stabilization, ext "cell": "rans3pf_projection", "family": "two_phase_level_set", "role": "velocity", - "module": "proteus.mprans.RANS3PF", + "module": "proteus.kernels.RANS3PF", "name": "rans3p", "formulation": "nonconservative_inertia", "spaces": {"velocity": {"options": [("CG", 2)], "default": ("CG", 2)}}, @@ -205,7 +205,7 @@ def _scalar_transport(cell, role, module, name, coefficients, stabilization, ext "cell": "presinc", "family": "two_phase_level_set", "role": "pressure_increment", - "module": "proteus.mprans.PresInc", + "module": "proteus.kernels.PresInc", "name": "pressureIncrement", "formulation": AS_WRITTEN, "spaces": {"fields": {"options": [("CG", 1)], "default": ("CG", 1)}}, @@ -225,7 +225,7 @@ def _scalar_transport(cell, role, module, name, coefficients, stabilization, ext "cell": "pres", "family": "two_phase_level_set", "role": "pressure", - "module": "proteus.mprans.Pres", + "module": "proteus.kernels.Pres", "name": "pressure", "formulation": AS_WRITTEN, "spaces": {"fields": {"options": [("CG", 1)], "default": ("CG", 1)}}, @@ -244,7 +244,7 @@ def _scalar_transport(cell, role, module, name, coefficients, stabilization, ext "cell": "presinit", "family": "two_phase_level_set", "role": "pressure_spin_up", - "module": "proteus.mprans.PresInit", + "module": "proteus.kernels.PresInit", "name": "pressureInitial", "formulation": AS_WRITTEN, "spaces": {"fields": {"options": [("CG", 1)], "default": ("CG", 1)}}, @@ -260,15 +260,15 @@ def _scalar_transport(cell, role, module, name, coefficients, stabilization, ext "hints": [], }, # ---- two-phase level-set flow: the interface ------------------------------------------------------------- - _scalar_transport("vof", "volume_fraction", "proteus.mprans.VOF", "vof", + _scalar_transport("vof", "volume_fraction", "proteus.kernels.VOF", "vof", {"useMetrics": 1.0}, _SUPG), - _scalar_transport("ncls", "level_set", "proteus.mprans.NCLS", "ncls", + _scalar_transport("ncls", "level_set", "proteus.kernels.NCLS", "ncls", {"useMetrics": 1.0, "checkMass": False}, _SUPG, extra_hints=["checkMass"]), { "cell": "rdls", "family": "two_phase_level_set", "role": "redistancing", - "module": "proteus.mprans.RDLS", + "module": "proteus.kernels.RDLS", "name": "rdls", "formulation": AS_WRITTEN, "spaces": {"fields": {"options": [("CG", 1)], "default": ("CG", 1)}}, @@ -301,7 +301,7 @@ def _scalar_transport(cell, role, module, name, coefficients, stabilization, ext "cell": "mcorr", "family": "two_phase_level_set", "role": "mass_correction", - "module": "proteus.mprans.MCorr", + "module": "proteus.kernels.MCorr", "name": "mcorr", "formulation": AS_WRITTEN, "spaces": {"fields": {"options": [("CG", 1)], "default": ("CG", 1)}}, @@ -332,7 +332,7 @@ def _scalar_transport(cell, role, module, name, coefficients, stabilization, ext "cell": "clsvof", "family": "two_phase_level_set", "role": "level_set_redistanced", - "module": "proteus.mprans.CLSVOF", + "module": "proteus.kernels.CLSVOF", "name": "clsvof", "formulation": AS_WRITTEN, "spaces": {"fields": {"options": [("CG", 1)], "default": ("CG", 1)}}, @@ -365,7 +365,7 @@ def _scalar_transport(cell, role, module, name, coefficients, stabilization, ext "cell": "sw2dcv", "family": "shallow_water", "role": "shallow_water", - "module": "proteus.mprans.SW2DCV", + "module": "proteus.kernels.SW2DCV", "name": "sw", "formulation": AS_WRITTEN, "scheme": {"options": ["graph_viscosity_convex_limiting"], "default": "graph_viscosity_convex_limiting"}, @@ -402,7 +402,7 @@ def _scalar_transport(cell, role, module, name, coefficients, stabilization, ext "cell": "gn_sw2dcv", "family": "dispersive_shallow_water", "role": "shallow_water", - "module": "proteus.mprans.GN_SW2DCV", + "module": "proteus.kernels.GN_SW2DCV", "name": "GN_sw", "formulation": AS_WRITTEN, "scheme": {"options": ["graph_viscosity_convex_limiting"], "default": "graph_viscosity_convex_limiting"}, @@ -453,16 +453,16 @@ def _scalar_transport(cell, role, module, name, coefficients, stabilization, ext #: TwoPhaseFlow's Parameters class for each module: the deck machinery builds each model's p and n from it TWO_PHASE_PARAMETERS = { - "proteus.mprans.RANS2P": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelRANS2P", - "proteus.mprans.RANS3PF": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelRANS3PF", - "proteus.mprans.PresInc": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelPressureIncrement", - "proteus.mprans.Pres": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelPressure", - "proteus.mprans.PresInit": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelPressureInitial", - "proteus.mprans.VOF": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelVOF", - "proteus.mprans.NCLS": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelNCLS", - "proteus.mprans.RDLS": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelRDLS", - "proteus.mprans.MCorr": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelMCorr", - "proteus.mprans.CLSVOF": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelCLSVOF", + "proteus.kernels.RANS2P": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelRANS2P", + "proteus.kernels.RANS3PF": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelRANS3PF", + "proteus.kernels.PresInc": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelPressureIncrement", + "proteus.kernels.Pres": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelPressure", + "proteus.kernels.PresInit": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelPressureInitial", + "proteus.kernels.VOF": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelVOF", + "proteus.kernels.NCLS": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelNCLS", + "proteus.kernels.RDLS": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelRDLS", + "proteus.kernels.MCorr": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelMCorr", + "proteus.kernels.CLSVOF": "proteus.TwoPhaseFlow.utils.Parameters.ParametersModelCLSVOF", } #: a dispatched numerics attribute -> where TwoPhaseFlow's Parameters takes it before it builds the n module. @@ -527,9 +527,9 @@ def _scalar_transport(cell, role, module, name, coefficients, stabilization, ext #: SWFlow's p and n modules for each module (proteus/SWFlow/models, read through Context's mySWFlowProblem, as #: parun --SWEs loads them) and its sw_model switch SHALLOW_WATER_MODELS = { - "proteus.mprans.SW2DCV": {"sw_model": 0, "p": "sw_p", "n": "sw_n"}, + "proteus.kernels.SW2DCV": {"sw_model": 0, "p": "sw_p", "n": "sw_n"}, # the dispersive model by hyperbolic relaxation: six unknowns, h, hu, hv and the auxiliaries h eta, h w, h beta - "proteus.mprans.GN_SW2DCV": {"sw_model": 1, "p": "GN_sw_p", "n": "GN_sw_n"}, + "proteus.kernels.GN_SW2DCV": {"sw_model": 1, "p": "GN_sw_p", "n": "GN_sw_n"}, } #: the dispersive family's auxiliary unknowns, by the role ymf gives them (ymf.dispersion.AUXILIARY_ROLES), in the diff --git a/proteus/FemTools.py b/proteus/FemTools.py index d616f74cd6..f863c1a14c 100644 --- a/proteus/FemTools.py +++ b/proteus/FemTools.py @@ -7576,6 +7576,10 @@ def impose(g): return g if strongFacesOnly: getPeriodicBoundaryConditions = None + #kept for adoptDOF: a dof this rank sees but whose condition came from a face of another rank + self._getPointwiseBoundaryConditions = getPointwiseBoundaryConditions + self._impose = impose + self._exactConversion = exactConversion if (getPointwiseBoundaryConditions is not None and femSpace.strongDirichletConditions and (not weakDirichletConditions or strongFacesOnly)): for eN in range(femSpace.elementMaps.mesh.nElements_global): @@ -7763,6 +7767,32 @@ def impose(g): self.global2freeGlobal_free_dofs[i] = self.global2freeGlobal[dofN]#map each of the unknown DOF's to the free unknown number + def adoptDOF(self,dofN,x,materialFlag): + """Hold the strong condition that another rank's face (or node) flag gives this dof. + + A dof on the rank cut is in a rank's dictionary only if one of that rank's own elements has the + face or node that selects it; ``LinearAlgebraTools.strongDirichletNonAuthorityDofs`` hands the + authority's point and flag to the other ranks that see the dof, so that every copy loads the + same value into ``u`` and zeroes the same column. The setter is called exactly as the + constructor does. Returns whether the dof was adopted (not for exact-conversion spaces, whose + condition is a combination of data at several points, and not where the setter gives nothing). + """ + if self._getPointwiseBoundaryConditions is None or self._exactConversion or dofN in self.DOFBoundaryConditionsDict: + return False + gReturn = self._getPointwiseBoundaryConditions(x,materialFlag) + try: + g = gReturn[0] + except TypeError: + g = gReturn + g = self._impose(g) + if not g: + return False + self.DOFBoundaryConditionsDict[dofN] = g + self.DOFBoundaryPointDict[dofN] = x + self.DOFBoundaryMaterialFlag[dofN] = materialFlag + self.freeDOFSet.discard(dofN) + return True + @staticmethod def exactConversionCondition(femSpace,eN,i,g,materialFlag,getPointwiseBoundaryConditions,impose=lambda g: g): """ diff --git a/proteus/Gauges.py b/proteus/Gauges.py index 522ddad100..5b3e7aa526 100644 --- a/proteus/Gauges.py +++ b/proteus/Gauges.py @@ -1472,7 +1472,9 @@ def gauges_from_ymf(spec, fields=None, tags=None): def _flow_model_with_boundary_integrals(p): - return type(p.coefficients).__module__ in ("proteus.mprans.RANS2P", "proteus.mprans.RANS3PF") + # the module a class reports is its package and its file (proteus.kernels.RANS2P) + package, _, name = type(p.coefficients).__module__.rpartition(".") + return package == "proteus.kernels" and name in ("RANS2P", "RANS3PF") def _variable_names(p): diff --git a/proteus/LinearAlgebraTools.py b/proteus/LinearAlgebraTools.py index c2f7f2085a..6554f039e9 100644 --- a/proteus/LinearAlgebraTools.py +++ b/proteus/LinearAlgebraTools.py @@ -2425,7 +2425,7 @@ def matvec(self,x,y): ParMat_petsc4py = ParMat_mpi4py -def strongDirichletNonAuthorityDofs(model, par_r): +def strongDirichletNonAuthorityDofs(model, par_r, adopt=None): """The local dofs whose strong-Dirichlet row this rank must not contribute. With ``forceStrongConditions`` every rank replaces the rows of the dofs in its own @@ -2442,6 +2442,21 @@ def strongDirichletNonAuthorityDofs(model, par_r): and one ``u - g`` whatever the partition. No Dirichlet value is exchanged, so values that depend on x or t work. Collective, once per level model. + The copies that are not held are not left alone: ``u - g`` is the authority's row, + but every other rank that sees the dof still assembles the PDE rows of its own + equations with its copy of ``u``, and zeroes the column of the dof only if it + holds it. If the owner is not the authority (the cut puts the face that selects + the dof on another rank than the owner's elements) the owner's copy was never + loaded with g and the owner's rows kept the column of an unknown that is not one: + the corner (0, 1) of the unit square (node flag 3, the top face, selected by the + left face of an element on another rank) stayed at 0 instead of 1 and the solution + followed (s = -146.306 against -140.990 serial). So the authority's point and flag + (no value, no function) go to every other rank that sees the dof and has no entry + of its own, and it adopts the condition (``DOFBoundaryConditions.adoptDOF``, which + calls the same setter as the constructor): every copy then loads the same g and + zeroes the same column. Those adoptions are appended to ``adopt`` as + ``(component, local dof number, point, flag)``, and the caller applies them. + Returns the local dof indices to zero (an int array, maybe empty). """ mpi = Comm.get().comm.tompi4py() @@ -2452,17 +2467,27 @@ def strongDirichletNonAuthorityDofs(model, par_r): s2g = numpy.asarray(par_r.subdomain2global) nloc = s2g.shape[0] hold = numpy.zeros(nloc, dtype=bool) + info = {} # local dof -> (point, flag) of what this rank's dictionary says, where it can be handed on + where = {} # local dof -> (component, dof number) for every dof the dictionaries can hold outside = 0 dbcs = model.dirichletConditionsForceDOF if hasattr(dbcs, 'DOFBoundaryConditionsDict'): # one object, not one per component (a single-component model) dbcs = {0: dbcs} for cj, dbc in dbcs.items(): + flags = getattr(dbc, 'DOFBoundaryMaterialFlag', {}) for dofN in dbc.DOFBoundaryConditionsDict: d = model.offset[cj] + model.stride[cj] * dofN if d < nloc: hold[d] = True + if dofN in flags and dofN in dbc.DOFBoundaryPointDict and hasattr(dbc, 'adoptDOF'): + info[d] = (numpy.array(dbc.DOFBoundaryPointDict[dofN], dtype=float), int(flags[dofN])) else: outside += 1 + if hasattr(dbc, 'adoptDOF'): + for dofN in range(model.u[cj].femSpace.dim): + d = model.offset[cj] + model.stride[cj] * dofN + if d < nloc: + where[d] = (cj, dofN) # a layout whose Dirichlet dofs are not subdomain dofs (a serial-periodic numbering) is left as it was; # every rank must agree, so the decision is collective # (and likewise where two local dofs share a global number, as merged periodic dofs do) @@ -2475,7 +2500,7 @@ def strongDirichletNonAuthorityDofs(model, par_r): send = [None] * size for r in numpy.unique(gown): sel = gown == r - send[r] = (s2g[ghosts[sel]], hold[ghosts[sel]]) + send[r] = (s2g[ghosts[sel]], hold[ghosts[sel]], [info.get(int(d)) for d in ghosts[sel]]) recv = mpi.alltoall(send) owned_order = numpy.argsort(s2g[:nproc]) owned_sorted = s2g[:nproc][owned_order] @@ -2484,36 +2509,48 @@ def strongDirichletNonAuthorityDofs(model, par_r): for src, item in enumerate(recv): if item is None: continue - for g, h in zip(*item): - rec = any_holder.setdefault(int(g), [None, None]) # [lowest holder rank among ghosts, owner holds] + for g, h, i in zip(*item): + rec = any_holder.setdefault(int(g), [None, None, None]) # [lowest holder rank among ghosts, its info, ...] if h and (rec[0] is None or src < rec[0]): rec[0] = src + rec[1] = i zero_owned = [] + authority_of = {} for g, rec in any_holder.items(): d = int(owned_order[numpy.searchsorted(owned_sorted, g)]) owner_holds = bool(hold[d]) - rec[1] = owner_holds if rec[0] is None and not owner_holds: continue # nobody holds it authority = rank if owner_holds else rec[0] - rec.append(authority) + auth_info = info.get(d) if owner_holds else rec[1] + authority_of[g] = (authority, auth_info) if authority != rank: zero_owned.append(d) + if adopt is not None and auth_info is not None and not owner_holds and d in where: + adopt.append(where[d] + auth_info) reply = [None] * size for src, item in enumerate(recv): if item is None: continue flags = numpy.zeros(len(item[0]), dtype=bool) + given = [None] * len(item[0]) for k, g in enumerate(item[0]): - rec = any_holder[int(g)] - if len(rec) == 3 and rec[2] != src: - flags[k] = True - reply[src] = flags + if int(g) in authority_of: + authority, auth_info = authority_of[int(g)] + if authority != src: + flags[k] = True + given[k] = auth_info + reply[src] = (flags, given) back = mpi.alltoall(reply) zero_ghost = [] for r in numpy.unique(gown): sel = numpy.where(gown == r)[0] - zero_ghost.extend(ghosts[sel][back[r]].tolist()) + flags, given = back[r] + zero_ghost.extend(ghosts[sel][flags].tolist()) + if adopt is not None: + for dloc, auth_info in zip(ghosts[sel], given): + if auth_info is not None and not hold[dloc] and int(dloc) in where: + adopt.append(where[int(dloc)] + auth_info) # an owned dof that no other rank sees is never shared: nothing to do for it return numpy.array(sorted(zero_owned + zero_ghost), dtype=cmeshTools.INDEX_DTYPE) @@ -2526,7 +2563,13 @@ def attachStrongDirichletAuthority(model, par_r, par_jacobian): return if getattr(par_r, 'proteus2petsc_subdomain', None) is not None or par_r.getBlockSize() != 1: return # permuted or block layouts are not handled - idx = strongDirichletNonAuthorityDofs(model, par_r) + adopt = [] + idx = strongDirichletNonAuthorityDofs(model, par_r, adopt) + dbcs = model.dirichletConditionsForceDOF + if hasattr(dbcs, 'DOFBoundaryConditionsDict'): + dbcs = {0: dbcs} + for cj, dofN, x, flag in adopt: + dbcs[cj].adoptDOF(dofN, x, flag) par_r.dirichlet_nonauthority = idx par_jacobian.dirichlet_nonauthority = idx - logEvent("Strong Dirichlet authority on rank %i: %i local dofs not contributed" % (Comm.get().rank(), idx.shape[0]), level=4) + logEvent("Strong Dirichlet authority on rank %i: %i local dofs not contributed, %i adopted" % (Comm.get().rank(), idx.shape[0], len(adopt)), level=4) diff --git a/proteus/LinearSolvers.py b/proteus/LinearSolvers.py index 7b743d8fbc..20b4d93ee3 100644 --- a/proteus/LinearSolvers.py +++ b/proteus/LinearSolvers.py @@ -16,7 +16,7 @@ from math import * import math from .Profiling import logEvent -from .mprans import cArgumentsDict +from . import cArgumentsDict class LinearSolver(object): """ The base class for linear solvers. @@ -928,7 +928,7 @@ def __init__(self, linear_smoother, pde_type='general_saddle_point'): pde_type : str Currently supports Stokes and navierStokes """ - from proteus.mprans import RANS2P + from proteus.kernels import RANS2P if linear_smoother.PCType!='schur': raise Exception('This function only works with the' \ 'LinearSmoothers for Schur Complements.') @@ -4015,7 +4015,7 @@ class OperatorConstructor_rans2p(OperatorConstructor): Arguments: ---------- - LevelModel : :class:`proteus.mprans.RANS2P.LevelModel` + LevelModel : :class:`proteus.kernels.RANS2P.LevelModel` Level transport model derived from the rans2p class. """ def __init__(self,levelModel): diff --git a/proteus/MeshAdaptPUMI/AdaptHelper.py b/proteus/MeshAdaptPUMI/AdaptHelper.py index e28f32cf0b..8cd79d3384 100644 --- a/proteus/MeshAdaptPUMI/AdaptHelper.py +++ b/proteus/MeshAdaptPUMI/AdaptHelper.py @@ -5,7 +5,7 @@ from proteus import MeshTools from proteus import SimTools import proteus.Domain -import proteus.mprans +import proteus.kernels def gatherGlobalMesh(sub, mpicomm, nd, vertices=None): """Assemble the whole (partitioned-numbering) mesh on rank 0 from the owned @@ -285,7 +285,8 @@ def PUMI_recomputeStructures(self,modelListOld): #clsvof needs to call poststep as well once, disc_ICs need to be turned off after initial time step try: - if(isinstance(self.modelList[self.phaseIdx].levelModelList[0],proteus.mprans.CLSVOF.LevelModel)): + from proteus.kernels import CLSVOF # call time: proteus.kernels.CLSVOF imports proteus, which imports this module + if(isinstance(self.modelList[self.phaseIdx].levelModelList[0],CLSVOF.LevelModel)): model = self.modelList[self.phaseIdx] self.postStep(model) model.levelModelList[0].coefficients.disc_ICs = modelListOld[self.phaseIdx].levelModelList[0].coefficients.disc_ICs @@ -564,11 +565,12 @@ def PUMI_transferFields(self): lm.u_store[ci] = lm.u[ci].copy() #for each type of phase tracking model, this will need to be done + from proteus.kernels import VOF, NCLS # call time, as above for m in self.modelList: for lm in m.levelModelList: try: - if(isinstance(lm,proteus.mprans.VOF.LevelModel) or - isinstance(lm,proteus.mprans.NCLS.LevelModel) + if(isinstance(lm,VOF.LevelModel) or + isinstance(lm,NCLS.LevelModel) ): lm.setUnknowns(m.uList[0]) except: diff --git a/proteus/mprans/MeshSmoothing.pxd b/proteus/MeshSmoothing.pxd similarity index 100% rename from proteus/mprans/MeshSmoothing.pxd rename to proteus/MeshSmoothing.pxd diff --git a/proteus/mprans/MeshSmoothing.pyx b/proteus/MeshSmoothing.pyx similarity index 100% rename from proteus/mprans/MeshSmoothing.pyx rename to proteus/MeshSmoothing.pyx diff --git a/proteus/MeshTools.py b/proteus/MeshTools.py index 1acfc50b04..62f2f23850 100644 --- a/proteus/MeshTools.py +++ b/proteus/MeshTools.py @@ -9198,6 +9198,58 @@ def writeMeshFiles(domain, meshOptions): else: raise TypeError("writeMeshFiles: no mesh generator for a " + type(domain).__name__) +def _tetgenFileProblems(fileprefix): + """What stops ``fileprefix`` from being partitioned from its tetgen files (``parun -F``), as strings. + + ``partitionNodesFromTetgenFiles`` reads ``.node`` and ``.ele`` and, for the faces and edges the + subdomains need, ``.face`` and ``.edge`` (``tetgen -Vfeen``). A missing file is a problem. Their + markers are optional to the reader (a file whose header announces none gives flag 0), so a header + with no marker column is only a warning (:func:`_tetgenMarkerWarnings`). What a header cannot tell + is whether the files belong together (a stale ``.edge``). + """ + problems = [] + for ext in ("node", "ele", "face", "edge"): + name = "{0:s}.{1:s}".format(fileprefix, ext) + if not os.path.isfile(name): + problems.append("missing " + name) + return problems + + +def _tetgenMarkerWarnings(fileprefix): + """A header without the boundary marker column leaves every face or edge unflagged: say so.""" + warnings = [] + for ext in ("face", "edge"): + name = "{0:s}.{1:s}".format(fileprefix, ext) + try: + with open(name) as f: + header = f.readline().split() + except OSError: + continue + if len(header) < 2 or header[1] != "1": + warnings.append("{0:s} has no boundary marker column in its header, so every {1:s} gets flag 0 " + "(tetgen without -B writes it)".format(name, ext)) + return warnings + + +def _requireTetgenFilesToPartition(comm, fileprefix): + """Exit, on every rank and naming the files, unless the tetgen files of ``fileprefix`` can be partitioned. + + Rank 0 looks (it is where the files are written, and the other ranks must agree with it); the + ranks read them collectively afterwards. + """ + import sys + result = None + if comm.isMaster(): + result = (_tetgenFileProblems(fileprefix), _tetgenMarkerWarnings(fileprefix)) + problems, warnings = comm.comm.tompi4py().bcast(result, root=0) + for warning in warnings: + logEvent("Warning: " + warning, level=1) + if problems: + sys.exit("ERROR: parun -F partitions the mesh from its tetgen files and cannot: %s. " + "Make them with `tetgen -Vfeen %s.poly` (the f flag writes .face, ee writes .edge), " + "or set genMesh so that this run does." % ("; ".join(problems), fileprefix)) + + def _generateMesh(domain,meshOptions,generatePartitionedMeshFromFiles=False,numerics=None): # convenience function to generate a mesh using triangle/tetgen/gmsh comm = Comm.get() @@ -9577,8 +9629,9 @@ def _generateMesh(domain,meshOptions,generatePartitionedMeshFromFiles=False,nume parallelPartitioningType=meshOptions.parallelPartitioningType) elif generatePartitionedMeshFromFiles: logEvent("Generating partitioned mesh from Tetgen files") - if("f" not in meshOptions.triangleOptions or "ee" not in meshOptions.triangleOptions): - sys.exit("ERROR: Remake the mesh with the `f` flag and `ee` flags in triangleOptions.") + # the files on disk decide, not the options string that may have made them: a deck that + # reads a stored mesh (genMesh False) has no triangleOptions to say how it was made + _requireTetgenFilesToPartition(comm, fileprefix) mlMesh.generatePartitionedMeshFromTetgenFiles(fileprefix, nbase,mesh,meshOptions.nLevels, nLayersOfOverlap=meshOptions.nLayersOfOverlapForParallel, parallelPartitioningType=meshOptions.parallelPartitioningType) diff --git a/proteus/mprans/MoveMeshMonitor.py b/proteus/MoveMeshMonitor.py similarity index 99% rename from proteus/mprans/MoveMeshMonitor.py rename to proteus/MoveMeshMonitor.py index 04729b7df2..2dfba2c415 100644 --- a/proteus/mprans/MoveMeshMonitor.py +++ b/proteus/MoveMeshMonitor.py @@ -2,8 +2,8 @@ import copy from proteus.Profiling import logEvent from proteus import TransportCoefficients -from proteus.mprans import MeshSmoothing as ms -from proteus.mprans import cMoveMeshMonitor as cmm +from proteus import MeshSmoothing as ms +from proteus import cMoveMeshMonitor as cmm class Coefficients(TransportCoefficients.PoissonEquationCoefficients): """ diff --git a/proteus/NumericalSolution.py b/proteus/NumericalSolution.py index 2b7b6574e8..fdf41e1c86 100644 --- a/proteus/NumericalSolution.py +++ b/proteus/NumericalSolution.py @@ -19,7 +19,7 @@ from . import Viewers from . import Gauges from . import WallLimit -from .mprans import PressureNormalization +from .kernels import PressureNormalization from .Archiver import ArchiveFlags from . import Domain from .MeshAdaptPUMI import Checkpoint,AdaptHelper @@ -173,6 +173,32 @@ class StepTimeError(RuntimeError): ``t_system_last < tn`` test as if the run had reached the final time, so it finished with exit code 0.""" +#: Module paths a hot-start state written before C49 R1 can carry, and where those modules are now (first match wins; +#: whole path components only). The kernel packages became one, proteus.kernels; a few helper modules of +#: proteus.mprans went to proteus/ and proteus/mbd, and proteus.ADR (top level) became proteus.kernels.ADR. +_MOVED_MODULES = (("proteus.mprans.SpatialTools", "proteus.SpatialTools"), + ("proteus.mprans.BoundaryConditions", "proteus.BoundaryConditions"), + ("proteus.mprans.BodyDynamics", "proteus.mbd.BodyDynamics"), + ("proteus.mprans.MeshSmoothing", "proteus.MeshSmoothing"), + ("proteus.mprans.MoveMeshMonitor", "proteus.MoveMeshMonitor"), + ("proteus.mprans.cMoveMeshMonitor", "proteus.cMoveMeshMonitor"), + ("proteus.mprans.cArgumentsDict", "proteus.cArgumentsDict"), + ("proteus.mprans", "proteus.kernels"), + ("proteus.richards", "proteus.kernels"), + ("proteus.m_comp_co2", "proteus.kernels"), + ("proteus.elastoplastic", "proteus.kernels"), + ("proteus.ADR", "proteus.kernels.ADR")) + + +def _current_module_path(text): + """``text`` (a class path such as 'proteus.kernels.NCLS.RKEV lag=True') with a leading old module path replaced by + the current one; anything else comes back unchanged.""" + for old, new in _MOVED_MODULES: + if text == old or text.startswith(old + ".") or text.startswith(old + " "): + return new + text[len(old):] + return text + + class NS_base(object): # (HasTraits): r""" The base class for managing the numerical solution of PDE's. @@ -1509,6 +1535,13 @@ def digest(a): digest(mesh.elementNumbering_subdomain2global), digest(mesh.nodeNumbering_subdomain2global)], dtype='int64') + @staticmethod + def _normalize_archived_policy(policy): + """An archived step policy with the module paths a state written before C49 R1 carries (proteus.kernels.NCLS.RKEV, + proteus.kernels.Richards...) read as the current ones (proteus.kernels.NCLS.RKEV, ...). Read side only: the + policy written now carries the current paths.""" + return {k: _current_module_path(v) if isinstance(v, str) else v for k, v in policy.items()} + def _hot_start_policy(self, model, index): """The step policy a ``continue`` hot start must find unchanged: the time integrator and its order, the step controllers, the shock @@ -1877,7 +1910,7 @@ def _solverStateUsable(self, model, index, tCount): differs = [] if "policy" in state: import json - then = json.loads(bytes(state["policy"]).decode()) + then = self._normalize_archived_policy(json.loads(bytes(state["policy"]).decode())) now = json.loads(json.dumps(self._hot_start_policy(model, index), default=str)) differs = ["%s: archived %s, now %s" % (k, then.get(k), now.get(k)) for k in sorted(set(then) | set(now)) if then.get(k) != now.get(k)] diff --git a/proteus/SWFlow/models/GN_sw_p.py b/proteus/SWFlow/models/GN_sw_p.py index 23438ea240..1af0c7d97f 100644 --- a/proteus/SWFlow/models/GN_sw_p.py +++ b/proteus/SWFlow/models/GN_sw_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.mprans import GN_SW2DCV +from proteus.kernels import GN_SW2DCV from proteus.Domain import RectangularDomain import numpy as np from proteus import Context diff --git a/proteus/SWFlow/models/sw_p.py b/proteus/SWFlow/models/sw_p.py index cd8bfec3eb..46a95dbc05 100644 --- a/proteus/SWFlow/models/sw_p.py +++ b/proteus/SWFlow/models/sw_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.mprans import SW2DCV +from proteus.kernels import SW2DCV from proteus.Domain import RectangularDomain import numpy as np from proteus import Context diff --git a/proteus/SpatialTools.py b/proteus/SpatialTools.py index 9f6e7abe28..fffb9d6677 100644 --- a/proteus/SpatialTools.py +++ b/proteus/SpatialTools.py @@ -37,6 +37,13 @@ from .Profiling import logEvent from subprocess import check_call from proteus import Comm +from itertools import compress +import csv +import numbers +import os +from math import atan2, acos, asin +from proteus import AuxiliaryVariables, Archiver, Profiling, Gauges +from proteus.mbd import BodyDynamics as bd from copy import deepcopy from functools import reduce @@ -1325,23 +1332,6 @@ def rotation3D(points, rot, axis=(0., 0., 1.), pivot=(0., 0., 0.)): return points_rot -def assembleDomain(domain): - """ - This function sets up everything needed for the domain, meshing, and - AuxiliaryVariables calculations (if any). - It should always be called after defining and manipulating all the shapes - to be attached to the domain. - - Parameters - ---------- - domain: proteus.Domain.D_base - Domain class instance that hold all the geometrical informations and - boundary conditions of the shape. - """ - # reinitialize geometry of domain - _assembleGeometry(domain, BC_class=bc.BC_Base) - _generateMesh(domain) - def _assembleGeometry(domain, BC_class): """ Assembles all the geometrical informations of the shapes attached to a @@ -1677,4 +1667,2151 @@ def extrude2Dto3D(extrusion, vertices, segments, facets, regions=None): if regions is not None: for region in regions_extruded: region += extrusion/2. - return vertices, segments, facets, regions_extruded \ No newline at end of file + return vertices, segments, facets, regions_extruded + + +# ----------------------------------------------------------------------------- +# TWO-PHASE FLOW (RANS) SHAPES, formerly proteus.SpatialTools (merged here by C49 R1) +# +# Importing this module makes every predefined shape a ShapeRANS (the bases are reassigned below), as importing +# proteus.SpatialTools did, so a shape of either kind has the rigid-body, relaxation-zone, gauge and +# auxiliary-variable methods; the boundary conditions of a shape are BC_RANS. assembleDomain (below) takes the +# two-phase path when any shape of the domain is a ShapeRANS and the generic one when none is. +# ----------------------------------------------------------------------------- + +class ShapeRANS(Shape): + """ + Base/super class of all shapes. Sets the boundary condition class to + proteus.BoundaryConditions.BC_RANS. + + Parameters + ---------- + domain: proteus.Domain.D_base + Domain class instance that hold all the geometrical informations and + boundary conditions of the shape. + nd: Optional[int] + Number of dimensions of the shape. If not set, will take the number of + dimensions of the domain. + """ + + def __init__(self, domain, nd): + super(ShapeRANS, self).__init__(domain, nd, BC_class=bc.BC_RANS) + self.mass = None + self.density = None + self.free_x = (1, 1, 1) + self.free_r = (1, 1, 1) + self.record_values = False + self.zones = {} # for absorption/generation zones + self.auxiliaryVariables = {} # list of auxvar attached to shape + self.It = None # inertia tensor + + def _attachAuxiliaryVariable(self, key, auxvar=None, gauge=None): + """ + Attaches an auxiliary variable to the auxiliaryVariables dictionary of + the shape (used in buildDomain function) + + Parameters + ---------- + key: string + Dictionary key defining the auxiliaryVariable to attach + auxvar: + auxiliaryVariable to associate with key + + gauge: Gauges + + Notes + ----- + This function is called automatically when using other functions to set + auxiliaryVariables and should not be used manually. + """ + if key not in self.auxiliaryVariables: + if key == 'RigidBody': + self.auxiliaryVariables[key] = auxvar + if self.holes is None: + self.holes = np.array([self.barycenter[:self.nd]]) + elif key == 'WallFunction': + self.auxiliaryVariables[key] = auxvar + elif key == 'kWallFunction': + self.auxiliaryVariables[key] = auxvar + elif key == 'RelaxZones': + self.auxiliaryVariables[key] = self.zones + elif str(key).startswith('Gauge_'): + self.auxiliaryVariables[key] = [gauge] + else: + logEvent("auxiliaryVariable key: " + "{key} not recognized.".format(key=str(key)), level=1) + elif str(key).startswith('Gauge_'): + if gauge not in self.auxiliaryVariables[key]: + self.auxiliaryVariables[key] += [gauge] + else: + logEvent( + "Attempted to put identical " + "gauge at key: {key}".format(key=str(key)), level=1) + else: + logEvent("Key {key} is already attached.".format(key=str(key)), + level=1) + + def attachPointGauges(self, model_key, gauges, activeTime=None, + sampleRate=0, + fileName='point_gauges.csv'): + """Attaches Point Gauges (in the Proteus/Gauges.py style) to the shape. + + Parameters + ---------- + model_key: string + Label of the model to use as a key for selecting particular gauges. + See proteus Gauges.py PointGauges class for the remaining parameters. + """ + new_gauges = Gauges.PointGauges(gauges, activeTime, sampleRate, + fileName) + self._attachAuxiliaryVariable('Gauge_' + model_key, + gauge=new_gauges) + + def attachLineGauges(self, model_key, gauges, activeTime=None, + sampleRate=0, + fileName='line_gauges.csv'): + """Attaches Line Gauges (in the Proteus/Gauges.py style) to the shape. + + Parameters + ---------- + model_key: string + Label of the model to use as a key for selecting particular gauges. + See proteus Gauges.py LineGauges class for the remaining parameters. + """ + new_gauges = Gauges.LineGauges(gauges, activeTime, sampleRate, + fileName) + self._attachAuxiliaryVariable('Gauge_' + model_key, + gauge=new_gauges) + + def attachLineIntegralGauges(self, model_key, gauges, activeTime=None, + sampleRate=0, + fileName='line_integral_gauges.csv'): + """Attaches Line Integral Gauges (in the Proteus/Gauges.py style). + + Parameters + ---------- + model_key: string + Label of the model to use as a key for selecting particular gauges. + See proteus Gauges.py LineIntegralGauges class for the remaining parameters. + """ + new_gauges = Gauges.LineIntegralGauges(gauges, activeTime, + sampleRate, fileName) + self._attachAuxiliaryVariable('Gauge_' + model_key, + gauge=new_gauges) + + def setTank(self): + """ + Sets tank boundary conditions (for moving domain). + """ + for boundcond in self.BC_list: + boundcond.setTank() + + def setTurbulentWall(self, wall): + """ + Sets a turbulent wall as an object to be attacched to auxiliaryVariable. + The objects has to be defined with WallFunction class. + + Parameters + ---------- + wall: list of WallFunction class object + """ + + auxvar = wall + self._attachAuxiliaryVariable('WallFunction', auxvar) + + def setTurbulentKWall(self, kWall): + """ + Sets a turbulent wall as an object to be attacched to auxiliaryVariable. + The objects has to be defined with WallFunction class. + + Parameters + ---------- + kWall: list of WallFunction class object for kappa + """ + + auxvar = kWall + self._attachAuxiliaryVariable('kWallFunction', auxvar) + + def setAbsorptionZones(self, flags, epsFact_porous, center, orientation, + dragAlpha, vert_axis=None,dragBeta=0., + porosity=1.): + """ + Sets a region (given the local flag) to an absorption zone + + Parameters + ---------- + dragAlpha: Optional + Relaxation zone coefficient. + flags: array_like, int + Local flags of the region. Can be an integer or a list. + epsFact_porous: float + Half of absorption zone (region) length (used for blending func). + center: array_like + Coordinates of the center of the absorption zone. + orientation: array_like + Orientation vector pointing TOWARDS incoming waves. + vert_axis: Optional[int] + index of vertical position vector (x:0, y:1, z:2), must always be + aligned with gravity. If not set, will be 1 in 2D (y), 2 in 3D (z). + dragBeta: Optional[float] + Relaxation zone coefficient. + porosity: Optional[float] + Relaxation zone coefficient. + """ + self._attachAuxiliaryVariable('RelaxZones') + waves = None + wind_speed = np.array([0., 0., 0.]) + if isinstance(flags, numbers.Integral): + flags = [int(flags)] + epsFact_porous = [epsFact_porous] + center = np.array([center]) + orientation = np.array([orientation]) + dragAlpha = [dragAlpha] + dragBeta = [dragBeta] + porosity = [porosity] + for i, flag in enumerate(flags): + self._checkNd(center[i]) + self._checkNd(orientation[i]) + ori = get_unit_vector(orientation[i]) + self.zones[flag] = bc.RelaxationZone(shape=self, + zone_type='absorption', + orientation=ori, + center=center[i], + waves=waves, + wind_speed=wind_speed, + epsFact_porous=epsFact_porous[i], + dragAlpha=dragAlpha[i], + dragBeta=dragBeta[i], + porosity=porosity[i], + vert_axis=vert_axis) + + def setGenerationZones(self, flags, epsFact_porous, center, orientation, + waves, dragAlpha,vert_axis=None, + wind_speed=(0., 0., 0.), dragBeta=0., + porosity=1., smoothing=0.): + """ + Sets a region (given the local flag) to a generation zone + + Parameters + ---------- + flags: array_like, int + Local flags of the region. Can be an integer or a list. + epsFact_porous: float + Half of absorption zone (region) length (used for blending func). + center: array_like + Coordinates of the center of the absorption zone. + orientation: array_like + Orientation vector pointing ACCORDING WITH the direction of generated waves. + waves: proteus.WaveTools + Class instance of wave generated from proteus.WaveTools. + dragAlpha: Optional[float] + Relaxation zone coefficient. + vert_axis: Optional[int] + index of vertical position vector (x:0, y:1, z:2), must always be + aligned with gravity. If not set, will be 1 in 2D (y), 2 in 3D (z). + wind_speed: Optional[array_like] + Speed of wind in generation zone (default is (0., 0., 0.)) + dragBeta: Optional[float] + Relaxation zone coefficient. + porosity: Optional[float] + Relaxation zone coefficient. + """ + self._attachAuxiliaryVariable('RelaxZones') + if isinstance(flags, numbers.Integral): + flags = [int(flags)] + epsFact_porous = [epsFact_porous] + center = np.array([center]) + orientation = np.array([orientation]) + waves = [waves] + wind_speed = np.array([wind_speed]) + dragAlpha = [dragAlpha] + dragBeta = [dragBeta] + porosity = [porosity] + smoothing = [smoothing] + for i, flag in enumerate(flags): + self._checkNd(center[i]) + self._checkNd(orientation[i]) + ori = get_unit_vector(orientation[i]) + self.zones[flag] = bc.RelaxationZone(shape=self, + zone_type='generation', + orientation=ori, + center=center[i], + waves=waves[i], + wind_speed=wind_speed[i], + epsFact_porous=epsFact_porous[i], + dragAlpha=dragAlpha[i], + dragBeta=dragBeta[i], + porosity=porosity[i], + smoothing=smoothing[i], + vert_axis=vert_axis) + + def setPorousZones(self, flags, dragAlpha, dragBeta, + porosity): + """ + Sets a region (given the local flag) to a porous zone + + Parameters + ---------- + flags: array_like, int + Local flags of the region. Can be an integer or a list. + dragAlpha: float + Darcy-type coefficient + dragBeta: float + Forchheimer-type coefficient + porosity: float + Porosity + """ + self._attachAuxiliaryVariable('RelaxZones') + if isinstance(flags, numbers.Integral): + flags = [int(flags)] + dragAlpha = [dragAlpha] + dragBeta = [dragBeta] + porosity = [porosity] + for i, flag in enumerate(flags): + # note for porous zone: + # epsFact_porous = q_phi_sponge, --> Hs always equal to 1. + self.zones[flag] = bc.RelaxationZone(shape=self, + zone_type='porous', + orientation=None, + center=None, + waves=None, + wind_speed=None, + epsFact_porous=1., + dragAlpha=dragAlpha[i], + dragBeta=dragBeta[i], + porosity=porosity[i]) + +# ----------------------------------------------------------------------------- +# ADDING FUNCTIONALITY TO SHAPE FROM proteus.SpatialTools +# ----------------------------------------------------------------------------- + + +# reassigning base/super class to access all functions from ShapeRANS and Shape +Rectangle.__bases__ = (ShapeRANS,) +Cuboid.__bases__ = (ShapeRANS,) +Sphere.__bases__ = (ShapeRANS,) +Cylinder.__bases__ = (ShapeRANS,) +CustomShape.__bases__ = (ShapeRANS,) +ShapeSTL.__bases__ = (ShapeRANS,) +Circle.__bases__ = (ShapeRANS,) + +# adding extra functionality to predefined shapes + + +def _CuboidsetInertiaTensor(self): + """ + Sets the inertia tensor of the cuboid + (!) should not be used manually + """ + L, W, H = self.dim + self.It = [[(W**2.+H**2.)/12., 0, 0], + [0, (L**2.+H**2.)/12., 0], + [0, 0, (W**2.+L**2.)/12.]] + + +Cuboid._setInertiaTensor = _CuboidsetInertiaTensor + + +def _RectanglesetInertiaTensor(self): + """ + Sets the inertia tensor of the rectangle + (!) should not be used manually + """ + L, H = self.dim + self.It = (L**2+H**2)/12 + + +Rectangle._setInertiaTensor = _RectanglesetInertiaTensor + + +# ----------------------------------------------------------------------------- +# DEFINING NEW SHAPES TYPES +# ----------------------------------------------------------------------------- + +class Tank3D(ShapeRANS): + """ + Class to create a 3D tank (cuboidal shape). + + Parameters + ---------- + domain: proteus.Domain.D_base + Domain class instance that hold all the geometrical informations and + boundary conditions of the shape. + dim: Optional[array_like] + Dimensions of the cuboid. + coords: Optional[array_like] + Coordinates of the centroid of the shape. + """ + count = 0 + + def __init__(self, domain, dim=(0., 0., 0.), coords=None): + super(Tank3D, self).__init__(domain, nd=3) + self.__class__.count += 1 + self.name = "tank3d" + repr(self.__class__.count) + if coords is None: + self.coords = np.array(dim)/2. + self.from_0 = True + else: + self.coords = coords + self.from_0 = False + self.holes = None + self.boundaryTags = {'z-': 1, + 'x-': 2, + 'y+': 3, + 'x+': 4, + 'y-': 5, + 'z+': 6, + 'sponge': 7, + 'wall': 8} + self.b_or = np.array([[0., 0., -1.], + [-1., 0., 0.], + [0., 1., 0.], + [1., 0., 0.], + [0., -1., 0.], + [0., 0., 1.]]) + self.BC = {'z-': self.BC_class(shape=self, name='z-', + b_or=self.b_or, b_i=0), + 'x-': self.BC_class(shape=self, name='x-', + b_or=self.b_or, b_i=1), + 'y+': self.BC_class(shape=self, name='y+', + b_or=self.b_or, b_i=2), + 'x+': self.BC_class(shape=self, name='x+', + b_or=self.b_or, b_i=3), + 'y-': self.BC_class(shape=self, name='y+', + b_or=self.b_or, b_i=4), + 'z+': self.BC_class(shape=self, name='z+', + b_or=self.b_or, b_i=5), + 'sponge': self.BC_class(shape=self, name='sponge'), + 'wall': self.BC_class(shape=self, name='wall')} + self.BC_list = [self.BC['z-'], + self.BC['x-'], + self.BC['y+'], + self.BC['x+'], + self.BC['y+'], + self.BC['z+'], + self.BC['sponge'], + self.BC['wall']] + # self.BC = BCContainer(self.BC_dict) + for i in range(6): + self.BC_list[i].setTank() + self.barycenter = np.array([0., 0., 0.]) + self.spongeLayers = {'y+': None, 'y-': None, 'x+': None, 'x-': None} + self.setDimensions(dim) + + def setSponge(self, x_p=None, x_n=None, y_p=None, y_n=None): + """ + Set length of sponge layers of the tank (used for wave absorption or + generation zones). + (!) Sponge layers expand outwards. + + Parameters + ---------- + x_p: Optional[float] + length of sponge layer in +x direction. + x_n: Optional[float] + length of sponge layer in -x direction. + y_p: Optional[float] + length of sponge layer in +y direction. + y_n: Optional[float] + length of sponge layer in -y direction. + """ + self.spongeLayers['x+'] = x_p + self.spongeLayers['x-'] = x_n + self.spongeLayers['y+'] = y_p + self.spongeLayers['y-'] = y_n + self.setDimensions(self.dim) + + def setDimensions(self, dim): + """ + Set dimension of the tank + Parameters + ---------- + dim: array_like + dimensions of the tank (excluding sponge layers), array of length 3. + """ + L, W, H = dim + self.dim = dim + if self.from_0 is True: + x, y, z = L/2., W/2., H/2. + else: + x, y, z = self.coords + self.coords = [x, y, z] + x0, x1 = x - 0.5 * L, x + 0.5 * L + y0, y1 = y - 0.5 * W, y + 0.5 * W + z0, z1 = z - 0.5 * H, z + 0.5 * H + # --------------------------------------------- + # first add all vecors, facets, regions at the bottom + # --------------------------------------------- + bt = self.boundaryTags + x_p = self.spongeLayers['x+'] or 0. + x_n = self.spongeLayers['x-'] or 0. + y_p = self.spongeLayers['y+'] or 0. + y_n = self.spongeLayers['y-'] or 0. + vertices = [[x0, y0, z0], [x1, y0, z0], [x1, y1, z0], [x0, y1, z0], + [x0, y0, z1], [x1, y0, z1], [x1, y1, z1], [x0, y1, z1]] + vertexFlags = [bt['z-'], bt['z-'], bt['z-'], bt['z-'], + bt['z+'], bt['z+'], bt['z+'], bt['z+']] + facets = [[[0, 1, 2, 3]], [[4, 5, 6, 7]]] + segments = [] + segmentFlags = [] + volumes = [[[0, 1]]] + facetFlags = [bt['z-'], bt['z+']] + regions = [[(x0+x1)/2., (y0+y1)/2., (z0+z1)/2.]] + regionFlags = [1] + self.regionIndice = {'tank': 0} + v_i = 8 # index of next vector to add + r_i = 1 # index of next region to add + f_i = len(facets) + nb_sponge = 0 # number of sponge layers defined + + ymin = y0 - y_n + ymax = y1 + y_p + xmin = x0 - x_n + xmax = x1 + x_p + corners = False + # y- + if y_n: + v0 = v_i + v1 = v_i + 2 + v2 = v_i + 1 + v3 = v_i + 3 + if corners: + vertices += [[x0, ymin, z0], [x0, ymin, z1], + [x1, ymin, z0], [x1, ymin, z1]] + else: + vertices += [[xmin, ymin, z0], [xmin, ymin, z1], + [xmax, ymin, z0], [xmax, ymin, z1]] + vertexFlags += [bt['z-'], bt['z+'], + bt['z-'], bt['z+']] + facets += [[[v0, v1, v3, v2]]] + facetFlags += [bt['y-']] + volumes[0][0] += [f_i] + regions += [[(x0+x1)/2., (y0+(ymin))/2., (z0+z1)/2.]] + self.regionIndice['y-'] = r_i + regionFlags += [r_i + 1] + facets += [[[0, 1, v1, v0]], + [[4, 5, v3, v2]], + [[0, 1, 5, 4]], + [[0, v0, v2, 4]], + [[1, v1, v3, 5]]] + facetFlags += [bt['z-'], + bt['z+'], + bt['sponge']] + if x_n > 0: + facetFlags += [bt['wall']] + else: + facetFlags += [bt['x-']] + if x_p > 0: + facetFlags += [bt['wall']] + else: + facetFlags += [bt['x+']] + volumes[0][0][-1] = f_i + 3 # add to volume + r_i += 1 + nb_sponge += 1 + volumes += [[[len(facets) - i - 1 for i in range(6)]]] + x_n_facet_i = len(facets) - 2 + else: + facets += [[[0, 1, 5, 4]]] + facetFlags += [bt['y-']] + volumes[0][0] += [f_i] + v_i = len(vertices) + f_i = len(facets) + # x+ + if x_p: + if corners: + vertices += [[xmax, y0, z0], [xmax, y0, z1], + [xmax, y1, z0], [xmax, y1, z1]] + v0 = v_i + v1 = v_i + 2 + v2 = v_i + 1 + v3 = v_i + 3 + vertexFlags += [bt['z-'], bt['z+'], + bt['z-'], bt['z+']] + else: + v0 = v_i - 2 + v1 = v_i + v2 = v_i - 1 + v3 = v_i + 1 + if not y_n: + vertices += [[xmax, ymin, z0], [xmax, ymin, z1]] + vertexFlags += [bt['z-'], bt['z+']] + v0 = v_i + v1 = v_i + 2 + v2 = v_i + 1 + v3 = v_i + 3 + vertices += [[xmax, ymax, z0], [xmax, ymax, z1]] + vertexFlags += [bt['z-'], bt['z+']] + facets += [[[v0, v1, v3, v2]]] + facetFlags += [bt['x+']] + volumes[0][0] += [f_i] + regions += [[(x1+(xmax))/2., (y0+y1)/2., (z0+z1)/2.]] + self.regionIndice['x+'] = r_i + regionFlags += [r_i + 1] + facets += [[[1, 2, v1, v0]], + [[5, 6, v3, v2]], + [[1, 2, 6, 5]]] + facetFlags += [bt['z-'], + bt['z+'], + bt['sponge']] + if corners or not y_n: + facets += [[[1, v0, v2, 5]]] + if y_n > 0: + facetFlags += [bt['wall']] + else: + facetFlags += [bt['y-']] + facets += [[[2, v1, v3, 6]]] + if y_p > 0: + facetFlags += [bt['wall']] + else: + facetFlags += [bt['y+']] + volumes[0][0][-1] = f_i + 3 # add to volume + r_i += 1 + nb_sponge += 1 + volumes += [[[len(facets) - i - 1 for i in range(6)]]] + else: + facets += [[[1, 2, 6, 5]]] + facetFlags += [bt['x+']] + volumes[0][0] += [f_i] + v_i = len(vertices) + f_i = len(facets) + # y+ + if y_p: + if corners: + vertices += [[x1, ymax, z0], [x1, ymax, z1], + [x0, ymax, z0], [x0, ymax, z1]] + v0 = v_i + v1 = v_i + 2 + v2 = v_i + 1 + v3 = v_i + 3 + vertexFlags += [bt['z-'], bt['z+'], + bt['z-'], bt['z+']] + else: + v0 = v_i - 2 + v1 = v_i + v2 = v_i - 1 + v3 = v_i + 1 + if not x_p: + vertices += [[xmax, ymax, z0], [xmax, ymax, z1]] + vertexFlags += [bt['z-'], bt['z+']] + v0 = v_i + v1 = v_i + 2 + v2 = v_i + 1 + v3 = v_i + 3 + vertices += [[xmin, ymax, z0], [xmin, ymax, z1]] + vertexFlags += [bt['z-'], bt['z+']] + facets += [[[v0, v1, v3, v2]]] + volumes[0][0] += [f_i] + facetFlags += [bt['y+']] + regions += [[(x0+x1)/2., (y1+(ymax))/2., (z0+z1)/2.]] + self.regionIndice['y+'] = r_i + regionFlags += [r_i + 1] + facets += [[[2, 3, v1, v0]], + [[6, 7, v3, v2]], + [[2, 3, 7, 6]]] + facetFlags += [bt['z-'], + bt['z+'], + bt['sponge']] + if corners or not x_p: + facets += [[[2, v0, v2, 6]]] + if x_p > 0: + facetFlags += [bt['wall']] + else: + facetFlags += [bt['x+']] + facets += [[[3, v1, v3, 7]]] + if x_n > 0: + facetFlags += [bt['wall']] + else: + facetFlags += [bt['x-']] + volumes[0][0][-1] = f_i + 3 + r_i += 1 + nb_sponge += 1 + volumes += [[[len(facets) - i - 1 for i in range(6)]]] + else: + facets += [[[3, 2, 6, 7]]] + facetFlags += [bt['y+']] + volumes[0][0] += [f_i] + v_i = len(vertices) + f_i = len(facets) + # x- + if x_n: + volumes[0][0] += [f_i] + if corners: + vertices += [[xmin, y0, z0], [xmin, y0, z1], + [xmin, y1, z0], [xmin, y1, z1]] + v0 = v_i + v1 = v_i + 2 + v2 = v_i + 1 + v3 = v_i + 3 + vertexFlags += [bt['z-'], bt['z+'], + bt['z-'], bt['z+']] + else: + if not y_p: + vertices += [[xmin, ymax, z0], [xmin, ymax, z1]] + v0 = v_i - 2 + v1 = v_i + v2 = v_i - 1 + v3 = v_i + 1 + vertexFlags += [bt['z-'], bt['z+']] + if not y_n: + vertices += [[xmin, ymin, z0], [xmin, ymin, z1]] + if not y_p: + v0 = v_i + 2 + v1 = v_i + v2 = v_i + 3 + v3 = v_i + 1 + else: + v0 = v_i + v1 = v_i - 2 + v2 = v_i + 1 + v3 = v_i - 1 + vertexFlags += [bt['z-'], bt['z+']] + else: + v1 = v_i - 2 + v0 = 8 + v3 = v_i - 1 + v2 = 9 + if not y_p: + v1 = v_i + v3 = v_i + 1 + facets += [[[v0, v1, v3, v2]]] + facetFlags += [bt['x-']] + regions += [[(x0+(xmin))/2., (y0+y1)/2., (z0+z1)/2.]] + self.regionIndice['x-'] = r_i + regionFlags += [r_i + 1] + facets += [[[0, 3, v1, v0]], + [[4, 7, v3, v2]], + [[0, 3, 7, 4]]] + facetFlags += [bt['z-'], + bt['z+'], + bt['sponge']] + volumes[0][0][-1] = f_i + 3 + if corners or not y_n or not y_p: + if corners or not y_n: + facets += [[[0, v0, v2, 4]]] + if y_n > 0: + facetFlags += [bt['wall']] + else: + facetFlags += [bt['y-']] + if corners or not y_p: + facets += [[[3, v1, v3, 7]]] + if y_p > 0: + facetFlags += [bt['wall']] + else: + facetFlags += [bt['y+']] + r_i += 1 + nb_sponge += 1 + if corners or not y_n: + volumes += [[[len(facets) - i - 1 for i in range(6)]]] + else: + volumes += [[[len(facets) - i - 1 for i in range(5)] + [x_n_facet_i]]] + else: + facets += [[[0, 3, 7, 4]]] + facetFlags += [bt['x-']] + volumes[0][0] += [f_i] + v_i = len(vertices) + f_i = len(facets) + self.vertices = np.array(vertices) + self.vertices = np.dot(self.vertices, self.coords_system) + self.vertexFlags = np.array(vertexFlags) + self.segments = np.array(segments) + self.segmentFlags = np.array(segmentFlags) + self.facets = np.array(facets) + self.facetFlags = np.array(facetFlags) + self.regions = np.array(regions) + self.regionFlags = np.array(regionFlags) + self.volumes = volumes + + def setAbsorptionZones(self, dragAlpha, allSponge=False, + y_n=False, y_p=False, + x_n=False, x_p=False, + dragBeta=0., porosity=1.): + """ + Sets regions (x+, x-, y+, y-) to absorption zones + + Parameters + ---------- + dragAlpha: float + Relaxation zone coefficient. + allSponge: bool + If True, all sponge layers are converted to absorption zones. + x_p: bool + If True, x+ region is converted to absorption zone. + x_n: bool + If True, x- region is converted to absorption zone. + y_p: bool + If True, y+ region is converted to absorption zone. + y_n: bool + If True, y- region is converted to absorption zone. + dragBeta: Optional[float] + Relaxation zone coefficient. + porosity: Optional[float] + Relaxation zone coefficient. + """ + self.abs_zones = {'y-': y_n, 'y+': y_p, 'x-': x_n, 'x+': x_p} + if allSponge is True: + for key in self.abs_zones: + self.abs_zones[key] = True + waves = None + wind_speed = np.array([0., 0., 0.]) + sl = self.spongeLayers + for key, value in list(self.abs_zones.items()): + if value is True: + self._attachAuxiliaryVariable('RelaxZones') + ind = self.regionIndice[key] + flag = self.regionFlags[ind] + epsFact_porous = self.spongeLayers[key]/2. + center = np.array(self.coords) + zeros_to_append = 3 - len(center) + if zeros_to_append: + for i in range(zeros_to_append): + center = np.append(center, [0]) + if key == 'x-': + center[0] += -0.5 * self.dim[0] - 0.5 * sl['x-'] + orientation = np.array([1., 0., 0.]) + elif key == 'x+': + center[0] += +0.5 * self.dim[0] + 0.5 * sl['x+'] + orientation = np.array([-1., 0., 0.]) + elif key == 'y-': + center[1] += -0.5 * self.dim[1] - 0.5 * sl['y-'] + orientation = np.array([0., 1., 0.]) + elif key == 'y+': + center[1] += +0.5 * self.dim[1] + 0.5 * sl['y+'] + orientation = np.array([0., -1., 0.]) + self.zones[flag] = bc.RelaxationZone(shape=self, + zone_type='absorption', + orientation=orientation, + center=center, + waves=waves, + wind_speed=wind_speed, + epsFact_porous=epsFact_porous, + dragAlpha=dragAlpha, + dragBeta=dragBeta, + porosity=porosity) + + def setGenerationZones(self, dragAlpha, smoothing, waves=None, + wind_speed=(0., 0., 0.), allSponge=False, y_n=False, + y_p=False, x_n=False, x_p=False, dragBeta=0., + porosity=1.): + """ + Sets regions (x+, x-, y+, y-) to generation zones + + Parameters + ---------- + dragAlpha: float + Relaxation zone coefficient. + smoothing: float + Smoothing distance (typically 3.*he) + waves: proteus.WaveTools + Class instance of wave generated from proteus.WaveTools. + wind_speed: Optional[array_like] + Speed of wind in generation zone (default is (0., 0., 0.)) + allSponge: bool + If True, all sponge layers are converted to generation zones. + x_p: bool + If True, x+ region is converted to generation zone. + x_n: bool + If True, x- region is converted to generation zone. + y_p: bool + If True, y+ region is converted to generation zone. + y_n: bool + If True, y- region is converted to generation zone. + dragBeta: Optional[float] + Relaxation zone coefficient. + porosity: Optional[float] + Relaxation zone coefficient. + """ + self.abs_zones = {'y-': y_n, 'y+': y_p, 'x-': x_n, 'x+': x_p} + if allSponge is True: + for key in self.abs_zones: + self.abs_zones[key] = True + waves = waves + wind_speed = np.array(wind_speed) + sl = self.spongeLayers + for key, value in list(self.abs_zones.items()): + if value is True: + self._attachAuxiliaryVariable('RelaxZones') + ind = self.regionIndice[key] + flag = self.regionFlags[ind] + epsFact_porous = self.spongeLayers[key]/2. + center = np.array(self.coords) + zeros_to_append = 3 - len(center) + if zeros_to_append: + for i in range(zeros_to_append): + center = np.append(center, [0]) + if key == 'x-': + center[0] += -0.5 * self.dim[0] - sl['x-']/2. + orientation = np.array([1., 0., 0.]) + self.BC['x-'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, + wind_speed=wind_speed, + smoothing=smoothing) + elif key == 'x+': + center[0] += +0.5 * self.dim[0] + sl['x+']/2. + orientation = np.array([-1., 0., 0.]) + self.BC['x+'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, + wind_speed=wind_speed, + smoothing=smoothing) + elif key == 'y-': + center[1] += -0.5 * self.dim[1] - sl['y-']/2. + orientation = np.array([0., 1., 0.]) + self.BC['y-'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, + wind_speed=wind_speed, + smoothing=smoothing) + elif key == 'y+': + center[1] += +0.5 * self.dim[1] + sl['y+']/2. + orientation = np.array([0., -1., 0.]) + self.BC['y+'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, + wind_speed=wind_speed, + smoothing=smoothing) + self.zones[flag] = bc.RelaxationZone(shape=self, + zone_type='generation', + orientation=orientation, + center=center, + waves=waves, + wind_speed=wind_speed, + epsFact_porous=epsFact_porous, + dragAlpha=dragAlpha, + dragBeta=dragBeta, + porosity=porosity, + smoothing=smoothing) + + +class Tank2D(ShapeRANS): + """ + Class to create a 2D tank (rectangular shape). + + Parameters + ---------- + domain: proteus.Domain.D_base + Domain class instance that hold all the geometrical informations and + boundary conditions of the shape. + dim: array_like + Dimensions of the tank (excluding sponge layers). + coords: Optional[array_like] + Coordinates of the centroid of the shape. + """ + count = 0 + + def __init__(self, domain, dim, coords=None): + super(Tank2D, self).__init__(domain, nd=2) + if coords is None: + self.coords = np.array(dim)/2. + self.from_0 = True + else: + self.coords = coords + self.from_0 = False + self.dim = dim + self._nameSelf() + self._setupBCs() + self.spongeLayers = {'x-': None, + 'x+': None} + self.constructShape() + + def _nameSelf(self): + self.__class__.count += 1 + self.name = "tank2D" + repr(self.__class__.count) + + def _setupBCs(self): + self.boundaryTags = {'y-': 1, 'x+': 2, 'y+': 3, 'x-': 4, 'sponge': 5} + self.b_or = np.array([[0., -1., 0.], + [1., 0., 0.], + [0., 1., 0.], + [-1., 0., 0.]]) + self.BC = {'y-': self.BC_class(shape=self, name='y-', + b_or=self.b_or, b_i=0), + 'x+': self.BC_class(shape=self, name='x+', + b_or=self.b_or, b_i=1), + 'y+': self.BC_class(shape=self, name='y+', + b_or=self.b_or, b_i=2), + 'x-': self.BC_class(shape=self, name='x-', + b_or=self.b_or, b_i=3), + 'sponge': self.BC_class(shape=self, name='sponge')} + self.BC_list = [self.BC['y-'], + self.BC['x+'], + self.BC['y+'], + self.BC['x-'], + self.BC['sponge']] + # self.BC = BCContainer(self.BC_dict) + for i in range(4): + self.BC_list[i].setTank() + + def constructShape(self): + """ + Construct the geometry of the tank: segments, regions, etc. + + Parameters + ---------- + frame: array_like + An array of (x,y) coordinates in counterclockwise order to define + the boundaries of the main (that is, excluding extensions such as + sponge zones) shape. This can be generated with tank2DFrame or + subclass specific methods. + frame_flags: array_like + A corresponding array of boundary tags associated with each point + in the frame. This can be generated with tank2DFrame or subclass + specific methods. + """ + self._findEdges(self.dim) + vertices, vertexFlags = self._constructVertices() + segments, segmentFlags = self._constructSegments(vertices, vertexFlags) + regions, regionFlags = self._constructRegions(vertices, vertexFlags, + segments, segmentFlags) + facets, facetFlags = self._constructFacets() + + self.vertices = np.array(vertices) + self.vertexFlags = np.array(vertexFlags) + self.segments = np.array(segments) + self.segmentFlags = np.array(segmentFlags) + self.regions = np.array(regions) + self.regionFlags = np.array(regionFlags) + self.facets = np.array(facets) + self.facetFlags = np.array(facetFlags) + + def _findEdges(self, dim): + + coords = self.coords + from_0 = self.from_0 + + if from_0: + self.x0 = 0 + self.x1 = dim[0] + self.y0 = 0 + self.y1 = dim[1] + else: # not from_0 and coords is not None + self.x0 = coords[0] - 0.5 * dim[0] + self.x1 = coords[0] + 0.5 * dim[0] + self.y0 = coords[1] - 0.5 * dim[1] + self.y1 = coords[1] + 0.5 * dim[1] + + def _constructVertices(self): + vertices = [[self.x0, self.y0], + [self.x1, self.y0], + [self.x1, self.y1], + [self.x0, self.y1]] + vertexFlags = [self.boundaryTags['y-'], + self.boundaryTags['y-'], + self.boundaryTags['y+'], + self.boundaryTags['y+']] + if self.spongeLayers['x-']: + vertices += [[self.x0 - self.spongeLayers['x-'], self.y0], + [self.x0 - self.spongeLayers['x-'], self.y1]] + vertexFlags += [self.boundaryTags['y-'], + self.boundaryTags['y+']] + if self.spongeLayers['x+']: + vertices += [[self.x1 + self.spongeLayers['x+'], self.y0], + [self.x1 + self.spongeLayers['x+'], self.y1]] + vertexFlags += [self.boundaryTags['y-'], + self.boundaryTags['y+']] + return vertices, vertexFlags + + def _constructSegments(self, vertices, vertexFlags): + segments = [[0, 1], [1, 2], [2, 3], [3, 0]] + segmentFlags = [self.boundaryTags['y-'], + self.boundaryTags['x+'], + self.boundaryTags['y+'], + self.boundaryTags['x-']] + added_vertices = 0 + if self.spongeLayers['x-']: + segments += [[0, 4 + added_vertices], + [4 + added_vertices, 5 + added_vertices], + [5 + added_vertices, 3]] + segmentFlags += [self.boundaryTags['y-'], + self.boundaryTags['x-'], + self.boundaryTags['y+']] + segmentFlags[3] = self.boundaryTags['sponge'] + added_vertices += 2 + if self.spongeLayers['x+']: + segments += [[1, 4 + added_vertices], + [4 + added_vertices, 5 + added_vertices], + [5 + added_vertices, 2]] + segmentFlags += [self.boundaryTags['y-'], + self.boundaryTags['x+'], + self.boundaryTags['y+']] + segmentFlags[1] = self.boundaryTags['sponge'] + added_vertices += 2 + return segments, segmentFlags + + def _constructFacets(self): + facets = [[[0, 1, 2, 3]]] + facetFlags = [1] + added_vertices = 0 + added_facets = 0 + if self.spongeLayers['x-']: + facets += [[[3, 0, 4, 5]]] + facetFlags += [2 + added_facets] + added_vertices += 2 + added_facets += 1 + if self.spongeLayers['x+']: + facets += [[[2, 1, added_vertices + 4, added_vertices + 5]]] + facetFlags += [2 + added_facets] + return facets, facetFlags + + def _constructRegions(self, vertices, vertexFlags, segments, segmentFlags): + regions = [[self.x0 + 0.01 * (self.x1 - self.x0), 0.5 * (self.y0 + self.y1)], ] + ind_region = 1 + regionFlags = [ind_region, ] + self.regionIndice = {'tank': ind_region - 1} + if self.spongeLayers['x-']: + regions += [[self.x0 - 0.5 * self.spongeLayers['x-'], + 0.5 * (self.y0 + self.y1)]] + ind_region += 1 + regionFlags += [ind_region] + self.regionIndice['x-'] = ind_region - 1 + if self.spongeLayers['x+']: + regions += [[self.x1 + 0.5 * self.spongeLayers['x+'], + 0.5 * (self.y0 + self.y1)]] + ind_region += 1 + regionFlags += [ind_region] + self.regionIndice['x+'] = ind_region - 1 + return regions, regionFlags + + def setSponge(self, x_n=None, x_p=None): + """ + Set length of sponge layers of the tank (used for wave absorption or + generation zones). + (!) Sponge layers expand outwards. + + Parameters + ---------- + x_p: Optional[float] + length of sponge layer in +x direction. + x_n: Optional[float] + length of sponge layer in -x direction. + """ + self.spongeLayers['x-'] = x_n + self.spongeLayers['x+'] = x_p + self.constructShape() + + def setAbsorptionZones(self, dragAlpha, x_n=False, x_p=False, + dragBeta=0., porosity=1.): + """ + Sets regions (x+, x-) to absorption zones + + Parameters + ---------- + dragAlpha: float + Relaxation zone coefficient. + allSponge: bool + If True, all sponge layers are converted to absorption zones. + x_p: bool + If True, x+ region is converted to absorption zone. + x_n: bool + If True, x- region is converted to absorption zone. + dragBeta: Optional[float] + Relaxation zone coefficient. + porosity: Optional[float] + Relaxation zone coefficient. + """ + waves = None + wind_speed = np.array([0., 0., 0.]) + if x_n or x_p: + self._attachAuxiliaryVariable('RelaxZones') + if x_n is True: + center = np.array([self.coords[0]-0.5*self.dim[0]-0.5*self.spongeLayers['x-'], + self.coords[1], + 0.]) + ind = self.regionIndice['x-'] + flag = self.regionFlags[ind] + epsFact_porous = self.spongeLayers['x-']/2. + orientation = np.array([1., 0.]) + self.zones[flag] = bc.RelaxationZone(shape=self, + zone_type='absorption', + orientation=orientation, + center=center, + waves=waves, + wind_speed=wind_speed, + epsFact_porous=epsFact_porous, + dragAlpha=dragAlpha, + dragBeta=dragBeta, + porosity=porosity) + if x_p is True: + center = np.array([self.coords[0]+0.5*self.dim[0]+0.5*self.spongeLayers['x+'], + self.coords[1], + 0.]) + ind = self.regionIndice['x+'] + flag = self.regionFlags[ind] + epsFact_porous = self.spongeLayers['x+']/2. + orientation = np.array([-1., 0.]) + self.zones[flag] = bc.RelaxationZone(shape=self, + zone_type='absorption', + orientation=orientation, + center=center, + waves=waves, + wind_speed=wind_speed, + epsFact_porous=epsFact_porous, + dragAlpha=dragAlpha, + dragBeta=dragBeta, + porosity=porosity) + + def setGenerationZones(self, dragAlpha, smoothing, + waves=None, wind_speed=(0., 0., 0.), + x_n=False, x_p=False, + dragBeta=0., porosity=1.): + """ + Sets regions (x+, x-) to generation zones + + Parameters + ---------- + dragAlpha: float + Relaxation zone coefficient + smoothing: + Smoothing distance + waves: proteus.WaveTools + Class instance of wave generated from proteus.WaveTools. + wind_speed: Optional[array_like] + Speed of wind in generation zone (default is (0., 0., 0.)) + allSponge: bool + If True, all sponge layers are converted to generation zones. + x_p: bool + If True, x+ region is converted to generation zone. + x_n: bool + If True, x- region is converted to generation zone. + dragBeta: Optional[float] + Relaxation zone coefficient. + porosity: Optional[float] + Relaxation zone coefficient. + """ + waves = waves + wind_speed = np.array(wind_speed) + if x_n or x_p: + self._attachAuxiliaryVariable('RelaxZones') + if x_n is True: + center = np.array([self.coords[0]-0.5*self.dim[0]-0.5*self.spongeLayers['x-'], + self.coords[1], + 0.]) + ind = self.regionIndice['x-'] + flag = self.regionFlags[ind] + epsFact_porous = self.spongeLayers['x-']/2. + orientation = np.array([1., 0.]) + self.zones[flag] = bc.RelaxationZone(shape=self, + zone_type='generation', + orientation=orientation, + center=center, + waves=waves, + wind_speed=wind_speed, + epsFact_porous=epsFact_porous, + dragAlpha=dragAlpha, + dragBeta=dragBeta, + porosity=porosity, + smoothing=smoothing) + self.BC['x-'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, + wind_speed=wind_speed, + smoothing=smoothing) + if x_p is True: + center = np.array([self.coords[0]+0.5*self.dim[0]+0.5*self.spongeLayers['x+'], + self.coords[1], + 0.]) + ind = self.regionIndice['x+'] + flag = self.regionFlags[ind] + epsFact_porous = self.spongeLayers['x+']/2. + orientation = np.array([-1., 0.]) + self.zones[flag] = bc.RelaxationZone(shape=self, + zone_type='generation', + orientation=orientation, + center=center, + waves=waves, + wind_speed=wind_speed, + epsFact_porous=epsFact_porous, + dragAlpha=dragAlpha, + dragBeta=dragBeta, + porosity=porosity, + smoothing=smoothing) + self.BC['x+'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, + wind_speed=wind_speed, + smoothing=smoothing) + +#[temp] no tests yet! + + +class TankWithObstacles2D(Tank2D): + """ + Class to create a 2D rectangular tank with obstacles built out of any wall. + + An obstacle is defined by a contiguous list of points which start and end + on the walls or corners of the tank. + + This also covers special boundary conditions. To tag a segment with a + unique boundary tag, add the starting vertex (in the counterclockwise + format the shape is generated in) of the segment as a value in a dictionary + element keyed to the name of the boundary tag. + + (!) Warning: If each of the four corners of the rectangular tank is inside + an obstacle or a vertex for an obstacle, then the tank's region is defined + in a pseudorandom manner, which may make it unreliable when dealing with + holes caused by other shapes. + (!) Warning: Obstacle boundary tags are keyed to whichever edge they started + from. If this is undesirable, it may be manually overriden by applying + special boundary conditions to affected segments. + + Parameters + ---------- + domain: proteus.Domain.D_base + Domain class instance that hold all the geometrical informations and + boundary conditions of the shape. + dim: Optional[array_like] + Dimensions of the cuboid. + obstacles: Optional[array_like] + A list of lists of (x,y) coordinates. Each (x,y) coordinate is a length + and height relative to the x-,y- corner of the tank. Each list of + coordinates is an obstacle defined by points connected in the order of + their index. The list of lists gives all such obstacles in a + counterclockwise manner of which they should be appended, starting from + the (x-,y-) corner. + special_boundaries: Optional[mapping] + A dictionary of lists of vertices keyed to boundary names. The vertices + listed will be given the boundary name they are keyed to, overriding + any other designation they would be given. + If this is a distinct boundary name, the segment starting from the vertex + will be assigned the same boundary tag. + full_circle: Optional[bool] + A boolean tag to check if the final obstacle ends on the same edge that + the first obstacle starts on. Default is False. + coords: Optional[array_like] + Coordinates of the centroid of the shape. + hole: Optional[bool] + If True (default), the obstacle of the tank is just an open hole at the + bottom of the tank. If False, a segment at the bottom of the obstacle is + created to close the hole. + obstacle_regions: Optional[array_like] + To use only if hole=False.(x,y) coordinates of a point inside the + obstacle in order to fill the obstacle with what should be inside + (for example a porous material). + + """ + + def __init__(self, domain, dim=(0., 0.), + obstacles=None, special_boundaries=None, + full_circle=False, + coords=None, hole=True, obstacle_regions=None): + if obstacles: + self.obstacles = obstacles + else: + self.obstacles = [] + + self.special_boundaries = [] + self.special_BC_vertices = [] + self.full_circle = full_circle + + self.spongeLayers = {'x-': None, + 'x+': None} + + if special_boundaries: + for key in list(special_boundaries.keys()): + self.special_boundaries += [key for v in special_boundaries[key]] + self.special_BC_vertices += special_boundaries[key] + + self.corners = {'x-y-': False, 'x+y-': False, + 'x+y+': False, 'x-y+': False} + + self.hole = hole + self.obstacle_regions = obstacle_regions + super(TankWithObstacles2D, self).__init__(domain, dim, coords) + + def _setupBCs(self): + super(TankWithObstacles2D, self)._setupBCs() + for boundary in self.special_boundaries: + if boundary not in list(self.boundaryTags.keys()): + self.boundaryTags[boundary] = len(self.boundaryTags) + 1 + self.BC[boundary] = self.BC_class(shape=self, name=boundary) + self.BC_list += [self.BC[boundary]] + # add boundaryTags + self.obstacle_flags = [] + max_flag = 0 + for tag, flag in list(self.boundaryTags.items()): + if flag > max_flag: + max_flag = flag + flag = max_flag + 1 + for i in range(len(self.obstacles)): + tag = 'obstacle' + repr(i + 1) + self.boundaryTags[tag] = flag + self.obstacle_flags += [flag] + self.BC[tag] = self.BC_class(shape=self, name=tag) + self.BC_list += [self.BC[tag]] + flag += 1 + if self.hole is False: + assert len(self.obstacles) == len(self.obstacle_regions), 'must have same number of regions as obstacles' + + def _resetEdgesFromVertices(self, vertices): + """ + Resets self.x0, self.x1, self.y0, self.y1 based on the actual shape. + + In particular, they will form a bounding box form around the shape - + the furthest points in x and y dimensions, both high and low. + + Parameters + ---------- + vertices: array_like + """ + sorted_vertices = sorted(vertices, key=lambda vertex: vertex[1]) + self.y0 = sorted_vertices[0][1] + self.y1 = sorted_vertices[-1][1] + sorted_vertices = sorted(vertices, key=lambda vertex: vertex[0]) + self.x0 = sorted_vertices[0][0] + self.x1 = sorted_vertices[-1][0] + + def _findSpongeLayerCorners(self, vertices): + """ + Finds the corners for horizontal (x-, x+) sponge layers. + + Parameters + ---------- + vertices: array_like + """ + self._resetEdgesFromVertices(vertices) + + potential_x_n_corners = [vertex for vertex in vertices + if np.isclose(vertex[0], self.x0)] + potential_x_p_corners = [vertex for vertex in vertices + if np.isclose(vertex[0], self.x1)] + + potential_x_n_corners.sort(key=lambda vertex: vertex[1]) + potential_x_p_corners.sort(key=lambda vertex: vertex[1]) + + self.x0y0 = potential_x_n_corners[0] + self.x0y1 = potential_x_n_corners[-1] + self.x1y0 = potential_x_p_corners[0] + self.x1y1 = potential_x_p_corners[-1] + + def _constructVertices(self): + + def getClockwiseOrder(first_point): + clockwise_ordering = ('x-y-', 'y-', 'x+y-', 'x+', + 'x+y+', 'y+', 'x-y+', 'x-') + index = clockwise_ordering.index(first_point) + return clockwise_ordering[index:] + clockwise_ordering[:index] + + def findLocation(vertex): + """ + Given an (x,y) coordinate gives a label associated to corner or edge + """ + dim = [self.x1 - self.x0, self.y1 - self.y0] + if np.isclose(vertex[0], 0) and np.isclose(vertex[1], 0): + return 'x-y-' + elif np.isclose(vertex[0], dim[0]) and np.isclose(vertex[1], dim[1]): + return 'x+y+' + elif np.isclose(vertex[0], 0) and np.isclose(vertex[1], dim[1]): + return 'x-y+' + elif np.isclose(vertex[0], dim[0]) and np.isclose(vertex[1], 0): + return 'x+y-' + elif np.isclose(vertex[0], 0): + return 'x-' + elif np.isclose(vertex[0], dim[0]): + return 'x+' + elif np.isclose(vertex[1], 0): + return 'y-' + elif np.isclose(vertex[1], dim[1]): + return 'y+' + else: + raise ValueError("Point " + str(vertex) + " does not seem to" + "be on a tank wall.") + + def checkClosure(start_point, end_point): + if start_point == end_point: + return True + + def addCorner(corner_flag): + if corner_flag == 'x-y-': + corner = [[self.x0, self.y0]] + elif corner_flag == 'x+y-': + corner = [[self.x1, self.y0]] + elif corner_flag == 'x+y+': + corner = [[self.x1, self.y1]] + elif corner_flag == 'x-y+': + corner = [[self.x0, self.y1]] + # vertex flags + if corner_flag in ['x-y-', 'x+y-']: + corner_tag = [self.boundaryTags['y-']] + else: + corner_tag = [self.boundaryTags['y+']] + + return corner, corner_tag + + def addIntermediateCorners(first, last): + """ + Returns corner vertices (and flags) in between two segments + """ + ordering = getClockwiseOrder(first) + corners = [x for x in ordering + if x in list(self.corners.keys()) + and ordering.index(x) < ordering.index(last) + ] + corner_vertices = [] + corner_flags = [] + + for corner in corners: + self.corners[corner] = True + vertex, flag = addCorner(corner) + corner_vertices += vertex + corner_flags += flag + + return corner_vertices, corner_flags + + def addRemainingCorners(first, last): + if first == last: + if self.full_circle: + return [] + else: + return addAllCorners(first) + else: + return addIntermediateCorners(first, last) + + def addAllCorners(starting_point): + """ + Returns all corners and flags. + """ + corner_vertices = [] + corner_flags = [] + + ordering = getClockwiseOrder(starting_point) + + for potential_corner in ordering: + if potential_corner in list(self.corners.keys()): + self.corners[potential_corner] = True + vertex, flag = addCorner(potential_corner) + corner_vertices += vertex + corner_flags += flag + + return corner_vertices, corner_flags + + def addSpongeVertices(): + sponge_vertices = [] + sponge_vertexFlags = [] + if self.spongeLayers['x-']: + sponge_vertices += [[v[0] - self.spongeLayers['x-'], v[1]] + for v in [self.x0y0, self.x0y1]] + sponge_vertexFlags += [self.boundaryTags['y-'], + self.boundaryTags['y+']] + if self.spongeLayers['x+']: + sponge_vertices += [[v[0] + self.spongeLayers['x+'], v[1]] + for v in [self.x1y0, self.x1y1]] + sponge_vertexFlags += [self.boundaryTags['y-'], + self.boundaryTags['y+']] + return sponge_vertices, sponge_vertexFlags + + #--------------------------------------------------------# + vertices = [] + vertexFlags = [] + former_end = None + first_start = None + + for nb, obstacle in enumerate(self.obstacles): + start = findLocation(obstacle[0]) + end = findLocation(obstacle[-1]) + + if start == end and checkClosure(obstacle[0], obstacle[-1]): + raise ValueError("Obstacles must be open (start and end" + " vertices must be distinct)") + if start == former_end and checkClosure(obstacle[0], vertices[-1]): + vertices.pop() + vertexFlags.pop() + + # ---- In-Between Corner Vertices ---- # + if former_end is not None: + new_vertices, new_flags = addIntermediateCorners(former_end, start) + vertices += new_vertices + vertexFlags += new_flags + + # ---- Obstacle ---- # + if self.hole is True: + vertices += obstacle + vertexFlags += [self.boundaryTags[start] + for i in range(len(obstacle))] + elif self.hole is False: + vertices += obstacle + vertexFlags += [self.boundaryTags['obstacle' + repr(nb + 1)] + for i in range(len(obstacle))] + + # ---- Paperwork ---- # + former_end = end + if first_start is None: + first_start = start + + # ---- Remaining Corner Vertices ---- # + if first_start is not None: + new_vertices, new_flags = addRemainingCorners(former_end, + first_start) + else: + new_vertices, new_flags = addAllCorners('x-') + + vertices += new_vertices + vertexFlags += new_flags + + # ---- Check for Special Conditions ---- # + for vertex in self.special_BC_vertices: + flag_index = vertices.index(vertex) + boundary_index = self.special_BC_vertices.index(vertex) + boundary_name = self.special_boundaries[boundary_index] + vertexFlags[flag_index] = self.boundaryTags[boundary_name] + + # ---- Adjustments for Sponge Zones ---- # + self._findSpongeLayerCorners(vertices=vertices) + + # ---- Add Sponge Zone Vertices ---- # + new_vertices, new_flags = addSpongeVertices() + vertices += new_vertices + vertexFlags += new_flags + + return vertices, vertexFlags + + def _constructSegments(self, vertices, vertexFlags): + # VertexFlag --> SegmentFlag logic: + # + # if EITHER are x+ --> segment is x+ + # UNLESS the other is x- --> y+ + # if EITHER are x- --> segment is x- + # UNLESS the other is x+ --> y- + # if it STARTS y- --> segment is y- + # UNLESS they are vertical --> x+ + # if it STARTS y+ --> segment is y+ + # UNLESS they are vertical --> x- + # if BOTH are *** --> segment is *** + # (if two different *** are around, it takes the first) + segments = [] + segmentFlags = [] + + on_sponge_edge = {'x-': False, 'x+': False} + sponge_edges_covered = {'x-': False, 'x+': False} + + def checkSpongeStatus(start_index, end_index): + start_vertex = vertices[start_index] + if self.spongeLayers['x-']: + if not on_sponge_edge['x-']: + if start_vertex in (self.x0y0, self.x0y1): + on_sponge_edge['x-'] = True + elif not sponge_edges_covered['x-']: + if start_vertex in (self.x0y0, self.x0y1): + on_sponge_edge['x-'] = False + sponge_edges_covered['x-'] = True + else: + vertexFlags[start_index] = self.boundaryTags['sponge'] + else: + pass + + if self.spongeLayers['x+']: + if not on_sponge_edge['x+']: + if start_vertex in (self.x1y0, self.x1y1): + on_sponge_edge['x+'] = True + elif not sponge_edges_covered['x+']: + if start_vertex in (self.x1y0, self.x1y1): + on_sponge_edge['x+'] = False + sponge_edges_covered['x+'] = True + else: + vertexFlags[start_index] = self.boundaryTags['sponge'] + else: + pass + + end_vertex = vertices[end_index] + if on_sponge_edge['x-']: + if end_vertex not in (self.x0y0, self.x0y1): + vertexFlags[end_index] = self.boundaryTags['sponge'] + if on_sponge_edge['x+']: + if end_vertex not in (self.x1y0, self.x1y1): + vertexFlags[end_index] = self.boundaryTags['sponge'] + + def getSegmentFlag(start, end): + if ((self.spongeLayers['x-'] and not sponge_edges_covered['x-']) or + (self.spongeLayers['x+'] and not sponge_edges_covered['x+'])): + checkSpongeStatus(start, end) + + if on_sponge_edge['x-'] or on_sponge_edge['x+']: + return [self.boundaryTags['sponge'], ] + + else: + if vertexFlags[start] in self.obstacle_flags: + if vertexFlags[end] == vertexFlags[start]: + return [vertexFlags[start], ] + else: + return [self.boundaryTags['y-'], ] + elif vertexFlags[start] == self.boundaryTags['x+']: + if vertexFlags[end] == self.boundaryTags['x-']: + return [self.boundaryTags['y+'], ] + else: + return [self.boundaryTags['x+'], ] + + elif vertexFlags[start] == self.boundaryTags['x-']: + if vertexFlags[end] == self.boundaryTags['x+']: + return [self.boundaryTags['y-'], ] + else: + return [self.boundaryTags['x-'], ] + + elif vertexFlags[end] == self.boundaryTags['x+']: + if vertexFlags[start] in [self.boundaryTags['y-'], + self.boundaryTags['y+']]: + return [self.boundaryTags['x+'], ] + + elif vertexFlags[end] == self.boundaryTags['x-']: + if vertexFlags[start] in [self.boundaryTags['y-'], + self.boundaryTags['y+']]: + return [self.boundaryTags['x-'], ] + + elif vertexFlags[start] == self.boundaryTags['y-']: + if (vertexFlags[end] == self.boundaryTags['y+'] + and np.isclose(vertices[start][0], vertices[end][0]) + ): + return [self.boundaryTags['x+'], ] + else: + return [self.boundaryTags['y-'], ] + + elif vertexFlags[start] == self.boundaryTags['y+']: + if (vertexFlags[end] == self.boundaryTags['y-'] + and np.isclose(vertices[start][0], vertices[end][0]) + ): + return [self.boundaryTags['x-'], ] + else: + return [self.boundaryTags['y+'], ] + + else: + return [vertexFlags[start], ] + + # ---- Initial Sponge Logic ---- # + sponge_vertex_count = 0 + + if self.spongeLayers['x-']: + sponge_vertex_count += 2 + if self.spongeLayers['x+']: + sponge_vertex_count += 2 + + # ---- Build Main Segments ---- # + for i in range(len(vertices) - 1 - sponge_vertex_count): + segments += [[i, i + 1], ] + segmentFlags += getSegmentFlag(i, i + 1) + segments += [[len(vertices) - 1 - sponge_vertex_count, 0], ] + segmentFlags += getSegmentFlag(len(vertices) - 1 - sponge_vertex_count, + 0) + if self.hole is False: + start_vertex_obstacle = 0 + for obstacle in self.obstacles: + segments += [[start_vertex_obstacle, start_vertex_obstacle + (len(obstacle) - 1)]] + segmentFlags += [self.boundaryTags['y-']] + start_vertex_obstacle += len(obstacle) + + # ---- Build Sponge Segments ---- # + if self.spongeLayers['x-']: + segments += [[vertices.index(self.x0y0), + len(vertices) - sponge_vertex_count], + [len(vertices) - sponge_vertex_count, + len(vertices) - sponge_vertex_count + 1], + [len(vertices) - sponge_vertex_count + 1, + vertices.index(self.x0y1)] + ] + segmentFlags += [self.boundaryTags['y-'], + self.boundaryTags['x-'], + self.boundaryTags['y+']] + if self.spongeLayers['x+']: + segments += [[vertices.index(self.x1y0), len(vertices) - 2], + [len(vertices) - 2, len(vertices) - 1], + [len(vertices) - 1, vertices.index(self.x1y1)] + ] + segmentFlags += [self.boundaryTags['y-'], + self.boundaryTags['x+'], + self.boundaryTags['y+']] + + return segments, segmentFlags + + def _constructRegions(self, vertices, vertexFlags, segments, segmentFlags): + + ind_region = 0 + self.regionIndice = {} + regions = [] + regionFlags = [] + + if self.hole is False: + for i, region in enumerate(self.obstacle_regions): + regions = [[region[0], region[1]]] + ind_region += 1 + regionFlags = [ind_region, ] + self.regionIndice['obstacle' + repr(i + 1)] = ind_region - 1 + + if True in list(self.corners.values()): + regions += self._getCornerRegion() + else: + regions += self._getRandomRegion(vertices, segments) + + ind_region += 1 + regionFlags += [ind_region] + self.regionIndice['tank'] = ind_region - 1 + + sponge_half_height_x0 = 0.5 * (self.x0y0[1] + self.x0y1[1]) + sponge_half_height_x1 = 0.5 * (self.x1y0[1] + self.x1y1[1]) + sponge_x0 = self.x0y0[0] + sponge_x1 = self.x1y0[0] + + if self.spongeLayers['x-']: + regions += [[sponge_x0 - 0.5 * self.spongeLayers['x-'], + sponge_half_height_x0]] + ind_region += 1 + regionFlags += [ind_region] + self.regionIndice['x-'] = ind_region - 1 + if self.spongeLayers['x+']: + regions += [[sponge_x1 + 0.5 * self.spongeLayers['x+'], + sponge_half_height_x1]] + ind_region += 1 + regionFlags += [ind_region] + self.regionIndice['x+'] = ind_region - 1 + + return regions, regionFlags + + def _findExtrema(self, points): + """ + Return the extrema of a series of points in n dimensions in the form: + max(x1), max(x2), ... , max(xn), min(x1), ... , min(xn) + """ + points = np.array(points) + return np.max(points, 0).tolist() + np.min(points, 0).tolist() + + def _getCornerRegion(self): + eps = np.finfo(float).eps + if self.corners['x-y-']: + return [[self.x0 + eps, self.y0 + eps], ] + elif self.corners['x+y-']: + return [[self.x1 - eps, self.y0 + eps], ] + elif self.corners['x+y+']: + return [[self.x1 - eps, self.y1 - eps], ] + elif self.corners['x-y+']: + return [[self.x0 + eps, self.y1 - eps], ] + + def _getRandomRegion(self, vertices, segments): + x_p, y_p, x_n, y_n = self._findExtrema(vertices) + if self.spongeLayers['x-']: + x_n += self.spongeLayers['x-'] + if self.spongeLayers['x+']: + x_p -= self.spongeLayers['x+'] + + count = 0 + allowed_tries = 100 + + while True: + count += 1 + vertical_line = np.random.uniform(x_n, x_p) + if True in [np.isclose(vertical_line, vertex[0]) for vertex in + vertices]: + continue + + lowest_intersect = second_intersect = y_p + + for segment in segments: + line_x0 = vertices[segment[0]][0] + line_y0 = vertices[segment[0]][1] + line_x1 = vertices[segment[1]][0] + line_y1 = vertices[segment[1]][1] + if (line_x0 < vertical_line < line_x1 + or line_x0 > vertical_line > line_x1): + # (due to the strict inequality check and + # our selection of vertical_line - x1 > x0 should be sure) + intersection_height = line_y0 + ( + (line_y1 - line_y0) + * (vertical_line - line_x0) + / (line_x1 - line_x0) + ) + if intersection_height < lowest_intersect: + second_intersect = lowest_intersect + lowest_intersect = intersection_height + elif intersection_height < second_intersect: + second_intersect = intersection_height + + interior_point = 0.5 * (lowest_intersect + second_intersect) + + if lowest_intersect < interior_point < second_intersect: + break + if count > allowed_tries: + ValueError( + "Cannot find a proper interior point of the defined " + "shape after " + str(count) + " tries.") + + return [[vertical_line, interior_point], ] + + def setAbsorptionZones(self, dragAlpha, x_n=False, x_p=False, + dragBeta=0., porosity=1.): + """ + Sets regions (x+, x-) to absorption zones + + Parameters + ---------- + dragAlpha: float + Relaxation zone coefficient + allSponge: bool + If True, all sponge layers are converted to absorption zones. + x_p: bool + If True, x+ region is converted to absorption zone. + x_n: bool + If True, x- region is converted to absorption zone. + dragBeta: Optional[float] + Relaxation zone coefficient. + porosity: Optional[float] + Relaxation zone coefficient. + """ + sponge_half_height_x0 = 0.5 * (self.x0y0[1] + self.x0y1[1]) + sponge_half_height_x1 = 0.5 * (self.x1y0[1] + self.x1y1[1]) + sponge_x0 = self.x0y0[0] + sponge_x1 = self.x1y0[0] + + waves = None + wind_speed = np.array([0., 0., 0.]) + if x_n or x_p: + self._attachAuxiliaryVariable('RelaxZones') + if x_n is True: + center = np.array([sponge_x0 - 0.5 * self.spongeLayers['x-'], + sponge_half_height_x0, 0.]) + ind = self.regionIndice['x-'] + flag = self.regionFlags[ind] + epsFact_porous = self.spongeLayers['x-']/2. + orientation = np.array([1., 0.]) + self.zones[flag] = bc.RelaxationZone(shape=self, + zone_type='absorption', + orientation=orientation, + center=center, + waves=waves, + wind_speed=wind_speed, + epsFact_porous=epsFact_porous, + dragAlpha=dragAlpha, + dragBeta=dragBeta, + porosity=porosity) + if x_p is True: + center = np.array([sponge_x1 + 0.5 * self.spongeLayers['x+'], + sponge_half_height_x1, 0.]) + ind = self.regionIndice['x+'] + flag = self.regionFlags[ind] + epsFact_porous = self.spongeLayers['x+']/2. + orientation = np.array([-1., 0.]) + self.zones[flag] = bc.RelaxationZone(shape=self, + zone_type='absorption', + orientation=orientation, + center=center, + waves=waves, + wind_speed=wind_speed, + epsFact_porous=epsFact_porous, + dragAlpha=dragAlpha, + dragBeta=dragBeta, + porosity=porosity) + + def setGenerationZones(self, dragAlpha, smoothing, waves=None, + wind_speed=(0., 0., 0.), x_n=False, x_p=False, + dragBeta=0., porosity=1.): + """ + Sets regions (x+, x-) to generation zones + + Parameters + ---------- + dragAlpha: float + Relaxation zone coefficient. + smoothing: float + Smoothing distance (typically 3*he) + waves: proteus.WaveTools + Class instance of wave generated from proteus.WaveTools. + wind_speed: Optional[array_like] + Speed of wind in generation zone (default is (0., 0., 0.)) + allSponge: bool + If True, all sponge layers are converted to generation zones. + x_p: bool + If True, x+ region is converted to generation zone. + x_n: bool + If True, x- region is converted to generation zone. + dragBeta: Optional[float] + Relaxation zone coefficient. + porosity: Optional[float] + Relaxation zone coefficient. + """ + sponge_half_height_x0 = 0.5 * (self.x0y0[1] + self.x0y1[1]) + sponge_half_height_x1 = 0.5 * (self.x1y0[1] + self.x1y1[1]) + sponge_x0 = self.x0y0[0] + sponge_x1 = self.x1y0[0] + + waves = waves + wind_speed = np.array(wind_speed) + if x_n or x_p: + self._attachAuxiliaryVariable('RelaxZones') + if x_n is True: + + center = np.array([sponge_x0 - 0.5 * self.spongeLayers['x-'], + sponge_half_height_x0, 0.]) + ind = self.regionIndice['x-'] + flag = self.regionFlags[ind] + epsFact_porous = self.spongeLayers['x-']/2. + orientation = np.array([1., 0.]) + self.zones[flag] = bc.RelaxationZone(shape=self, + zone_type='generation', + orientation=orientation, + center=center, + waves=waves, + wind_speed=wind_speed, + epsFact_porous=epsFact_porous, + dragAlpha=dragAlpha, + dragBeta=dragBeta, + porosity=porosity, + smoothing=smoothing) + self.BC['x-'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, + wind_speed=wind_speed, + smoothing=smoothing) + if x_p is True: + + center = np.array([sponge_x1 + 0.5 * self.spongeLayers['x+'], + sponge_half_height_x1, 0.]) + ind = self.regionIndice['x+'] + flag = self.regionFlags[ind] + epsFact_porous = self.spongeLayers['x+']/2. + orientation = np.array([-1., 0.]) + self.zones[flag] = bc.RelaxationZone(shape=self, + zone_type='generation', + orientation=orientation, + center=center, + waves=waves, + wind_speed=wind_speed, + epsFact_porous=epsFact_porous, + dragAlpha=dragAlpha, + dragBeta=dragBeta, + porosity=porosity, + smoothing=smoothing) + self.BC['x+'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, + wind_speed=wind_speed, + smoothing=smoothing) + + + +def assembleDomain(domain): + """ + This function sets up everything needed for the domain, meshing, and + AuxiliaryVariables calculations (if any). + It should always be called after defining and manipulating all the shapes + to be attached to the domain. + + If any shape of the domain is a ShapeRANS (the predefined shapes are, once this module is imported; so are + Tank2D, Tank3D and TankWithObstacles2D) the two-phase flow boundary conditions (BC_RANS) are used, the + boundary between processors is set non-material, the auxiliary variables of the shapes are assembled and the + mesh is generated unless the domain is a PUMIDomain. A domain without such a shape gets the generic boundary + conditions (BC_Base) and a mesh. + + Parameters + ---------- + domain: proteus.Domain.D_base + Domain class instance that hold all the geometrical informations and + boundary conditions of the shape. + """ + if any(isinstance(shape, ShapeRANS) for shape in domain.shape_list): + _assembleGeometry(domain, BC_class=bc.BC_RANS) + domain.BCbyFlag[0].setNonMaterial() # set BC for boundary between processors + assembleAuxiliaryVariables(domain) + if(domain.name != "PUMIDomain"): + _generateMesh(domain) + else: + # reinitialize geometry of domain + _assembleGeometry(domain, BC_class=bc.BC_Base) + _generateMesh(domain) + + +def assembleAuxiliaryVariables(domain): + """ + Adds the auxiliary variables to the domain. + + Parameters + ---------- + domain: proteus.Domain.D_base + Domain class instance that hold all the geometrical informations and + boundary conditions of the shape. + + Notes + ----- + Should be called after assembleGeometry + """ + + domain.auxiliaryVariables = { + 'dissipation': [], + 'kappa': [], + 'ls': [], + 'ls_consrv': [], + 'moveMesh': [], + 'redist': [], + 'twp': [], + 'vof': [], + 'thp': [], + 'vos': [], + 'SWFlow' :[] + } + + zones_global = {} + start_region = 0 + start_rflag = 0 + start_flag = 0 + for shape in domain.shape_list: + aux = domain.auxiliaryVariables + # ---------------------------- + # RIGID BODIES + if 'RigidBody' in list(shape.auxiliaryVariables.keys()): + body = shape.auxiliaryVariables['RigidBody'] + aux['twp'] += [body] + # fixing mesh on rigid body + for boundcond in shape.BC_list: + boundcond.setRigidBodyMoveMesh(body) + # update the indice for force/moment calculations + body.i_start = start_flag + 1 + body.i_end = start_flag + 1 + len(shape.BC_list) + if 'ChRigidBody' in list(shape.auxiliaryVariables.keys()): + body = shape.auxiliaryVariables['ChRigidBody'] + for boundcond in shape.BC_list: + boundcond.setChMoveMesh(body) + if body.boundaryFlags.size == 0: + flags = [] + for tag, flag in shape.boundaryTags.items(): + flags += [start_flag+flag] + body.setBoundaryFlags(flags) + if 'WallFunction' in list(shape.auxiliaryVariables.keys()): + wall = shape.auxiliaryVariables['WallFunction'] + for ii in range(len(wall)): + aux['twp'] += [wall[ii]] + logEvent('WALL ATTACHED TO AUXVAR --> %s' % wall[ii]) + if 'kWallFunction' in list(shape.auxiliaryVariables.keys()): + kWall = shape.auxiliaryVariables['kWallFunction'] + for ii in range(len(kWall)): + aux['kappa'] += [kWall[ii]] + logEvent('kWALL ATTACHED TO AUXVAR --> %s' % kWall[ii]) + # ---------------------------- + # ABSORPTION/GENERATION ZONES + + if 'RelaxZones' in list(shape.auxiliaryVariables.keys()): + if not zones_global: + aux['twp'] += [bc.RelaxationZoneWaveGenerator(zones_global, + domain.nd)] + # add relaxation zones to SWFlow AuxiliaryVariables + aux['SWFlow'] += [bc.RelaxationZoneWaveGenerator(zones_global, + domain.nd)] + if not hasattr(domain, 'porosityTypes'): + # create arrays of default values + domain.porosityTypes = np.ones(len(domain.regionFlags) + 1) + domain.dragAlphaTypes = np.zeros(len(domain.regionFlags) + 1) + domain.dragBetaTypes = np.zeros(len(domain.regionFlags) + 1) + domain.epsFact_porous = np.zeros(len(domain.regionFlags) + 1) + i0 = start_region + 1 + for flag, zone in list(shape.zones.items()): + ind = [i for i, f in enumerate(shape.regionFlags) if f == flag] + for i1 in ind: + domain.porosityTypes[i0 + i1] = zone.porosity + domain.dragAlphaTypes[i0 + i1] = zone.dragAlpha + domain.dragBetaTypes[i0 + i1] = zone.dragBeta + domain.epsFact_porous[i0 + i1] = zone.epsFact_porous + # update dict with global key instead of local key + key = flag + start_rflag + zones_global[key] = zone + start_flag += len(shape.BC_list) + # ---------------------------- + # GAUGES + gauge_dict = {key: shape.auxiliaryVariables.get(key, []) + for key in list(shape.auxiliaryVariables.keys()) + if str(key).startswith('Gauge_')} + for key in list(gauge_dict.keys()): + key_name = key.split('_', 1)[1] # Cutting off "Gauge_" prefix + if key_name not in aux: + # It is probably too dangerous to simply put "aux[key_name] = []" + # as this system is fragile to typos. Instead, we throw an error. + raise ValueError('ERROR: Gauge key ', + key_name, + ' is not a recognized model by SpatialTools.', + ' The known models in our dictionary are ', + str(list(aux.keys())) + ) + else: + aux[key_name] += gauge_dict[key] + if shape.regions is not None: + start_region += len(shape.regions) + start_rflag = max(domain.regionFlags[0:start_region]) + + +def get_unit_vector(vector): + return np.array(vector)/np.linalg.norm(vector) diff --git a/proteus/SplitOperator.py b/proteus/SplitOperator.py index 70e74ee792..af48d46251 100644 --- a/proteus/SplitOperator.py +++ b/proteus/SplitOperator.py @@ -6,6 +6,7 @@ """ import numpy from .Profiling import logEvent +from .Comm import globalMax class System(object): def __init__(self): @@ -1016,3 +1017,53 @@ def initialize_dt_system(self,t0,tOut): (self.system.name, self.stepSequence), level=1) + + +# From the 2012 gwvd decks (erdc/proteus-gwvd@14961d2 src/Gwvd_consolidated_classes.py), moved here from proteus/gwvd. + +class ISO_fixed_MinModelStep(ISO_fixed_MinAdaptiveModelStep): + """ + Iterate flow and transport within a step (Povich 2013, Sec. 4.5) until the max norm of the owned + residuals of both models is below atol_iso, then advance. + """ + + def __init__(self, modelList, system=defaultSystem, stepExact=False, atol_iso=1.e-8): + ISO_fixed_MinAdaptiveModelStep.__init__(self, modelList, system, stepExact) + self.atol_iso = atol_iso + self.convergence_flag = False + self.velocity_Postprocess = False + + def setFromOptions(self, soOptions): + self.velocity_Postprocess = False + if 'atol_iso' in dir(soOptions): + self.atol_iso = soOptions.atol_iso + if 'velocity_Postprocess' in dir(soOptions): + self.velocity_Postprocess = soOptions.velocity_Postprocess + + def converged(self): + if self.convergence_flag and self.its != 0: + self.its = 0 + self.convergence_flag = False + return True + return False + + def SysNorm(self, rSys): + # The 2012 code takes the signed maximum of each residual (not max |r|), so negative + # residuals never block convergence. Kept for fidelity with the published runs. + return max(globalMax(float(r.max())) for r in rSys) + + def sequenceTaken(self): + self.its += 1 + rSys = [] + for model in self.modelList: + lm = model.levelModelList[-1] + lm.getResidual(model.uList[-1], model.rList[-1]) + rSys.append(model.rList[-1][:lm.mesh.subdomainMesh.nNodes_owned]) + rNorm = self.SysNorm(rSys) + logEvent("ISO iteration %d: max residual %12.5e (atol_iso %12.5e)" % (self.its, rNorm, self.atol_iso), level=1) + if rNorm < self.atol_iso and self.its != 0: + self.convergence_flag = True + if self.convergence_flag: + for model in self.modelList: + model.stepController.updateTimeHistory() + model.stepController.choose_dt_model() diff --git a/proteus/StepControl.py b/proteus/StepControl.py index b4f5541161..749226610d 100644 --- a/proteus/StepControl.py +++ b/proteus/StepControl.py @@ -1355,3 +1355,37 @@ def stepExact_model(self,tOut): self.set_dt_allLevels() #self.substeps = [self.t_model] self.setSubsteps([self.t_model]) + + +# From the 2012 gwvd decks (erdc/proteus-gwvd@14961d2 src/Gwvd_consolidated_classes.py), moved here from proteus/gwvd. + +class Fixed_dt_controller_systemit(Min_dt_controller): + """Fixed model step dt = nOptions.DT, for the iterated (ISO) coupling of flow and transport.""" + + def __init__(self, model, nOptions): + Min_dt_controller.__init__(self, model, nOptions) + self.dt = nOptions.DT + self.dt_model_last = None + model.levelModelList[-1].timeIntegration.isAdaptive = True # needed by the ISO controller + + def initialize_dt_model(self, t0, tOut): + self.saveSolution() + self.dt_model = self.dt + if self.dt_model_last is None: + self.dt_model_last = self.dt_model + self.set_dt_allLevels() + self.substeps = [self.t_model] + logEvent("Initializing time step on model %s to dt = %12.5e" % (self.model.name, self.dt_model), level=1) + + def choose_dt_model(self): + self.solverFailures = 0 + self.errorFailures = 0 + self.saveSolution() + self.dt_model = self.dt + if self.dt_model_last is None: + self.dt_model_last = self.dt_model + self.set_dt_allLevels() + self.setSubsteps([self.t_model]) + + def stepExact_model(self, tOut): + pass diff --git a/proteus/TimeIntegration.py b/proteus/TimeIntegration.py index 506ff0043c..ee44d1e434 100644 --- a/proteus/TimeIntegration.py +++ b/proteus/TimeIntegration.py @@ -4308,4 +4308,62 @@ def calculateCoefs(self): self.beta_bdf[ci].flat[:] -= self.mt1_last[ci].flat +# From the 2012 gwvd decks (erdc/proteus-gwvd@14961d2 src/Gwvd_consolidated_classes.py), moved here from proteus/gwvd. + +class NonConservativeBackwardEuler(BackwardEuler): + """Backward Euler on the primary variable: m_t = dm (u - u_last)/dt, with dm frozen at the new iterate. + + Until the time history is initialized, m_t is reported as zero. Current proteus spins up model 0 + (the flow) before the transport history exists, when u_last is still zero and dt is the default + 1.0; the flow source omega (drho/dc) c_t / rho would then see a fictitious c_t = omega rho c. + """ + + def __init__(self, transport, integrateInterpolationPoints=False): + BackwardEuler.__init__(self, transport, + integrateInterpolationPoints=integrateInterpolationPoints) + self.historyInitialized = False + + def initializeTimeHistory(self, resetFromDOF=True): + BackwardEuler.initializeTimeHistory(self, resetFromDOF) + self.historyInitialized = True + + def calculateElementCoefficients(self, q): + self.calculateCoefs() + if not self.historyInitialized: + for ci in self.m_last.keys(): + self.m_tmp[ci][:] = q[('u', ci)] + q[('mt', ci)].fill(0.0) + return + for ci in self.m_last.keys(): + self.m_tmp[ci][:] = q[('u', ci)] + q[('mt', ci)][:] = q[('u', ci)] + q[('mt', ci)] -= self.m_last[ci] + q[('mt', ci)] /= self.dt + q[('mt', ci)] *= q[('dm', ci, ci)] + for cj in range(self.nc): + if ('dmt', ci, cj) in q: + q[('dmt', ci, cj)][:] = q[('dm', ci, cj)] + q[('dmt', ci, cj)] /= self.dt + if ('dm_sge', ci, cj) in q and ('dmt_sge', ci, cj) in q: + q[('dmt_sge', ci, cj)][:] = q[('dm_sge', ci, cj)] + q[('dmt_sge', ci, cj)] /= self.dt + + def calculateGeneralizedInterpolationCoefficients(self, cip): + if not self.integrateInterpolationPoints: + return + for ci in self.m_ip_last.keys(): + self.m_ip_tmp[ci][:] = cip[('u', ci)] + cip[('mt', ci)][:] = cip[('u', ci)] + cip[('mt', ci)] -= self.m_ip_last[ci] + cip[('mt', ci)] /= self.dt + cip[('mt', ci)] *= cip[('dm', ci, ci)] + for cj in range(self.nc): + if ('dmt', ci, cj) in cip: + cip[('dmt', ci, cj)][:] = cip[('dm', ci, cj)] + cip[('dmt', ci, cj)] /= self.dt + if ('dmt_sge', ci, cj) in cip: + cip[('dmt_sge', ci, cj)][:] = cip[('dm_sge', ci, cj)] + cip[('dmt_sge', ci, cj)] /= self.dt + + ## @} diff --git a/proteus/TransportCoefficients.py b/proteus/TransportCoefficients.py index a240604b66..d267b93327 100644 --- a/proteus/TransportCoefficients.py +++ b/proteus/TransportCoefficients.py @@ -10258,4 +10258,263 @@ def evaluate(self,t,c): c[('df',2,3)], c[('df',3,1)], c[('df',3,2)], - c[('df',3,3)]) \ No newline at end of file + c[('df',3,3)]) + + +######################################################################## +# Variable-density groundwater flow and transport (continuous Galerkin path), from proteus/gwvd. +# Ported from erdc/proteus-gwvd@14961d2 (src/GwvdCoefficients.py, src/gwvdCoefficients.c; Povich et al. 2013, +# Comput. Geosci. 17:529). Primary variables: the freshwater head h and the normalized mass fraction c (`mf`). +# The flow "velocity" handed to transport is the mass flux rho*q from the flow model's velocity +# post-processing (`conservativeFlux`). The C coefficient evaluators are reimplemented with numpy. +######################################################################## + +def density_eval(mf, epsilon, rho_fw): + """Linear density relation rho = rho_fw (1 + epsilon c).""" + return rho_fw * (1.0 + epsilon * mf) + + +def var_visc(mf, mf_s): + """Relative viscosity of Lever & Jackson (1985), as in the 2012 code (a ratio, not a viscosity).""" + mf_a = mf * mf_s + return 1.0 + 1.85 * mf_a - 4.1 * mf_a**2 + 44.5 * mf_a**3 + + +def knabnerFrolkovicConsistentVelCorrection_Triangle_P1(epsilon, c_l2g, c_dof, J, Jinv, gravity, + q_rhog_consistent, eps_tol=1.0e-9): + """Knabner-Frolkovic (1996) consistent rho*g on P1 triangles, Eqs. 3.3-3.16. + + Writes J^{-T} hhat into q_rhog_consistent (nElements x 2), where hhat holds the reference-element + derivatives of the integrated buoyancy term. For the linear density used here the exact integral + is the mean of the two vertex values, which is what the 2012 C code evaluates. + """ + JeT = numpy.swapaxes(J[:, 0], 1, 2) + JeTinv = numpy.swapaxes(Jinv[:, 0], 1, 2) + ghat = numpy.einsum('eij,j->ei', JeT, gravity) + c_e = c_dof[c_l2g[:, :3]] + h1 = numpy.where(numpy.abs(c_e[:, 1] - c_e[:, 0]) <= eps_tol, + epsilon * c_e[:, 0], 0.5 * epsilon * (c_e[:, 1] + c_e[:, 0])) + h2 = numpy.where(numpy.abs(c_e[:, 2] - c_e[:, 0]) <= eps_tol, + epsilon * c_e[:, 0], 0.5 * epsilon * (c_e[:, 2] + c_e[:, 0])) + h_hat = numpy.stack([ghat[:, 0] * h1, ghat[:, 1] * h2], axis=1) + q_rhog_consistent[:] = numpy.einsum('eij,ej->ei', JeTinv, h_hat) + + +class VariableDensity_mod2_FlowEquationCoefficients(TC_base): + """ + Variable-density subsurface flow in non-divergence (mod2) form for the freshwater head h: + + S rho h_t + div(f - a grad h) + r = 0, + a = k rho_fw g rho / mu, f = -a epsilon c e_z (or -a (rho g)~ with the consistent velocity), + r = omega (drho/dc) c_t / rho. + + The mass fraction c and its time derivative come from the transport model. + """ + + def __init__(self, aOfX=None, rOfX=None, bOfX=None, S=1.0, omega=.3, epsilon=.025, rho_fw=1000.0, + gc=9.8, Kx=1.0e-10, Ky=1.0e-10, Kz=1.0e-10, mu=1.0e-3, mf_s=0.167, drho_dmf=200.0, + rho_source=0.0, T_model=None, C_model=None, flowModelIndex=0, transModelIndex=1, + cModelIndex=2, nc=1, nd=2, consistentVelocityFlag=0, consistentVelocityFunction=None, + variableViscosityFlag=0, rho_eval=None, rhoInt_eval=None, gravity=None, + getInterface=None, Height=1.0): + self.aOfX = aOfX + self.rOfX = rOfX + self.bOfX = bOfX + self.omega = omega + self.epsilon = epsilon + self.S = S + self.gc = gc + self.rho_fw = rho_fw + self.Kx = Kx + self.Ky = Ky + self.Kz = Kz + self.mu = mu + self.mf_s = mf_s + self.rho_source = rho_source + self.nd = nd + self.drho_dmf = drho_dmf + self.T_model = T_model + self.C_model = C_model + self.getInterface = getInterface + self.Height = Height + self.consistentVelocityFlag = consistentVelocityFlag # 0 none, 1 Knabner-Frolkovic 96 + self.variableViscosityFlag = variableViscosityFlag + if C_model is not None: + raise NotImplementedError("surface-water coupling (C_model) is not ported") + if consistentVelocityFlag == 1 and nd != 2: + raise NotImplementedError("only the P1 triangle consistent velocity is ported") + mass, advection, diffusion, potential, reaction, hamiltonian = {}, {}, {}, {}, {}, {} + for i in range(nc): + mass[i] = {i: 'linear'} + advection[i] = {i: 'constant'} + diffusion[i] = {i: {i: 'constant'}} + potential[i] = {i: 'u'} + reaction[i] = {i: 'constant'} + TC_base.__init__(self, nc, mass, advection, diffusion, potential, + reaction, hamiltonian, variableNames=['h']) + self.transModelIndex = transModelIndex + self.flowModelIndex = flowModelIndex + self.cModelIndex = cModelIndex + self.q_mf = None + self.q_mfdt = None + self.ebqe_mf = None + self.ebqe_mfdt = None + self.ebq_mf = None + self.ebq_mfdt = None + self.consistentVelocityFunction = consistentVelocityFunction + self.q_rhog_consistent = None + self.rho_eval = rho_eval + self.rhoInt_eval = rhoInt_eval + self.gravity = gravity + + def preStep(self, t, firstStep=False): + """Build the consistent rho*g from the current mass fraction, if requested.""" + if self.consistentVelocityFlag == 1 and self.T_model is not None: + assert self.transModel.u[0].femSpace.isSpace('C0',('lagrange','bernstein'),1,'simplex') + knabnerFrolkovicConsistentVelCorrection_Triangle_P1(self.epsilon, + self.transModel.u[0].femSpace.dofMap.l2g, + self.transModel.u[0].dof, + self.model.q['J'], + self.model.q['inverse(J)'], + numpy.asarray(self.gravity, 'd'), + self.q_rhog_consistent) + + def initializeMesh(self, mesh): + self.elementBoundaryElements = mesh.elementBoundaryElementsArray + self.exteriorElementBoundaries = mesh.exteriorElementBoundariesArray + + def attachModels(self, modelList): + self.model = modelList[self.flowModelIndex] + if self.T_model is not None: + self.transModel = modelList[self.transModelIndex] + self.q_mf = self.transModel.q[('u', 0)] + self.q_mfdt = self.transModel.q[('mt', 0)] + self.ebqe_mf = self.transModel.ebqe[('u', 0)] + self.ebqe_mfdt = numpy.zeros(self.ebqe_mf.shape, 'd') + if ('u', 0) in self.transModel.ebq: + self.ebq_mf = self.transModel.ebq[('u', 0)] + self.ebq_mfdt = numpy.zeros(self.ebq_mf.shape, 'd') + if self.consistentVelocityFlag != 0: + self.q_rhog_consistent = numpy.zeros((self.q_mf.shape[0], self.nd), 'd') + + def evaluate(self, t, c): + if self.q_mf is not None and c[('u', 0)].shape == self.q_mf.shape: + mf, mfdt, b_flag = self.q_mf, self.q_mfdt, 0 + elif self.ebqe_mf is not None and c[('u', 0)].shape == self.ebqe_mf.shape: + mf, mfdt, b_flag = self.ebqe_mf, self.ebqe_mfdt, 1 + elif self.ebq_mf is not None and c[('u', 0)].shape == self.ebq_mf.shape: + # as in 2012: element-boundary points have no c_t, so the coefficients are left unset + return + else: + raise RuntimeError("no mass fraction for points of shape %s" % (c[('u', 0)].shape,)) + nd = self.nd + a = c[('a', 0, 0)] + assert a.shape[-1] == nd * nd, "expected full (non-sparse) diffusion storage" + density = density_eval(mf, self.epsilon, self.rho_fw) + logEvent("gwvd flow: t=%g b_flag=%d max|c_t|=%g" % (t, b_flag, numpy.abs(mfdt).max()), level=5) + c[('m', 0)][:] = c[('u', 0)] * self.S * density # replaced by the time integrator + c[('dm', 0, 0)][:] = self.S * density + c[('r', 0)][:] = self.drho_dmf * mfdt / density + K = [self.Kx, self.Ky, self.Kz][:nd] + denom = self.mu if self.variableViscosityFlag == 0 else var_visc(mf, self.mf_s) + a.fill(0.0) + for I in range(nd): + a[..., I * nd + I] = K[I] * self.gc * self.rho_fw * density / denom + f, df = c[('f', 0)], c[('df', 0, 0)] + df.fill(0.0) + if self.consistentVelocityFlag == 1: + if b_flag == 0: + rhog = self.q_rhog_consistent[:, numpy.newaxis, :] + else: + eN = self.elementBoundaryElements[self.exteriorElementBoundaries, 0] + rhog = self.q_rhog_consistent[eN][:, numpy.newaxis, :] + A = a.reshape(a.shape[:-1] + (nd, nd)) + f[:] = -numpy.einsum('...ij,...j->...i', A, numpy.broadcast_to(rhog, f.shape)) + else: + f.fill(0.0) + f[..., nd - 1] = -a[..., (nd - 1) * nd + nd - 1] * self.epsilon * mf + + +class VDGroundwater_mod2_TransportCoefficients(TC_base): + """ + Mass-fraction transport in advective (Hamilton-Jacobi) form driven by the flow model's mass flux v: + + omega rho c_t + v . grad c - div(a grad c) = 0, + a = rho d omega I + alpha_T |v| I + (alpha_L - alpha_T) v v^T / |v|. + """ + + def __init__(self, nc=1, nd=2, omega=0.3, alpha_L=1.0, alpha_T=0.2, rho_fw=1000, d=1.3e-9, + epsilon=0.0, rho_source=0.0, mf_source=0.0, flowModelIndex=0, transModelIndex=1, + cModelIndex=2, C_Model=None, F_Model=0, getInterface=None, Height=1.0): + self.nd = nd + self.omega = omega + self.nc = nc + self.d = d + self.alpha_L = alpha_L + self.alpha_T = alpha_T + self.rho_fw = rho_fw + self.epsilon = epsilon + self.rho_source = rho_source + self.mf_source = mf_source + self.F_Model = F_Model + self.C_Model = C_Model + self.flowModelIndex = flowModelIndex + self.transModelIndex = transModelIndex + self.cModelIndex = cModelIndex + self.getInterface = getInterface + self.Height = Height + if C_Model is not None: + raise NotImplementedError("surface-water coupling (C_Model) is not ported") + mass, advection, diffusion, potential, reaction, hamiltonian = {}, {}, {}, {}, {}, {} + for i in range(nc): + mass[i] = {i: 'linear'} + advection[i] = {i: 'linear'} + diffusion[i] = {i: {i: 'constant'}} + potential[i] = {i: 'u'} + reaction[i] = {i: 'linear'} + hamiltonian[i] = {i: 'linear'} + TC_base.__init__(self, nc, mass, advection, diffusion, potential, + reaction, hamiltonian, variableNames=['mf']) + + def attachModels(self, modelList): + self.model = modelList[self.transModelIndex] + if self.F_Model is not None: + flow = modelList[self.flowModelIndex] + self.flowModel = flow + self.q_v = flow.q[('velocity', 0)] + self.ebq_v = flow.ebq.get(('velocity', 0)) + self.ebqe_v = flow.ebqe[('velocity', 0)] + self.ebq_global_v = flow.ebq_global.get(('velocity', 0)) + + def evaluate(self, t, c): + shape = c[('df', 0, 0)].shape + for v in (self.q_v, self.ebq_v, self.ebqe_v, self.ebq_global_v): + if v is not None and v.shape == shape: + break + else: + raise RuntimeError("no flow velocity for points of shape %s" % (shape,)) + nd = self.nd + a = c[('a', 0, 0)] + assert a.shape[-1] == nd * nd, "expected full (non-sparse) diffusion storage" + u = c[('u', 0)] + density = density_eval(u, self.epsilon, self.rho_fw) + c[('m', 0)][:] = u # replaced by NonConservativeBackwardEuler: m_t = dm (u - u_last)/dt + c[('dm', 0, 0)][:] = self.omega * density + c[('r', 0)].fill(0.0) + c[('dr', 0, 0)].fill(0.0) + c[('f', 0)].fill(0.0) + c[('df', 0, 0)].fill(0.0) + c[('H', 0)][:] = numpy.einsum('...i,...i->...', c[('grad(u)', 0)], v) + c[('dH', 0, 0)][:] = v + norm_v = numpy.sqrt(numpy.einsum('...i,...i->...', v, v)) + safe = numpy.where(norm_v > 0.0, norm_v, 1.0) + a.fill(0.0) + for I in range(nd): + a[..., I * nd + I] = (density * self.d * self.omega + + numpy.where(norm_v > 0.0, + self.alpha_T * norm_v + + (self.alpha_L - self.alpha_T) * v[..., I]**2 / safe, 0.0)) + for J in range(I + 1, nd): + off = numpy.where(norm_v > 0.0, (self.alpha_L - self.alpha_T) * v[..., I] * v[..., J] / safe, 0.0) + a[..., I * nd + J] = off + a[..., J * nd + I] = off diff --git a/proteus/TwoPhaseFlow/TwoPhaseFlowProblem.py b/proteus/TwoPhaseFlow/TwoPhaseFlowProblem.py index b300492026..9742aaf28d 100644 --- a/proteus/TwoPhaseFlow/TwoPhaseFlowProblem.py +++ b/proteus/TwoPhaseFlow/TwoPhaseFlowProblem.py @@ -139,7 +139,7 @@ def assert_boundaryConditions(self): # check diffusive flux BCs assert 'pressure_increment_DFBC' in boundaryConditions,"Provide pressure_increment_DFBC" else: - assert self.domain.useSpatialTools is True, 'Either define boundaryConditions dict or use proteus.mprans.SpatialTools to set Boundary Conditions and run function assembleDomain' + assert self.domain.useSpatialTools is True, 'Either define boundaryConditions dict or use proteus.SpatialTools to set Boundary Conditions and run function assembleDomain' def initializeAll(self): @@ -231,7 +231,7 @@ def __init__(self,modelList,system=defaultSystem,stepExact=True): def unattachedAuxiliaryVariables(domain_auxvars, model_list): """ The entries of domain.auxiliaryVariables (a dict of lists, as filled by - proteus.mprans.SpatialTools.assembleDomain) that none of the models in + proteus.SpatialTools.assembleDomain) that none of the models in model_list has in its auxiliaryVariables, as {key: [objects]}. """ if not isinstance(domain_auxvars, dict): @@ -390,7 +390,7 @@ def __init__(self,ProblemInstance): self.initialConditions = None self.boundaryConditions=None - # to use proteus.mprans.BoundaryConditions + # to use proteus.BoundaryConditions # but only if SpatialTools was used to make the domain self.useBoundaryConditionsModule = True diff --git a/proteus/TwoPhaseFlow/utils/Parameters.py b/proteus/TwoPhaseFlow/utils/Parameters.py index 3c0fa5fe7b..3fc77cc085 100644 --- a/proteus/TwoPhaseFlow/utils/Parameters.py +++ b/proteus/TwoPhaseFlow/utils/Parameters.py @@ -14,7 +14,8 @@ parallel=False # models -from proteus.mprans import (RANS2P, +from proteus import MoveMeshMonitor +from proteus.kernels import (RANS2P, RANS3PF, VOF, RDLS, @@ -23,7 +24,6 @@ CLSVOF, AddedMass, MoveMesh, - MoveMeshMonitor, Pres, PresInit, PresInc, diff --git a/proteus/__init__.py b/proteus/__init__.py index 96d5bc8cd3..434d993d5f 100644 --- a/proteus/__init__.py +++ b/proteus/__init__.py @@ -41,7 +41,7 @@ from . import _threads _threads.apply_defaults(_threads.launched_size()) -__version__ = '2.0.0rc1' +__version__ = '2.0.0rc2' #: What ``from proteus import *`` binds. It is that surface, not an #: inventory of submodules: several exist that are deliberately absent, @@ -95,7 +95,6 @@ "cmeshTools", "cnumericalFlux", "cTwophaseDarcyCoefficients", - "cADR", "WaveTools", "Context", "BoundaryConditions", diff --git a/proteus/_kernel_aliases.py b/proteus/_kernel_aliases.py new file mode 100644 index 0000000000..4bfdd1fc10 --- /dev/null +++ b/proteus/_kernel_aliases.py @@ -0,0 +1,88 @@ +"""Deprecated import paths of the kernel packages (C49 R1). + +proteus.mprans, proteus.richards, proteus.m_comp_co2 and proteus.elastoplastic became proteus.kernels, and a few modules +of proteus.mprans went elsewhere (SpatialTools and BoundaryConditions were merged into proteus.SpatialTools and +proteus.BoundaryConditions, BodyDynamics went to proteus.mbd, MeshSmoothing, MoveMeshMonitor, cMoveMeshMonitor and +cArgumentsDict to proteus). Each old package is a thin ``__init__`` that calls :func:`install`: ``proteus.mprans.X`` +(``import``, ``from ... import``, a dotted use after an import) is then the very module object of its new home, so +``proteus.mprans.RANS2P is proteus.kernels.RANS2P`` and classes report their new module path. The old paths warn once +per package with a DeprecationWarning, stay through 2.0.x and are removed at 2.1. + +What an alias cannot do: Cython ``cimport`` (update it), and ``proteus.richards.ADR`` / ``cADR`` (removed with the +Richards ADR model, no replacement: proteus.kernels.ADR is the unrelated top-level ADR model). +""" +import importlib +import importlib.abc +import importlib.util +import sys +import warnings + +_HERE_TO_PROTEUS = ("MeshSmoothing", "MoveMeshMonitor", "cMoveMeshMonitor", "cArgumentsDict") + +#: old package -> {submodule: new module path, or None when it was removed}; every other submodule of an old package +#: is the one of the same name in proteus.kernels +_SPECIAL = { + "proteus.mprans": dict({"SpatialTools": "proteus.SpatialTools", + "BoundaryConditions": "proteus.BoundaryConditions", + "BodyDynamics": "proteus.mbd.BodyDynamics"}, + **{name: "proteus." + name for name in _HERE_TO_PROTEUS}), + "proteus.richards": {"ADR": None, "cADR": None}, + "proteus.m_comp_co2": {}, + "proteus.elastoplastic": {}, +} + + +def _target(fullname): + package, _, name = fullname.rpartition(".") + table = _SPECIAL.get(package) + if table is None: + return None + new = table.get(name, "proteus.kernels." + name) + if new is None: + return None + try: + return new if importlib.util.find_spec(new) is not None else None + except ModuleNotFoundError: + return None + + +class _AliasFinder(importlib.abc.MetaPathFinder, importlib.abc.Loader): + def find_spec(self, fullname, path=None, target=None): + new = _target(fullname) + if new is None: + return None + spec = importlib.util.spec_from_loader(fullname, self) + spec.loader_state = {"target": new} + return spec + + def create_module(self, spec): + module = importlib.import_module(spec.loader_state["target"]) + spec.loader_state["spec"] = module.__spec__ # the import system is about to replace it with this alias's + return module + + def exec_module(self, module): + module.__spec__ = module.__spec__.loader_state["spec"] + + +_FINDER = _AliasFinder() + + +def install(package): + """Called by the ``__init__`` of an old package: warn, and make its submodules aliases (and attributes) of the new ones.""" + warnings.warn("%s is deprecated: the kernels are in proteus.kernels (SpatialTools and BoundaryConditions in " + "proteus.SpatialTools and proteus.BoundaryConditions, BodyDynamics in proteus.mbd); the old path " + "stays through 2.0.x and is removed at 2.1" % package, DeprecationWarning, stacklevel=3) + if _FINDER not in sys.meta_path: + sys.meta_path.insert(0, _FINDER) + + def __getattr__(name, _package=package): + # proteus.mprans.RANS2P after only `import proteus.mprans`, as the old package's submodule attributes did + # (not `__path__` and the other module attributes) + if name.startswith("__"): + raise AttributeError(name) + try: + return importlib.import_module("%s.%s" % (_package, name)) + except ModuleNotFoundError: + raise AttributeError("module %r has no attribute %r" % (_package, name)) from None + + sys.modules[package].__getattr__ = __getattr__ diff --git a/proteus/cADR.py b/proteus/cADR.py new file mode 100644 index 0000000000..e4a63019d4 --- /dev/null +++ b/proteus/cADR.py @@ -0,0 +1,8 @@ +"""Deprecated: the ADR extension is proteus.kernels.cADR (C49 R1). ``proteus.cADR`` is that module, through 2.0.x.""" +import sys +import warnings + +from proteus.kernels import cADR as _cADR + +warnings.warn("proteus.cADR is deprecated: use proteus.kernels.cADR (removed at 2.1)", DeprecationWarning, stacklevel=2) +sys.modules[__name__] = _cADR diff --git a/proteus/mprans/cMoveMeshMonitor.pyx b/proteus/cMoveMeshMonitor.pyx similarity index 99% rename from proteus/mprans/cMoveMeshMonitor.pyx rename to proteus/cMoveMeshMonitor.pyx index 553eb830c2..13e59bd857 100644 --- a/proteus/mprans/cMoveMeshMonitor.pyx +++ b/proteus/cMoveMeshMonitor.pyx @@ -10,8 +10,8 @@ from libcpp cimport bool from proteus.Profiling import logEvent INDEX_DTYPE = np.dtype('i%d' % sizeof(proteus_index_t)) # dtype of proteus_index_t (index_type.h) -from proteus.mprans import MeshSmoothing as ms -from proteus.mprans cimport MeshSmoothing as ms +from proteus import MeshSmoothing as ms +from proteus cimport MeshSmoothing as ms from proteus import Comm from mpi4py import MPI diff --git a/proteus/elastoplastic/__init__.py b/proteus/elastoplastic/__init__.py index 954f14b54b..9b79a88fc5 100644 --- a/proteus/elastoplastic/__init__.py +++ b/proteus/elastoplastic/__init__.py @@ -1,6 +1,6 @@ -""" -Modules for simulating elastic and plastic materials -""" +"""Deprecated: the elastoplastic kernel is in proteus.kernels (C49 R1); see proteus._kernel_aliases.""" +from proteus import _kernel_aliases -__all__ = ["ElastoPlastic", - "cElastoPlastic"] \ No newline at end of file +_kernel_aliases.install(__name__) + +__all__ = ["ElastoPlastic", "cElastoPlastic"] diff --git a/proteus/gwvd/GwvdCoefficients.py b/proteus/gwvd/GwvdCoefficients.py deleted file mode 100644 index 393ece79fe..0000000000 --- a/proteus/gwvd/GwvdCoefficients.py +++ /dev/null @@ -1,265 +0,0 @@ -""" -Variable-density groundwater flow and transport coefficients (continuous Galerkin path). - -Ported from erdc/proteus-gwvd@14961d2: `src/GwvdCoefficients.py` (classes) and -`src/gwvdCoefficients.c` (`density_eval`, `knabnerFrolkovicConsistentVelCorrection_Triangle_P1`, -`vdgroundwater_mod2_FlowCoefficientsEvaluate`, `vdgroundwater_mod2_TransportCoefficientsEvaluate`). -The primary variables are the freshwater head h and the normalized mass fraction c (`mf`). -The flow "velocity" handed to transport is the mass flux rho*q from the flow model's velocity -post-processing (`conservativeFlux`). -""" -import numpy as np -from proteus import TransportCoefficients -from proteus import FemTools -from proteus.Profiling import logEvent - - -def density_eval(mf, epsilon, rho_fw): - """Linear density relation rho = rho_fw (1 + epsilon c).""" - return rho_fw * (1.0 + epsilon * mf) - - -def var_visc(mf, mf_s): - """Relative viscosity of Lever & Jackson (1985), as in the 2012 code (a ratio, not a viscosity).""" - mf_a = mf * mf_s - return 1.0 + 1.85 * mf_a - 4.1 * mf_a**2 + 44.5 * mf_a**3 - - -def knabnerFrolkovicConsistentVelCorrection_Triangle_P1(epsilon, c_l2g, c_dof, J, Jinv, gravity, - q_rhog_consistent, eps_tol=1.0e-9): - """Knabner-Frolkovic (1996) consistent rho*g on P1 triangles, Eqs. 3.3-3.16. - - Writes J^{-T} hhat into q_rhog_consistent (nElements x 2), where hhat holds the reference-element - derivatives of the integrated buoyancy term. For the linear density used here the exact integral - is the mean of the two vertex values, which is what the 2012 C code evaluates. - """ - JeT = np.swapaxes(J[:, 0], 1, 2) - JeTinv = np.swapaxes(Jinv[:, 0], 1, 2) - ghat = np.einsum('eij,j->ei', JeT, gravity) - c_e = c_dof[c_l2g[:, :3]] - h1 = np.where(np.abs(c_e[:, 1] - c_e[:, 0]) <= eps_tol, - epsilon * c_e[:, 0], 0.5 * epsilon * (c_e[:, 1] + c_e[:, 0])) - h2 = np.where(np.abs(c_e[:, 2] - c_e[:, 0]) <= eps_tol, - epsilon * c_e[:, 0], 0.5 * epsilon * (c_e[:, 2] + c_e[:, 0])) - h_hat = np.stack([ghat[:, 0] * h1, ghat[:, 1] * h2], axis=1) - q_rhog_consistent[:] = np.einsum('eij,ej->ei', JeTinv, h_hat) - - -class VariableDensity_mod2_FlowEquationCoefficients(TransportCoefficients.TC_base): - """ - Variable-density subsurface flow in non-divergence (mod2) form for the freshwater head h: - - S rho h_t + div(f - a grad h) + r = 0, - a = k rho_fw g rho / mu, f = -a epsilon c e_z (or -a (rho g)~ with the consistent velocity), - r = omega (drho/dc) c_t / rho. - - The mass fraction c and its time derivative come from the transport model. - """ - - def __init__(self, aOfX=None, rOfX=None, bOfX=None, S=1.0, omega=.3, epsilon=.025, rho_fw=1000.0, - gc=9.8, Kx=1.0e-10, Ky=1.0e-10, Kz=1.0e-10, mu=1.0e-3, mf_s=0.167, drho_dmf=200.0, - rho_source=0.0, T_model=None, C_model=None, flowModelIndex=0, transModelIndex=1, - cModelIndex=2, nc=1, nd=2, consistentVelocityFlag=0, consistentVelocityFunction=None, - variableViscosityFlag=0, rho_eval=None, rhoInt_eval=None, gravity=None, - getInterface=None, Height=1.0): - self.aOfX = aOfX - self.rOfX = rOfX - self.bOfX = bOfX - self.omega = omega - self.epsilon = epsilon - self.S = S - self.gc = gc - self.rho_fw = rho_fw - self.Kx = Kx - self.Ky = Ky - self.Kz = Kz - self.mu = mu - self.mf_s = mf_s - self.rho_source = rho_source - self.nd = nd - self.drho_dmf = drho_dmf - self.T_model = T_model - self.C_model = C_model - self.getInterface = getInterface - self.Height = Height - self.consistentVelocityFlag = consistentVelocityFlag # 0 none, 1 Knabner-Frolkovic 96 - self.variableViscosityFlag = variableViscosityFlag - if C_model is not None: - raise NotImplementedError("surface-water coupling (C_model) is not ported") - if consistentVelocityFlag == 1 and nd != 2: - raise NotImplementedError("only the P1 triangle consistent velocity is ported") - mass, advection, diffusion, potential, reaction, hamiltonian = {}, {}, {}, {}, {}, {} - for i in range(nc): - mass[i] = {i: 'linear'} - advection[i] = {i: 'constant'} - diffusion[i] = {i: {i: 'constant'}} - potential[i] = {i: 'u'} - reaction[i] = {i: 'constant'} - TransportCoefficients.TC_base.__init__(self, nc, mass, advection, diffusion, potential, - reaction, hamiltonian, variableNames=['h']) - self.transModelIndex = transModelIndex - self.flowModelIndex = flowModelIndex - self.cModelIndex = cModelIndex - self.q_mf = None - self.q_mfdt = None - self.ebqe_mf = None - self.ebqe_mfdt = None - self.ebq_mf = None - self.ebq_mfdt = None - self.consistentVelocityFunction = consistentVelocityFunction - self.q_rhog_consistent = None - self.rho_eval = rho_eval - self.rhoInt_eval = rhoInt_eval - self.gravity = gravity - - def preStep(self, t, firstStep=False): - """Build the consistent rho*g from the current mass fraction, if requested.""" - if self.consistentVelocityFlag == 1 and self.T_model is not None: - assert self.transModel.u[0].femSpace.isSpace('C0',('lagrange','bernstein'),1,'simplex') - knabnerFrolkovicConsistentVelCorrection_Triangle_P1(self.epsilon, - self.transModel.u[0].femSpace.dofMap.l2g, - self.transModel.u[0].dof, - self.model.q['J'], - self.model.q['inverse(J)'], - np.asarray(self.gravity, 'd'), - self.q_rhog_consistent) - - def initializeMesh(self, mesh): - self.elementBoundaryElements = mesh.elementBoundaryElementsArray - self.exteriorElementBoundaries = mesh.exteriorElementBoundariesArray - - def attachModels(self, modelList): - self.model = modelList[self.flowModelIndex] - if self.T_model is not None: - self.transModel = modelList[self.transModelIndex] - self.q_mf = self.transModel.q[('u', 0)] - self.q_mfdt = self.transModel.q[('mt', 0)] - self.ebqe_mf = self.transModel.ebqe[('u', 0)] - self.ebqe_mfdt = np.zeros(self.ebqe_mf.shape, 'd') - if ('u', 0) in self.transModel.ebq: - self.ebq_mf = self.transModel.ebq[('u', 0)] - self.ebq_mfdt = np.zeros(self.ebq_mf.shape, 'd') - if self.consistentVelocityFlag != 0: - self.q_rhog_consistent = np.zeros((self.q_mf.shape[0], self.nd), 'd') - - def evaluate(self, t, c): - if self.q_mf is not None and c[('u', 0)].shape == self.q_mf.shape: - mf, mfdt, b_flag = self.q_mf, self.q_mfdt, 0 - elif self.ebqe_mf is not None and c[('u', 0)].shape == self.ebqe_mf.shape: - mf, mfdt, b_flag = self.ebqe_mf, self.ebqe_mfdt, 1 - elif self.ebq_mf is not None and c[('u', 0)].shape == self.ebq_mf.shape: - # as in 2012: element-boundary points have no c_t, so the coefficients are left unset - return - else: - raise RuntimeError("no mass fraction for points of shape %s" % (c[('u', 0)].shape,)) - nd = self.nd - a = c[('a', 0, 0)] - assert a.shape[-1] == nd * nd, "expected full (non-sparse) diffusion storage" - density = density_eval(mf, self.epsilon, self.rho_fw) - logEvent("gwvd flow: t=%g b_flag=%d max|c_t|=%g" % (t, b_flag, np.abs(mfdt).max()), level=5) - c[('m', 0)][:] = c[('u', 0)] * self.S * density # replaced by the time integrator - c[('dm', 0, 0)][:] = self.S * density - c[('r', 0)][:] = self.drho_dmf * mfdt / density - K = [self.Kx, self.Ky, self.Kz][:nd] - denom = self.mu if self.variableViscosityFlag == 0 else var_visc(mf, self.mf_s) - a.fill(0.0) - for I in range(nd): - a[..., I * nd + I] = K[I] * self.gc * self.rho_fw * density / denom - f, df = c[('f', 0)], c[('df', 0, 0)] - df.fill(0.0) - if self.consistentVelocityFlag == 1: - if b_flag == 0: - rhog = self.q_rhog_consistent[:, np.newaxis, :] - else: - eN = self.elementBoundaryElements[self.exteriorElementBoundaries, 0] - rhog = self.q_rhog_consistent[eN][:, np.newaxis, :] - A = a.reshape(a.shape[:-1] + (nd, nd)) - f[:] = -np.einsum('...ij,...j->...i', A, np.broadcast_to(rhog, f.shape)) - else: - f.fill(0.0) - f[..., nd - 1] = -a[..., (nd - 1) * nd + nd - 1] * self.epsilon * mf - - -class VDGroundwater_mod2_TransportCoefficients(TransportCoefficients.TC_base): - """ - Mass-fraction transport in advective (Hamilton-Jacobi) form driven by the flow model's mass flux v: - - omega rho c_t + v . grad c - div(a grad c) = 0, - a = rho d omega I + alpha_T |v| I + (alpha_L - alpha_T) v v^T / |v|. - """ - - def __init__(self, nc=1, nd=2, omega=0.3, alpha_L=1.0, alpha_T=0.2, rho_fw=1000, d=1.3e-9, - epsilon=0.0, rho_source=0.0, mf_source=0.0, flowModelIndex=0, transModelIndex=1, - cModelIndex=2, C_Model=None, F_Model=0, getInterface=None, Height=1.0): - self.nd = nd - self.omega = omega - self.nc = nc - self.d = d - self.alpha_L = alpha_L - self.alpha_T = alpha_T - self.rho_fw = rho_fw - self.epsilon = epsilon - self.rho_source = rho_source - self.mf_source = mf_source - self.F_Model = F_Model - self.C_Model = C_Model - self.flowModelIndex = flowModelIndex - self.transModelIndex = transModelIndex - self.cModelIndex = cModelIndex - self.getInterface = getInterface - self.Height = Height - if C_Model is not None: - raise NotImplementedError("surface-water coupling (C_Model) is not ported") - mass, advection, diffusion, potential, reaction, hamiltonian = {}, {}, {}, {}, {}, {} - for i in range(nc): - mass[i] = {i: 'linear'} - advection[i] = {i: 'linear'} - diffusion[i] = {i: {i: 'constant'}} - potential[i] = {i: 'u'} - reaction[i] = {i: 'linear'} - hamiltonian[i] = {i: 'linear'} - TransportCoefficients.TC_base.__init__(self, nc, mass, advection, diffusion, potential, - reaction, hamiltonian, variableNames=['mf']) - - def attachModels(self, modelList): - self.model = modelList[self.transModelIndex] - if self.F_Model is not None: - flow = modelList[self.flowModelIndex] - self.flowModel = flow - self.q_v = flow.q[('velocity', 0)] - self.ebq_v = flow.ebq.get(('velocity', 0)) - self.ebqe_v = flow.ebqe[('velocity', 0)] - self.ebq_global_v = flow.ebq_global.get(('velocity', 0)) - - def evaluate(self, t, c): - shape = c[('df', 0, 0)].shape - for v in (self.q_v, self.ebq_v, self.ebqe_v, self.ebq_global_v): - if v is not None and v.shape == shape: - break - else: - raise RuntimeError("no flow velocity for points of shape %s" % (shape,)) - nd = self.nd - a = c[('a', 0, 0)] - assert a.shape[-1] == nd * nd, "expected full (non-sparse) diffusion storage" - u = c[('u', 0)] - density = density_eval(u, self.epsilon, self.rho_fw) - c[('m', 0)][:] = u # replaced by NonConservativeBackwardEuler: m_t = dm (u - u_last)/dt - c[('dm', 0, 0)][:] = self.omega * density - c[('r', 0)].fill(0.0) - c[('dr', 0, 0)].fill(0.0) - c[('f', 0)].fill(0.0) - c[('df', 0, 0)].fill(0.0) - c[('H', 0)][:] = np.einsum('...i,...i->...', c[('grad(u)', 0)], v) - c[('dH', 0, 0)][:] = v - norm_v = np.sqrt(np.einsum('...i,...i->...', v, v)) - safe = np.where(norm_v > 0.0, norm_v, 1.0) - a.fill(0.0) - for I in range(nd): - a[..., I * nd + I] = (density * self.d * self.omega - + np.where(norm_v > 0.0, - self.alpha_T * norm_v - + (self.alpha_L - self.alpha_T) * v[..., I]**2 / safe, 0.0)) - for J in range(I + 1, nd): - off = np.where(norm_v > 0.0, (self.alpha_L - self.alpha_T) * v[..., I] * v[..., J] / safe, 0.0) - a[..., I * nd + J] = off - a[..., J * nd + I] = off diff --git a/proteus/gwvd/Gwvd_consolidated_classes.py b/proteus/gwvd/Gwvd_consolidated_classes.py deleted file mode 100644 index 416934f96c..0000000000 --- a/proteus/gwvd/Gwvd_consolidated_classes.py +++ /dev/null @@ -1,148 +0,0 @@ -""" -Time integration, step control and iterative split-operator classes used by the 2012 gwvd decks. - -Ported from erdc/proteus-gwvd@14961d2 `src/Gwvd_consolidated_classes.py`: only the classes the -continuous Galerkin decks select (`Fixed_dt_controller_systemit`, `NonConservativeBackwardEuler`, -`ISO_fixed_MinModelStep`). -""" -import proteus.StepControl -import proteus.TimeIntegration -import proteus.SplitOperator -from proteus.Comm import globalMax -from proteus.Profiling import logEvent - - -class Fixed_dt_controller_systemit(proteus.StepControl.Min_dt_controller): - """Fixed model step dt = nOptions.DT, for the iterated (ISO) coupling of flow and transport.""" - - def __init__(self, model, nOptions): - proteus.StepControl.Min_dt_controller.__init__(self, model, nOptions) - self.dt = nOptions.DT - self.dt_model_last = None - model.levelModelList[-1].timeIntegration.isAdaptive = True # needed by the ISO controller - - def initialize_dt_model(self, t0, tOut): - self.saveSolution() - self.dt_model = self.dt - if self.dt_model_last is None: - self.dt_model_last = self.dt_model - self.set_dt_allLevels() - self.substeps = [self.t_model] - logEvent("Initializing time step on model %s to dt = %12.5e" % (self.model.name, self.dt_model), level=1) - - def choose_dt_model(self): - self.solverFailures = 0 - self.errorFailures = 0 - self.saveSolution() - self.dt_model = self.dt - if self.dt_model_last is None: - self.dt_model_last = self.dt_model - self.set_dt_allLevels() - self.setSubsteps([self.t_model]) - - def stepExact_model(self, tOut): - pass - - -class NonConservativeBackwardEuler(proteus.TimeIntegration.BackwardEuler): - """Backward Euler on the primary variable: m_t = dm (u - u_last)/dt, with dm frozen at the new iterate. - - Until the time history is initialized, m_t is reported as zero. Current proteus spins up model 0 - (the flow) before the transport history exists, when u_last is still zero and dt is the default - 1.0; the flow source omega (drho/dc) c_t / rho would then see a fictitious c_t = omega rho c. - """ - - def __init__(self, transport, integrateInterpolationPoints=False): - proteus.TimeIntegration.BackwardEuler.__init__(self, transport, - integrateInterpolationPoints=integrateInterpolationPoints) - self.historyInitialized = False - - def initializeTimeHistory(self, resetFromDOF=True): - proteus.TimeIntegration.BackwardEuler.initializeTimeHistory(self, resetFromDOF) - self.historyInitialized = True - - def calculateElementCoefficients(self, q): - self.calculateCoefs() - if not self.historyInitialized: - for ci in self.m_last.keys(): - self.m_tmp[ci][:] = q[('u', ci)] - q[('mt', ci)].fill(0.0) - return - for ci in self.m_last.keys(): - self.m_tmp[ci][:] = q[('u', ci)] - q[('mt', ci)][:] = q[('u', ci)] - q[('mt', ci)] -= self.m_last[ci] - q[('mt', ci)] /= self.dt - q[('mt', ci)] *= q[('dm', ci, ci)] - for cj in range(self.nc): - if ('dmt', ci, cj) in q: - q[('dmt', ci, cj)][:] = q[('dm', ci, cj)] - q[('dmt', ci, cj)] /= self.dt - if ('dm_sge', ci, cj) in q and ('dmt_sge', ci, cj) in q: - q[('dmt_sge', ci, cj)][:] = q[('dm_sge', ci, cj)] - q[('dmt_sge', ci, cj)] /= self.dt - - def calculateGeneralizedInterpolationCoefficients(self, cip): - if not self.integrateInterpolationPoints: - return - for ci in self.m_ip_last.keys(): - self.m_ip_tmp[ci][:] = cip[('u', ci)] - cip[('mt', ci)][:] = cip[('u', ci)] - cip[('mt', ci)] -= self.m_ip_last[ci] - cip[('mt', ci)] /= self.dt - cip[('mt', ci)] *= cip[('dm', ci, ci)] - for cj in range(self.nc): - if ('dmt', ci, cj) in cip: - cip[('dmt', ci, cj)][:] = cip[('dm', ci, cj)] - cip[('dmt', ci, cj)] /= self.dt - if ('dmt_sge', ci, cj) in cip: - cip[('dmt_sge', ci, cj)][:] = cip[('dm_sge', ci, cj)] - cip[('dmt_sge', ci, cj)] /= self.dt - - -class ISO_fixed_MinModelStep(proteus.SplitOperator.ISO_fixed_MinAdaptiveModelStep): - """ - Iterate flow and transport within a step (Povich 2013, Sec. 4.5) until the max norm of the owned - residuals of both models is below atol_iso, then advance. - """ - - def __init__(self, modelList, system=proteus.SplitOperator.defaultSystem, stepExact=False, atol_iso=1.e-8): - proteus.SplitOperator.ISO_fixed_MinAdaptiveModelStep.__init__(self, modelList, system, stepExact) - self.atol_iso = atol_iso - self.convergence_flag = False - self.velocity_Postprocess = False - - def setFromOptions(self, soOptions): - self.velocity_Postprocess = False - if 'atol_iso' in dir(soOptions): - self.atol_iso = soOptions.atol_iso - if 'velocity_Postprocess' in dir(soOptions): - self.velocity_Postprocess = soOptions.velocity_Postprocess - - def converged(self): - if self.convergence_flag and self.its != 0: - self.its = 0 - self.convergence_flag = False - return True - return False - - def SysNorm(self, rSys): - # The 2012 code takes the signed maximum of each residual (not max |r|), so negative - # residuals never block convergence. Kept for fidelity with the published runs. - return max(globalMax(float(r.max())) for r in rSys) - - def sequenceTaken(self): - self.its += 1 - rSys = [] - for model in self.modelList: - lm = model.levelModelList[-1] - lm.getResidual(model.uList[-1], model.rList[-1]) - rSys.append(model.rList[-1][:lm.mesh.subdomainMesh.nNodes_owned]) - rNorm = self.SysNorm(rSys) - logEvent("ISO iteration %d: max residual %12.5e (atol_iso %12.5e)" % (self.its, rNorm, self.atol_iso), level=1) - if rNorm < self.atol_iso and self.its != 0: - self.convergence_flag = True - if self.convergence_flag: - for model in self.modelList: - model.stepController.updateTimeHistory() - model.stepController.choose_dt_model() diff --git a/proteus/gwvd/__init__.py b/proteus/gwvd/__init__.py deleted file mode 100644 index 9cdd21640a..0000000000 --- a/proteus/gwvd/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -""" -Variable-density groundwater flow and transport (Povich et al. 2013, Comput. Geosci. 17:529). - -Port of the continuous Galerkin path of erdc/proteus-gwvd at commit 14961d2 (2012-07-31): the -mod2 flow and transport coefficients, the Knabner-Frolkovic consistent-velocity correction and the -time-integration, step-control and iterative split-operator classes the 2012 decks use. The C -coefficient evaluators are reimplemented with numpy. -""" -__all__ = ["GwvdCoefficients", "Gwvd_consolidated_classes"] diff --git a/proteus/mprans/.gitignore b/proteus/kernels/.gitignore similarity index 100% rename from proteus/mprans/.gitignore rename to proteus/kernels/.gitignore diff --git a/proteus/ADR.cpp b/proteus/kernels/ADR.cpp similarity index 100% rename from proteus/ADR.cpp rename to proteus/kernels/ADR.cpp diff --git a/proteus/ADR.h b/proteus/kernels/ADR.h similarity index 99% rename from proteus/ADR.h rename to proteus/kernels/ADR.h index 936c4ae4ea..bb8fd3e205 100644 --- a/proteus/ADR.h +++ b/proteus/kernels/ADR.h @@ -17,7 +17,7 @@ #include "cutquadric.h" #include "UnfittedKernels.h" #include "Unfitted.h" -#include "mprans/ArgumentsDict.h" +#include "ArgumentsDict.h" #include "pyarray.h" namespace py = pybind11; diff --git a/proteus/ADR.py b/proteus/kernels/ADR.py similarity index 99% rename from proteus/ADR.py rename to proteus/kernels/ADR.py index 9722c96c85..9bc1c89e46 100644 --- a/proteus/ADR.py +++ b/proteus/kernels/ADR.py @@ -21,8 +21,8 @@ from proteus.TransportCoefficients import TC_base from proteus.SubgridError import SGE_base from proteus.ShockCapturing import ShockCapturing_base -from proteus.cADR import * -from proteus.mprans import cArgumentsDict +from proteus.kernels.cADR import * +from proteus import cArgumentsDict import proteus.NumericalFlux import proteus.Transport diff --git a/proteus/mprans/AddedMass.cpp b/proteus/kernels/AddedMass.cpp similarity index 100% rename from proteus/mprans/AddedMass.cpp rename to proteus/kernels/AddedMass.cpp diff --git a/proteus/mprans/AddedMass.h b/proteus/kernels/AddedMass.h similarity index 100% rename from proteus/mprans/AddedMass.h rename to proteus/kernels/AddedMass.h diff --git a/proteus/mprans/AddedMass.py b/proteus/kernels/AddedMass.py similarity index 99% rename from proteus/mprans/AddedMass.py rename to proteus/kernels/AddedMass.py index 7798639200..5e5fb85447 100644 --- a/proteus/mprans/AddedMass.py +++ b/proteus/kernels/AddedMass.py @@ -15,7 +15,8 @@ from proteus.TransportCoefficients import TC_base from proteus.SubgridError import SGE_base from proteus.ShockCapturing import ShockCapturing_base -from . import cAddedMass, cArgumentsDict +from . import cAddedMass +from proteus import cArgumentsDict from mpi4py import MPI import proteus.NumericalFlux import proteus.Transport diff --git a/proteus/mprans/ArchiveBeams.py b/proteus/kernels/ArchiveBeams.py similarity index 100% rename from proteus/mprans/ArchiveBeams.py rename to proteus/kernels/ArchiveBeams.py diff --git a/proteus/mprans/CLSVOF.cpp b/proteus/kernels/CLSVOF.cpp similarity index 100% rename from proteus/mprans/CLSVOF.cpp rename to proteus/kernels/CLSVOF.cpp diff --git a/proteus/mprans/CLSVOF.h b/proteus/kernels/CLSVOF.h similarity index 100% rename from proteus/mprans/CLSVOF.h rename to proteus/kernels/CLSVOF.h diff --git a/proteus/mprans/CLSVOF.py b/proteus/kernels/CLSVOF.py similarity index 99% rename from proteus/mprans/CLSVOF.py rename to proteus/kernels/CLSVOF.py index 200dd0c16a..f411e9ff5e 100644 --- a/proteus/mprans/CLSVOF.py +++ b/proteus/kernels/CLSVOF.py @@ -1,13 +1,13 @@ import proteus import proteus.MeshTools -from proteus.mprans.cCLSVOF import * +from proteus.kernels.cCLSVOF import * import numpy as np from proteus import cmeshTools from proteus.Transport import OneLevelTransport from proteus.Transport import TC_base, NonlinearEquation, Quadrature from proteus.Transport import logEvent, memory, FluxBoundaryConditions, Comm from proteus.Transport import cfemIntegrals -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.LinearAlgebraTools import proteus.NonlinearSolvers import proteus.NumericalFlux diff --git a/proteus/mprans/Dissipation.cpp b/proteus/kernels/Dissipation.cpp similarity index 100% rename from proteus/mprans/Dissipation.cpp rename to proteus/kernels/Dissipation.cpp diff --git a/proteus/mprans/Dissipation.h b/proteus/kernels/Dissipation.h similarity index 100% rename from proteus/mprans/Dissipation.h rename to proteus/kernels/Dissipation.h diff --git a/proteus/mprans/Dissipation.py b/proteus/kernels/Dissipation.py similarity index 99% rename from proteus/mprans/Dissipation.py rename to proteus/kernels/Dissipation.py index 7c2d9c5a18..8a6399e98f 100644 --- a/proteus/mprans/Dissipation.py +++ b/proteus/kernels/Dissipation.py @@ -1,11 +1,11 @@ import proteus -from proteus.mprans.cDissipation import * -from proteus.mprans.cDissipation2D import * +from proteus.kernels.cDissipation import * +from proteus.kernels.cDissipation2D import * import numpy as np from proteus import cmeshTools from proteus import Profiling as prof from proteus import cfemIntegrals -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.Comm import proteus.FemTools import proteus.NonlinearSolvers diff --git a/proteus/mprans/Dissipation2D.cpp b/proteus/kernels/Dissipation2D.cpp similarity index 100% rename from proteus/mprans/Dissipation2D.cpp rename to proteus/kernels/Dissipation2D.cpp diff --git a/proteus/mprans/Dissipation2D.h b/proteus/kernels/Dissipation2D.h similarity index 100% rename from proteus/mprans/Dissipation2D.h rename to proteus/kernels/Dissipation2D.h diff --git a/proteus/elastoplastic/ElastoPlastic.h b/proteus/kernels/ElastoPlastic.h similarity index 99% rename from proteus/elastoplastic/ElastoPlastic.h rename to proteus/kernels/ElastoPlastic.h index d8958ab10b..c401ae1ff9 100644 --- a/proteus/elastoplastic/ElastoPlastic.h +++ b/proteus/kernels/ElastoPlastic.h @@ -18,7 +18,7 @@ #include "tresca.h" #include "druckerPrager.h" #include "mcdp.h" -#include "../mprans/ArgumentsDict.h" +#include "ArgumentsDict.h" #include "pyarray.h" #include "pybind11/pybind11.h" diff --git a/proteus/elastoplastic/ElastoPlastic.py b/proteus/kernels/ElastoPlastic.py similarity index 99% rename from proteus/elastoplastic/ElastoPlastic.py rename to proteus/kernels/ElastoPlastic.py index 37141f9791..38341eae14 100644 --- a/proteus/elastoplastic/ElastoPlastic.py +++ b/proteus/kernels/ElastoPlastic.py @@ -8,7 +8,7 @@ from proteus.Transport import NonlinearEquation, logEvent, memory from proteus.Transport import FluxBoundaryConditions, Comm, cfemIntegrals from proteus.Transport import DOFBoundaryConditions, Quadrature -from proteus.mprans import cArgumentsDict +from proteus import cArgumentsDict import proteus.Transport import proteus.TransportCoefficients diff --git a/proteus/mprans/EntropyViscosity.py b/proteus/kernels/EntropyViscosity.py similarity index 100% rename from proteus/mprans/EntropyViscosity.py rename to proteus/kernels/EntropyViscosity.py diff --git a/proteus/mprans/GN_SW2DCV.cpp b/proteus/kernels/GN_SW2DCV.cpp similarity index 100% rename from proteus/mprans/GN_SW2DCV.cpp rename to proteus/kernels/GN_SW2DCV.cpp diff --git a/proteus/mprans/GN_SW2DCV.h b/proteus/kernels/GN_SW2DCV.h similarity index 100% rename from proteus/mprans/GN_SW2DCV.h rename to proteus/kernels/GN_SW2DCV.h diff --git a/proteus/mprans/GN_SW2DCV.py b/proteus/kernels/GN_SW2DCV.py similarity index 99% rename from proteus/mprans/GN_SW2DCV.py rename to proteus/kernels/GN_SW2DCV.py index 8da54248a5..0c8c8946e2 100644 --- a/proteus/mprans/GN_SW2DCV.py +++ b/proteus/kernels/GN_SW2DCV.py @@ -1,8 +1,8 @@ import proteus from proteus import FemTools from proteus import LinearAlgebraTools as LAT -from proteus.mprans.cGN_SW2DCV import * -from proteus.mprans.SW2DCV import bathymetryAtNodes +from proteus.kernels.cGN_SW2DCV import * +from proteus.kernels.SW2DCV import bathymetryAtNodes import numpy as np from proteus import cmeshTools from proteus.csparsity import CSR_INDEX_DTYPE @@ -10,7 +10,7 @@ from proteus.Transport import Quadrature, logEvent, memory, BackwardEuler from proteus.Transport import FluxBoundaryConditions, Comm, DOFBoundaryConditions from proteus.Transport import cfemIntegrals, globalMax, SparseMat -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.NumericalFlux import proteus.TimeIntegration import proteus.Transport diff --git a/proteus/mprans/Kappa.cpp b/proteus/kernels/Kappa.cpp similarity index 100% rename from proteus/mprans/Kappa.cpp rename to proteus/kernels/Kappa.cpp diff --git a/proteus/mprans/Kappa.h b/proteus/kernels/Kappa.h similarity index 100% rename from proteus/mprans/Kappa.h rename to proteus/kernels/Kappa.h diff --git a/proteus/mprans/Kappa.py b/proteus/kernels/Kappa.py similarity index 99% rename from proteus/mprans/Kappa.py rename to proteus/kernels/Kappa.py index 003ab7ed59..594df646e3 100644 --- a/proteus/mprans/Kappa.py +++ b/proteus/kernels/Kappa.py @@ -1,12 +1,12 @@ import proteus -from proteus.mprans.cKappa import * -from proteus.mprans.cKappa2D import * +from proteus.kernels.cKappa import * +from proteus.kernels.cKappa2D import * from proteus import Profiling as prof import numpy as np from proteus import cmeshTools from proteus.Transport import OneLevelTransport from proteus import cfemIntegrals -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.Comm import proteus.FemTools import proteus.NonlinearSolvers diff --git a/proteus/mprans/Kappa2D.cpp b/proteus/kernels/Kappa2D.cpp similarity index 100% rename from proteus/mprans/Kappa2D.cpp rename to proteus/kernels/Kappa2D.cpp diff --git a/proteus/mprans/Kappa2D.h b/proteus/kernels/Kappa2D.h similarity index 100% rename from proteus/mprans/Kappa2D.h rename to proteus/kernels/Kappa2D.h diff --git a/proteus/mprans/MCorr.cpp b/proteus/kernels/MCorr.cpp similarity index 100% rename from proteus/mprans/MCorr.cpp rename to proteus/kernels/MCorr.cpp diff --git a/proteus/mprans/MCorr.h b/proteus/kernels/MCorr.h similarity index 100% rename from proteus/mprans/MCorr.h rename to proteus/kernels/MCorr.h diff --git a/proteus/mprans/MCorr.py b/proteus/kernels/MCorr.py similarity index 99% rename from proteus/mprans/MCorr.py rename to proteus/kernels/MCorr.py index 6f4d3b8818..5ef22b6bea 100644 --- a/proteus/mprans/MCorr.py +++ b/proteus/kernels/MCorr.py @@ -1,13 +1,13 @@ import proteus from proteus import cfemIntegrals, Norms, Quadrature from proteus.Comm import globalSum -from proteus.mprans.cMCorr import * +from proteus.kernels.cMCorr import * import numpy as np from proteus import cmeshTools from proteus.Transport import OneLevelTransport, logEvent, memory, fabs from proteus.Transport import TC_base, l2Norm, NonlinearEquation from proteus.LinearAlgebraTools import SparseMat, ParVec_petsc4py -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.NonlinearSolvers import proteus.StepControl import proteus.TransportCoefficients diff --git a/proteus/mprans/MCorr3P.cpp b/proteus/kernels/MCorr3P.cpp similarity index 100% rename from proteus/mprans/MCorr3P.cpp rename to proteus/kernels/MCorr3P.cpp diff --git a/proteus/mprans/MCorr3P.h b/proteus/kernels/MCorr3P.h similarity index 100% rename from proteus/mprans/MCorr3P.h rename to proteus/kernels/MCorr3P.h diff --git a/proteus/mprans/MCorr3P.py b/proteus/kernels/MCorr3P.py similarity index 99% rename from proteus/mprans/MCorr3P.py rename to proteus/kernels/MCorr3P.py index 2aeddf1715..834219f601 100644 --- a/proteus/mprans/MCorr3P.py +++ b/proteus/kernels/MCorr3P.py @@ -19,7 +19,7 @@ from proteus.SubgridError import SGE_base from proteus.ShockCapturing import ShockCapturing_base from . import cMCorr3P -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.NonlinearSolvers import proteus.StepControl import proteus.Transport diff --git a/proteus/mprans/MoveMesh.cpp b/proteus/kernels/MoveMesh.cpp similarity index 100% rename from proteus/mprans/MoveMesh.cpp rename to proteus/kernels/MoveMesh.cpp diff --git a/proteus/mprans/MoveMesh.h b/proteus/kernels/MoveMesh.h similarity index 100% rename from proteus/mprans/MoveMesh.h rename to proteus/kernels/MoveMesh.h diff --git a/proteus/mprans/MoveMesh.py b/proteus/kernels/MoveMesh.py similarity index 99% rename from proteus/mprans/MoveMesh.py rename to proteus/kernels/MoveMesh.py index 967d2ccebc..04740a2081 100644 --- a/proteus/mprans/MoveMesh.py +++ b/proteus/kernels/MoveMesh.py @@ -1,13 +1,13 @@ import proteus -from proteus.mprans.cMoveMesh2D import cMoveMesh2D_base -from proteus.mprans.cMoveMesh import cMoveMesh_base +from proteus.kernels.cMoveMesh2D import cMoveMesh2D_base +from proteus.kernels.cMoveMesh import cMoveMesh_base import numpy as np from math import sqrt from proteus.Transport import OneLevelTransport, TC_base, NonlinearEquation from proteus import Quadrature, FemTools, Comm, Archiver, cfemIntegrals from proteus.Profiling import logEvent, memory from proteus import cmeshTools -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.Transport import proteus.TransportCoefficients diff --git a/proteus/mprans/MoveMesh2D.cpp b/proteus/kernels/MoveMesh2D.cpp similarity index 100% rename from proteus/mprans/MoveMesh2D.cpp rename to proteus/kernels/MoveMesh2D.cpp diff --git a/proteus/mprans/MoveMesh2D.h b/proteus/kernels/MoveMesh2D.h similarity index 100% rename from proteus/mprans/MoveMesh2D.h rename to proteus/kernels/MoveMesh2D.h diff --git a/proteus/mprans/NCLS.cpp b/proteus/kernels/NCLS.cpp similarity index 100% rename from proteus/mprans/NCLS.cpp rename to proteus/kernels/NCLS.cpp diff --git a/proteus/mprans/NCLS.h b/proteus/kernels/NCLS.h similarity index 100% rename from proteus/mprans/NCLS.h rename to proteus/kernels/NCLS.h diff --git a/proteus/mprans/NCLS.py b/proteus/kernels/NCLS.py similarity index 99% rename from proteus/mprans/NCLS.py rename to proteus/kernels/NCLS.py index 54a538ab84..0d2e98ad4d 100644 --- a/proteus/mprans/NCLS.py +++ b/proteus/kernels/NCLS.py @@ -1,6 +1,6 @@ import proteus import proteus.MeshTools -from proteus.mprans.cNCLS import * +from proteus.kernels.cNCLS import * import numpy as np from proteus import cmeshTools from proteus.Transport import OneLevelTransport, cfemIntegrals, SparseMat @@ -10,7 +10,7 @@ from proteus.Transport import globalMax, SSP, ExplicitConsistentMassMatrixWithRedistancing from proteus.Comm import globalSum from proteus import Norms -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.NumericalFlux import proteus.ShockCapturing import proteus.SubgridError diff --git a/proteus/mprans/NCLS3P.cpp b/proteus/kernels/NCLS3P.cpp similarity index 100% rename from proteus/mprans/NCLS3P.cpp rename to proteus/kernels/NCLS3P.cpp diff --git a/proteus/mprans/NCLS3P.h b/proteus/kernels/NCLS3P.h similarity index 100% rename from proteus/mprans/NCLS3P.h rename to proteus/kernels/NCLS3P.h diff --git a/proteus/mprans/NCLS3P.py b/proteus/kernels/NCLS3P.py similarity index 99% rename from proteus/mprans/NCLS3P.py rename to proteus/kernels/NCLS3P.py index ef45c5aa25..6e35d7ec91 100644 --- a/proteus/mprans/NCLS3P.py +++ b/proteus/kernels/NCLS3P.py @@ -15,10 +15,10 @@ from proteus.TransportCoefficients import TC_base from proteus.SubgridError import SGE_base from proteus.LinearAlgebraTools import ParVec_petsc4py -from proteus.mprans import EntropyViscosity +from proteus.kernels import EntropyViscosity from proteus.ShockCapturing import ShockCapturing_base from . import cNCLS3P -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.NonlinearSolvers import proteus.NumericalFlux import proteus.ShockCapturing diff --git a/proteus/mprans/Pres.cpp b/proteus/kernels/Pres.cpp similarity index 100% rename from proteus/mprans/Pres.cpp rename to proteus/kernels/Pres.cpp diff --git a/proteus/mprans/Pres.h b/proteus/kernels/Pres.h similarity index 100% rename from proteus/mprans/Pres.h rename to proteus/kernels/Pres.h diff --git a/proteus/mprans/Pres.py b/proteus/kernels/Pres.py similarity index 99% rename from proteus/mprans/Pres.py rename to proteus/kernels/Pres.py index d09aad2f3f..3ee019a3ab 100644 --- a/proteus/mprans/Pres.py +++ b/proteus/kernels/Pres.py @@ -15,7 +15,7 @@ from proteus.SubgridError import SGE_base from proteus.ShockCapturing import ShockCapturing_base from . import cPres -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.NumericalFlux import proteus.Transport @@ -43,7 +43,7 @@ class Coefficients(TC_base): p^{k+1} - p^{k} - phi^{k+1} + \nabla\cdot(\mu \mathbf{u}^{k+1}) = 0 """ #: a closed domain fixes this pressure only up to a constant: NumericalSolution.postStep shifts it to zero - #: integral mean when no Dirichlet condition fixes it (proteus.mprans.PressureNormalization) + #: integral mean when no Dirichlet condition fixes it (proteus.kernels.PressureNormalization) zeroMean = True def __init__(self, diff --git a/proteus/mprans/PresInc.cpp b/proteus/kernels/PresInc.cpp similarity index 100% rename from proteus/mprans/PresInc.cpp rename to proteus/kernels/PresInc.cpp diff --git a/proteus/mprans/PresInc.h b/proteus/kernels/PresInc.h similarity index 100% rename from proteus/mprans/PresInc.h rename to proteus/kernels/PresInc.h diff --git a/proteus/mprans/PresInc.py b/proteus/kernels/PresInc.py similarity index 99% rename from proteus/mprans/PresInc.py rename to proteus/kernels/PresInc.py index bb1a2c2461..5be73540fe 100644 --- a/proteus/mprans/PresInc.py +++ b/proteus/kernels/PresInc.py @@ -17,7 +17,7 @@ from proteus.SubgridError import SGE_base from proteus.ShockCapturing import ShockCapturing_base from . import cPresInc -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.NumericalFlux import proteus.Transport @@ -46,7 +46,7 @@ class Coefficients(TC_base): q^t = (1-\theta_s) v_f + \theta_s v_s """ #: a closed domain fixes this pressure only up to a constant: NumericalSolution.postStep shifts it to zero - #: integral mean when no Dirichlet condition fixes it (proteus.mprans.PressureNormalization) + #: integral mean when no Dirichlet condition fixes it (proteus.kernels.PressureNormalization) zeroMean = True def __init__(self, @@ -798,7 +798,7 @@ def _settleNullSpace(self): partial row back. Collective.""" if not self.coefficients.fixNullSpace: return - from proteus.mprans.PressureNormalization import _hasDirichlet + from proteus.kernels.PressureNormalization import _hasDirichlet if _hasDirichlet(self): log("PresInc: fixNullSpace ignored, a Dirichlet condition fixes the constant", level=1) self.coefficients.fixNullSpace = False diff --git a/proteus/mprans/PresInit.cpp b/proteus/kernels/PresInit.cpp similarity index 100% rename from proteus/mprans/PresInit.cpp rename to proteus/kernels/PresInit.cpp diff --git a/proteus/mprans/PresInit.h b/proteus/kernels/PresInit.h similarity index 100% rename from proteus/mprans/PresInit.h rename to proteus/kernels/PresInit.h diff --git a/proteus/mprans/PresInit.py b/proteus/kernels/PresInit.py similarity index 99% rename from proteus/mprans/PresInit.py rename to proteus/kernels/PresInit.py index ea77b1aa16..9a6ad9e475 100644 --- a/proteus/mprans/PresInit.py +++ b/proteus/kernels/PresInit.py @@ -16,7 +16,7 @@ from proteus.SubgridError import SGE_base from proteus.ShockCapturing import ShockCapturing_base from . import cPresInit -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.Transport @@ -31,7 +31,7 @@ class Coefficients(TC_base): p^{k+1} - p^{k} - phi^{k+1} + \nabla\cdot(\mu \mathbf{u}^{k+1}) = 0 """ #: a closed domain fixes this pressure only up to a constant: NumericalSolution.postStep shifts it to zero - #: integral mean when no Dirichlet condition fixes it (proteus.mprans.PressureNormalization) + #: integral mean when no Dirichlet condition fixes it (proteus.kernels.PressureNormalization) zeroMean = True def __init__(self, diff --git a/proteus/mprans/PressureNormalization.py b/proteus/kernels/PressureNormalization.py similarity index 100% rename from proteus/mprans/PressureNormalization.py rename to proteus/kernels/PressureNormalization.py diff --git a/proteus/mprans/RANS2P.cpp b/proteus/kernels/RANS2P.cpp similarity index 100% rename from proteus/mprans/RANS2P.cpp rename to proteus/kernels/RANS2P.cpp diff --git a/proteus/mprans/RANS2P.h b/proteus/kernels/RANS2P.h similarity index 100% rename from proteus/mprans/RANS2P.h rename to proteus/kernels/RANS2P.h diff --git a/proteus/mprans/RANS2P.py b/proteus/kernels/RANS2P.py similarity index 99% rename from proteus/mprans/RANS2P.py rename to proteus/kernels/RANS2P.py index 2d0efb5b74..fb6a4f81ff 100644 --- a/proteus/mprans/RANS2P.py +++ b/proteus/kernels/RANS2P.py @@ -6,8 +6,8 @@ import proteus from proteus.Gauges import open_history_file, on_hot_start, keep_steps_up_to import sys -from proteus.mprans.cRANS2P import * -from proteus.mprans.cRANS2P2D import * +from proteus.kernels.cRANS2P import * +from proteus.kernels.cRANS2P2D import * from proteus import Profiling from proteus import LinearAlgebraTools as LAT from proteus.Comm import (globalSum, @@ -17,7 +17,7 @@ from proteus import * from proteus.Transport import * from proteus.Transport import OneLevelTransport -from . import cArgumentsDict +from proteus import cArgumentsDict from proteus.csparsity import CSR_INDEX_DTYPE import proteus.NumericalFlux import proteus.Profiling diff --git a/proteus/mprans/RANS2P2D.cpp b/proteus/kernels/RANS2P2D.cpp similarity index 100% rename from proteus/mprans/RANS2P2D.cpp rename to proteus/kernels/RANS2P2D.cpp diff --git a/proteus/mprans/RANS2P2D.h b/proteus/kernels/RANS2P2D.h similarity index 100% rename from proteus/mprans/RANS2P2D.h rename to proteus/kernels/RANS2P2D.h diff --git a/proteus/mprans/RANS2P_IB.cpp b/proteus/kernels/RANS2P_IB.cpp similarity index 100% rename from proteus/mprans/RANS2P_IB.cpp rename to proteus/kernels/RANS2P_IB.cpp diff --git a/proteus/mprans/RANS2P_IB.h b/proteus/kernels/RANS2P_IB.h similarity index 100% rename from proteus/mprans/RANS2P_IB.h rename to proteus/kernels/RANS2P_IB.h diff --git a/proteus/mprans/RANS2P_IB.py b/proteus/kernels/RANS2P_IB.py similarity index 99% rename from proteus/mprans/RANS2P_IB.py rename to proteus/kernels/RANS2P_IB.py index 3af53efbe4..5d17e2766c 100644 --- a/proteus/mprans/RANS2P_IB.py +++ b/proteus/kernels/RANS2P_IB.py @@ -1,6 +1,6 @@ import proteus -import proteus.mprans.RANS2P as RANS2P -from proteus.mprans.cRANS2P_IB import * +import proteus.kernels.RANS2P as RANS2P +from proteus.kernels.cRANS2P_IB import * import numpy as np from proteus import cmeshTools from proteus.csparsity import CSR_INDEX_DTYPE @@ -12,9 +12,9 @@ from proteus import * from proteus.Transport import * from proteus.Transport import OneLevelTransport -from . import cArgumentsDict +from proteus import cArgumentsDict -class Coefficients(proteus.mprans.RANS2P.Coefficients): +class Coefficients(proteus.kernels.RANS2P.Coefficients): _epsFact_solid_is_used = True # the immersed-boundary kernels read it def __init__(self, @@ -426,7 +426,7 @@ def initializeBeams(self): pass -class LevelModel(proteus.mprans.RANS2P.LevelModel): +class LevelModel(proteus.kernels.RANS2P.LevelModel): # def __init__(self, # uDict, # phiDict, diff --git a/proteus/mprans/RANS3PF.cpp b/proteus/kernels/RANS3PF.cpp similarity index 100% rename from proteus/mprans/RANS3PF.cpp rename to proteus/kernels/RANS3PF.cpp diff --git a/proteus/mprans/RANS3PF.h b/proteus/kernels/RANS3PF.h similarity index 100% rename from proteus/mprans/RANS3PF.h rename to proteus/kernels/RANS3PF.h diff --git a/proteus/mprans/RANS3PF.py b/proteus/kernels/RANS3PF.py similarity index 99% rename from proteus/mprans/RANS3PF.py rename to proteus/kernels/RANS3PF.py index 0bd428e1cb..f58aa71f1a 100644 --- a/proteus/mprans/RANS3PF.py +++ b/proteus/kernels/RANS3PF.py @@ -24,7 +24,7 @@ from proteus.ShockCapturing import ShockCapturing_base from . import cRANS3PF from . import cRANS3PF2D -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.NumericalFlux import proteus.Profiling import proteus.ShockCapturing diff --git a/proteus/mprans/RANS3PF2D.cpp b/proteus/kernels/RANS3PF2D.cpp similarity index 100% rename from proteus/mprans/RANS3PF2D.cpp rename to proteus/kernels/RANS3PF2D.cpp diff --git a/proteus/mprans/RANS3PF2D.h b/proteus/kernels/RANS3PF2D.h similarity index 100% rename from proteus/mprans/RANS3PF2D.h rename to proteus/kernels/RANS3PF2D.h diff --git a/proteus/mprans/RANS3PSed.cpp b/proteus/kernels/RANS3PSed.cpp similarity index 100% rename from proteus/mprans/RANS3PSed.cpp rename to proteus/kernels/RANS3PSed.cpp diff --git a/proteus/mprans/RANS3PSed.h b/proteus/kernels/RANS3PSed.h similarity index 100% rename from proteus/mprans/RANS3PSed.h rename to proteus/kernels/RANS3PSed.h diff --git a/proteus/mprans/RANS3PSed.py b/proteus/kernels/RANS3PSed.py similarity index 99% rename from proteus/mprans/RANS3PSed.py rename to proteus/kernels/RANS3PSed.py index 51c2407446..2e691fbdf3 100644 --- a/proteus/mprans/RANS3PSed.py +++ b/proteus/kernels/RANS3PSed.py @@ -23,7 +23,7 @@ from proteus.ShockCapturing import ShockCapturing_base from . import cRANS3PSed from . import cRANS3PSed2D -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.NumericalFlux import proteus.ShockCapturing import proteus.SubgridError diff --git a/proteus/mprans/RANS3PSed2D.cpp b/proteus/kernels/RANS3PSed2D.cpp similarity index 100% rename from proteus/mprans/RANS3PSed2D.cpp rename to proteus/kernels/RANS3PSed2D.cpp diff --git a/proteus/mprans/RANS3PSed2D.h b/proteus/kernels/RANS3PSed2D.h similarity index 100% rename from proteus/mprans/RANS3PSed2D.h rename to proteus/kernels/RANS3PSed2D.h diff --git a/proteus/mprans/RDLS.cpp b/proteus/kernels/RDLS.cpp similarity index 100% rename from proteus/mprans/RDLS.cpp rename to proteus/kernels/RDLS.cpp diff --git a/proteus/mprans/RDLS.h b/proteus/kernels/RDLS.h similarity index 100% rename from proteus/mprans/RDLS.h rename to proteus/kernels/RDLS.h diff --git a/proteus/mprans/RDLS.py b/proteus/kernels/RDLS.py similarity index 99% rename from proteus/mprans/RDLS.py rename to proteus/kernels/RDLS.py index d776858a1c..b710052943 100644 --- a/proteus/mprans/RDLS.py +++ b/proteus/kernels/RDLS.py @@ -1,6 +1,6 @@ import proteus from proteus import TimeIntegration -from proteus.mprans.cRDLS import * +from proteus.kernels.cRDLS import * from proteus.Comm import globalMax import numpy as np from proteus import cmeshTools @@ -8,7 +8,7 @@ from proteus.Transport import TC_base, NonlinearEquation, Quadrature, logEvent from proteus.Transport import cfemIntegrals from proteus.LinearAlgebraTools import ParVec_petsc4py -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.FemTools import proteus.NonlinearSolvers import proteus.ShockCapturing diff --git a/proteus/richards/Richards.h b/proteus/kernels/Richards.h similarity index 99% rename from proteus/richards/Richards.h rename to proteus/kernels/Richards.h index d7e18c7d31..953e98d9f5 100644 --- a/proteus/richards/Richards.h +++ b/proteus/kernels/Richards.h @@ -7,7 +7,7 @@ #include "CompKernel.h" #include "ModelFactory.h" #include "../pskRelations.h" -#include "../mprans/ArgumentsDict.h" +#include "ArgumentsDict.h" #include "pyarray.h" #define nnz nSpace diff --git a/proteus/richards/Richards.py b/proteus/kernels/Richards.py similarity index 99% rename from proteus/richards/Richards.py rename to proteus/kernels/Richards.py index d1701692ab..b5cf00ddc3 100644 --- a/proteus/richards/Richards.py +++ b/proteus/kernels/Richards.py @@ -10,7 +10,7 @@ from proteus.Transport import TC_base, NonlinearEquation, logEvent, memory from proteus.Transport import FluxBoundaryConditions, Comm, cfemIntegrals from proteus.Transport import DOFBoundaryConditions, Quadrature -from proteus.mprans import cArgumentsDict +from proteus import cArgumentsDict from proteus.LinearAlgebraTools import SparseMat from proteus import TimeIntegration from proteus.NonlinearSolvers import ExplicitLumpedMassMatrixForRichards @@ -583,7 +583,7 @@ def attachModels(self, modelList): # quadrature rule. The copy would raise a bare numpy broadcast error on # a size mismatch and say nothing at all if the two rules merely order # their points differently, so check the rules themselves here. - from proteus.mprans.TADR import checkCoupledQuadrature + from proteus.kernels.TADR import checkCoupledQuadrature checkCoupledQuadrature(self.model, 'Richards', self.densityModel, 'density (transport) model') diff --git a/proteus/mprans/SW2D.cpp b/proteus/kernels/SW2D.cpp similarity index 100% rename from proteus/mprans/SW2D.cpp rename to proteus/kernels/SW2D.cpp diff --git a/proteus/mprans/SW2D.h b/proteus/kernels/SW2D.h similarity index 100% rename from proteus/mprans/SW2D.h rename to proteus/kernels/SW2D.h diff --git a/proteus/mprans/SW2D.py b/proteus/kernels/SW2D.py similarity index 99% rename from proteus/mprans/SW2D.py rename to proteus/kernels/SW2D.py index c501d1ce4a..1a66d95b96 100644 --- a/proteus/mprans/SW2D.py +++ b/proteus/kernels/SW2D.py @@ -1,10 +1,10 @@ import proteus -from proteus.mprans.cSW2D import * +from proteus.kernels.cSW2D import * from proteus.Comm import globalMax import numpy as np from proteus import cmeshTools from proteus.Transport import OneLevelTransport -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.NumericalFlux import proteus.ShockCapturing import proteus.SubgridError diff --git a/proteus/mprans/SW2DCV.cpp b/proteus/kernels/SW2DCV.cpp similarity index 100% rename from proteus/mprans/SW2DCV.cpp rename to proteus/kernels/SW2DCV.cpp diff --git a/proteus/mprans/SW2DCV.h b/proteus/kernels/SW2DCV.h similarity index 100% rename from proteus/mprans/SW2DCV.h rename to proteus/kernels/SW2DCV.h diff --git a/proteus/mprans/SW2DCV.py b/proteus/kernels/SW2DCV.py similarity index 99% rename from proteus/mprans/SW2DCV.py rename to proteus/kernels/SW2DCV.py index d830738f03..0c65a11717 100644 --- a/proteus/mprans/SW2DCV.py +++ b/proteus/kernels/SW2DCV.py @@ -1,7 +1,7 @@ import proteus from proteus import FemTools from proteus import LinearAlgebraTools as LAT -from proteus.mprans.cSW2DCV import * +from proteus.kernels.cSW2DCV import * import numpy as np from proteus import cmeshTools from proteus.csparsity import CSR_INDEX_DTYPE @@ -9,7 +9,7 @@ from proteus.Transport import Quadrature, logEvent, memory, BackwardEuler from proteus.Transport import FluxBoundaryConditions, Comm, DOFBoundaryConditions from proteus.Transport import cfemIntegrals, globalMax, SparseMat -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.NumericalFlux import proteus.TimeIntegration import proteus.Transport diff --git a/proteus/mprans/SedClosure.cpp b/proteus/kernels/SedClosure.cpp similarity index 100% rename from proteus/mprans/SedClosure.cpp rename to proteus/kernels/SedClosure.cpp diff --git a/proteus/mprans/SedClosure.h b/proteus/kernels/SedClosure.h similarity index 100% rename from proteus/mprans/SedClosure.h rename to proteus/kernels/SedClosure.h diff --git a/proteus/mprans/TADR.cpp b/proteus/kernels/TADR.cpp similarity index 100% rename from proteus/mprans/TADR.cpp rename to proteus/kernels/TADR.cpp diff --git a/proteus/mprans/TADR.h b/proteus/kernels/TADR.h similarity index 100% rename from proteus/mprans/TADR.h rename to proteus/kernels/TADR.h diff --git a/proteus/mprans/TADR.py b/proteus/kernels/TADR.py similarity index 99% rename from proteus/mprans/TADR.py rename to proteus/kernels/TADR.py index 5303ae45b8..574ce387a8 100644 --- a/proteus/mprans/TADR.py +++ b/proteus/kernels/TADR.py @@ -19,10 +19,10 @@ from proteus.NumericalFlux import Advection_DiagonalUpwind_Diffusion_IIPG_exterior from proteus.LinearAlgebraTools import SparseMat, ParVec_petsc4py from proteus.NonlinearSolvers import ExplicitLumpedMassMatrix,ExplicitConsistentMassMatrixForVOF,TwoStageNewton -from proteus.mprans.cTADR import cTADR_base +from proteus.kernels.cTADR import cTADR_base -from . import cArgumentsDict -from proteus.mprans import EntropyViscosity +from proteus import cArgumentsDict +from proteus.kernels import EntropyViscosity #: Coefficients(diagnostics=...): the run-time diagnostics a TADR model can log, each off by default since it #: costs MPI reductions every step or call. diff --git a/proteus/mprans/VOF.cpp b/proteus/kernels/VOF.cpp similarity index 100% rename from proteus/mprans/VOF.cpp rename to proteus/kernels/VOF.cpp diff --git a/proteus/mprans/VOF.h b/proteus/kernels/VOF.h similarity index 100% rename from proteus/mprans/VOF.h rename to proteus/kernels/VOF.h diff --git a/proteus/mprans/VOF.py b/proteus/kernels/VOF.py similarity index 99% rename from proteus/mprans/VOF.py rename to proteus/kernels/VOF.py index 586955aeb8..522308e319 100644 --- a/proteus/mprans/VOF.py +++ b/proteus/kernels/VOF.py @@ -21,13 +21,13 @@ from proteus.LinearAlgebraTools import SparseMat, ParVec_petsc4py from proteus.NonlinearSolvers import ExplicitLumpedMassMatrix,ExplicitConsistentMassMatrixForVOF,TwoStageNewton from proteus import TimeIntegration -from proteus.mprans.cVOF import * +from proteus.kernels.cVOF import * from proteus import * from proteus.Transport import * from proteus.Transport import OneLevelTransport #from . import cVOF3P -from . import cArgumentsDict -from proteus.mprans import EntropyViscosity +from proteus import cArgumentsDict +from proteus.kernels import EntropyViscosity import proteus.NumericalFlux import proteus.ShockCapturing import proteus.SubgridError diff --git a/proteus/mprans/VOF3P.cpp b/proteus/kernels/VOF3P.cpp similarity index 100% rename from proteus/mprans/VOF3P.cpp rename to proteus/kernels/VOF3P.cpp diff --git a/proteus/mprans/VOF3P.h b/proteus/kernels/VOF3P.h similarity index 100% rename from proteus/mprans/VOF3P.h rename to proteus/kernels/VOF3P.h diff --git a/proteus/mprans/VOF3P.py b/proteus/kernels/VOF3P.py similarity index 99% rename from proteus/mprans/VOF3P.py rename to proteus/kernels/VOF3P.py index 7cccef132e..bbacc403da 100644 --- a/proteus/mprans/VOF3P.py +++ b/proteus/kernels/VOF3P.py @@ -22,8 +22,8 @@ from proteus.NonlinearSolvers import ExplicitLumpedMassMatrix,ExplicitConsistentMassMatrixForVOF,TwoStageNewton from proteus import TimeIntegration from . import cVOF3P -from . import cArgumentsDict -from proteus.mprans import EntropyViscosity +from proteus import cArgumentsDict +from proteus.kernels import EntropyViscosity import proteus.NumericalFlux import proteus.ShockCapturing import proteus.SubgridError diff --git a/proteus/mprans/VOS3P.cpp b/proteus/kernels/VOS3P.cpp similarity index 100% rename from proteus/mprans/VOS3P.cpp rename to proteus/kernels/VOS3P.cpp diff --git a/proteus/mprans/VOS3P.h b/proteus/kernels/VOS3P.h similarity index 100% rename from proteus/mprans/VOS3P.h rename to proteus/kernels/VOS3P.h diff --git a/proteus/mprans/VOS3P.py b/proteus/kernels/VOS3P.py similarity index 99% rename from proteus/mprans/VOS3P.py rename to proteus/kernels/VOS3P.py index 19a133ac2d..7cf5d7d6d0 100644 --- a/proteus/mprans/VOS3P.py +++ b/proteus/kernels/VOS3P.py @@ -22,7 +22,7 @@ from proteus.NonlinearSolvers import ExplicitLumpedMassMatrix,ExplicitConsistentMassMatrixForVOF from proteus import TimeIntegration from . import cVOS3P -from . import cArgumentsDict +from proteus import cArgumentsDict import proteus.NumericalFlux import proteus.ShockCapturing import proteus.SubgridError diff --git a/proteus/kernels/__init__.py b/proteus/kernels/__init__.py new file mode 100644 index 0000000000..f38711247f --- /dev/null +++ b/proteus/kernels/__init__.py @@ -0,0 +1,42 @@ +""" +The model kernels: free surface incompressible flow and fluid/structure interaction (the former proteus.mprans), +variably saturated flow (proteus.richards), compositional two-phase flow (proteus.m_comp_co2), elastic and plastic +solids (proteus.elastoplastic) and the advection-diffusion-reaction model with the unfitted (cut cell) terms +(proteus.ADR). One flat package since C49 R1; the old import paths are deprecated aliases (proteus/_kernel_aliases.py) +that stay through 2.0.x and are removed at 2.1. +""" + +__all__ = ["ADR", + "AddedMass", + "ArchiveBeams", + "CLSVOF", + "Dissipation", + "ElastoPlastic", + "GN_SW2DCV", + "Kappa", + "MCorr", + "MCorr3P", + "MoveMesh", + "NCLS", + "NCLS3P", + "Pres", + "PresInc", + "PresInit", + "RANS2P", + "RANS2P_IB", + "RANS3PF", + "RANS3PSed", + "RDLS", + "Richards", + "SW2D", + "SW2DCV", + "TADR", + "VOF", + "VOF3P", + "VOS3P", + "beamFEM", + "cADR", + "cElastoPlastic", + "cRichards", + "cm_comp_co2", + "m_comp_co2"] diff --git a/proteus/mprans/beamFEM.py b/proteus/kernels/beamFEM.py similarity index 100% rename from proteus/mprans/beamFEM.py rename to proteus/kernels/beamFEM.py diff --git a/proteus/elastoplastic/cElastoPlastic.cpp b/proteus/kernels/cElastoPlastic.cpp similarity index 100% rename from proteus/elastoplastic/cElastoPlastic.cpp rename to proteus/kernels/cElastoPlastic.cpp diff --git a/proteus/richards/cRichards.cpp b/proteus/kernels/cRichards.cpp similarity index 100% rename from proteus/richards/cRichards.cpp rename to proteus/kernels/cRichards.cpp diff --git a/proteus/m_comp_co2/cm_comp_co2.cpp b/proteus/kernels/cm_comp_co2.cpp similarity index 100% rename from proteus/m_comp_co2/cm_comp_co2.cpp rename to proteus/kernels/cm_comp_co2.cpp diff --git a/proteus/m_comp_co2/co2_brine_eos.h b/proteus/kernels/co2_brine_eos.h similarity index 100% rename from proteus/m_comp_co2/co2_brine_eos.h rename to proteus/kernels/co2_brine_eos.h diff --git a/proteus/m_comp_co2/co2_brine_flash.h b/proteus/kernels/co2_brine_flash.h similarity index 100% rename from proteus/m_comp_co2/co2_brine_flash.h rename to proteus/kernels/co2_brine_flash.h diff --git a/proteus/elastoplastic/druckerPrager.h b/proteus/kernels/druckerPrager.h similarity index 100% rename from proteus/elastoplastic/druckerPrager.h rename to proteus/kernels/druckerPrager.h diff --git a/proteus/m_comp_co2/jet2.h b/proteus/kernels/jet2.h similarity index 100% rename from proteus/m_comp_co2/jet2.h rename to proteus/kernels/jet2.h diff --git a/proteus/m_comp_co2/m_comp_co2.h b/proteus/kernels/m_comp_co2.h similarity index 99% rename from proteus/m_comp_co2/m_comp_co2.h rename to proteus/kernels/m_comp_co2.h index 4c72e6a057..bb6d633700 100644 --- a/proteus/m_comp_co2/m_comp_co2.h +++ b/proteus/kernels/m_comp_co2.h @@ -9,7 +9,7 @@ #include #include "CompKernel.h" #include "ModelFactory.h" -#include "../mprans/ArgumentsDict.h" +#include "ArgumentsDict.h" #include "pyarray.h" #include "../pskRelations.h" // Compositional CO2-brine EOS + analytic (p,z) flash (P3). Standalone headers diff --git a/proteus/m_comp_co2/m_comp_co2.py b/proteus/kernels/m_comp_co2.py similarity index 99% rename from proteus/m_comp_co2/m_comp_co2.py rename to proteus/kernels/m_comp_co2.py index 2716af897c..398354740d 100644 --- a/proteus/m_comp_co2/m_comp_co2.py +++ b/proteus/kernels/m_comp_co2.py @@ -11,7 +11,7 @@ from proteus.Transport import TC_base, NonlinearEquation, logEvent, memory from proteus.Transport import FluxBoundaryConditions, Comm, cfemIntegrals from proteus.Transport import DOFBoundaryConditions, Quadrature -from proteus.mprans import cArgumentsDict +from proteus import cArgumentsDict from proteus.LinearAlgebraTools import SparseMat from proteus import TimeIntegration from proteus.NonlinearSolvers import ExplicitLumpedMassMatrixForRichards @@ -880,7 +880,7 @@ def apply_dissolution_flash(self, t): recovers the instantaneous local-equilibrium flash (dissolves in place), finite k_d lets the free-gas plume rise before it dissolves over a slower timescale. X_sat is the physical solubility mass fraction. See - the kernel comment in proteus/m_comp_co2/m_comp_co2.h. + the kernel comment in proteus/kernels/m_comp_co2.h. """ if self.dissolution_mode != 'flash' or self.X_sat <= 0.0: return diff --git a/proteus/elastoplastic/mcdp.h b/proteus/kernels/mcdp.h similarity index 100% rename from proteus/elastoplastic/mcdp.h rename to proteus/kernels/mcdp.h diff --git a/proteus/elastoplastic/mohrCoulomb.h b/proteus/kernels/mohrCoulomb.h similarity index 100% rename from proteus/elastoplastic/mohrCoulomb.h rename to proteus/kernels/mohrCoulomb.h diff --git a/proteus/elastoplastic/mohrCoulomb2.h b/proteus/kernels/mohrCoulomb2.h similarity index 100% rename from proteus/elastoplastic/mohrCoulomb2.h rename to proteus/kernels/mohrCoulomb2.h diff --git a/proteus/elastoplastic/tresca.h b/proteus/kernels/tresca.h similarity index 100% rename from proteus/elastoplastic/tresca.h rename to proteus/kernels/tresca.h diff --git a/proteus/elastoplastic/vonMises.h b/proteus/kernels/vonMises.h similarity index 100% rename from proteus/elastoplastic/vonMises.h rename to proteus/kernels/vonMises.h diff --git a/proteus/m_comp_co2/__init__.py b/proteus/m_comp_co2/__init__.py index 5d5b48589a..66a46b021b 100644 --- a/proteus/m_comp_co2/__init__.py +++ b/proteus/m_comp_co2/__init__.py @@ -1,6 +1,6 @@ -""" -Modules for simulating variably saturated single-phase flow -""" +"""Deprecated: the compositional CO2-brine kernel is in proteus.kernels (C49 R1); see proteus._kernel_aliases.""" +from proteus import _kernel_aliases -__all__ = ["m_comp_co2", - "cm_comp_co2"] +_kernel_aliases.install(__name__) + +__all__ = ["m_comp_co2", "cm_comp_co2"] diff --git a/proteus/mprans/BodyDynamics.py b/proteus/mbd/BodyDynamics.py similarity index 99% rename from proteus/mprans/BodyDynamics.py rename to proteus/mbd/BodyDynamics.py index 7e9f03307f..a832d9d45d 100644 --- a/proteus/mprans/BodyDynamics.py +++ b/proteus/mbd/BodyDynamics.py @@ -16,7 +16,7 @@ class instance acting as a rigid body. To set a shape as a rigid body, use Parameters ---------- - shape: proteus.mprans.SpatialTools.Shape_RANS + shape: proteus.SpatialTools.Shape_RANS Class instance of the shape associated to the rigid body calculations. cfl_target: Optional[float] UNUSED (to implement), sets the maximum displacement of the body diff --git a/proteus/mbd/CouplingFSI.pyx b/proteus/mbd/CouplingFSI.pyx index 290b2b831b..fb3569278d 100644 --- a/proteus/mbd/CouplingFSI.pyx +++ b/proteus/mbd/CouplingFSI.pyx @@ -56,7 +56,7 @@ cdef extern from "index_type.h": #: width of proteus_index_t in index_type.h, same rule as cmeshTools.INDEX_DTYPE _INDEX_DTYPE = np.dtype('i%d' % sizeof(proteus_index_t)) # chrono Python headers -from proteus.mprans import BodyDynamics as bd +from proteus.mbd import BodyDynamics as bd import pychrono as chrono from pychrono import fea as chrono_fea @@ -160,7 +160,7 @@ cdef class ProtChBody: ---------- shape: SpatialTools.Shape instance of shape from proteus.SpatialTools or - proteus.mprans.SpatialTools + proteus.SpatialTools """ assert self.Shape is None, 'Shape '+self.Shape.name+' was already attached' self.Shape = shape diff --git a/proteus/mprans/BoundaryConditions.pxd b/proteus/mprans/BoundaryConditions.pxd deleted file mode 100644 index 76da140831..0000000000 --- a/proteus/mprans/BoundaryConditions.pxd +++ /dev/null @@ -1,201 +0,0 @@ -# cython: language_level=3 -cimport cython -from libcpp cimport bool -cimport numpy as np -from proteus.BoundaryConditions cimport (BC_Base, - BoundaryCondition) -# needed for cython > 0.27 -from proteus cimport BoundaryConditions - -ctypedef double[:,:,:] double_memview3 -ctypedef double[:,:] double_memview2 -ctypedef double[:] double_memview1 -ctypedef int[:] int_memview1 - -# ctypedef double (*cpp_uOfXT) (BC_RANS, double[:], double) - -cdef class BC_RANS(BC_Base): - cdef double[:] zero_array - cdef double f - cdef __cppClass_WavesCharacteristics waves - cdef object body - cdef double[:] wind_speed - cdef double[:, :] body_python_rot_matrix - cdef double[:] body_python_last_pos - cdef double[:] body_python_h - cdef public: - # dirichlet - cdef BoundaryCondition p_dirichlet - cdef BoundaryCondition u_dirichlet - cdef BoundaryCondition v_dirichlet - cdef BoundaryCondition w_dirichlet - cdef BoundaryCondition phi_dirichlet - cdef BoundaryCondition vof_dirichlet - cdef BoundaryCondition k_dirichlet - cdef BoundaryCondition dissipation_dirichlet - cdef BoundaryCondition pAddedMass_dirichlet - # advective - cdef BoundaryCondition p_advective - cdef BoundaryCondition u_advective - cdef BoundaryCondition v_advective - cdef BoundaryCondition w_advective - cdef BoundaryCondition vof_advective - cdef BoundaryCondition k_advective - cdef BoundaryCondition dissipation_advective - #diffusive - cdef BoundaryCondition u_diffusive - cdef BoundaryCondition v_diffusive - cdef BoundaryCondition w_diffusive - cdef BoundaryCondition k_diffusive - cdef BoundaryCondition dissipation_diffusive - # mesh - cdef BoundaryCondition hx_dirichlet - cdef BoundaryCondition hy_dirichlet - cdef BoundaryCondition hz_dirichlet - cdef BoundaryCondition u_stress - cdef BoundaryCondition v_stress - cdef BoundaryCondition w_stress - # sediment solver - cdef BoundaryCondition us_dirichlet - cdef BoundaryCondition vs_dirichlet - cdef BoundaryCondition ws_dirichlet - cdef BoundaryCondition vos_dirichlet - cdef BoundaryCondition us_advective - cdef BoundaryCondition vs_advective - cdef BoundaryCondition ws_advective - cdef BoundaryCondition vos_advective - cdef BoundaryCondition us_diffusive - cdef BoundaryCondition vs_diffusive - cdef BoundaryCondition ws_diffusive - # projection scheme - cdef BoundaryCondition pInit_dirichlet - cdef BoundaryCondition pInc_dirichlet - cdef BoundaryCondition pInit_advective - cdef BoundaryCondition pInc_advective - cdef BoundaryCondition pInit_diffusive - cdef BoundaryCondition pInc_diffusive - # clsvof - cdef BoundaryCondition clsvof_dirichlet - cdef BoundaryCondition clsvof_advective - cdef BoundaryCondition clsvof_diffusive - - - # functions - # cpdef void reset(self) - # cpdef void setNonMaterial(self) - # cpdef void setTank(self) - # cpdef void setFixedNodes(self) - # cpdef void setNoSlip(self) - # cpdef void setFreeSlip(self) - # cpdef void setAtmosphere(self, double[:] orientation=*, double vof_air=*) - # cpdef void setMoveMesh(self, double[:] last_pos, double[:] h=*, double[:,:] rot_matrix=*) - @cython.locals(hx=np.ndarray) - cpdef double[:] __cpp_MoveMesh_h(self, double[:] x, double t) - cpdef double __cpp_MoveMesh_hx(self, double[:] x, double t) - cpdef double __cpp_MoveMesh_hy(self, double[:] x, double t) - cpdef double __cpp_MoveMesh_hz(self, double[:] x, double t) -# @cython.locals(waveHeight=double, wavePhi=double, -# water_speed=double_memview1, x_max=double_memview1, -# u=cython.p_double, H=double) - cdef double __cpp_UnsteadyTwoPhaseVelocityInlet_u_dirichlet(self, double[:] x, double t) - cdef double __cpp_UnsteadyTwoPhaseVelocityInlet_v_dirichlet(self, double[:] x, double t) - cdef double __cpp_UnsteadyTwoPhaseVelocityInlet_w_dirichlet(self, double[:] x, double t) - cdef double __cpp_UnsteadyTwoPhaseVelocityInlet_phi_dirichlet(self, double[:] x, double t) - cdef double __cpp_UnsteadyTwoPhaseVelocityInlet_vof_dirichlet(self, double[:] x, double t) - cdef double __cpp_UnsteadyTwoPhaseVelocityInlet_p_advective(self, double[:] x, double t) - -ctypedef double[:] (*cfvel) (double[3], double) # pointer to velocity function -ctypedef double (*cfeta) (double[3], double) # pointer to eta function -ctypedef double[:] (*cfvelrel) (RelaxationZone, double[3], double) # pointer to velocity function of RelaxationZone class -ctypedef double (*cfphirel) (RelaxationZone, double[3]) # pointer to phi function of RelaxationZone class -ctypedef double (*cfphiwave) (RelaxationZone, double[3]) # pointer to phi function of RelaxationZone class -ctypedef np.float64_t float64_t -ctypedef np.int64_t int64_t - -cdef class RelaxationZone: - cdef double[:] wind_speed - cdef double[:] u_calc # calculated velocity - # wave characteristics (if any) - cdef cfvelrel uu - cdef cfphirel phi - cdef double mwl - cdef cfeta eta - cdef double waveHeight - cdef double wavePhi - cdef double waterSpeed - cdef int nd - cdef double[:] zero_vel - cdef __cppClass_WavesCharacteristics waves - cdef public: - object Shape - str zone_type - double dragAlpha - double dragBeta - double porosity - double epsFact_solid - double epsFact_porous - double vert_axis - double[:] center - double[:] orientation - cpdef void calculate_init(self) - cdef double[:] calculate_vel(self, cython.p_double x, double t) - @cython.locals(xx=double_memview1, waveHeight=double, wavePhi=double, - waterSpeed=double_memview1, x_max=double_memview1, H=double, - u=cython.double[3], o1=double, o2=double, o3=double) - cdef double[:] __cpp_calculate_vel_wave(self, double* x, double t) - cdef double[:] __cpp_calculate_vel_zero(self, double* x, double t) - cdef double calculate_phi(self, double* x) - @cython.locals(d1=double, d2=double, d3=double, phi=double, - o1=double, o2=double, o3=double) - cdef double __cpp_calculate_phi_porous(self, double[3] x) - cdef double __cpp_calculate_phi_porous_sponge(self, double[3] x) - -cdef class RelaxationZoneWaveGenerator: - cdef int nd # dimension - cdef int max_flag # maximum region flag of relaxation zones (initialised in calculate_init) - cdef np.ndarray zones_array # zones array for fast access - cdef public: - dict zones # zones dictionary - object model # model attached to zone - object ar # - # cpdef RelaxationZoneWaveGenerator attachModel(self, dict, int) # needed - # cpdef void attachAuxiliaryVariables(self, dict) # needed - @cython.locals(zones=np.ndarray) - cpdef void calculate_init(self) - cpdef void calculate(self) - @cython.locals(m=object, zone=RelaxationZone, mType=int, nE=int, nk=int, - qx=double_memview3, x=cython.double[3], t=double, nl=int, - q_phi_porous=double_memview2, phi=double, - q_velocity_solid=double_memview3, u=double_memview1, mTypes=int_memview1) - cdef void __cpp_iterate(self) # main iteration loop - - -cdef class __cppClass_WavesCharacteristics: - cdef int vert_axis # vertical axis - # relaxation zone info (if any) - cdef double[:] center # center of zone - cdef double[:] orientation # orientation of zone - # zero array - cdef double[:] zero_vel - cdef double[:] _b_or - cdef double[:] wind_speed - cdef double vof_air - cdef double vof_water - cdef double smoothing - cdef public: - # wave class from WaveTools - object WT - @cython.locals(phi=double, waterSpeed=double_memview1, - H=double) - cdef double[:] __cpp_calculate_velocity(self, double* x, double t) - @cython.locals(ux=double_memview1, b0=double, b1=double, b2=double, u0=double, - u1=double, u2=double) - cdef double __cpp_calculate_pressure(self, double* x, double t) - @cython.locals(level=double) - cdef double __cpp_calculate_phi(self, double* x, double t) - @cython.locals(phi=double, H=double) - cdef double __cpp_calculate_vof(self, double* x, double t) - @cython.locals(H=double) - cdef double __cpp_calculate_smoothing_H(self, double phi) - -cdef double* __x_to_cpp(double[:]) diff --git a/proteus/mprans/BoundaryConditions.py b/proteus/mprans/BoundaryConditions.py deleted file mode 100644 index 2ef1676fc0..0000000000 --- a/proteus/mprans/BoundaryConditions.py +++ /dev/null @@ -1,1665 +0,0 @@ -#!python -# distutils: language = c++ -# cython: profile=True, binding=True, embedsignature=True -# cython: wraparound=False -# cython: boundscheck=False -# cython: initializedcheck=False -import cython - -""" -Module for creating boundary conditions. Imported in mprans.SpatialTools.py -""" -import os, sys -import numpy as np -from proteus import (AuxiliaryVariables, - BoundaryConditions, - Comm) -from proteus.ctransportCoefficients import (smoothedHeaviside, - smoothedHeaviside_integral) -from proteus import WaveTools as wt -from proteus.Profiling import logEvent -from math import cos, sin, sqrt, atan2, acos, asin -from mpi4py import MPI -from scipy import spatial - -__all__ = ['BC_RANS', - 'RelaxationZone', - 'RelaxationZoneWaveGenerator', - '_cppClass_WavesCharacteristics', - 'WallFunctions', - 'kWall'] - - -class BC_RANS(BoundaryConditions.BC_Base): - """ - Class regrouping boundary conditions for two-phase flows - """ - - def __init__(self, shape=None, name=None, b_or=None, b_i=0., nd=None): - super(BC_RANS, self).__init__(shape=shape, name=name, b_or=b_or, b_i=b_i, nd=nd) - # _dirichlet - self.p_dirichlet = BoundaryCondition() # pressure - self.u_dirichlet = BoundaryCondition() # velocity u - self.v_dirichlet = BoundaryCondition() # velocity v - self.w_dirichlet = BoundaryCondition() # velocity w - self.phi_dirichlet = BoundaryCondition() # phi - self.vof_dirichlet = BoundaryCondition() # VOF - self.k_dirichlet = BoundaryCondition() # kappa - self.dissipation_dirichlet = BoundaryCondition() # dissipation - self.pAddedMass_dirichlet = BoundaryCondition() - # _advective - self.p_advective = BoundaryCondition() - self.u_advective = BoundaryCondition() - self.v_advective = BoundaryCondition() - self.w_advective = BoundaryCondition() - self.vof_advective = BoundaryCondition() - self.k_advective = BoundaryCondition() - self.dissipation_advective = BoundaryCondition() - # _diffusive - self.u_diffusive = BoundaryCondition() - self.v_diffusive = BoundaryCondition() - self.w_diffusive = BoundaryCondition() - self.k_diffusive = BoundaryCondition() - self.dissipation_diffusive = BoundaryCondition() - # moveMesh boundary conditions - self.hx_dirichlet = BoundaryCondition() - self.hy_dirichlet = BoundaryCondition() - self.hz_dirichlet = BoundaryCondition() - self.u_stress = BoundaryCondition() - self.v_stress = BoundaryCondition() - self.w_stress = BoundaryCondition() - self.u_stress.uOfXT = 0. - self.v_stress.uOfXT = 0. - self.w_stress.uOfXT = 0. - # sediment solver - self.us_dirichlet = BoundaryCondition() # sediment velocity u - self.vs_dirichlet = BoundaryCondition() # sediment velocity v - self.ws_dirichlet = BoundaryCondition() # sediment velocity w - self.vos_dirichlet = BoundaryCondition() # VOS - self.us_advective = BoundaryCondition() - self.vs_advective = BoundaryCondition() - self.ws_advective = BoundaryCondition() - self.vos_advective = BoundaryCondition() - self.us_diffusive = BoundaryCondition() - self.vs_diffusive = BoundaryCondition() - self.ws_diffusive = BoundaryCondition() - # projection scheme - self.pInit_dirichlet = BoundaryCondition() # initial pressure - self.pInc_dirichlet = BoundaryCondition() # pressure increment - self.pInit_advective = BoundaryCondition() - self.pInc_advective = BoundaryCondition() - self.pInit_diffusive = BoundaryCondition() - self.pInc_diffusive = BoundaryCondition() - # clsvof - self.clsvof_dirichlet = BoundaryCondition() - self.clsvof_advective = BoundaryCondition() - self.clsvof_diffusive = BoundaryCondition() - - def reset(self): - """ - Resets all BoundaryCondtion functions to None, apart from the BCs - affecting: moving mesh - """ - # self.BC_type = 'None' - self.p_dirichlet.resetBC() - self.pInit_dirichlet.resetBC() - self.pInc_dirichlet.resetBC() - self.u_dirichlet.resetBC() - self.v_dirichlet.resetBC() - self.w_dirichlet.resetBC() - self.phi_dirichlet.resetBC() - self.vof_dirichlet.resetBC() - self.k_dirichlet.resetBC() - self.dissipation_dirichlet.resetBC() - self.us_dirichlet.resetBC() - self.vs_dirichlet.resetBC() - self.ws_dirichlet.resetBC() - self.vos_dirichlet.resetBC() - self.p_advective.resetBC() - self.pInit_advective.resetBC() - self.pInc_advective.resetBC() - self.u_advective.resetBC() - self.v_advective.resetBC() - self.w_advective.resetBC() - self.vof_advective.resetBC() - self.k_advective.resetBC() - self.dissipation_advective.resetBC() - self.us_advective.resetBC() - self.vs_advective.resetBC() - self.ws_advective.resetBC() - self.vos_advective.resetBC() - self.pInit_diffusive.resetBC() - self.pInc_diffusive.resetBC() - self.u_diffusive.resetBC() - self.v_diffusive.resetBC() - self.w_diffusive.resetBC() - self.k_diffusive.resetBC() - self.dissipation_diffusive.resetBC() - self.us_diffusive.resetBC() - self.vs_diffusive.resetBC() - self.ws_diffusive.resetBC() - self.clsvof_dirichlet.resetBC() - self.clsvof_advective.resetBC() - self.clsvof_diffusive.resetBC() - - def setNonMaterial(self): - """ - Sets non-material boundary conditions (diffusive flux and advective vof - to 0.). - """ - self.reset() - self.BC_type = 'NonMaterial' - self.vof_advective.setConstantBC(0.) - self.vos_advective.setConstantBC(0.) - self.p_advective.setConstantBC(0.) - self.u_advective.setConstantBC(0.) - self.v_advective.setConstantBC(0.) - self.w_advective.setConstantBC(0.) - self.u_diffusive.setConstantBC(0.) - self.v_diffusive.setConstantBC(0.) - self.w_diffusive.setConstantBC(0.) - self.us_diffusive.setConstantBC(0.) - self.vs_diffusive.setConstantBC(0.) - self.ws_diffusive.setConstantBC(0.) - self.k_diffusive.setConstantBC(0.) - self.dissipation_diffusive.setConstantBC(0.) - self.pInc_diffusive.setConstantBC(0.) - - def setTank(self, b_or=None): - if b_or is None: - assert self._b_or is not None, 'Boundary orientation must be defined!' - b_or = self._b_or - self.u_stress.uOfXT = 0. - self.v_stress.uOfXT = 0. - self.w_stress.uOfXT = 0. - self.hx_dirichlet.resetBC() - self.hy_dirichlet.resetBC() - self.hz_dirichlet.resetBC() - if b_or[0] == 1 or b_or[0] == -1: - self.hx_dirichlet.setConstantBC(0.) - self.u_stress.uOfXT = None - elif b_or[1] == 1 or b_or[1] == -1: - self.hy_dirichlet.setConstantBC(0.) - self.v_stress.uOfXT = None - elif len(b_or) > 2 and (b_or[2] == 1 or b_or[2] == -1): - self.hz_dirichlet.setConstantBC(0.) - self.w_stress.uOfXT = None - - def setFixedNodes(self): - """ - For moving domains: fixes nodes/boundary - """ - self.hx_dirichlet.setConstantBC(0.) - self.hy_dirichlet.setConstantBC(0.) - self.hz_dirichlet.setConstantBC(0.) - self.u_stress.uOfXT = 0. - self.v_stress.uOfXT = 0. - self.w_stress.uOfXT = 0. - - def setNoSlip(self): - """ - Sets no slip conditions at the boundary - """ - self.reset() - self.BC_type = 'NoSlip' - # dirichlet - self.u_dirichlet.setConstantBC(0.) - self.v_dirichlet.setConstantBC(0.) - self.w_dirichlet.setConstantBC(0.) - self.us_dirichlet.setConstantBC(0.) - self.vs_dirichlet.setConstantBC(0.) - self.ws_dirichlet.setConstantBC(0.) - self.k_dirichlet.setConstantBC(1e-20) - self.dissipation_dirichlet.setConstantBC(1e-10) - # advective - self.p_advective.setConstantBC(0.) - self.pInit_advective.setConstantBC(0.) - self.pInc_advective.setConstantBC(0.) - self.vof_advective.setConstantBC(0.) - self.vos_advective.setConstantBC(0.) - # diffusive - self.pInc_diffusive.setConstantBC(0.) - self.k_diffusive.setConstantBC(0.) - self.dissipation_diffusive.setConstantBC(0.) - - def setFreeSlip(self): - """ - Sets free slip conditions at the boundary - """ - self.reset() - self.BC_type = 'FreeSlip' - # dirichlet - self.k_dirichlet.setConstantBC(1e-20) - self.dissipation_dirichlet.setConstantBC(1e-10) - # advective - self.p_advective.setConstantBC(0.) - self.pInit_advective.setConstantBC(0.) - self.pInc_advective.setConstantBC(0.) - self.u_advective.setConstantBC(0.) - self.v_advective.setConstantBC(0.) - self.w_advective.setConstantBC(0.) - self.us_advective.setConstantBC(0.) - self.vs_advective.setConstantBC(0.) - self.ws_advective.setConstantBC(0.) - self.vof_advective.setConstantBC(0.) - self.vos_advective.setConstantBC(0.) - # diffusive - self.u_diffusive.setConstantBC(0.) - self.v_diffusive.setConstantBC(0.) - self.w_diffusive.setConstantBC(0.) - self.us_diffusive.setConstantBC(0.) - self.vs_diffusive.setConstantBC(0.) - self.ws_diffusive.setConstantBC(0.) - self.pInc_diffusive.setConstantBC(0.) - self.k_diffusive.setConstantBC(0.) - self.dissipation_diffusive.setConstantBC(0.) - - def setConstantInletVelocity(self, U, ramp, kk, dd , b_or): - """ - Sets constant velocity in each inlet face with ramping up and turbulence properties - """ - self.reset() - self.BC_type = 'constantInletVelocity' - Uin = np.dot(U,b_or) - uu = U[0] - vv = U[1] - ww = U[2] - - # dirichlet - self.u_dirichlet.setLinearRamp(ramp, uu) - self.v_dirichlet.setLinearRamp(ramp ,vv) - self.w_dirichlet.setLinearRamp(ramp ,ww) - self.us_dirichlet.setConstantBC(0.) - self.vs_dirichlet.setConstantBC(0.) - self.ws_dirichlet.setConstantBC(0.) - self.k_dirichlet.setConstantBC(kk) - self.dissipation_dirichlet.setConstantBC(dd) - #advective - self.p_advective.setLinearRamp(ramp, Uin) - self.pInit_advective.setConstantBC(0.) - self.pInc_advective.setLinearRamp(ramp,Uin) - # diffusive - self.k_diffusive.setConstantBC(0.) - self.dissipation_diffusive.setConstantBC(0.) - self.us_diffusive.setConstantBC(0.) - self.vs_diffusive.setConstantBC(0.) - self.ws_diffusive.setConstantBC(0.) - def setConstantOutletPressure(self, p, rho, g ,kk, dd, b_or): - """ - Sets constant pressure in each outlet face for single phase flows - """ - self.reset() - self.BC_type = 'constantOutletPressure' - # dirichlet - a1 = rho*g - self.u_dirichlet.setConstantBC(0.) - self.v_dirichlet.setConstantBC(0.) - self.w_dirichlet.setConstantBC(0.) - self.us_dirichlet.setConstantBC(0.) - self.vs_dirichlet.setConstantBC(0.) - self.ws_dirichlet.setConstantBC(0.) - - self.p_dirichlet.setLinearBC(p,a1) - self.pInit_dirichlet.setLinearBC(p, a1) - self.pInc_dirichlet.setConstantBC(0.) - self.k_dirichlet.setConstantBC(kk) - self.dissipation_dirichlet.setConstantBC(dd) - - # diffusive - if b_or[0] == 1. or b_or[0] == -1.: - self.u_diffusive.setConstantBC(0.) - if b_or[1] == 1. or b_or[1] == -1.: - self.v_diffusive.setConstantBC(0.) - if b_or[2] == 1. or b_or[2] == -1.: - self.w_diffusive.setConstantBC(0.) - self.k_diffusive.setConstantBC(0.) - self.dissipation_diffusive.setConstantBC(0.) - self.us_diffusive.setConstantBC(0.) - self.vs_diffusive.setConstantBC(0.) - self.ws_diffusive.setConstantBC(0.) - - def setAtmosphere(self, orientation=None, vof_air=1.,kInflow=None,dInflow=None): - """ - Sets atmosphere boundary conditions (water can come out) - (!) pressure dirichlet set to 0 for this BC - - Parameters - ---------- - orientation: Optional[array_like] - orientation of the boundary. Optional if orientation was already - passed when creating the BC_RANS class instance. - vof_air: Optional[float] - VOF value of air (default is 1.) - """ - self.BC_type = 'Atmosphere' - if orientation is None and self._b_or is not None: - orientation = self._b_or - assert orientation is not None, 'oritentation must be set for BC' - self.reset() - self.p_dirichlet.setConstantBC(0.) - self.pInc_dirichlet.setConstantBC(0.) - self.pInit_dirichlet.setConstantBC(0.) - self.vof_dirichlet.setConstantBC(vof_air) # air - self.vos_dirichlet.setConstantBC(0.) - self.u_dirichlet.setConstantBC(0.) - self.v_dirichlet.setConstantBC(0.) - self.w_dirichlet.setConstantBC(0.) - self.us_dirichlet.setConstantBC(0.) - self.vs_dirichlet.setConstantBC(0.) - self.ws_dirichlet.setConstantBC(0.) - self.k_dirichlet.setConstantBC(1e-20) - self.k_diffusive.setConstantBC(0.) - self.dissipation_dirichlet.setConstantBC(1e-10) - self.dissipation_diffusive.setConstantBC(0.) - - if orientation[0] == 1. or orientation[0] == -1.: - self.u_diffusive.setConstantBC(0.) - self.us_diffusive.setConstantBC(0.) - if orientation[1] == 1. or orientation[1] == -1.: - self.v_diffusive.setConstantBC(0.) - self.vs_diffusive.setConstantBC(0.) - if orientation[2] == 1. or orientation[2] == -1.: - self.w_diffusive.setConstantBC(0.) - self.ws_diffusive.setConstantBC(0.) - - if kInflow is not None: - self.k_dirichlet.setConstantBC(kInflow) - else: - logEvent("WARNING: Dirichlet condition for k in "+str(self.BC_type)+" has not been set. Ignore if RANS is not used") - if dInflow is not None: - self.dissipation_dirichlet.setConstantBC(dInflow) - else: - logEvent("WARNING: Dirichlet condition for dissipation in "+str(self.BC_type)+" has not been set. Ignore if RANS is not used") - def setRigidBodyMoveMesh(self, body): - """ - Sets boundary conditions for moving the mesh with a rigid body - - Parameters - ---------- - last_pos: array_like - last position of rigig body - h: array_like - displacement of the body - rot_matrix: - rotation matrix describing displament due to rotation between last - position and new position (3x3 array) - - (!) if set manually, the input arrays should be updated externally - without loosing their memory address - """ - def get_DBC_h(i): - def DBC_h(x, t, n=None): - x_0 = x - body.last_position - new_x_0 = np.dot(x_0, body.rotation_matrix) - hx = new_x_0 - x_0 + body.h - return hx[i] - return DBC_h - self.hx_dirichlet.uOfXT = get_DBC_h(0) - self.hy_dirichlet.uOfXT = get_DBC_h(1) - if body.nd > 2: - self.hz_dirichlet.uOfXT = get_DBC_h(2) - - def setChMoveMesh(self, body): - self.hx_dirichlet.uOfXT = lambda x, t, n=None: body.hx(x, t) - self.hy_dirichlet.uOfXT = lambda x, t, n=None: body.hy(x, t) - self.hz_dirichlet.uOfXT = lambda x, t, n=None: body.hz(x, t) - - def setTurbulentDirichlet(self, kVal, dissipationVal): - """ - Sets only dirichlet conditions for turbulence at the boundary. - It's a rough approximation for evalueting the near wall turbulence - based on empirical assumptions. - More sophisticated wall functions are recommended to be used. - - Parameters - ---------- - kVal: float. - constant value applied on k. - dissipationVal: float. - constant value applied on dissipation. - """ - # turbulent boundary conditions - self.k_dirichlet.setConstantBC(kVal) - self.dissipation_dirichlet.setConstantBC(dissipationVal) - self.k_advective.resetBC() - self.dissipation_advective.resetBC() - self.k_diffusive.resetBC() - self.dissipation_diffusive.resetBC() - - def setTurbulentZeroGradient(self): - """ - Sets only zero-gradient conditions for turbulence at the boundary. - More sophisticated wall functions are recommended to be used. - """ - # turbulent boundary conditions - self.k_dirichlet.setConstantBC(0.) - self.dissipation_dirichlet.setConstantBC(0.) - self.k_advective.resetBC() - self.dissipation_advective.resetBC() - self.k_diffusive.setConstantBC(0.) - self.dissipation_diffusive.setConstantBC(0.) - - def setWallFunction(self, wall, shearStress=False): - """ - Sets turbulent boundaries for wall treatment. - Calculation made on nodes outside the viscous sublayer and based - on assumption on the velocity profile close to the wall in order to - impose the wall shear stress. - - Parameters - ---------- - wall: wall object. - BoundaryConditions class to be attached for setting up - all the turbulent parameters. - shearStress: True/False. - At the moment version with shearStress=False is the only one that - returns good results. - Keep it False at the moment! - - - When True, the wall function prescribes diffusive boundaries - for velocity and kappa. It's like imposing the shear stress. - - If False, the wall function prescribes dirichlet conditions. - """ - wf = wall - self.reset() - self.setNoSlip() - self.BC_type = "Wall function" - self.dissipation_diffusive.resetBC() - self.k_dirichlet.uOfXT = lambda x, t, n=None: wf.get_k_dirichlet(x, t, n) - self.dissipation_dirichlet.uOfXT = lambda x, t, n=None: wf.get_dissipation_dirichlet(x, t ,n) - self.u_dirichlet.uOfXT = lambda x, t, n=None: wf.get_u_dirichlet(x, t ,n) - self.v_dirichlet.uOfXT = lambda x, t, n=None: wf.get_v_dirichlet(x, t ,n) - self.w_dirichlet.uOfXT = lambda x, t, n=None: wf.get_w_dirichlet(x, t ,n) - """ - self.dissipation_dirichlet.uOfXT = lambda x, t: wf.get_dissipation_dirichlet(x, t) - self.vof_advective.setConstantBC(0.) - self.p_advective.setConstantBC(0.) - if shearStress: - #self.k_dirichlet.uOfXT = lambda x, t: wf.get_k_dirichlet(x, t) - self.k_advective.setConstantBC(0.) - self.u_diffusive.uOfXT = lambda x, t: wf.get_u_diffusive(x, t) - self.v_diffusive.uOfXT = lambda x, t: wf.get_v_diffusive(x, t) - self.w_diffusive.uOfXT = lambda x, t: wf.get_w_diffusive(x, t) - self.k_diffusive.setConstantBC(0.) - else: - self.u_dirichlet.uOfXT = lambda x, t: wf.get_u_dirichlet(x, t) - self.v_dirichlet.uOfXT = lambda x, t: wf.get_v_dirichlet(x, t) - self.w_dirichlet.uOfXT = lambda x, t: wf.get_w_dirichlet(x, t) - self.k_dirichlet.uOfXT = lambda x, t: wf.get_k_dirichlet(x, t) - """ - def setMoveMesh(self, last_pos, h=(0., 0., 0.), rot_matrix=None): - """ - Sets boundary conditions for moving the mesh with a rigid body - - Parameters - ---------- - last_pos: array_like - last position of rigig body - h: array_like - displacement of the body - rot_matrix: - rotation matrix describing displament due to rotation between last - position and new position (3x3 array) - - (!) if set manually, the input arrays should be updated externally - without loosing their memory address - """ - if rot_matrix is None: - rot_matrix = np.array([[1., 0., 0.], - [0., 1., 0.], - [0., 0., 1.]]) - self.body_python_rot_matrix = rot_matrix - self.body_python_last_pos = last_pos - self.body_python_h = h - self.hx_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_MoveMesh_hx(x, t) - self.hy_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_MoveMesh_hy(x, t) - self.hz_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_MoveMesh_hz(x, t) - - def __cpp_MoveMesh_h(self, x, t): - cython.declare(x_0=cython.double[3]) - cython.declare(new_x_0=cython.double[3]) - hx = np.zeros(3) - x_0[0] = x[0] - self.body_python_last_pos[0] - x_0[1] = x[1] - self.body_python_last_pos[1] - x_0[2] = x[2] - self.body_python_last_pos[2] - new_x_0 = np.dot(x_0, self.body_python_rot_matrix) - hx[0] = new_x_0[0] - x_0[0] + self.body_python_h[0] - hx[1] = new_x_0[1] - x_0[1] + self.body_python_h[1] - hx[2] = new_x_0[2] - x_0[2] + self.body_python_h[2] - return hx - - def __cpp_MoveMesh_hx(self, x, t): - return self.__cpp_MoveMesh_h(x, t)[0] - - def __cpp_MoveMesh_hy(self, x, t): - return self.__cpp_MoveMesh_h(x, t)[1] - - def __cpp_MoveMesh_hz(self, x, t): - return self.__cpp_MoveMesh_h(x, t)[2] - - def setUnsteadyTwoPhaseVelocityInlet(self, wave, smoothing, vert_axis=None,orientation=None, - wind_speed=None, vof_air=1., vof_water=0.,kInflow=1e-30, dInflow = 1e-10): - """ - Imposes a velocity profile on the fluid with input wave and wind - conditions. - - Parameters - ---------- - wave: proteus.WaveTools - class describing a wave (from proteus.WaveTools) - smoothing: float - smoothing distance (typically 3.*he) - vert_axis: Optional[int] - index of vertical position vector (x:0, y:1, z:2), must always be - aligned with gravity. If not set, will be 1 in 2D (y), 2 in 3D (z). - wind_speed: Optional[array_like] - speed of air phase - vof_air: Optional[float] - VOF value of air (default is 1.) - vof_water: Optional[float] - VOF value of water (default is 0.) - - Below the sea water level: fluid velocity to wave speed. - Above the sea water level: fluid velocity set to wind speed - (with smoothing). - """ - self.reset() - if vert_axis is None: - vert_axis = self.nd - 1 - if wind_speed is None: - wind_speed = np.zeros(3) - if orientation is not None: - b_or = orientation - else: - b_or=self._b_or - assert b_or is not None, "ERROR: Boundary orientation for Unsteady flow inlet is not defined" - self.waves = __cppClass_WavesCharacteristics(waves=wave, vert_axis=vert_axis, b_or=b_or, - wind_speed=wind_speed, smoothing=smoothing, vof_water=vof_water, vof_air=vof_air) - - self.u_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_u_dirichlet(x, t) - self.v_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_v_dirichlet(x, t) - self.w_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_w_dirichlet(x, t) - self.phi_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_phi_dirichlet(x, t) - self.vof_dirichlet.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_vof_dirichlet(x, t) - self.p_advective.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_p_advective(x, t) - self.pInc_advective.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_p_advective(x, t) - - self.pInc_diffusive.setConstantBC(0.0) - self.pInit_advective.uOfXT = lambda x, t, n=None: self.__cpp_UnsteadyTwoPhaseVelocityInlet_p_advective(x, t)#setConstantBC(0.0) - self.vos_dirichlet.setConstantBC(0.0) - self.us_dirichlet.setConstantBC(0.0) - self.vs_dirichlet.setConstantBC(0.0) - self.ws_dirichlet.setConstantBC(0.0) - self.k_dirichlet.setConstantBC(kInflow) - self.dissipation_dirichlet.setConstantBC(dInflow) - self.dissipation_diffusive.setConstantBC(0.) - self.k_diffusive.setConstantBC(0.0) - - def __cpp_UnsteadyTwoPhaseVelocityInlet_u_dirichlet(self, x, t): - cython.declare(xx=cython.double[3]) - xx[0] = x[0] - xx[1] = x[1] - xx[2] = x[2] - return self.waves.__cpp_calculate_velocity(xx, t)[0] - - def __cpp_UnsteadyTwoPhaseVelocityInlet_v_dirichlet(self, x, t): - cython.declare(xx=cython.double[3]) - xx[0] = x[0] - xx[1] = x[1] - xx[2] = x[2] - return self.waves.__cpp_calculate_velocity(xx, t)[1] - - def __cpp_UnsteadyTwoPhaseVelocityInlet_w_dirichlet(self, x, t): - cython.declare(xx=cython.double[3]) - xx[0] = x[0] - xx[1] = x[1] - xx[2] = x[2] - return self.waves.__cpp_calculate_velocity(xx, t)[2] - - def __cpp_UnsteadyTwoPhaseVelocityInlet_p_advective(self, x, t): - cython.declare(xx=cython.double[3]) - xx[0] = x[0] - xx[1] = x[1] - xx[2] = x[2] - return self.waves.__cpp_calculate_pressure(xx, t) - - def __cpp_UnsteadyTwoPhaseVelocityInlet_phi_dirichlet(self, x, t): - cython.declare(xx=cython.double[3]) - xx[0] = x[0] - xx[1] = x[1] - xx[2] = x[2] - return self.waves.__cpp_calculate_phi(xx, t) - - def __cpp_UnsteadyTwoPhaseVelocityInlet_vof_dirichlet(self, x, t): - cython.declare(xx=cython.double[3]) - xx[0] = x[0] - xx[1] = x[1] - xx[2] = x[2] - return self.waves.__cpp_calculate_vof(xx, t) - - def setTwoPhaseVelocityInlet(self, U, waterLevel, smoothing, Uwind=None, - vert_axis=None, air=1., water=0., - kInflow=None, dissipationInflow=None, - kInflowAir=None, dissipationInflowAir=None): - """ - Imposes a velocity profile lower than the sea level and an open - boundary for higher than the sealevel. - - Parameters - ---------- - U: list. - Velocity vector at the global system. - Uwind: list. - Air velocity vector at the global system. - waterLevel: float. - water level at global coordinate system. - smoothing: float. - range within smoothing function is valid. - [3.0 times mesh element size can be a good value] - vert_axis: optional. - index of vertical in position vector, must always be - aligned with gravity, by default set to 1]. - air: optional. - Volume fraction for air (1.0 by default). - water: optional. - Volume fraction for water (0.0 by default). - kInflow: float (optional). - K inflow value for turbulent model imposed at the boundary. - dissipationInflow: float (optional). - Dissipation inflow value for turbulent model imposed at the boundary. - kInflowAir: float (optional). - Air K inflow value for turbulent model imposed at the boundary. - dissipationInflowAir: float (optional). - Air dissipation inflow value for turbulent model imposed at the boundary. - - Notes - ----- - Below the seawater level, the condition returns the _dirichlet and - p_advective condition according to the inflow velocity. - Above the sea water level, the condition returns the gravity as zero, - and sets _dirichlet condition to zero, only if there is a zero inflow - velocity component. - (!) This condition is best used for boundaries and gravity aligned with - one of the main axes. - """ - self.reset() - self.BC_type = 'TwoPhaseVelocityInlet' - - if vert_axis is None: - vert_axis = self.nd - 1 - if Uwind is None: - Uwind = np.zeros(3) - - U = np.array(U) - Uwind = np.array(Uwind) - - def get_inlet_ux_dirichlet(i): - def ux_dirichlet(x, t, n=None): - phi = x[vert_axis] - waterLevel - if phi <= 0.: - H = 0.0 - elif 0 < phi <= smoothing: - H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(smoothing/2., phi - smoothing/2.) - else: - H = 1.0 - u = H * Uwind[i] + (1 - H) * U[i] - return u - return ux_dirichlet - - def inlet_phi_dirichlet(x, t, n=None): - phi = x[vert_axis] - waterLevel - return phi - - def inlet_vof_dirichlet(x, t, n=None): - phi = x[vert_axis] - waterLevel - if phi >= smoothing: - H = 1. - elif smoothing > 0 and -smoothing < phi < smoothing: - H = smoothedHeaviside(smoothing, phi) - elif phi <= -smoothing: - H = 0. - vof = H * air + (1 - H) * water - return vof - - def inlet_p_advective(x, t, n=None): - b_or = self._b_or - phi = x[vert_axis] - waterLevel - if phi <= 0.: - H = 0.0 - elif 0 < phi <= smoothing: - H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(smoothing/2., phi - smoothing/2.) - else: - H = 1.0 - u = H * Uwind + (1 - H) * U - # This is the normal velocity, based on the inwards boundary - # orientation -b_or - u_p = np.sum(u * np.abs(b_or)) - return -u_p - - def inlet_k_dirichlet(x, t, n=None): - phi = x[vert_axis] - waterLevel - if phi <= 0.: - H = 0.0 - elif 0 < phi <= smoothing: - H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(smoothing/2., phi - smoothing/2.) - else: - H = 1.0 - return H * kInflowAir + (1 - H) * kInflow - - def inlet_dissipation_dirichlet(x, t, n=None): - phi = x[vert_axis] - waterLevel - if phi <= 0.: - H = 0.0 - elif 0 < phi <= smoothing: - H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(smoothing/2., phi - smoothing/2.) - else: - H = 1.0 - return H * dissipationInflowAir + (1 - H) * dissipationInflow - - self.u_dirichlet.uOfXT = get_inlet_ux_dirichlet(0) - self.v_dirichlet.uOfXT = get_inlet_ux_dirichlet(1) - self.w_dirichlet.uOfXT = get_inlet_ux_dirichlet(2) - self.phi_dirichlet.uOfXT = inlet_phi_dirichlet - self.vof_dirichlet.uOfXT = inlet_vof_dirichlet - self.p_advective.uOfXT = inlet_p_advective - if kInflow is not None: - self.k_dirichlet.uOfXT = inlet_k_dirichlet - self.k_advective.resetBC() - self.k_diffusive.resetBC() - if dissipationInflow is not None: - self.dissipation_dirichlet.uOfXT = inlet_dissipation_dirichlet - self.dissipation_advective.resetBC() - self.dissipation_diffusive.resetBC() - - def setHydrostaticPressureOutletWithDepth(self, seaLevel, rhoUp, rhoDown, g, - refLevel, smoothing, orientation=None,U=None, Uwind=None, - pRef=0.0, vert_axis=None, - air=1.0, water=0.0, - kInflow=None, dissipationInflow=None, - kInflowAir=None, dissipationInflowAir=None): - """ - Returns the pressure and vof profile based on the known depth. - If the boundary is aligned with one of the main axes, sets the tangential - velocity components to zero as well. - (!) This condition is best used for boundaries and gravity aligned with - one of the main axes. - - Parameters - ---------- - rhoUp: Phase density of the upper part. - rhoDown: Phase density of the lower part. - g: Gravitational acceleration vector. - refLevel: Level at which pressure = pRef. - pRef: Reference value for the pressure at x[vert_axis]=refLevel, by default set to 0. - vert_axis: index of vertical in position vector, must always be aligned with gravity, by default set to 1. - """ - self.reset() - - if vert_axis is None: - vert_axis = self.nd - 1 - - def hydrostaticPressureOutletWithDepth_p_dirichlet(x, t , n=None): - p_top = pRef - phi_top = refLevel - seaLevel - phi = x[vert_axis] - seaLevel - return p_top - g[vert_axis] * (rhoDown * (phi_top - phi) + - (rhoUp - rhoDown) * - (smoothedHeaviside_integral(smoothing, phi_top) - - - smoothedHeaviside_integral(smoothing, phi))) - - def hydrostaticPressureOutletWithDepth_phi_dirichlet(x, t, n=None): - phi = x[vert_axis] - seaLevel - return phi - - def hydrostaticPressureOutletWithDepth_vof_dirichlet(x, t, n=None): - phi = x[vert_axis] - seaLevel - if phi >= smoothing: - H = 1. - elif smoothing > 0 and -smoothing < phi < smoothing: - H = smoothedHeaviside(smoothing, phi) - elif phi <= -smoothing: - H = 0. - return H * air + (1 - H) * water - - def inlet_k_dirichlet(x, t, n=None): - phi = x[vert_axis] - seaLevel - if phi <= 0.: - H = 0.0 - elif 0 < phi <= smoothing: - H = smoothedHeaviside(smoothing/2., phi - smoothing/2.) - else: - H = 1.0 - return H * kInflowAir + (1 - H) * kInflow - - def inlet_dissipation_dirichlet(x, t, n=None): - phi = x[vert_axis] - seaLevel - if phi <= 0.: - H = 0.0 - elif 0 < phi <= smoothing: - H = smoothedHeaviside(smoothing/2., phi - smoothing/2.) - else: - H = 1.0 - return H * dissipationInflowAir + (1 - H) * dissipationInflow - - if orientation is not None: - b_or = orientation - else: - b_or=self._b_or - assert b_or is not None, "ERROR: Boundary orientation for Hydrostatic flow outlet is not defined" - if b_or[0] == 1. or b_or[0] == -1.: - self.v_dirichlet.setConstantBC(0.) - self.w_dirichlet.setConstantBC(0.) - self.u_diffusive.setConstantBC(0.) - if b_or[1] == 1. or b_or[1] == -1.: - self.u_dirichlet.setConstantBC(0.) - self.w_dirichlet.setConstantBC(0.) - self.v_diffusive.setConstantBC(0.) - if b_or[2] == 1. or b_or[2] == -1.: - self.u_dirichlet.setConstantBC(0.) - self.v_dirichlet.setConstantBC(0.) - self.w_diffusive.setConstantBC(0.) -#sediment - self.us_advective.setConstantBC(0.) - self.vs_advective.setConstantBC(0.) - self.ws_advective.setConstantBC(0.) - self.vos_advective.setConstantBC(0.) - self.us_diffusive.setConstantBC(0.) - self.vs_diffusive.setConstantBC(0.) -#end sediment - self.p_dirichlet.uOfXT = hydrostaticPressureOutletWithDepth_p_dirichlet - self.pInit_dirichlet.uOfXT = hydrostaticPressureOutletWithDepth_p_dirichlet - self.pInc_dirichlet.setConstantBC(0.) - self.phi_dirichlet.uOfXT = hydrostaticPressureOutletWithDepth_phi_dirichlet - self.vof_dirichlet.uOfXT = hydrostaticPressureOutletWithDepth_vof_dirichlet - self.k_diffusive.setConstantBC(0.) - self.dissipation_diffusive.setConstantBC(0.) - if U is not None: - def get_inlet_ux_dirichlet(i): - def ux_dirichlet(x, t, n=None): - phi = x[vert_axis] - seaLevel - if phi <= 0.: - H = 0.0 - elif 0 < phi <= smoothing: - H = smoothedHeaviside(smoothing/2., phi - smoothing/2.) - else: - H = 1.0 - return H * Uwind[i] + (1 - H) * U[i] - return ux_dirichlet - - if Uwind is None: - Uwind = np.zeros(3) - U = np.array(U) - Uwind = np.array(Uwind) - self.u_dirichlet.uOfXT = get_inlet_ux_dirichlet(0) - self.v_dirichlet.uOfXT = get_inlet_ux_dirichlet(1) - self.w_dirichlet.uOfXT = get_inlet_ux_dirichlet(2) - self.u_diffusive.resetBC() - - if kInflow is not None: - self.k_dirichlet.uOfXT = inlet_k_dirichlet - self.k_advective.resetBC() - self.k_diffusive.resetBC() - if dissipationInflow is not None: - self.dissipation_dirichlet.uOfXT = inlet_dissipation_dirichlet - self.dissipation_advective.resetBC() - self.dissipation_diffusive.resetBC() - -# for regions - -class RelaxationZone: - """ - Holds information about a relaxation zone (wave generation/absorption - or porous zone) - - Parameters - ---------- - zone_type: string - type of zone, can be set to 'absorption', 'generation', or 'porous' - center: array_like - coordinates of center of the zone - orientation: array_like - orientation for absorption/generation zones: from boundary to tank - epsFact_porous: float - half the zone length - waves: Optional[proteus.WaveTools] - class instance of a wave from proteus.WaveTools (must be set for - generation zone) - shape: Optional[proteus.SpatialTools.Shape] - shape class instance containing region - dragAlpha: Optional[float] - parameter for porous zones (default: 0.5/1.005e-6) - dragBeta: Optional[float] - parameter for porous zones (default: 0.) - porosity: Optional[float] - parameter for porous zone (default: 1.) - vert_axis: Optional[int] - index of vertical position vector (x:0, y:1, z:2), must always be - aligned with gravity. If not set, will be 1 in 2D (y), 2 in 3D (z). - smoothing: Optional[float] - smoothing distance from the free surface (usually 3*he) - vof_water: Optional[int] - VOF value of water (default: 0) - vof_air: Optional[int] - VOF value of air (default: 1) - """ - - def __cinit__(self, zone_type, center, orientation, epsFact_porous, - waves=None, shape=None, wind_speed=np.array([0., 0., 0.]), - dragAlpha=0.5/1.005e-6, dragBeta=0., porosity=1., vert_axis=None, smoothing=0., - vof_water=0., vof_air=1.): - self.Shape = shape - self.nd = self.Shape.Domain.nd - self.zone_type = zone_type - self.center = center - self.orientation = orientation - if vert_axis is None: - vert_axis = self.Shape.Domain.nd - 1 - self.vert_axis = vert_axis - if waves is not None: - self.waves = __cppClass_WavesCharacteristics(waves=waves, wind_speed=wind_speed, vert_axis=vert_axis, - smoothing=smoothing, vof_water=vof_water, vof_air=vof_air) - self.epsFact_porous = epsFact_porous - self.dragAlpha = dragAlpha - self.dragBeta = dragBeta - self.porosity = porosity - self.zero_vel = np.zeros(3) - - def calculate_init(self): - if self.zone_type == 'generation': - # self.u = &self.waves.u - # self.eta = &self.waves.eta - self.uu = self.__cpp_calculate_vel_wave - self.phi = self.__cpp_calculate_phi_porous_sponge - elif self.zone_type == 'absorption': - self.uu = self.__cpp_calculate_vel_zero - self.phi = self.__cpp_calculate_phi_porous_sponge - elif self.zone_type == 'porous': - self.uu = self.__cpp_calculate_vel_zero - self.phi = self.__cpp_calculate_phi_porous - - def calculate_phi(self, x): - return self.phi(self, x) - - def __cpp_calculate_phi_porous_sponge(self, x): - """ - Used for RelaxationZone only - """ - cython.declare(d=cython.double[3], o=cython.double[3]) - d[0] = self.center[0] - x[0] - d[1] = self.center[1] - x[1] - o[0] = self.orientation[0] - o[1] = self.orientation[1] - if self.nd > 2: - d[2] = self.center[2] - x[2] - o[2] = self.orientation[2] - else: - d[2] = 0 - o[2] = 0 - phi = o[0] * d[0] + o[1] * d[1] + o[2] * d[2] - return phi - - def __cpp_calculate_phi_porous(self, x): - IN_POROUS_ZONE=-10000.0 - return IN_POROUS_ZONE - - def calculate_vel(self, x, t): - cython.declare(d=cython.double[3], o=cython.double[3]) - d[0] = x[0] - d[1] = x[1] - d[2] = x[2] - return self.uu(self, d, t) - - def calculate_phi_python(self, x): - cython.declare(xx=cython.double[3], tt=cython.double) - xx[0] = x[0] - xx[1] = x[1] - xx[2] = x[2] - ph = self.phi(self, xx) - return ph - - def calculate_vel_python(self, x, t, n=None): - cython.declare(xx=cython.double[3], tt=cython.double) - xx[0] = x[0] - xx[1] = x[1] - xx[2] = x[2] - tt = t - return self.uu(self, xx, tt) - - def __cpp_calculate_vel_zero(self, x, t): - return self.zero_vel - - def __cpp_calculate_vel_wave(self, x, t): - return self.waves.__cpp_calculate_velocity(x, t) - - -class RelaxationZoneWaveGenerator: - """ - Prescribe a velocity penalty scaling in a material zone via a - Darcy-Forchheimer penalty - - Parameters - ---------- - zones: dict - dictionary with key as the region flag and values as a RelaxationZone - class - nd: int - number of dimensions of domain - """ - - def __init__(self, zones, nd): - self.zones = zones - self.nd = nd - - def attachModel(self, model, ar): - self.model = model - self.ar = ar - return self - - def attachAuxiliaryVariables(self, avDict): - pass - - def calculate_init(self): - max_key = 0 - for key, zone in list(self.zones.items()): - zone.calculate_init() - if key > max_key: - max_key = key - self.max_flag = max_key - self.zones_array = np.empty(self.max_flag + 1, dtype=RelaxationZone) - for key, zone in list(self.zones.items()): - self.zones_array[key] = zone - - def calculate(self): - self.__cpp_iterate() - - def __cpp_iterate(self): - nl = len(self.model.levelModelList) - for l in range(nl): # usually only 1 - # initialisation of variables before costly loop - m = self.model.levelModelList[l] - nE = m.coefficients.q_phi.shape[0] - nk = m.coefficients.q_phi.shape[1] - t = m.timeIntegration.t - qx = m.q['x'] - q_phi_porous = m.coefficients.q_phi_porous - q_velocity_porous = m.coefficients.q_velocity_porous - mTypes = m.mesh.elementMaterialTypes - # costly loop - for eN in range(nE): - mType = mTypes[eN] - if mType <= self.max_flag: - zone = self.zones_array[mType] - if zone is not None: - for k in range(nk): - x[0] = qx[eN, k, 0] - x[1] = qx[eN, k, 1] - x[2] = qx[eN, k, 2] - phi = zone.calculate_phi(x) - q_phi_porous[eN, k] = phi - u = zone.calculate_vel(x, t) - q_velocity_porous[eN, k, 0] = u[0] - q_velocity_porous[eN, k, 1] = u[1] - if self.nd > 2: - q_velocity_porous[eN, k, 2] = u[2] - m.q['phi_porous'] = q_phi_porous - m.q['velocity_porous'] = q_velocity_porous - - -class __cppClass_WavesCharacteristics: - """ - Class holding information from WaveTools waves and cnvering it to - boundary conditions to use for relaxation zones and wave inlet. - This class is created automatically when passing WaveTools class - instances to a relaxation zone or wave inlet BC. - - Parameters - ---------- - wave: proteus.WaveTools - class describing a wave (from proteus.WaveTools) - vert_axis: int - index of vertical position vector (x:0, y:1, z:2), must always be - aligned with gravity. If not set, will be 1 in 2D (y), 2 in 3D (z). - wind_speed: Optional[array_like] - speed of air phase - b_or: Optional[array_like] - boundary orientation. Necessary for pressure calculations. Used - for boundary conditions but not in relaxation zones. - smoothing: Optional[float] - smoothing distance from the free surface (usually 3*he) - vof_water: Optional[float] - VOF value of water (default: 0) - vof_air: Optional[float] - VOF value of air (default: 1) - """ - - def __init__(self, waves, vert_axis, wind_speed=None, b_or=None, - smoothing=0., vof_water=0., vof_air=1.): - self.WT = waves # wavetools wave - self.vert_axis = vert_axis - self.zero_vel = np.zeros(3) - self._b_or = b_or - self.smoothing = smoothing - self.vof_air = vof_air - self.vof_water = vof_water - if wind_speed is None: - self.wind_speed = self.zero_vel - else: - self.wind_speed = wind_speed - - def __cpp_calculate_velocity(self, x, t): - # u is returned as a memoryview (pxd: cdef double[:]); a C array declared here lives on this - # function's stack and the view dangles once it returns. Unnoticed until the module was built - # with line tracing, which reuses that stack: the caller then read 0.0. - u = np.empty(3) - cython.declare(xx=cython.double[3]) - cython.declare(x_max=cython.double[3]) - xx[0] = x[0] - xx[1] = x[1] - xx[2] = x[2] - phi = self.__cpp_calculate_phi(x, t) - if phi <= 0.: - # no smoothing below mwl, or wave peak could get chopped off - H = 0 - waterSpeed = self.WT.u(xx, t) - elif 0 < phi <= self.smoothing: - # smoothing on half the range of VOF (above wave crest) - H = smoothedHeaviside(self.smoothing/2., phi - self.smoothing/2.) - # use max velocity of wave for water - x_max[0] = x[0] - x_max[1] = x[1] - x_max[2] = x[2] - x_max[self.vert_axis] = x[self.vert_axis] - phi - waterSpeed = self.WT.u(x_max, t) - else: - H = 1. - waterSpeed = self.zero_vel - u[0] = H * self.wind_speed[0] + (1 - H) * waterSpeed[0] - u[1] = H * self.wind_speed[1] + (1 - H) * waterSpeed[1] - u[2] = H * self.wind_speed[2] + (1 - H) * waterSpeed[2] - return u - - def __cpp_calculate_pressure(self, x, t): - # This is the normal velocity, based on the outwards boundary - # orientation b_or - # needs to be equal to -ux_dirichlet - ux = self.__cpp_calculate_velocity(x, t) - b0, b1, b2 = self._b_or[0], self._b_or[1], self._b_or[2] - u0, u1, u2 = ux[0], ux[1], ux[2] - return b0 * u0 + b1 * u1 + b2 * u2 - - def __cpp_calculate_phi(self, x, t): - cython.declare(xx=cython.double[3]) - xx[0] = x[0] - xx[1] = x[1] - xx[2] = x[2] - level = self.WT.mwl + self.WT.eta(xx, t) - return x[self.vert_axis] - level - - def __cpp_calculate_vof(self, x, t): - phi = self.__cpp_calculate_phi(x, t) - H = self.__cpp_calculate_smoothing_H(phi) - return H - - def __cpp_calculate_smoothing_H(self, phi): - if phi >= self.smoothing: - H = 1. - elif self.smoothing > 0 and -self.smoothing < phi < self.smoothing: - H = smoothedHeaviside(self.smoothing, phi) - elif phi <= -self.smoothing: - H = 0. - return H - - -def __x_to_cpp(x): - cython.declare(xx=double[3]) - xx[0] = x[0] - xx[1] = x[1] - xx[2] = x[2] - return xx - - -class WallFunctions(AuxiliaryVariables.AV_base): - """ - Auxiliary variable used to calculate attributes of an associated shape - class instance acting as a wall. - """ - - def __init__(self, turbModel, kWall, Y, Yplus, U0, nu=1.004e-6, Cmu=0.09, K=0.41, B=5.57): - """ - Sets turbulent boundaries for wall treatment. - Calculation made on nodes outside the viscous sublayer and based - on assumption on the velocity profile close to the wall in order to - impose the wall shear stress. - - - k is assumed to be constant in the fully turbulent region close to the wall, - in this way kv = kp. - - dissipation is calculated. - - Parameters - ---------- - turbModel: string. - 'ke' or 'kw', for switching between k-epsilon or k-omega models. - kWall: object. - Class kWall object for extracting kappa from the model. - Y: float. - size of the nearest element to the boundary. - Yplus: float. - size of the nearest element to the boundary in terms of wall unit. - U0: array_like. - stream velocity. - nu: float. - fluid viscosity. - Cmu: float. - turbulent viscosity constant. - K: float. - von Karman coefficient. - B: float. - roughness coefficient for walls. - """ - self.turbModel = turbModel - self.Y = Y - self.Yplus = Yplus - self.U0 = U0 - self.nu = nu - self.Cmu = Cmu - self.K = K - self.B = B - # initialise variables - self.Ubound = np.zeros(3) - self.kappa = 1e-10 - self.tau_rho = 0. - self.utAbs = 1e-10 - self.ut = np.zeros(3) - self.x = np.zeros(3) - self.t = 0. - self.model = None - self.xi, self.element, self.rank = None, None, None - self.kWall = kWall - - def attachModel(self, model, ar): - """ - Attaches model to auxiliary variable - """ - self.model = model - self.ar = ar - self.nd = model.levelModelList[0].nSpace_global - self.Closure_0_model = model.levelModelList[0].coefficients.Closure_0_model - self.Closure_1_model = model.levelModelList[0].coefficients.Closure_1_model - return self - - def attachAuxiliaryVariables(self, avDict): - pass - - def calculate_init(self): - pass - - def calculate(self): - pass - - def getLocalNearestNode(self, coords, kdtree): - """ - Finds nearest node to coordinates (local) - Parameters - ---------- - coords: array_like - coordinates from which to find nearest node - kdtree: scipy.spatial.cKDTree - instance of scipy kdtree - Returns - ------- - node: int - nearest node index - distance: float - distance to nearest node - """ - # determine local nearest node distance - distance, node = kdtree.query(coords) - return node, distance - - def getLocalElement(self, femSpace, coords, node): - """ - Given coordinates and its nearest node, determine if it is on a - local element. - Parameters - ---------- - femSpace: object - finite element space - coords: array_like - coordinates from which to element - node: int - nearest node index - Returns - ------- - eN: int or None - local index of element (None if not found) - """ - patchBoundaryNodes = set() - checkedElements = [] - # nodeElementOffsets give the indices to get the elements sharing the node - statem1 = node + 1 < len(femSpace.mesh.nodeElementOffsets) - for eOffset in range(femSpace.mesh.nodeElementOffsets[node], femSpace.mesh.nodeElementOffsets[node + 1]): - eN = femSpace.mesh.nodeElementsArray[eOffset] - checkedElements.append(eN) - # union of set - patchBoundaryNodes |= set(femSpace.mesh.elementNodesArray[eN]) - # evaluate the inverse map for element eN (global to local) - xi = femSpace.elementMaps.getInverseValue(eN, coords) - #J = femSpace.elementMaps.getJacobianValues(eN, ) - # query whether xi lies within the reference element - if femSpace.elementMaps.referenceElement.onElement(xi): - return eN - # extra loop if case coords is in neighbour element - for node in patchBoundaryNodes: - for eOffset in range(femSpace.mesh.nodeElementOffsets[node], femSpace.mesh.nodeElementOffsets[node + 1]): - eN = femSpace.mesh.nodeElementsArray[eOffset] - if eN not in checkedElements: - checkedElements.append(eN) - # evaluate the inverse map for element eN - xi = femSpace.elementMaps.getInverseValue(eN, coords) - # query whether xi lies within the reference element - if femSpace.elementMaps.referenceElement.onElement(xi): - return eN - # no elements found - return None - - def findElementContainingCoords(self, coords): - """ - Given global coordinates of a point, returns - local coordinates and the owner of the point. - - Parameters - ---------- - coords: array_like - global coordinates to look for - Returns - ------- - xi: - local coordinates - eN: int - (local) element number - rank: int - processor rank containing element - """ - comm = Comm.get().comm.tompi4py() - xi = owning_proc = element = rank = None # initialised as None - self.xi, self.element, self.rank = xi, element, rank - # get nearest node on each processor - # comm.barrier() - self.u = self.model.levelModelList[0].u - self.femSpace_velocity = self.u[1].femSpace - nodes_kdtree = spatial.cKDTree(self.model.levelModelList[0].mesh.nodeArray) - nearest_node, nearest_node_distance = self.getLocalNearestNode(coords, nodes_kdtree) - # look for element containing coords on each processor (if it exists) - local_element = self.getLocalElement(self.femSpace_velocity, coords, nearest_node) - if local_element: - xi = self.femSpace_velocity.elementMaps.getInverseValue(local_element, coords) - rank = comm.rank - else: - xi = None - rank = None - #rank = comm.allreduce(rank, op=MPI.MAX) - return xi, local_element, rank - - def getFluidVelocityLocalCoords(self, xi, element, rank): - """ - Given local details, returns velocity field at those coordinates. - - Parameters - ---------- - xi: - local coords in element - element: int - element number (local to processor 'rank') - rank: int - rank of processor owning the element - """ - comm = Comm.get().comm.tompi4py() - if comm.rank == rank: - u = self.u[1].getValue(element, xi) - v = self.u[2].getValue(element, xi) - if self.nd > 2: - w = self.u[3].getValue(element, xi) - if self.nd <= 2: - w = 0. - else: - u = v = w = None - return u, v, w - - def setYplusNormalDirection(self, x, t,n, relax=1.0): - """ - Return the point at y+ distance in normal - direction from the boundary. - """ - # near wall point - if len(n) < 3: - nP = (relax * self.Y * (-n[:2])) + x[:2] - else: - nP = (relax * self.Y * (-n)) + x - return nP - - def extractVelocity(self, x, t, n): - """ - Extraction of the velocity at y+ distance from the boundary. - """ - coords = self.setYplusNormalDirection(x, t, n) - xi, element, rank = self.findElementContainingCoords(coords) - if rank is not None: - u, v, w = self.getFluidVelocityLocalCoords(xi, element, rank) - else: - relax = 0.5 - while rank is None: - coords_relax = self.setYplusNormalDirection(x, t, n ,relax) - xi, element, rank = self.findElementContainingCoords(coords_relax) - relax *= 0.5 - # just use the element containing the boundary quadrature point to interpolate to the y+ point - u, v, w = self.getFluidVelocityLocalCoords(self.femSpace_velocity.elementMaps.getInverseValue(element, coords), - element, - rank) - self.xi, self.element, self.rank = xi, element, rank - return u, v, w - - def tangentialVelocity(self, x, t, n, uInit=None): - """ - Given the velocity, calculates its - tangential component to the wall. - - Parameters - ---------- - uInit: True/False. - Switch for initializing the module. - True only during the first time step. - """ - n=np.pad(n,(0,3-n.shape[0]),mode='constant',constant_values=0.0) - if uInit is True or self.model is None: - u0, u1, u2 = self.U0 - else: - u0, u1, u2 = self.extractVelocity(x, t, n) - self.meanV = np.array([u0, u1, u2]) - # projection of u vector over an ortoganal plane to n - self.tanU = self.meanV - self.meanV * (n**2) - # tangential unit vector - self.tV = self.tanU/np.sqrt(np.sum(self.tanU**2)) - - def getVariables(self, x, t): - """ - Calculates velocity, gradient of the velocity and - kappa according with wall functions theory (see - S. B. Pope pg 442-443). - """ - comm = Comm.get().comm.tompi4py() - # Extraction of kappa - self.kappa = self.kWall.getKappa(x, t, self.xi, self.element, self.rank) - # Calculation of nominal friction velocity based on kappa - self.utStar = (self.kappa**0.5) * (self.Cmu**0.25) - self.Ystar = self.Y * self.utStar / self.nu - # Absolute value of the extracted velocity at y+ location. - Up = np.sqrt(np.sum(self.tanU**2)) - # viscous layer - if self.Ystar < 11.225: - self.Ustar = self.Ystar - self.uDir = (self.utStar*self.Ystar) * self.tV - self.gradU = ( (self.utStar**2)/self.nu ) * self.tV - # log-law layer - else: - # Wall function theory from S.B. Pope, page 442-443 - E = np.exp(self.B * self.K) - self.Ustar = self.utStar * np.log(E * self.Ystar) / self.K - self.utAbs = self.utStar * np.sqrt(Up/self.Ustar) - # Velocity vector and velocity gradient multiplied by the tangential vector unit - self.gradU = (self.utAbs/(self.K*self.Y)) * self.tV - # Linear approximation for velocity at the wall (using the gradU of the logLaw) - self.uDir = self.tanU - (self.gradU * self.Y) - - def get_u_dirichlet(self, x, t, n): - if t > 0.: - uInit = False - else: - uInit = True - self.tangentialVelocity(x, t, n, uInit) - self.getVariables(x, t) - return self.uDir[0] - - def get_v_dirichlet(self, x, t, n): - if t > 0.: - uInit = False - else: - uInit = True - self.tangentialVelocity(x, t, n, uInit) - self.getVariables(x, t) - return self.uDir[1] - - def get_w_dirichlet(self, x, t, n): - if t > 0.: - uInit = False - else: - uInit = True - self.tangentialVelocity(x, t, n, uInit) - self.getVariables(x, t) - return self.uDir[2] - - def get_k_dirichlet(self, x, t, n): - if t > 0.: - uInit = False - else: - uInit = True - self.tangentialVelocity(x, t,n, uInit) - self.getVariables(x, t) - return self.kappa - - def get_dissipation_dirichlet(self, x, t, n): - if t > 0.: - uInit = False - else: - uInit = True - self.tangentialVelocity(x, t, n, uInit) - self.getVariables(x, t) - d = 0. - if self.turbModel == 'ke': - d = (self.utStar**3)/(self.K*self.Y) - elif self.turbModel == 'kw' and self.kappa > 0.: - d = np.sqrt(self.kappa)/(self.K*self.Y*(self.Cmu**0.25)) - return d - - def get_u_diffusive(self, x, t, n): - if t > 0.: - uInit = False - else: - uInit = True - self.tangentialVelocity(x, t, n, uInit) - self.getVariables(x, t) - gradU = self.gradU[0] - return gradU - - def get_v_diffusive(self, x, t, n ): - if t > 0.: - uInit = False - else: - uInit = True - self.tangentialVelocity(x, t, n, uInit) - self.getVariables(x, t) - gradU = self.gradU[1] - return gradU - - def get_w_diffusive(self, x, t, n): - if t > 0.: - uInit = False - else: - uInit = True - self.tangentialVelocity(x, t, n, uInit) - self.getVariables(x, t) - gradU = self.gradU[2] - return gradU - - -class kWall(AuxiliaryVariables.AV_base): - """ - Auxiliary variable used to calculate attributes of an associated shape - class instance acting as a wall for the k variable. - """ - - def __init__(self, Y, Yplus, nu=1.004e-6, Cmu=0.09): - """ - Sets turbulent boundaries for wall treatment. - """ - self.kappa = 1e-10 - self.Y = Y - self.Yplus = Yplus - self.nu = nu - self.model = None - self.Cmu = Cmu - - def attachModel(self, model, ar): - """ - Attaches model to auxiliary variable - """ - self.model = model - self.ar = ar - self.nd = model.levelModelList[0].nSpace_global - return self - - def attachAuxiliaryVariables(self, avDict): - pass - - def calculate_init(self): - pass - - def calculate(self): - pass - - def getFluidKappaLocalCoords(self, xi, element, rank): - """ - - Parameters - ---------- - xi: - local coords in element - element: int - element number (local to processor 'rank') - rank: int - rank of processor owning the element - """ - comm = Comm.get().comm.tompi4py() - # solution of the selected model - self.u = self.model.levelModelList[0].u - #self.femSpace_kappa = self.u[0].femSpace - if comm.rank == rank: - kappa = self.u[0].getValue(element, xi) - else: - kappa = None - return kappa - - def kappaNearWall(self, xi, element, rank, kInit=None): - if kInit is True or self.model is None: - self.ut = self.Yplus * self.nu / self.Y - self.kappa = (self.ut**2)/np.sqrt(self.Cmu) - else: - self.kappa = self.getFluidKappaLocalCoords(xi, element, rank) - - def getKappa(self, x, t, xi, element, rank): - if t > 0.: - kInit = False - else: - kInit = True - self.kappaNearWall(xi, element, rank, kInit) - return abs(self.kappa) \ No newline at end of file diff --git a/proteus/mprans/SpatialTools.py b/proteus/mprans/SpatialTools.py deleted file mode 100644 index 5450b61f42..0000000000 --- a/proteus/mprans/SpatialTools.py +++ /dev/null @@ -1,2170 +0,0 @@ -""" -This module adds functionality to proteus.SpatialTools module by enabling -two-phase flow functionality such as converting shapes to moving rigid bodies, -or adding wave absorption and generation zones. - - -Example -------- -from proteus import Domain -from proteus.mprans import SpatialTools as st -import numpy as np - -domain = Domain.PlanarStraightLineGraphDomain() -tank = st.Tank2D(domain. dim=[4., 4.]) -tank.setSponge(left=0.4) -tank.setAbsorptionZones(left=true) -shape = st.Rectangle(domain, dim=[0.5, 0.5], coords=[1., 1.]) -shape.setRigidBody() -shape2.rotate(np.pi/3.) -shape2.BC.left.setNoSlip() - -st.assembleDomain(domain) -""" -from math import cos, sin, sqrt, atan2, acos, asin -from itertools import compress -import csv -import numbers -import os -import numpy as np -from proteus import AuxiliaryVariables, Archiver, Comm, Profiling, Gauges -from proteus.Profiling import logEvent -from proteus.mprans import BoundaryConditions as bc -from proteus.mprans import BodyDynamics as bd -from proteus.SpatialTools import (Shape, - Cuboid, - Sphere, - Cylinder, - Rectangle, - Circle, - CustomShape, - ShapeSTL, - BCContainer, - _assembleGeometry, - _generateMesh) - - -class ShapeRANS(Shape): - """ - Base/super class of all shapes. Sets the boundary condition class to - proteus.mprans.BoundaryConditions.BC_RANS. - - Parameters - ---------- - domain: proteus.Domain.D_base - Domain class instance that hold all the geometrical informations and - boundary conditions of the shape. - nd: Optional[int] - Number of dimensions of the shape. If not set, will take the number of - dimensions of the domain. - """ - - def __init__(self, domain, nd): - super(ShapeRANS, self).__init__(domain, nd, BC_class=bc.BC_RANS) - self.mass = None - self.density = None - self.free_x = (1, 1, 1) - self.free_r = (1, 1, 1) - self.record_values = False - self.zones = {} # for absorption/generation zones - self.auxiliaryVariables = {} # list of auxvar attached to shape - self.It = None # inertia tensor - - def _attachAuxiliaryVariable(self, key, auxvar=None, gauge=None): - """ - Attaches an auxiliary variable to the auxiliaryVariables dictionary of - the shape (used in buildDomain function) - - Parameters - ---------- - key: string - Dictionary key defining the auxiliaryVariable to attach - auxvar: - auxiliaryVariable to associate with key - - gauge: Gauges - - Notes - ----- - This function is called automatically when using other functions to set - auxiliaryVariables and should not be used manually. - """ - if key not in self.auxiliaryVariables: - if key == 'RigidBody': - self.auxiliaryVariables[key] = auxvar - if self.holes is None: - self.holes = np.array([self.barycenter[:self.nd]]) - elif key == 'WallFunction': - self.auxiliaryVariables[key] = auxvar - elif key == 'kWallFunction': - self.auxiliaryVariables[key] = auxvar - elif key == 'RelaxZones': - self.auxiliaryVariables[key] = self.zones - elif str(key).startswith('Gauge_'): - self.auxiliaryVariables[key] = [gauge] - else: - logEvent("auxiliaryVariable key: " - "{key} not recognized.".format(key=str(key)), level=1) - elif str(key).startswith('Gauge_'): - if gauge not in self.auxiliaryVariables[key]: - self.auxiliaryVariables[key] += [gauge] - else: - logEvent( - "Attempted to put identical " - "gauge at key: {key}".format(key=str(key)), level=1) - else: - logEvent("Key {key} is already attached.".format(key=str(key)), - level=1) - - def attachPointGauges(self, model_key, gauges, activeTime=None, - sampleRate=0, - fileName='point_gauges.csv'): - """Attaches Point Gauges (in the Proteus/Gauges.py style) to the shape. - - Parameters - ---------- - model_key: string - Label of the model to use as a key for selecting particular gauges. - See proteus Gauges.py PointGauges class for the remaining parameters. - """ - new_gauges = Gauges.PointGauges(gauges, activeTime, sampleRate, - fileName) - self._attachAuxiliaryVariable('Gauge_' + model_key, - gauge=new_gauges) - - def attachLineGauges(self, model_key, gauges, activeTime=None, - sampleRate=0, - fileName='line_gauges.csv'): - """Attaches Line Gauges (in the Proteus/Gauges.py style) to the shape. - - Parameters - ---------- - model_key: string - Label of the model to use as a key for selecting particular gauges. - See proteus Gauges.py LineGauges class for the remaining parameters. - """ - new_gauges = Gauges.LineGauges(gauges, activeTime, sampleRate, - fileName) - self._attachAuxiliaryVariable('Gauge_' + model_key, - gauge=new_gauges) - - def attachLineIntegralGauges(self, model_key, gauges, activeTime=None, - sampleRate=0, - fileName='line_integral_gauges.csv'): - """Attaches Line Integral Gauges (in the Proteus/Gauges.py style). - - Parameters - ---------- - model_key: string - Label of the model to use as a key for selecting particular gauges. - See proteus Gauges.py LineIntegralGauges class for the remaining parameters. - """ - new_gauges = Gauges.LineIntegralGauges(gauges, activeTime, - sampleRate, fileName) - self._attachAuxiliaryVariable('Gauge_' + model_key, - gauge=new_gauges) - - def setTank(self): - """ - Sets tank boundary conditions (for moving domain). - """ - for boundcond in self.BC_list: - boundcond.setTank() - - def setTurbulentWall(self, wall): - """ - Sets a turbulent wall as an object to be attacched to auxiliaryVariable. - The objects has to be defined with WallFunction class. - - Parameters - ---------- - wall: list of WallFunction class object - """ - - auxvar = wall - self._attachAuxiliaryVariable('WallFunction', auxvar) - - def setTurbulentKWall(self, kWall): - """ - Sets a turbulent wall as an object to be attacched to auxiliaryVariable. - The objects has to be defined with WallFunction class. - - Parameters - ---------- - kWall: list of WallFunction class object for kappa - """ - - auxvar = kWall - self._attachAuxiliaryVariable('kWallFunction', auxvar) - - def setAbsorptionZones(self, flags, epsFact_porous, center, orientation, - dragAlpha, vert_axis=None,dragBeta=0., - porosity=1.): - """ - Sets a region (given the local flag) to an absorption zone - - Parameters - ---------- - dragAlpha: Optional - Relaxation zone coefficient. - flags: array_like, int - Local flags of the region. Can be an integer or a list. - epsFact_porous: float - Half of absorption zone (region) length (used for blending func). - center: array_like - Coordinates of the center of the absorption zone. - orientation: array_like - Orientation vector pointing TOWARDS incoming waves. - vert_axis: Optional[int] - index of vertical position vector (x:0, y:1, z:2), must always be - aligned with gravity. If not set, will be 1 in 2D (y), 2 in 3D (z). - dragBeta: Optional[float] - Relaxation zone coefficient. - porosity: Optional[float] - Relaxation zone coefficient. - """ - self._attachAuxiliaryVariable('RelaxZones') - waves = None - wind_speed = np.array([0., 0., 0.]) - if isinstance(flags, numbers.Integral): - flags = [int(flags)] - epsFact_porous = [epsFact_porous] - center = np.array([center]) - orientation = np.array([orientation]) - dragAlpha = [dragAlpha] - dragBeta = [dragBeta] - porosity = [porosity] - for i, flag in enumerate(flags): - self._checkNd(center[i]) - self._checkNd(orientation[i]) - ori = get_unit_vector(orientation[i]) - self.zones[flag] = bc.RelaxationZone(shape=self, - zone_type='absorption', - orientation=ori, - center=center[i], - waves=waves, - wind_speed=wind_speed, - epsFact_porous=epsFact_porous[i], - dragAlpha=dragAlpha[i], - dragBeta=dragBeta[i], - porosity=porosity[i], - vert_axis=vert_axis) - - def setGenerationZones(self, flags, epsFact_porous, center, orientation, - waves, dragAlpha,vert_axis=None, - wind_speed=(0., 0., 0.), dragBeta=0., - porosity=1., smoothing=0.): - """ - Sets a region (given the local flag) to a generation zone - - Parameters - ---------- - flags: array_like, int - Local flags of the region. Can be an integer or a list. - epsFact_porous: float - Half of absorption zone (region) length (used for blending func). - center: array_like - Coordinates of the center of the absorption zone. - orientation: array_like - Orientation vector pointing ACCORDING WITH the direction of generated waves. - waves: proteus.WaveTools - Class instance of wave generated from proteus.WaveTools. - dragAlpha: Optional[float] - Relaxation zone coefficient. - vert_axis: Optional[int] - index of vertical position vector (x:0, y:1, z:2), must always be - aligned with gravity. If not set, will be 1 in 2D (y), 2 in 3D (z). - wind_speed: Optional[array_like] - Speed of wind in generation zone (default is (0., 0., 0.)) - dragBeta: Optional[float] - Relaxation zone coefficient. - porosity: Optional[float] - Relaxation zone coefficient. - """ - self._attachAuxiliaryVariable('RelaxZones') - if isinstance(flags, numbers.Integral): - flags = [int(flags)] - epsFact_porous = [epsFact_porous] - center = np.array([center]) - orientation = np.array([orientation]) - waves = [waves] - wind_speed = np.array([wind_speed]) - dragAlpha = [dragAlpha] - dragBeta = [dragBeta] - porosity = [porosity] - smoothing = [smoothing] - for i, flag in enumerate(flags): - self._checkNd(center[i]) - self._checkNd(orientation[i]) - ori = get_unit_vector(orientation[i]) - self.zones[flag] = bc.RelaxationZone(shape=self, - zone_type='generation', - orientation=ori, - center=center[i], - waves=waves[i], - wind_speed=wind_speed[i], - epsFact_porous=epsFact_porous[i], - dragAlpha=dragAlpha[i], - dragBeta=dragBeta[i], - porosity=porosity[i], - smoothing=smoothing[i], - vert_axis=vert_axis) - - def setPorousZones(self, flags, dragAlpha, dragBeta, - porosity): - """ - Sets a region (given the local flag) to a porous zone - - Parameters - ---------- - flags: array_like, int - Local flags of the region. Can be an integer or a list. - dragAlpha: float - Darcy-type coefficient - dragBeta: float - Forchheimer-type coefficient - porosity: float - Porosity - """ - self._attachAuxiliaryVariable('RelaxZones') - if isinstance(flags, numbers.Integral): - flags = [int(flags)] - dragAlpha = [dragAlpha] - dragBeta = [dragBeta] - porosity = [porosity] - for i, flag in enumerate(flags): - # note for porous zone: - # epsFact_porous = q_phi_sponge, --> Hs always equal to 1. - self.zones[flag] = bc.RelaxationZone(shape=self, - zone_type='porous', - orientation=None, - center=None, - waves=None, - wind_speed=None, - epsFact_porous=1., - dragAlpha=dragAlpha[i], - dragBeta=dragBeta[i], - porosity=porosity[i]) - -# ----------------------------------------------------------------------------- -# ADDING FUNCTIONALITY TO SHAPE FROM proteus.SpatialTools -# ----------------------------------------------------------------------------- - - -# reassigning base/super class to access all functions from ShapeRANS and Shape -Rectangle.__bases__ = (ShapeRANS,) -Cuboid.__bases__ = (ShapeRANS,) -Sphere.__bases__ = (ShapeRANS,) -Cylinder.__bases__ = (ShapeRANS,) -CustomShape.__bases__ = (ShapeRANS,) -ShapeSTL.__bases__ = (ShapeRANS,) -Circle.__bases__ = (ShapeRANS,) - -# adding extra functionality to predefined shapes - - -def _CuboidsetInertiaTensor(self): - """ - Sets the inertia tensor of the cuboid - (!) should not be used manually - """ - L, W, H = self.dim - self.It = [[(W**2.+H**2.)/12., 0, 0], - [0, (L**2.+H**2.)/12., 0], - [0, 0, (W**2.+L**2.)/12.]] - - -Cuboid._setInertiaTensor = _CuboidsetInertiaTensor - - -def _RectanglesetInertiaTensor(self): - """ - Sets the inertia tensor of the rectangle - (!) should not be used manually - """ - L, H = self.dim - self.It = (L**2+H**2)/12 - - -Rectangle._setInertiaTensor = _RectanglesetInertiaTensor - - -# ----------------------------------------------------------------------------- -# DEFINING NEW SHAPES TYPES -# ----------------------------------------------------------------------------- - -class Tank3D(ShapeRANS): - """ - Class to create a 3D tank (cuboidal shape). - - Parameters - ---------- - domain: proteus.Domain.D_base - Domain class instance that hold all the geometrical informations and - boundary conditions of the shape. - dim: Optional[array_like] - Dimensions of the cuboid. - coords: Optional[array_like] - Coordinates of the centroid of the shape. - """ - count = 0 - - def __init__(self, domain, dim=(0., 0., 0.), coords=None): - super(Tank3D, self).__init__(domain, nd=3) - self.__class__.count += 1 - self.name = "tank3d" + repr(self.__class__.count) - if coords is None: - self.coords = np.array(dim)/2. - self.from_0 = True - else: - self.coords = coords - self.from_0 = False - self.holes = None - self.boundaryTags = {'z-': 1, - 'x-': 2, - 'y+': 3, - 'x+': 4, - 'y-': 5, - 'z+': 6, - 'sponge': 7, - 'wall': 8} - self.b_or = np.array([[0., 0., -1.], - [-1., 0., 0.], - [0., 1., 0.], - [1., 0., 0.], - [0., -1., 0.], - [0., 0., 1.]]) - self.BC = {'z-': self.BC_class(shape=self, name='z-', - b_or=self.b_or, b_i=0), - 'x-': self.BC_class(shape=self, name='x-', - b_or=self.b_or, b_i=1), - 'y+': self.BC_class(shape=self, name='y+', - b_or=self.b_or, b_i=2), - 'x+': self.BC_class(shape=self, name='x+', - b_or=self.b_or, b_i=3), - 'y-': self.BC_class(shape=self, name='y+', - b_or=self.b_or, b_i=4), - 'z+': self.BC_class(shape=self, name='z+', - b_or=self.b_or, b_i=5), - 'sponge': self.BC_class(shape=self, name='sponge'), - 'wall': self.BC_class(shape=self, name='wall')} - self.BC_list = [self.BC['z-'], - self.BC['x-'], - self.BC['y+'], - self.BC['x+'], - self.BC['y+'], - self.BC['z+'], - self.BC['sponge'], - self.BC['wall']] - # self.BC = BCContainer(self.BC_dict) - for i in range(6): - self.BC_list[i].setTank() - self.barycenter = np.array([0., 0., 0.]) - self.spongeLayers = {'y+': None, 'y-': None, 'x+': None, 'x-': None} - self.setDimensions(dim) - - def setSponge(self, x_p=None, x_n=None, y_p=None, y_n=None): - """ - Set length of sponge layers of the tank (used for wave absorption or - generation zones). - (!) Sponge layers expand outwards. - - Parameters - ---------- - x_p: Optional[float] - length of sponge layer in +x direction. - x_n: Optional[float] - length of sponge layer in -x direction. - y_p: Optional[float] - length of sponge layer in +y direction. - y_n: Optional[float] - length of sponge layer in -y direction. - """ - self.spongeLayers['x+'] = x_p - self.spongeLayers['x-'] = x_n - self.spongeLayers['y+'] = y_p - self.spongeLayers['y-'] = y_n - self.setDimensions(self.dim) - - def setDimensions(self, dim): - """ - Set dimension of the tank - Parameters - ---------- - dim: array_like - dimensions of the tank (excluding sponge layers), array of length 3. - """ - L, W, H = dim - self.dim = dim - if self.from_0 is True: - x, y, z = L/2., W/2., H/2. - else: - x, y, z = self.coords - self.coords = [x, y, z] - x0, x1 = x - 0.5 * L, x + 0.5 * L - y0, y1 = y - 0.5 * W, y + 0.5 * W - z0, z1 = z - 0.5 * H, z + 0.5 * H - # --------------------------------------------- - # first add all vecors, facets, regions at the bottom - # --------------------------------------------- - bt = self.boundaryTags - x_p = self.spongeLayers['x+'] or 0. - x_n = self.spongeLayers['x-'] or 0. - y_p = self.spongeLayers['y+'] or 0. - y_n = self.spongeLayers['y-'] or 0. - vertices = [[x0, y0, z0], [x1, y0, z0], [x1, y1, z0], [x0, y1, z0], - [x0, y0, z1], [x1, y0, z1], [x1, y1, z1], [x0, y1, z1]] - vertexFlags = [bt['z-'], bt['z-'], bt['z-'], bt['z-'], - bt['z+'], bt['z+'], bt['z+'], bt['z+']] - facets = [[[0, 1, 2, 3]], [[4, 5, 6, 7]]] - segments = [] - segmentFlags = [] - volumes = [[[0, 1]]] - facetFlags = [bt['z-'], bt['z+']] - regions = [[(x0+x1)/2., (y0+y1)/2., (z0+z1)/2.]] - regionFlags = [1] - self.regionIndice = {'tank': 0} - v_i = 8 # index of next vector to add - r_i = 1 # index of next region to add - f_i = len(facets) - nb_sponge = 0 # number of sponge layers defined - - ymin = y0 - y_n - ymax = y1 + y_p - xmin = x0 - x_n - xmax = x1 + x_p - corners = False - # y- - if y_n: - v0 = v_i - v1 = v_i + 2 - v2 = v_i + 1 - v3 = v_i + 3 - if corners: - vertices += [[x0, ymin, z0], [x0, ymin, z1], - [x1, ymin, z0], [x1, ymin, z1]] - else: - vertices += [[xmin, ymin, z0], [xmin, ymin, z1], - [xmax, ymin, z0], [xmax, ymin, z1]] - vertexFlags += [bt['z-'], bt['z+'], - bt['z-'], bt['z+']] - facets += [[[v0, v1, v3, v2]]] - facetFlags += [bt['y-']] - volumes[0][0] += [f_i] - regions += [[(x0+x1)/2., (y0+(ymin))/2., (z0+z1)/2.]] - self.regionIndice['y-'] = r_i - regionFlags += [r_i + 1] - facets += [[[0, 1, v1, v0]], - [[4, 5, v3, v2]], - [[0, 1, 5, 4]], - [[0, v0, v2, 4]], - [[1, v1, v3, 5]]] - facetFlags += [bt['z-'], - bt['z+'], - bt['sponge']] - if x_n > 0: - facetFlags += [bt['wall']] - else: - facetFlags += [bt['x-']] - if x_p > 0: - facetFlags += [bt['wall']] - else: - facetFlags += [bt['x+']] - volumes[0][0][-1] = f_i + 3 # add to volume - r_i += 1 - nb_sponge += 1 - volumes += [[[len(facets) - i - 1 for i in range(6)]]] - x_n_facet_i = len(facets) - 2 - else: - facets += [[[0, 1, 5, 4]]] - facetFlags += [bt['y-']] - volumes[0][0] += [f_i] - v_i = len(vertices) - f_i = len(facets) - # x+ - if x_p: - if corners: - vertices += [[xmax, y0, z0], [xmax, y0, z1], - [xmax, y1, z0], [xmax, y1, z1]] - v0 = v_i - v1 = v_i + 2 - v2 = v_i + 1 - v3 = v_i + 3 - vertexFlags += [bt['z-'], bt['z+'], - bt['z-'], bt['z+']] - else: - v0 = v_i - 2 - v1 = v_i - v2 = v_i - 1 - v3 = v_i + 1 - if not y_n: - vertices += [[xmax, ymin, z0], [xmax, ymin, z1]] - vertexFlags += [bt['z-'], bt['z+']] - v0 = v_i - v1 = v_i + 2 - v2 = v_i + 1 - v3 = v_i + 3 - vertices += [[xmax, ymax, z0], [xmax, ymax, z1]] - vertexFlags += [bt['z-'], bt['z+']] - facets += [[[v0, v1, v3, v2]]] - facetFlags += [bt['x+']] - volumes[0][0] += [f_i] - regions += [[(x1+(xmax))/2., (y0+y1)/2., (z0+z1)/2.]] - self.regionIndice['x+'] = r_i - regionFlags += [r_i + 1] - facets += [[[1, 2, v1, v0]], - [[5, 6, v3, v2]], - [[1, 2, 6, 5]]] - facetFlags += [bt['z-'], - bt['z+'], - bt['sponge']] - if corners or not y_n: - facets += [[[1, v0, v2, 5]]] - if y_n > 0: - facetFlags += [bt['wall']] - else: - facetFlags += [bt['y-']] - facets += [[[2, v1, v3, 6]]] - if y_p > 0: - facetFlags += [bt['wall']] - else: - facetFlags += [bt['y+']] - volumes[0][0][-1] = f_i + 3 # add to volume - r_i += 1 - nb_sponge += 1 - volumes += [[[len(facets) - i - 1 for i in range(6)]]] - else: - facets += [[[1, 2, 6, 5]]] - facetFlags += [bt['x+']] - volumes[0][0] += [f_i] - v_i = len(vertices) - f_i = len(facets) - # y+ - if y_p: - if corners: - vertices += [[x1, ymax, z0], [x1, ymax, z1], - [x0, ymax, z0], [x0, ymax, z1]] - v0 = v_i - v1 = v_i + 2 - v2 = v_i + 1 - v3 = v_i + 3 - vertexFlags += [bt['z-'], bt['z+'], - bt['z-'], bt['z+']] - else: - v0 = v_i - 2 - v1 = v_i - v2 = v_i - 1 - v3 = v_i + 1 - if not x_p: - vertices += [[xmax, ymax, z0], [xmax, ymax, z1]] - vertexFlags += [bt['z-'], bt['z+']] - v0 = v_i - v1 = v_i + 2 - v2 = v_i + 1 - v3 = v_i + 3 - vertices += [[xmin, ymax, z0], [xmin, ymax, z1]] - vertexFlags += [bt['z-'], bt['z+']] - facets += [[[v0, v1, v3, v2]]] - volumes[0][0] += [f_i] - facetFlags += [bt['y+']] - regions += [[(x0+x1)/2., (y1+(ymax))/2., (z0+z1)/2.]] - self.regionIndice['y+'] = r_i - regionFlags += [r_i + 1] - facets += [[[2, 3, v1, v0]], - [[6, 7, v3, v2]], - [[2, 3, 7, 6]]] - facetFlags += [bt['z-'], - bt['z+'], - bt['sponge']] - if corners or not x_p: - facets += [[[2, v0, v2, 6]]] - if x_p > 0: - facetFlags += [bt['wall']] - else: - facetFlags += [bt['x+']] - facets += [[[3, v1, v3, 7]]] - if x_n > 0: - facetFlags += [bt['wall']] - else: - facetFlags += [bt['x-']] - volumes[0][0][-1] = f_i + 3 - r_i += 1 - nb_sponge += 1 - volumes += [[[len(facets) - i - 1 for i in range(6)]]] - else: - facets += [[[3, 2, 6, 7]]] - facetFlags += [bt['y+']] - volumes[0][0] += [f_i] - v_i = len(vertices) - f_i = len(facets) - # x- - if x_n: - volumes[0][0] += [f_i] - if corners: - vertices += [[xmin, y0, z0], [xmin, y0, z1], - [xmin, y1, z0], [xmin, y1, z1]] - v0 = v_i - v1 = v_i + 2 - v2 = v_i + 1 - v3 = v_i + 3 - vertexFlags += [bt['z-'], bt['z+'], - bt['z-'], bt['z+']] - else: - if not y_p: - vertices += [[xmin, ymax, z0], [xmin, ymax, z1]] - v0 = v_i - 2 - v1 = v_i - v2 = v_i - 1 - v3 = v_i + 1 - vertexFlags += [bt['z-'], bt['z+']] - if not y_n: - vertices += [[xmin, ymin, z0], [xmin, ymin, z1]] - if not y_p: - v0 = v_i + 2 - v1 = v_i - v2 = v_i + 3 - v3 = v_i + 1 - else: - v0 = v_i - v1 = v_i - 2 - v2 = v_i + 1 - v3 = v_i - 1 - vertexFlags += [bt['z-'], bt['z+']] - else: - v1 = v_i - 2 - v0 = 8 - v3 = v_i - 1 - v2 = 9 - if not y_p: - v1 = v_i - v3 = v_i + 1 - facets += [[[v0, v1, v3, v2]]] - facetFlags += [bt['x-']] - regions += [[(x0+(xmin))/2., (y0+y1)/2., (z0+z1)/2.]] - self.regionIndice['x-'] = r_i - regionFlags += [r_i + 1] - facets += [[[0, 3, v1, v0]], - [[4, 7, v3, v2]], - [[0, 3, 7, 4]]] - facetFlags += [bt['z-'], - bt['z+'], - bt['sponge']] - volumes[0][0][-1] = f_i + 3 - if corners or not y_n or not y_p: - if corners or not y_n: - facets += [[[0, v0, v2, 4]]] - if y_n > 0: - facetFlags += [bt['wall']] - else: - facetFlags += [bt['y-']] - if corners or not y_p: - facets += [[[3, v1, v3, 7]]] - if y_p > 0: - facetFlags += [bt['wall']] - else: - facetFlags += [bt['y+']] - r_i += 1 - nb_sponge += 1 - if corners or not y_n: - volumes += [[[len(facets) - i - 1 for i in range(6)]]] - else: - volumes += [[[len(facets) - i - 1 for i in range(5)] + [x_n_facet_i]]] - else: - facets += [[[0, 3, 7, 4]]] - facetFlags += [bt['x-']] - volumes[0][0] += [f_i] - v_i = len(vertices) - f_i = len(facets) - self.vertices = np.array(vertices) - self.vertices = np.dot(self.vertices, self.coords_system) - self.vertexFlags = np.array(vertexFlags) - self.segments = np.array(segments) - self.segmentFlags = np.array(segmentFlags) - self.facets = np.array(facets) - self.facetFlags = np.array(facetFlags) - self.regions = np.array(regions) - self.regionFlags = np.array(regionFlags) - self.volumes = volumes - - def setAbsorptionZones(self, dragAlpha, allSponge=False, - y_n=False, y_p=False, - x_n=False, x_p=False, - dragBeta=0., porosity=1.): - """ - Sets regions (x+, x-, y+, y-) to absorption zones - - Parameters - ---------- - dragAlpha: float - Relaxation zone coefficient. - allSponge: bool - If True, all sponge layers are converted to absorption zones. - x_p: bool - If True, x+ region is converted to absorption zone. - x_n: bool - If True, x- region is converted to absorption zone. - y_p: bool - If True, y+ region is converted to absorption zone. - y_n: bool - If True, y- region is converted to absorption zone. - dragBeta: Optional[float] - Relaxation zone coefficient. - porosity: Optional[float] - Relaxation zone coefficient. - """ - self.abs_zones = {'y-': y_n, 'y+': y_p, 'x-': x_n, 'x+': x_p} - if allSponge is True: - for key in self.abs_zones: - self.abs_zones[key] = True - waves = None - wind_speed = np.array([0., 0., 0.]) - sl = self.spongeLayers - for key, value in list(self.abs_zones.items()): - if value is True: - self._attachAuxiliaryVariable('RelaxZones') - ind = self.regionIndice[key] - flag = self.regionFlags[ind] - epsFact_porous = self.spongeLayers[key]/2. - center = np.array(self.coords) - zeros_to_append = 3 - len(center) - if zeros_to_append: - for i in range(zeros_to_append): - center = np.append(center, [0]) - if key == 'x-': - center[0] += -0.5 * self.dim[0] - 0.5 * sl['x-'] - orientation = np.array([1., 0., 0.]) - elif key == 'x+': - center[0] += +0.5 * self.dim[0] + 0.5 * sl['x+'] - orientation = np.array([-1., 0., 0.]) - elif key == 'y-': - center[1] += -0.5 * self.dim[1] - 0.5 * sl['y-'] - orientation = np.array([0., 1., 0.]) - elif key == 'y+': - center[1] += +0.5 * self.dim[1] + 0.5 * sl['y+'] - orientation = np.array([0., -1., 0.]) - self.zones[flag] = bc.RelaxationZone(shape=self, - zone_type='absorption', - orientation=orientation, - center=center, - waves=waves, - wind_speed=wind_speed, - epsFact_porous=epsFact_porous, - dragAlpha=dragAlpha, - dragBeta=dragBeta, - porosity=porosity) - - def setGenerationZones(self, dragAlpha, smoothing, waves=None, - wind_speed=(0., 0., 0.), allSponge=False, y_n=False, - y_p=False, x_n=False, x_p=False, dragBeta=0., - porosity=1.): - """ - Sets regions (x+, x-, y+, y-) to generation zones - - Parameters - ---------- - dragAlpha: float - Relaxation zone coefficient. - smoothing: float - Smoothing distance (typically 3.*he) - waves: proteus.WaveTools - Class instance of wave generated from proteus.WaveTools. - wind_speed: Optional[array_like] - Speed of wind in generation zone (default is (0., 0., 0.)) - allSponge: bool - If True, all sponge layers are converted to generation zones. - x_p: bool - If True, x+ region is converted to generation zone. - x_n: bool - If True, x- region is converted to generation zone. - y_p: bool - If True, y+ region is converted to generation zone. - y_n: bool - If True, y- region is converted to generation zone. - dragBeta: Optional[float] - Relaxation zone coefficient. - porosity: Optional[float] - Relaxation zone coefficient. - """ - self.abs_zones = {'y-': y_n, 'y+': y_p, 'x-': x_n, 'x+': x_p} - if allSponge is True: - for key in self.abs_zones: - self.abs_zones[key] = True - waves = waves - wind_speed = np.array(wind_speed) - sl = self.spongeLayers - for key, value in list(self.abs_zones.items()): - if value is True: - self._attachAuxiliaryVariable('RelaxZones') - ind = self.regionIndice[key] - flag = self.regionFlags[ind] - epsFact_porous = self.spongeLayers[key]/2. - center = np.array(self.coords) - zeros_to_append = 3 - len(center) - if zeros_to_append: - for i in range(zeros_to_append): - center = np.append(center, [0]) - if key == 'x-': - center[0] += -0.5 * self.dim[0] - sl['x-']/2. - orientation = np.array([1., 0., 0.]) - self.BC['x-'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, - wind_speed=wind_speed, - smoothing=smoothing) - elif key == 'x+': - center[0] += +0.5 * self.dim[0] + sl['x+']/2. - orientation = np.array([-1., 0., 0.]) - self.BC['x+'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, - wind_speed=wind_speed, - smoothing=smoothing) - elif key == 'y-': - center[1] += -0.5 * self.dim[1] - sl['y-']/2. - orientation = np.array([0., 1., 0.]) - self.BC['y-'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, - wind_speed=wind_speed, - smoothing=smoothing) - elif key == 'y+': - center[1] += +0.5 * self.dim[1] + sl['y+']/2. - orientation = np.array([0., -1., 0.]) - self.BC['y+'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, - wind_speed=wind_speed, - smoothing=smoothing) - self.zones[flag] = bc.RelaxationZone(shape=self, - zone_type='generation', - orientation=orientation, - center=center, - waves=waves, - wind_speed=wind_speed, - epsFact_porous=epsFact_porous, - dragAlpha=dragAlpha, - dragBeta=dragBeta, - porosity=porosity, - smoothing=smoothing) - - -class Tank2D(ShapeRANS): - """ - Class to create a 2D tank (rectangular shape). - - Parameters - ---------- - domain: proteus.Domain.D_base - Domain class instance that hold all the geometrical informations and - boundary conditions of the shape. - dim: array_like - Dimensions of the tank (excluding sponge layers). - coords: Optional[array_like] - Coordinates of the centroid of the shape. - """ - count = 0 - - def __init__(self, domain, dim, coords=None): - super(Tank2D, self).__init__(domain, nd=2) - if coords is None: - self.coords = np.array(dim)/2. - self.from_0 = True - else: - self.coords = coords - self.from_0 = False - self.dim = dim - self._nameSelf() - self._setupBCs() - self.spongeLayers = {'x-': None, - 'x+': None} - self.constructShape() - - def _nameSelf(self): - self.__class__.count += 1 - self.name = "tank2D" + repr(self.__class__.count) - - def _setupBCs(self): - self.boundaryTags = {'y-': 1, 'x+': 2, 'y+': 3, 'x-': 4, 'sponge': 5} - self.b_or = np.array([[0., -1., 0.], - [1., 0., 0.], - [0., 1., 0.], - [-1., 0., 0.]]) - self.BC = {'y-': self.BC_class(shape=self, name='y-', - b_or=self.b_or, b_i=0), - 'x+': self.BC_class(shape=self, name='x+', - b_or=self.b_or, b_i=1), - 'y+': self.BC_class(shape=self, name='y+', - b_or=self.b_or, b_i=2), - 'x-': self.BC_class(shape=self, name='x-', - b_or=self.b_or, b_i=3), - 'sponge': self.BC_class(shape=self, name='sponge')} - self.BC_list = [self.BC['y-'], - self.BC['x+'], - self.BC['y+'], - self.BC['x-'], - self.BC['sponge']] - # self.BC = BCContainer(self.BC_dict) - for i in range(4): - self.BC_list[i].setTank() - - def constructShape(self): - """ - Construct the geometry of the tank: segments, regions, etc. - - Parameters - ---------- - frame: array_like - An array of (x,y) coordinates in counterclockwise order to define - the boundaries of the main (that is, excluding extensions such as - sponge zones) shape. This can be generated with tank2DFrame or - subclass specific methods. - frame_flags: array_like - A corresponding array of boundary tags associated with each point - in the frame. This can be generated with tank2DFrame or subclass - specific methods. - """ - self._findEdges(self.dim) - vertices, vertexFlags = self._constructVertices() - segments, segmentFlags = self._constructSegments(vertices, vertexFlags) - regions, regionFlags = self._constructRegions(vertices, vertexFlags, - segments, segmentFlags) - facets, facetFlags = self._constructFacets() - - self.vertices = np.array(vertices) - self.vertexFlags = np.array(vertexFlags) - self.segments = np.array(segments) - self.segmentFlags = np.array(segmentFlags) - self.regions = np.array(regions) - self.regionFlags = np.array(regionFlags) - self.facets = np.array(facets) - self.facetFlags = np.array(facetFlags) - - def _findEdges(self, dim): - - coords = self.coords - from_0 = self.from_0 - - if from_0: - self.x0 = 0 - self.x1 = dim[0] - self.y0 = 0 - self.y1 = dim[1] - else: # not from_0 and coords is not None - self.x0 = coords[0] - 0.5 * dim[0] - self.x1 = coords[0] + 0.5 * dim[0] - self.y0 = coords[1] - 0.5 * dim[1] - self.y1 = coords[1] + 0.5 * dim[1] - - def _constructVertices(self): - vertices = [[self.x0, self.y0], - [self.x1, self.y0], - [self.x1, self.y1], - [self.x0, self.y1]] - vertexFlags = [self.boundaryTags['y-'], - self.boundaryTags['y-'], - self.boundaryTags['y+'], - self.boundaryTags['y+']] - if self.spongeLayers['x-']: - vertices += [[self.x0 - self.spongeLayers['x-'], self.y0], - [self.x0 - self.spongeLayers['x-'], self.y1]] - vertexFlags += [self.boundaryTags['y-'], - self.boundaryTags['y+']] - if self.spongeLayers['x+']: - vertices += [[self.x1 + self.spongeLayers['x+'], self.y0], - [self.x1 + self.spongeLayers['x+'], self.y1]] - vertexFlags += [self.boundaryTags['y-'], - self.boundaryTags['y+']] - return vertices, vertexFlags - - def _constructSegments(self, vertices, vertexFlags): - segments = [[0, 1], [1, 2], [2, 3], [3, 0]] - segmentFlags = [self.boundaryTags['y-'], - self.boundaryTags['x+'], - self.boundaryTags['y+'], - self.boundaryTags['x-']] - added_vertices = 0 - if self.spongeLayers['x-']: - segments += [[0, 4 + added_vertices], - [4 + added_vertices, 5 + added_vertices], - [5 + added_vertices, 3]] - segmentFlags += [self.boundaryTags['y-'], - self.boundaryTags['x-'], - self.boundaryTags['y+']] - segmentFlags[3] = self.boundaryTags['sponge'] - added_vertices += 2 - if self.spongeLayers['x+']: - segments += [[1, 4 + added_vertices], - [4 + added_vertices, 5 + added_vertices], - [5 + added_vertices, 2]] - segmentFlags += [self.boundaryTags['y-'], - self.boundaryTags['x+'], - self.boundaryTags['y+']] - segmentFlags[1] = self.boundaryTags['sponge'] - added_vertices += 2 - return segments, segmentFlags - - def _constructFacets(self): - facets = [[[0, 1, 2, 3]]] - facetFlags = [1] - added_vertices = 0 - added_facets = 0 - if self.spongeLayers['x-']: - facets += [[[3, 0, 4, 5]]] - facetFlags += [2 + added_facets] - added_vertices += 2 - added_facets += 1 - if self.spongeLayers['x+']: - facets += [[[2, 1, added_vertices + 4, added_vertices + 5]]] - facetFlags += [2 + added_facets] - return facets, facetFlags - - def _constructRegions(self, vertices, vertexFlags, segments, segmentFlags): - regions = [[self.x0 + 0.01 * (self.x1 - self.x0), 0.5 * (self.y0 + self.y1)], ] - ind_region = 1 - regionFlags = [ind_region, ] - self.regionIndice = {'tank': ind_region - 1} - if self.spongeLayers['x-']: - regions += [[self.x0 - 0.5 * self.spongeLayers['x-'], - 0.5 * (self.y0 + self.y1)]] - ind_region += 1 - regionFlags += [ind_region] - self.regionIndice['x-'] = ind_region - 1 - if self.spongeLayers['x+']: - regions += [[self.x1 + 0.5 * self.spongeLayers['x+'], - 0.5 * (self.y0 + self.y1)]] - ind_region += 1 - regionFlags += [ind_region] - self.regionIndice['x+'] = ind_region - 1 - return regions, regionFlags - - def setSponge(self, x_n=None, x_p=None): - """ - Set length of sponge layers of the tank (used for wave absorption or - generation zones). - (!) Sponge layers expand outwards. - - Parameters - ---------- - x_p: Optional[float] - length of sponge layer in +x direction. - x_n: Optional[float] - length of sponge layer in -x direction. - """ - self.spongeLayers['x-'] = x_n - self.spongeLayers['x+'] = x_p - self.constructShape() - - def setAbsorptionZones(self, dragAlpha, x_n=False, x_p=False, - dragBeta=0., porosity=1.): - """ - Sets regions (x+, x-) to absorption zones - - Parameters - ---------- - dragAlpha: float - Relaxation zone coefficient. - allSponge: bool - If True, all sponge layers are converted to absorption zones. - x_p: bool - If True, x+ region is converted to absorption zone. - x_n: bool - If True, x- region is converted to absorption zone. - dragBeta: Optional[float] - Relaxation zone coefficient. - porosity: Optional[float] - Relaxation zone coefficient. - """ - waves = None - wind_speed = np.array([0., 0., 0.]) - if x_n or x_p: - self._attachAuxiliaryVariable('RelaxZones') - if x_n is True: - center = np.array([self.coords[0]-0.5*self.dim[0]-0.5*self.spongeLayers['x-'], - self.coords[1], - 0.]) - ind = self.regionIndice['x-'] - flag = self.regionFlags[ind] - epsFact_porous = self.spongeLayers['x-']/2. - orientation = np.array([1., 0.]) - self.zones[flag] = bc.RelaxationZone(shape=self, - zone_type='absorption', - orientation=orientation, - center=center, - waves=waves, - wind_speed=wind_speed, - epsFact_porous=epsFact_porous, - dragAlpha=dragAlpha, - dragBeta=dragBeta, - porosity=porosity) - if x_p is True: - center = np.array([self.coords[0]+0.5*self.dim[0]+0.5*self.spongeLayers['x+'], - self.coords[1], - 0.]) - ind = self.regionIndice['x+'] - flag = self.regionFlags[ind] - epsFact_porous = self.spongeLayers['x+']/2. - orientation = np.array([-1., 0.]) - self.zones[flag] = bc.RelaxationZone(shape=self, - zone_type='absorption', - orientation=orientation, - center=center, - waves=waves, - wind_speed=wind_speed, - epsFact_porous=epsFact_porous, - dragAlpha=dragAlpha, - dragBeta=dragBeta, - porosity=porosity) - - def setGenerationZones(self, dragAlpha, smoothing, - waves=None, wind_speed=(0., 0., 0.), - x_n=False, x_p=False, - dragBeta=0., porosity=1.): - """ - Sets regions (x+, x-) to generation zones - - Parameters - ---------- - dragAlpha: float - Relaxation zone coefficient - smoothing: - Smoothing distance - waves: proteus.WaveTools - Class instance of wave generated from proteus.WaveTools. - wind_speed: Optional[array_like] - Speed of wind in generation zone (default is (0., 0., 0.)) - allSponge: bool - If True, all sponge layers are converted to generation zones. - x_p: bool - If True, x+ region is converted to generation zone. - x_n: bool - If True, x- region is converted to generation zone. - dragBeta: Optional[float] - Relaxation zone coefficient. - porosity: Optional[float] - Relaxation zone coefficient. - """ - waves = waves - wind_speed = np.array(wind_speed) - if x_n or x_p: - self._attachAuxiliaryVariable('RelaxZones') - if x_n is True: - center = np.array([self.coords[0]-0.5*self.dim[0]-0.5*self.spongeLayers['x-'], - self.coords[1], - 0.]) - ind = self.regionIndice['x-'] - flag = self.regionFlags[ind] - epsFact_porous = self.spongeLayers['x-']/2. - orientation = np.array([1., 0.]) - self.zones[flag] = bc.RelaxationZone(shape=self, - zone_type='generation', - orientation=orientation, - center=center, - waves=waves, - wind_speed=wind_speed, - epsFact_porous=epsFact_porous, - dragAlpha=dragAlpha, - dragBeta=dragBeta, - porosity=porosity, - smoothing=smoothing) - self.BC['x-'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, - wind_speed=wind_speed, - smoothing=smoothing) - if x_p is True: - center = np.array([self.coords[0]+0.5*self.dim[0]+0.5*self.spongeLayers['x+'], - self.coords[1], - 0.]) - ind = self.regionIndice['x+'] - flag = self.regionFlags[ind] - epsFact_porous = self.spongeLayers['x+']/2. - orientation = np.array([-1., 0.]) - self.zones[flag] = bc.RelaxationZone(shape=self, - zone_type='generation', - orientation=orientation, - center=center, - waves=waves, - wind_speed=wind_speed, - epsFact_porous=epsFact_porous, - dragAlpha=dragAlpha, - dragBeta=dragBeta, - porosity=porosity, - smoothing=smoothing) - self.BC['x+'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, - wind_speed=wind_speed, - smoothing=smoothing) - -#[temp] no tests yet! - - -class TankWithObstacles2D(Tank2D): - """ - Class to create a 2D rectangular tank with obstacles built out of any wall. - - An obstacle is defined by a contiguous list of points which start and end - on the walls or corners of the tank. - - This also covers special boundary conditions. To tag a segment with a - unique boundary tag, add the starting vertex (in the counterclockwise - format the shape is generated in) of the segment as a value in a dictionary - element keyed to the name of the boundary tag. - - (!) Warning: If each of the four corners of the rectangular tank is inside - an obstacle or a vertex for an obstacle, then the tank's region is defined - in a pseudorandom manner, which may make it unreliable when dealing with - holes caused by other shapes. - (!) Warning: Obstacle boundary tags are keyed to whichever edge they started - from. If this is undesirable, it may be manually overriden by applying - special boundary conditions to affected segments. - - Parameters - ---------- - domain: proteus.Domain.D_base - Domain class instance that hold all the geometrical informations and - boundary conditions of the shape. - dim: Optional[array_like] - Dimensions of the cuboid. - obstacles: Optional[array_like] - A list of lists of (x,y) coordinates. Each (x,y) coordinate is a length - and height relative to the x-,y- corner of the tank. Each list of - coordinates is an obstacle defined by points connected in the order of - their index. The list of lists gives all such obstacles in a - counterclockwise manner of which they should be appended, starting from - the (x-,y-) corner. - special_boundaries: Optional[mapping] - A dictionary of lists of vertices keyed to boundary names. The vertices - listed will be given the boundary name they are keyed to, overriding - any other designation they would be given. - If this is a distinct boundary name, the segment starting from the vertex - will be assigned the same boundary tag. - full_circle: Optional[bool] - A boolean tag to check if the final obstacle ends on the same edge that - the first obstacle starts on. Default is False. - coords: Optional[array_like] - Coordinates of the centroid of the shape. - hole: Optional[bool] - If True (default), the obstacle of the tank is just an open hole at the - bottom of the tank. If False, a segment at the bottom of the obstacle is - created to close the hole. - obstacle_regions: Optional[array_like] - To use only if hole=False.(x,y) coordinates of a point inside the - obstacle in order to fill the obstacle with what should be inside - (for example a porous material). - - """ - - def __init__(self, domain, dim=(0., 0.), - obstacles=None, special_boundaries=None, - full_circle=False, - coords=None, hole=True, obstacle_regions=None): - if obstacles: - self.obstacles = obstacles - else: - self.obstacles = [] - - self.special_boundaries = [] - self.special_BC_vertices = [] - self.full_circle = full_circle - - self.spongeLayers = {'x-': None, - 'x+': None} - - if special_boundaries: - for key in list(special_boundaries.keys()): - self.special_boundaries += [key for v in special_boundaries[key]] - self.special_BC_vertices += special_boundaries[key] - - self.corners = {'x-y-': False, 'x+y-': False, - 'x+y+': False, 'x-y+': False} - - self.hole = hole - self.obstacle_regions = obstacle_regions - super(TankWithObstacles2D, self).__init__(domain, dim, coords) - - def _setupBCs(self): - super(TankWithObstacles2D, self)._setupBCs() - for boundary in self.special_boundaries: - if boundary not in list(self.boundaryTags.keys()): - self.boundaryTags[boundary] = len(self.boundaryTags) + 1 - self.BC[boundary] = self.BC_class(shape=self, name=boundary) - self.BC_list += [self.BC[boundary]] - # add boundaryTags - self.obstacle_flags = [] - max_flag = 0 - for tag, flag in list(self.boundaryTags.items()): - if flag > max_flag: - max_flag = flag - flag = max_flag + 1 - for i in range(len(self.obstacles)): - tag = 'obstacle' + repr(i + 1) - self.boundaryTags[tag] = flag - self.obstacle_flags += [flag] - self.BC[tag] = self.BC_class(shape=self, name=tag) - self.BC_list += [self.BC[tag]] - flag += 1 - if self.hole is False: - assert len(self.obstacles) == len(self.obstacle_regions), 'must have same number of regions as obstacles' - - def _resetEdgesFromVertices(self, vertices): - """ - Resets self.x0, self.x1, self.y0, self.y1 based on the actual shape. - - In particular, they will form a bounding box form around the shape - - the furthest points in x and y dimensions, both high and low. - - Parameters - ---------- - vertices: array_like - """ - sorted_vertices = sorted(vertices, key=lambda vertex: vertex[1]) - self.y0 = sorted_vertices[0][1] - self.y1 = sorted_vertices[-1][1] - sorted_vertices = sorted(vertices, key=lambda vertex: vertex[0]) - self.x0 = sorted_vertices[0][0] - self.x1 = sorted_vertices[-1][0] - - def _findSpongeLayerCorners(self, vertices): - """ - Finds the corners for horizontal (x-, x+) sponge layers. - - Parameters - ---------- - vertices: array_like - """ - self._resetEdgesFromVertices(vertices) - - potential_x_n_corners = [vertex for vertex in vertices - if np.isclose(vertex[0], self.x0)] - potential_x_p_corners = [vertex for vertex in vertices - if np.isclose(vertex[0], self.x1)] - - potential_x_n_corners.sort(key=lambda vertex: vertex[1]) - potential_x_p_corners.sort(key=lambda vertex: vertex[1]) - - self.x0y0 = potential_x_n_corners[0] - self.x0y1 = potential_x_n_corners[-1] - self.x1y0 = potential_x_p_corners[0] - self.x1y1 = potential_x_p_corners[-1] - - def _constructVertices(self): - - def getClockwiseOrder(first_point): - clockwise_ordering = ('x-y-', 'y-', 'x+y-', 'x+', - 'x+y+', 'y+', 'x-y+', 'x-') - index = clockwise_ordering.index(first_point) - return clockwise_ordering[index:] + clockwise_ordering[:index] - - def findLocation(vertex): - """ - Given an (x,y) coordinate gives a label associated to corner or edge - """ - dim = [self.x1 - self.x0, self.y1 - self.y0] - if np.isclose(vertex[0], 0) and np.isclose(vertex[1], 0): - return 'x-y-' - elif np.isclose(vertex[0], dim[0]) and np.isclose(vertex[1], dim[1]): - return 'x+y+' - elif np.isclose(vertex[0], 0) and np.isclose(vertex[1], dim[1]): - return 'x-y+' - elif np.isclose(vertex[0], dim[0]) and np.isclose(vertex[1], 0): - return 'x+y-' - elif np.isclose(vertex[0], 0): - return 'x-' - elif np.isclose(vertex[0], dim[0]): - return 'x+' - elif np.isclose(vertex[1], 0): - return 'y-' - elif np.isclose(vertex[1], dim[1]): - return 'y+' - else: - raise ValueError("Point " + str(vertex) + " does not seem to" - "be on a tank wall.") - - def checkClosure(start_point, end_point): - if start_point == end_point: - return True - - def addCorner(corner_flag): - if corner_flag == 'x-y-': - corner = [[self.x0, self.y0]] - elif corner_flag == 'x+y-': - corner = [[self.x1, self.y0]] - elif corner_flag == 'x+y+': - corner = [[self.x1, self.y1]] - elif corner_flag == 'x-y+': - corner = [[self.x0, self.y1]] - # vertex flags - if corner_flag in ['x-y-', 'x+y-']: - corner_tag = [self.boundaryTags['y-']] - else: - corner_tag = [self.boundaryTags['y+']] - - return corner, corner_tag - - def addIntermediateCorners(first, last): - """ - Returns corner vertices (and flags) in between two segments - """ - ordering = getClockwiseOrder(first) - corners = [x for x in ordering - if x in list(self.corners.keys()) - and ordering.index(x) < ordering.index(last) - ] - corner_vertices = [] - corner_flags = [] - - for corner in corners: - self.corners[corner] = True - vertex, flag = addCorner(corner) - corner_vertices += vertex - corner_flags += flag - - return corner_vertices, corner_flags - - def addRemainingCorners(first, last): - if first == last: - if self.full_circle: - return [] - else: - return addAllCorners(first) - else: - return addIntermediateCorners(first, last) - - def addAllCorners(starting_point): - """ - Returns all corners and flags. - """ - corner_vertices = [] - corner_flags = [] - - ordering = getClockwiseOrder(starting_point) - - for potential_corner in ordering: - if potential_corner in list(self.corners.keys()): - self.corners[potential_corner] = True - vertex, flag = addCorner(potential_corner) - corner_vertices += vertex - corner_flags += flag - - return corner_vertices, corner_flags - - def addSpongeVertices(): - sponge_vertices = [] - sponge_vertexFlags = [] - if self.spongeLayers['x-']: - sponge_vertices += [[v[0] - self.spongeLayers['x-'], v[1]] - for v in [self.x0y0, self.x0y1]] - sponge_vertexFlags += [self.boundaryTags['y-'], - self.boundaryTags['y+']] - if self.spongeLayers['x+']: - sponge_vertices += [[v[0] + self.spongeLayers['x+'], v[1]] - for v in [self.x1y0, self.x1y1]] - sponge_vertexFlags += [self.boundaryTags['y-'], - self.boundaryTags['y+']] - return sponge_vertices, sponge_vertexFlags - - #--------------------------------------------------------# - vertices = [] - vertexFlags = [] - former_end = None - first_start = None - - for nb, obstacle in enumerate(self.obstacles): - start = findLocation(obstacle[0]) - end = findLocation(obstacle[-1]) - - if start == end and checkClosure(obstacle[0], obstacle[-1]): - raise ValueError("Obstacles must be open (start and end" - " vertices must be distinct)") - if start == former_end and checkClosure(obstacle[0], vertices[-1]): - vertices.pop() - vertexFlags.pop() - - # ---- In-Between Corner Vertices ---- # - if former_end is not None: - new_vertices, new_flags = addIntermediateCorners(former_end, start) - vertices += new_vertices - vertexFlags += new_flags - - # ---- Obstacle ---- # - if self.hole is True: - vertices += obstacle - vertexFlags += [self.boundaryTags[start] - for i in range(len(obstacle))] - elif self.hole is False: - vertices += obstacle - vertexFlags += [self.boundaryTags['obstacle' + repr(nb + 1)] - for i in range(len(obstacle))] - - # ---- Paperwork ---- # - former_end = end - if first_start is None: - first_start = start - - # ---- Remaining Corner Vertices ---- # - if first_start is not None: - new_vertices, new_flags = addRemainingCorners(former_end, - first_start) - else: - new_vertices, new_flags = addAllCorners('x-') - - vertices += new_vertices - vertexFlags += new_flags - - # ---- Check for Special Conditions ---- # - for vertex in self.special_BC_vertices: - flag_index = vertices.index(vertex) - boundary_index = self.special_BC_vertices.index(vertex) - boundary_name = self.special_boundaries[boundary_index] - vertexFlags[flag_index] = self.boundaryTags[boundary_name] - - # ---- Adjustments for Sponge Zones ---- # - self._findSpongeLayerCorners(vertices=vertices) - - # ---- Add Sponge Zone Vertices ---- # - new_vertices, new_flags = addSpongeVertices() - vertices += new_vertices - vertexFlags += new_flags - - return vertices, vertexFlags - - def _constructSegments(self, vertices, vertexFlags): - # VertexFlag --> SegmentFlag logic: - # - # if EITHER are x+ --> segment is x+ - # UNLESS the other is x- --> y+ - # if EITHER are x- --> segment is x- - # UNLESS the other is x+ --> y- - # if it STARTS y- --> segment is y- - # UNLESS they are vertical --> x+ - # if it STARTS y+ --> segment is y+ - # UNLESS they are vertical --> x- - # if BOTH are *** --> segment is *** - # (if two different *** are around, it takes the first) - segments = [] - segmentFlags = [] - - on_sponge_edge = {'x-': False, 'x+': False} - sponge_edges_covered = {'x-': False, 'x+': False} - - def checkSpongeStatus(start_index, end_index): - start_vertex = vertices[start_index] - if self.spongeLayers['x-']: - if not on_sponge_edge['x-']: - if start_vertex in (self.x0y0, self.x0y1): - on_sponge_edge['x-'] = True - elif not sponge_edges_covered['x-']: - if start_vertex in (self.x0y0, self.x0y1): - on_sponge_edge['x-'] = False - sponge_edges_covered['x-'] = True - else: - vertexFlags[start_index] = self.boundaryTags['sponge'] - else: - pass - - if self.spongeLayers['x+']: - if not on_sponge_edge['x+']: - if start_vertex in (self.x1y0, self.x1y1): - on_sponge_edge['x+'] = True - elif not sponge_edges_covered['x+']: - if start_vertex in (self.x1y0, self.x1y1): - on_sponge_edge['x+'] = False - sponge_edges_covered['x+'] = True - else: - vertexFlags[start_index] = self.boundaryTags['sponge'] - else: - pass - - end_vertex = vertices[end_index] - if on_sponge_edge['x-']: - if end_vertex not in (self.x0y0, self.x0y1): - vertexFlags[end_index] = self.boundaryTags['sponge'] - if on_sponge_edge['x+']: - if end_vertex not in (self.x1y0, self.x1y1): - vertexFlags[end_index] = self.boundaryTags['sponge'] - - def getSegmentFlag(start, end): - if ((self.spongeLayers['x-'] and not sponge_edges_covered['x-']) or - (self.spongeLayers['x+'] and not sponge_edges_covered['x+'])): - checkSpongeStatus(start, end) - - if on_sponge_edge['x-'] or on_sponge_edge['x+']: - return [self.boundaryTags['sponge'], ] - - else: - if vertexFlags[start] in self.obstacle_flags: - if vertexFlags[end] == vertexFlags[start]: - return [vertexFlags[start], ] - else: - return [self.boundaryTags['y-'], ] - elif vertexFlags[start] == self.boundaryTags['x+']: - if vertexFlags[end] == self.boundaryTags['x-']: - return [self.boundaryTags['y+'], ] - else: - return [self.boundaryTags['x+'], ] - - elif vertexFlags[start] == self.boundaryTags['x-']: - if vertexFlags[end] == self.boundaryTags['x+']: - return [self.boundaryTags['y-'], ] - else: - return [self.boundaryTags['x-'], ] - - elif vertexFlags[end] == self.boundaryTags['x+']: - if vertexFlags[start] in [self.boundaryTags['y-'], - self.boundaryTags['y+']]: - return [self.boundaryTags['x+'], ] - - elif vertexFlags[end] == self.boundaryTags['x-']: - if vertexFlags[start] in [self.boundaryTags['y-'], - self.boundaryTags['y+']]: - return [self.boundaryTags['x-'], ] - - elif vertexFlags[start] == self.boundaryTags['y-']: - if (vertexFlags[end] == self.boundaryTags['y+'] - and np.isclose(vertices[start][0], vertices[end][0]) - ): - return [self.boundaryTags['x+'], ] - else: - return [self.boundaryTags['y-'], ] - - elif vertexFlags[start] == self.boundaryTags['y+']: - if (vertexFlags[end] == self.boundaryTags['y-'] - and np.isclose(vertices[start][0], vertices[end][0]) - ): - return [self.boundaryTags['x-'], ] - else: - return [self.boundaryTags['y+'], ] - - else: - return [vertexFlags[start], ] - - # ---- Initial Sponge Logic ---- # - sponge_vertex_count = 0 - - if self.spongeLayers['x-']: - sponge_vertex_count += 2 - if self.spongeLayers['x+']: - sponge_vertex_count += 2 - - # ---- Build Main Segments ---- # - for i in range(len(vertices) - 1 - sponge_vertex_count): - segments += [[i, i + 1], ] - segmentFlags += getSegmentFlag(i, i + 1) - segments += [[len(vertices) - 1 - sponge_vertex_count, 0], ] - segmentFlags += getSegmentFlag(len(vertices) - 1 - sponge_vertex_count, - 0) - if self.hole is False: - start_vertex_obstacle = 0 - for obstacle in self.obstacles: - segments += [[start_vertex_obstacle, start_vertex_obstacle + (len(obstacle) - 1)]] - segmentFlags += [self.boundaryTags['y-']] - start_vertex_obstacle += len(obstacle) - - # ---- Build Sponge Segments ---- # - if self.spongeLayers['x-']: - segments += [[vertices.index(self.x0y0), - len(vertices) - sponge_vertex_count], - [len(vertices) - sponge_vertex_count, - len(vertices) - sponge_vertex_count + 1], - [len(vertices) - sponge_vertex_count + 1, - vertices.index(self.x0y1)] - ] - segmentFlags += [self.boundaryTags['y-'], - self.boundaryTags['x-'], - self.boundaryTags['y+']] - if self.spongeLayers['x+']: - segments += [[vertices.index(self.x1y0), len(vertices) - 2], - [len(vertices) - 2, len(vertices) - 1], - [len(vertices) - 1, vertices.index(self.x1y1)] - ] - segmentFlags += [self.boundaryTags['y-'], - self.boundaryTags['x+'], - self.boundaryTags['y+']] - - return segments, segmentFlags - - def _constructRegions(self, vertices, vertexFlags, segments, segmentFlags): - - ind_region = 0 - self.regionIndice = {} - regions = [] - regionFlags = [] - - if self.hole is False: - for i, region in enumerate(self.obstacle_regions): - regions = [[region[0], region[1]]] - ind_region += 1 - regionFlags = [ind_region, ] - self.regionIndice['obstacle' + repr(i + 1)] = ind_region - 1 - - if True in list(self.corners.values()): - regions += self._getCornerRegion() - else: - regions += self._getRandomRegion(vertices, segments) - - ind_region += 1 - regionFlags += [ind_region] - self.regionIndice['tank'] = ind_region - 1 - - sponge_half_height_x0 = 0.5 * (self.x0y0[1] + self.x0y1[1]) - sponge_half_height_x1 = 0.5 * (self.x1y0[1] + self.x1y1[1]) - sponge_x0 = self.x0y0[0] - sponge_x1 = self.x1y0[0] - - if self.spongeLayers['x-']: - regions += [[sponge_x0 - 0.5 * self.spongeLayers['x-'], - sponge_half_height_x0]] - ind_region += 1 - regionFlags += [ind_region] - self.regionIndice['x-'] = ind_region - 1 - if self.spongeLayers['x+']: - regions += [[sponge_x1 + 0.5 * self.spongeLayers['x+'], - sponge_half_height_x1]] - ind_region += 1 - regionFlags += [ind_region] - self.regionIndice['x+'] = ind_region - 1 - - return regions, regionFlags - - def _findExtrema(self, points): - """ - Return the extrema of a series of points in n dimensions in the form: - max(x1), max(x2), ... , max(xn), min(x1), ... , min(xn) - """ - points = np.array(points) - return np.max(points, 0).tolist() + np.min(points, 0).tolist() - - def _getCornerRegion(self): - eps = np.finfo(float).eps - if self.corners['x-y-']: - return [[self.x0 + eps, self.y0 + eps], ] - elif self.corners['x+y-']: - return [[self.x1 - eps, self.y0 + eps], ] - elif self.corners['x+y+']: - return [[self.x1 - eps, self.y1 - eps], ] - elif self.corners['x-y+']: - return [[self.x0 + eps, self.y1 - eps], ] - - def _getRandomRegion(self, vertices, segments): - x_p, y_p, x_n, y_n = self._findExtrema(vertices) - if self.spongeLayers['x-']: - x_n += self.spongeLayers['x-'] - if self.spongeLayers['x+']: - x_p -= self.spongeLayers['x+'] - - count = 0 - allowed_tries = 100 - - while True: - count += 1 - vertical_line = np.random.uniform(x_n, x_p) - if True in [np.isclose(vertical_line, vertex[0]) for vertex in - vertices]: - continue - - lowest_intersect = second_intersect = y_p - - for segment in segments: - line_x0 = vertices[segment[0]][0] - line_y0 = vertices[segment[0]][1] - line_x1 = vertices[segment[1]][0] - line_y1 = vertices[segment[1]][1] - if (line_x0 < vertical_line < line_x1 - or line_x0 > vertical_line > line_x1): - # (due to the strict inequality check and - # our selection of vertical_line - x1 > x0 should be sure) - intersection_height = line_y0 + ( - (line_y1 - line_y0) - * (vertical_line - line_x0) - / (line_x1 - line_x0) - ) - if intersection_height < lowest_intersect: - second_intersect = lowest_intersect - lowest_intersect = intersection_height - elif intersection_height < second_intersect: - second_intersect = intersection_height - - interior_point = 0.5 * (lowest_intersect + second_intersect) - - if lowest_intersect < interior_point < second_intersect: - break - if count > allowed_tries: - ValueError( - "Cannot find a proper interior point of the defined " - "shape after " + str(count) + " tries.") - - return [[vertical_line, interior_point], ] - - def setAbsorptionZones(self, dragAlpha, x_n=False, x_p=False, - dragBeta=0., porosity=1.): - """ - Sets regions (x+, x-) to absorption zones - - Parameters - ---------- - dragAlpha: float - Relaxation zone coefficient - allSponge: bool - If True, all sponge layers are converted to absorption zones. - x_p: bool - If True, x+ region is converted to absorption zone. - x_n: bool - If True, x- region is converted to absorption zone. - dragBeta: Optional[float] - Relaxation zone coefficient. - porosity: Optional[float] - Relaxation zone coefficient. - """ - sponge_half_height_x0 = 0.5 * (self.x0y0[1] + self.x0y1[1]) - sponge_half_height_x1 = 0.5 * (self.x1y0[1] + self.x1y1[1]) - sponge_x0 = self.x0y0[0] - sponge_x1 = self.x1y0[0] - - waves = None - wind_speed = np.array([0., 0., 0.]) - if x_n or x_p: - self._attachAuxiliaryVariable('RelaxZones') - if x_n is True: - center = np.array([sponge_x0 - 0.5 * self.spongeLayers['x-'], - sponge_half_height_x0, 0.]) - ind = self.regionIndice['x-'] - flag = self.regionFlags[ind] - epsFact_porous = self.spongeLayers['x-']/2. - orientation = np.array([1., 0.]) - self.zones[flag] = bc.RelaxationZone(shape=self, - zone_type='absorption', - orientation=orientation, - center=center, - waves=waves, - wind_speed=wind_speed, - epsFact_porous=epsFact_porous, - dragAlpha=dragAlpha, - dragBeta=dragBeta, - porosity=porosity) - if x_p is True: - center = np.array([sponge_x1 + 0.5 * self.spongeLayers['x+'], - sponge_half_height_x1, 0.]) - ind = self.regionIndice['x+'] - flag = self.regionFlags[ind] - epsFact_porous = self.spongeLayers['x+']/2. - orientation = np.array([-1., 0.]) - self.zones[flag] = bc.RelaxationZone(shape=self, - zone_type='absorption', - orientation=orientation, - center=center, - waves=waves, - wind_speed=wind_speed, - epsFact_porous=epsFact_porous, - dragAlpha=dragAlpha, - dragBeta=dragBeta, - porosity=porosity) - - def setGenerationZones(self, dragAlpha, smoothing, waves=None, - wind_speed=(0., 0., 0.), x_n=False, x_p=False, - dragBeta=0., porosity=1.): - """ - Sets regions (x+, x-) to generation zones - - Parameters - ---------- - dragAlpha: float - Relaxation zone coefficient. - smoothing: float - Smoothing distance (typically 3*he) - waves: proteus.WaveTools - Class instance of wave generated from proteus.WaveTools. - wind_speed: Optional[array_like] - Speed of wind in generation zone (default is (0., 0., 0.)) - allSponge: bool - If True, all sponge layers are converted to generation zones. - x_p: bool - If True, x+ region is converted to generation zone. - x_n: bool - If True, x- region is converted to generation zone. - dragBeta: Optional[float] - Relaxation zone coefficient. - porosity: Optional[float] - Relaxation zone coefficient. - """ - sponge_half_height_x0 = 0.5 * (self.x0y0[1] + self.x0y1[1]) - sponge_half_height_x1 = 0.5 * (self.x1y0[1] + self.x1y1[1]) - sponge_x0 = self.x0y0[0] - sponge_x1 = self.x1y0[0] - - waves = waves - wind_speed = np.array(wind_speed) - if x_n or x_p: - self._attachAuxiliaryVariable('RelaxZones') - if x_n is True: - - center = np.array([sponge_x0 - 0.5 * self.spongeLayers['x-'], - sponge_half_height_x0, 0.]) - ind = self.regionIndice['x-'] - flag = self.regionFlags[ind] - epsFact_porous = self.spongeLayers['x-']/2. - orientation = np.array([1., 0.]) - self.zones[flag] = bc.RelaxationZone(shape=self, - zone_type='generation', - orientation=orientation, - center=center, - waves=waves, - wind_speed=wind_speed, - epsFact_porous=epsFact_porous, - dragAlpha=dragAlpha, - dragBeta=dragBeta, - porosity=porosity, - smoothing=smoothing) - self.BC['x-'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, - wind_speed=wind_speed, - smoothing=smoothing) - if x_p is True: - - center = np.array([sponge_x1 + 0.5 * self.spongeLayers['x+'], - sponge_half_height_x1, 0.]) - ind = self.regionIndice['x+'] - flag = self.regionFlags[ind] - epsFact_porous = self.spongeLayers['x+']/2. - orientation = np.array([-1., 0.]) - self.zones[flag] = bc.RelaxationZone(shape=self, - zone_type='generation', - orientation=orientation, - center=center, - waves=waves, - wind_speed=wind_speed, - epsFact_porous=epsFact_porous, - dragAlpha=dragAlpha, - dragBeta=dragBeta, - porosity=porosity, - smoothing=smoothing) - self.BC['x+'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, - wind_speed=wind_speed, - smoothing=smoothing) - - -def assembleDomain(domain): - """ - This function sets up everything needed for the domain, meshing, and - AuxiliaryVariables calculations (if any). - It should always be called after defining and manipulating all the shapes - to be attached to the domain. - - Parameters - ---------- - domain: proteus.Domain.D_base - Domain class instance that hold all the geometrical informations and - boundary conditions of the shape. - """ - _assembleGeometry(domain, BC_class=bc.BC_RANS) - domain.BCbyFlag[0].setNonMaterial() # set BC for boundary between processors - assembleAuxiliaryVariables(domain) - if(domain.name != "PUMIDomain"): - _generateMesh(domain) - - -def assembleAuxiliaryVariables(domain): - """ - Adds the auxiliary variables to the domain. - - Parameters - ---------- - domain: proteus.Domain.D_base - Domain class instance that hold all the geometrical informations and - boundary conditions of the shape. - - Notes - ----- - Should be called after assembleGeometry - """ - - domain.auxiliaryVariables = { - 'dissipation': [], - 'kappa': [], - 'ls': [], - 'ls_consrv': [], - 'moveMesh': [], - 'redist': [], - 'twp': [], - 'vof': [], - 'thp': [], - 'vos': [], - 'SWFlow' :[] - } - - zones_global = {} - start_region = 0 - start_rflag = 0 - start_flag = 0 - for shape in domain.shape_list: - aux = domain.auxiliaryVariables - # ---------------------------- - # RIGID BODIES - if 'RigidBody' in list(shape.auxiliaryVariables.keys()): - body = shape.auxiliaryVariables['RigidBody'] - aux['twp'] += [body] - # fixing mesh on rigid body - for boundcond in shape.BC_list: - boundcond.setRigidBodyMoveMesh(body) - # update the indice for force/moment calculations - body.i_start = start_flag + 1 - body.i_end = start_flag + 1 + len(shape.BC_list) - if 'ChRigidBody' in list(shape.auxiliaryVariables.keys()): - body = shape.auxiliaryVariables['ChRigidBody'] - for boundcond in shape.BC_list: - boundcond.setChMoveMesh(body) - if body.boundaryFlags.size == 0: - flags = [] - for tag, flag in shape.boundaryTags.items(): - flags += [start_flag+flag] - body.setBoundaryFlags(flags) - if 'WallFunction' in list(shape.auxiliaryVariables.keys()): - wall = shape.auxiliaryVariables['WallFunction'] - for ii in range(len(wall)): - aux['twp'] += [wall[ii]] - logEvent('WALL ATTACHED TO AUXVAR --> %s' % wall[ii]) - if 'kWallFunction' in list(shape.auxiliaryVariables.keys()): - kWall = shape.auxiliaryVariables['kWallFunction'] - for ii in range(len(kWall)): - aux['kappa'] += [kWall[ii]] - logEvent('kWALL ATTACHED TO AUXVAR --> %s' % kWall[ii]) - # ---------------------------- - # ABSORPTION/GENERATION ZONES - - if 'RelaxZones' in list(shape.auxiliaryVariables.keys()): - if not zones_global: - aux['twp'] += [bc.RelaxationZoneWaveGenerator(zones_global, - domain.nd)] - # add relaxation zones to SWFlow AuxiliaryVariables - aux['SWFlow'] += [bc.RelaxationZoneWaveGenerator(zones_global, - domain.nd)] - if not hasattr(domain, 'porosityTypes'): - # create arrays of default values - domain.porosityTypes = np.ones(len(domain.regionFlags) + 1) - domain.dragAlphaTypes = np.zeros(len(domain.regionFlags) + 1) - domain.dragBetaTypes = np.zeros(len(domain.regionFlags) + 1) - domain.epsFact_porous = np.zeros(len(domain.regionFlags) + 1) - i0 = start_region + 1 - for flag, zone in list(shape.zones.items()): - ind = [i for i, f in enumerate(shape.regionFlags) if f == flag] - for i1 in ind: - domain.porosityTypes[i0 + i1] = zone.porosity - domain.dragAlphaTypes[i0 + i1] = zone.dragAlpha - domain.dragBetaTypes[i0 + i1] = zone.dragBeta - domain.epsFact_porous[i0 + i1] = zone.epsFact_porous - # update dict with global key instead of local key - key = flag + start_rflag - zones_global[key] = zone - start_flag += len(shape.BC_list) - # ---------------------------- - # GAUGES - gauge_dict = {key: shape.auxiliaryVariables.get(key, []) - for key in list(shape.auxiliaryVariables.keys()) - if str(key).startswith('Gauge_')} - for key in list(gauge_dict.keys()): - key_name = key.split('_', 1)[1] # Cutting off "Gauge_" prefix - if key_name not in aux: - # It is probably too dangerous to simply put "aux[key_name] = []" - # as this system is fragile to typos. Instead, we throw an error. - raise ValueError('ERROR: Gauge key ', - key_name, - ' is not a recognized model by SpatialTools.', - ' The known models in our dictionary are ', - str(list(aux.keys())) - ) - else: - aux[key_name] += gauge_dict[key] - if shape.regions is not None: - start_region += len(shape.regions) - start_rflag = max(domain.regionFlags[0:start_region]) - - -def get_unit_vector(vector): - return np.array(vector)/np.linalg.norm(vector) \ No newline at end of file diff --git a/proteus/mprans/__init__.py b/proteus/mprans/__init__.py index 4c9c876dfa..28e5226f2a 100644 --- a/proteus/mprans/__init__.py +++ b/proteus/mprans/__init__.py @@ -1,35 +1,9 @@ -""" -Modules for simulating free surface incompressible flow and fluid/structure interaction -""" +"""Deprecated: the free surface flow kernels are in proteus.kernels (C49 R1); see proteus._kernel_aliases.""" +from proteus import _kernel_aliases -__all__ = ["AddedMass", - "BodyDynamics", - "BoundaryConditions", - "Dissipation", - "Kappa", - "MoveMeshMonitor", - "NCLS", - "Pres", - "RANS3PF", - "SpatialTools", - "VOF3P", - "ArchiveBeams", - "BoundaryConditions", - "GN_SW2DCV", - "MCorr3P", - "MoveMesh", - "PresInc", - "RANS2P_IB", - "RANS3PSed", - "SW2DCV", - "VOF", - "beamFEM", - "CLSVOF", - "MCorr", - "NCLS3P", - "PresInit", - "RANS2P", - "RDLS", - "SW2D", - "VOS3P", - "TADR"] +_kernel_aliases.install(__name__) + +__all__ = ["AddedMass", "ArchiveBeams", "BodyDynamics", "BoundaryConditions", "CLSVOF", "Dissipation", "GN_SW2DCV", + "Kappa", "MCorr", "MCorr3P", "MoveMesh", "MoveMeshMonitor", "NCLS", "NCLS3P", "Pres", "PresInc", "PresInit", + "RANS2P", "RANS2P_IB", "RANS3PF", "RANS3PSed", "RDLS", "SW2D", "SW2DCV", "SpatialTools", "TADR", "VOF", "VOF3P", + "VOS3P", "beamFEM"] diff --git a/proteus/pskRelations.h b/proteus/pskRelations.h index ac0555db01..60ba5866e6 100644 --- a/proteus/pskRelations.h +++ b/proteus/pskRelations.h @@ -783,7 +783,7 @@ class PskSpline: public PskRelation /** \file \brief Richards free-function PSK closures (moved here from - proteus/richards/psk_models.h). + proteus/kernels/psk_models.h). The class hierarchy above (VGM/VGB/BCM/BCB/...) exposes the same constitutive models through a stateful calc(Sw) interface. The routines diff --git a/proteus/richards/ADR.h b/proteus/richards/ADR.h deleted file mode 100644 index d2836d2a6d..0000000000 --- a/proteus/richards/ADR.h +++ /dev/null @@ -1,653 +0,0 @@ -#ifndef ADR_H -#define ADR_H -#include -#include -#include -#include "CompKernel.h" -#include "ModelFactory.h" -#include "../mprans/ArgumentsDict.h" -#include "pyarray.h" -#define nnz nSpace - -namespace py = pybind11; -#define POWER_SMOOTHNESS_INDICATOR 2 -#define IS_BETAij_ONE 0 -#define GLOBAL_FCT 0 - -namespace proteus -{ -namespace richards -{ - class ADR_base - { - //The base class defining the interface - public: - virtual ~ADR_base(){} - virtual void calculateResidual(arguments_dict& args)=0; - virtual void calculateJacobian(arguments_dict& args)=0; - }; - - template - - class ADR : public ADR_base - { - public: - const int nDOF_test_X_trial_element; - CompKernelType ck; - ADR(): - nDOF_test_X_trial_element(nDOF_test_element*nDOF_trial_element), - ck() - {} - - inline - - void evaluateCoefficients(const proteus_csr_index_t rowptr[nSpace], - const proteus_csr_index_t colind[nnz], - const double rho, - const double beta, - const double gravity[nSpace], - const double alpha, - const double n_vg, - const double thetaR, - const double thetaSR, - const double KWs[nnz], - const double& u, - double& m, - double& dm, - double f[nSpace], - double df[nSpace], - double a[nnz], - double da[nnz], - double as[nnz], - double& kr, - double& dkr) - { - const int nSpace2 = nSpace * nSpace; - double psiC; - double pcBar; - double pcBar_n; - double pcBar_nM1; - double pcBar_nM2; - double onePlus_pcBar_n; - double sBar; - double sqrt_sBar; - double DsBar_DpsiC; - double thetaW; - double DthetaW_DpsiC; - double vBar; - double vBar2; - double DvBar_DpsiC; - double KWr; - double DKWr_DpsiC; - double rho2 = rho * rho; - double thetaS; - double rhom; - double drhom; - double m_vg; - double pcBarStar; - double sqrt_sBarStar; - m = u; //rhom*thetaW; //u - dm = 1.0; //-rhom*DthetaW_DpsiC+drhom*thetaW;// 1.0;// - for (int I=0;I& mesh_trial_ref = args.array("mesh_trial_ref"); - proteus::pyarray& mesh_grad_trial_ref = args.array("mesh_grad_trial_ref"); - proteus::pyarray& mesh_dof = args.array("mesh_dof"); - proteus::pyarray& mesh_velocity_dof = args.array("mesh_velocity_dof"); - double MOVING_DOMAIN = args.scalar("MOVING_DOMAIN"); - proteus::pyarray& mesh_l2g = args.array("mesh_l2g"); - proteus::pyarray& dV_ref = args.array("dV_ref"); - proteus::pyarray& u_trial_ref = args.array("u_trial_ref"); - proteus::pyarray& u_grad_trial_ref = args.array("u_grad_trial_ref"); - proteus::pyarray& u_test_ref = args.array("u_test_ref"); - proteus::pyarray& u_grad_test_ref = args.array("u_grad_test_ref"); - proteus::pyarray& mesh_trial_trace_ref = args.array("mesh_trial_trace_ref"); - proteus::pyarray& mesh_grad_trial_trace_ref = args.array("mesh_grad_trial_trace_ref"); - proteus::pyarray& dS_ref = args.array("dS_ref"); - proteus::pyarray& u_trial_trace_ref = args.array("u_trial_trace_ref"); - proteus::pyarray& u_grad_trial_trace_ref = args.array("u_grad_trial_trace_ref"); - proteus::pyarray& u_test_trace_ref = args.array("u_test_trace_ref"); - proteus::pyarray& u_grad_test_trace_ref = args.array("u_grad_test_trace_ref"); - proteus::pyarray& normal_ref = args.array("normal_ref"); - proteus::pyarray& boundaryJac_ref = args.array("boundaryJac_ref"); - proteus_index_t nElements_global = args.scalar("nElements_global"); - proteus::pyarray& ebqe_penalty_ext = args.array("ebqe_penalty_ext"); - proteus::pyarray& elementMaterialTypes = args.array("elementMaterialTypes"); - proteus::pyarray& isSeepageFace = args.array("isSeepageFace"); - proteus::pyarray& a_rowptr = args.array("a_rowptr"); - proteus::pyarray& a_colind = args.array("a_colind"); - double rho = args.scalar("rho"); - double beta = args.scalar("beta"); - proteus::pyarray& gravity = args.array("gravity"); - proteus::pyarray& alpha = args.array("alpha"); - proteus::pyarray& n = args.array("n"); - proteus::pyarray& thetaR = args.array("thetaR"); - proteus::pyarray& thetaSR = args.array("thetaSR"); - proteus::pyarray& KWs = args.array("KWs"); - double useMetrics = args.scalar("useMetrics"); - double alphaBDF = args.scalar("alphaBDF"); - int lag_shockCapturing = args.scalar("lag_shockCapturing"); - double shockCapturingDiffusion = args.scalar("shockCapturingDiffusion"); - double sc_uref = args.scalar("sc_uref"); - double sc_alpha = args.scalar("sc_alpha"); - proteus::pyarray& u_l2g = args.array("u_l2g"); - proteus::pyarray& elementDiameter = args.array("elementDiameter"); - proteus::pyarray& u_dof = args.array("u_dof"); - proteus::pyarray& u_dof_old = args.array("u_dof_old"); - proteus::pyarray& velocity = args.array("velocity"); - proteus::pyarray& q_m = args.array("q_m"); - proteus::pyarray& q_u = args.array("q_u"); - proteus::pyarray& q_dV = args.array("q_dV"); - proteus::pyarray& q_m_betaBDF = args.array("q_m_betaBDF"); - proteus::pyarray& cfl = args.array("cfl"); - proteus::pyarray& q_numDiff_u = args.array("q_numDiff_u"); - proteus::pyarray& q_numDiff_u_last = args.array("q_numDiff_u_last"); - proteus_index_t offset_u = args.scalar("offset_u"); - proteus_index_t stride_u = args.scalar("stride_u"); - proteus::pyarray& globalResidual = args.array("globalResidual"); - proteus_index_t nExteriorElementBoundaries_global = args.scalar("nExteriorElementBoundaries_global"); - proteus::pyarray& exteriorElementBoundariesArray = args.array("exteriorElementBoundariesArray"); - proteus::pyarray& elementBoundaryElementsArray = args.array("elementBoundaryElementsArray"); - proteus::pyarray& elementBoundaryLocalElementBoundariesArray = args.array("elementBoundaryLocalElementBoundariesArray"); - proteus::pyarray& ebqe_velocity_ext = args.array("ebqe_velocity_ext"); - proteus::pyarray& isDOFBoundary_u = args.array("isDOFBoundary_u"); - proteus::pyarray& ebqe_bc_u_ext = args.array("ebqe_bc_u_ext"); - proteus::pyarray& isFluxBoundary_u = args.array("isFluxBoundary_u"); - proteus::pyarray& ebqe_bc_flux_ext = args.array("ebqe_bc_flux_ext"); - proteus::pyarray& ebqe_phi = args.array("ebqe_phi"); - double epsFact = args.scalar("epsFact"); - proteus::pyarray& ebqe_u = args.array("ebqe_u"); - proteus::pyarray& ebqe_flux = args.array("ebqe_flux"); - // PARAMETERS FOR EDGE BASED STABILIZATION - double cE = args.scalar("cE"); - double cK = args.scalar("cK"); - // PARAMETERS FOR LOG BASED ENTROPY FUNCTION - double uL = args.scalar("uL"); - double uR = args.scalar("uR"); - // PARAMETERS FOR EDGE VISCOSITY - proteus_index_t numDOFs = args.scalar("numDOFs"); - proteus_csr_index_t NNZ = args.scalar("NNZ"); - proteus::pyarray& csrRowIndeces_DofLoops = args.array("csrRowIndeces_DofLoops"); - proteus::pyarray& csrColumnOffsets_DofLoops = args.array("csrColumnOffsets_DofLoops"); - proteus::pyarray& csrRowIndeces_CellLoops = args.array("csrRowIndeces_CellLoops"); - proteus::pyarray& csrColumnOffsets_CellLoops = args.array("csrColumnOffsets_CellLoops"); - proteus::pyarray& csrColumnOffsets_eb_CellLoops = args.array("csrColumnOffsets_eb_CellLoops"); - // C matrices - proteus::pyarray& Cx = args.array("Cx"); - proteus::pyarray& Cy = args.array("Cy"); - proteus::pyarray& Cz = args.array("Cz"); - proteus::pyarray& CTx = args.array("CTx"); - proteus::pyarray& CTy = args.array("CTy"); - proteus::pyarray& CTz = args.array("CTz"); - proteus::pyarray& ML = args.array("ML"); - proteus::pyarray& delta_x_ij = args.array("delta_x_ij"); - // PARAMETERS FOR 1st or 2nd ORDER MPP METHOD - int LUMPED_MASS_MATRIX = args.scalar("LUMPED_MASS_MATRIX"); - int STABILIZATION_TYPE = args.scalar("STABILIZATION_TYPE"); - int ENTROPY_TYPE = args.scalar("ENTROPY_TYPE"); - // FOR FCT - proteus::pyarray& dLow = args.array("dLow"); - proteus::pyarray& fluxMatrix = args.array("fluxMatrix"); - proteus::pyarray& uDotLow = args.array("uDotLow"); - proteus::pyarray& uLow = args.array("uLow"); - proteus::pyarray& dt_times_fH_minus_fL = args.array("dt_times_fH_minus_fL"); - proteus::pyarray& min_s_bc = args.array("min_s_bc"); - proteus::pyarray& max_s_bc = args.array("max_s_bc"); - // AUX QUANTITIES OF INTEREST - proteus::pyarray& quantDOFs = args.array("quantDOFs"); - proteus::pyarray& sLow = args.array("sLow"); - proteus::pyarray& sn = args.array("sn"); - - assert(a_rowptr.data()[nSpace] == nnz); - assert(a_rowptr.data()[nSpace] == nSpace); - //cek should this be read in? - double Ct_sge = 4.0; - // if (LUMPED_MASS_MATRIX ==1) - // { - // mass_lumping(nElements_global, nDOF_test_element, nQuadraturePoints_element, u_test_ref, dV_ref, ML, u_l2g); - // } - - //loop over elements to compute volume integrals and load them into element and global residual - // - //eN is the element index - //eN_k is the quadrature point index for a scalar - //eN_k_nSpace is the quadrature point index for a vector - //eN_i is the element test function index - //eN_j is the element trial function index - //eN_k_j is the quadrature point index for a trial function - //eN_k_i is the quadrature point index for a trial function - for(proteus_index_t eN=0;eN& mesh_trial_ref = args.array("mesh_trial_ref"); - proteus::pyarray& mesh_grad_trial_ref = args.array("mesh_grad_trial_ref"); - proteus::pyarray& mesh_dof = args.array("mesh_dof"); - proteus::pyarray& mesh_velocity_dof = args.array("mesh_velocity_dof"); - double MOVING_DOMAIN = args.scalar("MOVING_DOMAIN"); - proteus::pyarray& mesh_l2g = args.array("mesh_l2g"); - proteus::pyarray& dV_ref = args.array("dV_ref"); - proteus::pyarray& u_trial_ref = args.array("u_trial_ref"); - proteus::pyarray& u_grad_trial_ref = args.array("u_grad_trial_ref"); - proteus::pyarray& u_test_ref = args.array("u_test_ref"); - proteus::pyarray& u_grad_test_ref = args.array("u_grad_test_ref"); - proteus::pyarray& mesh_trial_trace_ref = args.array("mesh_trial_trace_ref"); - proteus::pyarray& mesh_grad_trial_trace_ref = args.array("mesh_grad_trial_trace_ref"); - proteus::pyarray& dS_ref = args.array("dS_ref"); - proteus::pyarray& u_trial_trace_ref = args.array("u_trial_trace_ref"); - proteus::pyarray& u_grad_trial_trace_ref = args.array("u_grad_trial_trace_ref"); - proteus::pyarray& u_test_trace_ref = args.array("u_test_trace_ref"); - proteus::pyarray& u_grad_test_trace_ref = args.array("u_grad_test_trace_ref"); - proteus::pyarray& normal_ref = args.array("normal_ref"); - proteus::pyarray& boundaryJac_ref = args.array("boundaryJac_ref"); - proteus_index_t nElements_global = args.scalar("nElements_global"); - proteus::pyarray& ebqe_penalty_ext = args.array("ebqe_penalty_ext"); - proteus::pyarray& elementMaterialTypes = args.array("elementMaterialTypes"); - proteus::pyarray& isSeepageFace = args.array("isSeepageFace"); - proteus::pyarray& a_rowptr = args.array("a_rowptr"); - proteus::pyarray& a_colind = args.array("a_colind"); - double rho = args.scalar("rho"); - double beta = args.scalar("beta"); - proteus::pyarray& gravity = args.array("gravity"); - proteus::pyarray& alpha = args.array("alpha"); - proteus::pyarray& n = args.array("n"); - proteus::pyarray& thetaR = args.array("thetaR"); - proteus::pyarray& thetaSR = args.array("thetaSR"); - proteus::pyarray& KWs = args.array("KWs"); - double useMetrics = args.scalar("useMetrics"); - double alphaBDF = args.scalar("alphaBDF"); - int lag_shockCapturing = args.scalar("lag_shockCapturing"); - double shockCapturingDiffusion = args.scalar("shockCapturingDiffusion"); - proteus::pyarray& u_l2g = args.array("u_l2g"); - proteus::pyarray& elementDiameter = args.array("elementDiameter"); - proteus::pyarray& u_dof = args.array("u_dof"); - proteus::pyarray& velocity = args.array("velocity"); - proteus::pyarray& q_m_betaBDF = args.array("q_m_betaBDF"); - proteus::pyarray& cfl = args.array("cfl"); - proteus::pyarray& q_numDiff_u_last = args.array("q_numDiff_u_last"); - proteus::pyarray& csrRowIndeces_u_u = args.array("csrRowIndeces_u_u"); - proteus::pyarray& csrColumnOffsets_u_u = args.array("csrColumnOffsets_u_u"); - proteus::pyarray& globalJacobian = args.array("globalJacobian"); - proteus_index_t nExteriorElementBoundaries_global = args.scalar("nExteriorElementBoundaries_global"); - proteus::pyarray& exteriorElementBoundariesArray = args.array("exteriorElementBoundariesArray"); - proteus::pyarray& elementBoundaryElementsArray = args.array("elementBoundaryElementsArray"); - proteus::pyarray& elementBoundaryLocalElementBoundariesArray = args.array("elementBoundaryLocalElementBoundariesArray"); - proteus::pyarray& ebqe_velocity_ext = args.array("ebqe_velocity_ext"); - proteus::pyarray& isDOFBoundary_u = args.array("isDOFBoundary_u"); - proteus::pyarray& ebqe_bc_u_ext = args.array("ebqe_bc_u_ext"); - proteus::pyarray& isFluxBoundary_u = args.array("isFluxBoundary_u"); - proteus::pyarray& ebqe_bc_flux_ext = args.array("ebqe_bc_flux_ext"); - proteus::pyarray& csrColumnOffsets_eb_u_u = args.array("csrColumnOffsets_eb_u_u"); - int LUMPED_MASS_MATRIX = args.scalar("LUMPED_MASS_MATRIX"); - assert(a_rowptr.data()[nSpace] == nnz); - assert(a_rowptr.data()[nSpace] == nSpace); - double Ct_sge = 4.0; - - // - //loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian - // - for(proteus_index_t eN=0;eN(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag); - } - else if (nSpaceIn == 2) - { - assert(nSpaceIn == 3); - return proteus::chooseAndAllocateDiscretization2D(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag); - } - else - { - assert(nSpaceIn == 3); - return proteus::chooseAndAllocateDiscretization(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, - CompKernelFlag); - } - } -}//richards -}//proteus -#endif diff --git a/proteus/richards/ADR.py b/proteus/richards/ADR.py deleted file mode 100644 index 54a771bddd..0000000000 --- a/proteus/richards/ADR.py +++ /dev/null @@ -1,1711 +0,0 @@ -from __future__ import division -from builtins import range -import proteus -from .cADR import * -import numpy as np -from proteus import cmeshTools -from proteus.Transport import OneLevelTransport -from proteus.Transport import TC_base, NonlinearEquation, logEvent, memory -from proteus.Transport import FluxBoundaryConditions, Comm, cfemIntegrals -from proteus.Transport import DOFBoundaryConditions, Quadrature -from proteus.mprans import cArgumentsDict -from proteus.LinearAlgebraTools import SparseMat -from proteus import TimeIntegration -import proteus.Transport -import proteus.TransportCoefficients -#from proteus.NonlinearSolvers import ExplicitLumpedMassMatrixForRichards - -class ThetaScheme(TimeIntegration.BackwardEuler): - def __init__(self,transport,integrateInterpolationPoints=False): - self.transport=transport - TimeIntegration.BackwardEuler.__init__(self,transport, integrateInterpolationPoints) - def updateTimeHistory(self,resetFromDOF=False): - TimeIntegration.BackwardEuler.updateTimeHistory(self,resetFromDOF) - self.transport.u_dof_old[:] = self.u -class RKEV(TimeIntegration.SSP): - from proteus import TimeIntegration - """ - Wrapper for SSPRK time integration using EV - - ... more to come ... - """ - - def __init__(self, transport, timeOrder=1, runCFL=0.1, integrateInterpolationPoints=False): - TimeIntegration.SSP.__init__(self, transport, integrateInterpolationPoints=integrateInterpolationPoints) - self.runCFL = runCFL - self.dtLast = None - self.isAdaptive = True - # About the cfl - assert transport.coefficients.STABILIZATION_TYPE > 0, "SSP method just works for edge based EV methods; i.e., STABILIZATION_TYPE>0" - assert hasattr(transport, 'edge_based_cfl'), "No edge based cfl defined" - self.cfl = transport.edge_based_cfl - # Stuff particular for SSP - self.timeOrder = timeOrder # order of approximation - self.nStages = timeOrder # number of stages total - self.lstage = 0 # last stage completed - # storage vectors - self.u_dof_last = {} - # per component stage values, list with array at each stage - self.u_dof_stage = {} - for ci in range(self.nc): - if ('m', ci) in transport.q: - self.u_dof_last[ci] = transport.u[ci].dof.copy() - self.u_dof_stage[ci] = [] - for k in range(self.nStages + 1): - self.u_dof_stage[ci].append(transport.u[ci].dof.copy()) - - # def set_dt(self, DTSET): - # self.dt = DTSET # don't update t - def choose_dt(self): - comm = Comm.get() - maxCFL = 1.0e-6 - maxCFL = max(maxCFL, comm.globalMax(self.cfl.max())) - self.dt = self.runCFL / maxCFL - if self.dtLast is None: - self.dtLast = self.dt - self.t = self.tLast + self.dt - self.substeps = [self.t for i in range(self.nStages)] # Manuel is ignoring different time step levels for now - - def initialize_dt(self, t0, tOut, q): - """ - Modify self.dt - """ - self.tLast = t0 - self.choose_dt() - self.t = t0 + self.dt - - def setCoefficients(self): - """ - beta are all 1's here - mwf not used right now - """ - self.alpha = np.zeros((self.nStages, self.nStages), 'd') - self.dcoefs = np.zeros((self.nStages), 'd') - - def updateStage(self): - """ - Need to switch to use coefficients - """ - self.lstage += 1 - assert self.timeOrder in [1, 2, 3] - assert self.lstage > 0 and self.lstage <= self.timeOrder - if self.timeOrder == 3: - if self.lstage == 1: - logEvent("First stage of SSP33 method", level=4) - for ci in range(self.nc): - self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof - # update u_dof_old - self.transport.u_dof_old[:] = self.u_dof_stage[ci][self.lstage] - elif self.lstage == 2: - logEvent("Second stage of SSP33 method", level=4) - for ci in range(self.nc): - self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof - self.u_dof_stage[ci][self.lstage] *= 1. / 4. - self.u_dof_stage[ci][self.lstage] += 3. / 4. * self.u_dof_last[ci] - # Update u_dof_old - self.transport.u_dof_old[:] = self.u_dof_stage[ci][self.lstage] - elif self.lstage == 3: - logEvent("Third stage of SSP33 method", level=4) - for ci in range(self.nc): - self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof - self.u_dof_stage[ci][self.lstage] *= 2.0 / 3.0 - self.u_dof_stage[ci][self.lstage] += 1.0 / 3.0 * self.u_dof_last[ci] - # update u_dof_old - self.transport.u_dof_old[:] = self.u_dof_last[ci] - # update solution to u[0].dof - self.transport.u[ci].dof[:] = self.u_dof_stage[ci][self.lstage] - elif self.timeOrder == 2: - if self.lstage == 1: - logEvent("First stage of SSP22 method", level=4) - for ci in range(self.nc): - self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof - # Update u_dof_old - self.transport.u_dof_old[:] = self.transport.u[ci].dof - elif self.lstage == 2: - logEvent("Second stage of SSP22 method", level=4) - for ci in range(self.nc): - self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof - self.u_dof_stage[ci][self.lstage][:] *= 1. / 2. - self.u_dof_stage[ci][self.lstage][:] += 1. / 2. * self.u_dof_last[ci] - # update u_dof_old - self.transport.u_dof_old[:] = self.u_dof_last[ci] - # update solution to u[0].dof - self.transport.u[ci].dof[:] = self.u_dof_stage[ci][self.lstage] - else: - assert self.timeOrder == 1 - for ci in range(self.nc): - self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof[:] - self.transport.u_dof_old[:] = self.transport.u[ci].dof - - def initializeTimeHistory(self, resetFromDOF=True): - """ - Push necessary information into time history arrays - """ - for ci in range(self.nc): - self.u_dof_last[ci][:] = self.transport.u[ci].dof[:] - for k in range(self.nStages): - self.u_dof_stage[ci][k][:] = self.transport.u[ci].dof[:] - - def updateTimeHistory(self, resetFromDOF=False): - """ - assumes successful step has been taken - """ - - self.t = self.tLast + self.dt - for ci in range(self.nc): - self.u_dof_last[ci][:] = self.transport.u[ci].dof[:] - for k in range(self.nStages): - self.u_dof_stage[ci][k][:] = self.transport.u[ci].dof[:] - self.lstage = 0 - self.dtLast = self.dt - self.tLast = self.t - - def generateSubsteps(self, tList): - """ - create list of substeps over time values given in tList. These correspond to stages - """ - self.substeps = [] - tLast = self.tLast - for t in tList: - dttmp = t - tLast - self.substeps.extend([tLast + dttmp for i in range(self.nStages)]) - tLast = t - - def resetOrder(self, order): - """ - initialize data structures for stage updges - """ - self.timeOrder = order # order of approximation - self.nStages = order # number of stages total - self.lstage = 0 # last stage completed - # storage vectors - # per component stage values, list with array at each stage - self.u_dof_stage = {} - for ci in range(self.nc): - if ('m', ci) in self.transport.q: - self.u_dof_stage[ci] = [] - for k in range(self.nStages + 1): - self.u_dof_stage[ci].append(self.transport.u[ci].dof.copy()) - self.substeps = [self.t for i in range(self.nStages)] - - def setFromOptions(self, nOptions): - """ - allow classes to set various numerical parameters - """ - if 'runCFL' in dir(nOptions): - self.runCFL = nOptions.runCFL - flags = ['timeOrder'] - for flag in flags: - if flag in dir(nOptions): - val = getattr(nOptions, flag) - setattr(self, flag, val) - if flag == 'timeOrder': - self.resetOrder(self.timeOrder) - -class Coefficients(proteus.TransportCoefficients.TC_base): - """ - version of Re where element material type id's used in evals - """ - #from proteus.ctransportCoefficients import conservativeHeadADRMualemVanGenuchtenHetEvaluateV2 - #from proteus.ctransportCoefficients import conservativeHeadADRMualemVanGenuchten_sd_het - def __init__(self, - nd, - Ksw_types, - vgm_n_types, - vgm_alpha_types, - thetaR_types, - thetaSR_types, - gravity, - density, - beta, - diagonal_conductivity=True, - getSeepageFace=None, - # FOR EDGE BASED EV - STABILIZATION_TYPE=0, - ENTROPY_TYPE=2, # logarithmic - LUMPED_MASS_MATRIX=False, - MONOLITHIC=True, - FCT=False, - forceStrongBoundaryConditions=False, - num_fct_iter=1, - # FOR ENTROPY VISCOSITY - cE=1.0, - uL=0.0, - uR=1.0, - # FOR ARTIFICIAL COMPRESSION - cK=1.0, - # OUTPUT quantDOFs - outputQuantDOFs=False): - variableNames=['pressure_head'] - nc=1 - mass={0:{0:'nonlinear'}} - advection={0:{0:'nonlinear'}} - diffusion={0:{0:{0:'nonlinear'}}} - potential={0:{0:'u'}} - reaction={0:{0:'linear'}} - hamiltonian={} - self.getSeepageFace=getSeepageFace - self.gravity=gravity - self.rho = density - self.beta=beta - self.vgm_n_types = vgm_n_types - self.vgm_alpha_types = vgm_alpha_types - self.thetaR_types = thetaR_types - self.thetaSR_types = thetaSR_types - self.elementMaterialTypes = None - self.exteriorElementBoundaryTypes = None - self.materialTypes_q = None - self.materialTypes_ebq = None - self.materialTypes_ebqe = None - self.nd = nd - self.nMaterialTypes = len(thetaR_types) - self.q = {}; self.ebqe = {}; self.ebq = {}; self.ebq_global={} - #try to allow some flexibility in input of permeability/conductivity tensor - self.diagonal_conductivity = diagonal_conductivity - self.Ksw_types_in = Ksw_types - if self.diagonal_conductivity: - sparseDiffusionTensors = {(0,0):(np.arange(self.nd+1,dtype='i'), - np.arange(self.nd,dtype='i'))} - - assert len(Ksw_types.shape) in [1,2], "if diagonal conductivity true then Ksw_types scalar or vector of diagonal entries" - #allow scalar input Ks - if len(Ksw_types.shape)==1: - self.Ksw_types = np.zeros((self.nMaterialTypes,self.nd),'d') - for I in range(self.nd): - self.Ksw_types[:,I] = Ksw_types - else: - self.Ksw_types = Ksw_types - else: #full - sparseDiffusionTensors = {(0,0):(np.arange(self.nd**2+1,step=self.nd,dtype='i'), - np.array([list(range(self.nd)) for row in range(self.nd)],dtype='i'))} - assert len(Ksw_types.shape) in [1,2], "if full tensor conductivity true then Ksw_types scalar or 'flattened' row-major representation of entries" - if len(Ksw_types.shape)==1: - self.Ksw_types = np.zeros((self.nMaterialTypes,self.nd**2),'d') - for I in range(self.nd): - self.Ksw_types[:,I*self.nd+I] = Ksw_types - else: - assert Ksw_types.shape[1] == self.nd**2 - self.Ksw_types = Ksw_types - # EDGE BASED (AND ENTROPY) VISCOSITY - self.LUMPED_MASS_MATRIX = LUMPED_MASS_MATRIX - self.MONOLITHIC = MONOLITHIC - self.STABILIZATION_TYPE = STABILIZATION_TYPE - self.ENTROPY_TYPE = ENTROPY_TYPE - self.FCT = FCT - self.num_fct_iter=num_fct_iter - self.uL = uL - self.uR = uR - self.cK = cK - self.forceStrongConditions = forceStrongBoundaryConditions - self.cE = cE - self.outputQuantDOFs = outputQuantDOFs - TC_base.__init__(self, - nc, - mass, - advection, - diffusion, - potential, - reaction, - hamiltonian, - variableNames, - sparseDiffusionTensors = sparseDiffusionTensors, - useSparseDiffusion = True) - - def initializeMesh(self,mesh): - from proteus.SubsurfaceTransportCoefficients import BlockHeterogeneousCoefficients - self.elementMaterialTypes,self.exteriorElementBoundaryTypes,self.elementBoundaryTypes = BlockHeterogeneousCoefficients(mesh).initializeMaterialTypes() - #want element boundary material types for evaluating heterogeneity - #not boundary conditions - self.isSeepageFace = np.zeros((mesh.nExteriorElementBoundaries_global),'i') - if self.getSeepageFace != None: - for ebNE in range(mesh.nExteriorElementBoundaries_global): - #mwf missing ebNE-->ebN? - ebN = mesh.exteriorElementBoundariesArray[ebNE] - #print "eb flag",mesh.elementBoundaryMaterialTypes[ebN] - #print self.getSeepageFace(mesh.elementBoundaryMaterialTypes[ebN]) - self.isSeepageFace[ebNE] = self.getSeepageFace(mesh.elementBoundaryMaterialTypes[ebN]) - #print self.isSeepageFace - def initializeElementQuadrature(self,t,cq): - self.materialTypes_q = self.elementMaterialTypes - self.q_shape = cq[('u',0)].shape -# cq['Ks'] = np.zeros(self.q_shape,'d') -# for k in range(self.q_shape[1]): -# cq['Ks'][:,k] = self.Ksw_types[self.elementMaterialTypes,0] - self.q[('vol_frac',0)] = np.zeros(self.q_shape,'d') - def initializeElementBoundaryQuadrature(self,t,cebq,cebq_global): - self.materialTypes_ebq = np.zeros(cebq[('u',0)].shape[0:2],'i') - self.ebq_shape = cebq[('u',0)].shape - for ebN_local in range(self.ebq_shape[1]): - self.materialTypes_ebq[:,ebN_local] = self.elementMaterialTypes - self.ebq[('vol_frac',0)] = np.zeros(self.ebq_shape,'d') - - def initializeGlobalExteriorElementBoundaryQuadrature(self,t,cebqe): - self.materialTypes_ebqe = self.exteriorElementBoundaryTypes - self.ebqe_shape = cebqe[('u',0)].shape - self.ebqe[('vol_frac',0)] = np.zeros(self.ebqe_shape,'d') - # - def evaluate(self,t,c): - if c[('u',0)].shape == self.q_shape: - materialTypes = self.materialTypes_q - vol_frac = self.q[('vol_frac',0)] - elif c[('u',0)].shape == self.ebqe_shape: - materialTypes = self.materialTypes_ebqe - vol_frac = self.ebqe[('vol_frac',0)] - elif c[('u',0)].shape == self.ebq_shape: - materialTypes = self.materialTypes_ebq - vol_frac = self.ebq[('vol_frac',0)] - else: - assert False, "no materialType found to match c[('u',0)].shape= %s " % c[('u',0)].shape - self.conservativeHeadADRMualemVanGenuchten_sd_het(self.sdInfo[(0,0)][0], - self.sdInfo[(0,0)][1], - materialTypes, - self.rho, - self.beta, - self.gravity, - self.vgm_alpha_types, - self.vgm_n_types, - self.thetaR_types, - self.thetaSR_types, - self.Ksw_types, - c[('u',0)], - c[('m',0)], - c[('dm',0,0)], - c[('f',0)], - c[('df',0,0)], - c[('a',0,0)], - c[('da',0,0,0)], - vol_frac) - # print "Picard---------------------------------------------------------------" - # c[('df',0,0)][:] = 0.0 - # c[('da',0,0,0)][:] = 0.0 -# self.conservativeHeadADRMualemVanGenuchtenHetEvaluateV2(materialTypes, -# self.rho, -# self.beta, -# self.gravity, -# self.vgm_alpha_types, -# self.vgm_n_types, -# self.thetaR_types, -# self.thetaSR_types, -# self.Ksw_types, -# c[('u',0)], -# c[('m',0)], -# c[('dm',0,0)], -# c[('f',0)], -# c[('df',0,0)], -# c[('a',0,0)], -# c[('da',0,0,0)]) - -class LevelModel(proteus.Transport.OneLevelTransport): - nCalls=0 - def __init__(self, - uDict, - phiDict, - testSpaceDict, - matType, - dofBoundaryConditionsDict, - dofBoundaryConditionsSetterDict, - coefficients, - elementQuadrature, - elementBoundaryQuadrature, - fluxBoundaryConditionsDict=None, - advectiveFluxBoundaryConditionsSetterDict=None, - diffusiveFluxBoundaryConditionsSetterDictDict=None, - stressTraceBoundaryConditionsSetterDict=None, - stabilization=None, - shockCapturing=None, - conservativeFluxDict=None, - numericalFluxType=None, - TimeIntegrationClass=None, - massLumping=False, - reactionLumping=False, - options=None, - name='defaultName', - reuse_trial_and_test_quadrature=True, - sd = True, - movingDomain=False, - bdyNullSpace=False): - self.bdyNullSpace=bdyNullSpace - # - #set the objects describing the method and boundary conditions - # - self.movingDomain=movingDomain - self.tLast_mesh=None - # - self.name=name - self.sd=sd - self.Hess=False - self.lowmem=True - self.timeTerm=True#allow turning off the time derivative - #self.lowmem=False - self.testIsTrial=True - self.phiTrialIsTrial=True - self.u = uDict - self.ua = {}#analytical solutions - self.phi = phiDict - self.dphi={} - self.matType = matType - #mwf try to reuse test and trial information across components if spaces are the same - self.reuse_test_trial_quadrature = reuse_trial_and_test_quadrature#True#False - if self.reuse_test_trial_quadrature: - for ci in range(1,coefficients.nc): - assert self.u[ci].femSpace.sameSpaceAs(self.u[0].femSpace), "to reuse_test_trial_quad all femSpaces must be the same!" - self.u_dof_old = None - ## Simplicial Mesh - self.mesh = self.u[0].femSpace.mesh #assume the same mesh for all components for now - self.testSpace = testSpaceDict - self.dirichletConditions = dofBoundaryConditionsDict - self.dirichletNodeSetList=None #explicit Dirichlet conditions for now, no Dirichlet BC constraints - self.coefficients = coefficients - self.coefficients.initializeMesh(self.mesh) - self.nc = self.coefficients.nc - self.stabilization = stabilization - self.shockCapturing = shockCapturing - self.conservativeFlux = conservativeFluxDict #no velocity post-processing for now - self.fluxBoundaryConditions=fluxBoundaryConditionsDict - self.advectiveFluxBoundaryConditionsSetterDict=advectiveFluxBoundaryConditionsSetterDict - self.diffusiveFluxBoundaryConditionsSetterDictDict = diffusiveFluxBoundaryConditionsSetterDictDict - #determine whether the stabilization term is nonlinear - self.stabilizationIsNonlinear = False - #cek come back - if self.stabilization != None: - for ci in range(self.nc): - if ci in coefficients.mass: - for flag in list(coefficients.mass[ci].values()): - if flag == 'nonlinear': - self.stabilizationIsNonlinear=True - if ci in coefficients.advection: - for flag in list(coefficients.advection[ci].values()): - if flag == 'nonlinear': - self.stabilizationIsNonlinear=True - if ci in coefficients.diffusion: - for diffusionDict in list(coefficients.diffusion[ci].values()): - for flag in list(diffusionDict.values()): - if flag != 'constant': - self.stabilizationIsNonlinear=True - if ci in coefficients.potential: - for flag in list(coefficients.potential[ci].values()): - if flag == 'nonlinear': - self.stabilizationIsNonlinear=True - if ci in coefficients.reaction: - for flag in list(coefficients.reaction[ci].values()): - if flag == 'nonlinear': - self.stabilizationIsNonlinear=True - if ci in coefficients.hamiltonian: - for flag in list(coefficients.hamiltonian[ci].values()): - if flag == 'nonlinear': - self.stabilizationIsNonlinear=True - #determine if we need element boundary storage - self.elementBoundaryIntegrals = {} - for ci in range(self.nc): - self.elementBoundaryIntegrals[ci] = ((self.conservativeFlux != None) or - (numericalFluxType != None) or - (self.fluxBoundaryConditions[ci] == 'outFlow') or - (self.fluxBoundaryConditions[ci] == 'mixedFlow') or - (self.fluxBoundaryConditions[ci] == 'setFlow')) - # - #calculate some dimensions - # - self.nSpace_global = self.u[0].femSpace.nSpace_global #assume same space dim for all variables - self.nDOF_trial_element = [u_j.femSpace.max_nDOF_element for u_j in list(self.u.values())] - self.nDOF_phi_trial_element = [phi_k.femSpace.max_nDOF_element for phi_k in list(self.phi.values())] - self.n_phi_ip_element = [phi_k.femSpace.referenceFiniteElement.interpolationConditions.nQuadraturePoints for phi_k in list(self.phi.values())] - self.nDOF_test_element = [femSpace.max_nDOF_element for femSpace in list(self.testSpace.values())] - self.nFreeDOF_global = [dc.nFreeDOF_global for dc in list(self.dirichletConditions.values())] - self.nVDOF_element = sum(self.nDOF_trial_element) - self.nFreeVDOF_global = sum(self.nFreeDOF_global) - # - NonlinearEquation.__init__(self,self.nFreeVDOF_global) - # - #build the quadrature point dictionaries from the input (this - #is just for convenience so that the input doesn't have to be - #complete) - # - elementQuadratureDict={} - elemQuadIsDict = isinstance(elementQuadrature,dict) - if elemQuadIsDict: #set terms manually - for I in self.coefficients.elementIntegralKeys: - if I in elementQuadrature: - elementQuadratureDict[I] = elementQuadrature[I] - else: - elementQuadratureDict[I] = elementQuadrature['default'] - else: - for I in self.coefficients.elementIntegralKeys: - elementQuadratureDict[I] = elementQuadrature - if self.stabilization != None: - for I in self.coefficients.elementIntegralKeys: - if elemQuadIsDict: - if I in elementQuadrature: - elementQuadratureDict[('stab',)+I[1:]] = elementQuadrature[I] - else: - elementQuadratureDict[('stab',)+I[1:]] = elementQuadrature['default'] - else: - elementQuadratureDict[('stab',)+I[1:]] = elementQuadrature - if self.shockCapturing != None: - for ci in self.shockCapturing.components: - if elemQuadIsDict: - if ('numDiff',ci,ci) in elementQuadrature: - elementQuadratureDict[('numDiff',ci,ci)] = elementQuadrature[('numDiff',ci,ci)] - else: - elementQuadratureDict[('numDiff',ci,ci)] = elementQuadrature['default'] - else: - elementQuadratureDict[('numDiff',ci,ci)] = elementQuadrature - if massLumping: - for ci in list(self.coefficients.mass.keys()): - elementQuadratureDict[('m',ci)] = Quadrature.SimplexLobattoQuadrature(self.nSpace_global,1) - for I in self.coefficients.elementIntegralKeys: - elementQuadratureDict[('stab',)+I[1:]] = Quadrature.SimplexLobattoQuadrature(self.nSpace_global,1) - if reactionLumping: - for ci in list(self.coefficients.mass.keys()): - elementQuadratureDict[('r',ci)] = Quadrature.SimplexLobattoQuadrature(self.nSpace_global,1) - for I in self.coefficients.elementIntegralKeys: - elementQuadratureDict[('stab',)+I[1:]] = Quadrature.SimplexLobattoQuadrature(self.nSpace_global,1) - elementBoundaryQuadratureDict={} - if isinstance(elementBoundaryQuadrature,dict): #set terms manually - for I in self.coefficients.elementBoundaryIntegralKeys: - if I in elementBoundaryQuadrature: - elementBoundaryQuadratureDict[I] = elementBoundaryQuadrature[I] - else: - elementBoundaryQuadratureDict[I] = elementBoundaryQuadrature['default'] - else: - for I in self.coefficients.elementBoundaryIntegralKeys: - elementBoundaryQuadratureDict[I] = elementBoundaryQuadrature - # - # find the union of all element quadrature points and - # build a quadrature rule for each integral that has a - # weight at each point in the union - #mwf include tag telling me which indices are which quadrature rule? - (self.elementQuadraturePoints,self.elementQuadratureWeights, - self.elementQuadratureRuleIndeces) = Quadrature.buildUnion(elementQuadratureDict) - self.nQuadraturePoints_element = self.elementQuadraturePoints.shape[0] - self.nQuadraturePoints_global = self.nQuadraturePoints_element*self.mesh.nElements_global - # - #Repeat the same thing for the element boundary quadrature - # - (self.elementBoundaryQuadraturePoints, - self.elementBoundaryQuadratureWeights, - self.elementBoundaryQuadratureRuleIndeces) = Quadrature.buildUnion(elementBoundaryQuadratureDict) - self.nElementBoundaryQuadraturePoints_elementBoundary = self.elementBoundaryQuadraturePoints.shape[0] - self.nElementBoundaryQuadraturePoints_global = (self.mesh.nElements_global* - self.mesh.nElementBoundaries_element* - self.nElementBoundaryQuadraturePoints_elementBoundary) - # - #storage dictionaries - self.scalars_element = set() - # - #simplified allocations for test==trial and also check if space is mixed or not - # - self.q={} - self.ebq={} - self.ebq_global={} - self.ebqe={} - self.phi_ip={} - self.edge_based_cfl = np.zeros(self.u[0].dof.shape)+100 - #mesh - #self.q['x'] = np.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element,3),'d') - self.q[('dV_u', 0)] = (1.0 / self.mesh.nElements_global) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') - self.ebqe['x'] = np.zeros((self.mesh.nExteriorElementBoundaries_global,self.nElementBoundaryQuadraturePoints_elementBoundary,3),'d') - self.q[('u',0)] = np.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element),'d') - self.q[('grad(u)',0)] = np.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element,self.nSpace_global),'d') - self.q['velocity'] = np.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element,self.nSpace_global),'d') - self.q[('m',0)] = self.q[('u',0)].copy() - self.q[('mt',0)] = self.q[('u',0)].copy() - self.q[('m_last',0)] = self.q[('u',0)].copy() - self.q[('m_tmp',0)] = self.q[('u',0)].copy() - self.q[('cfl',0)] = np.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element),'d') - self.q[('numDiff',0,0)] = np.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element),'d') - self.ebqe[('u',0)] = np.zeros((self.mesh.nExteriorElementBoundaries_global,self.nElementBoundaryQuadraturePoints_elementBoundary),'d') - self.ebqe[('grad(u)',0)] = np.zeros((self.mesh.nExteriorElementBoundaries_global,self.nElementBoundaryQuadraturePoints_elementBoundary,self.nSpace_global),'d') - self.ebqe['velocity'] = np.zeros((self.mesh.nExteriorElementBoundaries_global,self.nElementBoundaryQuadraturePoints_elementBoundary,self.nSpace_global),'d') - self.ebqe[('advectiveFlux_bc_flag',0)] = np.zeros((self.mesh.nExteriorElementBoundaries_global,self.nElementBoundaryQuadraturePoints_elementBoundary),'i') - self.ebqe[('advectiveFlux_bc',0)] = np.zeros((self.mesh.nExteriorElementBoundaries_global,self.nElementBoundaryQuadraturePoints_elementBoundary),'d') - self.ebqe[('advectiveFlux',0)] = np.zeros((self.mesh.nExteriorElementBoundaries_global,self.nElementBoundaryQuadraturePoints_elementBoundary),'d') - self.ebqe[('penalty')] = np.zeros((self.mesh.nExteriorElementBoundaries_global,self.nElementBoundaryQuadraturePoints_elementBoundary),'d') - self.points_elementBoundaryQuadrature= set() - self.scalars_elementBoundaryQuadrature= set([('u',ci) for ci in range(self.nc)]) - self.vectors_elementBoundaryQuadrature= set() - self.tensors_elementBoundaryQuadrature= set() - self.inflowBoundaryBC = {} - self.inflowBoundaryBC_values = {} - self.inflowFlux = {} - for cj in range(self.nc): - self.inflowBoundaryBC[cj] = np.zeros((self.mesh.nExteriorElementBoundaries_global,),'i') - self.inflowBoundaryBC_values[cj] = np.zeros((self.mesh.nExteriorElementBoundaries_global,self.nDOF_trial_element[cj]),'d') - self.inflowFlux[cj] = np.zeros((self.mesh.nExteriorElementBoundaries_global,self.nElementBoundaryQuadraturePoints_elementBoundary),'d') - self.internalNodes = set(range(self.mesh.nNodes_global)) - #identify the internal nodes this is ought to be in mesh - ##\todo move this to mesh - for ebNE in range(self.mesh.nExteriorElementBoundaries_global): - ebN = self.mesh.exteriorElementBoundariesArray[ebNE] - eN_global = self.mesh.elementBoundaryElementsArray[ebN,0] - ebN_element = self.mesh.elementBoundaryLocalElementBoundariesArray[ebN,0] - for i in range(self.mesh.nNodes_element): - if i != ebN_element: - I = self.mesh.elementNodesArray[eN_global,i] - self.internalNodes -= set([I]) - self.nNodes_internal = len(self.internalNodes) - self.internalNodesArray=np.zeros((self.nNodes_internal,),cmeshTools.INDEX_DTYPE) - for nI,n in enumerate(self.internalNodes): - self.internalNodesArray[nI]=n - # - del self.internalNodes - self.internalNodes = None - logEvent("Updating local to global mappings",2) - self.updateLocal2Global() - logEvent("Building time integration object",2) - logEvent(memory("inflowBC, internalNodes,updateLocal2Global","OneLevelTransport"),level=4) - #mwf for interpolating subgrid error for gradients etc - if self.stabilization and self.stabilization.usesGradientStabilization: - self.timeIntegration = TimeIntegrationClass(self,integrateInterpolationPoints=True) - else: - self.timeIntegration = TimeIntegrationClass(self) - - if options != None: - self.timeIntegration.setFromOptions(options) - logEvent(memory("TimeIntegration","OneLevelTransport"),level=4) - logEvent("Calculating numerical quadrature formulas",2) - self.calculateQuadrature() - #lay out components/equations contiguously for now - self.offset = [0] - for ci in range(1,self.nc): - self.offset += [self.offset[ci-1]+self.nFreeDOF_global[ci-1]] - self.stride = [1 for ci in range(self.nc)] - #use contiguous layout of components for parallel, requires weak DBC's - # mql. Some ASSERTS to restrict the combination of the methods - if self.coefficients.STABILIZATION_TYPE > 0: - pass - #except: - # pass - # END OF ASSERTS - - # cek adding empty data member for low order numerical viscosity structures here for now - self.ML = None # lumped mass matrix - self.MC_global = None # consistent mass matrix - self.cterm_global = None - self.cterm_transpose_global = None - # dL_global and dC_global are not the full matrices but just the CSR arrays containing the non zero entries - self.residualComputed=False #TMP - self.dLow= None - self.fluxMatrix = None - self.uDotLow = None - self.uLow = None - self.dt_times_dC_minus_dL = None - self.min_s_bc = None - self.max_s_bc = None - # Aux quantity at DOFs to be filled by optimized code (MQL) - self.quantDOFs = np.zeros(self.u[0].dof.shape, 'd') - self.sLow = np.zeros(self.u[0].dof.shape, 'd') - self.sHigh = np.zeros(self.u[0].dof.shape, 'd') - self.sn = np.zeros(self.u[0].dof.shape, 'd') - comm = Comm.get() - self.comm=comm - if comm.size() > 1: - assert numericalFluxType != None and numericalFluxType.useWeakDirichletConditions,"You must use a numerical flux to apply weak boundary conditions for parallel runs" - self.offset = [0] - for ci in range(1,self.nc): - self.offset += [ci] - self.stride = [self.nc for ci in range(self.nc)] - # - logEvent(memory("stride+offset","OneLevelTransport"),level=4) - if numericalFluxType != None: - if options is None or options.periodicDirichletConditions is None: - self.numericalFlux = numericalFluxType(self, - dofBoundaryConditionsSetterDict, - advectiveFluxBoundaryConditionsSetterDict, - diffusiveFluxBoundaryConditionsSetterDictDict) - else: - self.numericalFlux = numericalFluxType(self, - dofBoundaryConditionsSetterDict, - advectiveFluxBoundaryConditionsSetterDict, - diffusiveFluxBoundaryConditionsSetterDictDict, - options.periodicDirichletConditions) - else: - self.numericalFlux = None - #set penalty terms - #cek todo move into numerical flux initialization - if 'penalty' in self.ebq_global: - for ebN in range(self.mesh.nElementBoundaries_global): - for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN,k] = self.numericalFlux.penalty_constant / (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) - #penalty term - #cek move to Numerical flux initialization - if 'penalty' in self.ebqe: - for ebNE in range(self.mesh.nExteriorElementBoundaries_global): - ebN = self.mesh.exteriorElementBoundariesArray[ebNE] - for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE,k] = self.numericalFlux.penalty_constant / self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power - logEvent(memory("numericalFlux","OneLevelTransport"),level=4) - self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray - #use post processing tools to get conservative fluxes, None by default - from proteus import PostProcessingTools - self.velocityPostProcessor = PostProcessingTools.VelocityPostProcessingChooser(self) - logEvent(memory("velocity postprocessor","OneLevelTransport"),level=4) - #helper for writing out data storage - from proteus import Archiver - self.elementQuadratureDictionaryWriter = Archiver.XdmfWriter() - self.elementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter() - self.exteriorElementBoundaryQuadratureDictionaryWriter = Archiver.XdmfWriter() - #TODO get rid of this - for ci,fbcObject in list(self.fluxBoundaryConditionsObjectsDict.items()): - self.ebqe[('advectiveFlux_bc_flag',ci)] = np.zeros(self.ebqe[('advectiveFlux_bc',ci)].shape,'i') - for t,g in list(fbcObject.advectiveFluxBoundaryConditionsDict.items()): - if ci in self.coefficients.advection: - self.ebqe[('advectiveFlux_bc',ci)][t[0],t[1]] = g(self.ebqe[('x')][t[0],t[1]],self.timeIntegration.t) - self.ebqe[('advectiveFlux_bc_flag',ci)][t[0],t[1]] = 1 - - if hasattr(self.numericalFlux,'setDirichletValues'): - self.numericalFlux.setDirichletValues(self.ebqe) - if not hasattr(self.numericalFlux,'isDOFBoundary'): - self.numericalFlux.isDOFBoundary = {0:np.zeros(self.ebqe[('u',0)].shape,'i')} - if not hasattr(self.numericalFlux,'ebqe'): - self.numericalFlux.ebqe = {('u',0):np.zeros(self.ebqe[('u',0)].shape,'d')} - #TODO how to handle redistancing calls for calculateCoefficients,calculateElementResidual etc - self.globalResidualDummy = None - compKernelFlag=0 - self.delta_x_ij=None - self.ADR = cADR_base(self.nSpace_global, - self.nQuadraturePoints_element, - self.u[0].femSpace.elementMaps.localFunctionSpace.dim, - self.u[0].femSpace.referenceFiniteElement.localFunctionSpace.dim, - self.testSpace[0].referenceFiniteElement.localFunctionSpace.dim, - self.nElementBoundaryQuadraturePoints_elementBoundary, - compKernelFlag) - if self.movingDomain: - self.MOVING_DOMAIN=1.0 - else: - self.MOVING_DOMAIN=0.0 - #cek hack - self.movingDomain=False - self.MOVING_DOMAIN=0.0 - if self.mesh.nodeVelocityArray is None: - self.mesh.nodeVelocityArray = np.zeros(self.mesh.nodeArray.shape,'d') - self.forceStrongConditions=self.coefficients.forceStrongConditions - self.dirichletConditionsForceDOF = {} - if self.forceStrongConditions: - for cj in range(self.nc): - self.dirichletConditionsForceDOF[cj] = DOFBoundaryConditions(self.u[cj].femSpace,dofBoundaryConditionsSetterDict[cj],weakDirichletConditions=False) - def FCTStep(self): - import pdb - rowptr, colind, MassMatrix = self.MC_global.getCSRrepresentation() - limited_solution = np.zeros((len(rowptr) - 1),'d') - #self.u_free_dof_stage_0_l = np.zeros((len(rowptr) - 1),'d') - #self.timeIntegration.u_dof_stage[0][self.timeIntegration.lstage], # soln - #fromFreeToGlobal=0 - #cfemIntegrals.copyBetweenFreeUnknownsAndGlobalUnknowns(fromFreeToGlobal, - # self.offset[0], - # self.stride[0], - # self.dirichletConditions[0].global2freeGlobal_global_dofs, - # self.dirichletConditions[0].global2freeGlobal_free_dofs, - # self.u_free_dof_stage_0_l, - # self.timeIntegration.u_dof_stage[0][self.timeIntegration.lstage]) - argsDict = cArgumentsDict.ArgumentsDict() - argsDict["bc_mask"] = self.bc_mask - argsDict["NNZ"] = self.nnz - argsDict["numDOFs"] = len(rowptr) - 1 # num of DOFs - argsDict["dt"] = self.timeIntegration.dt - argsDict["lumped_mass_matrix"] = self.ML - argsDict["soln"] = self.sn - argsDict["pn"] = self.u[0].dof - argsDict["solH"] = self.sHigh - argsDict["uLow"] = self.sLow - argsDict["uDotLow"] = self.uDotLow - argsDict["limited_solution"] = limited_solution - argsDict["csrRowIndeces_DofLoops"] = rowptr - argsDict["csrColumnOffsets_DofLoops"] = colind - argsDict["MassMatrix"] = MassMatrix - argsDict["dt_times_fH_minus_fL"] = self.dt_times_dC_minus_dL - argsDict["min_s_bc"] = np.ones_like(self.min_s_bc)*self.coefficients.rho*(self.coefficients.thetaR_types[0]) #cek hack just set from physical bounds - argsDict["max_s_bc"] = np.ones_like(self.min_s_bc)*self.coefficients.rho*(self.coefficients.thetaR_types[0] + self.coefficients.thetaSR_types[0]) #cek hack - argsDict["LUMPED_MASS_MATRIX"] = self.coefficients.LUMPED_MASS_MATRIX - argsDict["MONOLITHIC"] =0#cek hack self.coefficients.MONOLITHIC - #pdb.set_trace() - self.ADR.FCTStep(argsDict) - - # self.nnz, # number of non zero entries - # len(rowptr) - 1, # number of DOFs - # self.timeIntegration.dt, - # self.ML, # Lumped mass matrix - # self.sn, - # self.u_dof_old, - # self.sHigh, # high order solution - # self.sLow, - # limited_solution, - # rowptr, # Row indices for Sparsity Pattern (convenient for DOF loops) - # colind, # Column indices for Sparsity Pattern (convenient for DOF loops) - # MassMatrix, - # self.dt_times_dC_minus_dL, - # self.min_s_bc, - # self.max_s_bc, - # self.coefficients.LUMPED_MASS_MATRIX, - # self.coefficients.MONOLITHIC) - old_dof = self.u[0].dof.copy() - self.invert(limited_solution, self.u[0].dof) - self.timeIntegration.u[:] = self.u[0].dof - #fromFreeToGlobal=1 #direction copying - #cfemIntegrals.copyBetweenFreeUnknownsAndGlobalUnknowns(fromFreeToGlobal, - # self.offset[0], - # self.stride[0], - # self.dirichletConditions[0].global2freeGlobal_global_dofs, - # self.dirichletConditions[0].global2freeGlobal_free_dofs, - # self.u[0].dof, - # limited_solution) - def kth_FCT_step(self): - #import pdb - #pdb.set_trace() - rowptr, colind, MassMatrix = self.MC_global.getCSRrepresentation() - limitedFlux = np.zeros(self.nnz) - limited_solution = np.zeros((len(rowptr) - 1),'d') - #limited_solution[:] = self.timeIntegration.u_dof_stage[0][self.timeIntegration.lstage] - fromFreeToGlobal=0 #direction copying - cfemIntegrals.copyBetweenFreeUnknownsAndGlobalUnknowns(fromFreeToGlobal, - self.offset[0], - self.stride[0], - self.dirichletConditions[0].global2freeGlobal_global_dofs, - self.dirichletConditions[0].global2freeGlobal_free_dofs, - limited_solution, - self.timeintegration.u_dof_stage[0][self.timeIntegration.lstage]) - - self.ADR.kth_FCT_step( - self.timeIntegration.dt, - self.coefficients.num_fct_iter, - self.nnz, # number of non zero entries - len(rowptr) - 1, # number of DOFs - MassMatrix, - self.ML, # Lumped mass matrix - self.u_dof_old, - limited_solution, - self.uDotLow, - self.uLow, - self.dLow, - self.fluxMatrix, - limitedFlux, - rowptr, - colind) - - self.timeIntegration.u[:] = limited_solution - #self.u[0].dof[:] = limited_solution - fromFreeToGlobal=1 #direction copying - cfemIntegrals.copyBetweenFreeUnknownsAndGlobalUnknowns(fromFreeToGlobal, - self.offset[0], - self.stride[0], - self.dirichletConditions[0].global2freeGlobal_global_dofs, - self.dirichletConditions[0].global2freeGlobal_free_dofs, - self.u[0].dof, - limited_solution) - def calculateCoefficients(self): - pass - def calculateElementResidual(self): - if self.globalResidualDummy != None: - self.getResidual(self.u[0].dof,self.globalResidualDummy) - def getResidual(self,u,r): - import pdb - import copy - """ - Calculate the element residuals and add in to the global residual - """ - cfemIntegrals.zeroJacobian_CSR(self.nNonzerosInJacobian, - self.jacobian) - if self.u_dof_old is None: - # Pass initial condition to u_dof_old - self.u_dof_old = np.copy(self.u[0].dof) - rowptr, colind, nzval = self.jacobian.getCSRrepresentation() - nnz = nzval.shape[-1] # number of non-zero entries in sparse matrix - r.fill(0.0) - ######################## - ### COMPUTE C MATRIX ### - ######################## - if self.cterm_global is None: - # since we only need cterm_global to persist, we can drop the other self.'s - self.cterm = {} - self.cterm_a = {} - self.cterm_global = {} - self.cterm_transpose = {} - self.cterm_a_transpose = {} - self.cterm_global_transpose = {} - rowptr, colind, nzval = self.jacobian.getCSRrepresentation() - nnz = nzval.shape[-1] # number of non-zero entries in sparse matrix - di = self.q[('grad(u)', 0)].copy() # direction of derivative - # JACOBIANS (FOR ELEMENT TRANSFORMATION) - self.q[('J')] = np.zeros((self.mesh.nElements_global, - self.nQuadraturePoints_element, - self.nSpace_global, - self.nSpace_global), - 'd') - self.q[('inverse(J)')] = np.zeros((self.mesh.nElements_global, - self.nQuadraturePoints_element, - self.nSpace_global, - self.nSpace_global), - 'd') - self.q[('det(J)')] = np.zeros((self.mesh.nElements_global, - self.nQuadraturePoints_element), - 'd') - self.u[0].femSpace.elementMaps.getJacobianValues(self.elementQuadraturePoints, - self.q['J'], - self.q['inverse(J)'], - self.q['det(J)']) - self.q['abs(det(J))'] = np.abs(self.q['det(J)']) - # SHAPE FUNCTIONS - self.q[('w', 0)] = np.zeros((self.mesh.nElements_global, - self.nQuadraturePoints_element, - self.nDOF_test_element[0]), - 'd') - self.q[('w*dV_m', 0)] = self.q[('w', 0)].copy() - self.u[0].femSpace.getBasisValues(self.elementQuadraturePoints, self.q[('w', 0)]) - cfemIntegrals.calculateWeightedShape(self.elementQuadratureWeights[('u', 0)], - self.q['abs(det(J))'], - self.q[('w', 0)], - self.q[('w*dV_m', 0)]) - # GRADIENT OF TEST FUNCTIONS - self.q[('grad(w)', 0)] = np.zeros((self.mesh.nElements_global, - self.nQuadraturePoints_element, - self.nDOF_test_element[0], - self.nSpace_global), - 'd') - self.u[0].femSpace.getBasisGradientValues(self.elementQuadraturePoints, - self.q['inverse(J)'], - self.q[('grad(w)', 0)]) - self.q[('grad(w)*dV_f', 0)] = np.zeros((self.mesh.nElements_global, - self.nQuadraturePoints_element, - self.nDOF_test_element[0], - self.nSpace_global), - 'd') - cfemIntegrals.calculateWeightedShapeGradients(self.elementQuadratureWeights[('u', 0)], - self.q['abs(det(J))'], - self.q[('grad(w)', 0)], - self.q[('grad(w)*dV_f', 0)]) - ########################## - ### LUMPED MASS MATRIX ### - ########################## - # assume a linear mass term - dm = np.ones(self.q[('u', 0)].shape, 'd') - elementMassMatrix = np.zeros((self.mesh.nElements_global, - self.nDOF_test_element[0], - self.nDOF_trial_element[0]), 'd') - cfemIntegrals.updateMassJacobian_weak_lowmem(dm, - self.q[('w', 0)], - self.q[('w*dV_m', 0)], - elementMassMatrix) - self.MC_a = nzval.copy() - self.MC_global = SparseMat(self.nFreeDOF_global[0], - self.nFreeDOF_global[0], - nnz, - self.MC_a, - colind, - rowptr) - cfemIntegrals.zeroJacobian_CSR(self.nnz, self.MC_global) - cfemIntegrals.updateGlobalJacobianFromElementJacobian_CSR(self.l2g[0]['nFreeDOF'], - self.l2g[0]['freeLocal'], - self.l2g[0]['nFreeDOF'], - self.l2g[0]['freeLocal'], - self.csrRowIndeces[(0, 0)], - self.csrColumnOffsets[(0, 0)], - elementMassMatrix, - self.MC_global) - self.ML = np.zeros((self.nFreeDOF_global[0],), 'd') - for i in range(self.nFreeDOF_global[0]): - self.ML[i] = self.MC_a[rowptr[i]:rowptr[i + 1]].sum() - np.testing.assert_almost_equal(self.ML.sum(), - self.mesh.volume, - err_msg="Trace of lumped mass matrix should be the domain volume", verbose=True) - for d in range(self.nSpace_global): # spatial dimensions - # C matrices - self.cterm[d] = np.zeros((self.mesh.nElements_global, - self.nDOF_test_element[0], - self.nDOF_trial_element[0]), 'd') - self.cterm_a[d] = nzval.copy() - #self.cterm_a[d] = np.zeros(nzval.size) - self.cterm_global[d] = SparseMat(self.nFreeDOF_global[0], - self.nFreeDOF_global[0], - nnz, - self.cterm_a[d], - colind, - rowptr) - cfemIntegrals.zeroJacobian_CSR(self.nnz, self.cterm_global[d]) - di[:] = 0.0 - di[..., d] = 1.0 - cfemIntegrals.updateHamiltonianJacobian_weak_lowmem(di, - self.q[('grad(w)*dV_f', 0)], - self.q[('w', 0)], - self.cterm[d]) # int[(di*grad(wj))*wi*dV] - cfemIntegrals.updateGlobalJacobianFromElementJacobian_CSR(self.l2g[0]['nFreeDOF'], - self.l2g[0]['freeLocal'], - self.l2g[0]['nFreeDOF'], - self.l2g[0]['freeLocal'], - self.csrRowIndeces[(0, 0)], - self.csrColumnOffsets[(0, 0)], - self.cterm[d], - self.cterm_global[d]) - # C Transpose matrices - self.cterm_transpose[d] = np.zeros((self.mesh.nElements_global, - self.nDOF_test_element[0], - self.nDOF_trial_element[0]), 'd') - self.cterm_a_transpose[d] = nzval.copy() - self.cterm_global_transpose[d] = SparseMat(self.nFreeDOF_global[0], - self.nFreeDOF_global[0], - nnz, - self.cterm_a_transpose[d], - colind, - rowptr) - cfemIntegrals.zeroJacobian_CSR(self.nnz, self.cterm_global_transpose[d]) - di[:] = 0.0 - di[..., d] = -1.0 - cfemIntegrals.updateAdvectionJacobian_weak_lowmem(di, - self.q[('w', 0)], - self.q[('grad(w)*dV_f', 0)], - self.cterm_transpose[d]) # -int[(-di*grad(wi))*wj*dV] - cfemIntegrals.updateGlobalJacobianFromElementJacobian_CSR(self.l2g[0]['nFreeDOF'], - self.l2g[0]['freeLocal'], - self.l2g[0]['nFreeDOF'], - self.l2g[0]['freeLocal'], - self.csrRowIndeces[(0, 0)], - self.csrColumnOffsets[(0, 0)], - self.cterm_transpose[d], - self.cterm_global_transpose[d]) - - rowptr, colind, Cx = self.cterm_global[0].getCSRrepresentation() - if (self.nSpace_global == 2): - rowptr, colind, Cy = self.cterm_global[1].getCSRrepresentation() - else: - Cy = np.zeros(Cx.shape, 'd') - if (self.nSpace_global == 3): - rowptr, colind, Cz = self.cterm_global[2].getCSRrepresentation() - else: - Cz = np.zeros(Cx.shape, 'd') - rowptr, colind, CTx = self.cterm_global_transpose[0].getCSRrepresentation() - if (self.nSpace_global == 2): - rowptr, colind, CTy = self.cterm_global_transpose[1].getCSRrepresentation() - else: - CTy = np.zeros(CTx.shape, 'd') - if (self.nSpace_global == 3): - rowptr, colind, CTz = self.cterm_global_transpose[2].getCSRrepresentation() - else: - CTz = np.zeros(CTx.shape, 'd') - - # This is dummy. I just care about the csr structure of the sparse matrix - self.dLow = np.zeros(Cx.shape, 'd') - self.fluxMatrix = np.zeros(Cx.shape, 'd') - self.dt_times_dC_minus_dL = np.zeros(Cx.shape, 'd') - nFree = len(rowptr)-1 - self.min_s_bc = np.zeros(nFree, 'd') + 1E10 - self.max_s_bc = np.zeros(nFree, 'd') - 1E10 - self.uDotLow = np.zeros(nFree, 'd') - self.uLow = np.zeros(nFree, 'd') - # - # cek end computationa of cterm_global - # - # cek showing mquezada an example of using cterm_global sparse matrix - # calculation y = c*x where x==1 - # direction=0 - #rowptr, colind, c = self.cterm_global[direction].getCSRrepresentation() - #y = np.zeros((self.nFreeDOF_global[0],),'d') - #x = np.ones((self.nFreeDOF_global[0],),'d') - # ij=0 - # for i in range(self.nFreeDOF_global[0]): - # for offset in range(rowptr[i],rowptr[i+1]): - # j = colind[offset] - # y[i] += c[ij]*x[j] - # ij+=1 - #Load the unknowns into the finite element dof - self.timeIntegration.calculateCoefs() - self.timeIntegration.calculateU(u) - self.setUnknowns(self.timeIntegration.u) - #cek can put in logic to skip of BC's don't depend on t or u - #Dirichlet boundary conditions - self.numericalFlux.setDirichletValues(self.ebqe) - #flux boundary conditions - #cek hack, just using advective flux for flux BC for now - for t,g in list(self.fluxBoundaryConditionsObjectsDict[0].advectiveFluxBoundaryConditionsDict.items()): - self.ebqe[('advectiveFlux_bc',0)][t[0],t[1]] = g(self.ebqe[('x')][t[0],t[1]],self.timeIntegration.t) - self.ebqe[('advectiveFlux_bc_flag',0)][t[0],t[1]] = 1 - # for t,g in self.fluxBoundaryConditionsObjectsDict[0].diffusiveFluxBoundaryConditionsDict.iteritems(): - # self.ebqe[('diffusiveFlux_bc',0)][t[0],t[1]] = g(self.ebqe[('x')][t[0],t[1]],self.timeIntegration.t) - # self.ebqe[('diffusiveFlux_bc_flag',0)][t[0],t[1]] = 1 - #self.shockCapturing.lag=True - if self.forceStrongConditions: - self.bc_mask = np.ones_like(self.u[0].dof) - for cj in range(len(self.dirichletConditionsForceDOF)): - for dofN,g in list(self.dirichletConditionsForceDOF[cj].DOFBoundaryConditionsDict.items()): - self.u[cj].dof[dofN] = g(self.dirichletConditionsForceDOF[cj].DOFBoundaryPointDict[dofN],self.timeIntegration.t) - self.u_dof_old[dofN] = self.u[cj].dof[dofN] - self.bc_mask[dofN] = 0.0 - degree_polynomial = 1 - try: - degree_polynomial = self.u[0].femSpace.order - except: - pass - - argsDict = cArgumentsDict.ArgumentsDict() - if self.forceStrongConditions: - argsDict["bc_mask"] = self.bc_mask - argsDict["dt"] = self.timeIntegration.dt - argsDict["Theta"] = 1.0 - argsDict["mesh_trial_ref"] = self.u[0].femSpace.elementMaps.psi - argsDict["mesh_grad_trial_ref"] = self.u[0].femSpace.elementMaps.grad_psi - argsDict["mesh_dof"] = self.mesh.nodeArray - argsDict["mesh_velocity_dof"] = self.mesh.nodeVelocityArray - argsDict["MOVING_DOMAIN"] = self.MOVING_DOMAIN - argsDict["mesh_l2g"] = self.mesh.elementNodesArray - argsDict["dV_ref"] = self.elementQuadratureWeights[('u',0)] - argsDict["u_trial_ref"] = self.u[0].femSpace.psi - argsDict["u_grad_trial_ref"] = self.u[0].femSpace.grad_psi - argsDict["u_test_ref"] = self.u[0].femSpace.psi - argsDict["u_grad_test_ref"] = self.u[0].femSpace.grad_psi - argsDict["mesh_trial_trace_ref"] = self.u[0].femSpace.elementMaps.psi_trace - argsDict["mesh_grad_trial_trace_ref"] = self.u[0].femSpace.elementMaps.grad_psi_trace - argsDict["dS_ref"] = self.elementBoundaryQuadratureWeights[('u',0)] - argsDict["u_trial_trace_ref"] = self.u[0].femSpace.psi_trace - argsDict["u_grad_trial_trace_ref"] = self.u[0].femSpace.grad_psi_trace - argsDict["u_test_trace_ref"] = self.u[0].femSpace.psi_trace - argsDict["u_grad_test_trace_ref"] = self.u[0].femSpace.grad_psi_trace - argsDict["normal_ref"] = self.u[0].femSpace.elementMaps.boundaryNormals - argsDict["boundaryJac_ref"] = self.u[0].femSpace.elementMaps.boundaryJacobians - argsDict["nElements_global"] = self.mesh.nElements_global - argsDict["ebqe_penalty_ext"] = self.ebqe['penalty'] - argsDict["elementMaterialTypes"] = self.mesh.elementMaterialTypes - argsDict["isSeepageFace"] = self.coefficients.isSeepageFace - argsDict["a_rowptr"] = self.coefficients.sdInfo[(0,0)][0] - argsDict["a_colind"] = self.coefficients.sdInfo[(0,0)][1] - argsDict["rho"] = self.coefficients.rho - argsDict["beta"] = self.coefficients.beta - argsDict["gravity"] = self.coefficients.gravity - argsDict["alpha"] = self.coefficients.vgm_alpha_types - argsDict["n"] = self.coefficients.vgm_n_types - argsDict["thetaR"] = self.coefficients.thetaR_types - argsDict["thetaSR"] = self.coefficients.thetaSR_types - argsDict["KWs"] = self.coefficients.Ksw_types - argsDict["useMetrics"] = 0.0 - argsDict["alphaBDF"] = self.timeIntegration.alpha_bdf - argsDict["lag_shockCapturing"] = 0 - argsDict["shockCapturingDiffusion"] = 0.0 - argsDict["sc_uref"] = 0.0 - argsDict["sc_alpha"] = 0.0 - argsDict["u_l2g"] = self.u[0].femSpace.dofMap.l2g - argsDict["r_l2g"] = self.l2g[0]['freeGlobal'] - argsDict["elementDiameter"] = self.mesh.elementDiametersArray - argsDict["degree_polynomial"] = degree_polynomial - argsDict["u_dof"] = self.u[0].dof - argsDict["u_dof_old"] = self.u_dof_old - argsDict["velocity"] = self.q['velocity'] - argsDict["q_v"] = self.q['velocity'] - argsDict["q_r"] = self.q[('u',0)] - #argsDict["q_v"] = self.q[('df',0,0)] - #argsDict["q_r"] = self.q[('r',0)] - argsDict["q_m"] = self.timeIntegration.m_tmp[0] - argsDict["q_u"] = self.q[('u',0)] - argsDict["q_dV"] = self.q[('dV_u',0)] - argsDict["q_m_betaBDF"] = self.timeIntegration.beta_bdf[0] - argsDict["cfl"] = self.q[('cfl',0)] - argsDict["q_numDiff_u"] = self.q[('cfl',0)] - argsDict["q_numDiff_u_last"] = self.q[('cfl',0)] - argsDict["offset_u"] = self.offset[0] - argsDict["stride_u"] = self.stride[0] - argsDict["globalResidual"] = r - argsDict["nExteriorElementBoundaries_global"] = self.mesh.nExteriorElementBoundaries_global - argsDict["exteriorElementBoundariesArray"] = self.mesh.exteriorElementBoundariesArray - argsDict["elementBoundaryElementsArray"] = self.mesh.elementBoundaryElementsArray - argsDict["elementBoundaryLocalElementBoundariesArray"] = self.mesh.elementBoundaryLocalElementBoundariesArray - argsDict["ebqe_velocity_ext"] = self.ebqe['velocity'] - argsDict["isDOFBoundary_u"] = self.numericalFlux.isDOFBoundary[0] - argsDict["ebqe_bc_u_ext"] = self.numericalFlux.ebqe[('u',0)] - argsDict["isFluxBoundary_u"] = self.ebqe[('advectiveFlux_bc_flag',0)] - argsDict["ebqe_bc_flux_ext"] = self.ebqe[('advectiveFlux_bc',0)] - argsDict["ebqe_phi"] = self.ebqe[('u',0)] - argsDict["epsFact"] = 0.0 - argsDict["ebqe_u"] = self.ebqe[('u',0)] - argsDict["ebqe_flux"] = self.ebqe[('advectiveFlux',0)] - argsDict['STABILIZATION_TYPE'] = self.coefficients.STABILIZATION_TYPE - # ENTROPY VISCOSITY and ARTIFICIAL COMRPESSION - argsDict["cE"] = self.coefficients.cE - argsDict["cK"] = self.coefficients.cK - # PARAMETERS FOR LOG BASED ENTROPY FUNCTION - argsDict["uL"] = self.coefficients.uL - argsDict["uR"] = self.coefficients.uR - # PARAMETERS FOR EDGE VISCOSITY - argsDict["numDOFs"] = len(rowptr) - 1 # num of DOFs - argsDict["NNZ"] = self.nnz - argsDict["Cx"] = len(Cx) # num of non-zero entries in the sparsity pattern - argsDict["csrRowIndeces_DofLoops"] = rowptr # Row indices for Sparsity Pattern (convenient for DOF loops) - argsDict["csrColumnOffsets_DofLoops"] = colind # Column indices for Sparsity Pattern (convenient for DOF loops) - argsDict["csrRowIndeces_CellLoops"] = self.csrRowIndeces[(0, 0)] # row indices (convenient for element loops) - argsDict["csrColumnOffsets_CellLoops"] = self.csrColumnOffsets[(0, 0)] # column indices (convenient for element loops) - argsDict["csrColumnOffsets_eb_CellLoops"] = self.csrColumnOffsets_eb[(0, 0)] # indices for boundary terms - argsDict["globalJacobian"] = self.jacobian.getCSRrepresentation()[2] - # C matrices - argsDict["Cx"] = Cx - argsDict["Cy"] = Cy - argsDict["Cz"] = Cz - argsDict["CTx"] = CTx - argsDict["CTy"] = CTy - argsDict["CTz"] = CTz - argsDict["ML"] = self.ML - argsDict["delta_x_ij"] = self.delta_x_ij - # PARAMETERS FOR 1st or 2nd ORDER MPP METHOD - argsDict["LUMPED_MASS_MATRIX"] = self.coefficients.LUMPED_MASS_MATRIX - argsDict["STABILIZATTION_TYPE"] = self.coefficients.STABILIZATION_TYPE - argsDict["ENTROPY_TYPE"] = self.coefficients.ENTROPY_TYPE - # FLUX CORRECTED TRANSPORT - argsDict["dLow"] = self.dLow - argsDict["fluxMatrix"] = self.fluxMatrix - argsDict["uDotLow"] = self.uDotLow - argsDict["uLow"] = self.uLow - argsDict["dt_times_fH_minus_fL"] = self.dt_times_dC_minus_dL - argsDict["min_s_bc"] = self.min_s_bc - argsDict["max_s_bc"] = self.max_s_bc - argsDict["quantDOFs"] = self.quantDOFs - argsDict["sLow"] = self.sLow - argsDict["sn"] = self.sn - if (self.coefficients.STABILIZATION_TYPE == 0): # SUPG - self.calculateResidual = self.ADR.calculateResidual - self.calculateJacobian = self.ADR.calculateJacobian - #else: - # self.calculateResidual = self.ADR.calculateResidual_entropy_viscosity - # self.calculateJacobian = self.ADR.calculateMassMatrix - #if self.delta_x_ij is None: - # self.delta_x_ij = -np.ones((self.nNonzerosInJacobian*3,),'d') - self.calculateResidual(argsDict) - #self.q[('mt',0)][:] =self.timeIntegration.m_tmp[0] - #self.q[('mt',0)] *= self.timeIntegration.alpha_bdf - #self.q[('mt',0)] += self.timeIntegration.beta_bdf[0] - #self.timeIntegration.calculateElementCoefficients(self.q) - if self.forceStrongConditions:# - for cj in range(len(self.dirichletConditionsForceDOF)):# - for dofN,g in list(self.dirichletConditionsForceDOF[cj].DOFBoundaryConditionsDict.items()): - r[self.offset[cj]+self.stride[cj]*dofN] = 0 - #if self.stabilization: - # self.stabilization.accumulateSubgridMassHistory(self.q) - logEvent("Global residual",level=9,data=r) - self.nonlinear_function_evaluations += 1 - if self.globalResidualDummy is None: - self.globalResidualDummy = np.zeros(r.shape,'d') - - def invert(self,u,r): - #u=s - #r=p - import pdb - import copy - """ - Calculate the element residuals and add in to the global residual - """ - self.sHigh[:] = u - rowptr, colind, nzval = self.jacobian.getCSRrepresentation() - nnz = nzval.shape[-1] # number of non-zero entries in sparse matrix - r.fill(0.0) - rowptr, colind, Cx = self.cterm_global[0].getCSRrepresentation() - if (self.nSpace_global == 2): - rowptr, colind, Cy = self.cterm_global[1].getCSRrepresentation() - else: - Cy = np.zeros(Cx.shape, 'd') - if (self.nSpace_global == 3): - rowptr, colind, Cz = self.cterm_global[2].getCSRrepresentation() - else: - Cz = np.zeros(Cx.shape, 'd') - rowptr, colind, CTx = self.cterm_global_transpose[0].getCSRrepresentation() - if (self.nSpace_global == 2): - rowptr, colind, CTy = self.cterm_global_transpose[1].getCSRrepresentation() - else: - CTy = np.zeros(CTx.shape, 'd') - if (self.nSpace_global == 3): - rowptr, colind, CTz = self.cterm_global_transpose[2].getCSRrepresentation() - else: - CTz = np.zeros(CTx.shape, 'd') - - # This is dummy. I just care about the csr structure of the sparse matrix - nFree = len(rowptr)-1 - degree_polynomial = 1 - try: - degree_polynomial = self.u[0].femSpace.order - except: - pass - if self.delta_x_ij is None: - self.delta_x_ij = -np.ones((self.nNonzerosInJacobian*3,),'d') - argsDict = cArgumentsDict.ArgumentsDict() - argsDict["dt"] = self.timeIntegration.dt - argsDict["mesh_trial_ref"] = self.u[0].femSpace.elementMaps.psi - argsDict["mesh_grad_trial_ref"] = self.u[0].femSpace.elementMaps.grad_psi - argsDict["mesh_dof"] = self.mesh.nodeArray - argsDict["mesh_velocity_dof"] = self.mesh.nodeVelocityArray - argsDict["MOVING_DOMAIN"] = self.MOVING_DOMAIN - argsDict["mesh_l2g"] = self.mesh.elementNodesArray - argsDict["dV_ref"] = self.elementQuadratureWeights[('u',0)] - argsDict["u_trial_ref"] = self.u[0].femSpace.psi - argsDict["u_grad_trial_ref"] = self.u[0].femSpace.grad_psi - argsDict["u_test_ref"] = self.u[0].femSpace.psi - argsDict["u_grad_test_ref"] = self.u[0].femSpace.grad_psi - argsDict["mesh_trial_trace_ref"] = self.u[0].femSpace.elementMaps.psi_trace - argsDict["mesh_grad_trial_trace_ref"] = self.u[0].femSpace.elementMaps.grad_psi_trace - argsDict["dS_ref"] = self.elementBoundaryQuadratureWeights[('u',0)] - argsDict["u_trial_trace_ref"] = self.u[0].femSpace.psi_trace - argsDict["u_grad_trial_trace_ref"] = self.u[0].femSpace.grad_psi_trace - argsDict["u_test_trace_ref"] = self.u[0].femSpace.psi_trace - argsDict["u_grad_test_trace_ref"] = self.u[0].femSpace.grad_psi_trace - argsDict["normal_ref"] = self.u[0].femSpace.elementMaps.boundaryNormals - argsDict["boundaryJac_ref"] = self.u[0].femSpace.elementMaps.boundaryJacobians - argsDict["nElements_global"] = self.mesh.nElements_global - argsDict["ebqe_penalty_ext"] = self.ebqe['penalty'] - argsDict["elementMaterialTypes"] = self.mesh.elementMaterialTypes - argsDict["isSeepageFace"] = self.coefficients.isSeepageFace - argsDict["a_rowptr"] = self.coefficients.sdInfo[(0,0)][0] - argsDict["a_colind"] = self.coefficients.sdInfo[(0,0)][1] - argsDict["rho"] = self.coefficients.rho - argsDict["beta"] = self.coefficients.beta - argsDict["gravity"] = self.coefficients.gravity - argsDict["alpha"] = self.coefficients.vgm_alpha_types - argsDict["n"] = self.coefficients.vgm_n_types - argsDict["thetaR"] = self.coefficients.thetaR_types - argsDict["thetaSR"] = self.coefficients.thetaSR_types - argsDict["KWs"] = self.coefficients.Ksw_types - argsDict["useMetrics"] = 0.0 - argsDict["alphaBDF"] = self.timeIntegration.alpha_bdf - argsDict["lag_shockCapturing"] = 0 - argsDict["shockCapturingDiffusion"] = 0.0 - argsDict["sc_uref"] = 0.0 - argsDict["sc_alpha"] = 0.0 - argsDict["u_l2g"] = self.u[0].femSpace.dofMap.l2g - argsDict["r_l2g"] = self.l2g[0]['freeGlobal'] - argsDict["elementDiameter"] = self.mesh.elementDiametersArray - argsDict["degree_polynomial"] = degree_polynomial - argsDict["u_dof"] = u#self.u[0].dof - argsDict["u_dof_old"] = self.u[0].dof - argsDict["velocity"] = self.q['velocity'] - argsDict["q_m"] = self.timeIntegration.m_tmp[0] - argsDict["q_u"] = self.q[('u',0)] - argsDict["q_dV"] = self.q[('dV_u',0)] - argsDict["q_m_betaBDF"] = self.timeIntegration.beta_bdf[0] - argsDict["cfl"] = self.q[('cfl',0)] - argsDict["q_numDiff_u"] = self.q[('cfl',0)] - argsDict["q_numDiff_u_last"] = self.q[('cfl',0)] - argsDict["offset_u"] = self.offset[0] - argsDict["stride_u"] = self.stride[0] - argsDict["globalResidual"] = r - argsDict["nExteriorElementBoundaries_global"] = self.mesh.nExteriorElementBoundaries_global - argsDict["exteriorElementBoundariesArray"] = self.mesh.exteriorElementBoundariesArray - argsDict["elementBoundaryElementsArray"] = self.mesh.elementBoundaryElementsArray - argsDict["elementBoundaryLocalElementBoundariesArray"] = self.mesh.elementBoundaryLocalElementBoundariesArray - argsDict["ebqe_velocity_ext"] = self.ebqe['velocity'] - argsDict["isDOFBoundary_u"] = self.numericalFlux.isDOFBoundary[0] - argsDict["ebqe_bc_u_ext"] = self.numericalFlux.ebqe[('u',0)] - argsDict["isFluxBoundary_u"] = self.ebqe[('advectiveFlux_bc_flag',0)] - argsDict["ebqe_bc_flux_ext"] = self.ebqe[('advectiveFlux_bc',0)] - argsDict["ebqe_phi"] = self.ebqe[('u',0)] - argsDict["epsFact"] = 0.0 - argsDict["ebqe_u"] = self.ebqe[('u',0)] - argsDict["ebqe_flux"] = self.ebqe[('advectiveFlux',0)] - argsDict['STABILIZATION_TYPE'] = self.coefficients.STABILIZATION_TYPE - # ENTROPY VISCOSITY and ARTIFICIAL COMRPESSION - argsDict["cE"] = self.coefficients.cE - argsDict["cK"] = self.coefficients.cK - # PARAMETERS FOR LOG BASED ENTROPY FUNCTION - argsDict["uL"] = self.coefficients.uL - argsDict["uR"] = self.coefficients.uR - # PARAMETERS FOR EDGE VISCOSITY - argsDict["numDOFs"] = len(rowptr) - 1 # num of DOFs - argsDict["NNZ"] = self.nnz - argsDict["Cx"] = len(Cx) # num of non-zero entries in the sparsity pattern - argsDict["csrRowIndeces_DofLoops"] = rowptr # Row indices for Sparsity Pattern (convenient for DOF loops) - argsDict["csrColumnOffsets_DofLoops"] = colind # Column indices for Sparsity Pattern (convenient for DOF loops) - argsDict["csrRowIndeces_CellLoops"] = self.csrRowIndeces[(0, 0)] # row indices (convenient for element loops) - argsDict["csrColumnOffsets_CellLoops"] = self.csrColumnOffsets[(0, 0)] # column indices (convenient for element loops) - argsDict["csrColumnOffsets_eb_CellLoops"] = self.csrColumnOffsets_eb[(0, 0)] # indices for boundary terms - # C matrices - argsDict["Cx"] = Cx - argsDict["Cy"] = Cy - argsDict["Cz"] = Cz - argsDict["CTx"] = CTx - argsDict["CTy"] = CTy - argsDict["CTz"] = CTz - argsDict["ML"] = self.ML - argsDict["delta_x_ij"] = self.delta_x_ij - # PARAMETERS FOR 1st or 2nd ORDER MPP METHOD - argsDict["LUMPED_MASS_MATRIX"] = self.coefficients.LUMPED_MASS_MATRIX - argsDict["STABILIZATTION_TYPE"] = self.coefficients.STABILIZATION_TYPE - argsDict["ENTROPY_TYPE"] = self.coefficients.ENTROPY_TYPE - # FLUX CORRECTED TRANSPORT - argsDict["dLow"] = self.dLow - argsDict["fluxMatrix"] = self.fluxMatrix - argsDict["uDotLow"] = self.uDotLow - argsDict["uLow"] = self.uLow - argsDict["dt_times_fH_minus_fL"] = self.dt_times_dC_minus_dL - argsDict["min_s_bc"] = self.min_s_bc - argsDict["max_s_bc"] = self.max_s_bc - argsDict["quantDOFs"] = self.quantDOFs - argsDict["sLow"] = self.sLow - argsDict["sn"] = self.sn - self.ADR.invert(argsDict) - # self.timeIntegration.dt, - # self.u[0].femSpace.elementMaps.psi, - # self.u[0].femSpace.elementMaps.grad_psi, - # self.mesh.nodeArray, - # self.mesh.nodeVelocityArray, - # self.MOVING_DOMAIN, - # self.mesh.elementNodesArray, - # self.elementQuadratureWeights[('u',0)], - # self.u[0].femSpace.psi, - # self.u[0].femSpace.grad_psi, - # self.u[0].femSpace.psi, - # self.u[0].femSpace.grad_psi, - # #element boundary - # self.u[0].femSpace.elementMaps.psi_trace, - # self.u[0].femSpace.elementMaps.grad_psi_trace, - # self.elementBoundaryQuadratureWeights[('u',0)], - # self.u[0].femSpace.psi_trace, - # self.u[0].femSpace.grad_psi_trace, - # self.u[0].femSpace.psi_trace, - # self.u[0].femSpace.grad_psi_trace, - # self.u[0].femSpace.elementMaps.boundaryNormals, - # self.u[0].femSpace.elementMaps.boundaryJacobians, - # #physics - # self.mesh.nElements_global, - # self.ebqe['penalty'],#double* ebqe_penalty_ext, - # self.mesh.elementMaterialTypes,#int* elementMaterialTypes, - # self.coefficients.isSeepageFace, - # self.coefficients.sdInfo[(0,0)][0],#int* a_rowptr, - # self.coefficients.sdInfo[(0,0)][1],#int* a_colind, - # self.coefficients.rho,#double rho, - # self.coefficients.beta,#double beta, - # self.coefficients.gravity,#double* gravity, - # self.coefficients.vgm_alpha_types,#double* alpha, - # self.coefficients.vgm_n_types,#double* n, - # self.coefficients.thetaR_types,#double* thetaR, - # self.coefficients.thetaSR_types,#double* thetaSR, - # self.coefficients.Ksw_types,#double* KWs, - # False,#self.coefficients.useMetrics, - # self.timeIntegration.alpha_bdf, - # 0,#self.shockCapturing.lag, - # 0.0,#cek hack self.shockCapturing.shockCapturingFactor, - # 0.0,#self.coefficients.sc_uref, - # 0.0,#self.coefficients.sc_beta, - # self.u[0].femSpace.dofMap.l2g, - # self.l2g[0]['freeGlobal'], - # self.mesh.elementDiametersArray, - # degree_polynomial, - # self.sHigh, - # self.u_dof_old, - # self.q['velocity'],#self.coefficients.q_v, - # self.timeIntegration.m_tmp[0], - # self.q[('u',0)], - # self.timeIntegration.beta_bdf[0], - # self.q[('cfl',0)], - # self.edge_based_cfl, - # self.q[('cfl',0)],#cek hack self.shockCapturing.numDiff[0], - # self.q[('cfl',0)],#cek hack self.shockCapturing.numDiff_last[0], - # self.offset[0],self.stride[0], - # r, - # self.mesh.nExteriorElementBoundaries_global, - # self.mesh.exteriorElementBoundariesArray, - # self.mesh.elementBoundaryElementsArray, - # self.mesh.elementBoundaryLocalElementBoundariesArray, - # self.ebqe['velocity'],#self.coefficients.ebqe_v, - # self.numericalFlux.isDOFBoundary[0], - # self.numericalFlux.ebqe[('u',0)], - # self.ebqe[('advectiveFlux_bc_flag',0)], - # self.ebqe[('advectiveFlux_bc',0)], - # self.ebqe[('u',0)],#cek hack self.coefficients.ebqe_phi, - # 0.0,#cek hack self.coefficients.epsFact, - # self.ebqe[('u',0)], - # self.ebqe[('advectiveFlux',0)], - # # ENTROPY VISCOSITY and ARTIFICIAL COMRPESSION - # self.coefficients.cE, - # self.coefficients.cK, - # # PARAMETERS FOR LOG BASED ENTROPY FUNCTION - # self.coefficients.uL, - # self.coefficients.uR, - # # PARAMETERS FOR EDGE VISCOSITY - # len(rowptr) - 1, # num of DOFs - # len(Cx), # num of non-zero entries in the sparsity pattern - # rowptr, # Row indices for Sparsity Pattern (convenient for DOF loops) - # colind, # Column indices for Sparsity Pattern (convenient for DOF loops) - # self.csrRowIndeces[(0, 0)], # row indices (convenient for element loops) - # self.csrColumnOffsets[(0, 0)], # column indices (convenient for element loops) - # self.csrColumnOffsets_eb[(0, 0)], # indices for boundary terms - # # C matrices - # Cx, - # Cy, - # Cz, - # CTx, - # CTy, - # CTz, - # self.ML, - # self.delta_x_ij, - # # PARAMETERS FOR 1st or 2nd ORDER MPP METHOD - # self.coefficients.LUMPED_MASS_MATRIX, - # self.coefficients.STABILIZATION_TYPE, - # self.coefficients.ENTROPY_TYPE, - # # FLUX CORRECTED TRANSPORT - # self.dLow, - # self.fluxMatrix, - # self.uDotLow, - # self.uLow, - # self.dt_times_dC_minus_dL, - # self.min_s_bc, - # self.max_s_bc, - # self.quantDOFs) - #self.q[('mt',0)][:] =self.timeIntegration.m_tmp[0] - #self.q[('mt',0)] *= self.timeIntegration.alpha_bdf - #self.q[('mt',0)] += self.timeIntegration.beta_bdf[0] - #self.timeIntegration.calculateElementCoefficients(self.q) - #if self.forceStrongConditions:# - # for cj in range(len(self.dirichletConditionsForceDOF)):# - # for dofN,g in list(self.dirichletConditionsForceDOF[cj].DOFBoundaryConditionsDict.items()): - # r[self.offset[cj]+self.stride[cj]*dofN] = 0 - #if self.stabilization: - # self.stabilization.accumulateSubgridMassHistory(self.q) - #logEvent("Global residual",level=9,data=r) - #self.nonlinear_function_evaluations += 1 - #if self.globalResidualDummy is None: - # self.globalResidualDummy = numpy.zeros(r.shape,'d') - def getJacobian(self,jacobian): - if (self.coefficients.STABILIZATION_TYPE == 0): # SUPG - cfemIntegrals.zeroJacobian_CSR(self.nNonzerosInJacobian, - jacobian) - degree_polynomial = 1 - try: - degree_polynomial = self.u[0].femSpace.order - except: - pass - if self.delta_x_ij is None: - self.delta_x_ij = -np.ones((self.nNonzerosInJacobian*3,),'d') - argsDict = cArgumentsDict.ArgumentsDict() - argsDict["dt"] = self.timeIntegration.dt - argsDict["mesh_trial_ref"] = self.u[0].femSpace.elementMaps.psi - argsDict["mesh_grad_trial_ref"] = self.u[0].femSpace.elementMaps.grad_psi - argsDict["mesh_dof"] = self.mesh.nodeArray - argsDict["mesh_velocity_dof"] = self.mesh.nodeVelocityArray - argsDict["MOVING_DOMAIN"] = self.MOVING_DOMAIN - argsDict["mesh_l2g"] = self.mesh.elementNodesArray - argsDict["dV_ref"] = self.elementQuadratureWeights[('u',0)] - argsDict["u_trial_ref"] = self.u[0].femSpace.psi - argsDict["u_grad_trial_ref"] = self.u[0].femSpace.grad_psi - argsDict["u_test_ref"] = self.u[0].femSpace.psi - argsDict["u_grad_test_ref"] = self.u[0].femSpace.grad_psi - argsDict["mesh_trial_trace_ref"] = self.u[0].femSpace.elementMaps.psi_trace - argsDict["mesh_grad_trial_trace_ref"] = self.u[0].femSpace.elementMaps.grad_psi_trace - argsDict["dS_ref"] = self.elementBoundaryQuadratureWeights[('u',0)] - argsDict["u_trial_trace_ref"] = self.u[0].femSpace.psi_trace - argsDict["u_grad_trial_trace_ref"] = self.u[0].femSpace.grad_psi_trace - argsDict["u_test_trace_ref"] = self.u[0].femSpace.psi_trace - argsDict["u_grad_test_trace_ref"] = self.u[0].femSpace.grad_psi_trace - argsDict["normal_ref"] = self.u[0].femSpace.elementMaps.boundaryNormals - argsDict["boundaryJac_ref"] = self.u[0].femSpace.elementMaps.boundaryJacobians - argsDict["nElements_global"] = self.mesh.nElements_global - argsDict["ebqe_penalty_ext"] = self.ebqe['penalty'] - argsDict["elementMaterialTypes"] = self.mesh.elementMaterialTypes - argsDict["isSeepageFace"] = self.coefficients.isSeepageFace - argsDict["a_rowptr"] = self.coefficients.sdInfo[(0,0)][0] - argsDict["a_colind"] = self.coefficients.sdInfo[(0,0)][1] - argsDict["rho"] = self.coefficients.rho - argsDict["beta"] = self.coefficients.beta - argsDict["gravity"] = self.coefficients.gravity - argsDict["alpha"] = self.coefficients.vgm_alpha_types - argsDict["n"] = self.coefficients.vgm_n_types - argsDict["thetaR"] = self.coefficients.thetaR_types - argsDict["thetaSR"] = self.coefficients.thetaSR_types - argsDict["KWs"] = self.coefficients.Ksw_types - argsDict["useMetrics"] = 0.0 - argsDict["alphaBDF"] = self.timeIntegration.alpha_bdf - argsDict["lag_shockCapturing"] = 0 - argsDict["shockCapturingDiffusion"] = 0.0 - argsDict["u_l2g"] = self.u[0].femSpace.dofMap.l2g - argsDict["r_l2g"] = self.l2g[0]['freeGlobal'] - argsDict["elementDiameter"] = self.mesh.elementDiametersArray - argsDict["degree_polynomial"] = degree_polynomial - argsDict["u_dof"] = self.u[0].dof - argsDict["velocity"] = self.q['velocity'] - argsDict["q_v"] = self.q['velocity'] - argsDict["q_r"] = self.q[('u',0)] - - #argsDict["q_v"] = self.q[('f',0,0)] - #argsDict["q_r"] = self.q[('r',0)] - argsDict["q_m_betaBDF"] = self.timeIntegration.beta_bdf[0] - argsDict["cfl"] = self.q[('cfl',0)] - argsDict["q_numDiff_u_last"] = self.q[('cfl',0)] - argsDict["csrRowIndeces_u_u"] = self.csrRowIndeces[(0,0)] - argsDict["csrColumnOffsets_u_u"] = self.csrColumnOffsets[(0,0)] - argsDict["globalJacobian"] = jacobian.getCSRrepresentation()[2] - argsDict["delta_x_ij"] = self.delta_x_ij - argsDict["nExteriorElementBoundaries_global"] = self.mesh.nExteriorElementBoundaries_global - argsDict["exteriorElementBoundariesArray"] = self.mesh.exteriorElementBoundariesArray - argsDict["elementBoundaryElementsArray"] = self.mesh.elementBoundaryElementsArray - argsDict["elementBoundaryLocalElementBoundariesArray"] = self.mesh.elementBoundaryLocalElementBoundariesArray - argsDict["ebqe_velocity_ext"] = self.ebqe['velocity'] - argsDict["isDOFBoundary_u"] = self.numericalFlux.isDOFBoundary[0] - argsDict["ebqe_bc_u_ext"] = self.numericalFlux.ebqe[('u',0)] - argsDict["isFluxBoundary_u"] = self.ebqe[('advectiveFlux_bc_flag',0)] - argsDict["ebqe_bc_flux_ext"] = self.ebqe[('advectiveFlux_bc',0)] - argsDict["csrColumnOffsets_eb_u_u"] = self.csrColumnOffsets_eb[(0,0)] - argsDict["LUMPED_MASS_MATRIX"] = self.coefficients.LUMPED_MASS_MATRIX - self.calculateJacobian(argsDict) - if self.forceStrongConditions: - for dofN in list(self.dirichletConditionsForceDOF[0].DOFBoundaryConditionsDict.keys()): - global_dofN = self.offset[0]+self.stride[0]*dofN - self.nzval[np.where(self.colind == global_dofN)] = 0.0 #column - self.nzval[self.rowptr[global_dofN]:self.rowptr[global_dofN+1]] = 0.0 #row - zeroRow=True - for i in range(self.rowptr[global_dofN],self.rowptr[global_dofN+1]):#row - if (self.colind[i] == global_dofN): - self.nzval[i] = 1.0 - zeroRow = False - if zeroRow: - raise RuntimeError("Jacobian has a zero row because sparse matrix has no diagonal entry at row "+repr(global_dofN)+". You probably need add diagonal mass or reaction term") - #scaling = 1.0#probably want to add some scaling to match non-dirichlet diagonals in linear system - #for cj in range(self.nc): - # for dofN in list(self.dirichletConditionsForceDOF[cj].DOFBoundaryConditionsDict.keys()): - # global_dofN = self.offset[cj]+self.stride[cj]*dofN - # for i in range(self.rowptr[global_dofN],self.rowptr[global_dofN+1]): - # if (self.colind[i] == global_dofN): - # self.nzval[i] = scaling - # else: - # self.nzval[i] = 0.0 - logEvent("Jacobian ",level=10,data=jacobian) - #mwf decide if this is reasonable for solver statistics - self.nonlinear_function_jacobian_evaluations += 1 - return jacobian - def calculateElementQuadrature(self): - """ - Calculate the physical location and weights of the quadrature rules - and the shape information at the quadrature points. - - This function should be called only when the mesh changes. - """ - #self.u[0].femSpace.elementMaps.getValues(self.elementQuadraturePoints, - # self.q['x']) - self.u[0].femSpace.elementMaps.getBasisValuesRef(self.elementQuadraturePoints) - self.u[0].femSpace.elementMaps.getBasisGradientValuesRef(self.elementQuadraturePoints) - self.u[0].femSpace.getBasisValuesRef(self.elementQuadraturePoints) - self.u[0].femSpace.getBasisGradientValuesRef(self.elementQuadraturePoints) - self.coefficients.initializeElementQuadrature(self.timeIntegration.t,self.q) - if self.stabilization != None: - self.stabilization.initializeElementQuadrature(self.mesh,self.timeIntegration.t,self.q) - self.stabilization.initializeTimeIntegration(self.timeIntegration) - if self.shockCapturing != None: - self.shockCapturing.initializeElementQuadrature(self.mesh,self.timeIntegration.t,self.q) - def calculateElementBoundaryQuadrature(self): - pass - def calculateExteriorElementBoundaryQuadrature(self): - """ - Calculate the physical location and weights of the quadrature rules - and the shape information at the quadrature points on global element boundaries. - - This function should be called only when the mesh changes. - """ - # - #get physical locations of element boundary quadrature points - # - #assume all components live on the same mesh - self.u[0].femSpace.elementMaps.getBasisValuesTraceRef(self.elementBoundaryQuadraturePoints) - self.u[0].femSpace.elementMaps.getBasisGradientValuesTraceRef(self.elementBoundaryQuadraturePoints) - self.u[0].femSpace.getBasisValuesTraceRef(self.elementBoundaryQuadraturePoints) - self.u[0].femSpace.getBasisGradientValuesTraceRef(self.elementBoundaryQuadraturePoints) - self.u[0].femSpace.elementMaps.getValuesGlobalExteriorTrace(self.elementBoundaryQuadraturePoints, - self.ebqe['x']) - self.fluxBoundaryConditionsObjectsDict = dict([(cj,FluxBoundaryConditions(self.mesh, - self.nElementBoundaryQuadraturePoints_elementBoundary, - self.ebqe[('x')], - getAdvectiveFluxBoundaryConditions=self.advectiveFluxBoundaryConditionsSetterDict[cj], - getDiffusiveFluxBoundaryConditions=self.diffusiveFluxBoundaryConditionsSetterDictDict[cj])) - for cj in list(self.advectiveFluxBoundaryConditionsSetterDict.keys())]) - self.coefficients.initializeGlobalExteriorElementBoundaryQuadrature(self.timeIntegration.t,self.ebqe) - def estimate_mt(self): - pass - def calculateSolutionAtQuadrature(self): - pass - def calculateAuxiliaryQuantitiesAfterStep(self): - pass diff --git a/proteus/richards/__init__.py b/proteus/richards/__init__.py index efb02ccd86..ef9bd256aa 100644 --- a/proteus/richards/__init__.py +++ b/proteus/richards/__init__.py @@ -1,8 +1,6 @@ -""" -Modules for simulating variably saturated single-phase flow -""" +"""Deprecated: the Richards kernel is in proteus.kernels (C49 R1); see proteus._kernel_aliases.""" +from proteus import _kernel_aliases -__all__ = ["Richards", - "cRichards", - "ADR", - "cADR"] +_kernel_aliases.install(__name__) + +__all__ = ["Richards", "cRichards"] diff --git a/proteus/richards/cADR.cpp b/proteus/richards/cADR.cpp deleted file mode 100644 index 34b97ca35f..0000000000 --- a/proteus/richards/cADR.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "pybind11/pybind11.h" -#include "pybind11/stl_bind.h" - -#include "ADR.h" - -namespace py = pybind11; -using proteus::richards::ADR_base; - -PYBIND11_MODULE(cADR, m) -{ - proteus::import_numpy(); - - py::class_(m, "cADR_base") - .def(py::init(&proteus::richards::newADR)) - .def("calculateResidual", &ADR_base::calculateResidual) - .def("calculateJacobian", &ADR_base::calculateJacobian); -} diff --git a/proteus/tests/richards/re_vgm_sand_10m_1d_p.py b/proteus/tests/richards/re_vgm_sand_10m_1d_p.py index 966eaa593a..f762c25888 100644 --- a/proteus/tests/richards/re_vgm_sand_10m_1d_p.py +++ b/proteus/tests/richards/re_vgm_sand_10m_1d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards nd = 1 diff --git a/proteus/tests/richards/re_vgm_sand_10x10m_2d_p.py b/proteus/tests/richards/re_vgm_sand_10x10m_2d_p.py index b98abcb81a..31d478ff0e 100644 --- a/proteus/tests/richards/re_vgm_sand_10x10m_2d_p.py +++ b/proteus/tests/richards/re_vgm_sand_10x10m_2d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards nd = 2 L=(10.0,10.0,1.0) diff --git a/proteus/tests/richards/re_vgm_sand_10x10x10_3d_p.py b/proteus/tests/richards/re_vgm_sand_10x10x10_3d_p.py index 7cf7e595fa..adf074cae9 100644 --- a/proteus/tests/richards/re_vgm_sand_10x10x10_3d_p.py +++ b/proteus/tests/richards/re_vgm_sand_10x10x10_3d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards nd = 3 L=(3.0,3.0,3.0) diff --git a/pyproject.toml b/pyproject.toml index 69753b6368..3fa6987328 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,7 +86,7 @@ addopts = "--import-mode=importlib" # and scripts directories are not measured -- a test that is never run is # a different problem from code that is never run -- and neither are the # decks under proteus/tests. Cython extensions are not measured either, except -# the three compiled from .py files (BoundaryConditions, mprans.BoundaryConditions, +# the two compiled from .py files (BoundaryConditions, # WaveTools), which the CI coverage leg builds with PROTEUS_CYTHON_LINETRACE=1 # (setup.py) and measures with the Cython.Coverage plugin; its steps in # .github/workflows/sdist.yml add that plugin to a copy of this configuration. diff --git a/setup.py b/setup.py index 2632894d02..e401a06800 100644 --- a/setup.py +++ b/setup.py @@ -143,7 +143,7 @@ def build_extensions(self): # before any of proteus's own headers get a chance to guard # against this -- and per-extension `extra_compile_args` wiring is # inconsistent across this file's ~100 Extension() entries (some - # include PROTEUS_EXTRA_COMPILE_ARGS, several of the mprans.c* + # include PROTEUS_EXTRA_COMPILE_ARGS, several of the kernels.c* # extensions don't), so a couple of these silently slipped through # a first attempt at fixing this per-extension. Some of the # bindings' methods aren't fully header-inline, so merely including @@ -151,7 +151,7 @@ def build_extensions(self): # anywhere -- silently requires linking a separate libmpi_cxx that # these extensions never ask for. Confirmed via a real build # against Ubuntu's system OpenMPI package: cpartitioning and - # mprans.cRANS2P both failed to import with "undefined symbol: + # kernels.cRANS2P both failed to import with "undefined symbol: # _ZN3MPI8Datatype4FreeEv". Setting this here, on the compiler # instance itself right before any extension is actually compiled # (same idea as the -fPIE handling below, applied globally rather @@ -263,7 +263,7 @@ def __str__(self): # either (older Xeons/Atoms, and some virtualized/cloud CPU profiles that # expose a conservative feature mask, e.g. QEMU's default "qemu64" model) -- # requesting it there doesn't fail the build, it silently bakes an illegal -# instruction into mprans.MeshSmoothing/mprans.cMoveMeshMonitor that SIGILLs +# instruction into MeshSmoothing/cMoveMeshMonitor that SIGILLs # the first time either module is imported. So probe the actual build host's # CPU capability instead of just checking platform.machine(). If detection # itself isn't possible (unknown platform, sandboxed build host, etc.), @@ -334,8 +334,8 @@ def _probe_pumi_partitioners(scorec_lib_dir): # (or references into fixed-size element arrays) and compile-time element # shape. Keep -O2 the default; do not tune the legacy passes for flags. -# Line tracing for the coverage leg only (PROTEUS_CYTHON_LINETRACE=1 in the environment of the build). BoundaryConditions, -# mprans.BoundaryConditions and WaveTools are compiled by Cython from .py files, so coverage.py never sees their lines +# Line tracing for the coverage leg only (PROTEUS_CYTHON_LINETRACE=1 in the environment of the build). BoundaryConditions +# and WaveTools are compiled by Cython from .py files, so coverage.py never sees their lines # execute and reports them at 0%. Built with linetrace and CYTHON_TRACE, and measured with the Cython.Coverage plugin # (pyproject.toml's coverage config is unchanged; the CI coverage leg adds the plugin), their lines count. Slower at run # time, so every other build -- and every other leg of CI -- leaves it off. @@ -373,67 +373,67 @@ def _probe_pumi_partitioners(scorec_lib_dir): extra_compile_args=['-std=c++20']+PROTEUS_SCOREC_EXTRA_COMPILE_ARGS+PROTEUS_EXTRA_COMPILE_ARGS+PROTEUS_OPT, extra_link_args=PROTEUS_SCOREC_EXTRA_LINK_ARGS+PROTEUS_EXTRA_LINK_ARGS), Extension( - 'mprans.cArgumentsDict', - sources = ['proteus/mprans/ArgumentsDict.cpp'], - depends=['proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h'], + 'cArgumentsDict', + sources = ['proteus/ArgumentsDict.cpp'], + depends=['proteus/ArgumentsDict.h', 'proteus/pyarray.h'], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cPres', - sources = ['proteus/mprans/Pres.cpp'], - depends=['proteus/mprans/Pres.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + 'kernels.cPres', + sources = ['proteus/kernels/Pres.cpp'], + depends=['proteus/kernels/Pres.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cPresInit', - sources = ['proteus/mprans/PresInit.cpp'], - depends=['proteus/mprans/PresInit.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + 'kernels.cPresInit', + sources = ['proteus/kernels/PresInit.cpp'], + depends=['proteus/kernels/PresInit.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cPresInc', - sources = ['proteus/mprans/PresInc.cpp'], - depends = ['proteus/mprans/PresInc.h', 'proteus/mprans/PresInc.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + 'kernels.cPresInc', + sources = ['proteus/kernels/PresInc.cpp'], + depends = ['proteus/kernels/PresInc.h', 'proteus/kernels/PresInc.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), - Extension('mprans.cAddedMass', - sources = ['proteus/mprans/AddedMass.cpp'], - depends=['proteus/mprans/AddedMass.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + Extension('kernels.cAddedMass', + sources = ['proteus/kernels/AddedMass.cpp'], + depends=['proteus/kernels/AddedMass.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], language='c++', include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20']), - Extension('mprans.SedClosure', - sources = ['proteus/mprans/SedClosure.cpp'], - depends = ['proteus/mprans/SedClosure.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + Extension('kernels.SedClosure', + sources = ['proteus/kernels/SedClosure.cpp'], + depends = ['proteus/kernels/SedClosure.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], language='c++', include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20']), - Extension('mprans.cVOF3P', - sources = ['proteus/mprans/VOF3P.cpp'], - depends = ['proteus/mprans/VOF3P.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + Extension('kernels.cVOF3P', + sources = ['proteus/kernels/VOF3P.cpp'], + depends = ['proteus/kernels/VOF3P.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], language='c++', include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20']), Extension( - 'mprans.cVOS3P', - sources = ['proteus/mprans/VOS3P.cpp'], - depends = ['proteus/mprans/VOS3P.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + 'kernels.cVOS3P', + sources = ['proteus/kernels/VOS3P.cpp'], + depends = ['proteus/kernels/VOS3P.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), - Extension('mprans.cNCLS3P', - sources=['proteus/mprans/NCLS3P.cpp'], - depends=['proteus/mprans/NCLS3P.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h' , 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + Extension('kernels.cNCLS3P', + sources=['proteus/kernels/NCLS3P.cpp'], + depends=['proteus/kernels/NCLS3P.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h' , 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], language='c++', include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20']), - Extension('mprans.cMCorr3P', - sources=['proteus/mprans/MCorr3P.cpp'], - depends=['proteus/mprans/MCorr3P.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + Extension('kernels.cMCorr3P', + sources=['proteus/kernels/MCorr3P.cpp'], + depends=['proteus/kernels/MCorr3P.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], language='c++', include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], @@ -450,57 +450,46 @@ def _probe_pumi_partitioners(scorec_lib_dir): PROTEUS_BLAS_LIB], ), Extension( - 'mprans.cRANS3PSed', - sources=['proteus/mprans/RANS3PSed.cpp'], - depends=['proteus/mprans/RANS3PSed.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + 'kernels.cRANS3PSed', + sources=['proteus/kernels/RANS3PSed.cpp'], + depends=['proteus/kernels/RANS3PSed.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cRANS3PSed2D', - sources=['proteus/mprans/RANS3PSed2D.cpp'], - depends=['proteus/mprans/RANS3PSed2D.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + 'kernels.cRANS3PSed2D', + sources=['proteus/kernels/RANS3PSed2D.cpp'], + depends=['proteus/kernels/RANS3PSed2D.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'richards.cRichards', - sources=['proteus/richards/cRichards.cpp'], - depends=['proteus/richards/Richards.h', 'proteus/pskRelations.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h' ,'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + 'kernels.cRichards', + sources=['proteus/kernels/cRichards.cpp'], + depends=['proteus/kernels/Richards.h', 'proteus/pskRelations.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h' ,'proteus/ModelFactory.h', 'proteus/CompKernel.h'], include_dirs=get_pybind_include_dirs(), language='c++', extra_compile_args=PROTEUS_OPT+['-std=c++20'], ), Extension( - # proteus/richards/ADR.py does `from .cADR import *`. This entry was - # dropped in merge 9e2aca55 (2026-08-12); see erdc/proteus#1285. - 'richards.cADR', - sources=['proteus/richards/cADR.cpp'], - depends=['proteus/richards/ADR.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + 'kernels.cm_comp_co2', + sources=['proteus/kernels/cm_comp_co2.cpp'], + depends=['proteus/kernels/m_comp_co2.h', 'proteus/pskRelations.h', 'proteus/kernels/co2_brine_flash.h', 'proteus/kernels/co2_brine_eos.h', 'proteus/kernels/jet2.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h' ,'proteus/ModelFactory.h', 'proteus/CompKernel.h'], include_dirs=get_pybind_include_dirs(), language='c++', extra_compile_args=PROTEUS_OPT+['-std=c++20'], ), Extension( - 'm_comp_co2.cm_comp_co2', - sources=['proteus/m_comp_co2/cm_comp_co2.cpp'], - depends=['proteus/m_comp_co2/m_comp_co2.h', 'proteus/pskRelations.h', 'proteus/m_comp_co2/co2_brine_flash.h', 'proteus/m_comp_co2/co2_brine_eos.h', 'proteus/m_comp_co2/jet2.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h' ,'proteus/ModelFactory.h', 'proteus/CompKernel.h'], - include_dirs=get_pybind_include_dirs(), - language='c++', - extra_compile_args=PROTEUS_OPT+['-std=c++20'], - ), - - Extension( - 'elastoplastic.cElastoPlastic', - sources=['proteus/elastoplastic/cElastoPlastic.cpp'], + 'kernels.cElastoPlastic', + sources=['proteus/kernels/cElastoPlastic.cpp'], define_macros=[('PROTEUS_LAPACK_H', PROTEUS_LAPACK_H), ('PROTEUS_LAPACK_INTEGER', PROTEUS_LAPACK_INTEGER), ('PROTEUS_BLAS_H', PROTEUS_BLAS_H)], - depends=['proteus/elastoplastic/ElastoPlastic.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], + depends=['proteus/kernels/ElastoPlastic.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h'], include_dirs=get_pybind_include_dirs(), language='c++', extra_compile_args=PROTEUS_OPT+['-std=c++20'], @@ -511,9 +500,9 @@ def _probe_pumi_partitioners(scorec_lib_dir): extra_link_args=PROTEUS_EXTRA_LINK_ARGS ), Extension( - 'mprans.cRANS3PF', - sources=['proteus/mprans/RANS3PF.cpp'], - depends=['proteus/mprans/RANS3PF.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h', + 'kernels.cRANS3PF', + sources=['proteus/kernels/RANS3PF.cpp'], + depends=['proteus/kernels/RANS3PF.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h', 'proteus/equivalent_polynomials.h', 'proteus/equivalent_polynomials_utils.h', 'proteus/equivalent_polynomials_coefficients.h', @@ -522,9 +511,9 @@ def _probe_pumi_partitioners(scorec_lib_dir): extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cRANS3PF2D', - sources=['proteus/mprans/RANS3PF2D.cpp'], - depends=['proteus/mprans/RANS3PF2D.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h', + 'kernels.cRANS3PF2D', + sources=['proteus/kernels/RANS3PF2D.cpp'], + depends=['proteus/kernels/RANS3PF2D.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h', 'proteus/equivalent_polynomials.h', 'proteus/equivalent_polynomials_utils.h', 'proteus/equivalent_polynomials_coefficients.h', @@ -545,21 +534,14 @@ def _probe_pumi_partitioners(scorec_lib_dir): extra_compile_args=PROTEUS_OPT+['-std=c++14'], include_dirs=[numpy.get_include(),'proteus'], **PROTEUS_LINETRACE), - Extension("mprans.BoundaryConditions", - sources=['proteus/mprans/BoundaryConditions.py'], - depends=['proteus/mprans/BoundaryConditions.pxd'], - language='c++', - extra_compile_args=PROTEUS_OPT+['-std=c++14'], - include_dirs=[numpy.get_include(),'proteus'], - **PROTEUS_LINETRACE), - Extension("mprans.MeshSmoothing", - sources=['proteus/mprans/MeshSmoothing.pyx'], + Extension("MeshSmoothing", + sources=['proteus/MeshSmoothing.pyx'], language='c++', include_dirs=[numpy.get_include(),'proteus',PROTEUS_INCLUDE_DIR], libraries=['stdc++','m'], extra_compile_args=["-std=c++20"]+PROTEUS_AVX_FLAGS+PROTEUS_OPT), - Extension("mprans.cMoveMeshMonitor", - sources=['proteus/mprans/cMoveMeshMonitor.pyx'], + Extension("cMoveMeshMonitor", + sources=['proteus/cMoveMeshMonitor.pyx'], language='c++', include_dirs=[numpy.get_include(),'proteus',PROTEUS_INCLUDE_DIR], libraries=['stdc++','m'], @@ -610,9 +592,9 @@ def _probe_pumi_partitioners(scorec_lib_dir): libraries=['stdc++','m'], extra_compile_args=["-std=c++11"]+PROTEUS_OPT), Extension( - 'cADR', - sources=['proteus/ADR.cpp'], - depends=['proteus/ADR.h', 'proteus/mprans/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h', + 'kernels.cADR', + sources=['proteus/kernels/ADR.cpp'], + depends=['proteus/kernels/ADR.h', 'proteus/ArgumentsDict.h', 'proteus/pyarray.h', 'proteus/ModelFactory.h', 'proteus/CompKernel.h', 'proteus/equivalent_polynomials.h', 'proteus/cutquadric.h', 'proteus/cutclip.h', 'proteus/Unfitted.h', 'proteus/UnfittedKernels.h', 'proteus/equivalent_polynomials_utils.h', 'proteus/equivalent_polynomials_coefficients.h', @@ -937,23 +919,23 @@ def _probe_pumi_partitioners(scorec_lib_dir): # extra_compile_args=PROTEUS_EXTRA_COMPILE_ARGS + PROTEUS_PETSC_EXTRA_COMPILE_ARGS+PROTEUS_OPT, # ), Extension( - 'mprans.cCLSVOF', - sources=['proteus/mprans/CLSVOF.cpp'], - depends=["proteus/mprans/CLSVOF.h", "proteus/mprans/CLSVOF.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], + 'kernels.cCLSVOF', + sources=['proteus/kernels/CLSVOF.cpp'], + depends=["proteus/kernels/CLSVOF.h", "proteus/kernels/CLSVOF.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cNCLS', - sources=['proteus/mprans/NCLS.cpp'], - depends=["proteus/mprans/NCLS.h", "proteus/mprans/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], + 'kernels.cNCLS', + sources=['proteus/kernels/NCLS.cpp'], + depends=["proteus/kernels/NCLS.h", "proteus/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cMCorr', - sources=['proteus/mprans/MCorr.cpp'], - depends=["proteus/mprans/MCorr.h", "proteus/mprans/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"] + [ + 'kernels.cMCorr', + sources=['proteus/kernels/MCorr.cpp'], + depends=["proteus/kernels/MCorr.h", "proteus/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"] + [ "proteus/equivalent_polynomials.h", "proteus/equivalent_polynomials_utils.h", "proteus/equivalent_polynomials_coefficients.h", @@ -969,9 +951,9 @@ def _probe_pumi_partitioners(scorec_lib_dir): extra_link_args=PROTEUS_EXTRA_LINK_ARGS, language='c++'), Extension( - 'mprans.cRANS2P', - sources=['proteus/mprans/RANS2P.cpp'], - depends=["proteus/mprans/RANS2P.h", "proteus/mprans/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"] + [ + 'kernels.cRANS2P', + sources=['proteus/kernels/RANS2P.cpp'], + depends=["proteus/kernels/RANS2P.h", "proteus/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"] + [ "proteus/equivalent_polynomials.h", "proteus/equivalent_polynomials_utils.h", "proteus/equivalent_polynomials_coefficients.h", @@ -986,9 +968,9 @@ def _probe_pumi_partitioners(scorec_lib_dir): extra_link_args=PROTEUS_SCOREC_EXTRA_LINK_ARGS+PROTEUS_EXTRA_LINK_ARGS,#+['-fopenmp'], language='c++'), Extension( - 'mprans.cRANS2P_IB', - sources=['proteus/mprans/RANS2P_IB.cpp'], - depends=["proteus/mprans/RANS2P_IB.h", "proteus/mprans/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"] + [ + 'kernels.cRANS2P_IB', + sources=['proteus/kernels/RANS2P_IB.cpp'], + depends=["proteus/kernels/RANS2P_IB.h", "proteus/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"] + [ "proteus/equivalent_polynomials.h", "proteus/equivalent_polynomials_utils.h", "proteus/equivalent_polynomials_coefficients.h", @@ -997,9 +979,9 @@ def _probe_pumi_partitioners(scorec_lib_dir): extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cRANS2P2D', - sources=['proteus/mprans/RANS2P2D.cpp'], - depends=["proteus/mprans/RANS2P2D.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"] + [ + 'kernels.cRANS2P2D', + sources=['proteus/kernels/RANS2P2D.cpp'], + depends=["proteus/kernels/RANS2P2D.h"] + ["proteus/MixedModelFactory.h","proteus/CompKernel.h"] + [ "proteus/equivalent_polynomials.h", "proteus/equivalent_polynomials_utils.h", "proteus/equivalent_polynomials_coefficients.h", @@ -1014,9 +996,9 @@ def _probe_pumi_partitioners(scorec_lib_dir): extra_link_args=PROTEUS_SCOREC_EXTRA_LINK_ARGS+PROTEUS_EXTRA_LINK_ARGS,#+['-fopenmp'], language='c++'), Extension( - 'mprans.cRDLS', - sources=['proteus/mprans/RDLS.cpp'], - depends=["proteus/mprans/RDLS.h", "proteus/mprans/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"] + [ + 'kernels.cRDLS', + sources=['proteus/kernels/RDLS.cpp'], + depends=["proteus/kernels/RDLS.h", "proteus/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"] + [ "proteus/equivalent_polynomials.h", "proteus/equivalent_polynomials_utils.h", "proteus/equivalent_polynomials_coefficients.h", @@ -1025,9 +1007,9 @@ def _probe_pumi_partitioners(scorec_lib_dir): extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cVOF', - sources=['proteus/mprans/VOF.cpp'], - depends=["proteus/mprans/VOF.h", "proteus/mprans/ArgumentsDict.h", "proteus/pyarray.h", "proteus/ModelFactory.h","proteus/CompKernel.h", + 'kernels.cVOF', + sources=['proteus/kernels/VOF.cpp'], + depends=["proteus/kernels/VOF.h", "proteus/ArgumentsDict.h", "proteus/pyarray.h", "proteus/ModelFactory.h","proteus/CompKernel.h", "proteus/equivalent_polynomials.h", "proteus/equivalent_polynomials_utils.h", "proteus/equivalent_polynomials_coefficients.h", @@ -1036,72 +1018,72 @@ def _probe_pumi_partitioners(scorec_lib_dir): extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cTADR', - sources=['proteus/mprans/TADR.cpp'], - depends=["proteus/mprans/TADR.h", "proteus/mprans/ArgumentsDict.h", "proteus/pyarray.h", "proteus/ModelFactory.h","proteus/CompKernel.h"], + 'kernels.cTADR', + sources=['proteus/kernels/TADR.cpp'], + depends=["proteus/kernels/TADR.h", "proteus/ArgumentsDict.h", "proteus/pyarray.h", "proteus/ModelFactory.h","proteus/CompKernel.h"], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cMoveMesh', - ['proteus/mprans/MoveMesh.cpp'], - depends=["proteus/mprans/MoveMesh.h", "proteus/mprans/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], + 'kernels.cMoveMesh', + ['proteus/kernels/MoveMesh.cpp'], + depends=["proteus/kernels/MoveMesh.h", "proteus/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cMoveMesh2D', - sources=['proteus/mprans/MoveMesh2D.cpp'], - depends=["proteus/mprans/MoveMesh2D.h", "proteus/mprans/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], + 'kernels.cMoveMesh2D', + sources=['proteus/kernels/MoveMesh2D.cpp'], + depends=["proteus/kernels/MoveMesh2D.h", "proteus/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cSW2D', - sources=['proteus/mprans/SW2D.cpp'], - depends=["proteus/mprans/SW2D.h", "proteus/mprans/SW2D.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], + 'kernels.cSW2D', + sources=['proteus/kernels/SW2D.cpp'], + depends=["proteus/kernels/SW2D.h", "proteus/kernels/SW2D.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cSW2DCV', - sources=['proteus/mprans/SW2DCV.cpp'], - depends=["proteus/mprans/SW2DCV.h", "proteus/mprans/ArgumentsDict.h", "proteus/pyarray.h", "proteus/ModelFactory.h","proteus/CompKernel.h"], + 'kernels.cSW2DCV', + sources=['proteus/kernels/SW2DCV.cpp'], + depends=["proteus/kernels/SW2DCV.h", "proteus/ArgumentsDict.h", "proteus/pyarray.h", "proteus/ModelFactory.h","proteus/CompKernel.h"], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cGN_SW2DCV', - sources=['proteus/mprans/GN_SW2DCV.cpp'], - depends=["proteus/mprans/GN_SW2DCV.h", "proteus/mprans/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], + 'kernels.cGN_SW2DCV', + sources=['proteus/kernels/GN_SW2DCV.cpp'], + depends=["proteus/kernels/GN_SW2DCV.h", "proteus/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cKappa', - sources=['proteus/mprans/Kappa.cpp'], - depends=["proteus/mprans/Kappa.h", "proteus/mprans/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], + 'kernels.cKappa', + sources=['proteus/kernels/Kappa.cpp'], + depends=["proteus/kernels/Kappa.h", "proteus/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cKappa2D', - sources=['proteus/mprans/Kappa2D.cpp'], - depends=["proteus/mprans/Kappa2D.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], + 'kernels.cKappa2D', + sources=['proteus/kernels/Kappa2D.cpp'], + depends=["proteus/kernels/Kappa2D.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cDissipation', - sources=['proteus/mprans/Dissipation.cpp'], - depends=["proteus/mprans/Dissipation.h", "proteus/mprans/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], + 'kernels.cDissipation', + sources=['proteus/kernels/Dissipation.cpp'], + depends=["proteus/kernels/Dissipation.h", "proteus/ArgumentsDict.h", "proteus/pyarray.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), Extension( - 'mprans.cDissipation2D', - sources=['proteus/mprans/Dissipation2D.cpp'], - depends=["proteus/mprans/Dissipation2D.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], + 'kernels.cDissipation2D', + sources=['proteus/kernels/Dissipation2D.cpp'], + depends=["proteus/kernels/Dissipation2D.h"] + ["proteus/ModelFactory.h","proteus/CompKernel.h"], include_dirs=get_pybind_include_dirs(), extra_compile_args=PROTEUS_OPT+['-std=c++20'], language='c++'), @@ -1161,10 +1143,11 @@ def setup_given_extensions(extensions): # classifiers, python floor, dependencies, extras, the `pro` console script) lives in pyproject.toml's # [project] table. The version stays here: RELEASE.md names the three files # that carry it, and [project] declares it dynamic. - setup(version='2.0.0rc1', + setup(version='2.0.0rc2', packages = ['proteus', 'proteus.fenton', - 'proteus.mprans', + 'proteus.kernels', + 'proteus.mprans', # deprecated aliases of proteus.kernels (C49), removed at 2.1 'proteus.richards', 'proteus.m_comp_co2', 'proteus.elastoplastic', diff --git a/test/ADR3D/test_adr_3d.py b/test/ADR3D/test_adr_3d.py index 8e4a680c9a..d71c97784e 100644 --- a/test/ADR3D/test_adr_3d.py +++ b/test/ADR3D/test_adr_3d.py @@ -222,7 +222,7 @@ def test_curved_option_needs_p2(tmp_path, monkeypatch): def test_kernel_refuses_the_curved_option_on_p1(tmp_path, monkeypatch): - from proteus import ADR + from proteus.kernels import ADR monkeypatch.chdir(tmp_path) monkeypatch.setattr(ADR, "_requireSupportedDimension", lambda *a: None) so, p, n, o = _setup("plane_curved", "pOrder=1") @@ -454,7 +454,7 @@ def test_p2_immersed_stops_at_setup_in_3d(tmp_path, monkeypatch): def test_kernel_refuses_p2_immersed_in_3d(tmp_path, monkeypatch): - from proteus import ADR + from proteus.kernels import ADR monkeypatch.chdir(tmp_path) monkeypatch.setattr(ADR, "_requireSupportedDimension", lambda *a: None) so, p, n, opts = _setup("ifem_plane", "pOrder=2") @@ -466,7 +466,7 @@ def test_kernel_refuses_p2_immersed_in_3d(tmp_path, monkeypatch): @pytest.mark.parametrize("cut", sorted(CUT_PHASE)) def test_kernel_refuses_cut_cell_features_in_3d(cut, tmp_path, monkeypatch): """The C++ kernel makes the same check, for a caller that skips the Python one.""" - from proteus import ADR + from proteus.kernels import ADR monkeypatch.chdir(tmp_path) monkeypatch.setattr(ADR, "_requireSupportedDimension", lambda *a: None) so, p, n, opts = _setup(cut) diff --git a/test/AddedMass/addedmass2D.py b/test/AddedMass/addedmass2D.py index 57488ef6b9..16c1b39b20 100644 --- a/test/AddedMass/addedmass2D.py +++ b/test/AddedMass/addedmass2D.py @@ -1,6 +1,6 @@ import numpy as np from proteus import Domain -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st from proteus.mbd import CouplingFSI as fsi import pychrono as chrono from proteus.TwoPhaseFlow import TwoPhaseFlowProblem as tpf diff --git a/test/AddedMass/addedmass3D.py b/test/AddedMass/addedmass3D.py index 3cfd57890a..8766e6e840 100644 --- a/test/AddedMass/addedmass3D.py +++ b/test/AddedMass/addedmass3D.py @@ -1,6 +1,6 @@ import numpy as np from proteus import Domain -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st from proteus.mbd import CouplingFSI as fsi import pychrono as chrono from proteus.TwoPhaseFlow import TwoPhaseFlowProblem as tpf diff --git a/test/CCS_TADR_parallel/thelper_tadr.py b/test/CCS_TADR_parallel/thelper_tadr.py index 0f37850220..e3e585a273 100644 --- a/test/CCS_TADR_parallel/thelper_tadr.py +++ b/test/CCS_TADR_parallel/thelper_tadr.py @@ -1,172 +1,172 @@ -from proteus import Domain -from proteus import Norms -from proteus import Profiling -from proteus import Context -from proteus.mprans import TADR -import numpy as np -import math - -ct=Context.Options([ - # General parameters # - ("physicalDiffusion", 0.0, "isotropic diffusion coefficient"), - ("problem",0,"0: 1D problem with periodic BCs. 1: 2D rotation of zalesak disk"), - ("nd",2,"space dimension"), - ("T",0.1,"Final time"), - ("nDTout",1,"Number of time steps to archive"), - ("refinement",0,"Level of refinement"), - ("unstructured",False,"Use unstructured mesh. Set to false for periodic BCs"), - # Choice of numerical method # - ("STABILIZATION_TYPE","Galerkin","Galerkin, VMS, TaylorGalerkinEV, EntropyViscosity, SmoothnessIndicator, Kuzmin, "), - ("LUMPED_MASS_MATRIX",False,"Flag to lumped the mass matrix"), - ("ENTROPY_TYPE","POWER","POWER, LOG"), - ("FCT",True,"Use Flux Corrected Transport"), - # Numerical parameters # - ("cE",0.1,"Entropy viscosity constant"), - ("cK",1.0,"Artificial compression constant"), - ("cfl",0.5,"Target cfl"), - ("SSPOrder",2,"SSP method of order 1, 2 or 3") -],mutable=True) - -assert ct.problem==0 or ct.problem==1 or ct.problem == 2, "problem must be set to 0 or 1" -# SHOCK CAPTURING PARAMETERS # -shockCapturingFactor_tadr=0.2 -lag_shockCapturing_tadr=True - -# number of space dimensions # -nd=ct.nd - -# General parameters # -parallel = False # if True use PETSc solvers -linearSmoother = None -checkMass = False - -# Finite element sapce # -pDegree_tadr=1 -useBernstein=False -useHex=False - -# quadrature order # -tadr_quad_order = 2*pDegree_tadr+1 - -# parallel partitioning info # -from proteus import MeshTools -partitioningType = MeshTools.MeshParallelPartitioningTypes.node - -# create mesh # -nn=nnx= 21 #(2**ct.refinement)*10+1 -#nny=1 -if nd == 2: - #nny=(nnx-1)//10+1 if ct.problem==0 else nnx - nny=nnx -nnz=1 -he=1.0/(nnx-1.0) - -unstructured=ct.unstructured #True for tetgen, false for tet or hex from rectangular grid -if nd == 1: - box=Domain.RectangularDomain(L=(2.0,), - x=(0.0,), - name="box"); - domain = box -elif nd == 2: - domain = Domain.PlanarStraightLineGraphDomain() - boundaries = [f'marker_{i}' for i in range(1, 17)] - boundaryTags=dict([(key,i+1) for (i,key) in enumerate(boundaries)]) - file_path = 'points_array_try.txt' # Replace with your actual file path - with open(file_path, 'r') as file: - lines = file.readlines() - selected_values = [[float(line.split(',')[0]), float(line.split(',')[2])] for line in lines] - # Create a NumPy array from the selected values - filtered_points = np.array(selected_values) - vertices= filtered_points.tolist() - vertexFlags = [] - marker= np.loadtxt('vertexflags.txt', dtype=int).tolist() - for value in marker: - formatted_value = f"marker_{value}" - vertexFlags.append(boundaryTags[formatted_value]) - - segments=np.loadtxt('segments.txt', dtype=int).tolist() - - segmentFlags = [] - flags_segments= np.loadtxt('segmentsFlags.txt', dtype=int).tolist() - - for value in flags_segments: - marker_number= int(value) - formatted_value = f"marker_{marker_number}" - segmentFlags.append(boundaryTags[formatted_value]) - regions= [[0.8,1.4], #1 - [0.8,1.15], #2 - [0.6,1.0],[1.2,0.9],[1.7,1.0], #3 - [0.4,0.9],[1.1,0.8],[2.2,0.95], #4 - [0.5,0.85],[1.2,0.75],[1.7,0.9], #5 - [0.42,0.75],[1.20,0.65],[1.62,0.75], #6 - [2.61,0.70], #7 - [0.18,0.55],[0.60,0.60], #8 - [0.30,0.65], #9 - [0.21,0.60],[0.60,0.65], #10 - [0.15,0.35],[0.60,0.45], #11 - [0.15,0.20],[0.81,0.25], #12 - [1.83,0.05], #13 - [0.36,0.25], #14 - [0.96,0.90], #15 - [1.44,0.85], #16 - ] -#regionFlags=[1,2,3] - regionFlags=[1, - 2, - 3,3,3, - 4,4,4, - 5,5,5, - 6,6,6, - 7, - 8,8, - 9, - 10,10, - 11,11, - 12,12, - 13, - 14, - 15,16] - - - domain = Domain.PlanarStraightLineGraphDomain(vertices= vertices, - vertexFlags=vertexFlags, - segments=segments, - segmentFlags=segmentFlags, - regions = regions, - regionFlags = regionFlags,) - #holes= holes) - domain.writePoly('CCS_rescaled') - G=[2.799999952316284,1.4950000047683716] - triangleOptions="pAnea%f"% (0.5*(G[0]/(nnx-1))**2,) -# triangleOptions="pAq30Dena%8.8f" % 0.001 - - # box=Domain.RectangularDomain(L=(1.0,1.0 if ct.problem==0 else 1.0), - # x=(0.0,0.0), - # name="box"); - # box.writePoly("box") - - # if unstructured: - # domain=Domain.PlanarStraightLineGraphDomain(fileprefix="box") - # domain.boundaryTags = box.boundaryTags - # bt = domain.boundaryTags - # triangleOptions="pAq30Dena%8.8f" % (0.5*he**2,) - # else: - # domain = box -# import pdb -# pdb.set_trace() - -domain.MeshOptions.nn = nn -domain.MeshOptions.nnx = nnx -domain.MeshOptions.nny = nny -domain.MeshOptions.nnz = nnz -domain.MeshOptions.triangleFlag=0 - -soname="tadr_level_"+repr(ct.refinement) - -class MyCoefficients(TADR.Coefficients): - def attachModels(self,modelList): - self.model = modelList[0] - self.rdModel = self.model - self.q_v = np.zeros(self.model.q[('grad(u)',0)].shape,'d') - self.ebqe_v = np.zeros(self.model.ebqe[('grad(u)',0)].shape,'d') - +from proteus import Domain +from proteus import Norms +from proteus import Profiling +from proteus import Context +from proteus.kernels import TADR +import numpy as np +import math + +ct=Context.Options([ + # General parameters # + ("physicalDiffusion", 0.0, "isotropic diffusion coefficient"), + ("problem",0,"0: 1D problem with periodic BCs. 1: 2D rotation of zalesak disk"), + ("nd",2,"space dimension"), + ("T",0.1,"Final time"), + ("nDTout",1,"Number of time steps to archive"), + ("refinement",0,"Level of refinement"), + ("unstructured",False,"Use unstructured mesh. Set to false for periodic BCs"), + # Choice of numerical method # + ("STABILIZATION_TYPE","Galerkin","Galerkin, VMS, TaylorGalerkinEV, EntropyViscosity, SmoothnessIndicator, Kuzmin, "), + ("LUMPED_MASS_MATRIX",False,"Flag to lumped the mass matrix"), + ("ENTROPY_TYPE","POWER","POWER, LOG"), + ("FCT",True,"Use Flux Corrected Transport"), + # Numerical parameters # + ("cE",0.1,"Entropy viscosity constant"), + ("cK",1.0,"Artificial compression constant"), + ("cfl",0.5,"Target cfl"), + ("SSPOrder",2,"SSP method of order 1, 2 or 3") +],mutable=True) + +assert ct.problem==0 or ct.problem==1 or ct.problem == 2, "problem must be set to 0 or 1" +# SHOCK CAPTURING PARAMETERS # +shockCapturingFactor_tadr=0.2 +lag_shockCapturing_tadr=True + +# number of space dimensions # +nd=ct.nd + +# General parameters # +parallel = False # if True use PETSc solvers +linearSmoother = None +checkMass = False + +# Finite element sapce # +pDegree_tadr=1 +useBernstein=False +useHex=False + +# quadrature order # +tadr_quad_order = 2*pDegree_tadr+1 + +# parallel partitioning info # +from proteus import MeshTools +partitioningType = MeshTools.MeshParallelPartitioningTypes.node + +# create mesh # +nn=nnx= 21 #(2**ct.refinement)*10+1 +#nny=1 +if nd == 2: + #nny=(nnx-1)//10+1 if ct.problem==0 else nnx + nny=nnx +nnz=1 +he=1.0/(nnx-1.0) + +unstructured=ct.unstructured #True for tetgen, false for tet or hex from rectangular grid +if nd == 1: + box=Domain.RectangularDomain(L=(2.0,), + x=(0.0,), + name="box"); + domain = box +elif nd == 2: + domain = Domain.PlanarStraightLineGraphDomain() + boundaries = [f'marker_{i}' for i in range(1, 17)] + boundaryTags=dict([(key,i+1) for (i,key) in enumerate(boundaries)]) + file_path = 'points_array_try.txt' # Replace with your actual file path + with open(file_path, 'r') as file: + lines = file.readlines() + selected_values = [[float(line.split(',')[0]), float(line.split(',')[2])] for line in lines] + # Create a NumPy array from the selected values + filtered_points = np.array(selected_values) + vertices= filtered_points.tolist() + vertexFlags = [] + marker= np.loadtxt('vertexflags.txt', dtype=int).tolist() + for value in marker: + formatted_value = f"marker_{value}" + vertexFlags.append(boundaryTags[formatted_value]) + + segments=np.loadtxt('segments.txt', dtype=int).tolist() + + segmentFlags = [] + flags_segments= np.loadtxt('segmentsFlags.txt', dtype=int).tolist() + + for value in flags_segments: + marker_number= int(value) + formatted_value = f"marker_{marker_number}" + segmentFlags.append(boundaryTags[formatted_value]) + regions= [[0.8,1.4], #1 + [0.8,1.15], #2 + [0.6,1.0],[1.2,0.9],[1.7,1.0], #3 + [0.4,0.9],[1.1,0.8],[2.2,0.95], #4 + [0.5,0.85],[1.2,0.75],[1.7,0.9], #5 + [0.42,0.75],[1.20,0.65],[1.62,0.75], #6 + [2.61,0.70], #7 + [0.18,0.55],[0.60,0.60], #8 + [0.30,0.65], #9 + [0.21,0.60],[0.60,0.65], #10 + [0.15,0.35],[0.60,0.45], #11 + [0.15,0.20],[0.81,0.25], #12 + [1.83,0.05], #13 + [0.36,0.25], #14 + [0.96,0.90], #15 + [1.44,0.85], #16 + ] +#regionFlags=[1,2,3] + regionFlags=[1, + 2, + 3,3,3, + 4,4,4, + 5,5,5, + 6,6,6, + 7, + 8,8, + 9, + 10,10, + 11,11, + 12,12, + 13, + 14, + 15,16] + + + domain = Domain.PlanarStraightLineGraphDomain(vertices= vertices, + vertexFlags=vertexFlags, + segments=segments, + segmentFlags=segmentFlags, + regions = regions, + regionFlags = regionFlags,) + #holes= holes) + domain.writePoly('CCS_rescaled') + G=[2.799999952316284,1.4950000047683716] + triangleOptions="pAnea%f"% (0.5*(G[0]/(nnx-1))**2,) +# triangleOptions="pAq30Dena%8.8f" % 0.001 + + # box=Domain.RectangularDomain(L=(1.0,1.0 if ct.problem==0 else 1.0), + # x=(0.0,0.0), + # name="box"); + # box.writePoly("box") + + # if unstructured: + # domain=Domain.PlanarStraightLineGraphDomain(fileprefix="box") + # domain.boundaryTags = box.boundaryTags + # bt = domain.boundaryTags + # triangleOptions="pAq30Dena%8.8f" % (0.5*he**2,) + # else: + # domain = box +# import pdb +# pdb.set_trace() + +domain.MeshOptions.nn = nn +domain.MeshOptions.nnx = nnx +domain.MeshOptions.nny = nny +domain.MeshOptions.nnz = nnz +domain.MeshOptions.triangleFlag=0 + +soname="tadr_level_"+repr(ct.refinement) + +class MyCoefficients(TADR.Coefficients): + def attachModels(self,modelList): + self.model = modelList[0] + self.rdModel = self.model + self.q_v = np.zeros(self.model.q[('grad(u)',0)].shape,'d') + self.ebqe_v = np.zeros(self.model.ebqe[('grad(u)',0)].shape,'d') + diff --git a/test/CLSVOF/disc_ICs/clsvof.py b/test/CLSVOF/disc_ICs/clsvof.py index b6f0b7126c..4e3cb3762a 100644 --- a/test/CLSVOF/disc_ICs/clsvof.py +++ b/test/CLSVOF/disc_ICs/clsvof.py @@ -2,7 +2,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import CLSVOF +from proteus.kernels import CLSVOF import numpy as np import math try: diff --git a/test/CLSVOF/disc_ICs/clsvof_p.py b/test/CLSVOF/disc_ICs/clsvof_p.py index 525a13e36c..1230b81bf7 100644 --- a/test/CLSVOF/disc_ICs/clsvof_p.py +++ b/test/CLSVOF/disc_ICs/clsvof_p.py @@ -2,7 +2,7 @@ from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside from proteus import Context -from proteus.mprans import CLSVOF +from proteus.kernels import CLSVOF from math import * try: from .clsvof import * diff --git a/test/CLSVOF/pure_level_set/clsvof.py b/test/CLSVOF/pure_level_set/clsvof.py index 43d324fce6..3b8242c2ad 100644 --- a/test/CLSVOF/pure_level_set/clsvof.py +++ b/test/CLSVOF/pure_level_set/clsvof.py @@ -2,7 +2,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import CLSVOF +from proteus.kernels import CLSVOF import numpy as np import math import os diff --git a/test/CLSVOF/with_RANS2P/clsvof_p.py b/test/CLSVOF/with_RANS2P/clsvof_p.py index 10ba44215c..7d50101222 100644 --- a/test/CLSVOF/with_RANS2P/clsvof_p.py +++ b/test/CLSVOF/with_RANS2P/clsvof_p.py @@ -3,7 +3,7 @@ from proteus.ctransportCoefficients import smoothedHeaviside from math import * from .multiphase import * -from proteus.mprans import CLSVOF +from proteus.kernels import CLSVOF LevelModelType = CLSVOF.LevelModel coefficients = CLSVOF.Coefficients(V_model=0, diff --git a/test/CLSVOF/with_RANS2P/ls_consrv_p.py b/test/CLSVOF/with_RANS2P/ls_consrv_p.py index b6a0d7ea54..94779c4dca 100644 --- a/test/CLSVOF/with_RANS2P/ls_consrv_p.py +++ b/test/CLSVOF/with_RANS2P/ls_consrv_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import MCorr +from proteus.kernels import MCorr from .multiphase import * LevelModelType = MCorr.LevelModel diff --git a/test/CLSVOF/with_RANS2P/ls_n.py b/test/CLSVOF/with_RANS2P/ls_n.py index 2b9a3b51ca..fd4e4bd83c 100644 --- a/test/CLSVOF/with_RANS2P/ls_n.py +++ b/test/CLSVOF/with_RANS2P/ls_n.py @@ -5,7 +5,7 @@ NonlinearSolvers, LinearSolvers, LinearAlgebraTools) -from proteus.mprans import NCLS +from proteus.kernels import NCLS from .multiphase import * if timeDiscretization=='vbdf': diff --git a/test/CLSVOF/with_RANS2P/ls_p.py b/test/CLSVOF/with_RANS2P/ls_p.py index b3b59afdbb..8a55e25c8c 100644 --- a/test/CLSVOF/with_RANS2P/ls_p.py +++ b/test/CLSVOF/with_RANS2P/ls_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import NCLS +from proteus.kernels import NCLS from .multiphase import * LevelModelType = NCLS.LevelModel diff --git a/test/CLSVOF/with_RANS2P/multiphase.py b/test/CLSVOF/with_RANS2P/multiphase.py index 4124a3830e..15679ac335 100644 --- a/test/CLSVOF/with_RANS2P/multiphase.py +++ b/test/CLSVOF/with_RANS2P/multiphase.py @@ -7,9 +7,9 @@ FemTools as ft, MeshTools as mt, WaveTools as wt) -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st from proteus.Profiling import logEvent -from proteus.mprans.SpatialTools import Tank2D +from proteus.SpatialTools import Tank2D AUTOMATED_TEST=True diff --git a/test/CLSVOF/with_RANS2P/redist_n.py b/test/CLSVOF/with_RANS2P/redist_n.py index d4d4ea2839..1247ff5d53 100644 --- a/test/CLSVOF/with_RANS2P/redist_n.py +++ b/test/CLSVOF/with_RANS2P/redist_n.py @@ -5,7 +5,7 @@ LinearSolvers, LinearAlgebraTools, NumericalFlux) -from proteus.mprans import RDLS +from proteus.kernels import RDLS from . import redist_p as physics from .multiphase import * diff --git a/test/CLSVOF/with_RANS2P/redist_p.py b/test/CLSVOF/with_RANS2P/redist_p.py index 22e808cc97..c703269b3b 100644 --- a/test/CLSVOF/with_RANS2P/redist_p.py +++ b/test/CLSVOF/with_RANS2P/redist_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import RDLS +from proteus.kernels import RDLS from .multiphase import * LevelModelType = RDLS.LevelModel diff --git a/test/CLSVOF/with_RANS2P/twp_navier_stokes_n.py b/test/CLSVOF/with_RANS2P/twp_navier_stokes_n.py index 54574d4ddf..123f63f86d 100644 --- a/test/CLSVOF/with_RANS2P/twp_navier_stokes_n.py +++ b/test/CLSVOF/with_RANS2P/twp_navier_stokes_n.py @@ -5,7 +5,7 @@ LinearAlgebraTools) from proteus.default_n import * from . import twp_navier_stokes_p as physics -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P from .multiphase import * #time stepping diff --git a/test/CLSVOF/with_RANS2P/twp_navier_stokes_p.py b/test/CLSVOF/with_RANS2P/twp_navier_stokes_p.py index eeda55f3af..9aee4adbc7 100644 --- a/test/CLSVOF/with_RANS2P/twp_navier_stokes_p.py +++ b/test/CLSVOF/with_RANS2P/twp_navier_stokes_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P from .multiphase import * import numpy as np diff --git a/test/CLSVOF/with_RANS2P/vof_n.py b/test/CLSVOF/with_RANS2P/vof_n.py index 1df966a3dd..d747db69a2 100644 --- a/test/CLSVOF/with_RANS2P/vof_n.py +++ b/test/CLSVOF/with_RANS2P/vof_n.py @@ -5,7 +5,7 @@ LinearSolvers, LinearAlgebraTools) from . import vof_p as physics -from proteus.mprans import VOF +from proteus.kernels import VOF from .multiphase import * if timeDiscretization=='vbdf': diff --git a/test/CLSVOF/with_RANS2P/vof_p.py b/test/CLSVOF/with_RANS2P/vof_p.py index 515e2b0d90..33502aed24 100644 --- a/test/CLSVOF/with_RANS2P/vof_p.py +++ b/test/CLSVOF/with_RANS2P/vof_p.py @@ -1,6 +1,6 @@ from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside -from proteus.mprans import VOF +from proteus.kernels import VOF from .multiphase import * LevelModelType = VOF.LevelModel diff --git a/test/CLSVOF/with_RANS3PF/clsvof_p.py b/test/CLSVOF/with_RANS3PF/clsvof_p.py index 6172693ec1..15d0faa893 100644 --- a/test/CLSVOF/with_RANS3PF/clsvof_p.py +++ b/test/CLSVOF/with_RANS3PF/clsvof_p.py @@ -6,7 +6,7 @@ from .multiphase import * except: from multiphase import * -from proteus.mprans import CLSVOF +from proteus.kernels import CLSVOF LevelModelType = CLSVOF.LevelModel coefficients = CLSVOF.Coefficients(V_model=V_model, diff --git a/test/CLSVOF/with_RANS3PF/ls_consrv_p.py b/test/CLSVOF/with_RANS3PF/ls_consrv_p.py index 976060a6ad..acc409f2d8 100644 --- a/test/CLSVOF/with_RANS3PF/ls_consrv_p.py +++ b/test/CLSVOF/with_RANS3PF/ls_consrv_p.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * from .multiphase import * -from proteus.mprans import MCorr3P +from proteus.kernels import MCorr3P LevelModelType = MCorr3P.LevelModel coefficients = MCorr3P.Coefficients(LS_model=LS_model, diff --git a/test/CLSVOF/with_RANS3PF/ls_p.py b/test/CLSVOF/with_RANS3PF/ls_p.py index c29c8b1d10..d3a5c702e6 100644 --- a/test/CLSVOF/with_RANS3PF/ls_p.py +++ b/test/CLSVOF/with_RANS3PF/ls_p.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * from .multiphase import * -from proteus.mprans import NCLS3P +from proteus.kernels import NCLS3P LevelModelType = NCLS3P.LevelModel coefficients = NCLS3P.Coefficients(V_model=V_model, diff --git a/test/CLSVOF/with_RANS3PF/pressureInitial_p.py b/test/CLSVOF/with_RANS3PF/pressureInitial_p.py index 2e13649a28..0e8ad2fce7 100644 --- a/test/CLSVOF/with_RANS3PF/pressureInitial_p.py +++ b/test/CLSVOF/with_RANS3PF/pressureInitial_p.py @@ -5,7 +5,7 @@ from .multiphase import * except: from multiphase import * -from proteus.mprans import PresInit +from proteus.kernels import PresInit name = "pressureInitial" #LevelModelType = PresInit.LevelModel diff --git a/test/CLSVOF/with_RANS3PF/pressure_p.py b/test/CLSVOF/with_RANS3PF/pressure_p.py index e40efc0b39..543ce89ff3 100644 --- a/test/CLSVOF/with_RANS3PF/pressure_p.py +++ b/test/CLSVOF/with_RANS3PF/pressure_p.py @@ -5,7 +5,7 @@ from .multiphase import * except: from multiphase import * -from proteus.mprans import Pres +from proteus.kernels import Pres name = "pressure" LevelModelType = Pres.LevelModel diff --git a/test/CLSVOF/with_RANS3PF/pressureincrement_p.py b/test/CLSVOF/with_RANS3PF/pressureincrement_p.py index 218e9aee0c..f6e65bbb58 100644 --- a/test/CLSVOF/with_RANS3PF/pressureincrement_p.py +++ b/test/CLSVOF/with_RANS3PF/pressureincrement_p.py @@ -8,7 +8,7 @@ name = "pressureincrement" -from proteus.mprans import PresInc +from proteus.kernels import PresInc LevelModelType = PresInc.LevelModel coefficients=PresInc.Coefficients(rho_f_min = (1.0-1.0e-8)*rho_1, rho_s_min = (1.0-1.0e-8)*rho_s, diff --git a/test/CLSVOF/with_RANS3PF/redist_p.py b/test/CLSVOF/with_RANS3PF/redist_p.py index cf1dae5757..5a2947e8c6 100644 --- a/test/CLSVOF/with_RANS3PF/redist_p.py +++ b/test/CLSVOF/with_RANS3PF/redist_p.py @@ -2,7 +2,7 @@ from proteus.default_p import * from math import * from .multiphase import * -from proteus.mprans import RDLS3P +from proteus.kernels import RDLS3P """ The redistancing equation in the sloshbox test problem. """ diff --git a/test/CLSVOF/with_RANS3PF/twp_navier_stokes_p.py b/test/CLSVOF/with_RANS3PF/twp_navier_stokes_p.py index 3df9d4177f..f943d537ec 100644 --- a/test/CLSVOF/with_RANS3PF/twp_navier_stokes_p.py +++ b/test/CLSVOF/with_RANS3PF/twp_navier_stokes_p.py @@ -4,7 +4,7 @@ from .multiphase import * except: from multiphase import * -from proteus.mprans import RANS3PF +from proteus.kernels import RANS3PF #No RANS Closure_0_model = None diff --git a/test/CLSVOF/with_RANS3PF/vof_p.py b/test/CLSVOF/with_RANS3PF/vof_p.py index c5005ee8e2..2089bdee2d 100644 --- a/test/CLSVOF/with_RANS3PF/vof_p.py +++ b/test/CLSVOF/with_RANS3PF/vof_p.py @@ -2,7 +2,7 @@ from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside from .multiphase import * -from proteus.mprans import VOF3P +from proteus.kernels import VOF3P LevelModelType = VOF3P.LevelModel coefficients = VOF3P.Coefficients(LS_model=LS_model, diff --git a/test/FSI/fallingCylinder.py b/test/FSI/fallingCylinder.py index a5125707df..776356c0ef 100644 --- a/test/FSI/fallingCylinder.py +++ b/test/FSI/fallingCylinder.py @@ -1,7 +1,7 @@ import numpy as np from proteus import Domain from proteus import Context -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st from proteus.mbd import CouplingFSI as fsi import pychrono import os diff --git a/test/FSI/floatingCube.py b/test/FSI/floatingCube.py index 2396be57ec..40752d469d 100755 --- a/test/FSI/floatingCube.py +++ b/test/FSI/floatingCube.py @@ -1,6 +1,6 @@ import numpy as np from proteus import Domain, Context, Comm -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow import proteus.TwoPhaseFlow.utils.Parameters as Parameters from proteus import WaveTools as wt diff --git a/test/FSI/floatingCylinder.py b/test/FSI/floatingCylinder.py index f31dc6dd29..c09f933329 100755 --- a/test/FSI/floatingCylinder.py +++ b/test/FSI/floatingCylinder.py @@ -1,6 +1,6 @@ import numpy as np from proteus import Domain, Context, Comm -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow import proteus.TwoPhaseFlow.utils.Parameters as Parameters from proteus import WaveTools as wt diff --git a/test/HotStart_3P/pressureInitial_p.py b/test/HotStart_3P/pressureInitial_p.py index 3c3449f869..e250044b7f 100755 --- a/test/HotStart_3P/pressureInitial_p.py +++ b/test/HotStart_3P/pressureInitial_p.py @@ -2,7 +2,7 @@ from proteus import * from proteus.default_p import * from NS_hotstart import * -from proteus.mprans import PresInit +from proteus.kernels import PresInit #domain = ctx.domain #nd = ctx.nd diff --git a/test/HotStart_3P/pressure_p.py b/test/HotStart_3P/pressure_p.py index b1e3c65f37..00d39a6c52 100755 --- a/test/HotStart_3P/pressure_p.py +++ b/test/HotStart_3P/pressure_p.py @@ -2,7 +2,7 @@ from proteus import * from proteus.default_p import * from NS_hotstart import * -from proteus.mprans import Pres +from proteus.kernels import Pres name = "pressure" diff --git a/test/HotStart_3P/pressureincrement_p.py b/test/HotStart_3P/pressureincrement_p.py index fda278ea32..1cf2b4f274 100755 --- a/test/HotStart_3P/pressureincrement_p.py +++ b/test/HotStart_3P/pressureincrement_p.py @@ -7,7 +7,7 @@ #nd = ctx.nd name = "pressureincrement" -from proteus.mprans import PresInc +from proteus.kernels import PresInc coefficients=PresInc.Coefficients(rho_f_min = (1.0-1.0e-8)*rho_1, rho_s_min = (1.0-1.0e-8)*rho_s, nd = nd, diff --git a/test/HotStart_3P/twp_navier_stokes_p.py b/test/HotStart_3P/twp_navier_stokes_p.py index 313c6f1f5f..8c332554ca 100755 --- a/test/HotStart_3P/twp_navier_stokes_p.py +++ b/test/HotStart_3P/twp_navier_stokes_p.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * from NS_hotstart import * -from proteus.mprans import RANS3PF +from proteus.kernels import RANS3PF LevelModelType = RANS3PF.LevelModel diff --git a/test/IFEM/test_cut_geometry.py b/test/IFEM/test_cut_geometry.py index 6eee49295e..81a9564a31 100644 --- a/test/IFEM/test_cut_geometry.py +++ b/test/IFEM/test_cut_geometry.py @@ -13,7 +13,8 @@ import numpy as np import pytest -from proteus import ADR, Comm, Context, NumericalSolution, Profiling, default_s, defaults +from proteus.kernels import ADR +from proteus import Comm, Context, NumericalSolution, Profiling, default_s, defaults comm = Comm.get() Profiling.logLevel = 2 diff --git a/test/IFEM/test_ifem_3p.py b/test/IFEM/test_ifem_3p.py index cc8dd6f2d6..251db022d4 100644 --- a/test/IFEM/test_ifem_3p.py +++ b/test/IFEM/test_ifem_3p.py @@ -41,7 +41,8 @@ import numpy as np import pytest -from proteus import ADR, Comm, Context, NumericalSolution, Profiling, default_s, defaults +from proteus.kernels import ADR +from proteus import Comm, Context, NumericalSolution, Profiling, default_s, defaults comm = Comm.get() Profiling.logLevel = 2 diff --git a/test/LS_with_edgeBased_EV/MCorr/test_mcorr.py b/test/LS_with_edgeBased_EV/MCorr/test_mcorr.py index 7d10f4a4fa..f80b39bba1 100644 --- a/test/LS_with_edgeBased_EV/MCorr/test_mcorr.py +++ b/test/LS_with_edgeBased_EV/MCorr/test_mcorr.py @@ -91,7 +91,7 @@ def test_supg(self, opts): # NOTE: need thorough evaluation -- unskipped this session after fixing # a missing `from proteus.LinearAlgebraTools import SparseMat` import in - # proteus/mprans/MCorr.py (getMassMatrix), plus this test's own + # proteus/kernels/MCorr.py (getMassMatrix), plus this test's own # comparison code (it hardcoded a "level_3" filename/baseline that this # config never produces -- actual output is "level_0" -- and used a # PyTables-style `.root.` attribute that doesn't exist on h5py.File). diff --git a/test/LS_with_edgeBased_EV/MCorr/thelper_MCorr_p.py b/test/LS_with_edgeBased_EV/MCorr/thelper_MCorr_p.py index 158587643a..1e8ba21d14 100644 --- a/test/LS_with_edgeBased_EV/MCorr/thelper_MCorr_p.py +++ b/test/LS_with_edgeBased_EV/MCorr/thelper_MCorr_p.py @@ -2,7 +2,7 @@ from proteus.default_p import * from .thelper_cons_ls import * name=soname+"_phicor" -from proteus.mprans import MCorr +from proteus.kernels import MCorr LevelModelType = MCorr.LevelModel diff --git a/test/LS_with_edgeBased_EV/MCorr/thelper_ncls_p.py b/test/LS_with_edgeBased_EV/MCorr/thelper_ncls_p.py index 13617ff04b..a57f66fa0a 100644 --- a/test/LS_with_edgeBased_EV/MCorr/thelper_ncls_p.py +++ b/test/LS_with_edgeBased_EV/MCorr/thelper_ncls_p.py @@ -3,7 +3,7 @@ from proteus.ctransportCoefficients import smoothedHeaviside from math import * from .thelper_cons_ls import * -from proteus.mprans import NCLS +from proteus.kernels import NCLS #import Profiling LevelModelType = NCLS.LevelModel diff --git a/test/LS_with_edgeBased_EV/MCorr/thelper_redist_p.py b/test/LS_with_edgeBased_EV/MCorr/thelper_redist_p.py index a7aaa10fc5..7803051d18 100644 --- a/test/LS_with_edgeBased_EV/MCorr/thelper_redist_p.py +++ b/test/LS_with_edgeBased_EV/MCorr/thelper_redist_p.py @@ -2,7 +2,7 @@ from proteus.default_p import * from math import * from .thelper_cons_ls import * -from proteus.mprans import RDLS +from proteus.kernels import RDLS from . import thelper_ncls_p LevelModelType = RDLS.LevelModel diff --git a/test/LS_with_edgeBased_EV/MCorr/thelper_vof_p.py b/test/LS_with_edgeBased_EV/MCorr/thelper_vof_p.py index aa972cf535..d26ceafd7e 100644 --- a/test/LS_with_edgeBased_EV/MCorr/thelper_vof_p.py +++ b/test/LS_with_edgeBased_EV/MCorr/thelper_vof_p.py @@ -2,7 +2,7 @@ from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside from .thelper_cons_ls import * -from proteus.mprans import VOF +from proteus.kernels import VOF name=soname+"_vof" """ diff --git a/test/LS_with_edgeBased_EV/NCLS/import_files/ncls.py b/test/LS_with_edgeBased_EV/NCLS/import_files/ncls.py index 3cc4376c38..6c79799310 100644 --- a/test/LS_with_edgeBased_EV/NCLS/import_files/ncls.py +++ b/test/LS_with_edgeBased_EV/NCLS/import_files/ncls.py @@ -1,6 +1,6 @@ from proteus import Domain from proteus import Context -from proteus.mprans import NCLS +from proteus.kernels import NCLS from proteus import Norms from proteus import Profiling import numpy as np diff --git a/test/LS_with_edgeBased_EV/NCLS/ncls.py b/test/LS_with_edgeBased_EV/NCLS/ncls.py index dc9ac3ca68..4cd0d350d2 100644 --- a/test/LS_with_edgeBased_EV/NCLS/ncls.py +++ b/test/LS_with_edgeBased_EV/NCLS/ncls.py @@ -1,6 +1,6 @@ from proteus import Domain from proteus import Context -from proteus.mprans import NCLS +from proteus.kernels import NCLS from proteus import Norms from proteus import Profiling import numpy as np diff --git a/test/LS_with_edgeBased_EV/VOF/import_files/vof.py b/test/LS_with_edgeBased_EV/VOF/import_files/vof.py index a0773a80a7..c02410e7ca 100644 --- a/test/LS_with_edgeBased_EV/VOF/import_files/vof.py +++ b/test/LS_with_edgeBased_EV/VOF/import_files/vof.py @@ -2,7 +2,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import VOF +from proteus.kernels import VOF import numpy as np import math diff --git a/test/LS_with_edgeBased_EV/VOF/thelper_vof.py b/test/LS_with_edgeBased_EV/VOF/thelper_vof.py index d9145ae476..d2197cd60d 100644 --- a/test/LS_with_edgeBased_EV/VOF/thelper_vof.py +++ b/test/LS_with_edgeBased_EV/VOF/thelper_vof.py @@ -2,7 +2,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import VOF +from proteus.kernels import VOF import numpy as np import math diff --git a/test/MeshAdaptPUMI/Sizefields/cylinder2D_ibm/twp_navier_stokes_p.py b/test/MeshAdaptPUMI/Sizefields/cylinder2D_ibm/twp_navier_stokes_p.py index af0cc66550..faedfd2f5c 100644 --- a/test/MeshAdaptPUMI/Sizefields/cylinder2D_ibm/twp_navier_stokes_p.py +++ b/test/MeshAdaptPUMI/Sizefields/cylinder2D_ibm/twp_navier_stokes_p.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * from cylinder import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P name = "momentum" diff --git a/test/MeshAdaptPUMI/case_run/ls_consrv_p.py b/test/MeshAdaptPUMI/case_run/ls_consrv_p.py index 7814aec76b..54ff00935d 100644 --- a/test/MeshAdaptPUMI/case_run/ls_consrv_p.py +++ b/test/MeshAdaptPUMI/case_run/ls_consrv_p.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * from couette import * -from proteus.mprans import MCorr +from proteus.kernels import MCorr LevelModelType = MCorr.LevelModel diff --git a/test/MeshAdaptPUMI/case_run/ls_p.py b/test/MeshAdaptPUMI/case_run/ls_p.py index 07c7b9b040..9fd6c956ef 100644 --- a/test/MeshAdaptPUMI/case_run/ls_p.py +++ b/test/MeshAdaptPUMI/case_run/ls_p.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * from couette import * -from proteus.mprans import NCLS +from proteus.kernels import NCLS LevelModelType = NCLS.LevelModel diff --git a/test/MeshAdaptPUMI/case_run/redist_p.py b/test/MeshAdaptPUMI/case_run/redist_p.py index 2152250d9c..dc4508a2a0 100644 --- a/test/MeshAdaptPUMI/case_run/redist_p.py +++ b/test/MeshAdaptPUMI/case_run/redist_p.py @@ -2,7 +2,7 @@ from proteus.default_p import * from math import * from couette import * -from proteus.mprans import RDLS +from proteus.kernels import RDLS """ The redistancing equation in the sloshbox test problem. """ diff --git a/test/MeshAdaptPUMI/case_run/twp_navier_stokes_p.py b/test/MeshAdaptPUMI/case_run/twp_navier_stokes_p.py index e086a3ab30..c0c86a5923 100644 --- a/test/MeshAdaptPUMI/case_run/twp_navier_stokes_p.py +++ b/test/MeshAdaptPUMI/case_run/twp_navier_stokes_p.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * from couette import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P from decimal import * from proteus import Context diff --git a/test/MeshAdaptPUMI/case_run/vof_p.py b/test/MeshAdaptPUMI/case_run/vof_p.py index 65d81115fe..e4344b7f4d 100644 --- a/test/MeshAdaptPUMI/case_run/vof_p.py +++ b/test/MeshAdaptPUMI/case_run/vof_p.py @@ -2,7 +2,7 @@ from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside from couette import * -from proteus.mprans import VOF +from proteus.kernels import VOF LevelModelType = VOF.LevelModel if useOnlyVF: diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/dambreak_Colagrossi.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/dambreak_Colagrossi.py index d335aceb58..c3d27aa834 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/dambreak_Colagrossi.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/dambreak_Colagrossi.py @@ -10,9 +10,9 @@ MeshTools as mt, WaveTools as wt, Gauges) -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st from proteus.Profiling import logEvent -from proteus.mprans.SpatialTools import Tank2D +from proteus.SpatialTools import Tank2D from proteus.Gauges import PointGauges, LineIntegralGauges diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/ls_consrv_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/ls_consrv_p.py index 831568f612..e1353f5d26 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/ls_consrv_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/ls_consrv_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import MCorr +from proteus.kernels import MCorr from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/ls_n.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/ls_n.py index bc5f460e47..953442e8ee 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/ls_n.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/ls_n.py @@ -5,7 +5,7 @@ NonlinearSolvers, LinearSolvers, LinearAlgebraTools) -from proteus.mprans import NCLS +from proteus.kernels import NCLS from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/ls_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/ls_p.py index 80e104bb29..c742352b59 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/ls_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/ls_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import NCLS +from proteus.kernels import NCLS from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/redist_n.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/redist_n.py index 8880621b50..7a68167d33 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/redist_n.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/redist_n.py @@ -5,7 +5,7 @@ LinearSolvers, LinearAlgebraTools, NumericalFlux) -from proteus.mprans import RDLS +from proteus.kernels import RDLS import redist_p as physics from proteus import Context diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/redist_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/redist_p.py index c188f39abd..6d20bf1e4c 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/redist_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/redist_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import RDLS +from proteus.kernels import RDLS from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/twp_navier_stokes_n.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/twp_navier_stokes_n.py index db4b5bd6b7..cdefaeecd1 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/twp_navier_stokes_n.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/twp_navier_stokes_n.py @@ -5,7 +5,7 @@ LinearAlgebraTools) from proteus.default_n import * import twp_navier_stokes_p as physics -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/twp_navier_stokes_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/twp_navier_stokes_p.py index 41080763e4..2b304833a3 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/twp_navier_stokes_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/twp_navier_stokes_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P import numpy as np from proteus import Context diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/vof_n.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/vof_n.py index d8ac0e9a71..c4efa134a3 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/vof_n.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/vof_n.py @@ -5,7 +5,7 @@ LinearSolvers, LinearAlgebraTools) import vof_p as physics -from proteus.mprans import VOF +from proteus.kernels import VOF from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/vof_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/vof_p.py index 80bc0d0054..676f85fde5 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/vof_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/vof_p.py @@ -1,6 +1,6 @@ from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside -from proteus.mprans import VOF +from proteus.kernels import VOF from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/dambreak_Colagrossi.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/dambreak_Colagrossi.py index 4a892d3f1c..db52a6db2f 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/dambreak_Colagrossi.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/dambreak_Colagrossi.py @@ -10,9 +10,9 @@ MeshTools as mt, WaveTools as wt, Gauges) -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st from proteus.Profiling import logEvent -from proteus.mprans.SpatialTools import Tank2D +from proteus.SpatialTools import Tank2D from proteus.Gauges import PointGauges diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/ls_consrv_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/ls_consrv_p.py index 831568f612..e1353f5d26 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/ls_consrv_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/ls_consrv_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import MCorr +from proteus.kernels import MCorr from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/ls_n.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/ls_n.py index bc5f460e47..953442e8ee 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/ls_n.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/ls_n.py @@ -5,7 +5,7 @@ NonlinearSolvers, LinearSolvers, LinearAlgebraTools) -from proteus.mprans import NCLS +from proteus.kernels import NCLS from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/ls_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/ls_p.py index 80e104bb29..c742352b59 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/ls_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/ls_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import NCLS +from proteus.kernels import NCLS from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/redist_n.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/redist_n.py index 8880621b50..7a68167d33 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/redist_n.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/redist_n.py @@ -5,7 +5,7 @@ LinearSolvers, LinearAlgebraTools, NumericalFlux) -from proteus.mprans import RDLS +from proteus.kernels import RDLS import redist_p as physics from proteus import Context diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/redist_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/redist_p.py index c188f39abd..6d20bf1e4c 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/redist_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/redist_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import RDLS +from proteus.kernels import RDLS from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/twp_navier_stokes_n.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/twp_navier_stokes_n.py index db4b5bd6b7..cdefaeecd1 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/twp_navier_stokes_n.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/twp_navier_stokes_n.py @@ -5,7 +5,7 @@ LinearAlgebraTools) from proteus.default_n import * import twp_navier_stokes_p as physics -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/twp_navier_stokes_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/twp_navier_stokes_p.py index 41080763e4..2b304833a3 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/twp_navier_stokes_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/twp_navier_stokes_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P import numpy as np from proteus import Context diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/vof_n.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/vof_n.py index 28041e3da3..17f580d972 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/vof_n.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/vof_n.py @@ -5,7 +5,7 @@ LinearSolvers, LinearAlgebraTools) import vof_p as physics -from proteus.mprans import VOF +from proteus.kernels import VOF from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/vof_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/vof_p.py index 80bc0d0054..676f85fde5 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/vof_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rd/vof_p.py @@ -1,6 +1,6 @@ from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside -from proteus.mprans import VOF +from proteus.kernels import VOF from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/dambreak_Colagrossi.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/dambreak_Colagrossi.py index 1df1420f9a..de9a7f3df8 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/dambreak_Colagrossi.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/dambreak_Colagrossi.py @@ -10,9 +10,9 @@ MeshTools as mt, WaveTools as wt, Gauges) -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st from proteus.Profiling import logEvent -from proteus.mprans.SpatialTools import Tank2D +from proteus.SpatialTools import Tank2D from proteus.Gauges import PointGauges diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/ls_consrv_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/ls_consrv_p.py index 831568f612..e1353f5d26 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/ls_consrv_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/ls_consrv_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import MCorr +from proteus.kernels import MCorr from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/ls_n.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/ls_n.py index bc5f460e47..953442e8ee 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/ls_n.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/ls_n.py @@ -5,7 +5,7 @@ NonlinearSolvers, LinearSolvers, LinearAlgebraTools) -from proteus.mprans import NCLS +from proteus.kernels import NCLS from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/ls_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/ls_p.py index 80e104bb29..c742352b59 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/ls_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/ls_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import NCLS +from proteus.kernels import NCLS from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/redist_n.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/redist_n.py index 8880621b50..7a68167d33 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/redist_n.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/redist_n.py @@ -5,7 +5,7 @@ LinearSolvers, LinearAlgebraTools, NumericalFlux) -from proteus.mprans import RDLS +from proteus.kernels import RDLS import redist_p as physics from proteus import Context diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/redist_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/redist_p.py index c188f39abd..6d20bf1e4c 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/redist_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/redist_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import RDLS +from proteus.kernels import RDLS from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/twp_navier_stokes_n.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/twp_navier_stokes_n.py index db4b5bd6b7..cdefaeecd1 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/twp_navier_stokes_n.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/twp_navier_stokes_n.py @@ -5,7 +5,7 @@ LinearAlgebraTools) from proteus.default_n import * import twp_navier_stokes_p as physics -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/twp_navier_stokes_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/twp_navier_stokes_p.py index 41080763e4..2b304833a3 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/twp_navier_stokes_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/twp_navier_stokes_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P import numpy as np from proteus import Context diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/vof_n.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/vof_n.py index 28041e3da3..17f580d972 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/vof_n.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/vof_n.py @@ -5,7 +5,7 @@ LinearSolvers, LinearAlgebraTools) import vof_p as physics -from proteus.mprans import VOF +from proteus.kernels import VOF from proteus import Context ct = Context.get() diff --git a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/vof_p.py b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/vof_p.py index 80bc0d0054..676f85fde5 100644 --- a/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/vof_p.py +++ b/test/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D_rdmc/vof_p.py @@ -1,6 +1,6 @@ from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside -from proteus.mprans import VOF +from proteus.kernels import VOF from proteus import Context ct = Context.get() diff --git a/test/MoveMeshMonitor/moveMesh_n.py b/test/MoveMeshMonitor/moveMesh_n.py index 40c1f44a81..5cc6f30ea3 100644 --- a/test/MoveMeshMonitor/moveMesh_n.py +++ b/test/MoveMeshMonitor/moveMesh_n.py @@ -13,7 +13,7 @@ import moveMesh_p as physics from proteus import Context -from proteus.mprans import AddedMass +from proteus.kernels import AddedMass ct = Context.get() domain = ct.domain diff --git a/test/MoveMeshMonitor/moveMesh_p.py b/test/MoveMeshMonitor/moveMesh_p.py index 68287be68a..1cabeece6c 100644 --- a/test/MoveMeshMonitor/moveMesh_p.py +++ b/test/MoveMeshMonitor/moveMesh_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import MoveMeshMonitor +from proteus import MoveMeshMonitor import numpy as np from proteus import Context diff --git a/test/ProjScheme_with_EV/pressureInitial_p.py b/test/ProjScheme_with_EV/pressureInitial_p.py index c8ced12620..fbba1543b0 100644 --- a/test/ProjScheme_with_EV/pressureInitial_p.py +++ b/test/ProjScheme_with_EV/pressureInitial_p.py @@ -2,7 +2,7 @@ from proteus import * from proteus.default_p import * from .NS_convergence import * -from proteus.mprans import PresInit +from proteus.kernels import PresInit #domain = ctx.domain #nd = ctx.nd diff --git a/test/ProjScheme_with_EV/pressure_p.py b/test/ProjScheme_with_EV/pressure_p.py index 5c3c5bb0d9..49bd749b65 100644 --- a/test/ProjScheme_with_EV/pressure_p.py +++ b/test/ProjScheme_with_EV/pressure_p.py @@ -2,7 +2,7 @@ from proteus import * from proteus.default_p import * from .NS_convergence import * -from proteus.mprans import Pres +from proteus.kernels import Pres name = "pressure" LevelModelType = Pres.LevelModel diff --git a/test/ProjScheme_with_EV/pressureincrement_p.py b/test/ProjScheme_with_EV/pressureincrement_p.py index e314cd7f27..a236f70e40 100644 --- a/test/ProjScheme_with_EV/pressureincrement_p.py +++ b/test/ProjScheme_with_EV/pressureincrement_p.py @@ -5,7 +5,7 @@ name = "pressureincrement" -from proteus.mprans import PresInc +from proteus.kernels import PresInc LevelModelType = PresInc.LevelModel coefficients=PresInc.Coefficients(rho_f_min = (1.0-1.0e-8)*rho_1, rho_s_min = (1.0-1.0e-8)*rho_s, diff --git a/test/ProjScheme_with_EV/twp_navier_stokes_p.py b/test/ProjScheme_with_EV/twp_navier_stokes_p.py index 74ef84b4af..8fafd04efc 100644 --- a/test/ProjScheme_with_EV/twp_navier_stokes_p.py +++ b/test/ProjScheme_with_EV/twp_navier_stokes_p.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * from .NS_convergence import * -from proteus.mprans import RANS3PF +from proteus.kernels import RANS3PF LevelModelType = RANS3PF.LevelModel LS_model = None diff --git a/test/RANS3PSed/bed_sediment/ls_consrv_n.py b/test/RANS3PSed/bed_sediment/ls_consrv_n.py index a0f2210076..4fcfa098c5 100644 --- a/test/RANS3PSed/bed_sediment/ls_consrv_n.py +++ b/test/RANS3PSed/bed_sediment/ls_consrv_n.py @@ -8,7 +8,7 @@ NumericalFlux) import ls_consrv_p as physics from proteus import Context -from proteus.mprans.MCorr3P import DummyNewton +from proteus.kernels.MCorr3P import DummyNewton ct = Context.get() domain = ct.domain diff --git a/test/RANS3PSed/bed_sediment/ls_consrv_p.py b/test/RANS3PSed/bed_sediment/ls_consrv_p.py index e6918ab85d..a2ff74b3b9 100644 --- a/test/RANS3PSed/bed_sediment/ls_consrv_p.py +++ b/test/RANS3PSed/bed_sediment/ls_consrv_p.py @@ -1,7 +1,7 @@ from proteus import StepControl from proteus import * from proteus.default_p import * -from proteus.mprans import MCorr3P +from proteus.kernels import MCorr3P from proteus import Context ct = Context.get() diff --git a/test/RANS3PSed/bed_sediment/ls_n.py b/test/RANS3PSed/bed_sediment/ls_n.py index 8e92612429..8e28266e4c 100644 --- a/test/RANS3PSed/bed_sediment/ls_n.py +++ b/test/RANS3PSed/bed_sediment/ls_n.py @@ -6,7 +6,7 @@ NonlinearSolvers, LinearSolvers, LinearAlgebraTools) -from proteus.mprans import NCLS3P +from proteus.kernels import NCLS3P from proteus import Context ct = Context.get() diff --git a/test/RANS3PSed/bed_sediment/ls_p.py b/test/RANS3PSed/bed_sediment/ls_p.py index 2710893b0c..bd7e069dd0 100644 --- a/test/RANS3PSed/bed_sediment/ls_p.py +++ b/test/RANS3PSed/bed_sediment/ls_p.py @@ -1,7 +1,7 @@ from proteus import StepControl from proteus import * from proteus.default_p import * -from proteus.mprans import NCLS3P +from proteus.kernels import NCLS3P from proteus import Context ct = Context.get() diff --git a/test/RANS3PSed/bed_sediment/pressureInitial_p.py b/test/RANS3PSed/bed_sediment/pressureInitial_p.py index d86e560d1c..4fd0d91ade 100644 --- a/test/RANS3PSed/bed_sediment/pressureInitial_p.py +++ b/test/RANS3PSed/bed_sediment/pressureInitial_p.py @@ -1,7 +1,7 @@ from math import * from proteus import * from proteus.default_p import * -from proteus.mprans import PresInit +from proteus.kernels import PresInit from proteus import Context from tank import * diff --git a/test/RANS3PSed/bed_sediment/pressure_p.py b/test/RANS3PSed/bed_sediment/pressure_p.py index 98c685a218..fb15dd1e79 100644 --- a/test/RANS3PSed/bed_sediment/pressure_p.py +++ b/test/RANS3PSed/bed_sediment/pressure_p.py @@ -1,7 +1,7 @@ from math import * from proteus import * from proteus.default_p import * -from proteus.mprans import Pres +from proteus.kernels import Pres from proteus import Context from tank import * diff --git a/test/RANS3PSed/bed_sediment/pressureincrement_p.py b/test/RANS3PSed/bed_sediment/pressureincrement_p.py index 2f087a0f44..e5ea1a1d2f 100644 --- a/test/RANS3PSed/bed_sediment/pressureincrement_p.py +++ b/test/RANS3PSed/bed_sediment/pressureincrement_p.py @@ -3,7 +3,7 @@ from proteus.default_p import * from tank import * import tank_so -from proteus.mprans import PresInc +from proteus.kernels import PresInc from proteus import Context ct = Context.get() @@ -20,7 +20,7 @@ # nd = nd, # modelIndex=PINC_model, # fluidModelIndex=V_model) -from proteus.mprans import PresInc +from proteus.kernels import PresInc coefficients=PresInc.Coefficients(rho_f_min = (1.0-1.0e-8)*rho_1, rho_s_min = (1.0-1.0e-8)*rho_s, nd = nd, diff --git a/test/RANS3PSed/bed_sediment/redist_n.py b/test/RANS3PSed/bed_sediment/redist_n.py index ba4cb5c598..4027b829d5 100644 --- a/test/RANS3PSed/bed_sediment/redist_n.py +++ b/test/RANS3PSed/bed_sediment/redist_n.py @@ -6,7 +6,7 @@ LinearSolvers, LinearAlgebraTools, NumericalFlux) -from proteus.mprans import RDLS +from proteus.kernels import RDLS import redist_p as physics from proteus import Context diff --git a/test/RANS3PSed/bed_sediment/redist_p.py b/test/RANS3PSed/bed_sediment/redist_p.py index 6a485cbbd5..1f79fcfe06 100644 --- a/test/RANS3PSed/bed_sediment/redist_p.py +++ b/test/RANS3PSed/bed_sediment/redist_p.py @@ -2,7 +2,7 @@ from proteus import * from proteus.default_p import * from math import * -from proteus.mprans import RDLS +from proteus.kernels import RDLS from proteus import Context """ diff --git a/test/RANS3PSed/bed_sediment/tank.py b/test/RANS3PSed/bed_sediment/tank.py index c048159d63..acc3078bf2 100644 --- a/test/RANS3PSed/bed_sediment/tank.py +++ b/test/RANS3PSed/bed_sediment/tank.py @@ -4,10 +4,10 @@ from proteus import Domain, Context from proteus.default_n import * from proteus.Profiling import logEvent -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st from proteus import Gauges as ga from proteus import WaveTools as wt -from proteus.mprans.SedClosure import HsuSedStress +from proteus.kernels.SedClosure import HsuSedStress opts=Context.Options([ diff --git a/test/RANS3PSed/bed_sediment/threep_navier_stokes_sed_p.py b/test/RANS3PSed/bed_sediment/threep_navier_stokes_sed_p.py index b82c83eace..f94de38f90 100644 --- a/test/RANS3PSed/bed_sediment/threep_navier_stokes_sed_p.py +++ b/test/RANS3PSed/bed_sediment/threep_navier_stokes_sed_p.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * from tank import * -from proteus.mprans import RANS3PSed +from proteus.kernels import RANS3PSed from proteus import Context ct = Context.get() diff --git a/test/RANS3PSed/bed_sediment/twp_navier_stokes_p.py b/test/RANS3PSed/bed_sediment/twp_navier_stokes_p.py index 4694972d92..b53b3a2034 100644 --- a/test/RANS3PSed/bed_sediment/twp_navier_stokes_p.py +++ b/test/RANS3PSed/bed_sediment/twp_navier_stokes_p.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * from tank import * -from proteus.mprans import RANS3PF +from proteus.kernels import RANS3PF from proteus import Context ct = Context.get() diff --git a/test/RANS3PSed/bed_sediment/vof_n.py b/test/RANS3PSed/bed_sediment/vof_n.py index c76abb6c6e..c29f6f86d8 100644 --- a/test/RANS3PSed/bed_sediment/vof_n.py +++ b/test/RANS3PSed/bed_sediment/vof_n.py @@ -5,7 +5,7 @@ LinearSolvers, LinearAlgebraTools) import vof_p as physics -from proteus.mprans import VOF3P +from proteus.kernels import VOF3P from proteus import Context ct = Context.get() diff --git a/test/RANS3PSed/bed_sediment/vof_p.py b/test/RANS3PSed/bed_sediment/vof_p.py index 296fef5058..c891342bf2 100644 --- a/test/RANS3PSed/bed_sediment/vof_p.py +++ b/test/RANS3PSed/bed_sediment/vof_p.py @@ -1,6 +1,6 @@ from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside -from proteus.mprans import VOF3P +from proteus.kernels import VOF3P from proteus import Context ct = Context.get() diff --git a/test/RANS3PSed/bed_sediment/vos_n.py b/test/RANS3PSed/bed_sediment/vos_n.py index 261c6128c2..23a647800a 100644 --- a/test/RANS3PSed/bed_sediment/vos_n.py +++ b/test/RANS3PSed/bed_sediment/vos_n.py @@ -7,7 +7,7 @@ LinearAlgebraTools) import vof_p as physics from proteus import Context -from proteus.mprans import VOS3P +from proteus.kernels import VOS3P ct = Context.get() domain = ct.domain diff --git a/test/RANS3PSed/bed_sediment/vos_p.py b/test/RANS3PSed/bed_sediment/vos_p.py index ff084029bb..c558d74534 100644 --- a/test/RANS3PSed/bed_sediment/vos_p.py +++ b/test/RANS3PSed/bed_sediment/vos_p.py @@ -1,7 +1,7 @@ from proteus import StepControl from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside -from proteus.mprans import VOS3P +from proteus.kernels import VOS3P from proteus import Context from proteus import * diff --git a/test/SWFlow/beji_periodic.py b/test/SWFlow/beji_periodic.py index b4286e4439..42d3576670 100644 --- a/test/SWFlow/beji_periodic.py +++ b/test/SWFlow/beji_periodic.py @@ -1,6 +1,6 @@ from proteus import Domain, Context, MeshTools as mt -from proteus.mprans import (SW2DCV, GN_SW2DCV) -from proteus.mprans import SpatialTools as st +from proteus.kernels import (SW2DCV, GN_SW2DCV) +from proteus import SpatialTools as st from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain from proteus.Profiling import logEvent import proteus.SWFlow.SWFlowProblem as SWFlowProblem diff --git a/test/SWFlow/circular_damBreak.py b/test/SWFlow/circular_damBreak.py index 2438acad66..e25e6f00fe 100644 --- a/test/SWFlow/circular_damBreak.py +++ b/test/SWFlow/circular_damBreak.py @@ -1,4 +1,4 @@ -from proteus.mprans import (SW2DCV, GN_SW2DCV) +from proteus.kernels import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np from proteus import (Domain, Context, MeshTools as mt) diff --git a/test/SWFlow/conical_island.py b/test/SWFlow/conical_island.py index 192af2ab18..2df5c583fd 100644 --- a/test/SWFlow/conical_island.py +++ b/test/SWFlow/conical_island.py @@ -1,4 +1,4 @@ -from proteus.mprans import (SW2DCV, GN_SW2DCV) +from proteus.kernels import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain from proteus import (Domain, Context, MeshTools as mt) diff --git a/test/SWFlow/dSWEs_steady_state.py b/test/SWFlow/dSWEs_steady_state.py index 959ad1d8bc..2b3b8365dd 100644 --- a/test/SWFlow/dSWEs_steady_state.py +++ b/test/SWFlow/dSWEs_steady_state.py @@ -1,4 +1,4 @@ -from proteus.mprans import (SW2DCV, GN_SW2DCV) +from proteus.kernels import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain import numpy as np from proteus import (Domain, Context, diff --git a/test/SWFlow/dam3Bumps.py b/test/SWFlow/dam3Bumps.py index d6070a3220..3b2c23b5e8 100644 --- a/test/SWFlow/dam3Bumps.py +++ b/test/SWFlow/dam3Bumps.py @@ -1,4 +1,4 @@ -from proteus.mprans import (SW2DCV, GN_SW2DCV) +from proteus.kernels import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np from proteus import (Domain, Context, MeshTools as mt) diff --git a/test/SWFlow/mach_flow.py b/test/SWFlow/mach_flow.py index 9399cad189..041b34a6ef 100644 --- a/test/SWFlow/mach_flow.py +++ b/test/SWFlow/mach_flow.py @@ -1,10 +1,10 @@ -from proteus.mprans import (SW2DCV, GN_SW2DCV) +from proteus.kernels import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np from proteus import (Domain, Context, MeshTools as mt) from proteus.Profiling import logEvent import proteus.SWFlow.SWFlowProblem as SWFlowProblem -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st """ diff --git a/test/SWFlow/obstacle_flow.py b/test/SWFlow/obstacle_flow.py index 495c610420..1c3a8916d2 100644 --- a/test/SWFlow/obstacle_flow.py +++ b/test/SWFlow/obstacle_flow.py @@ -1,10 +1,10 @@ -from proteus.mprans import (SW2DCV, GN_SW2DCV) +from proteus.kernels import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np from proteus import (Domain, Context, MeshTools as mt) from proteus.Profiling import logEvent import proteus.SWFlow.SWFlowProblem as SWFlowProblem -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st import os diff --git a/test/SWFlow/parab1D.py b/test/SWFlow/parab1D.py index 5692b007f0..a522662bce 100644 --- a/test/SWFlow/parab1D.py +++ b/test/SWFlow/parab1D.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * -from proteus.mprans import SW2D -from proteus.mprans import SW2DCV +from proteus.kernels import SW2D +from proteus.kernels import SW2DCV from proteus.Domain import RectangularDomain import numpy as np from proteus import (Domain, Context, diff --git a/test/SWFlow/reef_island_runup.py b/test/SWFlow/reef_island_runup.py index 093584bd8c..50b680d4bb 100644 --- a/test/SWFlow/reef_island_runup.py +++ b/test/SWFlow/reef_island_runup.py @@ -1,4 +1,4 @@ -from proteus.mprans import (SW2DCV, GN_SW2DCV) +from proteus.kernels import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np from proteus import (Domain, Context, MeshTools as mt) diff --git a/test/SWFlow/runup_solitaryWave.py b/test/SWFlow/runup_solitaryWave.py index 2679060ee1..68bc7915c2 100644 --- a/test/SWFlow/runup_solitaryWave.py +++ b/test/SWFlow/runup_solitaryWave.py @@ -1,4 +1,4 @@ -from proteus.mprans import (SW2DCV, GN_SW2DCV) +from proteus.kernels import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np from proteus import (Domain, Context, MeshTools as mt) diff --git a/test/SWFlow/santos_step.py b/test/SWFlow/santos_step.py index 1b2027c1b4..1f51d0e3fd 100644 --- a/test/SWFlow/santos_step.py +++ b/test/SWFlow/santos_step.py @@ -1,4 +1,4 @@ -from proteus.mprans import (SW2DCV, GN_SW2DCV) +from proteus.kernels import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np from proteus import (Domain, Context, diff --git a/test/SWFlow/seawall.py b/test/SWFlow/seawall.py index d9a63c9fe3..25979868e8 100644 --- a/test/SWFlow/seawall.py +++ b/test/SWFlow/seawall.py @@ -1,4 +1,4 @@ -from proteus.mprans import (SW2DCV, GN_SW2DCV) +from proteus.kernels import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np from proteus import (Domain, Context, MeshTools as mt) diff --git a/test/SWFlow/solitary_wave.py b/test/SWFlow/solitary_wave.py index cf3d6da6d8..45843301f1 100644 --- a/test/SWFlow/solitary_wave.py +++ b/test/SWFlow/solitary_wave.py @@ -1,4 +1,4 @@ -from proteus.mprans import (SW2DCV, GN_SW2DCV) +from proteus.kernels import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np from proteus import (Domain, Context, MeshTools as mt) diff --git a/test/SWFlow/transcritical_bump.py b/test/SWFlow/transcritical_bump.py index 73a04bc553..2653a8fd6c 100644 --- a/test/SWFlow/transcritical_bump.py +++ b/test/SWFlow/transcritical_bump.py @@ -1,4 +1,4 @@ -from proteus.mprans import (SW2DCV, GN_SW2DCV) +from proteus.kernels import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np from proteus import (Domain, Context, MeshTools as mt) diff --git a/test/SWFlow/wet_well_balancing.py b/test/SWFlow/wet_well_balancing.py index 347c62d8a4..7143a30b43 100644 --- a/test/SWFlow/wet_well_balancing.py +++ b/test/SWFlow/wet_well_balancing.py @@ -1,4 +1,4 @@ -from proteus.mprans import (SW2DCV, GN_SW2DCV) +from proteus.kernels import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np from proteus import (Domain, Context, MeshTools as mt) diff --git a/test/TADR/Smooth_analytical_solution/thelper_tadr.py b/test/TADR/Smooth_analytical_solution/thelper_tadr.py index f6e73dfc3d..8142b3dc45 100644 --- a/test/TADR/Smooth_analytical_solution/thelper_tadr.py +++ b/test/TADR/Smooth_analytical_solution/thelper_tadr.py @@ -2,7 +2,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR import numpy as np import math diff --git a/test/TADR/thelper_tadr.py b/test/TADR/thelper_tadr.py index 52049093c2..c6fe2e76e3 100644 --- a/test/TADR/thelper_tadr.py +++ b/test/TADR/thelper_tadr.py @@ -2,7 +2,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR import numpy as np import math diff --git a/test/TwoPhaseFlow/damBreak.py b/test/TwoPhaseFlow/damBreak.py index 28d2cf954d..25955aaa1d 100644 --- a/test/TwoPhaseFlow/damBreak.py +++ b/test/TwoPhaseFlow/damBreak.py @@ -4,8 +4,8 @@ import numpy as np from proteus import (Domain, Context) from proteus.Profiling import logEvent -from proteus.mprans.SpatialTools import Tank2D -from proteus.mprans import SpatialTools as st +from proteus.SpatialTools import Tank2D +from proteus import SpatialTools as st import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow import proteus.TwoPhaseFlow.utils.Parameters as Parameters from proteus.Gauges import PointGauges, LineIntegralGauges, LineGauges diff --git a/test/TwoPhaseFlow/damBreakLevelSet.py b/test/TwoPhaseFlow/damBreakLevelSet.py index 6e8bcaca21..f7732f4bcc 100644 --- a/test/TwoPhaseFlow/damBreakLevelSet.py +++ b/test/TwoPhaseFlow/damBreakLevelSet.py @@ -9,8 +9,8 @@ import numpy as np from proteus import (Domain, Context) from proteus.Profiling import logEvent -from proteus.mprans.SpatialTools import Tank2D -from proteus.mprans import SpatialTools as st +from proteus.SpatialTools import Tank2D +from proteus import SpatialTools as st import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow import proteus.TwoPhaseFlow.utils.Parameters as Parameters from proteus.Gauges import PointGauges, LineIntegralGauges, LineGauges diff --git a/test/TwoPhaseFlow/damBreakLevelSet3D.py b/test/TwoPhaseFlow/damBreakLevelSet3D.py index 4c20a49def..d8c9afd9d4 100644 --- a/test/TwoPhaseFlow/damBreakLevelSet3D.py +++ b/test/TwoPhaseFlow/damBreakLevelSet3D.py @@ -12,7 +12,7 @@ from proteus import Comm, Context, Domain from proteus.ctransportCoefficients import smoothedHeaviside -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow opts = Context.Options([ diff --git a/test/TwoPhaseFlow/damBreak_PUMI.py b/test/TwoPhaseFlow/damBreak_PUMI.py index b83109fd91..1b6849d761 100644 --- a/test/TwoPhaseFlow/damBreak_PUMI.py +++ b/test/TwoPhaseFlow/damBreak_PUMI.py @@ -4,8 +4,8 @@ import numpy as np from proteus import (Domain, Context) from proteus.Profiling import logEvent -from proteus.mprans.SpatialTools import Tank2D -from proteus.mprans import SpatialTools as st +from proteus.SpatialTools import Tank2D +from proteus import SpatialTools as st import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow from proteus.Gauges import PointGauges, LineIntegralGauges, LineGauges import os diff --git a/test/TwoPhaseFlow/damBreak_solver_options.py b/test/TwoPhaseFlow/damBreak_solver_options.py index 4722c11406..c21373036f 100644 --- a/test/TwoPhaseFlow/damBreak_solver_options.py +++ b/test/TwoPhaseFlow/damBreak_solver_options.py @@ -4,8 +4,8 @@ import numpy as np from proteus import (Domain, Context, LinearSolvers) from proteus.Profiling import logEvent -from proteus.mprans.SpatialTools import Tank2D -from proteus.mprans import SpatialTools as st +from proteus.SpatialTools import Tank2D +from proteus import SpatialTools as st import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow from proteus.Gauges import PointGauges, LineIntegralGauges, LineGauges import os diff --git a/test/TwoPhaseFlow/marin.py b/test/TwoPhaseFlow/marin.py index 094276f89d..366344710b 100644 --- a/test/TwoPhaseFlow/marin.py +++ b/test/TwoPhaseFlow/marin.py @@ -5,9 +5,9 @@ from proteus import (Domain, Context, Gauges, MeshTools as mt) from proteus.Profiling import logEvent -from proteus.mprans.SpatialTools import Tank2D -from proteus.mprans.SpatialTools import Tank3D -from proteus.mprans import SpatialTools as st +from proteus.SpatialTools import Tank2D +from proteus.SpatialTools import Tank3D +from proteus import SpatialTools as st from proteus.Profiling import logEvent import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow import proteus.TwoPhaseFlow.utils.Parameters as Parameters diff --git a/test/TwoPhaseFlow/risingBubble.py b/test/TwoPhaseFlow/risingBubble.py index b0481f7ab1..ff5b21e1d4 100644 --- a/test/TwoPhaseFlow/risingBubble.py +++ b/test/TwoPhaseFlow/risingBubble.py @@ -4,8 +4,8 @@ import numpy as np from proteus import (Domain, Context) from proteus.Profiling import logEvent -from proteus.mprans.SpatialTools import Tank2D -from proteus.mprans import SpatialTools as st +from proteus.SpatialTools import Tank2D +from proteus import SpatialTools as st import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow import os diff --git a/test/VOS/vos.py b/test/VOS/vos.py index 23282be2b0..fd2fc8360a 100644 --- a/test/VOS/vos.py +++ b/test/VOS/vos.py @@ -2,7 +2,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import VOS3P +from proteus.kernels import VOS3P import numpy as np import math diff --git a/test/av_partition_mpi.py b/test/av_partition_mpi.py index e526a324fa..e7e868d510 100644 --- a/test/av_partition_mpi.py +++ b/test/av_partition_mpi.py @@ -23,7 +23,7 @@ rank_staging.write("damBreak.py", case) if os.environ.get("NOFIX"): - from proteus.mprans import RANS3PF + from proteus.kernels import RANS3PF _scatter = RANS3PF.LevelModel.scatterDOFArray RANS3PF.LevelModel.scatterDOFArray = lambda self, a: None if a is self.uStar_psi_dof else _scatter(self, a) diff --git a/test/ci/adr_3d_p.py b/test/ci/adr_3d_p.py index 757e5f0dcd..dbd73d74e2 100644 --- a/test/ci/adr_3d_p.py +++ b/test/ci/adr_3d_p.py @@ -6,7 +6,7 @@ Heterogeneous Poisson's equation, -div(a(x)u) = f(x), on unit domain [0,1]x[0,1]x[0,1] """ -from proteus import ADR +from proteus.kernels import ADR LevelModelType = ADR.LevelModel diff --git a/test/ci/adr_bl_3d_p.py b/test/ci/adr_bl_3d_p.py index 21987239dc..0835dd4ee3 100644 --- a/test/ci/adr_bl_3d_p.py +++ b/test/ci/adr_bl_3d_p.py @@ -4,7 +4,7 @@ Heterogeneous Poisson's equation, -div(a(x)u) = f(x), on unit domain [0,1]x[0,1]x[0,1] """ -from proteus import ADR +from proteus.kernels import ADR LevelModelType = ADR.LevelModel diff --git a/test/ci/ladr_3p_2d_p.py b/test/ci/ladr_3p_2d_p.py index 74211bf46f..44afe5248a 100644 --- a/test/ci/ladr_3p_2d_p.py +++ b/test/ci/ladr_3p_2d_p.py @@ -1,6 +1,7 @@ from proteus import * from proteus.default_p import * -from proteus import ADR, Domain, AnalyticalSolutions +from proteus.kernels import ADR +from proteus import Domain, AnalyticalSolutions import numpy import math diff --git a/test/ci/ladr_fitted_2d_p.py b/test/ci/ladr_fitted_2d_p.py index 58993a86ee..ae2c685018 100644 --- a/test/ci/ladr_fitted_2d_p.py +++ b/test/ci/ladr_fitted_2d_p.py @@ -15,7 +15,8 @@ """ from proteus import * from proteus.default_p import * -from proteus import ADR, Domain, AnalyticalSolutions +from proteus.kernels import ADR +from proteus import Domain, AnalyticalSolutions import numpy import math diff --git a/test/ci/ladr_sgs_2d_p.py b/test/ci/ladr_sgs_2d_p.py index 109979b704..64a8277bce 100644 --- a/test/ci/ladr_sgs_2d_p.py +++ b/test/ci/ladr_sgs_2d_p.py @@ -1,6 +1,7 @@ from proteus import * from proteus.default_p import * -from proteus import ADR, Domain, AnalyticalSolutions +from proteus.kernels import ADR +from proteus import Domain, AnalyticalSolutions import numpy import math diff --git a/test/ci/ladr_ss_2d_p.py b/test/ci/ladr_ss_2d_p.py index 483054e6e0..450726a170 100644 --- a/test/ci/ladr_ss_2d_p.py +++ b/test/ci/ladr_ss_2d_p.py @@ -1,6 +1,7 @@ from proteus import * from proteus.default_p import * -from proteus import ADR, Domain, AnalyticalSolutions +from proteus.kernels import ADR +from proteus import Domain, AnalyticalSolutions import numpy import math diff --git a/test/ci/ladr_ss_3d_p.py b/test/ci/ladr_ss_3d_p.py index d8aad02f0a..30fd21daef 100644 --- a/test/ci/ladr_ss_3d_p.py +++ b/test/ci/ladr_ss_3d_p.py @@ -1,6 +1,7 @@ from proteus import * from proteus.default_p import * -from proteus import ADR, Domain, AnalyticalSolutions +from proteus.kernels import ADR +from proteus import Domain, AnalyticalSolutions import numpy import math diff --git a/test/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_p.py b/test/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_p.py index c472c0ee3f..36a5c69fe5 100644 --- a/test/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_p.py +++ b/test/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_p.py @@ -8,7 +8,7 @@ from .cylinder2d import * except: from cylinder2d import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P name="rans2p" bcsTimeDependent = True LevelModelType = RANS2P.LevelModel diff --git a/test/cylinder2D/conforming_rans3p/pressureInitial_p.py b/test/cylinder2D/conforming_rans3p/pressureInitial_p.py index 880712b5ca..041744cc9a 100644 --- a/test/cylinder2D/conforming_rans3p/pressureInitial_p.py +++ b/test/cylinder2D/conforming_rans3p/pressureInitial_p.py @@ -6,7 +6,7 @@ except: from cylinder3p import * -from proteus.mprans import PresInit +from proteus.kernels import PresInit #domain = ctx.domain #nd = ctx.nd diff --git a/test/cylinder2D/conforming_rans3p/pressure_p.py b/test/cylinder2D/conforming_rans3p/pressure_p.py index 32a8a9ffbb..cf5b03f679 100644 --- a/test/cylinder2D/conforming_rans3p/pressure_p.py +++ b/test/cylinder2D/conforming_rans3p/pressure_p.py @@ -6,7 +6,7 @@ except: from cylinder3p import * -from proteus.mprans import Pres +from proteus.kernels import Pres name = "pressure" diff --git a/test/cylinder2D/conforming_rans3p/pressureincrement_p.py b/test/cylinder2D/conforming_rans3p/pressureincrement_p.py index 9423ac1fe9..cbb149384d 100644 --- a/test/cylinder2D/conforming_rans3p/pressureincrement_p.py +++ b/test/cylinder2D/conforming_rans3p/pressureincrement_p.py @@ -17,7 +17,7 @@ # nd = nd, # modelIndex=PINC_model, # fluidModelIndex=V_model) -from proteus.mprans import PresInc +from proteus.kernels import PresInc coefficients=PresInc.Coefficients(rho_f_min = (1.0-1.0e-8)*rho_1, rho_s_min = (1.0-1.0e-8)*rho_s, nd = nd, diff --git a/test/cylinder2D/conforming_rans3p/twp_navier_stokes_p.py b/test/cylinder2D/conforming_rans3p/twp_navier_stokes_p.py index 489a4aa6c2..10cf1e8a5c 100644 --- a/test/cylinder2D/conforming_rans3p/twp_navier_stokes_p.py +++ b/test/cylinder2D/conforming_rans3p/twp_navier_stokes_p.py @@ -4,7 +4,7 @@ from .cylinder3p import * except: from cylinder3p import * -from proteus.mprans import RANS3PF +from proteus.kernels import RANS3PF LevelModelType = RANS3PF.LevelModel if useOnlyVF: diff --git a/test/cylinder2D/ibm_method/pressureInitial_p.py b/test/cylinder2D/ibm_method/pressureInitial_p.py index afd55201ab..b4d2a99a69 100644 --- a/test/cylinder2D/ibm_method/pressureInitial_p.py +++ b/test/cylinder2D/ibm_method/pressureInitial_p.py @@ -5,7 +5,7 @@ from .cylinder import * except: from cylinder import * -from proteus.mprans import PresInit +from proteus.kernels import PresInit #domain = ctx.domain #nd = ctx.nd diff --git a/test/cylinder2D/ibm_method/pressure_p.py b/test/cylinder2D/ibm_method/pressure_p.py index 7a084b2653..89e8c0e520 100644 --- a/test/cylinder2D/ibm_method/pressure_p.py +++ b/test/cylinder2D/ibm_method/pressure_p.py @@ -5,7 +5,7 @@ from .cylinder import * except: from cylinder import * -from proteus.mprans import Pres +from proteus.kernels import Pres name = "pressure" diff --git a/test/cylinder2D/ibm_method/pressureincrement_p.py b/test/cylinder2D/ibm_method/pressureincrement_p.py index cb4fb12025..6f2de72143 100644 --- a/test/cylinder2D/ibm_method/pressureincrement_p.py +++ b/test/cylinder2D/ibm_method/pressureincrement_p.py @@ -17,7 +17,7 @@ # nd = nd, # modelIndex=PINC_model, # fluidModelIndex=V_model) -from proteus.mprans import PresInc +from proteus.kernels import PresInc coefficients=PresInc.Coefficients(rho_f_min = (1.0-1.0e-8)*rho_1, rho_s_min = (1.0-1.0e-8)*rho_s, nd = nd, diff --git a/test/cylinder2D/ibm_method/twp_navier_stokes_p.py b/test/cylinder2D/ibm_method/twp_navier_stokes_p.py index 9f2a405ddf..f8ea113be9 100644 --- a/test/cylinder2D/ibm_method/twp_navier_stokes_p.py +++ b/test/cylinder2D/ibm_method/twp_navier_stokes_p.py @@ -4,7 +4,7 @@ from .cylinder import * except: from cylinder import * -from proteus.mprans import RANS3PF +from proteus.kernels import RANS3PF name="rans3p" LevelModelType = RANS3PF.LevelModel if useOnlyVF: diff --git a/test/cylinder2D/ibm_rans2p/twp_navier_stokes_p.py b/test/cylinder2D/ibm_rans2p/twp_navier_stokes_p.py index af0cc66550..faedfd2f5c 100644 --- a/test/cylinder2D/ibm_rans2p/twp_navier_stokes_p.py +++ b/test/cylinder2D/ibm_rans2p/twp_navier_stokes_p.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * from cylinder import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P name = "momentum" diff --git a/test/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_p.py b/test/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_p.py index 9af9e8a4b6..c6afc21cab 100644 --- a/test/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_p.py +++ b/test/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_p.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * from cylinder import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P name = "momentum" LevelModelType = RANS2P.LevelModel diff --git a/test/cylinder2D/sbm_3Dmesh/pressureInitial_p.py b/test/cylinder2D/sbm_3Dmesh/pressureInitial_p.py index 5bf059823a..373bc0de3e 100644 --- a/test/cylinder2D/sbm_3Dmesh/pressureInitial_p.py +++ b/test/cylinder2D/sbm_3Dmesh/pressureInitial_p.py @@ -2,7 +2,7 @@ from proteus import * from proteus.default_p import * from cylinder import * -from proteus.mprans import PresInit +from proteus.kernels import PresInit #domain = ctx.domain #nd = ctx.nd diff --git a/test/cylinder2D/sbm_3Dmesh/pressure_p.py b/test/cylinder2D/sbm_3Dmesh/pressure_p.py index 93d090b050..69f42f69b4 100644 --- a/test/cylinder2D/sbm_3Dmesh/pressure_p.py +++ b/test/cylinder2D/sbm_3Dmesh/pressure_p.py @@ -2,7 +2,7 @@ from proteus import * from proteus.default_p import * from cylinder import * -from proteus.mprans import Pres +from proteus.kernels import Pres name = "pressure" diff --git a/test/cylinder2D/sbm_3Dmesh/pressureincrement_p.py b/test/cylinder2D/sbm_3Dmesh/pressureincrement_p.py index 92e3d30153..55e6c29f9a 100644 --- a/test/cylinder2D/sbm_3Dmesh/pressureincrement_p.py +++ b/test/cylinder2D/sbm_3Dmesh/pressureincrement_p.py @@ -14,7 +14,7 @@ # nd = nd, # modelIndex=PINC_model, # fluidModelIndex=V_model) -from proteus.mprans import PresInc +from proteus.kernels import PresInc coefficients=PresInc.Coefficients(rho_f_min = (1.0-1.0e-8)*rho_1, rho_s_min = (1.0-1.0e-8)*rho_s, nd = nd, diff --git a/test/cylinder2D/sbm_3Dmesh/twp_navier_stokes_p.py b/test/cylinder2D/sbm_3Dmesh/twp_navier_stokes_p.py index 60fb887feb..2fe6e25e74 100644 --- a/test/cylinder2D/sbm_3Dmesh/twp_navier_stokes_p.py +++ b/test/cylinder2D/sbm_3Dmesh/twp_navier_stokes_p.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * from cylinder import * -from proteus.mprans import RANS3PF +from proteus.kernels import RANS3PF name = "momentum" LevelModelType = RANS3PF.LevelModel diff --git a/test/cylinder2D/sbm_method/pressureInitial_p.py b/test/cylinder2D/sbm_method/pressureInitial_p.py index afd55201ab..b4d2a99a69 100644 --- a/test/cylinder2D/sbm_method/pressureInitial_p.py +++ b/test/cylinder2D/sbm_method/pressureInitial_p.py @@ -5,7 +5,7 @@ from .cylinder import * except: from cylinder import * -from proteus.mprans import PresInit +from proteus.kernels import PresInit #domain = ctx.domain #nd = ctx.nd diff --git a/test/cylinder2D/sbm_method/pressure_p.py b/test/cylinder2D/sbm_method/pressure_p.py index aa0c963794..4f58a6273e 100644 --- a/test/cylinder2D/sbm_method/pressure_p.py +++ b/test/cylinder2D/sbm_method/pressure_p.py @@ -5,7 +5,7 @@ from .cylinder import * except: from cylinder import * -from proteus.mprans import Pres +from proteus.kernels import Pres name = "pressure" diff --git a/test/cylinder2D/sbm_method/pressureincrement_p.py b/test/cylinder2D/sbm_method/pressureincrement_p.py index cb4fb12025..6f2de72143 100644 --- a/test/cylinder2D/sbm_method/pressureincrement_p.py +++ b/test/cylinder2D/sbm_method/pressureincrement_p.py @@ -17,7 +17,7 @@ # nd = nd, # modelIndex=PINC_model, # fluidModelIndex=V_model) -from proteus.mprans import PresInc +from proteus.kernels import PresInc coefficients=PresInc.Coefficients(rho_f_min = (1.0-1.0e-8)*rho_1, rho_s_min = (1.0-1.0e-8)*rho_s, nd = nd, diff --git a/test/cylinder2D/sbm_method/twp_navier_stokes_p.py b/test/cylinder2D/sbm_method/twp_navier_stokes_p.py index d133365145..0e80bd109b 100644 --- a/test/cylinder2D/sbm_method/twp_navier_stokes_p.py +++ b/test/cylinder2D/sbm_method/twp_navier_stokes_p.py @@ -4,7 +4,7 @@ from .cylinder import * except: from cylinder import * -from proteus.mprans import RANS3PF +from proteus.kernels import RANS3PF name="rans3p" LevelModelType = RANS3PF.LevelModel if useOnlyVF: diff --git a/test/cylinder2D/test_rans2p_cut_cells.py b/test/cylinder2D/test_rans2p_cut_cells.py index b4f319136f..f9c376fc76 100644 --- a/test/cylinder2D/test_rans2p_cut_cells.py +++ b/test/cylinder2D/test_rans2p_cut_cells.py @@ -41,7 +41,7 @@ def _probe(opts, monkeypatch, useExact): before = set(os.listdir(deckdir)) monkeypatch.chdir(deckdir) monkeypatch.syspath_prepend(deckdir) - from proteus.mprans import RANS2P + from proteus.kernels import RANS2P LevelModel = RANS2P.LevelModel getResidual = LevelModel.getResidual seen = {} diff --git a/test/cylinder2D/test_rans2p_ghost_penalty.py b/test/cylinder2D/test_rans2p_ghost_penalty.py index 78cd4e9ad7..ae00d8fdcf 100644 --- a/test/cylinder2D/test_rans2p_ghost_penalty.py +++ b/test/cylinder2D/test_rans2p_ghost_penalty.py @@ -53,7 +53,7 @@ def test_ghost_penalty_through_jumpPenalty(case, opts, monkeypatch): before = set(os.listdir(deckdir)) monkeypatch.chdir(deckdir) monkeypatch.syspath_prepend(deckdir) - from proteus.mprans import RANS2P + from proteus.kernels import RANS2P LevelModel = RANS2P.LevelModel getResidual, getJacobian = LevelModel.getResidual, LevelModel.getJacobian seen = {} diff --git a/test/dispatch/test_dispatch.py b/test/dispatch/test_dispatch.py index 0c391c054b..567290e54a 100644 --- a/test/dispatch/test_dispatch.py +++ b/test/dispatch/test_dispatch.py @@ -120,7 +120,7 @@ def test_level_set_five_is_damBreakLevelSet(dambreak): found = dispatch(dambreak, "level_set_five") assert found.family == "two_phase_level_set" assert found.formulation == "nonconservative_inertia" - assert [m.module for m in found] == ["proteus.mprans.%s" % m for m in ("RANS2P", "VOF", "NCLS", "RDLS", "MCorr")] + assert [m.module for m in found] == ["proteus.kernels.%s" % m for m in ("RANS2P", "VOF", "NCLS", "RDLS", "MCorr")] assert [m.role for m in found] == ["velocity_pressure", "volume_fraction", "level_set", "redistancing", "mass_correction"] flow = found["flow"] @@ -165,7 +165,7 @@ def test_shallow_water_is_SWFlow(lake): found = dispatch(lake, "convex_limited") assert found.family == "shallow_water" (model,) = found.models - assert model.module == "proteus.mprans.SW2DCV" + assert model.module == "proteus.kernels.SW2DCV" assert {k: model.sources[k] for k in ("cE", "LUMPED_MASS_MATRIX", "BOUNDS_RELAXATION")} == \ dict.fromkeys(("cE", "LUMPED_MASS_MATRIX", "BOUNDS_RELAXATION"), "spec") p, n = _swflow("dam3Bumps", "sw_p", "sw_n") @@ -191,7 +191,7 @@ def test_dispersive_shallow_water_is_SWFlow_GN(lake): found = dispatch(_dispersive(lake), "convex_limited") assert found.family == "dispersive_shallow_water" (model,) = found.models - assert model.module == "proteus.mprans.GN_SW2DCV" + assert model.module == "proteus.kernels.GN_SW2DCV" p, n = _swflow("dSWEs_steady_state", "GN_sw_p", "GN_sw_n") _compare_model(model, p, n, 2) diff --git a/test/dissipation_partition_mpi.py b/test/dissipation_partition_mpi.py index 902b31c2ef..bb1e31b456 100644 --- a/test/dissipation_partition_mpi.py +++ b/test/dissipation_partition_mpi.py @@ -19,7 +19,7 @@ from proteus import (Domain, MeshTools, NumericalSolution, StepControl, TimeIntegration, default_s, defaults) from proteus.FemTools import C0_AffineLinearOnSimplexWithNodalBasis from proteus.iproteus import opts -from proteus.mprans import Dissipation as NCLS +from proteus.kernels import Dissipation as NCLS from proteus.NonlinearSolvers import Newton from proteus.LinearAlgebraTools import SparseMatrix from proteus.LinearSolvers import KSP_petsc4py diff --git a/test/elliptic_redist/RDLS/ncls_p.py b/test/elliptic_redist/RDLS/ncls_p.py index bb73580fb5..ed46124707 100644 --- a/test/elliptic_redist/RDLS/ncls_p.py +++ b/test/elliptic_redist/RDLS/ncls_p.py @@ -6,7 +6,7 @@ except: from vortex2D import * -from proteus.mprans import NCLS +from proteus.kernels import NCLS LevelModelType = NCLS.LevelModel logEvent = Profiling.logEvent diff --git a/test/elliptic_redist/RDLS/rdls_p.py b/test/elliptic_redist/RDLS/rdls_p.py index 36767380a9..57f3022650 100644 --- a/test/elliptic_redist/RDLS/rdls_p.py +++ b/test/elliptic_redist/RDLS/rdls_p.py @@ -7,7 +7,7 @@ except: from vortex2D import * import ncls_p -from proteus.mprans import RDLS +from proteus.kernels import RDLS name = soname+"_rdls" LevelModelType = RDLS.LevelModel diff --git a/test/elliptic_redist/RDLS/vortex2D.py b/test/elliptic_redist/RDLS/vortex2D.py index c1ad659d9b..fb68baea78 100644 --- a/test/elliptic_redist/RDLS/vortex2D.py +++ b/test/elliptic_redist/RDLS/vortex2D.py @@ -1,6 +1,6 @@ from proteus import Domain from proteus import Context -from proteus.mprans import NCLS +from proteus.kernels import NCLS import numpy as np ct=Context.Options([ diff --git a/test/elliptic_redist/RDLS3P/ncls_p.py b/test/elliptic_redist/RDLS3P/ncls_p.py index d6ed133510..93f8450d44 100644 --- a/test/elliptic_redist/RDLS3P/ncls_p.py +++ b/test/elliptic_redist/RDLS3P/ncls_p.py @@ -2,7 +2,7 @@ from proteus.default_p import * from math import * from .vortex2D import * -from proteus.mprans import NCLS +from proteus.kernels import NCLS LevelModelType = NCLS.LevelModel logEvent = Profiling.logEvent diff --git a/test/elliptic_redist/RDLS3P/rdls_p.py b/test/elliptic_redist/RDLS3P/rdls_p.py index 5157427852..2447c9af97 100644 --- a/test/elliptic_redist/RDLS3P/rdls_p.py +++ b/test/elliptic_redist/RDLS3P/rdls_p.py @@ -2,7 +2,7 @@ from proteus.default_p import * from math import * from .vortex2D import * -from proteus.mprans import RDLS +from proteus.kernels import RDLS from . import ncls_p name = soname+"_rdls" diff --git a/test/elliptic_redist/RDLS3P/vortex2D.py b/test/elliptic_redist/RDLS3P/vortex2D.py index 24f2a36c73..e85ba29c8c 100644 --- a/test/elliptic_redist/RDLS3P/vortex2D.py +++ b/test/elliptic_redist/RDLS3P/vortex2D.py @@ -1,6 +1,6 @@ from proteus import Domain from proteus import Context -from proteus.mprans import NCLS +from proteus.kernels import NCLS import numpy as np ct=Context.Options([ diff --git a/test/gn_sw2dcv_partition_mpi.py b/test/gn_sw2dcv_partition_mpi.py index 80b3a7d2b6..2c89c29a99 100644 --- a/test/gn_sw2dcv_partition_mpi.py +++ b/test/gn_sw2dcv_partition_mpi.py @@ -16,7 +16,7 @@ + "\nmySWFlowProblem.GN_swe_parameters['LUMPED_MASS_MATRIX'] = 1\n") rank_staging.write("__init__.py", "") -from proteus.mprans import GN_SW2DCV as SW2DCV +from proteus.kernels import GN_SW2DCV as SW2DCV if os.environ.get("NOSCAT"): SW2DCV.LevelModel.scatterDOFArray = lambda self, a: None if os.environ.get("OLDVOL"): diff --git a/test/griffiths_lane_6/re_gl_6_3d_p.py b/test/griffiths_lane_6/re_gl_6_3d_p.py index 2258eed30e..ca13aed7cd 100644 --- a/test/griffiths_lane_6/re_gl_6_3d_p.py +++ b/test/griffiths_lane_6/re_gl_6_3d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import os nd=3 diff --git a/test/griffiths_lane_6/sm_gl_6_3d_p.py b/test/griffiths_lane_6/sm_gl_6_3d_p.py index bc4d559603..e764e74582 100644 --- a/test/griffiths_lane_6/sm_gl_6_3d_p.py +++ b/test/griffiths_lane_6/sm_gl_6_3d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.elastoplastic import ElastoPlastic +from proteus.kernels import ElastoPlastic import os """ Soil mechanics model for problem 6.3 in Smith and Griffiths diff --git a/test/gwvd/2dbox/gwvd_2dbox_flow_c0p1_n.py b/test/gwvd/2dbox/gwvd_2dbox_flow_c0p1_n.py index eabd1b95b8..c3efa8d5f7 100644 --- a/test/gwvd/2dbox/gwvd_2dbox_flow_c0p1_n.py +++ b/test/gwvd/2dbox/gwvd_2dbox_flow_c0p1_n.py @@ -1,17 +1,17 @@ from proteus import * from proteus.default_n import * -from proteus.gwvd import GwvdCoefficients, Gwvd_consolidated_classes +from proteus import TransportCoefficients, StepControl, TimeIntegration, SplitOperator from gwvd_2dbox_cg import * from gwvd_2dbox_flow_p_cg import * # Time Integration and Stepcontrol if (transient): - timeIntegration =Gwvd_consolidated_classes.NonConservativeBackwardEuler + timeIntegration =TimeIntegration.NonConservativeBackwardEuler DT=DT else: timeIntegration=None -stepController = Gwvd_consolidated_classes.Fixed_dt_controller_systemit# Min_dt_cfl_controller +stepController = StepControl.Fixed_dt_controller_systemit# Min_dt_cfl_controller # FEM Spaces and Quadrature Rules diff --git a/test/gwvd/2dbox/gwvd_2dbox_flow_p_cg.py b/test/gwvd/2dbox/gwvd_2dbox_flow_p_cg.py index fd4fb46e7f..17e376d739 100644 --- a/test/gwvd/2dbox/gwvd_2dbox_flow_p_cg.py +++ b/test/gwvd/2dbox/gwvd_2dbox_flow_p_cg.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.gwvd import GwvdCoefficients +from proteus import TransportCoefficients, StepControl, TimeIntegration, SplitOperator from gwvd_2dbox_cg import * import numpy from math import * @@ -134,14 +134,14 @@ def rhoInt_eval(mf): analyticalSolutionVelocity = velocityAnalyticalSolution if consistentVelocityFlag == 1: - coefficients = GwvdCoefficients.VariableDensity_mod2_FlowEquationCoefficients( S=S, omega = omega, + coefficients = TransportCoefficients.VariableDensity_mod2_FlowEquationCoefficients( S=S, omega = omega, epsilon=epsilon, nc = ncflow, nd = nd, rho_fw=rho_fw, gc=gc, Kx=Kx, Ky =Ky, mu=nu, drho_dmf=drho_dmf, consistentVelocityFlag = consistentVelocityFlag, gravity = gravity,T_model=1) else: - coefficients = GwvdCoefficients.VariableDensity_mod2_FlowEquationCoefficients(S=S, omega=omega, + coefficients = TransportCoefficients.VariableDensity_mod2_FlowEquationCoefficients(S=S, omega=omega, epsilon=epsilon, nc=ncflow, nd= nd,rho_fw=rho_fw, gc=gc, Kx=Kx, Ky =Ky, mu=nu, drho_dmf=drho_dmf, T_model=1) diff --git a/test/gwvd/2dbox/gwvd_2dbox_so_cg.py b/test/gwvd/2dbox/gwvd_2dbox_so_cg.py index efefb07aaf..d045316c9d 100644 --- a/test/gwvd/2dbox/gwvd_2dbox_so_cg.py +++ b/test/gwvd/2dbox/gwvd_2dbox_so_cg.py @@ -1,5 +1,5 @@ from proteus.default_so import * -from proteus.gwvd import Gwvd_consolidated_classes +from proteus import TransportCoefficients, StepControl, TimeIntegration, SplitOperator from gwvd_2dbox_cg import * name = "gwvd_2dbox_cv%d_pp%d_rho%d" % (consistentVelocityFlag, vel_pp, int(rho_sw)) @@ -10,7 +10,7 @@ #systemStepControllerType = Sequential_MinFLCBDFModelStep #systemStepControllerType = Sequential_FixedStep -systemStepControllerType =Gwvd_consolidated_classes.ISO_fixed_MinModelStep # Sequential_MinAdaptiveModelStep +systemStepControllerType =SplitOperator.ISO_fixed_MinModelStep # Sequential_MinAdaptiveModelStep atol_iso=1e-8 needEBQ_GLOBAL = True diff --git a/test/gwvd/2dbox/gwvd_2dbox_trans_c0p1_n.py b/test/gwvd/2dbox/gwvd_2dbox_trans_c0p1_n.py index 05ae4a3435..75537fc9b8 100644 --- a/test/gwvd/2dbox/gwvd_2dbox_trans_c0p1_n.py +++ b/test/gwvd/2dbox/gwvd_2dbox_trans_c0p1_n.py @@ -1,12 +1,12 @@ from proteus import * from proteus.default_n import * -from proteus.gwvd import GwvdCoefficients, Gwvd_consolidated_classes +from proteus import TransportCoefficients, StepControl, TimeIntegration, SplitOperator from gwvd_2dbox_trans_p_cg import * from gwvd_2dbox_cg import * # Time Integration and Step control -timeIntegration =Gwvd_consolidated_classes.NonConservativeBackwardEuler#_cfl# TimeIntegration.BackwardEuler -stepController = Gwvd_consolidated_classes.Fixed_dt_controller_systemit# +timeIntegration =TimeIntegration.NonConservativeBackwardEuler#_cfl# TimeIntegration.BackwardEuler +stepController = StepControl.Fixed_dt_controller_systemit# stepController= Min_dt_cfl_controller DT =DT #runCFL =1.0# 0.1 diff --git a/test/gwvd/2dbox/gwvd_2dbox_trans_p_cg.py b/test/gwvd/2dbox/gwvd_2dbox_trans_p_cg.py index ab71651adf..1db4500694 100644 --- a/test/gwvd/2dbox/gwvd_2dbox_trans_p_cg.py +++ b/test/gwvd/2dbox/gwvd_2dbox_trans_p_cg.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.gwvd import GwvdCoefficients +from proteus import TransportCoefficients, StepControl, TimeIntegration, SplitOperator from gwvd_2dbox_cg import * import numpy from math import * @@ -14,7 +14,7 @@ -coefficients =GwvdCoefficients.VDGroundwater_mod2_TransportCoefficients(nctrans,nd=nd, +coefficients =TransportCoefficients.VDGroundwater_mod2_TransportCoefficients(nctrans,nd=nd, omega=omega, alpha_L=alpha_L, alpha_T=alpha_T, diff --git a/test/gwvd/test_gwvd_2dbox.py b/test/gwvd/test_gwvd_2dbox.py new file mode 100644 index 0000000000..c4f98edc2f --- /dev/null +++ b/test/gwvd/test_gwvd_2dbox.py @@ -0,0 +1,70 @@ +"""The 2-D box deck of the variable-density groundwater flow and transport port (gwvd), run serially for 10 days. + +The deck (``2dbox/gwvd_2dbox_so_cg.py``) pairs the flow and transport models of Povich et al. (2013) with the +iterated split-operator step (``SplitOperator.ISO_fixed_MinModelStep``), the fixed-dt controller +(``StepControl.Fixed_dt_controller_systemit``) and the non-conservative backward Euler +(``TimeIntegration.NonConservativeBackwardEuler``). Those classes and the two coefficient classes +(``TransportCoefficients.VariableDensity_mod2_FlowEquationCoefficients``, ``VDGroundwater_mod2_TransportCoefficients``) +lived in ``proteus/gwvd`` until C49 R1 moved them into the modules named here; the numbers pinned below are the ones +the run gave before the move (bit for bit: the L2 norms of the final head and mass fraction at 17 digits were equal). + +Two cases: the plain velocity (``GWVD_CV=0``) and the Knabner-Frolkovic consistent velocity (``GWVD_CV=1``), which +removes most of the mass-fraction overshoot above 1 (1.028 to 1.004). +""" +import os +import shutil +import subprocess +import sys + +import h5py +import numpy +import pytest + +HERE = os.path.dirname(os.path.abspath(__file__)) +DECK = os.path.join(HERE, "2dbox") + +# case -> (norm of h at 10 d, norm of mf at 10 d, max of mf at 10 d) +PINNED = { + 0: (1810.4542075205875, 31.96240250334426, 1.0283524657346117), + 1: (1814.1829661317959, 31.958028300869735, 1.0037795569844588), +} + + +def _parun(): + found = shutil.which("parun", path=os.path.dirname(sys.executable) + os.pathsep + os.environ.get("PATH", "")) + return [found] if found else [sys.executable, os.path.join(os.path.dirname(os.path.dirname(HERE)), "scripts", + "parun")] + + +def _run_deck(cv, tmp_path): + work = tmp_path / ("cv%d" % cv) + shutil.copytree(DECK, str(work)) + env = dict(os.environ, GWVD_T_DAYS="10", GWVD_CV=str(cv), OMP_NUM_THREADS="1") + ran = subprocess.run(_parun() + ["gwvd_2dbox_so_cg.py", "-l1"], cwd=str(work), capture_output=True, text=True, + timeout=600, env=env) + assert ran.returncode == 0, ran.stdout[-3000:] + ran.stderr[-3000:] + (archive,) = [f for f in os.listdir(str(work)) if f.endswith(".h5")] + with h5py.File(str(work / archive), "r") as f: + return f["h_t1"][:], f["mf_t1"][:] + + +@pytest.mark.parametrize("cv", [0, 1]) +def test_the_2dbox_deck_runs_and_gives_the_pinned_solution(cv, tmp_path): + h, mf = _run_deck(cv, tmp_path) + h_norm, mf_norm, mf_max = PINNED[cv] + assert numpy.isfinite(h).all() and numpy.isfinite(mf).all() + assert numpy.linalg.norm(h) == pytest.approx(h_norm, rel=1e-8) + assert numpy.linalg.norm(mf) == pytest.approx(mf_norm, rel=1e-8) + assert mf.max() == pytest.approx(mf_max, rel=1e-8) + + +def test_the_gwvd_classes_live_where_the_decks_import_them(): + from proteus import StepControl, SplitOperator, TimeIntegration, TransportCoefficients + assert issubclass(StepControl.Fixed_dt_controller_systemit, StepControl.Min_dt_controller) + assert issubclass(TimeIntegration.NonConservativeBackwardEuler, TimeIntegration.BackwardEuler) + assert issubclass(SplitOperator.ISO_fixed_MinModelStep, SplitOperator.ISO_fixed_MinAdaptiveModelStep) + assert issubclass(TransportCoefficients.VariableDensity_mod2_FlowEquationCoefficients, + TransportCoefficients.TC_base) + assert issubclass(TransportCoefficients.VDGroundwater_mod2_TransportCoefficients, TransportCoefficients.TC_base) + with pytest.raises(ImportError): + import proteus.gwvd # noqa: F401 (the directory is gone; gwvd was never installed, so no alias) diff --git a/test/hotstart_measure/rkev_gauss_p.py b/test/hotstart_measure/rkev_gauss_p.py index 985c2718be..82c23348e1 100644 --- a/test/hotstart_measure/rkev_gauss_p.py +++ b/test/hotstart_measure/rkev_gauss_p.py @@ -4,7 +4,7 @@ from proteus import * from proteus.default_p import * from math import * -from proteus.mprans import VOF, NCLS, VOS3P +from proteus.kernels import VOF, NCLS, VOS3P """ Linear advection of a guassian with periodic bcs """ diff --git a/test/kappa_partition_mpi.py b/test/kappa_partition_mpi.py index 2618164a66..e4ae8952e1 100644 --- a/test/kappa_partition_mpi.py +++ b/test/kappa_partition_mpi.py @@ -19,7 +19,7 @@ from proteus import (Domain, MeshTools, NumericalSolution, StepControl, TimeIntegration, default_s, defaults) from proteus.FemTools import C0_AffineLinearOnSimplexWithNodalBasis from proteus.iproteus import opts -from proteus.mprans import Kappa as NCLS +from proteus.kernels import Kappa as NCLS from proteus.NonlinearSolvers import Newton from proteus.LinearAlgebraTools import SparseMatrix from proteus.LinearSolvers import KSP_petsc4py diff --git a/test/levelset/rotation/ls_consrv_rotation_2d_p.py b/test/levelset/rotation/ls_consrv_rotation_2d_p.py index 3b2d477719..a8d11e8bda 100644 --- a/test/levelset/rotation/ls_consrv_rotation_2d_p.py +++ b/test/levelset/rotation/ls_consrv_rotation_2d_p.py @@ -5,7 +5,7 @@ except: from rotation2D import * name=soname+"_phicor" -from proteus.mprans import MCorr +from proteus.kernels import MCorr LevelModelType = MCorr.LevelModel diff --git a/test/levelset/rotation/ls_rotation_2d_p.py b/test/levelset/rotation/ls_rotation_2d_p.py index 45d6e5aadd..26d096ad0a 100644 --- a/test/levelset/rotation/ls_rotation_2d_p.py +++ b/test/levelset/rotation/ls_rotation_2d_p.py @@ -5,7 +5,7 @@ from .rotation2D import * except: from rotation2D import * -from proteus.mprans import NCLS +from proteus.kernels import NCLS #import Profiling LevelModelType = NCLS.LevelModel diff --git a/test/levelset/rotation/redist_rotation_2d_p.py b/test/levelset/rotation/redist_rotation_2d_p.py index 4c79ead2bf..cda69e9792 100644 --- a/test/levelset/rotation/redist_rotation_2d_p.py +++ b/test/levelset/rotation/redist_rotation_2d_p.py @@ -1,7 +1,7 @@ from proteus import * from proteus.default_p import * from math import * -from proteus.mprans import RDLS +from proteus.kernels import RDLS try: from .rotation2D import * from . import ls_rotation_2d_p diff --git a/test/levelset/rotation/vof_rotation_2d_p.py b/test/levelset/rotation/vof_rotation_2d_p.py index fd9707bc0f..400a0bb3f1 100644 --- a/test/levelset/rotation/vof_rotation_2d_p.py +++ b/test/levelset/rotation/vof_rotation_2d_p.py @@ -5,7 +5,7 @@ from .rotation2D import * except: from rotation2D import * -from proteus.mprans import VOF +from proteus.kernels import VOF name=soname+"_vof" """ diff --git a/test/levelset/vortex/ls_consrv_vortex_3d_p.py b/test/levelset/vortex/ls_consrv_vortex_3d_p.py index 9326bf35bf..ccd4d72d8e 100644 --- a/test/levelset/vortex/ls_consrv_vortex_3d_p.py +++ b/test/levelset/vortex/ls_consrv_vortex_3d_p.py @@ -2,7 +2,7 @@ from proteus.default_p import * from .vortex import * name=soname+"_phicor" -from proteus.mprans import MCorr +from proteus.kernels import MCorr LevelModelType = MCorr.LevelModel diff --git a/test/levelset/vortex/ls_vortex_3d_p.py b/test/levelset/vortex/ls_vortex_3d_p.py index a1e6d5286e..44023c3d0d 100644 --- a/test/levelset/vortex/ls_vortex_3d_p.py +++ b/test/levelset/vortex/ls_vortex_3d_p.py @@ -2,7 +2,7 @@ from proteus.default_p import * from math import * from .vortex import * -from proteus.mprans import NCLS +from proteus.kernels import NCLS #import Profiling LevelModelType = NCLS.LevelModel diff --git a/test/levelset/vortex/redist_vortex_3d_p.py b/test/levelset/vortex/redist_vortex_3d_p.py index 49778453bf..cdfdb7bc2a 100644 --- a/test/levelset/vortex/redist_vortex_3d_p.py +++ b/test/levelset/vortex/redist_vortex_3d_p.py @@ -2,7 +2,7 @@ from proteus.default_p import * from math import * from .vortex import * -from proteus.mprans import RDLS +from proteus.kernels import RDLS from . import ls_vortex_3d_p name=soname+"_rdls" diff --git a/test/levelset/vortex/vof_vortex_3d_p.py b/test/levelset/vortex/vof_vortex_3d_p.py index d200491911..1b418e5805 100644 --- a/test/levelset/vortex/vof_vortex_3d_p.py +++ b/test/levelset/vortex/vof_vortex_3d_p.py @@ -2,7 +2,7 @@ from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside from .vortex import * -from proteus.mprans import VOF +from proteus.kernels import VOF name=soname+"_vof" """ diff --git a/test/levelset/vortex2D/ls_consrv_vortex_2d_p.py b/test/levelset/vortex2D/ls_consrv_vortex_2d_p.py index 4e2424124f..d4f43173dd 100644 --- a/test/levelset/vortex2D/ls_consrv_vortex_2d_p.py +++ b/test/levelset/vortex2D/ls_consrv_vortex_2d_p.py @@ -5,7 +5,7 @@ except: from vortex2D import * name=soname+"_phicor" -from proteus.mprans import MCorr +from proteus.kernels import MCorr LevelModelType = MCorr.LevelModel diff --git a/test/levelset/vortex2D/ls_vortex_2d_p.py b/test/levelset/vortex2D/ls_vortex_2d_p.py index f72d52bf98..6cf676f258 100644 --- a/test/levelset/vortex2D/ls_vortex_2d_p.py +++ b/test/levelset/vortex2D/ls_vortex_2d_p.py @@ -7,7 +7,7 @@ except: from vortex2D import * -from proteus.mprans import NCLS +from proteus.kernels import NCLS #import Profiling LevelModelType = NCLS.LevelModel diff --git a/test/levelset/vortex2D/redist_vortex_2d_p.py b/test/levelset/vortex2D/redist_vortex_2d_p.py index 1ab90fc37a..9170014ca6 100644 --- a/test/levelset/vortex2D/redist_vortex_2d_p.py +++ b/test/levelset/vortex2D/redist_vortex_2d_p.py @@ -8,7 +8,7 @@ from vortex2D import * import ls_vortex_2d_p -from proteus.mprans import RDLS +from proteus.kernels import RDLS name = soname+"_rdls" LevelModelType = RDLS.LevelModel diff --git a/test/levelset/vortex2D/test_mcorr_bisection.py b/test/levelset/vortex2D/test_mcorr_bisection.py index c856400a9c..de8e43bb38 100644 --- a/test/levelset/vortex2D/test_mcorr_bisection.py +++ b/test/levelset/vortex2D/test_mcorr_bisection.py @@ -49,7 +49,7 @@ def _run_two_steps(opts): def test_the_bisection_shift_conserves_the_vof_mass(opts, tmp_path, monkeypatch, bisect_decks): - from proteus.mprans import MCorr + from proteus.kernels import MCorr monkeypatch.chdir(tmp_path) ns = _run_two_steps(opts) m = [m for m in ns.modelList if type(m.levelModelList[-1]).__module__.endswith("MCorr")][0] diff --git a/test/levelset/vortex2D/vof_vortex_2d_p.py b/test/levelset/vortex2D/vof_vortex_2d_p.py index 672e4c3859..8293d069c6 100644 --- a/test/levelset/vortex2D/vof_vortex_2d_p.py +++ b/test/levelset/vortex2D/vof_vortex_2d_p.py @@ -5,7 +5,7 @@ from .vortex2D import * except: from vortex2D import * -from proteus.mprans import VOF +from proteus.kernels import VOF name=soname+"_vof" """ diff --git a/test/m_comp_co2/m_comp_co2_p.py b/test/m_comp_co2/m_comp_co2_p.py index 8a72ead5e5..f2850ca38e 100644 --- a/test/m_comp_co2/m_comp_co2_p.py +++ b/test/m_comp_co2/m_comp_co2_p.py @@ -21,7 +21,7 @@ open_top STAB 0, hydrostatic brine with a pressure-Dirichlet top open_top_stab2 STAB 2, the same through the EV boundary path -Per-rock nodal closure (proteus/m_comp_co2/Z_ACROSS_ROCK_INTERFACES.md): +Per-rock nodal closure (proteus/kernels/Z_ACROSS_ROCK_INTERFACES.md): rock_column 0.02 m x 0.2 m strip, C sand / ESF / C sand, closed, free gas starting 0.02 m below the ESF. The pooled gas column @@ -34,7 +34,7 @@ """ from proteus import Context, Domain from proteus.default_p import * -from proteus.m_comp_co2 import m_comp_co2 +from proteus.kernels import m_comp_co2 import numpy as np diff --git a/test/m_comp_co2/test_m_comp_co2.py b/test/m_comp_co2/test_m_comp_co2.py index 0b78794fe5..11f6ba2431 100644 --- a/test/m_comp_co2/test_m_comp_co2.py +++ b/test/m_comp_co2/test_m_comp_co2.py @@ -46,7 +46,7 @@ from proteus import Context, defaults from proteus.iproteus import NumericalSolution, default_s, opts -from proteus.m_comp_co2 import m_comp_co2 +from proteus.kernels import m_comp_co2 HERE = Path(__file__).resolve().parent diff --git a/test/mcorr_partition_mpi.py b/test/mcorr_partition_mpi.py index f57a420d19..f67c0a42ef 100644 --- a/test/mcorr_partition_mpi.py +++ b/test/mcorr_partition_mpi.py @@ -45,7 +45,7 @@ def partitionMesh(self, nLayersOfOverlap=1, parallelPartitioningType=MT.MeshPara thelper_cons_ls.ct.refinement = 1 from mcpkg import (thelper_cons_ls_so, thelper_ncls_p, thelper_ncls_n, thelper_vof_p, thelper_vof_n, thelper_MCorr_p, thelper_MCorr_n) -from proteus.mprans import MCorr +from proteus.kernels import MCorr if os.environ.get("NOFIX"): MCorr.LevelModel.scatterDOFArray = lambda self, a: None diff --git a/test/mesh_tests/minus_f_stored_mesh_mpi.py b/test/mesh_tests/minus_f_stored_mesh_mpi.py new file mode 100644 index 0000000000..3c1a417f1c --- /dev/null +++ b/test/mesh_tests/minus_f_stored_mesh_mpi.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +"""Helper run under mpiexec by test_minus_f_stored_mesh.py; not collected. + +Meshes a stored tetgen PLC mesh through ``MeshTools.generateMesh`` as a deck does that reads the mesh it +finds (genMesh False), with ``parun -F`` (``generatePartitionedMeshFromFiles``) or without it, and +prints one ``RESULT`` line per rank. + +Usage: minus_f_stored_mesh_mpi.py PREFIX OPTIONS F|memory + +PREFIX the stored mesh: PREFIX.poly (the domain), PREFIX.{node,ele,face,edge}, in the working directory +OPTIONS ``none``: triangleOptions stays unset (what a deck that sets it only under ``if genMesh:`` leaves); + otherwise the string to set as triangleOptions, whatever it says about how the files were made +F parun -F: the partitioner reads the files itself +memory no -F: rank 0 reads the whole mesh and it is partitioned in memory (the reference) + +The RESULT line says whether the branch under test ran: ``req`` counts calls of +``_requireTetgenFilesToPartition`` and ``files`` of ``cpartitioning.partitionNodesFromTetgenFiles``. +Nothing is written here: every rank runs this module, and the files were staged by the test. +""" +import sys +import types + +from proteus import Comm +comm = Comm.init() +from proteus import Domain, MeshTools, cpartitioning + +prefix, options, mode = sys.argv[1:4] + +calls = {"req": 0, "files": 0} + + +def count(owner, name, key): + original = getattr(owner, name) + + def counted(*args, **kwargs): + calls[key] += 1 + return original(*args, **kwargs) + setattr(owner, name, counted) + + +count(MeshTools, "_requireTetgenFilesToPartition", "req") +count(cpartitioning, "partitionNodesFromTetgenFiles", "files") + +domain = Domain.PiecewiseLinearComplexDomain(fileprefix=prefix) +meshOptions = MeshTools.getMeshOptions(domain) +meshOptions.genMesh = False +if options != "none": + meshOptions.triangleOptions = options +physics = types.SimpleNamespace(domain=domain, genMesh=False) +numerics = types.SimpleNamespace() +try: + mlMesh = MeshTools.generateMesh(physics, numerics, mode == "F") +except SystemExit as exit: + print("RESULT rank=%d exit=%s" % (comm.rank(), exit.code), flush=True) + raise +mesh = mlMesh.meshList[0] +nodes, elements = mesh.nodeOffsets_subdomain_owned, mesh.elementOffsets_subdomain_owned +rank = comm.rank() +print("RESULT rank=%d ownedNodes=%d ownedElements=%d globalNodes=%d globalElements=%d req=%d files=%d" % ( + rank, nodes[rank + 1] - nodes[rank], elements[rank + 1] - elements[rank], nodes[-1], elements[-1], + calls["req"], calls["files"]), flush=True) diff --git a/test/mesh_tests/restart_views_tet.py b/test/mesh_tests/restart_views_tet.py index c6c1b2f0fe..af7a5c4500 100644 --- a/test/mesh_tests/restart_views_tet.py +++ b/test/mesh_tests/restart_views_tet.py @@ -38,7 +38,7 @@ from proteus.FemTools import C0_AffineLinearOnSimplexWithNodalBasis # noqa: E402 from proteus.LinearAlgebraTools import SparseMatrix # noqa: E402 from proteus.LinearSolvers import KSP_petsc4py # noqa: E402 -from proteus.mprans import VOF # noqa: E402 +from proteus.kernels import VOF # noqa: E402 from proteus.NonlinearSolvers import Newton # noqa: E402 from proteus.Quadrature import SimplexGaussQuadrature # noqa: E402 diff --git a/test/mesh_tests/test_minus_f_stored_mesh.py b/test/mesh_tests/test_minus_f_stored_mesh.py new file mode 100644 index 0000000000..3483229fbd --- /dev/null +++ b/test/mesh_tests/test_minus_f_stored_mesh.py @@ -0,0 +1,131 @@ +"""``parun -F`` on a stored tetgen mesh tests the files, not ``triangleOptions`` (C7.1). + +``_generateMesh`` (the PiecewiseLinearComplexDomain branch) asked ``meshOptions.triangleOptions`` +whether the mesh had been made with the ``f`` and ``ee`` flags. A deck that reads the mesh it finds +(genMesh False) sets that string only where it generates, so the check raised ``TypeError`` (unset) or +exited with "Remake the mesh with the f flag" (a string without ``f``) on a mesh whose files were fine, +and passed a string that said ``feen`` over a mesh whose ``.edge`` file was gone (then a cython error). +Now the files decide: a missing ``.edge`` (the one file ``_generateMesh`` does not regenerate a mesh for; +a missing ``.node``, ``.ele`` or ``.face`` makes rank 0 run tetgen with the deck's options, as without -F) +exits on every rank and names the file; ``triangleOptions`` do not matter. + +minus_f_stored_mesh_mpi.py meshes the stored mesh of test/ci/meshPartition (131 nodes, 441 tetrahedra, +made by ``tetgen -Vfeen``) on every rank, with -F and in memory. The driver starts its own ranks, so +these tests skip under a multi-rank launch. +""" +import os +import shutil +import subprocess +import sys + +import pytest + +HERE = os.path.dirname(os.path.abspath(__file__)) +STORED = os.path.join(HERE, "..", "ci", "meshPartition") +EXTENSIONS = ("poly", "node", "ele", "face", "edge") +NODES, ELEMENTS = 131, 441 + + +def _launcher_env(): + env = dict((k, v) for k, v in os.environ.items() if not k.startswith(("PMI_", "PMIX_", "HYDRA_", "OMPI_COMM_WORLD"))) + env["PYTHONPATH"] = os.pathsep.join([p for p in sys.path if p] + [env.get("PYTHONPATH", "")]).strip(os.pathsep) + env.setdefault("OMPI_MCA_rmaps_base_oversubscribe", "1") + env.setdefault("PRTE_MCA_rmaps_default_mapping_policy", ":oversubscribe") + env.setdefault("FI_PROVIDER", "tcp") + env["OMP_NUM_THREADS"] = "1" + # the contiguous default partition, which makes -F and the in-memory partition comparable + env["PETSC_OPTIONS"] = "-mat_partitioning_type current" + return env + + +def _mpiexec(): + for name in ("PMI_SIZE", "OMPI_COMM_WORLD_SIZE", "PMIX_SIZE"): + if int(os.environ.get(name, "1")) > 1: + pytest.skip("launches its own mpiexec; run this file serially") + beside = os.path.join(os.path.dirname(sys.executable), "mpiexec") + found = beside if os.path.exists(beside) else shutil.which("mpiexec") + if found is None: + pytest.skip("no MPI launcher available") + return found + + +def _stage(tmp_path, name, drop=()): + """The stored mesh as ``.*`` in its own directory, without the extensions in ``drop``.""" + cwd = tmp_path / name + cwd.mkdir() + for ext in EXTENSIONS: + if ext not in drop: + shutil.copy(os.path.join(STORED, "plc." + ext), str(cwd / ("plc." + ext))) + return cwd + + +def _run(cwd, ranks, options, mode): + result = subprocess.run([_mpiexec(), "-n", str(ranks), sys.executable, + os.path.join(HERE, "minus_f_stored_mesh_mpi.py"), "plc", options, mode], + capture_output=True, text=True, env=_launcher_env(), cwd=str(cwd), timeout=600) + lines = [l for l in result.stdout.splitlines() if l.startswith("RESULT")] + return result, lines + + +def _fields(line): + return dict(kv.split("=") for kv in line.split()[1:]) + + +def _sum(lines, key): + return sum(int(_fields(l)[key]) for l in lines) + + +@pytest.mark.parametrize("ranks", [1, 2]) +@pytest.mark.parametrize("options", ["none", "pq1.2", "feen"]) +def test_f_partitions_the_stored_files_whatever_triangle_options_say(tmp_path, ranks, options): + """Unset, a string without ``f`` and ``ee``, and one with them: the same partition as the in-memory one.""" + cwd = _stage(tmp_path, "mesh") + result, lines = _run(cwd, ranks, options, "F") + assert result.returncode == 0, result.stdout[-3000:] + result.stderr[-3000:] + assert len(lines) == ranks + # the branch under test ran: the file check, then the partitioner that reads the files + assert all(_fields(l)["req"] == "1" and _fields(l)["files"] == "1" for l in lines), lines + assert _sum(lines, "ownedNodes") == NODES and _sum(lines, "ownedElements") == ELEMENTS + assert all(int(_fields(l)["globalNodes"]) == NODES and int(_fields(l)["globalElements"]) == ELEMENTS for l in lines) + # against the mesh read whole and partitioned in memory, rank by rank: the same nodes per rank (the + # two paths own elements by different rules, so only their total is compared, above) + reference, ref_lines = _run(_stage(tmp_path, "reference"), ranks, options, "memory") + assert reference.returncode == 0, reference.stdout[-3000:] + reference.stderr[-3000:] + assert all(_fields(l)["req"] == "0" and _fields(l)["files"] == "0" for l in ref_lines), ref_lines + key = lambda l: int(_fields(l)["rank"]) + for line, ref in zip(sorted(lines, key=key), sorted(ref_lines, key=key)): + for field in ("ownedNodes", "globalNodes", "globalElements"): + assert _fields(line)[field] == _fields(ref)[field], (line, ref) + + +@pytest.mark.parametrize("ranks", [1, 2]) +@pytest.mark.parametrize("options", ["feen", "none"]) +def test_a_missing_edge_file_exits_on_every_rank_and_is_named(tmp_path, ranks, options): + """Even when triangleOptions claim ``feen``: the files are what is tested (it was a cython error).""" + cwd = _stage(tmp_path, "mesh", drop=("edge",)) + result, lines = _run(cwd, ranks, options, "F") + assert result.returncode != 0 + assert len(lines) == ranks and all("exit=" in l for l in lines), lines + assert all("missing plc.edge" in l for l in lines), lines + assert "tetgen -Vfeen plc.poly" in lines[0] + + +def test_an_edge_file_without_markers_is_read_with_flag_zero(tmp_path): + """The reader takes the ``.edge`` markers when its header announces them and flags 0 otherwise, so the + content past the header does not matter to it: only the file's presence is required.""" + cwd = _stage(tmp_path, "mesh") + edge = cwd / "plc.edge" + rows = edge.read_text().splitlines() + edge.write_text("\n".join(["%s 0" % rows[0].split()[0]] + [" ".join(r.split()[:3]) for r in rows[1:]]) + "\n") + result, lines = _run(cwd, 2, "none", "F") + assert result.returncode == 0, result.stdout[-3000:] + result.stderr[-3000:] + assert _sum(lines, "ownedNodes") == NODES and _sum(lines, "ownedElements") == ELEMENTS + + +def test_the_file_problems_are_listed_in_one_message(tmp_path): + from proteus import MeshTools + cwd = _stage(tmp_path, "mesh", drop=("face", "edge")) + prefix = str(cwd / "plc") + assert MeshTools._tetgenFileProblems(prefix) == ["missing %s.face" % prefix, "missing %s.edge" % prefix] + assert MeshTools._tetgenFileProblems(str(tmp_path / "mesh" / "other")) == [ + "missing %s/mesh/other.%s" % (tmp_path, ext) for ext in ("node", "ele", "face", "edge")] diff --git a/test/ncls_edge_partition_mpi.py b/test/ncls_edge_partition_mpi.py index 655edd8e8a..c97960bf8d 100644 --- a/test/ncls_edge_partition_mpi.py +++ b/test/ncls_edge_partition_mpi.py @@ -36,7 +36,7 @@ def partitionMesh(self, nLayersOfOverlap=1, parallelPartitioningType=MT.MeshPara nodeOwners=nodeOwners, elementOwners=elementOwners, nodeWeights=nodeWeights) MT.Mesh.partitionMesh = partitionMesh -from proteus.mprans import NCLS +from proteus.kernels import NCLS if os.environ.get("NOPSISCAT"): # control: the redistancing residual reads ghost psi from truncated rows again _scatter = NCLS.LevelModel.scatterDOFArray diff --git a/test/ncls_partition_mpi.py b/test/ncls_partition_mpi.py index 3faaea3344..7055f89206 100644 --- a/test/ncls_partition_mpi.py +++ b/test/ncls_partition_mpi.py @@ -21,7 +21,7 @@ from proteus import (Domain, MeshTools, NumericalSolution, StepControl, TimeIntegration, default_s, defaults) from proteus.FemTools import C0_AffineLinearOnSimplexWithNodalBasis from proteus.iproteus import opts -from proteus.mprans import NCLS +from proteus.kernels import NCLS from proteus.NonlinearSolvers import Newton from proteus.LinearAlgebraTools import SparseMatrix from proteus.LinearSolvers import KSP_petsc4py diff --git a/test/perf/model_baseline_mpi.py b/test/perf/model_baseline_mpi.py index 4146699c69..e1dc35c06f 100644 --- a/test/perf/model_baseline_mpi.py +++ b/test/perf/model_baseline_mpi.py @@ -62,7 +62,7 @@ from proteus import (cfemIntegrals, cnumericalFlux, csubgridError, cshockCapturing, # noqa: E402 csparsity, csmoothers, ctimeIntegration, cpostprocessing, cmeshTools, cpartitioning, LinearSolvers, NonlinearSolvers, Transport) -from proteus.mprans import cArgumentsDict # noqa: E402 +from proteus import cArgumentsDict # noqa: E402 rank, size = comm.rank(), comm.size() mpi = comm.comm.tompi4py() @@ -95,7 +95,7 @@ def instrument_classes(): for modname in ('RANS2P', 'RANS3PF', 'CLSVOF', 'VOF', 'NCLS', 'RDLS', 'MCorr', 'PresInc', 'Pres', 'PresInit'): try: - cls = importlib.import_module('proteus.mprans.' + modname).LevelModel + cls = importlib.import_module('proteus.kernels.' + modname).LevelModel except (ImportError, AttributeError): continue if cls in seen: @@ -119,14 +119,14 @@ def instrument_kernels(ns): for lm in model.levelModelList: for attr, value in list(vars(lm).items()): module = type(value).__module__ or '' - if module.startswith('proteus.mprans.c') or module.startswith('proteus.c'): + if module.startswith('proteus.kernels.c') or module.startswith('proteus.c'): setattr(lm, attr, acc.KernelProxy(value, '%s.%s' % (lm.name, attr))) continue #a kernel method bound at setup (VOF: self.calculateResidual = self.vof.calculate...) owner = getattr(value, '__self__', None) owner_module = type(owner).__module__ or '' if owner is not None else '' if (attr.startswith('calculate') and callable(value) - and (owner_module.startswith('proteus.mprans.c') or owner_module.startswith('proteus.c'))): + and (owner_module.startswith('proteus.kernels.c') or owner_module.startswith('proteus.c'))): setattr(lm, attr, acc.wrap_pass(value, '%s.%s' % (lm.name, attr))) diff --git a/test/periodic/dissipation_n.py b/test/periodic/dissipation_n.py index 6c112858df..404f3e64b6 100644 --- a/test/periodic/dissipation_n.py +++ b/test/periodic/dissipation_n.py @@ -5,7 +5,7 @@ NonlinearSolvers, LinearSolvers, LinearAlgebraTools) -from proteus.mprans import Dissipation +from proteus.kernels import Dissipation from proteus import Context ct = Context.get() nd = ct.domain.nd diff --git a/test/periodic/dissipation_p.py b/test/periodic/dissipation_p.py index 7360ef8d19..1f22900b5e 100644 --- a/test/periodic/dissipation_p.py +++ b/test/periodic/dissipation_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.mprans import Dissipation +from proteus.kernels import Dissipation from proteus import Context ct = Context.get() domain = ct.domain diff --git a/test/periodic/duct.py b/test/periodic/duct.py index 6ed13dcb25..fc9145765f 100644 --- a/test/periodic/duct.py +++ b/test/periodic/duct.py @@ -14,7 +14,7 @@ Context, AnalyticalSolutions) from proteus.default_so import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P import os opts = Context.Options([ diff --git a/test/periodic/ductib.py b/test/periodic/ductib.py index ec477fdb01..f1b2d303b6 100644 --- a/test/periodic/ductib.py +++ b/test/periodic/ductib.py @@ -14,7 +14,7 @@ Context, AnalyticalSolutions) from proteus.default_so import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P opts = Context.Options([ ("nd", 2, "Number of space dimensions"), diff --git a/test/periodic/la_periodicGauss_p.py b/test/periodic/la_periodicGauss_p.py index 270eca1f56..7616a6743c 100644 --- a/test/periodic/la_periodicGauss_p.py +++ b/test/periodic/la_periodicGauss_p.py @@ -2,7 +2,7 @@ from proteus import * from proteus.default_p import * from math import * -from proteus.mprans import VOF, NCLS, VOS3P +from proteus.kernels import VOF, NCLS, VOS3P """ Linear advection of a guassian with periodic bcs """ diff --git a/test/periodic/ls_consrv_p.py b/test/periodic/ls_consrv_p.py index be30551d7d..6b70303163 100644 --- a/test/periodic/ls_consrv_p.py +++ b/test/periodic/ls_consrv_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import MCorr +from proteus.kernels import MCorr from proteus import Context ct = Context.get() diff --git a/test/periodic/ls_n.py b/test/periodic/ls_n.py index 9945bd9e61..832ff44110 100644 --- a/test/periodic/ls_n.py +++ b/test/periodic/ls_n.py @@ -5,7 +5,7 @@ NonlinearSolvers, LinearSolvers, LinearAlgebraTools) -from proteus.mprans import NCLS +from proteus.kernels import NCLS from proteus import Context ct = Context.get() diff --git a/test/periodic/ls_p.py b/test/periodic/ls_p.py index 02c4d80ea4..eab8aed181 100644 --- a/test/periodic/ls_p.py +++ b/test/periodic/ls_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import NCLS +from proteus.kernels import NCLS from proteus import Context ct = Context.get() diff --git a/test/periodic/periodic_solitary_waves.py b/test/periodic/periodic_solitary_waves.py index 0c586a5fe3..e8e44a4ba1 100644 --- a/test/periodic/periodic_solitary_waves.py +++ b/test/periodic/periodic_solitary_waves.py @@ -2,7 +2,7 @@ Non linear waves """ from proteus import Domain, Context -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st from proteus import WaveTools as wt import math import numpy as np diff --git a/test/periodic/redist_n.py b/test/periodic/redist_n.py index 289eb98c11..f23bc37bc1 100644 --- a/test/periodic/redist_n.py +++ b/test/periodic/redist_n.py @@ -5,7 +5,7 @@ LinearSolvers, LinearAlgebraTools, NumericalFlux) -from proteus.mprans import RDLS +from proteus.kernels import RDLS import redist_p as physics from proteus import Context diff --git a/test/periodic/redist_p.py b/test/periodic/redist_p.py index 01648b7a84..04865883a3 100644 --- a/test/periodic/redist_p.py +++ b/test/periodic/redist_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import RDLS +from proteus.kernels import RDLS from proteus import Context ct = Context.get() diff --git a/test/periodic/twp_navier_stokes_p.py b/test/periodic/twp_navier_stokes_p.py index 186e8b01a8..d566fad00c 100644 --- a/test/periodic/twp_navier_stokes_p.py +++ b/test/periodic/twp_navier_stokes_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P import numpy as np from proteus import Context from proteus.ctransportCoefficients import smoothedHeaviside diff --git a/test/periodic/vof_n.py b/test/periodic/vof_n.py index 92dc064493..54f2189906 100644 --- a/test/periodic/vof_n.py +++ b/test/periodic/vof_n.py @@ -5,7 +5,7 @@ LinearSolvers, LinearAlgebraTools) import vof_p as physics -from proteus.mprans import VOF +from proteus.kernels import VOF from proteus import Context ct = Context.get() diff --git a/test/periodic/vof_p.py b/test/periodic/vof_p.py index b1147bd654..2b345200a1 100644 --- a/test/periodic/vof_p.py +++ b/test/periodic/vof_p.py @@ -1,6 +1,6 @@ from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside -from proteus.mprans import VOF +from proteus.kernels import VOF from proteus import Context ct = Context.get() diff --git a/test/porosity/sloshing.py b/test/porosity/sloshing.py index db883341ae..8d480e673d 100644 --- a/test/porosity/sloshing.py +++ b/test/porosity/sloshing.py @@ -4,9 +4,9 @@ FemTools as ft, MeshTools as mt, WaveTools as wt) -from proteus.mprans import SpatialTools as st +from proteus import SpatialTools as st from proteus.Profiling import logEvent -from proteus.mprans.SpatialTools import Tank2D, CustomShape +from proteus.SpatialTools import Tank2D, CustomShape import proteus.TwoPhaseFlow.TwoPhaseFlowProblem as TpFlow diff --git a/test/rans2p_ib/beam_channel_p.py b/test/rans2p_ib/beam_channel_p.py index afcedec991..4eeace0de4 100644 --- a/test/rans2p_ib/beam_channel_p.py +++ b/test/rans2p_ib/beam_channel_p.py @@ -9,7 +9,7 @@ from proteus import * from proteus.default_p import * from proteus import Context -from proteus.mprans import RANS2P_IB +from proteus.kernels import RANS2P_IB opts = Context.Options([("beamRigid", True, "a rigid beam, or a flexible one (EI = GJ = 1e-4)")]) diff --git a/test/rans2p_ib/dye_n.py b/test/rans2p_ib/dye_n.py index 5bbbf499ac..478d6dd59e 100644 --- a/test/rans2p_ib/dye_n.py +++ b/test/rans2p_ib/dye_n.py @@ -1,5 +1,5 @@ from proteus.default_n import * -from proteus.mprans import VOF +from proteus.kernels import VOF import dye_p as physics from beam_channel_n import nnx, nny, nnz, nLevels, DT, nDTout, femSpaces as _flow_spaces diff --git a/test/rans2p_ib/dye_p.py b/test/rans2p_ib/dye_p.py index 3f24f902c5..ef4929978b 100644 --- a/test/rans2p_ib/dye_p.py +++ b/test/rans2p_ib/dye_p.py @@ -1,7 +1,7 @@ """A dye in the beam channel (VOF with no level set, carried by RANS2P_IB's velocity): dye 1 enters at x = 0 over the lower half of the inflow, the channel starts clean.""" from proteus.default_p import * -from proteus.mprans import VOF +from proteus.kernels import VOF from beam_channel_p import nd, L, T, eps, _inflow, _outflow name = "dye" diff --git a/test/rans2p_ib/test_rans2p_ib.py b/test/rans2p_ib/test_rans2p_ib.py index 53f566b448..c24da01326 100644 --- a/test/rans2p_ib/test_rans2p_ib.py +++ b/test/rans2p_ib/test_rans2p_ib.py @@ -12,7 +12,7 @@ import pytest -from proteus.mprans import RANS2P_IB +from proteus.kernels import RANS2P_IB HERE = os.path.dirname(os.path.abspath(__file__)) HELPER = os.path.join(HERE, "beam_channel_mpi.py") diff --git a/test/richards/WRR_draft/2d_bioswale/bio2d_convergence_p.py b/test/richards/WRR_draft/2d_bioswale/bio2d_convergence_p.py index 75a1c34442..1dcaac6de6 100755 --- a/test/richards/WRR_draft/2d_bioswale/bio2d_convergence_p.py +++ b/test/richards/WRR_draft/2d_bioswale/bio2d_convergence_p.py @@ -1,319 +1,319 @@ -from proteus import * -from proteus.default_p import * -from proteus.richards import Richards - -nd = 2 - -L=[3.0,5.0,1.0] - - -regularGrid=False - -domain = Domain.PlanarStraightLineGraphDomain() -boundaries=['bottom','top','left','right', - 'swale', - 'drain'] - -boundaryTags=dict([(key,i+1) for (i,key) in enumerate(boundaries)]) - -vertices=[[0.0,0.0], #0 - [0.0,3.0], #1 - [3.0,3.0 ], #2 - [3.0, 0.0], #3 - [3.0,5.0], # 4 - [0.0 ,5.0], #5 - [0.5, 3.0], #6 - [2.5, 3.0], #7 - [2.0, 1.0],#8 - [1.0, 1.0],#9 - [1.2, 1.9],#10 - [1.7, 1.9],#11 - [1.7, 1.4], #12 - [1.2, 1.4],#13 - ] - -vertexFlags=[boundaryTags['bottom'], #0 - boundaryTags['left'], #1 - boundaryTags['right'], #2 - boundaryTags['bottom'], #3 - boundaryTags['top'], #4 - boundaryTags['left'], #5 - boundaryTags['swale'], #6 - boundaryTags['swale'], #7 - boundaryTags['swale'], #8 - boundaryTags['swale'], #9 - boundaryTags['drain'], #10 - boundaryTags['drain'], #11 - boundaryTags['drain'], #12 - boundaryTags['drain'], #13 - ] - - -segments =[[0,1], #0 - [1,2], #1 - [2,3], #2 - [3,0], #3 - [2,4], #4 - [4,5], #5 - [5,1], #6 - [6,7], #7 - [7,8], #8 - [8,9], #9 - [9,6], #10 - [10,11], #11 - [11,12], #12 - [12,13], #13 - [13,10]] #14 - - -segmentFlags=[boundaryTags['left'], #0 - boundaryTags['swale'], #1 - boundaryTags['right'], #2 - boundaryTags['bottom'], #3 - boundaryTags['right'], #4 - boundaryTags['top'], #5 - boundaryTags['left'], #6 - - boundaryTags['swale'], #7 - boundaryTags['swale'], #8 - boundaryTags['swale'], #9 - boundaryTags['swale'], #10 - - - boundaryTags['drain'], #11 - boundaryTags['drain'], #12 - boundaryTags['drain'], #13 - boundaryTags['drain'], #14 - ] - -holes= [[1.5,1.5]] -#regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5], [1.5,0.5]] -#regionFlags=[1,2,3,4] -regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5]]#, [1.5,0.5]] -regionFlags=[1,2,3] - -domain = Domain.PlanarStraightLineGraphDomain(vertices= vertices, - vertexFlags=vertexFlags, - segments=segments, - segmentFlags=segmentFlags, - regions = regions, - regionFlags = regionFlags, - holes= holes) - - -#dplt.plot_pslg_domain(polygon) - -domain.writePoly('bio2d_N') - -#if not regularGrid: -# domain.writePoly('bio2d_N') -# domain = Domain.PlanarStraightLineGraphDomain('bio2d_N') - -#domain.polyfile="bio2d_n_coarse" - -analyticalSolution = None - -viscosity = 8.9e-4 #kg/(m*s) -density = 998.2 #kg/m^3 -gravity = 9.8 #m/s^2 -beta = 0.0 #density*gravity*4.524e-10 -m_per_s_by_m_per_d = 1.1574074e-5 -lengthScale = 1.0 #m -timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) -#make non-dimensional - -# Storage Zone -permeability3 = (5.0)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS3 = 0.4 #- -thetaR3 = 0.05 #- -mvg_alpha3 = 8 #1/m -mvg_n3 = 2.4 -mvg_m3 = 1.0 - 1.0/mvg_n3 -dimensionless_conductivity3 = (timeScale*density*gravity*permeability3/(viscosity*lengthScale)) - -#Bioswale Zone -permeability2 = (7.128)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS2 = 0.43 #- -thetaR2 = 0.045 #- -mvg_alpha2 = 14.5 #1/m -mvg_n2 = 2.68 -mvg_m2 = 1.0 - 1.0/mvg_n2 -dimensionless_conductivity2 = (timeScale*density*gravity*permeability2/(viscosity*lengthScale)) - -#base -permeability1 = (1.06)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS1 = 0.41 #- -thetaR1 = 0.065 #- -mvg_alpha1 = 7.5 #1/m -mvg_n1 = 1.89 -mvg_m1 = 1.0 - 1.0/mvg_n1 -dimensionless_conductivity1 = (timeScale*density*gravity*permeability1/(viscosity*lengthScale)) -#pipe -#permeability4 = (8.03*m_per_s_by_m_per_d)*viscosity/(gravity*density) #m^2 -#thetaS4 = 0.43 #- -#thetaR4 = 0.045 #- -#mvg_alpha4 = 20 #1/m -#mvg_n4 = 3 -#mvg_m4 = 1.0 - 1.0/mvg_n4 -#dimensionless_conductivity4 = (timeScale*density*gravity*permeability4/(viscosity*lengthScale)) - - - -#print 'Ks',dimensionless_conductivity -dimensionless_density = 1.0 -dimensionless_gravity = numpy.array([0.0, - -1.0, - 0.0]) -#dimensionless_alpha = mvg_alpha*lengthScale -nMediaTypes = 3 -alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') -nVGtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaStypes = numpy.zeros((nMediaTypes+1,),'d') -thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') -KsTypes = numpy.zeros((nMediaTypes+1,2),'d') - -for i in range(nMediaTypes+1): - if i==1: - alphaVGtypes[i] = mvg_alpha1 - nVGtypes[i] = mvg_n1 - thetaStypes[i] = thetaS1 - thetaRtypes[i] = thetaR1 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? - elif i==2: - alphaVGtypes[i] = mvg_alpha2 - nVGtypes[i] = mvg_n2 - thetaStypes[i] = thetaS2 - thetaRtypes[i] = thetaR2 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity2,dimensionless_conductivity2]#m/d? - - elif i==3: - alphaVGtypes[i] = mvg_alpha3 - nVGtypes[i] = mvg_n3 - thetaStypes[i] = thetaS3 - thetaRtypes[i] = thetaR3 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity3,dimensionless_conductivity3]#m/d? - #else: - # alphaVGtypes[i] = mvg_alpha4 - # nVGtypes[i] = mvg_n4 - # thetaStypes[i] = thetaS4 - # thetaRtypes[i] = thetaR4 - # thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - # KsTypes[i,:] = [dimensionless_conductivity4,dimensionless_conductivity4]#m/d? - -galerkin = False -useSeepageFace = True - -def getSeepageFace(flag): - if useSeepageFace: - if flag == boundaryTags['drain']: - return 1 - else: - return 0 - else: - return 0 - - - - -LevelModelType = Richards.LevelModel -coefficients = Richards.Coefficients(nd, - KsTypes, - nVGtypes, - alphaVGtypes, - thetaRtypes, - thetaSRtypes, - gravity=dimensionless_gravity, - density=dimensionless_density, - beta=0.0001, - diagonal_conductivity=True, - STABILIZATION_TYPE=2, - ENTROPY_TYPE=1, - LUMPED_MASS_MATRIX= False , - FCT=True, #False ,#True, - num_fct_iter=0, - # FOR ENTROPY VISCOSITY - cE=1.0, - uL=0.0, - uR=1.0, - # FOR ARTIFICIAL COMPRESSION - cK=1.0, - # OUTPUT quantDOFs - outputQuantDOFs=False, - getSeepageFace=getSeepageFace) -#galerkin = False - -#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, -# gravity=dimensionless_gravity, -# density=dimensionless_density, -# thetaS=thetaS, -# thetaR=thetaR, -# alpha= dimensionless_alpha, -# n = mvg_n, -# m = mvg_m, -# beta = beta) - - -#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, -# gravity=dimensionless_gravity, -# density=dimensionless_density, -# thetaS=thetaStypes, -# thetaR=thetaRtypes, -# alpha= alphaVGtypes, -# n = mvg_n, -# m = mvg_m, -# beta = beta)# - -#G= [1.8, 1.2,1] - -galerkin = False - -G=[3.0,5.0,1.0] - -pondingPressure= 0.5 - - -def getDBC_2D_Richards_Shock(x,flag): - if x[1] == G[1]: - if (x[0] >= G[0]/3.0 and - x[0] <= 2.0*G[0]/3.0): - return lambda x,t: pondingPressure - if x[1] == 0.0: - return None #lambda x,t: 0.0 - if (x[0] == 0.0 or - x[0] == G[0]): - return None #lambda x,t: x[1]*dimensionless_gravity[1]*dimensionless_density - # if flag=="drain": - # return lambda x,t: 0.0 - -dirichletConditions = {0:getDBC_2D_Richards_Shock} - -class ShockIC_2D_Richards: - def uOfXT(self,x,t): - bc=getDBC_2D_Richards_Shock(x,0) - if bc != None: - return bc(x,t) - else: - return -3.00 # x[1]*dimensionless_gravity[1]*dimensionless_density - -initialConditions = {0:ShockIC_2D_Richards()} - -fluxBoundaryConditions = {0:'noFlow'} - -def getFBC_2D_Richards_Shock(x,flag): - if x[1] == G[1]: - if (x[0] < G[0]/3.0 or - x[0] > 2.0*G[0]/3.0): - return lambda x,t: 0.0 - -advectiveFluxBoundaryConditions = {0:getFBC_2D_Richards_Shock} - -diffusiveFluxBoundaryConditions = {0:{0:getFBC_2D_Richards_Shock}} - -T = 0.3/timeScale +from proteus import * +from proteus.default_p import * +from proteus.kernels import Richards + +nd = 2 + +L=[3.0,5.0,1.0] + + +regularGrid=False + +domain = Domain.PlanarStraightLineGraphDomain() +boundaries=['bottom','top','left','right', + 'swale', + 'drain'] + +boundaryTags=dict([(key,i+1) for (i,key) in enumerate(boundaries)]) + +vertices=[[0.0,0.0], #0 + [0.0,3.0], #1 + [3.0,3.0 ], #2 + [3.0, 0.0], #3 + [3.0,5.0], # 4 + [0.0 ,5.0], #5 + [0.5, 3.0], #6 + [2.5, 3.0], #7 + [2.0, 1.0],#8 + [1.0, 1.0],#9 + [1.2, 1.9],#10 + [1.7, 1.9],#11 + [1.7, 1.4], #12 + [1.2, 1.4],#13 + ] + +vertexFlags=[boundaryTags['bottom'], #0 + boundaryTags['left'], #1 + boundaryTags['right'], #2 + boundaryTags['bottom'], #3 + boundaryTags['top'], #4 + boundaryTags['left'], #5 + boundaryTags['swale'], #6 + boundaryTags['swale'], #7 + boundaryTags['swale'], #8 + boundaryTags['swale'], #9 + boundaryTags['drain'], #10 + boundaryTags['drain'], #11 + boundaryTags['drain'], #12 + boundaryTags['drain'], #13 + ] + + +segments =[[0,1], #0 + [1,2], #1 + [2,3], #2 + [3,0], #3 + [2,4], #4 + [4,5], #5 + [5,1], #6 + [6,7], #7 + [7,8], #8 + [8,9], #9 + [9,6], #10 + [10,11], #11 + [11,12], #12 + [12,13], #13 + [13,10]] #14 + + +segmentFlags=[boundaryTags['left'], #0 + boundaryTags['swale'], #1 + boundaryTags['right'], #2 + boundaryTags['bottom'], #3 + boundaryTags['right'], #4 + boundaryTags['top'], #5 + boundaryTags['left'], #6 + + boundaryTags['swale'], #7 + boundaryTags['swale'], #8 + boundaryTags['swale'], #9 + boundaryTags['swale'], #10 + + + boundaryTags['drain'], #11 + boundaryTags['drain'], #12 + boundaryTags['drain'], #13 + boundaryTags['drain'], #14 + ] + +holes= [[1.5,1.5]] +#regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5], [1.5,0.5]] +#regionFlags=[1,2,3,4] +regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5]]#, [1.5,0.5]] +regionFlags=[1,2,3] + +domain = Domain.PlanarStraightLineGraphDomain(vertices= vertices, + vertexFlags=vertexFlags, + segments=segments, + segmentFlags=segmentFlags, + regions = regions, + regionFlags = regionFlags, + holes= holes) + + +#dplt.plot_pslg_domain(polygon) + +domain.writePoly('bio2d_N') + +#if not regularGrid: +# domain.writePoly('bio2d_N') +# domain = Domain.PlanarStraightLineGraphDomain('bio2d_N') + +#domain.polyfile="bio2d_n_coarse" + +analyticalSolution = None + +viscosity = 8.9e-4 #kg/(m*s) +density = 998.2 #kg/m^3 +gravity = 9.8 #m/s^2 +beta = 0.0 #density*gravity*4.524e-10 +m_per_s_by_m_per_d = 1.1574074e-5 +lengthScale = 1.0 #m +timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) +#make non-dimensional + +# Storage Zone +permeability3 = (5.0)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS3 = 0.4 #- +thetaR3 = 0.05 #- +mvg_alpha3 = 8 #1/m +mvg_n3 = 2.4 +mvg_m3 = 1.0 - 1.0/mvg_n3 +dimensionless_conductivity3 = (timeScale*density*gravity*permeability3/(viscosity*lengthScale)) + +#Bioswale Zone +permeability2 = (7.128)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS2 = 0.43 #- +thetaR2 = 0.045 #- +mvg_alpha2 = 14.5 #1/m +mvg_n2 = 2.68 +mvg_m2 = 1.0 - 1.0/mvg_n2 +dimensionless_conductivity2 = (timeScale*density*gravity*permeability2/(viscosity*lengthScale)) + +#base +permeability1 = (1.06)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS1 = 0.41 #- +thetaR1 = 0.065 #- +mvg_alpha1 = 7.5 #1/m +mvg_n1 = 1.89 +mvg_m1 = 1.0 - 1.0/mvg_n1 +dimensionless_conductivity1 = (timeScale*density*gravity*permeability1/(viscosity*lengthScale)) +#pipe +#permeability4 = (8.03*m_per_s_by_m_per_d)*viscosity/(gravity*density) #m^2 +#thetaS4 = 0.43 #- +#thetaR4 = 0.045 #- +#mvg_alpha4 = 20 #1/m +#mvg_n4 = 3 +#mvg_m4 = 1.0 - 1.0/mvg_n4 +#dimensionless_conductivity4 = (timeScale*density*gravity*permeability4/(viscosity*lengthScale)) + + + +#print 'Ks',dimensionless_conductivity +dimensionless_density = 1.0 +dimensionless_gravity = numpy.array([0.0, + -1.0, + 0.0]) +#dimensionless_alpha = mvg_alpha*lengthScale +nMediaTypes = 3 +alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') +nVGtypes = numpy.zeros((nMediaTypes+1,),'d') +thetaStypes = numpy.zeros((nMediaTypes+1,),'d') +thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') +thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') +KsTypes = numpy.zeros((nMediaTypes+1,2),'d') + +for i in range(nMediaTypes+1): + if i==1: + alphaVGtypes[i] = mvg_alpha1 + nVGtypes[i] = mvg_n1 + thetaStypes[i] = thetaS1 + thetaRtypes[i] = thetaR1 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? + elif i==2: + alphaVGtypes[i] = mvg_alpha2 + nVGtypes[i] = mvg_n2 + thetaStypes[i] = thetaS2 + thetaRtypes[i] = thetaR2 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity2,dimensionless_conductivity2]#m/d? + + elif i==3: + alphaVGtypes[i] = mvg_alpha3 + nVGtypes[i] = mvg_n3 + thetaStypes[i] = thetaS3 + thetaRtypes[i] = thetaR3 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity3,dimensionless_conductivity3]#m/d? + #else: + # alphaVGtypes[i] = mvg_alpha4 + # nVGtypes[i] = mvg_n4 + # thetaStypes[i] = thetaS4 + # thetaRtypes[i] = thetaR4 + # thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + # KsTypes[i,:] = [dimensionless_conductivity4,dimensionless_conductivity4]#m/d? + +galerkin = False +useSeepageFace = True + +def getSeepageFace(flag): + if useSeepageFace: + if flag == boundaryTags['drain']: + return 1 + else: + return 0 + else: + return 0 + + + + +LevelModelType = Richards.LevelModel +coefficients = Richards.Coefficients(nd, + KsTypes, + nVGtypes, + alphaVGtypes, + thetaRtypes, + thetaSRtypes, + gravity=dimensionless_gravity, + density=dimensionless_density, + beta=0.0001, + diagonal_conductivity=True, + STABILIZATION_TYPE=2, + ENTROPY_TYPE=1, + LUMPED_MASS_MATRIX= False , + FCT=True, #False ,#True, + num_fct_iter=0, + # FOR ENTROPY VISCOSITY + cE=1.0, + uL=0.0, + uR=1.0, + # FOR ARTIFICIAL COMPRESSION + cK=1.0, + # OUTPUT quantDOFs + outputQuantDOFs=False, + getSeepageFace=getSeepageFace) +#galerkin = False + +#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, +# gravity=dimensionless_gravity, +# density=dimensionless_density, +# thetaS=thetaS, +# thetaR=thetaR, +# alpha= dimensionless_alpha, +# n = mvg_n, +# m = mvg_m, +# beta = beta) + + +#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, +# gravity=dimensionless_gravity, +# density=dimensionless_density, +# thetaS=thetaStypes, +# thetaR=thetaRtypes, +# alpha= alphaVGtypes, +# n = mvg_n, +# m = mvg_m, +# beta = beta)# + +#G= [1.8, 1.2,1] + +galerkin = False + +G=[3.0,5.0,1.0] + +pondingPressure= 0.5 + + +def getDBC_2D_Richards_Shock(x,flag): + if x[1] == G[1]: + if (x[0] >= G[0]/3.0 and + x[0] <= 2.0*G[0]/3.0): + return lambda x,t: pondingPressure + if x[1] == 0.0: + return None #lambda x,t: 0.0 + if (x[0] == 0.0 or + x[0] == G[0]): + return None #lambda x,t: x[1]*dimensionless_gravity[1]*dimensionless_density + # if flag=="drain": + # return lambda x,t: 0.0 + +dirichletConditions = {0:getDBC_2D_Richards_Shock} + +class ShockIC_2D_Richards: + def uOfXT(self,x,t): + bc=getDBC_2D_Richards_Shock(x,0) + if bc != None: + return bc(x,t) + else: + return -3.00 # x[1]*dimensionless_gravity[1]*dimensionless_density + +initialConditions = {0:ShockIC_2D_Richards()} + +fluxBoundaryConditions = {0:'noFlow'} + +def getFBC_2D_Richards_Shock(x,flag): + if x[1] == G[1]: + if (x[0] < G[0]/3.0 or + x[0] > 2.0*G[0]/3.0): + return lambda x,t: 0.0 + +advectiveFluxBoundaryConditions = {0:getFBC_2D_Richards_Shock} + +diffusiveFluxBoundaryConditions = {0:{0:getFBC_2D_Richards_Shock}} + +T = 0.3/timeScale diff --git a/test/richards/WRR_draft/3d_bioswale/Bioswales3d_p.py b/test/richards/WRR_draft/3d_bioswale/Bioswales3d_p.py index fc4808ade5..bd44fab4b0 100755 --- a/test/richards/WRR_draft/3d_bioswale/Bioswales3d_p.py +++ b/test/richards/WRR_draft/3d_bioswale/Bioswales3d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards nd = 3 diff --git a/test/richards/WRR_draft/Fluid_Flower_Domain/CCS_p.py b/test/richards/WRR_draft/Fluid_Flower_Domain/CCS_p.py index 91b5b729f2..db25bae511 100644 --- a/test/richards/WRR_draft/Fluid_Flower_Domain/CCS_p.py +++ b/test/richards/WRR_draft/Fluid_Flower_Domain/CCS_p.py @@ -1,319 +1,319 @@ -from proteus import * -from proteus.default_p import * -from proteus.richards import Richards -import numpy as np - -nd = 2 - -#L= [] - -#L=[3.0,5.0,1.0] - - -regularGrid=False - -domain = Domain.PlanarStraightLineGraphDomain() -#boundaries=['bottom','top','left','right', -# 'swale', -# 'drain'] -boundaries = [f'marker_{i}' for i in range(1, 17)] - -boundaryTags=dict([(key,i+1) for (i,key) in enumerate(boundaries)]) - -# Read the values from the text file -file_path = 'points_array_try.txt' # Replace with your actual file path -with open(file_path, 'r') as file: - lines = file.readlines() - -# Extract the values for the first and third columns -selected_values = [[float(line.split(',')[0]), float(line.split(',')[2])] for line in lines] - -# Create a NumPy array from the selected values -filtered_points = np.array(selected_values) - -vertices= filtered_points.tolist() - - -vertexFlags = [] -marker= np.loadtxt('vertexflags.txt', dtype=int).tolist() -for value in marker: - formatted_value = f"marker_{value}" - vertexFlags.append(boundaryTags[formatted_value]) - -segments=np.loadtxt('segments.txt', dtype=int).tolist() - -segmentFlags = [] -flags_segments= np.loadtxt('segmentsFlags.txt', dtype=int).tolist() - -for value in flags_segments: - marker_number= int(value) - formatted_value = f"marker_{marker_number}" - segmentFlags.append(boundaryTags[formatted_value]) - - - - -#holes= [[1.5,1.5]] -#regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5], [1.5,0.5]] -#regionFlags=[1,2,3,4] -#regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5]]#, [1.5,0.5]] -regions= [[0.8,1.4], #1 - [0.8,1.15], #2 - [0.6,1.0],[1.2,0.9],[1.7,1.0], #3 - [0.4,0.9],[1.1,0.8],[2.2,0.95], #4 - [0.5,0.85],[1.2,0.75],[1.7,0.9], #5 - [0.42,0.75],[1.20,0.65],[1.62,0.75], #6 - [2.61,0.70], #7 - [0.18,0.55],[0.60,0.60], #8 - [0.30,0.65], #9 - [0.21,0.60],[0.60,0.65], #10 - [0.15,0.35],[0.60,0.45], #11 - [0.15,0.20],[0.81,0.25], #12 - [1.83,0.05], #13 - [0.36,0.25], #14 - [0.96,0.90], #15 - [1.44,0.85], #16 - ] -#regionFlags=[1,2,3] -regionFlags=[1, - 2, - 3,3,3, - 4,4,4, - 5,5,5, - 6,6,6, - 7, - 8,8, - 9, - 10,10, - 11,11, - 12,12, - 13, - 14, - 15,16] - - -domain = Domain.PlanarStraightLineGraphDomain(vertices= vertices, - vertexFlags=vertexFlags, - segments=segments, - segmentFlags=segmentFlags, - regions = regions, - regionFlags = regionFlags,) - #holes= holes) - - -#dplt.plot_pslg_domain(polygon) - - -if not regularGrid: - domain.writePoly('CCS') - domain = Domain.PlanarStraightLineGraphDomain('CCS') - - -#domain.polyfile="bio2d_n_coarse" -#domain.polyfile="ImageToStl.com_fflower-tc_n" -analyticalSolution = None - -viscosity = 8.9e-4 #kg/(m*s) -density = 998.2 #kg/m^3 -gravity = 9.8 #m/s^2 -beta = 0.0 #density*gravity*4.524e-10 -m_per_s_by_m_per_d = 1.1574074e-5 -lengthScale = 1.0 #m -timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) -#make non-dimensional - -# Storage Zone -permeability3 = (6.856)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS3 = 0.4 #- -thetaR3 = 0.05 #- -mvg_alpha3 = 8 #1/m -mvg_n3 = 2.4 -mvg_m3 = 1.0 - 1.0/mvg_n3 -dimensionless_conductivity3 = (timeScale*density*gravity*permeability3/(viscosity*lengthScale)) - -#Bioswale Zone -permeability2 = (6.856)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS2 = 0.4 #- -thetaR2 = 0.05 #- -mvg_alpha2 = 8 #1/m -mvg_n2 = 2.4 -mvg_m2 = 1.0 - 1.0/mvg_n3 -dimensionless_conductivity2 = (timeScale*density*gravity*permeability2/(viscosity*lengthScale)) - -#base -permeability1 = (6.856)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS1 = 0.4 #- -thetaR1 = 0.05 #- -mvg_alpha1 = 8 #1/m -mvg_n1 = 2.4 -mvg_m1 = 1.0 - 1.0/mvg_n1 -dimensionless_conductivity1 = (timeScale*density*gravity*permeability1/(viscosity*lengthScale)) -#pipe -permeability4 = (8.03*m_per_s_by_m_per_d)*viscosity/(gravity*density) #m^2 -thetaS4 = 0.43 #- -thetaR4 = 0.045 #- -mvg_alpha4 = 20 #1/m -mvg_n4 = 3 -mvg_m4 = 1.0 - 1.0/mvg_n4 -dimensionless_conductivity4 = (timeScale*density*gravity*permeability4/(viscosity*lengthScale)) - - - -#print 'Ks',dimensionless_conductivity -dimensionless_density = 1.0 -dimensionless_gravity = numpy.array([0.0, - -1.0, - 0.0]) -#dimensionless_alpha = mvg_alpha*lengthScale -nMediaTypes = 1 -alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') -nVGtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaStypes = numpy.zeros((nMediaTypes+1,),'d') -thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') -KsTypes = numpy.zeros((nMediaTypes+1,2),'d') - -for i in range(nMediaTypes+1): - if i==1: - alphaVGtypes[i] = mvg_alpha1 - nVGtypes[i] = mvg_n1 - thetaStypes[i] = thetaS1 - thetaRtypes[i] = thetaR1 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? - elif i==2: - alphaVGtypes[i] = mvg_alpha2 - nVGtypes[i] = mvg_n2 - thetaStypes[i] = thetaS2 - thetaRtypes[i] = thetaR2 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity2,dimensionless_conductivity2]#m/d? - - elif i==3: - alphaVGtypes[i] = mvg_alpha3 - nVGtypes[i] = mvg_n3 - thetaStypes[i] = thetaS3 - thetaRtypes[i] = thetaR3 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity3,dimensionless_conductivity3]#m/d? - else: - alphaVGtypes[i] = mvg_alpha4 - nVGtypes[i] = mvg_n4 - thetaStypes[i] = thetaS4 - thetaRtypes[i] = thetaR4 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity4,dimensionless_conductivity4]#m/d? - -galerkin = False -#useSeepageFace = True - -#def getSeepageFace(flag): -# if useSeepageFace: -# if flag == boundaryTags['drain']: -# return 1 -# else: -# return 0 -# else: -# return 0 - - - - -LevelModelType = Richards.LevelModel -coefficients = Richards.Coefficients(nd, - KsTypes, - nVGtypes, - alphaVGtypes, - thetaRtypes, - thetaSRtypes, - gravity=dimensionless_gravity, - density=dimensionless_density, - beta=0.0001, - diagonal_conductivity=True, - STABILIZATION_TYPE=0, #0, - ENTROPY_TYPE=1, - LUMPED_MASS_MATRIX= False , - FCT=False ,#True, - num_fct_iter=0, - # FOR ENTROPY VISCOSITY - cE=1.0, - uL=0.0, - uR=1.0, - # FOR ARTIFICIAL COMPRESSION - cK=1.0, - # OUTPUT quantDOFs - outputQuantDOFs=False)#, - #getSeepageFace=getSeepageFace) -#galerkin = False - -#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, -# gravity=dimensionless_gravity, -# density=dimensionless_density, -# thetaS=thetaS, -# thetaR=thetaR, -# alpha= dimensionless_alpha, -# n = mvg_n, -# m = mvg_m, -# beta = beta) - - -#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, -# gravity=dimensionless_gravity, -# density=dimensionless_density, -# thetaS=thetaStypes, -# thetaR=thetaRtypes, -# alpha= alphaVGtypes, -# n = mvg_n, -# m = mvg_m, -# beta = beta)# - -#G= [1.8, 1.2,1] -#domain.writePLY('CCS') -galerkin = False - -G=[2.799999952316284,1.4950000047683716] - -pondingPressure= 1.0 - -def getDBC_2D_Richards_Shock(x,flag): - #if x[1] == G[1]: - if x[1] >= 1.44: - if (x[0] >= G[0]/3.0 and - x[0] <= 2.0*G[0]/3.0): - return lambda x,t: pondingPressure - if x[1] == 0.0: - return lambda x,t: 0.0 - if (x[0] == 0.0 or - x[0] == G[0]): - return lambda x,t: x[1]*dimensionless_gravity[1]*dimensionless_density - # if flag=="drain": - # return lambda x,t: 0.0 - -dirichletConditions = {0:getDBC_2D_Richards_Shock} - -class ShockIC_2D_Richards: - def uOfXT(self,x,t): - bc=getDBC_2D_Richards_Shock(x,0) - if bc != None: - return bc(x,t) - else: - return x[1]*dimensionless_gravity[1]*dimensionless_density - -initialConditions = {0:ShockIC_2D_Richards()} - -fluxBoundaryConditions = {0:'noFlow'} - -def getFBC_2D_Richards_Shock(x,flag): - if x[1] == G[1]: - if (x[0] < G[0]/3.0 or - x[0] > 2.0*G[0]/3.0): - return lambda x,t: 0.0 - -advectiveFluxBoundaryConditions = {0:getFBC_2D_Richards_Shock} - -diffusiveFluxBoundaryConditions = {0:{0:getFBC_2D_Richards_Shock}} - -T = 0.01/timeScale +from proteus import * +from proteus.default_p import * +from proteus.kernels import Richards +import numpy as np + +nd = 2 + +#L= [] + +#L=[3.0,5.0,1.0] + + +regularGrid=False + +domain = Domain.PlanarStraightLineGraphDomain() +#boundaries=['bottom','top','left','right', +# 'swale', +# 'drain'] +boundaries = [f'marker_{i}' for i in range(1, 17)] + +boundaryTags=dict([(key,i+1) for (i,key) in enumerate(boundaries)]) + +# Read the values from the text file +file_path = 'points_array_try.txt' # Replace with your actual file path +with open(file_path, 'r') as file: + lines = file.readlines() + +# Extract the values for the first and third columns +selected_values = [[float(line.split(',')[0]), float(line.split(',')[2])] for line in lines] + +# Create a NumPy array from the selected values +filtered_points = np.array(selected_values) + +vertices= filtered_points.tolist() + + +vertexFlags = [] +marker= np.loadtxt('vertexflags.txt', dtype=int).tolist() +for value in marker: + formatted_value = f"marker_{value}" + vertexFlags.append(boundaryTags[formatted_value]) + +segments=np.loadtxt('segments.txt', dtype=int).tolist() + +segmentFlags = [] +flags_segments= np.loadtxt('segmentsFlags.txt', dtype=int).tolist() + +for value in flags_segments: + marker_number= int(value) + formatted_value = f"marker_{marker_number}" + segmentFlags.append(boundaryTags[formatted_value]) + + + + +#holes= [[1.5,1.5]] +#regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5], [1.5,0.5]] +#regionFlags=[1,2,3,4] +#regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5]]#, [1.5,0.5]] +regions= [[0.8,1.4], #1 + [0.8,1.15], #2 + [0.6,1.0],[1.2,0.9],[1.7,1.0], #3 + [0.4,0.9],[1.1,0.8],[2.2,0.95], #4 + [0.5,0.85],[1.2,0.75],[1.7,0.9], #5 + [0.42,0.75],[1.20,0.65],[1.62,0.75], #6 + [2.61,0.70], #7 + [0.18,0.55],[0.60,0.60], #8 + [0.30,0.65], #9 + [0.21,0.60],[0.60,0.65], #10 + [0.15,0.35],[0.60,0.45], #11 + [0.15,0.20],[0.81,0.25], #12 + [1.83,0.05], #13 + [0.36,0.25], #14 + [0.96,0.90], #15 + [1.44,0.85], #16 + ] +#regionFlags=[1,2,3] +regionFlags=[1, + 2, + 3,3,3, + 4,4,4, + 5,5,5, + 6,6,6, + 7, + 8,8, + 9, + 10,10, + 11,11, + 12,12, + 13, + 14, + 15,16] + + +domain = Domain.PlanarStraightLineGraphDomain(vertices= vertices, + vertexFlags=vertexFlags, + segments=segments, + segmentFlags=segmentFlags, + regions = regions, + regionFlags = regionFlags,) + #holes= holes) + + +#dplt.plot_pslg_domain(polygon) + + +if not regularGrid: + domain.writePoly('CCS') + domain = Domain.PlanarStraightLineGraphDomain('CCS') + + +#domain.polyfile="bio2d_n_coarse" +#domain.polyfile="ImageToStl.com_fflower-tc_n" +analyticalSolution = None + +viscosity = 8.9e-4 #kg/(m*s) +density = 998.2 #kg/m^3 +gravity = 9.8 #m/s^2 +beta = 0.0 #density*gravity*4.524e-10 +m_per_s_by_m_per_d = 1.1574074e-5 +lengthScale = 1.0 #m +timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) +#make non-dimensional + +# Storage Zone +permeability3 = (6.856)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS3 = 0.4 #- +thetaR3 = 0.05 #- +mvg_alpha3 = 8 #1/m +mvg_n3 = 2.4 +mvg_m3 = 1.0 - 1.0/mvg_n3 +dimensionless_conductivity3 = (timeScale*density*gravity*permeability3/(viscosity*lengthScale)) + +#Bioswale Zone +permeability2 = (6.856)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS2 = 0.4 #- +thetaR2 = 0.05 #- +mvg_alpha2 = 8 #1/m +mvg_n2 = 2.4 +mvg_m2 = 1.0 - 1.0/mvg_n3 +dimensionless_conductivity2 = (timeScale*density*gravity*permeability2/(viscosity*lengthScale)) + +#base +permeability1 = (6.856)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS1 = 0.4 #- +thetaR1 = 0.05 #- +mvg_alpha1 = 8 #1/m +mvg_n1 = 2.4 +mvg_m1 = 1.0 - 1.0/mvg_n1 +dimensionless_conductivity1 = (timeScale*density*gravity*permeability1/(viscosity*lengthScale)) +#pipe +permeability4 = (8.03*m_per_s_by_m_per_d)*viscosity/(gravity*density) #m^2 +thetaS4 = 0.43 #- +thetaR4 = 0.045 #- +mvg_alpha4 = 20 #1/m +mvg_n4 = 3 +mvg_m4 = 1.0 - 1.0/mvg_n4 +dimensionless_conductivity4 = (timeScale*density*gravity*permeability4/(viscosity*lengthScale)) + + + +#print 'Ks',dimensionless_conductivity +dimensionless_density = 1.0 +dimensionless_gravity = numpy.array([0.0, + -1.0, + 0.0]) +#dimensionless_alpha = mvg_alpha*lengthScale +nMediaTypes = 1 +alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') +nVGtypes = numpy.zeros((nMediaTypes+1,),'d') +thetaStypes = numpy.zeros((nMediaTypes+1,),'d') +thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') +thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') +KsTypes = numpy.zeros((nMediaTypes+1,2),'d') + +for i in range(nMediaTypes+1): + if i==1: + alphaVGtypes[i] = mvg_alpha1 + nVGtypes[i] = mvg_n1 + thetaStypes[i] = thetaS1 + thetaRtypes[i] = thetaR1 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? + elif i==2: + alphaVGtypes[i] = mvg_alpha2 + nVGtypes[i] = mvg_n2 + thetaStypes[i] = thetaS2 + thetaRtypes[i] = thetaR2 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity2,dimensionless_conductivity2]#m/d? + + elif i==3: + alphaVGtypes[i] = mvg_alpha3 + nVGtypes[i] = mvg_n3 + thetaStypes[i] = thetaS3 + thetaRtypes[i] = thetaR3 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity3,dimensionless_conductivity3]#m/d? + else: + alphaVGtypes[i] = mvg_alpha4 + nVGtypes[i] = mvg_n4 + thetaStypes[i] = thetaS4 + thetaRtypes[i] = thetaR4 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity4,dimensionless_conductivity4]#m/d? + +galerkin = False +#useSeepageFace = True + +#def getSeepageFace(flag): +# if useSeepageFace: +# if flag == boundaryTags['drain']: +# return 1 +# else: +# return 0 +# else: +# return 0 + + + + +LevelModelType = Richards.LevelModel +coefficients = Richards.Coefficients(nd, + KsTypes, + nVGtypes, + alphaVGtypes, + thetaRtypes, + thetaSRtypes, + gravity=dimensionless_gravity, + density=dimensionless_density, + beta=0.0001, + diagonal_conductivity=True, + STABILIZATION_TYPE=0, #0, + ENTROPY_TYPE=1, + LUMPED_MASS_MATRIX= False , + FCT=False ,#True, + num_fct_iter=0, + # FOR ENTROPY VISCOSITY + cE=1.0, + uL=0.0, + uR=1.0, + # FOR ARTIFICIAL COMPRESSION + cK=1.0, + # OUTPUT quantDOFs + outputQuantDOFs=False)#, + #getSeepageFace=getSeepageFace) +#galerkin = False + +#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, +# gravity=dimensionless_gravity, +# density=dimensionless_density, +# thetaS=thetaS, +# thetaR=thetaR, +# alpha= dimensionless_alpha, +# n = mvg_n, +# m = mvg_m, +# beta = beta) + + +#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, +# gravity=dimensionless_gravity, +# density=dimensionless_density, +# thetaS=thetaStypes, +# thetaR=thetaRtypes, +# alpha= alphaVGtypes, +# n = mvg_n, +# m = mvg_m, +# beta = beta)# + +#G= [1.8, 1.2,1] +#domain.writePLY('CCS') +galerkin = False + +G=[2.799999952316284,1.4950000047683716] + +pondingPressure= 1.0 + +def getDBC_2D_Richards_Shock(x,flag): + #if x[1] == G[1]: + if x[1] >= 1.44: + if (x[0] >= G[0]/3.0 and + x[0] <= 2.0*G[0]/3.0): + return lambda x,t: pondingPressure + if x[1] == 0.0: + return lambda x,t: 0.0 + if (x[0] == 0.0 or + x[0] == G[0]): + return lambda x,t: x[1]*dimensionless_gravity[1]*dimensionless_density + # if flag=="drain": + # return lambda x,t: 0.0 + +dirichletConditions = {0:getDBC_2D_Richards_Shock} + +class ShockIC_2D_Richards: + def uOfXT(self,x,t): + bc=getDBC_2D_Richards_Shock(x,0) + if bc != None: + return bc(x,t) + else: + return x[1]*dimensionless_gravity[1]*dimensionless_density + +initialConditions = {0:ShockIC_2D_Richards()} + +fluxBoundaryConditions = {0:'noFlow'} + +def getFBC_2D_Richards_Shock(x,flag): + if x[1] == G[1]: + if (x[0] < G[0]/3.0 or + x[0] > 2.0*G[0]/3.0): + return lambda x,t: 0.0 + +advectiveFluxBoundaryConditions = {0:getFBC_2D_Richards_Shock} + +diffusiveFluxBoundaryConditions = {0:{0:getFBC_2D_Richards_Shock}} + +T = 0.01/timeScale diff --git a/test/richards/WRR_draft/Theis_convergence/Theis_p.py b/test/richards/WRR_draft/Theis_convergence/Theis_p.py index 2f30ba8ca2..b9910adfeb 100755 --- a/test/richards/WRR_draft/Theis_convergence/Theis_p.py +++ b/test/richards/WRR_draft/Theis_convergence/Theis_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import math diff --git a/test/richards/WRR_draft/raingarden/Raingarden_p.py b/test/richards/WRR_draft/raingarden/Raingarden_p.py index 6bb7dd6790..18c1943530 100755 --- a/test/richards/WRR_draft/raingarden/Raingarden_p.py +++ b/test/richards/WRR_draft/raingarden/Raingarden_p.py @@ -1,318 +1,318 @@ -from proteus import * -from proteus.default_p import * -from proteus.richards import Richards - -nd = 2 - -#L=(10.0,10.0,1.0) - -G=(1.8, 1.2,1) -regularGrid=False - -domain = Domain.PlanarStraightLineGraphDomain() -boundaries=['bottom','top','left','right', - 'Storage','Root'] - -boundaryTags=dict([(key,i+1) for (i,key) in enumerate(boundaries)]) - -vertices= [[0.0,0.0], #0 - [G[0] ,0.0], #1 - [G[0] ,0.7], #2 - [G[0], G[1]], #3 - [0.0, G[1]], #4 - [0.0, 0.7], #5 - ] - -vertexFlags=[boundaryTags['bottom'], - boundaryTags['bottom'], - boundaryTags['right'], - boundaryTags['top'], - boundaryTags['top'], - boundaryTags['left'], - ] - - -segments=[[0,1], - [1,2], - [2,5], - [2,3], - [3,4], - [4,5], - [5,0]] - -segmentFlags=[boundaryTags['bottom'], - boundaryTags['right'], - boundaryTags['Storage'], - boundaryTags['right'], - boundaryTags['top'], - boundaryTags['left'], - boundaryTags['left']] - -regions=[[0.1,0.1], [0.9, 1,1]] - -regionFlags=[0,1] - - -domain = Domain.PlanarStraightLineGraphDomain(vertices= vertices, - vertexFlags=vertexFlags, - segments=segments, - segmentFlags=segmentFlags, - regions = regions, - regionFlags = regionFlags,) -#dplt.plot_pslg_domain(polygon) - - -if not regularGrid: - domain.writePoly('rg2d') - #domain = Domain.PlanarStraightLineGraphDomain('rg2d') - - -analyticalSolution = None - -viscosity = 8.9e-4 #kg/(m*s) -density = 998.2 #kg/m^3 -gravity = 9.8 #m/s^2 -beta = 0.0 #density*gravity*4.524e-10 -m_per_s_by_m_per_d = 1.1574074e-5 -lengthScale = 1.0 #m -timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) -#make non-dimensional - -permeability1 = (3.438*m_per_s_by_m_per_d)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS1 = 0.41 #- -thetaR1 = 0.02 #- -mvg_alpha1 = 1 #1/m -mvg_n1 = 1.6 -mvg_m1 = 1.0 - 1.0/mvg_n1 -dimensionless_conductivity1 = (timeScale*density*gravity*permeability1/(viscosity*lengthScale)) - -permeability2 = (5.60*m_per_s_by_m_per_d)*viscosity/(gravity*density) #m^2 -#permeability2 = (0.00111)*viscosity/(gravity*density) #m^2 -thetaS2 = 0.41 #- -thetaR2 = 0.041 #- -mvg_alpha2 = 1 #1/m -mvg_n2 = 1.378 -mvg_m2 = 1.0 - 1.0/mvg_n2 -dimensionless_conductivity2 = (timeScale*density*gravity*permeability2/(viscosity*lengthScale)) - -#print 'Ks',dimensionless_conductivity -dimensionless_density = 1.0 -dimensionless_gravity = numpy.array([0.0, - -1.0, - 0.0]) -#dimensionless_alpha = mvg_alpha*lengthScale -nMediaTypes = 2 -alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') -nVGtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaStypes = numpy.zeros((nMediaTypes+1,),'d') -thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') -KsTypes = numpy.zeros((nMediaTypes+1,2),'d') - -for i in range(nMediaTypes+1): - if i==0: - alphaVGtypes[i] = mvg_alpha1 - nVGtypes[i] = mvg_n1 - thetaStypes[i] = thetaS1 - thetaRtypes[i] = thetaR1 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? - if i==1: - alphaVGtypes[i] = mvg_alpha2 - nVGtypes[i] = mvg_n2 - thetaStypes[i] = thetaS2 - thetaRtypes[i] = thetaR2 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity2,dimensionless_conductivity2]#m/d? - - -LevelModelType = Richards.LevelModel -coefficients = Richards.Coefficients(nd, - KsTypes, - nVGtypes, - alphaVGtypes, - thetaRtypes, - thetaSRtypes, - gravity=dimensionless_gravity, - density=dimensionless_density, - beta=0.0001, - diagonal_conductivity=True, - STABILIZATION_TYPE=2, - ENTROPY_TYPE=1, - LUMPED_MASS_MATRIX= False , - FCT=False,#True, - num_fct_iter=0, - # FOR ENTROPY VISCOSITY - cE=1.0, - uL=0.0, - uR=1.0, - # FOR ARTIFICIAL COMPRESSION - cK=1.0, - # OUTPUT quantDOFs - outputQuantDOFs=False) - - -#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, -# gravity=dimensionless_gravity, -# density=dimensionless_density, -# thetaS=thetaS, -# thetaR=thetaR, -# alpha= dimensionless_alpha, -# n = mvg_n, -# m = mvg_m, -# beta = beta) - - -#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, -# gravity=dimensionless_gravity, -# density=dimensionless_density, -# thetaS=thetaStypes, -# thetaR=thetaRtypes, -# alpha= alphaVGtypes, -# n = mvg_n, -# m = mvg_m, -# beta = beta)# - - - -pondingPressure=0.2 - -def getDBC_2D_Richards_Shock(x,flag): - if x[1] == G[1]: - if (x[0] >= G[0]/3.0 and - x[0] <= 2.0*G[0]/3.0): - return lambda x,t: pondingPressure - if x[1] == 0.0: - return lambda x,t: 0.0 - if (x[0] == 0.0 or - x[0] == G[0]): - return lambda x,t: x[1]*dimensionless_gravity[1]*dimensionless_density - -dirichletConditions = {0:getDBC_2D_Richards_Shock} - -class ShockIC_2D_Richards: - def uOfXT(self,x,t): - bc=getDBC_2D_Richards_Shock(x,0) - if bc != None: - return bc(x,t) - else: - return x[1]*dimensionless_gravity[1]*dimensionless_density - -initialConditions = {0:ShockIC_2D_Richards()} - -fluxBoundaryConditions = {0:'noFlow'} - -def getFBC_2D_Richards_Shock(x,flag): - if x[1] == G[1]: - if (x[0] < G[0]/3.0 or - x[0] > 2.0*G[0]/3.0): - return lambda x,t: 0.0 - -advectiveFluxBoundaryConditions = {0:getFBC_2D_Richards_Shock} - -diffusiveFluxBoundaryConditions = {0:{0:getFBC_2D_Richards_Shock}} - -T = 1.0/timeScale - - -from proteus import * -from proteus.default_n import * - -from proteus.default_so import * - -timeIntegration = BackwardEuler -stepController = HeuristicNL_dt_controller -nonlinearIterationsFloor = 6 -nonlinearIterationsCeil = 12 - -#timeIntegrator = ForwardIntegrator -#timeIntegration = FLCBDF -#stepController = FLCBDF_controller -#systemStepControllerType = SplitOperator.Sequential_MinFLCBDFModelStep -nDTout = 200 -DT = T/nDTout -tnList = [0.0,1.0e-8]+[i*DT for i in range(1,nDTout+1)] -atol_u[0] = 1.0e-3 -rtol_u[0] = 1.0e-3 - -#DT = None#0.025#1.0e-1/timeScale -#nDTout = 100#int(T/DT) - -femSpaces = {0:C0_AffineLinearOnSimplexWithNodalBasis} -#femSpaces = {0:C0_AffineQuadraticOnSimplexWithNodalBasis} - -elementQuadrature = SimplexGaussQuadrature(nd,4) - -elementBoundaryQuadrature = SimplexGaussQuadrature(nd-1,4) - -elementQuadrature = SimplexLobattoQuadrature(nd,1) -# -elementBoundaryQuadrature = SimplexLobattoQuadrature(nd-1,1) - -nnx=41 -nny=41 -nLevels = 1 -triangleFlag=1 #alternating triangles -triangleOptions="pAq30Dena%f" % (0.5*(L[0]/(nnx-1))**2,) -subgridError = None - -#subgridError = None -#subgridError = AdvectionDiffusionReaction_ASGS(coefficients,nd,stabFlag='2',lag=True) - -massLumping = False - -numericalFluxType = None -numericalFluxType = Advection_DiagonalUpwind_Diffusion_IIPG_exterior #need weak for parallel and global conservation - -shockCapturing = None -#shockCapturing = ResGradQuadDelayLag_SC(coefficients,nd,shockCapturingFactor=0.75,lag=True,nStepsToDelay=5) - -#multilevelNonlinearSolver = NLStarILU -#multilevelNonlinearSolver = NLGaussSeidel -#multilevelNonlinearSolver = NLJacobi -#multilevelNonlinearSolver = NLNI -#multilevelNonlinearSolver = FAS -multilevelNonlinearSolver = Newton - -#levelNonlinearSolver = NLStarILU -#levelNonlinearSolver = FAS -levelNonlinearSolver = Newton -#levelNonlinearSolver = NLGaussSeidel -#levelNonlinearSolver = NLJacobi - -#nonlinearSmoother = NLStarILU -#nonlinearSmoother = NLGaussSeidel -nonlinearSmoother = NLJacobi - -fullNewtonFlag = True - -tolFac = 0.0 - -nl_atol_res = 1.0e-8 - -maxNonlinearIts = 10#1001 -maxLineSearches =0#5 - -matrix = SparseMatrix - -multilevelLinearSolver = LU -#multilevelLinearSolver = PETSc -#multilevelLinearSolver = NI - -levelLinearSolver = LU -#levelLinearSolver = PETSc -#levelLinearSolver = MGM - -linearSmoother = Jacobi -linearSmoother = GaussSeidel -linearSmoother = StarILU - -linTolFac = 0.001 - -#conservativeFlux = {0:'pwl-bdm'} -parallelPartitioningType = MeshParallelPartitioningTypes.element -#default number of layers to use > 1 with element partition means -#C0P1 methods don't need to do communication in global element assembly -#nodal partitioning does not need communication for C0P1 (has overlap 1) regardless -nLayersOfOverlapForParallel = 1 +from proteus import * +from proteus.default_p import * +from proteus.kernels import Richards + +nd = 2 + +#L=(10.0,10.0,1.0) + +G=(1.8, 1.2,1) +regularGrid=False + +domain = Domain.PlanarStraightLineGraphDomain() +boundaries=['bottom','top','left','right', + 'Storage','Root'] + +boundaryTags=dict([(key,i+1) for (i,key) in enumerate(boundaries)]) + +vertices= [[0.0,0.0], #0 + [G[0] ,0.0], #1 + [G[0] ,0.7], #2 + [G[0], G[1]], #3 + [0.0, G[1]], #4 + [0.0, 0.7], #5 + ] + +vertexFlags=[boundaryTags['bottom'], + boundaryTags['bottom'], + boundaryTags['right'], + boundaryTags['top'], + boundaryTags['top'], + boundaryTags['left'], + ] + + +segments=[[0,1], + [1,2], + [2,5], + [2,3], + [3,4], + [4,5], + [5,0]] + +segmentFlags=[boundaryTags['bottom'], + boundaryTags['right'], + boundaryTags['Storage'], + boundaryTags['right'], + boundaryTags['top'], + boundaryTags['left'], + boundaryTags['left']] + +regions=[[0.1,0.1], [0.9, 1,1]] + +regionFlags=[0,1] + + +domain = Domain.PlanarStraightLineGraphDomain(vertices= vertices, + vertexFlags=vertexFlags, + segments=segments, + segmentFlags=segmentFlags, + regions = regions, + regionFlags = regionFlags,) +#dplt.plot_pslg_domain(polygon) + + +if not regularGrid: + domain.writePoly('rg2d') + #domain = Domain.PlanarStraightLineGraphDomain('rg2d') + + +analyticalSolution = None + +viscosity = 8.9e-4 #kg/(m*s) +density = 998.2 #kg/m^3 +gravity = 9.8 #m/s^2 +beta = 0.0 #density*gravity*4.524e-10 +m_per_s_by_m_per_d = 1.1574074e-5 +lengthScale = 1.0 #m +timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) +#make non-dimensional + +permeability1 = (3.438*m_per_s_by_m_per_d)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS1 = 0.41 #- +thetaR1 = 0.02 #- +mvg_alpha1 = 1 #1/m +mvg_n1 = 1.6 +mvg_m1 = 1.0 - 1.0/mvg_n1 +dimensionless_conductivity1 = (timeScale*density*gravity*permeability1/(viscosity*lengthScale)) + +permeability2 = (5.60*m_per_s_by_m_per_d)*viscosity/(gravity*density) #m^2 +#permeability2 = (0.00111)*viscosity/(gravity*density) #m^2 +thetaS2 = 0.41 #- +thetaR2 = 0.041 #- +mvg_alpha2 = 1 #1/m +mvg_n2 = 1.378 +mvg_m2 = 1.0 - 1.0/mvg_n2 +dimensionless_conductivity2 = (timeScale*density*gravity*permeability2/(viscosity*lengthScale)) + +#print 'Ks',dimensionless_conductivity +dimensionless_density = 1.0 +dimensionless_gravity = numpy.array([0.0, + -1.0, + 0.0]) +#dimensionless_alpha = mvg_alpha*lengthScale +nMediaTypes = 2 +alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') +nVGtypes = numpy.zeros((nMediaTypes+1,),'d') +thetaStypes = numpy.zeros((nMediaTypes+1,),'d') +thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') +thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') +KsTypes = numpy.zeros((nMediaTypes+1,2),'d') + +for i in range(nMediaTypes+1): + if i==0: + alphaVGtypes[i] = mvg_alpha1 + nVGtypes[i] = mvg_n1 + thetaStypes[i] = thetaS1 + thetaRtypes[i] = thetaR1 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? + if i==1: + alphaVGtypes[i] = mvg_alpha2 + nVGtypes[i] = mvg_n2 + thetaStypes[i] = thetaS2 + thetaRtypes[i] = thetaR2 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity2,dimensionless_conductivity2]#m/d? + + +LevelModelType = Richards.LevelModel +coefficients = Richards.Coefficients(nd, + KsTypes, + nVGtypes, + alphaVGtypes, + thetaRtypes, + thetaSRtypes, + gravity=dimensionless_gravity, + density=dimensionless_density, + beta=0.0001, + diagonal_conductivity=True, + STABILIZATION_TYPE=2, + ENTROPY_TYPE=1, + LUMPED_MASS_MATRIX= False , + FCT=False,#True, + num_fct_iter=0, + # FOR ENTROPY VISCOSITY + cE=1.0, + uL=0.0, + uR=1.0, + # FOR ARTIFICIAL COMPRESSION + cK=1.0, + # OUTPUT quantDOFs + outputQuantDOFs=False) + + +#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, +# gravity=dimensionless_gravity, +# density=dimensionless_density, +# thetaS=thetaS, +# thetaR=thetaR, +# alpha= dimensionless_alpha, +# n = mvg_n, +# m = mvg_m, +# beta = beta) + + +#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, +# gravity=dimensionless_gravity, +# density=dimensionless_density, +# thetaS=thetaStypes, +# thetaR=thetaRtypes, +# alpha= alphaVGtypes, +# n = mvg_n, +# m = mvg_m, +# beta = beta)# + + + +pondingPressure=0.2 + +def getDBC_2D_Richards_Shock(x,flag): + if x[1] == G[1]: + if (x[0] >= G[0]/3.0 and + x[0] <= 2.0*G[0]/3.0): + return lambda x,t: pondingPressure + if x[1] == 0.0: + return lambda x,t: 0.0 + if (x[0] == 0.0 or + x[0] == G[0]): + return lambda x,t: x[1]*dimensionless_gravity[1]*dimensionless_density + +dirichletConditions = {0:getDBC_2D_Richards_Shock} + +class ShockIC_2D_Richards: + def uOfXT(self,x,t): + bc=getDBC_2D_Richards_Shock(x,0) + if bc != None: + return bc(x,t) + else: + return x[1]*dimensionless_gravity[1]*dimensionless_density + +initialConditions = {0:ShockIC_2D_Richards()} + +fluxBoundaryConditions = {0:'noFlow'} + +def getFBC_2D_Richards_Shock(x,flag): + if x[1] == G[1]: + if (x[0] < G[0]/3.0 or + x[0] > 2.0*G[0]/3.0): + return lambda x,t: 0.0 + +advectiveFluxBoundaryConditions = {0:getFBC_2D_Richards_Shock} + +diffusiveFluxBoundaryConditions = {0:{0:getFBC_2D_Richards_Shock}} + +T = 1.0/timeScale + + +from proteus import * +from proteus.default_n import * + +from proteus.default_so import * + +timeIntegration = BackwardEuler +stepController = HeuristicNL_dt_controller +nonlinearIterationsFloor = 6 +nonlinearIterationsCeil = 12 + +#timeIntegrator = ForwardIntegrator +#timeIntegration = FLCBDF +#stepController = FLCBDF_controller +#systemStepControllerType = SplitOperator.Sequential_MinFLCBDFModelStep +nDTout = 200 +DT = T/nDTout +tnList = [0.0,1.0e-8]+[i*DT for i in range(1,nDTout+1)] +atol_u[0] = 1.0e-3 +rtol_u[0] = 1.0e-3 + +#DT = None#0.025#1.0e-1/timeScale +#nDTout = 100#int(T/DT) + +femSpaces = {0:C0_AffineLinearOnSimplexWithNodalBasis} +#femSpaces = {0:C0_AffineQuadraticOnSimplexWithNodalBasis} + +elementQuadrature = SimplexGaussQuadrature(nd,4) + +elementBoundaryQuadrature = SimplexGaussQuadrature(nd-1,4) + +elementQuadrature = SimplexLobattoQuadrature(nd,1) +# +elementBoundaryQuadrature = SimplexLobattoQuadrature(nd-1,1) + +nnx=41 +nny=41 +nLevels = 1 +triangleFlag=1 #alternating triangles +triangleOptions="pAq30Dena%f" % (0.5*(L[0]/(nnx-1))**2,) +subgridError = None + +#subgridError = None +#subgridError = AdvectionDiffusionReaction_ASGS(coefficients,nd,stabFlag='2',lag=True) + +massLumping = False + +numericalFluxType = None +numericalFluxType = Advection_DiagonalUpwind_Diffusion_IIPG_exterior #need weak for parallel and global conservation + +shockCapturing = None +#shockCapturing = ResGradQuadDelayLag_SC(coefficients,nd,shockCapturingFactor=0.75,lag=True,nStepsToDelay=5) + +#multilevelNonlinearSolver = NLStarILU +#multilevelNonlinearSolver = NLGaussSeidel +#multilevelNonlinearSolver = NLJacobi +#multilevelNonlinearSolver = NLNI +#multilevelNonlinearSolver = FAS +multilevelNonlinearSolver = Newton + +#levelNonlinearSolver = NLStarILU +#levelNonlinearSolver = FAS +levelNonlinearSolver = Newton +#levelNonlinearSolver = NLGaussSeidel +#levelNonlinearSolver = NLJacobi + +#nonlinearSmoother = NLStarILU +#nonlinearSmoother = NLGaussSeidel +nonlinearSmoother = NLJacobi + +fullNewtonFlag = True + +tolFac = 0.0 + +nl_atol_res = 1.0e-8 + +maxNonlinearIts = 10#1001 +maxLineSearches =0#5 + +matrix = SparseMatrix + +multilevelLinearSolver = LU +#multilevelLinearSolver = PETSc +#multilevelLinearSolver = NI + +levelLinearSolver = LU +#levelLinearSolver = PETSc +#levelLinearSolver = MGM + +linearSmoother = Jacobi +linearSmoother = GaussSeidel +linearSmoother = StarILU + +linTolFac = 0.001 + +#conservativeFlux = {0:'pwl-bdm'} +parallelPartitioningType = MeshParallelPartitioningTypes.element +#default number of layers to use > 1 with element partition means +#C0P1 methods don't need to do communication in global element assembly +#nodal partitioning does not need communication for C0P1 (has overlap 1) regardless +nLayersOfOverlapForParallel = 1 diff --git a/test/richards/WRR_draft/seepage/input/2d/bio2d_convergence_p.py b/test/richards/WRR_draft/seepage/input/2d/bio2d_convergence_p.py index 4b5666cec7..0829b214fa 100755 --- a/test/richards/WRR_draft/seepage/input/2d/bio2d_convergence_p.py +++ b/test/richards/WRR_draft/seepage/input/2d/bio2d_convergence_p.py @@ -1,319 +1,319 @@ -from proteus import * -from proteus.default_p import * -from proteus.richards import Richards - -nd = 2 - -L=[3.0,5.0,1.0] - - -regularGrid=False - -domain = Domain.PlanarStraightLineGraphDomain() -boundaries=['bottom','top','left','right', - 'swale', - 'drain'] - -boundaryTags=dict([(key,i+1) for (i,key) in enumerate(boundaries)]) - -vertices=[[0.0,0.0], #0 - [0.0,3.0], #1 - [3.0,3.0 ], #2 - [3.0, 0.0], #3 - [3.0,5.0], # 4 - [0.0 ,5.0], #5 - [0.5, 3.0], #6 - [2.5, 3.0], #7 - [2.0, 1.0],#8 - [1.0, 1.0],#9 - [1.2, 1.9],#10 - [1.7, 1.9],#11 - [1.7, 1.4], #12 - [1.2, 1.4],#13 - ] - -vertexFlags=[boundaryTags['bottom'], #0 - boundaryTags['left'], #1 - boundaryTags['right'], #2 - boundaryTags['bottom'], #3 - boundaryTags['top'], #4 - boundaryTags['left'], #5 - boundaryTags['swale'], #6 - boundaryTags['swale'], #7 - boundaryTags['swale'], #8 - boundaryTags['swale'], #9 - boundaryTags['drain'], #10 - boundaryTags['drain'], #11 - boundaryTags['drain'], #12 - boundaryTags['drain'], #13 - ] - - -segments =[[0,1], #0 - [1,2], #1 - [2,3], #2 - [3,0], #3 - [2,4], #4 - [4,5], #5 - [5,1], #6 - [6,7], #7 - [7,8], #8 - [8,9], #9 - [9,6], #10 - [10,11], #11 - [11,12], #12 - [12,13], #13 - [13,10]] #14 - - -segmentFlags=[boundaryTags['left'], #0 - boundaryTags['swale'], #1 - boundaryTags['right'], #2 - boundaryTags['bottom'], #3 - boundaryTags['right'], #4 - boundaryTags['top'], #5 - boundaryTags['left'], #6 - - boundaryTags['swale'], #7 - boundaryTags['swale'], #8 - boundaryTags['swale'], #9 - boundaryTags['swale'], #10 - - - boundaryTags['drain'], #11 - boundaryTags['drain'], #12 - boundaryTags['drain'], #13 - boundaryTags['drain'], #14 - ] - -holes= [[1.5,1.5]] -#regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5], [1.5,0.5]] -#regionFlags=[1,2,3,4] -regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5]]#, [1.5,0.5]] -regionFlags=[1,2,3] - -domain = Domain.PlanarStraightLineGraphDomain(vertices= vertices, - vertexFlags=vertexFlags, - segments=segments, - segmentFlags=segmentFlags, - regions = regions, - regionFlags = regionFlags, - holes= holes) - - -#dplt.plot_pslg_domain(polygon) - -domain.writePoly('bio2d_N') - -#if not regularGrid: -# domain.writePoly('bio2d_N') -# domain = Domain.PlanarStraightLineGraphDomain('bio2d_N') - -#domain.polyfile="bio2d_n_coarse" - -analyticalSolution = None - -viscosity = 8.9e-4 #kg/(m*s) -density = 998.2 #kg/m^3 -gravity = 9.8 #m/s^2 -beta = 0.0 #density*gravity*4.524e-10 -m_per_s_by_m_per_d = 1.1574074e-5 -lengthScale = 1.0 #m -timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) -#make non-dimensional - -# Storage Zone -permeability3 = (5.0)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS3 = 0.4 #- -thetaR3 = 0.05 #- -mvg_alpha3 = 8 #1/m -mvg_n3 = 2.4 -mvg_m3 = 1.0 - 1.0/mvg_n3 -dimensionless_conductivity3 = (timeScale*density*gravity*permeability3/(viscosity*lengthScale)) - -#Bioswale Zone -permeability2 = (7.128)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS2 = 0.43 #- -thetaR2 = 0.045 #- -mvg_alpha2 = 14.5 #1/m -mvg_n2 = 2.68 -mvg_m2 = 1.0 - 1.0/mvg_n2 -dimensionless_conductivity2 = (timeScale*density*gravity*permeability2/(viscosity*lengthScale)) - -#base -permeability1 = (1.06)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS1 = 0.41 #- -thetaR1 = 0.065 #- -mvg_alpha1 = 7.5 #1/m -mvg_n1 = 1.89 -mvg_m1 = 1.0 - 1.0/mvg_n1 -dimensionless_conductivity1 = (timeScale*density*gravity*permeability1/(viscosity*lengthScale)) -#pipe -#permeability4 = (8.03*m_per_s_by_m_per_d)*viscosity/(gravity*density) #m^2 -#thetaS4 = 0.43 #- -#thetaR4 = 0.045 #- -#mvg_alpha4 = 20 #1/m -#mvg_n4 = 3 -#mvg_m4 = 1.0 - 1.0/mvg_n4 -#dimensionless_conductivity4 = (timeScale*density*gravity*permeability4/(viscosity*lengthScale)) - - - -#print 'Ks',dimensionless_conductivity -dimensionless_density = 1.0 -dimensionless_gravity = numpy.array([0.0, - -1.0, - 0.0]) -#dimensionless_alpha = mvg_alpha*lengthScale -nMediaTypes = 3 -alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') -nVGtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaStypes = numpy.zeros((nMediaTypes+1,),'d') -thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') -KsTypes = numpy.zeros((nMediaTypes+1,2),'d') - -for i in range(nMediaTypes+1): - if i==1: - alphaVGtypes[i] = mvg_alpha1 - nVGtypes[i] = mvg_n1 - thetaStypes[i] = thetaS1 - thetaRtypes[i] = thetaR1 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? - elif i==2: - alphaVGtypes[i] = mvg_alpha2 - nVGtypes[i] = mvg_n2 - thetaStypes[i] = thetaS2 - thetaRtypes[i] = thetaR2 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity2,dimensionless_conductivity2]#m/d? - - elif i==3: - alphaVGtypes[i] = mvg_alpha3 - nVGtypes[i] = mvg_n3 - thetaStypes[i] = thetaS3 - thetaRtypes[i] = thetaR3 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity3,dimensionless_conductivity3]#m/d? - #else: - # alphaVGtypes[i] = mvg_alpha4 - # nVGtypes[i] = mvg_n4 - # thetaStypes[i] = thetaS4 - # thetaRtypes[i] = thetaR4 - # thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - # KsTypes[i,:] = [dimensionless_conductivity4,dimensionless_conductivity4]#m/d? - -galerkin = False -useSeepageFace = True - -def getSeepageFace(flag): - if useSeepageFace: - if flag == boundaryTags['drain']: - return 1 - else: - return 0 - else: - return 0 - - - - -LevelModelType = Richards.LevelModel -coefficients = Richards.Coefficients(nd, - KsTypes, - nVGtypes, - alphaVGtypes, - thetaRtypes, - thetaSRtypes, - gravity=dimensionless_gravity, - density=dimensionless_density, - beta=0.0001, - diagonal_conductivity=True, - STABILIZATION_TYPE=0, - ENTROPY_TYPE=1, - LUMPED_MASS_MATRIX= False , - FCT=False, #False ,#True, - num_fct_iter=0, - # FOR ENTROPY VISCOSITY - cE=1.0, - uL=0.0, - uR=1.0, - # FOR ARTIFICIAL COMPRESSION - cK=1.0, - # OUTPUT quantDOFs - outputQuantDOFs=False, - getSeepageFace=getSeepageFace) -#galerkin = False - -#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, -# gravity=dimensionless_gravity, -# density=dimensionless_density, -# thetaS=thetaS, -# thetaR=thetaR, -# alpha= dimensionless_alpha, -# n = mvg_n, -# m = mvg_m, -# beta = beta) - - -#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, -# gravity=dimensionless_gravity, -# density=dimensionless_density, -# thetaS=thetaStypes, -# thetaR=thetaRtypes, -# alpha= alphaVGtypes, -# n = mvg_n, -# m = mvg_m, -# beta = beta)# - -#G= [1.8, 1.2,1] - -galerkin = False - -G=[3.0,5.0,1.0] - -pondingPressure= 0.5 - - -def getDBC_2D_Richards_Shock(x,flag): - if x[1] == G[1]: - if (x[0] >= G[0]/3.0 and - x[0] <= 2.0*G[0]/3.0): - return lambda x,t: pondingPressure - if x[1] == 0.0: - return None #lambda x,t: 0.0 - if (x[0] == 0.0 or - x[0] == G[0]): - return None #lambda x,t: x[1]*dimensionless_gravity[1]*dimensionless_density - # if flag=="drain": - # return lambda x,t: 0.0 - -dirichletConditions = {0:getDBC_2D_Richards_Shock} - -class ShockIC_2D_Richards: - def uOfXT(self,x,t): - bc=getDBC_2D_Richards_Shock(x,0) - if bc != None: - return bc(x,t) - else: - return -3.00 # x[1]*dimensionless_gravity[1]*dimensionless_density - -initialConditions = {0:ShockIC_2D_Richards()} - -fluxBoundaryConditions = {0:'noFlow'} - -def getFBC_2D_Richards_Shock(x,flag): - if x[1] == G[1]: - if (x[0] < G[0]/3.0 or - x[0] > 2.0*G[0]/3.0): - return lambda x,t: 0.0 - -advectiveFluxBoundaryConditions = {0:getFBC_2D_Richards_Shock} - -diffusiveFluxBoundaryConditions = {0:{0:getFBC_2D_Richards_Shock}} - -T = 0.3/timeScale +from proteus import * +from proteus.default_p import * +from proteus.kernels import Richards + +nd = 2 + +L=[3.0,5.0,1.0] + + +regularGrid=False + +domain = Domain.PlanarStraightLineGraphDomain() +boundaries=['bottom','top','left','right', + 'swale', + 'drain'] + +boundaryTags=dict([(key,i+1) for (i,key) in enumerate(boundaries)]) + +vertices=[[0.0,0.0], #0 + [0.0,3.0], #1 + [3.0,3.0 ], #2 + [3.0, 0.0], #3 + [3.0,5.0], # 4 + [0.0 ,5.0], #5 + [0.5, 3.0], #6 + [2.5, 3.0], #7 + [2.0, 1.0],#8 + [1.0, 1.0],#9 + [1.2, 1.9],#10 + [1.7, 1.9],#11 + [1.7, 1.4], #12 + [1.2, 1.4],#13 + ] + +vertexFlags=[boundaryTags['bottom'], #0 + boundaryTags['left'], #1 + boundaryTags['right'], #2 + boundaryTags['bottom'], #3 + boundaryTags['top'], #4 + boundaryTags['left'], #5 + boundaryTags['swale'], #6 + boundaryTags['swale'], #7 + boundaryTags['swale'], #8 + boundaryTags['swale'], #9 + boundaryTags['drain'], #10 + boundaryTags['drain'], #11 + boundaryTags['drain'], #12 + boundaryTags['drain'], #13 + ] + + +segments =[[0,1], #0 + [1,2], #1 + [2,3], #2 + [3,0], #3 + [2,4], #4 + [4,5], #5 + [5,1], #6 + [6,7], #7 + [7,8], #8 + [8,9], #9 + [9,6], #10 + [10,11], #11 + [11,12], #12 + [12,13], #13 + [13,10]] #14 + + +segmentFlags=[boundaryTags['left'], #0 + boundaryTags['swale'], #1 + boundaryTags['right'], #2 + boundaryTags['bottom'], #3 + boundaryTags['right'], #4 + boundaryTags['top'], #5 + boundaryTags['left'], #6 + + boundaryTags['swale'], #7 + boundaryTags['swale'], #8 + boundaryTags['swale'], #9 + boundaryTags['swale'], #10 + + + boundaryTags['drain'], #11 + boundaryTags['drain'], #12 + boundaryTags['drain'], #13 + boundaryTags['drain'], #14 + ] + +holes= [[1.5,1.5]] +#regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5], [1.5,0.5]] +#regionFlags=[1,2,3,4] +regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5]]#, [1.5,0.5]] +regionFlags=[1,2,3] + +domain = Domain.PlanarStraightLineGraphDomain(vertices= vertices, + vertexFlags=vertexFlags, + segments=segments, + segmentFlags=segmentFlags, + regions = regions, + regionFlags = regionFlags, + holes= holes) + + +#dplt.plot_pslg_domain(polygon) + +domain.writePoly('bio2d_N') + +#if not regularGrid: +# domain.writePoly('bio2d_N') +# domain = Domain.PlanarStraightLineGraphDomain('bio2d_N') + +#domain.polyfile="bio2d_n_coarse" + +analyticalSolution = None + +viscosity = 8.9e-4 #kg/(m*s) +density = 998.2 #kg/m^3 +gravity = 9.8 #m/s^2 +beta = 0.0 #density*gravity*4.524e-10 +m_per_s_by_m_per_d = 1.1574074e-5 +lengthScale = 1.0 #m +timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) +#make non-dimensional + +# Storage Zone +permeability3 = (5.0)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS3 = 0.4 #- +thetaR3 = 0.05 #- +mvg_alpha3 = 8 #1/m +mvg_n3 = 2.4 +mvg_m3 = 1.0 - 1.0/mvg_n3 +dimensionless_conductivity3 = (timeScale*density*gravity*permeability3/(viscosity*lengthScale)) + +#Bioswale Zone +permeability2 = (7.128)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS2 = 0.43 #- +thetaR2 = 0.045 #- +mvg_alpha2 = 14.5 #1/m +mvg_n2 = 2.68 +mvg_m2 = 1.0 - 1.0/mvg_n2 +dimensionless_conductivity2 = (timeScale*density*gravity*permeability2/(viscosity*lengthScale)) + +#base +permeability1 = (1.06)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS1 = 0.41 #- +thetaR1 = 0.065 #- +mvg_alpha1 = 7.5 #1/m +mvg_n1 = 1.89 +mvg_m1 = 1.0 - 1.0/mvg_n1 +dimensionless_conductivity1 = (timeScale*density*gravity*permeability1/(viscosity*lengthScale)) +#pipe +#permeability4 = (8.03*m_per_s_by_m_per_d)*viscosity/(gravity*density) #m^2 +#thetaS4 = 0.43 #- +#thetaR4 = 0.045 #- +#mvg_alpha4 = 20 #1/m +#mvg_n4 = 3 +#mvg_m4 = 1.0 - 1.0/mvg_n4 +#dimensionless_conductivity4 = (timeScale*density*gravity*permeability4/(viscosity*lengthScale)) + + + +#print 'Ks',dimensionless_conductivity +dimensionless_density = 1.0 +dimensionless_gravity = numpy.array([0.0, + -1.0, + 0.0]) +#dimensionless_alpha = mvg_alpha*lengthScale +nMediaTypes = 3 +alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') +nVGtypes = numpy.zeros((nMediaTypes+1,),'d') +thetaStypes = numpy.zeros((nMediaTypes+1,),'d') +thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') +thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') +KsTypes = numpy.zeros((nMediaTypes+1,2),'d') + +for i in range(nMediaTypes+1): + if i==1: + alphaVGtypes[i] = mvg_alpha1 + nVGtypes[i] = mvg_n1 + thetaStypes[i] = thetaS1 + thetaRtypes[i] = thetaR1 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? + elif i==2: + alphaVGtypes[i] = mvg_alpha2 + nVGtypes[i] = mvg_n2 + thetaStypes[i] = thetaS2 + thetaRtypes[i] = thetaR2 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity2,dimensionless_conductivity2]#m/d? + + elif i==3: + alphaVGtypes[i] = mvg_alpha3 + nVGtypes[i] = mvg_n3 + thetaStypes[i] = thetaS3 + thetaRtypes[i] = thetaR3 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity3,dimensionless_conductivity3]#m/d? + #else: + # alphaVGtypes[i] = mvg_alpha4 + # nVGtypes[i] = mvg_n4 + # thetaStypes[i] = thetaS4 + # thetaRtypes[i] = thetaR4 + # thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + # KsTypes[i,:] = [dimensionless_conductivity4,dimensionless_conductivity4]#m/d? + +galerkin = False +useSeepageFace = True + +def getSeepageFace(flag): + if useSeepageFace: + if flag == boundaryTags['drain']: + return 1 + else: + return 0 + else: + return 0 + + + + +LevelModelType = Richards.LevelModel +coefficients = Richards.Coefficients(nd, + KsTypes, + nVGtypes, + alphaVGtypes, + thetaRtypes, + thetaSRtypes, + gravity=dimensionless_gravity, + density=dimensionless_density, + beta=0.0001, + diagonal_conductivity=True, + STABILIZATION_TYPE=0, + ENTROPY_TYPE=1, + LUMPED_MASS_MATRIX= False , + FCT=False, #False ,#True, + num_fct_iter=0, + # FOR ENTROPY VISCOSITY + cE=1.0, + uL=0.0, + uR=1.0, + # FOR ARTIFICIAL COMPRESSION + cK=1.0, + # OUTPUT quantDOFs + outputQuantDOFs=False, + getSeepageFace=getSeepageFace) +#galerkin = False + +#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, +# gravity=dimensionless_gravity, +# density=dimensionless_density, +# thetaS=thetaS, +# thetaR=thetaR, +# alpha= dimensionless_alpha, +# n = mvg_n, +# m = mvg_m, +# beta = beta) + + +#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, +# gravity=dimensionless_gravity, +# density=dimensionless_density, +# thetaS=thetaStypes, +# thetaR=thetaRtypes, +# alpha= alphaVGtypes, +# n = mvg_n, +# m = mvg_m, +# beta = beta)# + +#G= [1.8, 1.2,1] + +galerkin = False + +G=[3.0,5.0,1.0] + +pondingPressure= 0.5 + + +def getDBC_2D_Richards_Shock(x,flag): + if x[1] == G[1]: + if (x[0] >= G[0]/3.0 and + x[0] <= 2.0*G[0]/3.0): + return lambda x,t: pondingPressure + if x[1] == 0.0: + return None #lambda x,t: 0.0 + if (x[0] == 0.0 or + x[0] == G[0]): + return None #lambda x,t: x[1]*dimensionless_gravity[1]*dimensionless_density + # if flag=="drain": + # return lambda x,t: 0.0 + +dirichletConditions = {0:getDBC_2D_Richards_Shock} + +class ShockIC_2D_Richards: + def uOfXT(self,x,t): + bc=getDBC_2D_Richards_Shock(x,0) + if bc != None: + return bc(x,t) + else: + return -3.00 # x[1]*dimensionless_gravity[1]*dimensionless_density + +initialConditions = {0:ShockIC_2D_Richards()} + +fluxBoundaryConditions = {0:'noFlow'} + +def getFBC_2D_Richards_Shock(x,flag): + if x[1] == G[1]: + if (x[0] < G[0]/3.0 or + x[0] > 2.0*G[0]/3.0): + return lambda x,t: 0.0 + +advectiveFluxBoundaryConditions = {0:getFBC_2D_Richards_Shock} + +diffusiveFluxBoundaryConditions = {0:{0:getFBC_2D_Richards_Shock}} + +T = 0.3/timeScale diff --git a/test/richards/WRR_draft/seepage/input/3d/Bioswales3d_p.py b/test/richards/WRR_draft/seepage/input/3d/Bioswales3d_p.py index 3638258d5d..c54132d9fb 100755 --- a/test/richards/WRR_draft/seepage/input/3d/Bioswales3d_p.py +++ b/test/richards/WRR_draft/seepage/input/3d/Bioswales3d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards nd = 3 diff --git a/test/richards/WRR_draft/test_1/celia_p.py b/test/richards/WRR_draft/test_1/celia_p.py index d01e19258f..c8b3721785 100755 --- a/test/richards/WRR_draft/test_1/celia_p.py +++ b/test/richards/WRR_draft/test_1/celia_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards opts= Context.Options([ ('num','fct',"numerics: num = fct, low-order, galerkin, low-order-galerkin, vms-galerkin, vms-sc-galerkin"), diff --git a/test/richards/WRR_input_files/Raingarden/Raingarden_p.py b/test/richards/WRR_input_files/Raingarden/Raingarden_p.py index 2bfb75e2a0..fece0ae1a4 100644 --- a/test/richards/WRR_input_files/Raingarden/Raingarden_p.py +++ b/test/richards/WRR_input_files/Raingarden/Raingarden_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from proteus import Context from domain_rg import * diff --git a/test/richards/WRR_input_files/Tracy_convergence/re_vgm_sand_10x10m_2d_p.py b/test/richards/WRR_input_files/Tracy_convergence/re_vgm_sand_10x10m_2d_p.py index c8fb5322a1..e4e42a1683 100644 --- a/test/richards/WRR_input_files/Tracy_convergence/re_vgm_sand_10x10m_2d_p.py +++ b/test/richards/WRR_input_files/Tracy_convergence/re_vgm_sand_10x10m_2d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from proteus import Context # Scheme selection. The defaults are the FCT scheme; the other two are diff --git a/test/richards/WRR_input_files/bio2d/Raingarden_p.py b/test/richards/WRR_input_files/bio2d/Raingarden_p.py index e9694bc531..82d6fdd760 100644 --- a/test/richards/WRR_input_files/bio2d/Raingarden_p.py +++ b/test/richards/WRR_input_files/bio2d/Raingarden_p.py @@ -15,7 +15,7 @@ """ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from domain_rg import * # brings in the domain AND the context object ct analyticalSolution = None diff --git a/test/richards/WRR_input_files/test_1/re_vgm_sand_10m_1d_p.py b/test/richards/WRR_input_files/test_1/re_vgm_sand_10m_1d_p.py index f62808e6a0..492be952fd 100755 --- a/test/richards/WRR_input_files/test_1/re_vgm_sand_10m_1d_p.py +++ b/test/richards/WRR_input_files/test_1/re_vgm_sand_10m_1d_p.py @@ -5,7 +5,7 @@ """ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from proteus import Context # Scheme selection. The defaults are the FCT scheme; the other two are diff --git a/test/richards/WRR_input_files/test_2/re_vgm_sand_10m_1d_p.py b/test/richards/WRR_input_files/test_2/re_vgm_sand_10m_1d_p.py index 81eefc4c7b..9bc1022843 100755 --- a/test/richards/WRR_input_files/test_2/re_vgm_sand_10m_1d_p.py +++ b/test/richards/WRR_input_files/test_2/re_vgm_sand_10m_1d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from proteus import Context # Scheme selection. The defaults are the FCT scheme; the other one is diff --git a/test/richards/WRR_input_files/test_3/re_vgm_sand_10m_1d_p.py b/test/richards/WRR_input_files/test_3/re_vgm_sand_10m_1d_p.py index 82e13290f4..d5a01916e1 100755 --- a/test/richards/WRR_input_files/test_3/re_vgm_sand_10m_1d_p.py +++ b/test/richards/WRR_input_files/test_3/re_vgm_sand_10m_1d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from proteus import Context # Scheme selection. The defaults are the FCT scheme; the other one is diff --git a/test/richards/adr_1d_n.py b/test/richards/adr_1d_n.py deleted file mode 100644 index f334ead5ae..0000000000 --- a/test/richards/adr_1d_n.py +++ /dev/null @@ -1,147 +0,0 @@ -from proteus import * -from proteus.default_n import * -from adr_1d_p import * - - -timeIntegrator = ForwardIntegrator -useFLCBDF = False#True#False -useGustafsson = False#True# -atol_u[0] = 1.0e-5 -rtol_u[0] = 1.0e-5 -#DT = 1.0e-6#None#0.025#1.0e-1/timeScale -tnList = [0.0]; -nDTout = 200#cek don't have stability worked out yet, blows up for large time steps -for i in range(nDTout): - tnList.append(0.0+(i+1)*(T)/float(nDTout)) -if useFLCBDF: - timeIntegration = FLCBDF - stepController = FLCBDF_controller - systemStepControllerType = SplitOperator.Sequential_MinFLCBDFModelStep -elif useGustafsson: - #timeIntegration = BackwardEuler - timeIntegration = VBDF - timeOrder = 2 - stepController = GustafssonFullNewton_dt_controller#FixedStep - #nDTout = 1#int(T/DT)#int(T/DT) #100#int(T/DT) - #for controlling time stepping - nonlinearConvergenceRate_ref = 0.2#0.3#0.2 - useInitialGuessPredictor= True - stepExact = True - systemStepControllerType = SplitOperator.Sequential_MinAdaptiveModelStep -else: - timeIntegration = BackwardEuler - stepController = HeuristicNL_dt_controller#FixedStep - #nDTout = 1#int(T/DT)#int(T/DT) #100#int(T/DT) - #for controlling time stepping - nonlinearIterationsFloor = 4 - nonlinearIterationsCeil = 8 - dtNLgrowFactor = 2 - dtNLreduceFactor = 0.5 - dtNLfailureReduceFactor = 0.5 - useInitialGuessPredictor= True - stepExact = True - -#if not galerkin: -# timeIntegration = Richards.ThetaScheme -# timeIntegration = Richards.RKEV -timeOrder = 1 -stepController = FixedStep -#systemStepControllerType = SplitOperator.Sequential_FixedStep -#dt_system_fixed = 0.001 -#nDTout = 1#int(T/DT)#int(T/DT) #100#int(T/DT) -#for controlling time stepping -nonlinearIterationsFloor = 4 -nonlinearIterationsCeil = 8 -dtNLgrowFactor = 2 -dtNLreduceFactor = 0.5 -dtNLfailureReduceFactor = 0.5 -useInitialGuessPredictor= True -stepExact = True - -femSpaces = {0:C0_AffineLinearOnSimplexWithNodalBasis} - -elementQuadrature = SimplexGaussQuadrature(nd,3) - -elementBoundaryQuadrature = SimplexGaussQuadrature(nd-1,1) - -#elementQuadrature = SimplexLobattoQuadrature(nd,1) -# -#elementBoundaryQuadrature = SimplexLobattoQuadrature(nd-1,1) - -#nn=101 -#nLevels = 4 -nn=51#3*2**2 -nLevels = 1#10-2 -#nn=3 -#nLevels = 10 - -subgridError = None -#subgridError = AdvectionDiffusionReaction_ASGS(coefficients,nd,stabFlag='2',lag=True) -#subgridError = AdvectionDiffusionReaction_ASGS(coefficients,nd,stabFlag='2',lag=False) -#subgridError = AdvectionDiffusionReactionTransientSubscales_ASGS(coefficients,nd,stabFlag='1',lag=True,trackSubScales=True,useHarariDirectly=False, -# limit_tau_t=True,tau_t_limit_max=0.9) -#subgridError = AdvectionDiffusionReactionHaukeSangalliInterpolant_ASGS(coefficients,nd,stabFlag='2',lag=True,interpolationFemSpaceType=femSpaces[0]) - -#masslumping = False -massLumping = True - -shockCapturing = None -#shockCapturing = ResGradQuad_SC(coefficients,nd,shockCapturingFactor=0.99,lag=True) -#shockCapturing = ResGradQuadDelayLag_SC(coefficients,nd,shockCapturingFactor=0.99,lag=True,nStepsToDelay=10) -#shockCapturing = JaffreGradU_SC(coefficients,nd,shockCapturingFactor=0.9,lag=True,betaPower=0.1) -#shockCapturing = ResGrad_SC(coefficients,nd,shockCapturingFactor=0.99,lag=True) -numericalFluxType = Richards_IIPG_exterior #need weak for parallel and global conservation -#numericalFluxType = Advection_DiagonalUpwind_Diffusion_IIPG_exterior #need weak for parallel and global conservation - -#multilevelNonlinearSolver = NLStarILU -#multilevelNonlinearSolver = NLGaussSeidel -#multilevelNonlinearSolver = NLJacobi -#multilevelNonlinearSolver = NLNI -#multilevelNonlinearSolver = FAS -multilevelNonlinearSolver = Newton - -#levelNonlinearSolver = FAS -if galerkin: - levelNonlinearSolver = Newton -else: - levelNonlinearSolver = Newton - #levelNonlinearSolver = ExplicitLumpedMassMatrixForRichards -#levelNonlinearSolver = ExplicitConsistentMassMatrixForRichards -#levelNonlinearSolver = NLStarILU -#levelNonlinearSolver = NLGaussSeidel -#levelNonlinearSolver = NLJacobi - -nonlinearSmoother = NLStarILU -#nonlinearSmoother = NLGaussSeidel -#nonlinearSmoother = NLJacobi - -fullNewtonFlag = True - -tolFac = 0.0 - -nl_atol_res = 1.0e-8 - -maxNonlinearIts = 100#1001 -maxLineSearches =100 - -matrix = SparseMatrix -#matrix = Numeric.array - -multilevelLinearSolver = LU -#multilevelLinearSolver = NI -#multilevelLinearSolver = Jacobi -#multilevelLinearSolver = GaussSeidel -#multilevelLinearSolver = StarILU - -#levelLinearSolver = LU -computeEigenvalues = False#True -#computeEigenvalues = False -levelLinearSolver = LU#MGM - -#linearSmoother = Jacobi -#linearSmoother = GaussSeidel -linearSmoother = StarILU - -linTolFac = 0.01 - -#conservativeFlux = {0:'pwl'} diff --git a/test/richards/adr_1d_p.py b/test/richards/adr_1d_p.py deleted file mode 100644 index d5a7fddc25..0000000000 --- a/test/richards/adr_1d_p.py +++ /dev/null @@ -1,165 +0,0 @@ -from proteus import * -from proteus.default_p import * -#from proteus.richards import Richards -from proteus.richards import ADR -nd = 1 - -L=(10.0,1.0,1.0) - -analyticalSolution = None - -viscosity = 8.9e-4 #kg/(m*s) -density = 998.2 #kg/m^3 -gravity = 9.8 #m/s^2 -beta = 0.0#density*gravity*4.524e-10 -m_per_s_by_m_per_d = 1.1574074e-5 -permeability = (5.04*m_per_s_by_m_per_d)*viscosity/(gravity*density) #m^2 -thetaS = 0.301 #- -thetaR = 0.093 #- -mvg_alpha = 5.47 #1/m -mvg_n = 4.264 -mvg_m = 1.0 - 1.0/mvg_n -lengthScale = 1.0 #m -timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) -#make non-dimensional -dimensionless_conductivity = (timeScale*density*gravity*permeability/(viscosity*lengthScale))/m_per_s_by_m_per_d -dimensionless_density = 1.0 -dimensionless_gravity = numpy.array([-1.0, - 0.0, - 0.0]) -dimensionless_alpha = mvg_alpha*lengthScale -satRichards = False -optRichards = True -nMediaTypes = 1 -alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') -nVGtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaStypes = numpy.zeros((nMediaTypes+1,),'d') -thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') -KsTypes = numpy.zeros((nMediaTypes+1,1),'d') - -for i in range(nMediaTypes+1): - alphaVGtypes[i] = mvg_alpha - nVGtypes[i] = mvg_n - thetaStypes[i] = thetaS - thetaRtypes[i] = thetaR - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity]#,dimensionless_conductivity,dimensionless_conductivity]#m/d? - -useSeepageFace = True -galerkin=True - -if galerkin: - stabilization_type=0 -else: - stabilization_type=1 -if optRichards: - LevelModelType = ADR.LevelModel - coefficients = ADR.Coefficients(nd, - KsTypes, - nVGtypes, - alphaVGtypes, - thetaRtypes, - thetaSRtypes, - gravity=dimensionless_gravity, - density=dimensionless_density, - beta=beta, - diagonal_conductivity=True, - STABILIZATION_TYPE=0, #stabilization_type, - ENTROPY_TYPE=1, - LUMPED_MASS_MATRIX=True, #False, - FCT=False, - MONOLITHIC=False, - num_fct_iter=1, - # FOR ENTROPY VISCOSITY - cE=1.0, - uL=0.0, - uR=1.0, - # FOR ARTIFICIAL COMPRESSION - cK=1.0, - # OUTPUT quantDOFs - outputQuantDOFs=False) - -elif satRichards: - coefficients = ConservativeSatRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, - gravity=dimensionless_gravity, - density=dimensionless_density, - thetaS=thetaS, - thetaR=thetaR, - alpha= dimensionless_alpha, - n = mvg_n, - m = mvg_m) -else: - coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, - gravity=dimensionless_gravity, - density=dimensionless_density, - thetaS=thetaS, - thetaR=thetaR, - alpha= dimensionless_alpha, - n = mvg_n, - m = mvg_m, - beta=beta) - -#pondingPressure=-0.1#-0.1 -#bottomPressure = -0.2#0.0 -pondingPressure= 0.1 -bottomPressure = 0.0 -pondingSaturation = 0.9 -waterTableSaturation = 0.9 -initialSaturation = 0.01 -#pondingPressure=-0.1 -if satRichards: - def getDBC_Richards_Shock(x,flag): - if x[0] == L[0]: - return lambda x,t: pondingSaturation - if x[0] == 0.0: - return lambda x,t: waterTableSaturation -else: - def getDBC_Richards_Shock(x,flag): - if x[0] == L[0]: - return lambda x,t: pondingPressure - if x[0] == 0.0: - return lambda x,t: bottomPressure - -dirichletConditions = {0:getDBC_Richards_Shock} - -if satRichards: - class ShockIC_Richards: - def uOfXT(self,x,t): - f = getDBC_Richards_Shock(x,0) - if f: - return f(x,t) - return initialSaturation -else: - class ShockIC_Richards: - def uOfXT(self,x,t): - if x[0]< L[0]/2 and x[0]>L[0]/3: - return 1.0 - else: - return 0.0 - # f = getDBC_Richards_Shock(x,0) - # if f: - # return f(x,t) - # return bottomPressure + x[0]*dimensionless_gravity[0]*dimensionless_density - #if x[0] < L[0]:#*0.5: - # return bottomPressure + x[0]*dimensionless_gravity[0]*dimensionless_density - #else: - # return pondingPressure - -initialConditions = {0:ShockIC_Richards()} - -fluxBoundaryConditions = {0:'outFlow'} - -def flux(x,flag): - return None -# if x[0] == L[0]: -# return lambda x,t: 0.0 -# if x[0] == 0.0: -# return lambda x,t: 0.0 - -advectiveFluxBoundaryConditions = {0:flux} - -diffusiveFluxBoundaryConditions = {0:{}} - -T = 1.0/timeScale -#T = 0.35/timeScale diff --git a/test/richards/adr_unit_square_2d_p.py b/test/richards/adr_unit_square_2d_p.py index b98abcb81a..31d478ff0e 100644 --- a/test/richards/adr_unit_square_2d_p.py +++ b/test/richards/adr_unit_square_2d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards nd = 2 L=(10.0,10.0,1.0) diff --git a/test/richards/bio2d_FCT/bio2d_convergence_p.py b/test/richards/bio2d_FCT/bio2d_convergence_p.py index 6621944252..38587cccb1 100644 --- a/test/richards/bio2d_FCT/bio2d_convergence_p.py +++ b/test/richards/bio2d_FCT/bio2d_convergence_p.py @@ -1,317 +1,317 @@ -from proteus import * -from proteus.default_p import * -from proteus.richards import Richards - -nd = 2 - -L=[3.0,5.0,1.0] - - -regularGrid=False - -domain = Domain.PlanarStraightLineGraphDomain() -boundaries=['bottom','top','left','right', - 'swale', - 'drain'] - -boundaryTags=dict([(key,i+1) for (i,key) in enumerate(boundaries)]) - -vertices=[[0.0,0.0], #0 - [0.0,3.0], #1 - [3.0,3.0 ], #2 - [3.0, 0.0], #3 - [3.0,5.0], # 4 - [0.0 ,5.0], #5 - [0.5, 3.0], #6 - [2.5, 3.0], #7 - [2.0, 1.0],#8 - [1.0, 1.0],#9 - [1.2, 1.9],#10 - [1.7, 1.9],#11 - [1.7, 1.4], #12 - [1.2, 1.4],#13 - ] - -vertexFlags=[boundaryTags['bottom'], #0 - boundaryTags['left'], #1 - boundaryTags['right'], #2 - boundaryTags['bottom'], #3 - boundaryTags['top'], #4 - boundaryTags['left'], #5 - boundaryTags['swale'], #6 - boundaryTags['swale'], #7 - boundaryTags['swale'], #8 - boundaryTags['swale'], #9 - boundaryTags['drain'], #10 - boundaryTags['drain'], #11 - boundaryTags['drain'], #12 - boundaryTags['drain'], #13 - ] - - -segments =[[0,1], #0 - [1,2], #1 - [2,3], #2 - [3,0], #3 - [2,4], #4 - [4,5], #5 - [5,1], #6 - [6,7], #7 - [7,8], #8 - [8,9], #9 - [9,6], #10 - [10,11], #11 - [11,12], #12 - [12,13], #13 - [13,10]] #14 - - -segmentFlags=[boundaryTags['left'], #0 - boundaryTags['swale'], #1 - boundaryTags['right'], #2 - boundaryTags['bottom'], #3 - boundaryTags['right'], #4 - boundaryTags['top'], #5 - boundaryTags['left'], #6 - - boundaryTags['swale'], #7 - boundaryTags['swale'], #8 - boundaryTags['swale'], #9 - boundaryTags['swale'], #10 - - - boundaryTags['drain'], #11 - boundaryTags['drain'], #12 - boundaryTags['drain'], #13 - boundaryTags['drain'], #14 - ] - -holes= [[1.5,1.5]] -#regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5], [1.5,0.5]] -#regionFlags=[1,2,3,4] -regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5]]#, [1.5,0.5]] -regionFlags=[1,2,3] - -domain = Domain.PlanarStraightLineGraphDomain(vertices= vertices, - vertexFlags=vertexFlags, - segments=segments, - segmentFlags=segmentFlags, - regions = regions, - regionFlags = regionFlags, - holes= holes) - - -#dplt.plot_pslg_domain(polygon) - - -if not regularGrid: - domain.writePoly('bio2d_N') - domain = Domain.PlanarStraightLineGraphDomain('bio2d_N') - -#domain.polyfile="bio2d_n_coarse" - -analyticalSolution = None - -viscosity = 8.9e-4 #kg/(m*s) -density = 998.2 #kg/m^3 -gravity = 9.8 #m/s^2 -beta = 0.0 #density*gravity*4.524e-10 -m_per_s_by_m_per_d = 1.1574074e-5 -lengthScale = 1.0 #m -timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) -#make non-dimensional - -# Storage Zone -permeability3 = (5.0)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS3 = 0.4 #- -thetaR3 = 0.05 #- -mvg_alpha3 = 8 #1/m -mvg_n3 = 2.4 -mvg_m3 = 1.0 - 1.0/mvg_n3 -dimensionless_conductivity3 = (timeScale*density*gravity*permeability3/(viscosity*lengthScale)) - -#Bioswale Zone -permeability2 = (7.128)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS2 = 0.43 #- -thetaR2 = 0.045 #- -mvg_alpha2 = 14.5 #1/m -mvg_n2 = 2.68 -mvg_m2 = 1.0 - 1.0/mvg_n2 -dimensionless_conductivity2 = (timeScale*density*gravity*permeability2/(viscosity*lengthScale)) - -#base -permeability1 = (1.06)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS1 = 0.41 #- -thetaR1 = 0.065 #- -mvg_alpha1 = 7.5 #1/m -mvg_n1 = 1.89 -mvg_m1 = 1.0 - 1.0/mvg_n1 -dimensionless_conductivity1 = (timeScale*density*gravity*permeability1/(viscosity*lengthScale)) -#pipe -#permeability4 = (8.03*m_per_s_by_m_per_d)*viscosity/(gravity*density) #m^2 -#thetaS4 = 0.43 #- -#thetaR4 = 0.045 #- -#mvg_alpha4 = 20 #1/m -#mvg_n4 = 3 -#mvg_m4 = 1.0 - 1.0/mvg_n4 -#dimensionless_conductivity4 = (timeScale*density*gravity*permeability4/(viscosity*lengthScale)) - - - -#print 'Ks',dimensionless_conductivity -dimensionless_density = 1.0 -dimensionless_gravity = numpy.array([0.0, - -1.0, - 0.0]) -#dimensionless_alpha = mvg_alpha*lengthScale -nMediaTypes = 3 -alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') -nVGtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaStypes = numpy.zeros((nMediaTypes+1,),'d') -thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') -KsTypes = numpy.zeros((nMediaTypes+1,2),'d') - -for i in range(nMediaTypes+1): - if i==1: - alphaVGtypes[i] = mvg_alpha1 - nVGtypes[i] = mvg_n1 - thetaStypes[i] = thetaS1 - thetaRtypes[i] = thetaR1 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? - elif i==2: - alphaVGtypes[i] = mvg_alpha2 - nVGtypes[i] = mvg_n2 - thetaStypes[i] = thetaS2 - thetaRtypes[i] = thetaR2 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity2,dimensionless_conductivity2]#m/d? - - elif i==3: - alphaVGtypes[i] = mvg_alpha3 - nVGtypes[i] = mvg_n3 - thetaStypes[i] = thetaS3 - thetaRtypes[i] = thetaR3 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity3,dimensionless_conductivity3]#m/d? - #else: - # alphaVGtypes[i] = mvg_alpha4 - # nVGtypes[i] = mvg_n4 - # thetaStypes[i] = thetaS4 - # thetaRtypes[i] = thetaR4 - # thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - # KsTypes[i,:] = [dimensionless_conductivity4,dimensionless_conductivity4]#m/d? - -galerkin = False -useSeepageFace = True - -def getSeepageFace(flag): - if useSeepageFace: - if flag == boundaryTags['drain']: - return 1 - else: - return 0 - else: - return 0 - - - - -LevelModelType = Richards.LevelModel -coefficients = Richards.Coefficients(nd, - KsTypes, - nVGtypes, - alphaVGtypes, - thetaRtypes, - thetaSRtypes, - gravity=dimensionless_gravity, - density=dimensionless_density, - beta=0.0001, - diagonal_conductivity=True, - STABILIZATION_TYPE=2, - ENTROPY_TYPE=1, - LUMPED_MASS_MATRIX= False , - FCT=True, #False ,#True, - num_fct_iter=0, - # FOR ENTROPY VISCOSITY - cE=1.0, - uL=0.0, - uR=1.0, - # FOR ARTIFICIAL COMPRESSION - cK=1.0, - # OUTPUT quantDOFs - outputQuantDOFs=False, - getSeepageFace=getSeepageFace) -#galerkin = False - -#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, -# gravity=dimensionless_gravity, -# density=dimensionless_density, -# thetaS=thetaS, -# thetaR=thetaR, -# alpha= dimensionless_alpha, -# n = mvg_n, -# m = mvg_m, -# beta = beta) - - -#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, -# gravity=dimensionless_gravity, -# density=dimensionless_density, -# thetaS=thetaStypes, -# thetaR=thetaRtypes, -# alpha= alphaVGtypes, -# n = mvg_n, -# m = mvg_m, -# beta = beta)# - -#G= [1.8, 1.2,1] - -galerkin = False - -G=[3.0,5.0,1.0] - -pondingPressure= 0.5 - -def getDBC_2D_Richards_Shock(x,flag): - if x[1] == G[1]: - if (x[0] >= G[0]/3.0 and - x[0] <= 2.0*G[0]/3.0): - return lambda x,t: pondingPressure - if x[1] == 0.0: - return lambda x,t: 0.0 - if (x[0] == 0.0 or - x[0] == G[0]): - return lambda x,t: x[1]*dimensionless_gravity[1]*dimensionless_density - # if flag=="drain": - # return lambda x,t: 0.0 - -dirichletConditions = {0:getDBC_2D_Richards_Shock} - -class ShockIC_2D_Richards: - def uOfXT(self,x,t): - bc=getDBC_2D_Richards_Shock(x,0) - if bc != None: - return bc(x,t) - else: - return x[1]*dimensionless_gravity[1]*dimensionless_density - -initialConditions = {0:ShockIC_2D_Richards()} - -fluxBoundaryConditions = {0:'noFlow'} - -def getFBC_2D_Richards_Shock(x,flag): - if x[1] == G[1]: - if (x[0] < G[0]/3.0 or - x[0] > 2.0*G[0]/3.0): - return lambda x,t: 0.0 - -advectiveFluxBoundaryConditions = {0:getFBC_2D_Richards_Shock} - -diffusiveFluxBoundaryConditions = {0:{0:getFBC_2D_Richards_Shock}} - -T = 0.3/timeScale +from proteus import * +from proteus.default_p import * +from proteus.kernels import Richards + +nd = 2 + +L=[3.0,5.0,1.0] + + +regularGrid=False + +domain = Domain.PlanarStraightLineGraphDomain() +boundaries=['bottom','top','left','right', + 'swale', + 'drain'] + +boundaryTags=dict([(key,i+1) for (i,key) in enumerate(boundaries)]) + +vertices=[[0.0,0.0], #0 + [0.0,3.0], #1 + [3.0,3.0 ], #2 + [3.0, 0.0], #3 + [3.0,5.0], # 4 + [0.0 ,5.0], #5 + [0.5, 3.0], #6 + [2.5, 3.0], #7 + [2.0, 1.0],#8 + [1.0, 1.0],#9 + [1.2, 1.9],#10 + [1.7, 1.9],#11 + [1.7, 1.4], #12 + [1.2, 1.4],#13 + ] + +vertexFlags=[boundaryTags['bottom'], #0 + boundaryTags['left'], #1 + boundaryTags['right'], #2 + boundaryTags['bottom'], #3 + boundaryTags['top'], #4 + boundaryTags['left'], #5 + boundaryTags['swale'], #6 + boundaryTags['swale'], #7 + boundaryTags['swale'], #8 + boundaryTags['swale'], #9 + boundaryTags['drain'], #10 + boundaryTags['drain'], #11 + boundaryTags['drain'], #12 + boundaryTags['drain'], #13 + ] + + +segments =[[0,1], #0 + [1,2], #1 + [2,3], #2 + [3,0], #3 + [2,4], #4 + [4,5], #5 + [5,1], #6 + [6,7], #7 + [7,8], #8 + [8,9], #9 + [9,6], #10 + [10,11], #11 + [11,12], #12 + [12,13], #13 + [13,10]] #14 + + +segmentFlags=[boundaryTags['left'], #0 + boundaryTags['swale'], #1 + boundaryTags['right'], #2 + boundaryTags['bottom'], #3 + boundaryTags['right'], #4 + boundaryTags['top'], #5 + boundaryTags['left'], #6 + + boundaryTags['swale'], #7 + boundaryTags['swale'], #8 + boundaryTags['swale'], #9 + boundaryTags['swale'], #10 + + + boundaryTags['drain'], #11 + boundaryTags['drain'], #12 + boundaryTags['drain'], #13 + boundaryTags['drain'], #14 + ] + +holes= [[1.5,1.5]] +#regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5], [1.5,0.5]] +#regionFlags=[1,2,3,4] +regions=[[0.1,0.1], [1.5, 2.5], [1.5, 4.5]]#, [1.5,0.5]] +regionFlags=[1,2,3] + +domain = Domain.PlanarStraightLineGraphDomain(vertices= vertices, + vertexFlags=vertexFlags, + segments=segments, + segmentFlags=segmentFlags, + regions = regions, + regionFlags = regionFlags, + holes= holes) + + +#dplt.plot_pslg_domain(polygon) + + +if not regularGrid: + domain.writePoly('bio2d_N') + domain = Domain.PlanarStraightLineGraphDomain('bio2d_N') + +#domain.polyfile="bio2d_n_coarse" + +analyticalSolution = None + +viscosity = 8.9e-4 #kg/(m*s) +density = 998.2 #kg/m^3 +gravity = 9.8 #m/s^2 +beta = 0.0 #density*gravity*4.524e-10 +m_per_s_by_m_per_d = 1.1574074e-5 +lengthScale = 1.0 #m +timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) +#make non-dimensional + +# Storage Zone +permeability3 = (5.0)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS3 = 0.4 #- +thetaR3 = 0.05 #- +mvg_alpha3 = 8 #1/m +mvg_n3 = 2.4 +mvg_m3 = 1.0 - 1.0/mvg_n3 +dimensionless_conductivity3 = (timeScale*density*gravity*permeability3/(viscosity*lengthScale)) + +#Bioswale Zone +permeability2 = (7.128)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS2 = 0.43 #- +thetaR2 = 0.045 #- +mvg_alpha2 = 14.5 #1/m +mvg_n2 = 2.68 +mvg_m2 = 1.0 - 1.0/mvg_n2 +dimensionless_conductivity2 = (timeScale*density*gravity*permeability2/(viscosity*lengthScale)) + +#base +permeability1 = (1.06)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS1 = 0.41 #- +thetaR1 = 0.065 #- +mvg_alpha1 = 7.5 #1/m +mvg_n1 = 1.89 +mvg_m1 = 1.0 - 1.0/mvg_n1 +dimensionless_conductivity1 = (timeScale*density*gravity*permeability1/(viscosity*lengthScale)) +#pipe +#permeability4 = (8.03*m_per_s_by_m_per_d)*viscosity/(gravity*density) #m^2 +#thetaS4 = 0.43 #- +#thetaR4 = 0.045 #- +#mvg_alpha4 = 20 #1/m +#mvg_n4 = 3 +#mvg_m4 = 1.0 - 1.0/mvg_n4 +#dimensionless_conductivity4 = (timeScale*density*gravity*permeability4/(viscosity*lengthScale)) + + + +#print 'Ks',dimensionless_conductivity +dimensionless_density = 1.0 +dimensionless_gravity = numpy.array([0.0, + -1.0, + 0.0]) +#dimensionless_alpha = mvg_alpha*lengthScale +nMediaTypes = 3 +alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') +nVGtypes = numpy.zeros((nMediaTypes+1,),'d') +thetaStypes = numpy.zeros((nMediaTypes+1,),'d') +thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') +thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') +KsTypes = numpy.zeros((nMediaTypes+1,2),'d') + +for i in range(nMediaTypes+1): + if i==1: + alphaVGtypes[i] = mvg_alpha1 + nVGtypes[i] = mvg_n1 + thetaStypes[i] = thetaS1 + thetaRtypes[i] = thetaR1 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? + elif i==2: + alphaVGtypes[i] = mvg_alpha2 + nVGtypes[i] = mvg_n2 + thetaStypes[i] = thetaS2 + thetaRtypes[i] = thetaR2 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity2,dimensionless_conductivity2]#m/d? + + elif i==3: + alphaVGtypes[i] = mvg_alpha3 + nVGtypes[i] = mvg_n3 + thetaStypes[i] = thetaS3 + thetaRtypes[i] = thetaR3 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity3,dimensionless_conductivity3]#m/d? + #else: + # alphaVGtypes[i] = mvg_alpha4 + # nVGtypes[i] = mvg_n4 + # thetaStypes[i] = thetaS4 + # thetaRtypes[i] = thetaR4 + # thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + # KsTypes[i,:] = [dimensionless_conductivity4,dimensionless_conductivity4]#m/d? + +galerkin = False +useSeepageFace = True + +def getSeepageFace(flag): + if useSeepageFace: + if flag == boundaryTags['drain']: + return 1 + else: + return 0 + else: + return 0 + + + + +LevelModelType = Richards.LevelModel +coefficients = Richards.Coefficients(nd, + KsTypes, + nVGtypes, + alphaVGtypes, + thetaRtypes, + thetaSRtypes, + gravity=dimensionless_gravity, + density=dimensionless_density, + beta=0.0001, + diagonal_conductivity=True, + STABILIZATION_TYPE=2, + ENTROPY_TYPE=1, + LUMPED_MASS_MATRIX= False , + FCT=True, #False ,#True, + num_fct_iter=0, + # FOR ENTROPY VISCOSITY + cE=1.0, + uL=0.0, + uR=1.0, + # FOR ARTIFICIAL COMPRESSION + cK=1.0, + # OUTPUT quantDOFs + outputQuantDOFs=False, + getSeepageFace=getSeepageFace) +#galerkin = False + +#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, +# gravity=dimensionless_gravity, +# density=dimensionless_density, +# thetaS=thetaS, +# thetaR=thetaR, +# alpha= dimensionless_alpha, +# n = mvg_n, +# m = mvg_m, +# beta = beta) + + +#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, +# gravity=dimensionless_gravity, +# density=dimensionless_density, +# thetaS=thetaStypes, +# thetaR=thetaRtypes, +# alpha= alphaVGtypes, +# n = mvg_n, +# m = mvg_m, +# beta = beta)# + +#G= [1.8, 1.2,1] + +galerkin = False + +G=[3.0,5.0,1.0] + +pondingPressure= 0.5 + +def getDBC_2D_Richards_Shock(x,flag): + if x[1] == G[1]: + if (x[0] >= G[0]/3.0 and + x[0] <= 2.0*G[0]/3.0): + return lambda x,t: pondingPressure + if x[1] == 0.0: + return lambda x,t: 0.0 + if (x[0] == 0.0 or + x[0] == G[0]): + return lambda x,t: x[1]*dimensionless_gravity[1]*dimensionless_density + # if flag=="drain": + # return lambda x,t: 0.0 + +dirichletConditions = {0:getDBC_2D_Richards_Shock} + +class ShockIC_2D_Richards: + def uOfXT(self,x,t): + bc=getDBC_2D_Richards_Shock(x,0) + if bc != None: + return bc(x,t) + else: + return x[1]*dimensionless_gravity[1]*dimensionless_density + +initialConditions = {0:ShockIC_2D_Richards()} + +fluxBoundaryConditions = {0:'noFlow'} + +def getFBC_2D_Richards_Shock(x,flag): + if x[1] == G[1]: + if (x[0] < G[0]/3.0 or + x[0] > 2.0*G[0]/3.0): + return lambda x,t: 0.0 + +advectiveFluxBoundaryConditions = {0:getFBC_2D_Richards_Shock} + +diffusiveFluxBoundaryConditions = {0:{0:getFBC_2D_Richards_Shock}} + +T = 0.3/timeScale diff --git a/test/richards/hornung_messing/hm_2d_p.py b/test/richards/hornung_messing/hm_2d_p.py index 9bc899838b..dd7990b5e8 100644 --- a/test/richards/hornung_messing/hm_2d_p.py +++ b/test/richards/hornung_messing/hm_2d_p.py @@ -13,7 +13,7 @@ """ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from proteus import Context ct = Context.Options([ diff --git a/test/richards/re_gl_6_3d_p.py b/test/richards/re_gl_6_3d_p.py index fa90184ee4..2a0a67144d 100644 --- a/test/richards/re_gl_6_3d_p.py +++ b/test/richards/re_gl_6_3d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import os nd=3 diff --git a/test/richards/re_vgm_sand_10m_1d_p.py b/test/richards/re_vgm_sand_10m_1d_p.py index 2fe5599bbb..b0e19ff963 100644 --- a/test/richards/re_vgm_sand_10m_1d_p.py +++ b/test/richards/re_vgm_sand_10m_1d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards opts= Context.Options([ ('num','fct',"numerics: num = fct, low-order, galerkin, low-order-galerkin, vms-galerkin, vms-sc-galerkin"), diff --git a/test/richards/re_vgm_sand_10x10m_2d_p.py b/test/richards/re_vgm_sand_10x10m_2d_p.py index d01545d155..7d49ee64a6 100644 --- a/test/richards/re_vgm_sand_10x10m_2d_p.py +++ b/test/richards/re_vgm_sand_10x10m_2d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards nd = 2 L=(10.0,10.0,1.0) diff --git a/test/richards/re_vgm_sand_10x10x10_3d_p.py b/test/richards/re_vgm_sand_10x10x10_3d_p.py index 92b8355eb8..97eaa02c93 100644 --- a/test/richards/re_vgm_sand_10x10x10_3d_p.py +++ b/test/richards/re_vgm_sand_10x10x10_3d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards nd = 3 L=(3.0,3.0,3.0) diff --git a/test/richards/test_1/re_vgm_sand_10m_1d_p.py b/test/richards/test_1/re_vgm_sand_10m_1d_p.py index d93b71c818..22597d1db5 100755 --- a/test/richards/test_1/re_vgm_sand_10m_1d_p.py +++ b/test/richards/test_1/re_vgm_sand_10m_1d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from proteus import Context # Scheme selection. The defaults are the FCT scheme; the other two are diff --git a/test/richards/test_2_HYDRUS/re_vgm_sand_10m_1d_p.py b/test/richards/test_2_HYDRUS/re_vgm_sand_10m_1d_p.py index 81eefc4c7b..9bc1022843 100755 --- a/test/richards/test_2_HYDRUS/re_vgm_sand_10m_1d_p.py +++ b/test/richards/test_2_HYDRUS/re_vgm_sand_10m_1d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from proteus import Context # Scheme selection. The defaults are the FCT scheme; the other one is diff --git a/test/richards/test_3/re_vgm_sand_10m_1d_p.py b/test/richards/test_3/re_vgm_sand_10m_1d_p.py index 5249718cc7..53dbd2ba32 100755 --- a/test/richards/test_3/re_vgm_sand_10m_1d_p.py +++ b/test/richards/test_3/re_vgm_sand_10m_1d_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from proteus import Context # Scheme selection. The defaults are the FCT scheme; the other one is diff --git a/test/richards_first_step_mass_compare.py b/test/richards_first_step_mass_compare.py index 8a44c6c92a..663b86e552 100644 --- a/test/richards_first_step_mass_compare.py +++ b/test/richards_first_step_mass_compare.py @@ -48,8 +48,8 @@ def load(p): return np.load(p) tree = os.path.dirname(os.path.dirname(proteus.__file__)) sys.path.insert(0, os.path.join(tree, 'test', 'salinity')) import test_vdft_compatible as T -from proteus.mprans import TADR -from proteus.richards import Richards +from proteus.kernels import TADR +from proteus.kernels import Richards from proteus import NumericalSolution, NonlinearSolvers if not refresh: Richards.LevelModel.refreshOldTimeMass = lambda self: None diff --git a/test/richards_instr.py b/test/richards_instr.py index aec242c54d..afd92d47a3 100644 --- a/test/richards_instr.py +++ b/test/richards_instr.py @@ -208,8 +208,8 @@ def newton_iteration_hint(): def install(): from proteus import LinearSolvers, NonlinearSolvers - from proteus.richards import Richards - from proteus.mprans import TADR + from proteus.kernels import Richards + from proteus.kernels import TADR for mod in (Richards, TADR): LM = mod.LevelModel diff --git a/test/salinity/Bioswale_contamination/Raingarden_p.py b/test/salinity/Bioswale_contamination/Raingarden_p.py index 5a2cde22d5..05e94e3dd4 100644 --- a/test/salinity/Bioswale_contamination/Raingarden_p.py +++ b/test/salinity/Bioswale_contamination/Raingarden_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from domain_rg import * analyticalSolution = None diff --git a/test/salinity/Bioswale_contamination/domain_rg.py b/test/salinity/Bioswale_contamination/domain_rg.py index 8914ab4a78..2701198d46 100644 --- a/test/salinity/Bioswale_contamination/domain_rg.py +++ b/test/salinity/Bioswale_contamination/domain_rg.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import math nd = 2 diff --git a/test/salinity/Bioswale_contamination/start_new/Raingarden_p.py b/test/salinity/Bioswale_contamination/start_new/Raingarden_p.py index ebdae70d56..6e322a70d4 100644 --- a/test/salinity/Bioswale_contamination/start_new/Raingarden_p.py +++ b/test/salinity/Bioswale_contamination/start_new/Raingarden_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from domain_rg import * analyticalSolution = None diff --git a/test/salinity/Bioswale_contamination/start_new/domain_rg.py b/test/salinity/Bioswale_contamination/start_new/domain_rg.py index 8914ab4a78..2701198d46 100644 --- a/test/salinity/Bioswale_contamination/start_new/domain_rg.py +++ b/test/salinity/Bioswale_contamination/start_new/domain_rg.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import math nd = 2 diff --git a/test/salinity/Bioswale_contamination/start_new/tranport_p.py b/test/salinity/Bioswale_contamination/start_new/tranport_p.py index a6de1c97dd..d288bc2e4f 100644 --- a/test/salinity/Bioswale_contamination/start_new/tranport_p.py +++ b/test/salinity/Bioswale_contamination/start_new/tranport_p.py @@ -9,7 +9,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR from proteus.Profiling import logEvent diff --git a/test/salinity/Bioswale_contamination/tranport_p.py b/test/salinity/Bioswale_contamination/tranport_p.py index 37076aa9a5..ba73cbc86d 100644 --- a/test/salinity/Bioswale_contamination/tranport_p.py +++ b/test/salinity/Bioswale_contamination/tranport_p.py @@ -9,7 +9,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR from proteus.Profiling import logEvent diff --git a/test/salinity/Goswami/CCS_p.py b/test/salinity/Goswami/CCS_p.py index 707625dccf..e9dba0e226 100644 --- a/test/salinity/Goswami/CCS_p.py +++ b/test/salinity/Goswami/CCS_p.py @@ -1,310 +1,310 @@ -from proteus import * -from proteus.default_p import * -from proteus.richards import Richards -import numpy as np - -nd = 2 - -#L= [] - -#L=[3.0,5.0,1.0] -# parallel partitioning info # -from proteus import MeshTools -partitioningType = MeshTools.MeshParallelPartitioningTypes.node -L=(.530,.26,1)#.26 -nd = 2 - -nnx =107#213#107 -nny =53#105#53#53# 105 - -#unstructured=ct.unstructured #True for tetgen, false for tet or hex from rectangular grid - - -domain = Domain.RectangularDomain(L=[L[0],L[1]],name="gwvd_gc_domain",units="m") -polyfile="gwvd_gc_domain_2d" -domain.writePoly(polyfile) -triangleOptions = "q30Dena0.00001" - - - -domain.MeshOptions.nnx = nnx -domain.MeshOptions.nny = nny -domain.MeshOptions.triangleFlag=0 - -regularGrid=False - - -#domain.polyfile="bio2d_n_coarse" -#domain.polyfile="ImageToStl.com_fflower-tc_n" -analyticalSolution = None - -viscosity = 8.9e-4 #kg/(m*s) -density = 998.2 #kg/m^3 -gravity = 9.8 #m/s^2 -beta = 0.0 #density*gravity*4.524e-10 -m_per_s_by_m_per_d = 1.1574074e-5 -lengthScale = 1.0 #m -timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) -#make non-dimensional - -#base -permeability1 = (1.2410491586180303e-09)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS1 = 0.4 #- -thetaR1 = 0.05 #- -mvg_alpha1 = 8.0 #1/m -mvg_n1 = 2.4 -mvg_m1 = 1.0 - 1.0/mvg_n1 -dimensionless_conductivity1 = (timeScale*density*gravity*permeability1/(viscosity*lengthScale)) - -#print 'Ks',dimensionless_conductivity -dimensionless_density = 1.0 -dimensionless_gravity = np.array([0.0, - -1.0, - 0.0]) -#dimensionless_alpha = mvg_alpha*lengthScale -nMediaTypes = 1 -alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') -nVGtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaStypes = numpy.zeros((nMediaTypes+1,),'d') -thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') -KsTypes = numpy.zeros((nMediaTypes+1,2),'d') - -for i in range(nMediaTypes+1): - if i==1: - alphaVGtypes[i] = mvg_alpha1 - nVGtypes[i] = mvg_n1 - thetaStypes[i] = thetaS1 - thetaRtypes[i] = thetaR1 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? - else: - alphaVGtypes[i] = mvg_alpha1 - nVGtypes[i] = mvg_n1 - thetaStypes[i] = thetaS1 - thetaRtypes[i] = thetaR1 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? - -galerkin = False -#useSeepageFace = True - -#def getSeepageFace(flag): -# if useSeepageFace: -# if flag == boundaryTags['drain']: -# return 1 -# else: -# return 0 -# else: -# return 0 - - - - -LevelModelType = Richards.LevelModel -coefficients = Richards.Coefficients(nd, - KsTypes, - nVGtypes, - alphaVGtypes, - thetaRtypes, - thetaSRtypes, - gravity=dimensionless_gravity, - density=dimensionless_density, - beta=0.0001, - diagonal_conductivity=True, - STABILIZATION_TYPE=2, #0, - ENTROPY_TYPE=1, - LUMPED_MASS_MATRIX= False , - FCT=False ,#True, - num_fct_iter=0, - # FOR ENTROPY VISCOSITY - cE=1.0, - uL=0.0, - uR=1.0, - # FOR ARTIFICIAL COMPRESSION - cK=1.0, - # OUTPUT quantDOFs - outputQuantDOFs=False)#, - -#recoeffs= coefficients - #getSeepageFace=getSeepageFace) -#galerkin = False - -#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, -# gravity=dimensionless_gravity, -# density=dimensionless_density, -# thetaS=thetaS, -# thetaR=thetaR, -# alpha= dimensionless_alpha, -# n = mvg_n, -# m = mvg_m, -# beta = beta) - - -#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, -# gravity=dimensionless_gravity, -# density=dimensionless_density, -# thetaS=thetaStypes, -# thetaR=thetaRtypes, -# alpha= alphaVGtypes, -# n = mvg_n, -# m = mvg_m, -# beta = beta)# - -#G= [1.8, 1.2,1] -#domain.writePLY('CCS') -galerkin = False - -#G=[2.799999952316284,1.4950000047683716] -L=[.530,.26,1] -# Density Relation -rho_fw = 998.2#1000 # density of freshwater -rho_sw =1026.10 # density of saltwater- corresponds to conc=37.1kg/m3 -mf_fw = 0.0 # saline mass fraction, freshwater -mf_sw = 1.0# .0357 # saline mass fraction, saltwater -epsilon =(rho_sw - rho_fw)/rho_fw -drho_dmf =epsilon*rho_fw #700. #epsilon*rho_fw # density change with mass fraction - -#pondingPressure= 0.5 -#For SS-1: 26.7 cm, SS-2: 26.55 cm, SS-3: 26.2 cm -h_ss1=.267 # Head for intruding steady state -h_ss3=.2655 # Head for intermediate steady state -h_ss2=.262 # Head for receding steady state -h_saltwater=.255 # -def head_ramp_intruding(x,t): - if (t<=5000): - return h_ss1 - elif (t>5000): - return h_ss2 #h_ss2 - -def head_ramp_receding(x,t): - if (t<=11000): - return h_ss2 - elif (t>11000): - return h_ss2 #h_ss2 -# Dirichlet -# def getHeadDirichletBCs_SS(x,tag): # Need to fix this -- should be h_s=25.5 cm at top -# if (abs(x[0])<1.e-8 and x[1]<=0.255): -# #return lambda x,t: x[1] + (1.0+epsilon*mf_sw)*(h_saltwater-x[1]) -# return lambda x,t: h_saltwater + epsilon*(h_saltwater-x[1]) -# elif (abs(x[0]-L[0])< 1.e-8): -# return lambda x,t: h_ss1 -# else: -# pass - -def getHeadDirichletBCs_SS(x, tag): - if abs(x[0]) < 1.e-8 and x[1] <= 0.255: # Left boundary (Saltwater region) - # Apply hydrostatic adjustment for saltwater region - return lambda x, t: h_saltwater + epsilon * (h_saltwater - x[1]) - elif abs(x[0] - L[0]) < 1.e-8: # Right boundary (Freshwater region) - # Set constant head for the freshwater side at steady-state level SS1 - return lambda x, t: h_ss1 - else: - # Return None for areas without Dirichlet boundary conditions - return None - -def getHeadDirichletBCs_Receding(x,tag): - if (abs(x[0])<1.e-8 and x[1]<=0.255): - return lambda x,t: x[1] + (1.0+epsilon*mf_sw)*(h_saltwater-x[1]) - elif (abs(x[0]-L[0])< 1.e-8): - return lambda x,t: head_ramp_receding(x,t) - else: - pass - -def getHeadDirichletBCs_Intruding(x,tag): # Need to fix this -- should be h_s=25.5 cm at top - if (abs(x[0])<1.e-8 and x[1]<=0.255): - return lambda x,t: x[1] + (1.0+epsilon*mf_sw)*(.255-x[1]) - elif (abs(x[0]-L[0])< 1.e-8): - return lambda x,t: head_ramp_intruding(x,t) - else: - pass - - -dirichletConditions = {0:getHeadDirichletBCs_SS} - - -# class hydrostaticIC: -# def __init__(self,val = 0.3): -# self.val = val -# def uOfXT(self,x,t): -# return x[1] + (L[1]-x[1])*(1.0+epsilon*self.val) #x[1] -# def uOfX(self,x,t): -# return x[1] + (L[1]-x[1])*(1.0+epsilon*self.val) -class hydrostaticIC: - def __init__(self, h_saltwater=0.255, h_freshwater=0.267, epsilon=0.028): - """ - Initializes the hydrostatic initial condition. - :param h_saltwater: Saltwater head (m) at the left boundary. - :param h_freshwater: Freshwater head (m) at the right boundary. - :param epsilon: Density ratio adjustment between saltwater and freshwater. - """ - self.h_saltwater = h_saltwater # Saltwater head - self.h_freshwater = h_freshwater # Freshwater head - self.epsilon = epsilon # Density adjustment factor - - def uOfXT(self, x, t): - """ - Computes the hydraulic head or hydrostatic pressure based on the region. - :param x: [x, y] coordinate of the point. - :param t: Time (not used for initial conditions). - :return: Initial hydraulic head or hydrostatic pressure. - """ - if x[1] <= self.h_saltwater: # Saltwater region (below interface) - # Saltwater hydrostatic pressure - return self.h_saltwater + self.epsilon * (self.h_saltwater - x[1]) - else: # Freshwater region (above interface) - # Freshwater hydraulic head - return self.h_freshwater - x[1] - - def uOfX(self, x, t): - """ - Wrapper for uOfXT to compute values without time dependency. - """ - return self.uOfXT(x, t) - -# class hydrostaticIC: -# def __init__(self, val=0.3, h_saltwater=0.255): -# self.val = val -# self.h_saltwater = h_saltwater - -# def uOfXT(self, x, t): -# if x[1] <= self.h_saltwater: # Saltwater region -# return self.h_saltwater + (self.h_saltwater - x[1]) * (1.0 + epsilon * self.val) -# else: # Freshwater region -# return x[1] # Adjust based on the freshwater condition (e.g., head or elevation) - -# def uOfX(self, x, t): -# return self.uOfXT(x, t) - -# class ShockIC_2D_Richards: -# def uOfXT(self,x,t): -# bc=getDBC_2D_Richards_Shock(x,0) -# if bc != None: -# return bc(x,t) -# else: -# return 0.0 #x[1]*dimensionless_gravity[1]*dimensionless_density - -initialConditions = {0:hydrostaticIC()} - -fluxBoundaryConditions = {0:'noFlow'} - -def getFlowDiffusiveFluxBCs(x,tag): - if ((x[0]>=1.e-8 and abs(x[0]-L[0]) > 1.e-8) and (x[1] < 1.e-8 or abs(x[1]-L[1])<1.e-8)): - return lambda x,t: 0.0 - elif (abs(x[0])<1.e-8 and x[1]>0.255): - return lambda x,t: 0.0 - else: - pass - -def getFlowAdvectiveFluxBCs(x,tag): - if ((x[0]>= 1.e-8 and abs(x[0]-L[0])>1.e-8) and (x[1] < 1.e-8 or abs(x[1]- L[1])<1.e-8)): - return lambda x,t: 0.0 - else: - pass - -advectiveFluxBoundaryConditions = {0:getFlowDiffusiveFluxBCs} - -diffusiveFluxBoundaryConditions = {0:{0:getFlowDiffusiveFluxBCs}} - -#T = 0.0003/timeScale +from proteus import * +from proteus.default_p import * +from proteus.kernels import Richards +import numpy as np + +nd = 2 + +#L= [] + +#L=[3.0,5.0,1.0] +# parallel partitioning info # +from proteus import MeshTools +partitioningType = MeshTools.MeshParallelPartitioningTypes.node +L=(.530,.26,1)#.26 +nd = 2 + +nnx =107#213#107 +nny =53#105#53#53# 105 + +#unstructured=ct.unstructured #True for tetgen, false for tet or hex from rectangular grid + + +domain = Domain.RectangularDomain(L=[L[0],L[1]],name="gwvd_gc_domain",units="m") +polyfile="gwvd_gc_domain_2d" +domain.writePoly(polyfile) +triangleOptions = "q30Dena0.00001" + + + +domain.MeshOptions.nnx = nnx +domain.MeshOptions.nny = nny +domain.MeshOptions.triangleFlag=0 + +regularGrid=False + + +#domain.polyfile="bio2d_n_coarse" +#domain.polyfile="ImageToStl.com_fflower-tc_n" +analyticalSolution = None + +viscosity = 8.9e-4 #kg/(m*s) +density = 998.2 #kg/m^3 +gravity = 9.8 #m/s^2 +beta = 0.0 #density*gravity*4.524e-10 +m_per_s_by_m_per_d = 1.1574074e-5 +lengthScale = 1.0 #m +timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) +#make non-dimensional + +#base +permeability1 = (1.2410491586180303e-09)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS1 = 0.4 #- +thetaR1 = 0.05 #- +mvg_alpha1 = 8.0 #1/m +mvg_n1 = 2.4 +mvg_m1 = 1.0 - 1.0/mvg_n1 +dimensionless_conductivity1 = (timeScale*density*gravity*permeability1/(viscosity*lengthScale)) + +#print 'Ks',dimensionless_conductivity +dimensionless_density = 1.0 +dimensionless_gravity = np.array([0.0, + -1.0, + 0.0]) +#dimensionless_alpha = mvg_alpha*lengthScale +nMediaTypes = 1 +alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') +nVGtypes = numpy.zeros((nMediaTypes+1,),'d') +thetaStypes = numpy.zeros((nMediaTypes+1,),'d') +thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') +thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') +KsTypes = numpy.zeros((nMediaTypes+1,2),'d') + +for i in range(nMediaTypes+1): + if i==1: + alphaVGtypes[i] = mvg_alpha1 + nVGtypes[i] = mvg_n1 + thetaStypes[i] = thetaS1 + thetaRtypes[i] = thetaR1 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? + else: + alphaVGtypes[i] = mvg_alpha1 + nVGtypes[i] = mvg_n1 + thetaStypes[i] = thetaS1 + thetaRtypes[i] = thetaR1 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? + +galerkin = False +#useSeepageFace = True + +#def getSeepageFace(flag): +# if useSeepageFace: +# if flag == boundaryTags['drain']: +# return 1 +# else: +# return 0 +# else: +# return 0 + + + + +LevelModelType = Richards.LevelModel +coefficients = Richards.Coefficients(nd, + KsTypes, + nVGtypes, + alphaVGtypes, + thetaRtypes, + thetaSRtypes, + gravity=dimensionless_gravity, + density=dimensionless_density, + beta=0.0001, + diagonal_conductivity=True, + STABILIZATION_TYPE=2, #0, + ENTROPY_TYPE=1, + LUMPED_MASS_MATRIX= False , + FCT=False ,#True, + num_fct_iter=0, + # FOR ENTROPY VISCOSITY + cE=1.0, + uL=0.0, + uR=1.0, + # FOR ARTIFICIAL COMPRESSION + cK=1.0, + # OUTPUT quantDOFs + outputQuantDOFs=False)#, + +#recoeffs= coefficients + #getSeepageFace=getSeepageFace) +#galerkin = False + +#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, +# gravity=dimensionless_gravity, +# density=dimensionless_density, +# thetaS=thetaS, +# thetaR=thetaR, +# alpha= dimensionless_alpha, +# n = mvg_n, +# m = mvg_m, +# beta = beta) + + +#coefficients = ConservativeHeadRichardsMualemVanGenuchten(hydraulicConductivity=dimensionless_conductivity, +# gravity=dimensionless_gravity, +# density=dimensionless_density, +# thetaS=thetaStypes, +# thetaR=thetaRtypes, +# alpha= alphaVGtypes, +# n = mvg_n, +# m = mvg_m, +# beta = beta)# + +#G= [1.8, 1.2,1] +#domain.writePLY('CCS') +galerkin = False + +#G=[2.799999952316284,1.4950000047683716] +L=[.530,.26,1] +# Density Relation +rho_fw = 998.2#1000 # density of freshwater +rho_sw =1026.10 # density of saltwater- corresponds to conc=37.1kg/m3 +mf_fw = 0.0 # saline mass fraction, freshwater +mf_sw = 1.0# .0357 # saline mass fraction, saltwater +epsilon =(rho_sw - rho_fw)/rho_fw +drho_dmf =epsilon*rho_fw #700. #epsilon*rho_fw # density change with mass fraction + +#pondingPressure= 0.5 +#For SS-1: 26.7 cm, SS-2: 26.55 cm, SS-3: 26.2 cm +h_ss1=.267 # Head for intruding steady state +h_ss3=.2655 # Head for intermediate steady state +h_ss2=.262 # Head for receding steady state +h_saltwater=.255 # +def head_ramp_intruding(x,t): + if (t<=5000): + return h_ss1 + elif (t>5000): + return h_ss2 #h_ss2 + +def head_ramp_receding(x,t): + if (t<=11000): + return h_ss2 + elif (t>11000): + return h_ss2 #h_ss2 +# Dirichlet +# def getHeadDirichletBCs_SS(x,tag): # Need to fix this -- should be h_s=25.5 cm at top +# if (abs(x[0])<1.e-8 and x[1]<=0.255): +# #return lambda x,t: x[1] + (1.0+epsilon*mf_sw)*(h_saltwater-x[1]) +# return lambda x,t: h_saltwater + epsilon*(h_saltwater-x[1]) +# elif (abs(x[0]-L[0])< 1.e-8): +# return lambda x,t: h_ss1 +# else: +# pass + +def getHeadDirichletBCs_SS(x, tag): + if abs(x[0]) < 1.e-8 and x[1] <= 0.255: # Left boundary (Saltwater region) + # Apply hydrostatic adjustment for saltwater region + return lambda x, t: h_saltwater + epsilon * (h_saltwater - x[1]) + elif abs(x[0] - L[0]) < 1.e-8: # Right boundary (Freshwater region) + # Set constant head for the freshwater side at steady-state level SS1 + return lambda x, t: h_ss1 + else: + # Return None for areas without Dirichlet boundary conditions + return None + +def getHeadDirichletBCs_Receding(x,tag): + if (abs(x[0])<1.e-8 and x[1]<=0.255): + return lambda x,t: x[1] + (1.0+epsilon*mf_sw)*(h_saltwater-x[1]) + elif (abs(x[0]-L[0])< 1.e-8): + return lambda x,t: head_ramp_receding(x,t) + else: + pass + +def getHeadDirichletBCs_Intruding(x,tag): # Need to fix this -- should be h_s=25.5 cm at top + if (abs(x[0])<1.e-8 and x[1]<=0.255): + return lambda x,t: x[1] + (1.0+epsilon*mf_sw)*(.255-x[1]) + elif (abs(x[0]-L[0])< 1.e-8): + return lambda x,t: head_ramp_intruding(x,t) + else: + pass + + +dirichletConditions = {0:getHeadDirichletBCs_SS} + + +# class hydrostaticIC: +# def __init__(self,val = 0.3): +# self.val = val +# def uOfXT(self,x,t): +# return x[1] + (L[1]-x[1])*(1.0+epsilon*self.val) #x[1] +# def uOfX(self,x,t): +# return x[1] + (L[1]-x[1])*(1.0+epsilon*self.val) +class hydrostaticIC: + def __init__(self, h_saltwater=0.255, h_freshwater=0.267, epsilon=0.028): + """ + Initializes the hydrostatic initial condition. + :param h_saltwater: Saltwater head (m) at the left boundary. + :param h_freshwater: Freshwater head (m) at the right boundary. + :param epsilon: Density ratio adjustment between saltwater and freshwater. + """ + self.h_saltwater = h_saltwater # Saltwater head + self.h_freshwater = h_freshwater # Freshwater head + self.epsilon = epsilon # Density adjustment factor + + def uOfXT(self, x, t): + """ + Computes the hydraulic head or hydrostatic pressure based on the region. + :param x: [x, y] coordinate of the point. + :param t: Time (not used for initial conditions). + :return: Initial hydraulic head or hydrostatic pressure. + """ + if x[1] <= self.h_saltwater: # Saltwater region (below interface) + # Saltwater hydrostatic pressure + return self.h_saltwater + self.epsilon * (self.h_saltwater - x[1]) + else: # Freshwater region (above interface) + # Freshwater hydraulic head + return self.h_freshwater - x[1] + + def uOfX(self, x, t): + """ + Wrapper for uOfXT to compute values without time dependency. + """ + return self.uOfXT(x, t) + +# class hydrostaticIC: +# def __init__(self, val=0.3, h_saltwater=0.255): +# self.val = val +# self.h_saltwater = h_saltwater + +# def uOfXT(self, x, t): +# if x[1] <= self.h_saltwater: # Saltwater region +# return self.h_saltwater + (self.h_saltwater - x[1]) * (1.0 + epsilon * self.val) +# else: # Freshwater region +# return x[1] # Adjust based on the freshwater condition (e.g., head or elevation) + +# def uOfX(self, x, t): +# return self.uOfXT(x, t) + +# class ShockIC_2D_Richards: +# def uOfXT(self,x,t): +# bc=getDBC_2D_Richards_Shock(x,0) +# if bc != None: +# return bc(x,t) +# else: +# return 0.0 #x[1]*dimensionless_gravity[1]*dimensionless_density + +initialConditions = {0:hydrostaticIC()} + +fluxBoundaryConditions = {0:'noFlow'} + +def getFlowDiffusiveFluxBCs(x,tag): + if ((x[0]>=1.e-8 and abs(x[0]-L[0]) > 1.e-8) and (x[1] < 1.e-8 or abs(x[1]-L[1])<1.e-8)): + return lambda x,t: 0.0 + elif (abs(x[0])<1.e-8 and x[1]>0.255): + return lambda x,t: 0.0 + else: + pass + +def getFlowAdvectiveFluxBCs(x,tag): + if ((x[0]>= 1.e-8 and abs(x[0]-L[0])>1.e-8) and (x[1] < 1.e-8 or abs(x[1]- L[1])<1.e-8)): + return lambda x,t: 0.0 + else: + pass + +advectiveFluxBoundaryConditions = {0:getFlowDiffusiveFluxBCs} + +diffusiveFluxBoundaryConditions = {0:{0:getFlowDiffusiveFluxBCs}} + +#T = 0.0003/timeScale diff --git a/test/salinity/Goswami/thelper_tadr.py b/test/salinity/Goswami/thelper_tadr.py index 899b73b439..fb66b5ab03 100644 --- a/test/salinity/Goswami/thelper_tadr.py +++ b/test/salinity/Goswami/thelper_tadr.py @@ -1,140 +1,140 @@ -from proteus import Domain -from proteus import Norms -from proteus import Profiling -from proteus import Context -from proteus.mprans import TADR -import numpy as np -import math -from proteus.Profiling import logEvent -#T =4800.0 #100.0 #12000 # 6.0e2*6..,1.0e4 #time scale, s -#nDTout =10 #0 # output timesteps to use -ct=Context.Options([ - # General parameters # - ("physicalDiffusion", 0.0, "isotropic diffusion coefficient"), - #("problem",0,"0: 1D problem with periodic BCs. 1: 2D rotation of zalesak disk"), - #("nd",2,"space dimension"), - ("T",100,"Final time"), - #("nDTout",100,"Number of time steps to archive"), - ("refinement",0,"Level of refinement"), - ("unstructured",False,"Use unstructured mesh. Set to false for periodic BCs"), - # Choice of numerical method # - ("STABILIZATION_TYPE","Galerkin","Galerkin, VMS, TaylorGalerkinEV, EntropyViscosity, SmoothnessIndicator, Kuzmin, "), - ("LUMPED_MASS_MATRIX",False,"Flag to lumped the mass matrix"), - ("ENTROPY_TYPE","POWER","POWER, LOG"), - ("FCT",True,"Use Flux Corrected Transport"), - # Numerical parameters # - ("cE",0.1,"Entropy viscosity constant"), - ("cK",1.0,"Artificial compression constant"), - ("cfl",0.5,"Target cfl"), - ("SSPOrder",2,"SSP method of order 1, 2 or 3") -],mutable=True) - -#assert ct.problem==0 or ct.problem==1 or ct.problem == 2, "problem must be set to 0 or 1" -# SHOCK CAPTURING PARAMETERS # -shockCapturingFactor_tadr=0.2 -lag_shockCapturing_tadr=True - -# number of space dimensions # -#nd=ct.nd - -# General parameters # -parallel = True # if True use PETSc solvers -linearSmoother = None -checkMass = False - -# Finite element sapce # -pDegree_tadr=1 -useBernstein=False -useHex=False - -# quadrature order # -tadr_quad_order = 2*pDegree_tadr+1 - -# parallel partitioning info # -from proteus import MeshTools -partitioningType = MeshTools.MeshParallelPartitioningTypes.node -L=(.530,.26,1)#.26 -nd = 2 - -nnx =107#213#107 -nny =53#105#53#53# 105 - -unstructured=ct.unstructured #True for tetgen, false for tet or hex from rectangular grid - - -domain = Domain.RectangularDomain(L=[L[0],L[1]],name="gwvd_gc_domain",units="m") - -polyfile="gwvd_gc_domain_2d" -domain.writePoly(polyfile) -triangleOptions = "q30Dena0.00001" - - -#domain.MeshOptions.nn = nn -domain.MeshOptions.nnx = nnx -domain.MeshOptions.nny = nny -#domain.MeshOptions.nnz = nnz -domain.MeshOptions.triangleFlag=0 - -soname="tadr_level_"+repr(ct.refinement) - - -# class MyCoefficients(TADR.Coefficients): -# def attachModels(self,modelList): -# self.model = modelList[0] -# self.rdModel = self.model -# self.q_v = np.zeros(self.model.q[('grad(u)',0)].shape,'d') -# self.ebqe_v = np.zeros(self.model.ebqe[('grad(u)',0)].shape,'d') - -# class MyCoefficients(TADR.Coefficients): -# def attachModels(self,modelList): -# self.model = modelList[0] -# self.rdModel = self.model -# self.q_v = np.copy(self.model.q[('grad(u)', 0)]) # Copy element-level velocity -# self.ebqe_v = np.copy(self.model.ebqe[('grad(u)', 0)]) -# if 'dV' not in self.model.q: -# self.model.q['dV'] = np.ones(self.model.q[('u', 0)].shape, 'd') -# # Ensure 'dV_last' exists in the Richards model quadrature -# if 'dV_last' not in self.model.q: -# self.model.q['dV_last'] = np.zeros_like(self.model.q['dV']) -# logEvent(f"Richards velocity (q_v): mean={self.q_v.mean()}, min={self.q_v.min()}, max={self.q_v.max()}") -# logEvent(f"Richards boundary velocity (ebqe_v): mean={self.ebqe_v.mean()}, min={self.ebqe_v.min()}, max={self.ebqe_v.max()}") - - # logEvent("Richards velocity (q_v):", self.q_v) - # logEvent("Richards boundary velocity (ebqe_v):", self.ebqe_v) - # #self.q_v = np.zeros(self.model.q[('grad(u)',0)].shape,'d') - #self.ebqe_v = np.zeros(self.model.ebqe[('grad(u)',0)].shape,'d') -class MyCoefficients(TADR.Coefficients): - def attachModels(self, modelList): - """ - Attach the Richards model to TADR and pass the velocity field (grad(u)). - """ - # Attach Richards model - self.model = modelList[0] # Richards model - self.rdModel = self.model # Alias for convenience - # Log modelList for inspection - logEvent(f"Model list contains {len(modelList)} models:") - for i, model in enumerate(modelList): - logEvent(f"Model {i}: {model.name}, Type: {type(model)}") - - # Reference velocity fields directly from Richards model - if ('grad(u_v)', 0) in self.model.q: - self.q_v = self.model.q[('grad(u_v)', 0)] # Reference gradient of u (velocity) - self.q_v *= 1.241e-9 - else: - raise KeyError("Richards model q[('grad(u_v)', 0)] not found!") - - if ('grad(u)', 0) in self.model.ebqe: - self.ebqe_v = self.model.ebqe[('grad(u)', 0)] # Reference boundary gradient of u (velocity) - else: - raise KeyError("Richards model ebqe[('grad(u)', 0)] not found!") - - # Ensure quadrature volumes exist - if 'dV' not in self.model.q: - self.model.q['dV'] = np.ones(self.model.q[('u', 0)].shape, 'd') - - if 'dV_last' not in self.model.q: - self.model.q['dV_last'] = np.zeros_like(self.model.q['dV']) - - # Log for debugging - logEvent(f"Richards velocity (q_v): mean={self.q_v.mean()}, min={self.q_v.min()}, max={self.q_v.max()}") +from proteus import Domain +from proteus import Norms +from proteus import Profiling +from proteus import Context +from proteus.kernels import TADR +import numpy as np +import math +from proteus.Profiling import logEvent +#T =4800.0 #100.0 #12000 # 6.0e2*6..,1.0e4 #time scale, s +#nDTout =10 #0 # output timesteps to use +ct=Context.Options([ + # General parameters # + ("physicalDiffusion", 0.0, "isotropic diffusion coefficient"), + #("problem",0,"0: 1D problem with periodic BCs. 1: 2D rotation of zalesak disk"), + #("nd",2,"space dimension"), + ("T",100,"Final time"), + #("nDTout",100,"Number of time steps to archive"), + ("refinement",0,"Level of refinement"), + ("unstructured",False,"Use unstructured mesh. Set to false for periodic BCs"), + # Choice of numerical method # + ("STABILIZATION_TYPE","Galerkin","Galerkin, VMS, TaylorGalerkinEV, EntropyViscosity, SmoothnessIndicator, Kuzmin, "), + ("LUMPED_MASS_MATRIX",False,"Flag to lumped the mass matrix"), + ("ENTROPY_TYPE","POWER","POWER, LOG"), + ("FCT",True,"Use Flux Corrected Transport"), + # Numerical parameters # + ("cE",0.1,"Entropy viscosity constant"), + ("cK",1.0,"Artificial compression constant"), + ("cfl",0.5,"Target cfl"), + ("SSPOrder",2,"SSP method of order 1, 2 or 3") +],mutable=True) + +#assert ct.problem==0 or ct.problem==1 or ct.problem == 2, "problem must be set to 0 or 1" +# SHOCK CAPTURING PARAMETERS # +shockCapturingFactor_tadr=0.2 +lag_shockCapturing_tadr=True + +# number of space dimensions # +#nd=ct.nd + +# General parameters # +parallel = True # if True use PETSc solvers +linearSmoother = None +checkMass = False + +# Finite element sapce # +pDegree_tadr=1 +useBernstein=False +useHex=False + +# quadrature order # +tadr_quad_order = 2*pDegree_tadr+1 + +# parallel partitioning info # +from proteus import MeshTools +partitioningType = MeshTools.MeshParallelPartitioningTypes.node +L=(.530,.26,1)#.26 +nd = 2 + +nnx =107#213#107 +nny =53#105#53#53# 105 + +unstructured=ct.unstructured #True for tetgen, false for tet or hex from rectangular grid + + +domain = Domain.RectangularDomain(L=[L[0],L[1]],name="gwvd_gc_domain",units="m") + +polyfile="gwvd_gc_domain_2d" +domain.writePoly(polyfile) +triangleOptions = "q30Dena0.00001" + + +#domain.MeshOptions.nn = nn +domain.MeshOptions.nnx = nnx +domain.MeshOptions.nny = nny +#domain.MeshOptions.nnz = nnz +domain.MeshOptions.triangleFlag=0 + +soname="tadr_level_"+repr(ct.refinement) + + +# class MyCoefficients(TADR.Coefficients): +# def attachModels(self,modelList): +# self.model = modelList[0] +# self.rdModel = self.model +# self.q_v = np.zeros(self.model.q[('grad(u)',0)].shape,'d') +# self.ebqe_v = np.zeros(self.model.ebqe[('grad(u)',0)].shape,'d') + +# class MyCoefficients(TADR.Coefficients): +# def attachModels(self,modelList): +# self.model = modelList[0] +# self.rdModel = self.model +# self.q_v = np.copy(self.model.q[('grad(u)', 0)]) # Copy element-level velocity +# self.ebqe_v = np.copy(self.model.ebqe[('grad(u)', 0)]) +# if 'dV' not in self.model.q: +# self.model.q['dV'] = np.ones(self.model.q[('u', 0)].shape, 'd') +# # Ensure 'dV_last' exists in the Richards model quadrature +# if 'dV_last' not in self.model.q: +# self.model.q['dV_last'] = np.zeros_like(self.model.q['dV']) +# logEvent(f"Richards velocity (q_v): mean={self.q_v.mean()}, min={self.q_v.min()}, max={self.q_v.max()}") +# logEvent(f"Richards boundary velocity (ebqe_v): mean={self.ebqe_v.mean()}, min={self.ebqe_v.min()}, max={self.ebqe_v.max()}") + + # logEvent("Richards velocity (q_v):", self.q_v) + # logEvent("Richards boundary velocity (ebqe_v):", self.ebqe_v) + # #self.q_v = np.zeros(self.model.q[('grad(u)',0)].shape,'d') + #self.ebqe_v = np.zeros(self.model.ebqe[('grad(u)',0)].shape,'d') +class MyCoefficients(TADR.Coefficients): + def attachModels(self, modelList): + """ + Attach the Richards model to TADR and pass the velocity field (grad(u)). + """ + # Attach Richards model + self.model = modelList[0] # Richards model + self.rdModel = self.model # Alias for convenience + # Log modelList for inspection + logEvent(f"Model list contains {len(modelList)} models:") + for i, model in enumerate(modelList): + logEvent(f"Model {i}: {model.name}, Type: {type(model)}") + + # Reference velocity fields directly from Richards model + if ('grad(u_v)', 0) in self.model.q: + self.q_v = self.model.q[('grad(u_v)', 0)] # Reference gradient of u (velocity) + self.q_v *= 1.241e-9 + else: + raise KeyError("Richards model q[('grad(u_v)', 0)] not found!") + + if ('grad(u)', 0) in self.model.ebqe: + self.ebqe_v = self.model.ebqe[('grad(u)', 0)] # Reference boundary gradient of u (velocity) + else: + raise KeyError("Richards model ebqe[('grad(u)', 0)] not found!") + + # Ensure quadrature volumes exist + if 'dV' not in self.model.q: + self.model.q['dV'] = np.ones(self.model.q[('u', 0)].shape, 'd') + + if 'dV_last' not in self.model.q: + self.model.q['dV_last'] = np.zeros_like(self.model.q['dV']) + + # Log for debugging + logEvent(f"Richards velocity (q_v): mean={self.q_v.mean()}, min={self.q_v.min()}, max={self.q_v.max()}") logEvent(f"Richards boundary velocity (ebqe_v): mean={self.ebqe_v.mean()}, min={self.ebqe_v.min()}, max={self.ebqe_v.max()}") \ No newline at end of file diff --git a/test/salinity/Henry/Henry_problem/domain_henry.py b/test/salinity/Henry/Henry_problem/domain_henry.py index d11b4ae54a..b8e711b20e 100644 --- a/test/salinity/Henry/Henry_problem/domain_henry.py +++ b/test/salinity/Henry/Henry_problem/domain_henry.py @@ -5,12 +5,12 @@ from proteus import Norms from proteus import Profiling from proteus import Context -#from proteus.mprans import TADR +#from proteus.kernels import TADR import numpy as np import math from proteus.Profiling import logEvent from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards details = """ The Dispersive Henry Benchmark problem (Arbarca et.al. 2007) and the modified Henry Benchmark diff --git a/test/salinity/Henry/Henry_problem/flow_p.py b/test/salinity/Henry/Henry_problem/flow_p.py index d975eede77..a73575ce83 100644 --- a/test/salinity/Henry/Henry_problem/flow_p.py +++ b/test/salinity/Henry/Henry_problem/flow_p.py @@ -1,167 +1,167 @@ -from proteus import * -from proteus.default_p import * -from proteus.richards import Richards -import numpy as np -try: - from .domain_henry import * -except: - from domain_henry import * -nd = 2 - - -analyticalSolution = None - -viscosity = 8.9e-4 #kg/(m*s) -density = 1000 # 998.2 #kg/m^3 -gravity = 9.8 #m/s^2 -beta = 0.0 #density*gravity*4.524e-10 -m_per_s_by_m_per_d = 1.1574074e-5 -lengthScale = 1.0 #m -timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) -#make non-dimensional - -#base -permeability1 = (1.2410491586180303e-03)*viscosity/(gravity*density) #m^2 -#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 -thetaS1 = 0.4 #- -thetaR1 = 0.05 #- -mvg_alpha1 = 8.0 #1/m -mvg_n1 = 2.4 -mvg_m1 = 1.0 - 1.0/mvg_n1 -dimensionless_conductivity1 = (timeScale*density*gravity*permeability1/(viscosity*lengthScale)) - -#print 'Ks',dimensionless_conductivity -dimensionless_density = 1.0 -dimensionless_gravity = np.array([0.0,# - -1.0, - 0.0]) -#dimensionless_alpha = mvg_alpha*lengthScale -nMediaTypes = 1 -alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') -nVGtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaStypes = numpy.zeros((nMediaTypes+1,),'d') -thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') -thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') -KsTypes = numpy.zeros((nMediaTypes+1,2),'d') - -for i in range(nMediaTypes+1): - if i==1: - alphaVGtypes[i] = mvg_alpha1 - nVGtypes[i] = mvg_n1 - thetaStypes[i] = thetaS1 - thetaRtypes[i] = thetaR1 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? - else: - alphaVGtypes[i] = mvg_alpha1 - nVGtypes[i] = mvg_n1 - thetaStypes[i] = thetaS1 - thetaRtypes[i] = thetaR1 - thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] - KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? - -galerkin = False -#useSeepageFace = True - -#def getSeepageFace(flag): -# if useSeepageFace: -# if flag == boundaryTags['drain']: -# return 1 -# else: -# return 0 -# else: -# return 0 - - - - -LevelModelType = Richards.LevelModel -coefficients = Richards.Coefficients(nd, - KsTypes, - nVGtypes, - alphaVGtypes, - thetaRtypes, - thetaSRtypes, - gravity=dimensionless_gravity, - density=dimensionless_density, - beta=0.0001, - diagonal_conductivity=True, - STABILIZATION_TYPE=2, #0, - ENTROPY_TYPE=1, - LUMPED_MASS_MATRIX= False , - FCT=False ,#True, - num_fct_iter=0, - # FOR ENTROPY VISCOSITY - cE=1.0, - uL=0.0, - uR=1.0, - # FOR ARTIFICIAL COMPRESSION - cK=1.0, - # OUTPUT quantDOFs - outputQuantDOFs=False)#, - -# -#galerkin = False - -# Density Relation -rho_fw = 1000.0 # density of freshwater -rho_sw = 1025.0 # 1026.0 density of saltwater -mf_fw = 0.0 # saline mass fraction, freshwater -mf_sw = 1.0# .0357 # saline mass fraction, saltwater -epsilon = (rho_sw - rho_fw)/rho_fw -drho_dmf =epsilon*rho_fw #700. #epsilon*rho_fw # density change with mass fraction -q_in=-6.6e-5 -# Dynamic Viscosity Relation -nu = 1.0e-3 - - -# class hydrostaticIC: -# def __init__(self, val=0.3): -# self.val = val -# def uOfXT(self, x, t): -# # Adjusting from hydraulic head to pressure head -# return (L[1] - x[1]) * (1.0 + epsilon * self.val) -# def uOfX(self, x, t): -# # Adjusting from hydraulic head to pressure head -# return (L[1] - x[1]) * (1.0 + epsilon * self.val) - -class hydrostaticIC: - #def __init__(self,val = 0.3): - #self.val = val - def uOfXT(self,x,t): - return 0+ x[1]*dimensionless_gravity[1]*dimensionless_density # + (L[1]-x[1])*(1.0+epsilon*self.val) #x[1] - #def uOfX(self,x,t): - # return x[1] + (L[1]-x[1])*(1.0+epsilon*self.val) -def getHenryheadDirichletBCs(x,tag): - #pass - if x[0]<1.e-8: - return lambda x,t: x[1] + (L[1]-x[1])*(1.0+epsilon*mf_sw) #mf_sw left boundary inflow - else: - pass - -# Flux Conditions - -def getFlowDiffusiveFluxBCs(x,tag): - if x[0]<1.e-8: - return lambda x,t: rho_fw*q_in #6.6e-5/2. - elif ((x[0]>=1.e-8 and abs(x[0]-L[0]) > 1.e-8) and (x[1] < 1.e-8 or abs(x[1]-L[1])<1.e-8)): - return lambda x,t: 0.0 - else: - pass - - -def getFlowAdvectiveFluxBCs(x,tag): - if ((x[0]>= 1.e-8 and abs(x[0]-L[0])>1.e-8) and (x[1] < 1.e-8 or abs(x[1]- L[1])<1.e-8)): - return lambda x,t: 0.0 - else: - pass - - -fluxBoundaryConditions = {0:'setFlow'} -#initialConditions={0:hydrostaticIC(mf_fw)} -initialConditions={0:hydrostaticIC()} -dirichletConditions = {0: getHenryheadDirichletBCs} -advectiveFluxBoundaryConditions = {0:getFlowDiffusiveFluxBCs} -diffusiveFluxBoundaryConditions = {0:{0:getFlowDiffusiveFluxBCs}} - -#T = 0.0003/timeScale +from proteus import * +from proteus.default_p import * +from proteus.kernels import Richards +import numpy as np +try: + from .domain_henry import * +except: + from domain_henry import * +nd = 2 + + +analyticalSolution = None + +viscosity = 8.9e-4 #kg/(m*s) +density = 1000 # 998.2 #kg/m^3 +gravity = 9.8 #m/s^2 +beta = 0.0 #density*gravity*4.524e-10 +m_per_s_by_m_per_d = 1.1574074e-5 +lengthScale = 1.0 #m +timeScale = 1.0 #d #1.0/sqrt(g*lengthScale) +#make non-dimensional + +#base +permeability1 = (1.2410491586180303e-03)*viscosity/(gravity*density) #m^2 +#permeability1 = (0.00504)*viscosity/(gravity*density) #m^2 +thetaS1 = 0.4 #- +thetaR1 = 0.05 #- +mvg_alpha1 = 8.0 #1/m +mvg_n1 = 2.4 +mvg_m1 = 1.0 - 1.0/mvg_n1 +dimensionless_conductivity1 = (timeScale*density*gravity*permeability1/(viscosity*lengthScale)) + +#print 'Ks',dimensionless_conductivity +dimensionless_density = 1.0 +dimensionless_gravity = np.array([0.0,# + -1.0, + 0.0]) +#dimensionless_alpha = mvg_alpha*lengthScale +nMediaTypes = 1 +alphaVGtypes = numpy.zeros((nMediaTypes+1,),'d') +nVGtypes = numpy.zeros((nMediaTypes+1,),'d') +thetaStypes = numpy.zeros((nMediaTypes+1,),'d') +thetaRtypes = numpy.zeros((nMediaTypes+1,),'d') +thetaSRtypes = numpy.zeros((nMediaTypes+1,),'d') +KsTypes = numpy.zeros((nMediaTypes+1,2),'d') + +for i in range(nMediaTypes+1): + if i==1: + alphaVGtypes[i] = mvg_alpha1 + nVGtypes[i] = mvg_n1 + thetaStypes[i] = thetaS1 + thetaRtypes[i] = thetaR1 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? + else: + alphaVGtypes[i] = mvg_alpha1 + nVGtypes[i] = mvg_n1 + thetaStypes[i] = thetaS1 + thetaRtypes[i] = thetaR1 + thetaSRtypes[i] = thetaStypes[i] - thetaRtypes[i] + KsTypes[i,:] = [dimensionless_conductivity1,dimensionless_conductivity1]#m/d? + +galerkin = False +#useSeepageFace = True + +#def getSeepageFace(flag): +# if useSeepageFace: +# if flag == boundaryTags['drain']: +# return 1 +# else: +# return 0 +# else: +# return 0 + + + + +LevelModelType = Richards.LevelModel +coefficients = Richards.Coefficients(nd, + KsTypes, + nVGtypes, + alphaVGtypes, + thetaRtypes, + thetaSRtypes, + gravity=dimensionless_gravity, + density=dimensionless_density, + beta=0.0001, + diagonal_conductivity=True, + STABILIZATION_TYPE=2, #0, + ENTROPY_TYPE=1, + LUMPED_MASS_MATRIX= False , + FCT=False ,#True, + num_fct_iter=0, + # FOR ENTROPY VISCOSITY + cE=1.0, + uL=0.0, + uR=1.0, + # FOR ARTIFICIAL COMPRESSION + cK=1.0, + # OUTPUT quantDOFs + outputQuantDOFs=False)#, + +# +#galerkin = False + +# Density Relation +rho_fw = 1000.0 # density of freshwater +rho_sw = 1025.0 # 1026.0 density of saltwater +mf_fw = 0.0 # saline mass fraction, freshwater +mf_sw = 1.0# .0357 # saline mass fraction, saltwater +epsilon = (rho_sw - rho_fw)/rho_fw +drho_dmf =epsilon*rho_fw #700. #epsilon*rho_fw # density change with mass fraction +q_in=-6.6e-5 +# Dynamic Viscosity Relation +nu = 1.0e-3 + + +# class hydrostaticIC: +# def __init__(self, val=0.3): +# self.val = val +# def uOfXT(self, x, t): +# # Adjusting from hydraulic head to pressure head +# return (L[1] - x[1]) * (1.0 + epsilon * self.val) +# def uOfX(self, x, t): +# # Adjusting from hydraulic head to pressure head +# return (L[1] - x[1]) * (1.0 + epsilon * self.val) + +class hydrostaticIC: + #def __init__(self,val = 0.3): + #self.val = val + def uOfXT(self,x,t): + return 0+ x[1]*dimensionless_gravity[1]*dimensionless_density # + (L[1]-x[1])*(1.0+epsilon*self.val) #x[1] + #def uOfX(self,x,t): + # return x[1] + (L[1]-x[1])*(1.0+epsilon*self.val) +def getHenryheadDirichletBCs(x,tag): + #pass + if x[0]<1.e-8: + return lambda x,t: x[1] + (L[1]-x[1])*(1.0+epsilon*mf_sw) #mf_sw left boundary inflow + else: + pass + +# Flux Conditions + +def getFlowDiffusiveFluxBCs(x,tag): + if x[0]<1.e-8: + return lambda x,t: rho_fw*q_in #6.6e-5/2. + elif ((x[0]>=1.e-8 and abs(x[0]-L[0]) > 1.e-8) and (x[1] < 1.e-8 or abs(x[1]-L[1])<1.e-8)): + return lambda x,t: 0.0 + else: + pass + + +def getFlowAdvectiveFluxBCs(x,tag): + if ((x[0]>= 1.e-8 and abs(x[0]-L[0])>1.e-8) and (x[1] < 1.e-8 or abs(x[1]- L[1])<1.e-8)): + return lambda x,t: 0.0 + else: + pass + + +fluxBoundaryConditions = {0:'setFlow'} +#initialConditions={0:hydrostaticIC(mf_fw)} +initialConditions={0:hydrostaticIC()} +dirichletConditions = {0: getHenryheadDirichletBCs} +advectiveFluxBoundaryConditions = {0:getFlowDiffusiveFluxBCs} +diffusiveFluxBoundaryConditions = {0:{0:getFlowDiffusiveFluxBCs}} + +#T = 0.0003/timeScale diff --git a/test/salinity/Henry/Henry_problem/tranport_p.py b/test/salinity/Henry/Henry_problem/tranport_p.py index 4557845360..2ee3e6bf4c 100644 --- a/test/salinity/Henry/Henry_problem/tranport_p.py +++ b/test/salinity/Henry/Henry_problem/tranport_p.py @@ -1,187 +1,187 @@ -from __future__ import absolute_import -from builtins import object -import numpy as np -from proteus import * -from proteus.default_p import * -from proteus.ctransportCoefficients import smoothedHeaviside - -from proteus import Domain -from proteus import Norms -from proteus import Profiling -from proteus import Context -from proteus.mprans import TADR - -from proteus.Profiling import logEvent - -from math import * -try: - from .domain_henry import * -except: - from domain_henry import * - -#T =4800.0 #100.0 #12000 # 6.0e2*6..,1.0e4 #time scale, s -#nDTout =10 #0 # output timesteps to use -ct=Context.Options([ - # General parameters # - ("physicalDiffusion", 0.0, "isotropic diffusion coefficient"), - #("problem",0,"0: 1D problem with periodic BCs. 1: 2D rotation of zalesak disk"), - #("nd",2,"space dimension"), - #("T",100,"Final time"), - #("nDTout",100,"Number of time steps to archive"), - ("refinement",0,"Level of refinement"), - ("unstructured",False,"Use unstructured mesh. Set to false for periodic BCs"), - # Choice of numerical method # - ("STABILIZATION_TYPE","Galerkin","Galerkin, VMS, TaylorGalerkinEV, EntropyViscosity, SmoothnessIndicator, Kuzmin, "), - ("LUMPED_MASS_MATRIX",False,"Flag to lumped the mass matrix"), - ("ENTROPY_TYPE","POWER","POWER, LOG"), - ("FCT",True,"Use Flux Corrected Transport"), - # Numerical parameters # - ("cE",0.1,"Entropy viscosity constant"), - ("cK",1.0,"Artificial compression constant"), - ("cfl",0.5,"Target cfl"), - ("SSPOrder",2,"SSP method of order 1, 2 or 3") -],mutable=True) - - -# SHOCK CAPTURING PARAMETERS # -shockCapturingFactor_tadr=0.2 -lag_shockCapturing_tadr=True - -# number of space dimensions # -#nd=ct.nd - -# General parameters # -parallel = False # if True use PETSc solvers -linearSmoother = None -checkMass = False - -# Finite element sapce # -pDegree_tadr=1 -useBernstein=False -useHex=False - -# quadrature order # -tadr_quad_order = 2*pDegree_tadr+1 -#from gw_cl_domain import * - -class MyCoefficients(TADR.Coefficients): - def attachModels(self, modelList): - """ - Attach the Richards model to TADR and pass the velocity field (grad(u)). - """ - # Attach Richards model - self.model = modelList[0] # Richards model - self.rdModel = self.model # Alias for convenience - # Log modelList for inspection - logEvent(f"Model list contains {len(modelList)} models:") - for i, model in enumerate(modelList): - logEvent(f"Model {i}: {model.name}, Type: {type(model)}") - - # Reference velocity fields directly from Richards model - if ('grad(u_v)', 0) in self.model.q: - self.q_v = self.model.q[('grad(u_v)', 0)] # Reference gradient of u (velocity) - #self.q_v *= 1.241e-9 - else: - raise KeyError("Richards model q[('grad(u_v)', 0)] not found!") - - if ('grad(u)', 0) in self.model.ebqe: - self.ebqe_v = self.model.ebqe[('grad(u)', 0)] # Reference boundary gradient of u (velocity) - else: - raise KeyError("Richards model ebqe[('grad(u)', 0)] not found!") - - # Ensure quadrature volumes exist - if 'dV' not in self.model.q: - self.model.q['dV'] = np.ones(self.model.q[('u', 0)].shape, 'd') - - if 'dV_last' not in self.model.q: - self.model.q['dV_last'] = np.zeros_like(self.model.q['dV']) - - # Log for debugging - logEvent(f"Richards velocity (q_v): mean={self.q_v.mean()}, min={self.q_v.min()}, max={self.q_v.max()}") - logEvent(f"Richards boundary velocity (ebqe_v): mean={self.ebqe_v.mean()}, min={self.ebqe_v.min()}, max={self.ebqe_v.max()}") - -LevelModelType = TADR.LevelModel -logEvent = Profiling.logEvent -#name=soname -a0= 18.8571e-6 #e-6 -def a(x): - return np.array([[a0,0.0],[0.0,a0]]) -aOfX = {0:a} -alpha_L= 0.1 -alpha_T= 0.1*alpha_L -Dm= 18.86e-6 -coefficients = MyCoefficients( - alpha_L=alpha_L, - alpha_T=alpha_T, - Dm=Dm, - V_model=0, - checkMass=checkMass, - FCT=ct.FCT, - LUMPED_MASS_MATRIX=ct.LUMPED_MASS_MATRIX, - STABILIZATION_TYPE=ct.STABILIZATION_TYPE, - diagonal_conductivity= True, - ENTROPY_TYPE=ct.ENTROPY_TYPE, - cE=ct.cE, cK=ct.cK, physicalDiffusion=ct.physicalDiffusion) -coefficients.variableNames=['u'] - -# Density Relation -rho_fw = 1000.0 # density of freshwater -rho_sw = 1025.0 # 1026.0 density of saltwater -mf_fw = 0.0 # saline mass fraction, freshwater -mf_sw = 1.0# .0357 # saline mass fraction, saltwater -epsilon = (rho_sw - rho_fw)/rho_fw -drho_dmf =epsilon*rho_fw #700. #epsilon*rho_fw # density change with mass fraction - -# Dynamic Viscosity Relation -nu = 1.0e-3 - -##################### -# INITIAL CONDITION # -##################### -########################### -# Defining Initial Conditions Functions -# Initially will start at all freshwater -# and then go to a steady state -########################### - - -class constantIC: - def __init__(self,cval=0.0): - self.cval = cval - def uOfXT(self,x,t): - return self.cval - def uOfX(self,x): - return self.cval -# return self.cval - - -def getHenryConcDirichletBCs(x,tag): - if x[0]<1.e-8: - return lambda x,t: mf_fw - elif abs(x[0]-L[0])<1.e-8: - return lambda x,t: mf_sw - -# Henry Problem Mass Flux Boundary Conditions - -def getzeroMassDiffusiveFluxBCs(x,tag): - if ((x[0] > 1.e-8 and abs(x[0] -L[0])> 1.e-8) and - (x[1] < 1.0e-8 or abs(x[1]- L[1]) < 1.0e-8) ): - return lambda x,t: 0.0 - else: - pass - -def getzeroBCs(x,tag): - return lambda x,t: 0.0 - -def getzeroMassAdvectiveFluxBCs(x,tag): - if ((x[0] > 1.0e-8 and x[0] < L[0]-1.0e-8) and - ( x[1] < 1.0e-8 or x[1] > L[1]-1.0e-8)): - return lambda x,t: 0.0 - - -initialConditions ={0:constantIC(mf_fw)} -dirichletConditions ={0:getHenryConcDirichletBCs} -fluxBoundaryConditions = {0:'setFlow'} -advectiveFluxBoundaryConditions ={0:getzeroMassDiffusiveFluxBCs} -diffusiveFluxBoundaryConditions ={0:{0:getzeroMassDiffusiveFluxBCs}}#{0:{0:getzeroBCs}}#{0:{0:getzeroMassDiffusiveFluxBCs}} - +from __future__ import absolute_import +from builtins import object +import numpy as np +from proteus import * +from proteus.default_p import * +from proteus.ctransportCoefficients import smoothedHeaviside + +from proteus import Domain +from proteus import Norms +from proteus import Profiling +from proteus import Context +from proteus.kernels import TADR + +from proteus.Profiling import logEvent + +from math import * +try: + from .domain_henry import * +except: + from domain_henry import * + +#T =4800.0 #100.0 #12000 # 6.0e2*6..,1.0e4 #time scale, s +#nDTout =10 #0 # output timesteps to use +ct=Context.Options([ + # General parameters # + ("physicalDiffusion", 0.0, "isotropic diffusion coefficient"), + #("problem",0,"0: 1D problem with periodic BCs. 1: 2D rotation of zalesak disk"), + #("nd",2,"space dimension"), + #("T",100,"Final time"), + #("nDTout",100,"Number of time steps to archive"), + ("refinement",0,"Level of refinement"), + ("unstructured",False,"Use unstructured mesh. Set to false for periodic BCs"), + # Choice of numerical method # + ("STABILIZATION_TYPE","Galerkin","Galerkin, VMS, TaylorGalerkinEV, EntropyViscosity, SmoothnessIndicator, Kuzmin, "), + ("LUMPED_MASS_MATRIX",False,"Flag to lumped the mass matrix"), + ("ENTROPY_TYPE","POWER","POWER, LOG"), + ("FCT",True,"Use Flux Corrected Transport"), + # Numerical parameters # + ("cE",0.1,"Entropy viscosity constant"), + ("cK",1.0,"Artificial compression constant"), + ("cfl",0.5,"Target cfl"), + ("SSPOrder",2,"SSP method of order 1, 2 or 3") +],mutable=True) + + +# SHOCK CAPTURING PARAMETERS # +shockCapturingFactor_tadr=0.2 +lag_shockCapturing_tadr=True + +# number of space dimensions # +#nd=ct.nd + +# General parameters # +parallel = False # if True use PETSc solvers +linearSmoother = None +checkMass = False + +# Finite element sapce # +pDegree_tadr=1 +useBernstein=False +useHex=False + +# quadrature order # +tadr_quad_order = 2*pDegree_tadr+1 +#from gw_cl_domain import * + +class MyCoefficients(TADR.Coefficients): + def attachModels(self, modelList): + """ + Attach the Richards model to TADR and pass the velocity field (grad(u)). + """ + # Attach Richards model + self.model = modelList[0] # Richards model + self.rdModel = self.model # Alias for convenience + # Log modelList for inspection + logEvent(f"Model list contains {len(modelList)} models:") + for i, model in enumerate(modelList): + logEvent(f"Model {i}: {model.name}, Type: {type(model)}") + + # Reference velocity fields directly from Richards model + if ('grad(u_v)', 0) in self.model.q: + self.q_v = self.model.q[('grad(u_v)', 0)] # Reference gradient of u (velocity) + #self.q_v *= 1.241e-9 + else: + raise KeyError("Richards model q[('grad(u_v)', 0)] not found!") + + if ('grad(u)', 0) in self.model.ebqe: + self.ebqe_v = self.model.ebqe[('grad(u)', 0)] # Reference boundary gradient of u (velocity) + else: + raise KeyError("Richards model ebqe[('grad(u)', 0)] not found!") + + # Ensure quadrature volumes exist + if 'dV' not in self.model.q: + self.model.q['dV'] = np.ones(self.model.q[('u', 0)].shape, 'd') + + if 'dV_last' not in self.model.q: + self.model.q['dV_last'] = np.zeros_like(self.model.q['dV']) + + # Log for debugging + logEvent(f"Richards velocity (q_v): mean={self.q_v.mean()}, min={self.q_v.min()}, max={self.q_v.max()}") + logEvent(f"Richards boundary velocity (ebqe_v): mean={self.ebqe_v.mean()}, min={self.ebqe_v.min()}, max={self.ebqe_v.max()}") + +LevelModelType = TADR.LevelModel +logEvent = Profiling.logEvent +#name=soname +a0= 18.8571e-6 #e-6 +def a(x): + return np.array([[a0,0.0],[0.0,a0]]) +aOfX = {0:a} +alpha_L= 0.1 +alpha_T= 0.1*alpha_L +Dm= 18.86e-6 +coefficients = MyCoefficients( + alpha_L=alpha_L, + alpha_T=alpha_T, + Dm=Dm, + V_model=0, + checkMass=checkMass, + FCT=ct.FCT, + LUMPED_MASS_MATRIX=ct.LUMPED_MASS_MATRIX, + STABILIZATION_TYPE=ct.STABILIZATION_TYPE, + diagonal_conductivity= True, + ENTROPY_TYPE=ct.ENTROPY_TYPE, + cE=ct.cE, cK=ct.cK, physicalDiffusion=ct.physicalDiffusion) +coefficients.variableNames=['u'] + +# Density Relation +rho_fw = 1000.0 # density of freshwater +rho_sw = 1025.0 # 1026.0 density of saltwater +mf_fw = 0.0 # saline mass fraction, freshwater +mf_sw = 1.0# .0357 # saline mass fraction, saltwater +epsilon = (rho_sw - rho_fw)/rho_fw +drho_dmf =epsilon*rho_fw #700. #epsilon*rho_fw # density change with mass fraction + +# Dynamic Viscosity Relation +nu = 1.0e-3 + +##################### +# INITIAL CONDITION # +##################### +########################### +# Defining Initial Conditions Functions +# Initially will start at all freshwater +# and then go to a steady state +########################### + + +class constantIC: + def __init__(self,cval=0.0): + self.cval = cval + def uOfXT(self,x,t): + return self.cval + def uOfX(self,x): + return self.cval +# return self.cval + + +def getHenryConcDirichletBCs(x,tag): + if x[0]<1.e-8: + return lambda x,t: mf_fw + elif abs(x[0]-L[0])<1.e-8: + return lambda x,t: mf_sw + +# Henry Problem Mass Flux Boundary Conditions + +def getzeroMassDiffusiveFluxBCs(x,tag): + if ((x[0] > 1.e-8 and abs(x[0] -L[0])> 1.e-8) and + (x[1] < 1.0e-8 or abs(x[1]- L[1]) < 1.0e-8) ): + return lambda x,t: 0.0 + else: + pass + +def getzeroBCs(x,tag): + return lambda x,t: 0.0 + +def getzeroMassAdvectiveFluxBCs(x,tag): + if ((x[0] > 1.0e-8 and x[0] < L[0]-1.0e-8) and + ( x[1] < 1.0e-8 or x[1] > L[1]-1.0e-8)): + return lambda x,t: 0.0 + + +initialConditions ={0:constantIC(mf_fw)} +dirichletConditions ={0:getHenryConcDirichletBCs} +fluxBoundaryConditions = {0:'setFlow'} +advectiveFluxBoundaryConditions ={0:getzeroMassDiffusiveFluxBCs} +diffusiveFluxBoundaryConditions ={0:{0:getzeroMassDiffusiveFluxBCs}}#{0:{0:getzeroBCs}}#{0:{0:getzeroMassDiffusiveFluxBCs}} + diff --git a/test/salinity/Henry_problem/Henry_corrected/domain_henry.py b/test/salinity/Henry_problem/Henry_corrected/domain_henry.py index 56f009170c..2b30920d8a 100644 --- a/test/salinity/Henry_problem/Henry_corrected/domain_henry.py +++ b/test/salinity/Henry_problem/Henry_corrected/domain_henry.py @@ -5,12 +5,12 @@ from proteus import Norms from proteus import Profiling from proteus import Context -#from proteus.mprans import TADR +#from proteus.kernels import TADR import numpy as np import math from proteus.Profiling import logEvent from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards details = """ The Dispersive Henry Benchmark problem (Arbarca et.al. 2007) and the modified Henry Benchmark diff --git a/test/salinity/Henry_problem/Henry_corrected/flow_p.py b/test/salinity/Henry_problem/Henry_corrected/flow_p.py index 4ffe54f0d2..f73a7d77f8 100644 --- a/test/salinity/Henry_problem/Henry_corrected/flow_p.py +++ b/test/salinity/Henry_problem/Henry_corrected/flow_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import numpy as np try: from .domain_henry import * diff --git a/test/salinity/Henry_problem/Henry_corrected/right_dbc/ref_3/domain_henry.py b/test/salinity/Henry_problem/Henry_corrected/right_dbc/ref_3/domain_henry.py index 653bd88dea..75f195af0a 100644 --- a/test/salinity/Henry_problem/Henry_corrected/right_dbc/ref_3/domain_henry.py +++ b/test/salinity/Henry_problem/Henry_corrected/right_dbc/ref_3/domain_henry.py @@ -5,12 +5,12 @@ from proteus import Norms from proteus import Profiling from proteus import Context -#from proteus.mprans import TADR +#from proteus.kernels import TADR import numpy as np import math from proteus.Profiling import logEvent from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards details = """ The Dispersive Henry Benchmark problem (Arbarca et.al. 2007) and the modified Henry Benchmark diff --git a/test/salinity/Henry_problem/Henry_corrected/right_dbc/ref_3/flow_p.py b/test/salinity/Henry_problem/Henry_corrected/right_dbc/ref_3/flow_p.py index c66feda477..841eefff5b 100644 --- a/test/salinity/Henry_problem/Henry_corrected/right_dbc/ref_3/flow_p.py +++ b/test/salinity/Henry_problem/Henry_corrected/right_dbc/ref_3/flow_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import numpy as np try: from .domain_henry import * diff --git a/test/salinity/Henry_problem/Henry_corrected/right_dbc/ref_3/tranport_p.py b/test/salinity/Henry_problem/Henry_corrected/right_dbc/ref_3/tranport_p.py index 1fdada76f8..4fa8664472 100644 --- a/test/salinity/Henry_problem/Henry_corrected/right_dbc/ref_3/tranport_p.py +++ b/test/salinity/Henry_problem/Henry_corrected/right_dbc/ref_3/tranport_p.py @@ -9,7 +9,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR from proteus.Profiling import logEvent diff --git a/test/salinity/Henry_problem/Henry_corrected/tranport_p.py b/test/salinity/Henry_problem/Henry_corrected/tranport_p.py index c2b4cd53e8..b7835b4597 100644 --- a/test/salinity/Henry_problem/Henry_corrected/tranport_p.py +++ b/test/salinity/Henry_problem/Henry_corrected/tranport_p.py @@ -9,7 +9,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR from proteus.Profiling import logEvent diff --git a/test/salinity/Levee_contamination/Case_A/Hydrostatic/Raingarden_p.py b/test/salinity/Levee_contamination/Case_A/Hydrostatic/Raingarden_p.py index 9049ef9f58..bd244d99ba 100644 --- a/test/salinity/Levee_contamination/Case_A/Hydrostatic/Raingarden_p.py +++ b/test/salinity/Levee_contamination/Case_A/Hydrostatic/Raingarden_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from domain_rg import * analyticalSolution = None diff --git a/test/salinity/Levee_contamination/Case_A/Hydrostatic/tranport_p.py b/test/salinity/Levee_contamination/Case_A/Hydrostatic/tranport_p.py index 066f747327..a5912d7a66 100644 --- a/test/salinity/Levee_contamination/Case_A/Hydrostatic/tranport_p.py +++ b/test/salinity/Levee_contamination/Case_A/Hydrostatic/tranport_p.py @@ -9,7 +9,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR from proteus.Profiling import logEvent diff --git a/test/salinity/Levee_contamination/Case_B/heterogeneous/hydrostatic_theta/Raingarden_p.py b/test/salinity/Levee_contamination/Case_B/heterogeneous/hydrostatic_theta/Raingarden_p.py index 42f25f62b8..286215fedc 100644 --- a/test/salinity/Levee_contamination/Case_B/heterogeneous/hydrostatic_theta/Raingarden_p.py +++ b/test/salinity/Levee_contamination/Case_B/heterogeneous/hydrostatic_theta/Raingarden_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from domain_rg import * analyticalSolution = None diff --git a/test/salinity/Levee_contamination/Case_B/heterogeneous/hydrostatic_theta/tranport_p.py b/test/salinity/Levee_contamination/Case_B/heterogeneous/hydrostatic_theta/tranport_p.py index 066f747327..a5912d7a66 100644 --- a/test/salinity/Levee_contamination/Case_B/heterogeneous/hydrostatic_theta/tranport_p.py +++ b/test/salinity/Levee_contamination/Case_B/heterogeneous/hydrostatic_theta/tranport_p.py @@ -9,7 +9,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR from proteus.Profiling import logEvent diff --git a/test/salinity/Levee_contamination/Case_C/cutoff_wall/hydrostatic_again_theta/Raingarden_p.py b/test/salinity/Levee_contamination/Case_C/cutoff_wall/hydrostatic_again_theta/Raingarden_p.py index 8bcc58d08c..a7afa76fe4 100644 --- a/test/salinity/Levee_contamination/Case_C/cutoff_wall/hydrostatic_again_theta/Raingarden_p.py +++ b/test/salinity/Levee_contamination/Case_C/cutoff_wall/hydrostatic_again_theta/Raingarden_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from domain_rg import * analyticalSolution = None diff --git a/test/salinity/Levee_contamination/Case_C/cutoff_wall/hydrostatic_again_theta/tranport_p.py b/test/salinity/Levee_contamination/Case_C/cutoff_wall/hydrostatic_again_theta/tranport_p.py index 066f747327..a5912d7a66 100644 --- a/test/salinity/Levee_contamination/Case_C/cutoff_wall/hydrostatic_again_theta/tranport_p.py +++ b/test/salinity/Levee_contamination/Case_C/cutoff_wall/hydrostatic_again_theta/tranport_p.py @@ -9,7 +9,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR from proteus.Profiling import logEvent diff --git a/test/salinity/Levee_contamination_Density/Case_D/Raingarden_p.py b/test/salinity/Levee_contamination_Density/Case_D/Raingarden_p.py index 80660c2733..5ba2f099c8 100644 --- a/test/salinity/Levee_contamination_Density/Case_D/Raingarden_p.py +++ b/test/salinity/Levee_contamination_Density/Case_D/Raingarden_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import numpy import numpy as np diff --git a/test/salinity/Levee_contamination_Density/Case_D/non_density/Raingarden_p.py b/test/salinity/Levee_contamination_Density/Case_D/non_density/Raingarden_p.py index 80660c2733..5ba2f099c8 100644 --- a/test/salinity/Levee_contamination_Density/Case_D/non_density/Raingarden_p.py +++ b/test/salinity/Levee_contamination_Density/Case_D/non_density/Raingarden_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import numpy import numpy as np diff --git a/test/salinity/Levee_contamination_Density/Case_D/non_density/tranport_p.py b/test/salinity/Levee_contamination_Density/Case_D/non_density/tranport_p.py index 56242abe94..d35554ab04 100644 --- a/test/salinity/Levee_contamination_Density/Case_D/non_density/tranport_p.py +++ b/test/salinity/Levee_contamination_Density/Case_D/non_density/tranport_p.py @@ -4,7 +4,7 @@ from proteus import * from proteus.default_p import * from proteus import Profiling -from proteus.mprans import TADR +from proteus.kernels import TADR try: from .domain_rg import * diff --git a/test/salinity/Levee_contamination_Density/Case_D/tranport_p.py b/test/salinity/Levee_contamination_Density/Case_D/tranport_p.py index 2005c6c4e1..b2e18e5d87 100644 --- a/test/salinity/Levee_contamination_Density/Case_D/tranport_p.py +++ b/test/salinity/Levee_contamination_Density/Case_D/tranport_p.py @@ -4,7 +4,7 @@ from proteus import * from proteus.default_p import * from proteus import Profiling -from proteus.mprans import TADR +from proteus.kernels import TADR try: from .domain_rg import * diff --git a/test/salinity/Variable_sat_density_watertable_2m_finer/flow_p.py b/test/salinity/Variable_sat_density_watertable_2m_finer/flow_p.py index cc9ad9ef2d..864b69f653 100644 --- a/test/salinity/Variable_sat_density_watertable_2m_finer/flow_p.py +++ b/test/salinity/Variable_sat_density_watertable_2m_finer/flow_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import numpy import numpy as np diff --git a/test/salinity/Variable_sat_density_watertable_2m_finer/tranport_n.py b/test/salinity/Variable_sat_density_watertable_2m_finer/tranport_n.py index f7a3081d9a..3e93636135 100644 --- a/test/salinity/Variable_sat_density_watertable_2m_finer/tranport_n.py +++ b/test/salinity/Variable_sat_density_watertable_2m_finer/tranport_n.py @@ -4,7 +4,7 @@ from proteus import * from proteus.default_n import * -from proteus.mprans import TADR +from proteus.kernels import TADR from domain_liu import * from tranport_p import * diff --git a/test/salinity/Variable_sat_density_watertable_2m_finer/tranport_p.py b/test/salinity/Variable_sat_density_watertable_2m_finer/tranport_p.py index 29382033b9..1e22190b60 100644 --- a/test/salinity/Variable_sat_density_watertable_2m_finer/tranport_p.py +++ b/test/salinity/Variable_sat_density_watertable_2m_finer/tranport_p.py @@ -4,7 +4,7 @@ from proteus import * from proteus.default_p import * from proteus import Profiling -from proteus.mprans import TADR +from proteus.kernels import TADR try: from .domain_liu import * diff --git a/test/salinity/stratified_column/column_flow_n.py b/test/salinity/stratified_column/column_flow_n.py index ed6bc919a6..21bc4b5e22 100644 --- a/test/salinity/stratified_column/column_flow_n.py +++ b/test/salinity/stratified_column/column_flow_n.py @@ -1,5 +1,5 @@ from proteus.default_n import * -from proteus.richards import Richards +from proteus.kernels import Richards try: from .column_flow_p import * diff --git a/test/salinity/stratified_column/column_flow_p.py b/test/salinity/stratified_column/column_flow_p.py index 86a3230bf5..7c76ad4763 100644 --- a/test/salinity/stratified_column/column_flow_p.py +++ b/test/salinity/stratified_column/column_flow_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import numpy as np try: diff --git a/test/salinity/stratified_column/column_transport_n.py b/test/salinity/stratified_column/column_transport_n.py index 8683d20ca9..4ad5e8288c 100644 --- a/test/salinity/stratified_column/column_transport_n.py +++ b/test/salinity/stratified_column/column_transport_n.py @@ -1,5 +1,5 @@ from proteus.default_n import * -from proteus.mprans import TADR +from proteus.kernels import TADR try: from .column_transport_p import * diff --git a/test/salinity/stratified_column/column_transport_p.py b/test/salinity/stratified_column/column_transport_p.py index 1fe0e1dcc5..9c02988010 100644 --- a/test/salinity/stratified_column/column_transport_p.py +++ b/test/salinity/stratified_column/column_transport_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import TADR +from proteus.kernels import TADR import numpy as np try: diff --git a/test/salinity/test_tadr_edge_flux_recording.py b/test/salinity/test_tadr_edge_flux_recording.py index bddda1615e..e89e945181 100644 --- a/test/salinity/test_tadr_edge_flux_recording.py +++ b/test/salinity/test_tadr_edge_flux_recording.py @@ -29,7 +29,7 @@ def test_edge_flux_branches_record_the_applied_boundary_flux(levee_deck, monkeypatch, stab, rtol): """ImplicitEV (5): measured 6.6e-13 relative (the Newton tolerance). Explicit EV (4): measured 4.0e-6 (the recorded flux is evaluated at c^n with the step's B, the budget over the step).""" - from proteus.mprans import TADR + from proteus.kernels import TADR rows = [] post = TADR.Coefficients.postStep diff --git a/test/salinity/test_vdft_compatible.py b/test/salinity/test_vdft_compatible.py index 22f4cd6c95..d1a98dfeb7 100644 --- a/test/salinity/test_vdft_compatible.py +++ b/test/salinity/test_vdft_compatible.py @@ -19,7 +19,7 @@ from proteus.iproteus import * # noqa: F401,F403 (opts, default_s, NumericalSolution) from proteus import LinearSolvers, NonlinearSolvers, StepControl -from proteus.mprans import TADR +from proteus.kernels import TADR HERE = os.path.dirname(os.path.abspath(__file__)) CASE_D = os.path.join(HERE, 'Levee_contamination_Density', 'Case_D') @@ -303,7 +303,7 @@ def test_levee_edge_flux_diagnostics_run(levee_deck, monkeypatch, stab, tadr_dia """Every run-time diagnostic, turned on through the Coefficients options, runs and logs without a probe failure (the probes catch their own exceptions, so a broken one would only say so in the log), and leaves the solution unchanged: c0 = cin = 0.5 stays 0.5.""" - from proteus.richards import Richards + from proteus.kernels import Richards logged = [] def record(msg, level=1, *args, **kwargs): @@ -347,7 +347,7 @@ def test_levee_edge_velocity(levee_deck): @pytest.mark.parametrize('model', ['TADR', 'Richards']) def test_an_unknown_diagnostic_is_refused(model): - from proteus.richards import Richards + from proteus.kernels import Richards module = {'TADR': TADR, 'Richards': Richards}[model] with pytest.raises(ValueError, match="unknown %s diagnostics" % model): module._diagnostics(("boundary_flux", "no_such_probe")) @@ -485,7 +485,7 @@ def test_first_dt_is_not_set_by_an_uninitialized_mass(levee_deck, monkeypatch): 1e-6, so dt > eps / nl_atol_res = 2e-10 (the deck's first output interval is 1e-8). The transport's RKEV used to propose 0.5 / 1.9e13 = 2.66e-14 because its edge-based CFL is formed from M_low = 0 (TADR.h floors it at 1e-14). Stops at the first step's preStep, so it needs no time stepping.""" - from proteus.richards import Richards + from proteus.kernels import Richards domain, rp, rn, tp, tn, so = levee_deck rp.coefficients.FCT = True rp.coefficients.FCT_TYPE = 'implicit' @@ -562,7 +562,7 @@ def test_first_step_old_time_mass_is_at_the_coupled_density(levee_deck, monkeypa change the mass: Newton's first step goes to |u| ~ 1e14, the iterates grow by 2 per iteration to 1e189 and the linear solve of the diverged step makes the all-NaN Jacobian of the nightly. Stops at the first step's preStep, so it needs no time stepping.""" - from proteus.richards import Richards + from proteus.kernels import Richards domain, rp, rn, tp, tn, so = levee_deck rp.coefficients.FCT = True rp.coefficients.FCT_TYPE = 'implicit' @@ -604,6 +604,6 @@ def checked_preStep(self, t, firstStep=False): def test_the_conservative_boundary_flux_is_opt_in(): """BC_CONS changes the boundary velocity a coupled transport sees, so existing decks keep the pointwise trace unless they ask for it.""" - from proteus.richards import Richards + from proteus.kernels import Richards import inspect assert inspect.signature(Richards.Coefficients.__init__).parameters['BC_CONS'].default is False diff --git a/test/salinity/vdft_reproduce/bioswale/Raingarden_p.py b/test/salinity/vdft_reproduce/bioswale/Raingarden_p.py index bdbe5fc7c6..143b8efea2 100644 --- a/test/salinity/vdft_reproduce/bioswale/Raingarden_p.py +++ b/test/salinity/vdft_reproduce/bioswale/Raingarden_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards from domain_rg import * analyticalSolution = None diff --git a/test/salinity/vdft_reproduce/bioswale/domain_rg.py b/test/salinity/vdft_reproduce/bioswale/domain_rg.py index 20d502190a..710ec0e8a2 100644 --- a/test/salinity/vdft_reproduce/bioswale/domain_rg.py +++ b/test/salinity/vdft_reproduce/bioswale/domain_rg.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import math nd = 2 diff --git a/test/salinity/vdft_reproduce/bioswale/tranport_p.py b/test/salinity/vdft_reproduce/bioswale/tranport_p.py index ed4e2f9cc2..e4599bf70f 100644 --- a/test/salinity/vdft_reproduce/bioswale/tranport_p.py +++ b/test/salinity/vdft_reproduce/bioswale/tranport_p.py @@ -9,7 +9,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR from proteus.Profiling import logEvent diff --git a/test/salinity/vdft_reproduce/elder/flow_p.py b/test/salinity/vdft_reproduce/elder/flow_p.py index 4511f19f21..2d5a0a6b2d 100644 --- a/test/salinity/vdft_reproduce/elder/flow_p.py +++ b/test/salinity/vdft_reproduce/elder/flow_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import numpy import numpy as np diff --git a/test/salinity/vdft_reproduce/elder/tranport_n_base.py b/test/salinity/vdft_reproduce/elder/tranport_n_base.py index 4863066d61..92ac3405f5 100644 --- a/test/salinity/vdft_reproduce/elder/tranport_n_base.py +++ b/test/salinity/vdft_reproduce/elder/tranport_n_base.py @@ -4,7 +4,7 @@ from proteus import * from proteus.default_n import * -from proteus.mprans import TADR +from proteus.kernels import TADR from domain_elder import * from tranport_p import * diff --git a/test/salinity/vdft_reproduce/elder/tranport_p.py b/test/salinity/vdft_reproduce/elder/tranport_p.py index df548ae76d..9da9149521 100644 --- a/test/salinity/vdft_reproduce/elder/tranport_p.py +++ b/test/salinity/vdft_reproduce/elder/tranport_p.py @@ -4,7 +4,7 @@ from proteus import * from proteus.default_p import * from proteus import Profiling -from proteus.mprans import TADR +from proteus.kernels import TADR try: from .domain_elder import * diff --git a/test/salinity/vdft_reproduce/henry/domain_henry.py b/test/salinity/vdft_reproduce/henry/domain_henry.py index 56f009170c..2b30920d8a 100644 --- a/test/salinity/vdft_reproduce/henry/domain_henry.py +++ b/test/salinity/vdft_reproduce/henry/domain_henry.py @@ -5,12 +5,12 @@ from proteus import Norms from proteus import Profiling from proteus import Context -#from proteus.mprans import TADR +#from proteus.kernels import TADR import numpy as np import math from proteus.Profiling import logEvent from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards details = """ The Dispersive Henry Benchmark problem (Arbarca et.al. 2007) and the modified Henry Benchmark diff --git a/test/salinity/vdft_reproduce/henry/flow_p.py b/test/salinity/vdft_reproduce/henry/flow_p.py index 390ac1fa15..432a34f672 100644 --- a/test/salinity/vdft_reproduce/henry/flow_p.py +++ b/test/salinity/vdft_reproduce/henry/flow_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import numpy as np try: from .domain_henry import * diff --git a/test/salinity/vdft_reproduce/henry/low_order/domain_henry.py b/test/salinity/vdft_reproduce/henry/low_order/domain_henry.py index 56f009170c..2b30920d8a 100644 --- a/test/salinity/vdft_reproduce/henry/low_order/domain_henry.py +++ b/test/salinity/vdft_reproduce/henry/low_order/domain_henry.py @@ -5,12 +5,12 @@ from proteus import Norms from proteus import Profiling from proteus import Context -#from proteus.mprans import TADR +#from proteus.kernels import TADR import numpy as np import math from proteus.Profiling import logEvent from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards details = """ The Dispersive Henry Benchmark problem (Arbarca et.al. 2007) and the modified Henry Benchmark diff --git a/test/salinity/vdft_reproduce/henry/low_order/flow_p.py b/test/salinity/vdft_reproduce/henry/low_order/flow_p.py index b0b317d751..259c5abe4f 100644 --- a/test/salinity/vdft_reproduce/henry/low_order/flow_p.py +++ b/test/salinity/vdft_reproduce/henry/low_order/flow_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import numpy as np try: from .domain_henry import * diff --git a/test/salinity/vdft_reproduce/henry/low_order/tranport_p.py b/test/salinity/vdft_reproduce/henry/low_order/tranport_p.py index ecc64b8954..646b108dc1 100644 --- a/test/salinity/vdft_reproduce/henry/low_order/tranport_p.py +++ b/test/salinity/vdft_reproduce/henry/low_order/tranport_p.py @@ -9,7 +9,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR from proteus.Profiling import logEvent diff --git a/test/salinity/vdft_reproduce/henry/tranport_p.py b/test/salinity/vdft_reproduce/henry/tranport_p.py index 0fd570089d..9e7d2fd833 100644 --- a/test/salinity/vdft_reproduce/henry/tranport_p.py +++ b/test/salinity/vdft_reproduce/henry/tranport_p.py @@ -9,7 +9,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR from proteus.Profiling import logEvent diff --git a/test/salinity/vdft_reproduce/levee_density/density/Raingarden_p.py b/test/salinity/vdft_reproduce/levee_density/density/Raingarden_p.py index ab7e0d3f45..efda9d62d5 100644 --- a/test/salinity/vdft_reproduce/levee_density/density/Raingarden_p.py +++ b/test/salinity/vdft_reproduce/levee_density/density/Raingarden_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import numpy import numpy as np diff --git a/test/salinity/vdft_reproduce/levee_density/density/tranport_p.py b/test/salinity/vdft_reproduce/levee_density/density/tranport_p.py index b63ae1697e..4a3c39f25c 100644 --- a/test/salinity/vdft_reproduce/levee_density/density/tranport_p.py +++ b/test/salinity/vdft_reproduce/levee_density/density/tranport_p.py @@ -4,7 +4,7 @@ from proteus import * from proteus.default_p import * from proteus import Profiling -from proteus.mprans import TADR +from proteus.kernels import TADR try: from .domain_rg import * diff --git a/test/salinity/vdft_reproduce/levee_density/non_density/Raingarden_p.py b/test/salinity/vdft_reproduce/levee_density/non_density/Raingarden_p.py index 3b2b63839f..9b49d76092 100644 --- a/test/salinity/vdft_reproduce/levee_density/non_density/Raingarden_p.py +++ b/test/salinity/vdft_reproduce/levee_density/non_density/Raingarden_p.py @@ -1,6 +1,6 @@ from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards import numpy import numpy as np diff --git a/test/salinity/vdft_reproduce/levee_density/non_density/tranport_p.py b/test/salinity/vdft_reproduce/levee_density/non_density/tranport_p.py index 1d493943cc..dbb0f16409 100644 --- a/test/salinity/vdft_reproduce/levee_density/non_density/tranport_p.py +++ b/test/salinity/vdft_reproduce/levee_density/non_density/tranport_p.py @@ -4,7 +4,7 @@ from proteus import * from proteus.default_p import * from proteus import Profiling -from proteus.mprans import TADR +from proteus.kernels import TADR try: from .domain_rg import * diff --git a/test/salinity/vdft_reproduce/mms/flow_n.py b/test/salinity/vdft_reproduce/mms/flow_n.py index 50d3a089f7..42c12626b3 100644 --- a/test/salinity/vdft_reproduce/mms/flow_n.py +++ b/test/salinity/vdft_reproduce/mms/flow_n.py @@ -10,7 +10,7 @@ from proteus import * from proteus.default_n import * from proteus.default_so import * -from proteus.richards import Richards +from proteus.kernels import Richards # Domain first: domain_mms re-exports default_p's `coefficients = None`, so # importing it after flow_p would clobber the Richards coefficients. diff --git a/test/salinity/vdft_reproduce/mms/flow_p.py b/test/salinity/vdft_reproduce/mms/flow_p.py index 91c5cfbfa4..586a167f02 100644 --- a/test/salinity/vdft_reproduce/mms/flow_p.py +++ b/test/salinity/vdft_reproduce/mms/flow_p.py @@ -10,7 +10,7 @@ import numpy as np from proteus import * from proteus.default_p import * -from proteus.richards import Richards +from proteus.kernels import Richards try: from .domain_mms import * diff --git a/test/salinity/vdft_reproduce/mms/run_mms.sh b/test/salinity/vdft_reproduce/mms/run_mms.sh index cca04fa46d..b8015d0057 100755 --- a/test/salinity/vdft_reproduce/mms/run_mms.sh +++ b/test/salinity/vdft_reproduce/mms/run_mms.sh @@ -27,6 +27,6 @@ echo "repo HEAD: $(git -C "$DECK" rev-parse HEAD)" > provenance.txt # uncommitted source edits at run time; the installed build may still differ git -C "$(git -C "$DECK" rev-parse --show-toplevel)" diff HEAD -- proteus > source.diff -python -c "import proteus.mprans.cTADR as c; print('cTADR from', c.__file__)" > run.out +python -c "import proteus.kernels.cTADR as c; print('cTADR from', c.__file__)" > run.out mpiexec -np "${MMS_NP:-1}" parun mms_so.py -l3 -O petsc.options.superlu >> run.out 2>&1 echo "exit $?" >> run.out diff --git a/test/salinity/vdft_reproduce/mms/transport_n.py b/test/salinity/vdft_reproduce/mms/transport_n.py index f38788e3b2..24704b1bf9 100644 --- a/test/salinity/vdft_reproduce/mms/transport_n.py +++ b/test/salinity/vdft_reproduce/mms/transport_n.py @@ -9,7 +9,7 @@ from proteus import * from proteus.default_n import * -from proteus.mprans import TADR +from proteus.kernels import TADR # Domain first: domain_mms re-exports default_p's `coefficients = None`. try: diff --git a/test/salinity/vdft_reproduce/mms/transport_p.py b/test/salinity/vdft_reproduce/mms/transport_p.py index 1948aa2f91..dd6ff4a409 100644 --- a/test/salinity/vdft_reproduce/mms/transport_p.py +++ b/test/salinity/vdft_reproduce/mms/transport_p.py @@ -21,7 +21,7 @@ from proteus import * from proteus.default_p import * from proteus.Comm import globalMax, globalSum -from proteus.mprans import TADR +from proteus.kernels import TADR from proteus.Profiling import logEvent try: diff --git a/test/salinity/vdft_reproduce/simmons_uhd/flow_n.py b/test/salinity/vdft_reproduce/simmons_uhd/flow_n.py index 0947bbbf2b..ff08e3f289 100644 --- a/test/salinity/vdft_reproduce/simmons_uhd/flow_n.py +++ b/test/salinity/vdft_reproduce/simmons_uhd/flow_n.py @@ -3,7 +3,7 @@ from proteus import * from proteus.default_n import * from proteus.default_so import * -from proteus.richards import Richards +from proteus.kernels import Richards # Domain first: domain_simmons re-exports default_p's `coefficients = None`, # so importing it after flow_p would clobber the Richards coefficients. diff --git a/test/salinity/vdft_reproduce/simmons_uhd/flow_p.py b/test/salinity/vdft_reproduce/simmons_uhd/flow_p.py index e8d7d8cfda..46a87b5e2e 100644 --- a/test/salinity/vdft_reproduce/simmons_uhd/flow_p.py +++ b/test/salinity/vdft_reproduce/simmons_uhd/flow_p.py @@ -42,7 +42,7 @@ from proteus import Comm from proteus.default_p import * from proteus.Profiling import logEvent -from proteus.richards import Richards +from proteus.kernels import Richards try: from .domain_simmons import * diff --git a/test/salinity/vdft_reproduce/simmons_uhd/transport_n.py b/test/salinity/vdft_reproduce/simmons_uhd/transport_n.py index a05b50750b..4eb8ce5f93 100644 --- a/test/salinity/vdft_reproduce/simmons_uhd/transport_n.py +++ b/test/salinity/vdft_reproduce/simmons_uhd/transport_n.py @@ -12,7 +12,7 @@ from proteus import * from proteus.default_n import * -from proteus.mprans import TADR +from proteus.kernels import TADR # Import the domain BEFORE the physics module. domain_simmons does # `from proteus.default_p import *`, which re-exports `coefficients = None`; diff --git a/test/salinity/vdft_reproduce/simmons_uhd/transport_p.py b/test/salinity/vdft_reproduce/simmons_uhd/transport_p.py index 519be123ff..adef3399a7 100644 --- a/test/salinity/vdft_reproduce/simmons_uhd/transport_p.py +++ b/test/salinity/vdft_reproduce/simmons_uhd/transport_p.py @@ -30,7 +30,7 @@ from proteus import * from proteus.default_p import * from proteus import Profiling -from proteus.mprans import TADR +from proteus.kernels import TADR try: from .domain_simmons import * diff --git a/test/salinity/vdft_reproduce/zalesak/run_stab5/fct/thelper_tadr.py b/test/salinity/vdft_reproduce/zalesak/run_stab5/fct/thelper_tadr.py index 52049093c2..c6fe2e76e3 100644 --- a/test/salinity/vdft_reproduce/zalesak/run_stab5/fct/thelper_tadr.py +++ b/test/salinity/vdft_reproduce/zalesak/run_stab5/fct/thelper_tadr.py @@ -2,7 +2,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR import numpy as np import math diff --git a/test/salinity/vdft_reproduce/zalesak/run_stab5/low/thelper_tadr.py b/test/salinity/vdft_reproduce/zalesak/run_stab5/low/thelper_tadr.py index 52049093c2..c6fe2e76e3 100644 --- a/test/salinity/vdft_reproduce/zalesak/run_stab5/low/thelper_tadr.py +++ b/test/salinity/vdft_reproduce/zalesak/run_stab5/low/thelper_tadr.py @@ -2,7 +2,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR import numpy as np import math diff --git a/test/salinity/vdft_reproduce/zalesak/thelper_tadr.py b/test/salinity/vdft_reproduce/zalesak/thelper_tadr.py index cf0ce52880..b0dc6fccc4 100644 --- a/test/salinity/vdft_reproduce/zalesak/thelper_tadr.py +++ b/test/salinity/vdft_reproduce/zalesak/thelper_tadr.py @@ -2,7 +2,7 @@ from proteus import Norms from proteus import Profiling from proteus import Context -from proteus.mprans import TADR +from proteus.kernels import TADR import numpy as np import math diff --git a/test/solid_mechanics/kirsch.py b/test/solid_mechanics/kirsch.py index 45e7812166..6a621dc96d 100644 --- a/test/solid_mechanics/kirsch.py +++ b/test/solid_mechanics/kirsch.py @@ -1,4 +1,4 @@ -"""Kirsch plate with a hole in plane strain, solved with proteus.elastoplastic on a one-element-thick tetrahedral slab. +"""Kirsch plate with a hole in plane strain, solved with proteus.kernels on a one-element-thick tetrahedral slab. Linear elasticity is obtained from the elastoplastic model with a cohesion far above any stress and P_a = 0. Exact displacements are imposed on the outer boundary, symmetry on x = 0 and y = 0, w = 0 on the slab faces, and the hole diff --git a/test/solid_mechanics/solid_deck.py b/test/solid_mechanics/solid_deck.py index 20e460efed..ba800b91e2 100644 --- a/test/solid_mechanics/solid_deck.py +++ b/test/solid_mechanics/solid_deck.py @@ -1,10 +1,10 @@ -"""Shared set-up of proteus.elastoplastic problems on one-element-thick tetrahedral slabs (plane strain).""" +"""Shared set-up of proteus.kernels problems on one-element-thick tetrahedral slabs (plane strain).""" import types import numpy as np from proteus import default_p, default_n, default_s, default_so from proteus import Domain, FemTools, Quadrature, NumericalFlux, StepControl, TimeIntegration, NonlinearSolvers from proteus import LinearSolvers, LinearAlgebraTools, MeshTools, NumericalSolution -from proteus.elastoplastic import ElastoPlastic +from proteus.kernels import ElastoPlastic MCDP, VON_MISES, TRESCA, DRUCKER_PRAGER, MOHR_COULOMB = 1, 2, 3, 4, 5 diff --git a/test/solid_mechanics/test_confined_compression.py b/test/solid_mechanics/test_confined_compression.py index 15a9a3d60c..e2a81bbf90 100644 --- a/test/solid_mechanics/test_confined_compression.py +++ b/test/solid_mechanics/test_confined_compression.py @@ -1,9 +1,9 @@ -"""Verification of the constitutive model selection and of load stepping in proteus.elastoplastic: confined compression +"""Verification of the constitutive model selection and of load stepping in proteus.kernels: confined compression of a block past yield, unloading and reverse yield, against a radial-return reference.""" import os import numpy as np import pytest -from proteus.elastoplastic import ElastoPlastic +from proteus.kernels import ElastoPlastic from . import confined_compression as cc from . import solid_deck diff --git a/test/solid_mechanics/test_kirsch.py b/test/solid_mechanics/test_kirsch.py index cabe9d8d52..a88f2a38be 100644 --- a/test/solid_mechanics/test_kirsch.py +++ b/test/solid_mechanics/test_kirsch.py @@ -1,4 +1,4 @@ -"""Verification of proteus.elastoplastic in the elastic range against the Kirsch solution (plate with a hole, plane strain).""" +"""Verification of proteus.kernels in the elastic range against the Kirsch solution (plate with a hole, plane strain).""" import math import os from . import kirsch diff --git a/test/solver_tests/import_modules/twp_navier_stokes_cavity_2d_p.py b/test/solver_tests/import_modules/twp_navier_stokes_cavity_2d_p.py index ffbd6f15f8..996a82a593 100644 --- a/test/solver_tests/import_modules/twp_navier_stokes_cavity_2d_p.py +++ b/test/solver_tests/import_modules/twp_navier_stokes_cavity_2d_p.py @@ -9,7 +9,7 @@ from .cavity2d import * except: from cavity2d import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P bcsTimeDependent = True LevelModelType = RANS2P.LevelModel diff --git a/test/solver_tests/import_modules/twp_navier_stokes_p.py b/test/solver_tests/import_modules/twp_navier_stokes_p.py index b08f7f5f55..49641405b7 100644 --- a/test/solver_tests/import_modules/twp_navier_stokes_p.py +++ b/test/solver_tests/import_modules/twp_navier_stokes_p.py @@ -1,5 +1,5 @@ from proteus.default_p import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P import numpy as np from proteus import Context from proteus import defaults diff --git a/test/solver_tests/import_modules/twp_navier_stokes_step2d_p.py b/test/solver_tests/import_modules/twp_navier_stokes_step2d_p.py index ec21594674..1de9875419 100644 --- a/test/solver_tests/import_modules/twp_navier_stokes_step2d_p.py +++ b/test/solver_tests/import_modules/twp_navier_stokes_step2d_p.py @@ -16,7 +16,7 @@ except: from step2d import * -from proteus.mprans import RANS2P +from proteus.kernels import RANS2P from proteus import Context ct = Context.get() diff --git a/test/state_contract_inventory.txt b/test/state_contract_inventory.txt index 03d1a5dd77..948c5bc2b2 100644 --- a/test/state_contract_inventory.txt +++ b/test/state_contract_inventory.txt @@ -6,15 +6,15 @@ # state defines state()/set_state(): archived per rank in solver_state/ and restored after the spin-up # (BackwardEuler's state is m_last, and BackwardEuler_cfl's also dtLast; PsiTCtte, PsiTCtte_new, SSP, # the RKEVs and TADR's CompatibleBackwardEuler inherit it, which does not say that they carry nothing -# more. Measured by test/test_hotstart_levelset.py, with the mprans.RANS2P shock capturing and +# more. Measured by test/test_hotstart_levelset.py, with the kernels.RANS2P shock capturing and # subgrid error lag machines and NumericalSolution's own owners: the coupled fields, the solver's # unknowns and the next system step; and with CLSVOF, and on rising_bubble_rans3p with the -# mprans.VOF3P and NCLS3P shock capturing lag machines) +# kernels.VOF3P and NCLS3P shock capturing lag machines) # rebuilt carries history that the spin-up rebuilds from the solution, and a hot start MEASURED to # continue exactly without its own state, given the state of the other owners of the model # (test/test_hotstart_state.py: backward Euler, and RKEV with its lagged shock capturing; -# test/hotstart_measure with HS_RD_LAG=1: mprans.RDLS.ShockCapturing, 1e-16 on every field; -# test/test_hotstart_rans3pf.py: mprans.RANS3PF.SubgridError and Min_dt_cfl_controller, bit-identical given the state of the rest +# test/hotstart_measure with HS_RD_LAG=1: kernels.RDLS.ShockCapturing, 1e-16 on every field; +# test/test_hotstart_rans3pf.py: kernels.RANS3PF.SubgridError and Min_dt_cfl_controller, bit-identical given the state of the rest # (RANS3PF.SubgridError also on rising_bubble_rans3p, where it switches to lagging: test_hotstart_levelset.py); # the vortex2D backward Euler hot start, 1e-16: Min_dt_controller, Newton_controller, MCorr.Newton_controller, Sequential_MinModelStep) # follows carries no history of its own: it re-derives its next step from a restored object @@ -44,19 +44,19 @@ SC ShockCapturing ResGradQuadDelayLag_SC unmeasured SC ShockCapturing ResGradQuad_SC unmeasured SC ShockCapturing ResGrad_SC unmeasured SC ShockCapturing ScalarAdvection_SC unmeasured -SC mprans.Dissipation ShockCapturing unmeasured -SC mprans.Kappa ShockCapturing unmeasured -SC mprans.NCLS ShockCapturing state -SC mprans.NCLS3P ShockCapturing state -SC mprans.RANS2P ShockCapturing state -SC mprans.RANS3PF ShockCapturing state -SC mprans.RANS3PSed ShockCapturing unmeasured -SC mprans.RDLS ShockCapturing rebuilt -SC mprans.SW2D ShockCapturing unmeasured -SC mprans.TADR ShockCapturing unmeasured -SC mprans.VOF ShockCapturing state -SC mprans.VOF3P ShockCapturing state -SC mprans.VOS3P ShockCapturing unmeasured +SC kernels.Dissipation ShockCapturing unmeasured +SC kernels.Kappa ShockCapturing unmeasured +SC kernels.NCLS ShockCapturing state +SC kernels.NCLS3P ShockCapturing state +SC kernels.RANS2P ShockCapturing state +SC kernels.RANS3PF ShockCapturing state +SC kernels.RANS3PSed ShockCapturing unmeasured +SC kernels.RDLS ShockCapturing rebuilt +SC kernels.SW2D ShockCapturing unmeasured +SC kernels.TADR ShockCapturing unmeasured +SC kernels.VOF ShockCapturing state +SC kernels.VOF3P ShockCapturing state +SC kernels.VOS3P ShockCapturing unmeasured SG SubgridError AdvectionDiffusionReactionHaukeSangalliInterpolantWithTransientSubScales_ASGS unmeasured SG SubgridError AdvectionDiffusionReactionHaukeSangalliInterpolant_ASGS unmeasured SG SubgridError AdvectionDiffusionReactionTransientSubscales_ASGS unmeasured @@ -78,19 +78,19 @@ SG SubgridError StokesASGS_velocity unmeasured SG SubgridError StokesASGS_velocity_pressure unmeasured SG SubgridError StokesStabilization_1 unmeasured SG SubgridError TwophaseStokes_LS_FC_ASGS unmeasured -SG mprans.Dissipation SubgridError unmeasured -SG mprans.Kappa SubgridError unmeasured -SG mprans.NCLS SubgridError unmeasured -SG mprans.NCLS3P SubgridError unmeasured -SG mprans.RANS2P SubgridError state -SG mprans.RANS3PF SubgridError rebuilt -SG mprans.RANS3PSed SubgridError unmeasured -SG mprans.RDLS SubgridError unmeasured -SG mprans.SW2D SubgridError unmeasured -SG mprans.TADR SubgridError unmeasured -SG mprans.VOF SubgridError unmeasured -SG mprans.VOF3P SubgridError unmeasured -SG mprans.VOS3P SubgridError unmeasured +SG kernels.Dissipation SubgridError unmeasured +SG kernels.Kappa SubgridError unmeasured +SG kernels.NCLS SubgridError unmeasured +SG kernels.NCLS3P SubgridError unmeasured +SG kernels.RANS2P SubgridError state +SG kernels.RANS3PF SubgridError rebuilt +SG kernels.RANS3PSed SubgridError unmeasured +SG kernels.RDLS SubgridError unmeasured +SG kernels.SW2D SubgridError unmeasured +SG kernels.TADR SubgridError unmeasured +SG kernels.VOF SubgridError unmeasured +SG kernels.VOF3P SubgridError unmeasured +SG kernels.VOS3P SubgridError unmeasured SO SplitOperator ISO_fixed_MinAdaptiveModelStep unmeasured SO SplitOperator SequentialNotInOrder_MinAdaptiveModelStep unmeasured SO SplitOperator SequentialNotInOrder_MinFLCBDFModelStep unmeasured @@ -114,9 +114,9 @@ STEP StepControl Osher_PsiTC_controller unmeasured STEP StepControl Osher_PsiTC_controller2 unmeasured STEP StepControl Osher_controller unmeasured STEP StepControl PsiTCtte_controller unmeasured -STEP mprans.MCorr Newton_controller rebuilt -STEP mprans.MCorr3P Newton_controller unmeasured -STEP mprans.RDLS PsiTC unmeasured +STEP kernels.MCorr Newton_controller rebuilt +STEP kernels.MCorr3P Newton_controller unmeasured +STEP kernels.RDLS PsiTC unmeasured TI TimeIntegration BackwardEuler state TI TimeIntegration BackwardEuler_cfl state TI TimeIntegration CentralDifference_2ndD unmeasured @@ -136,13 +136,24 @@ TI TimeIntegration PsiTCtte_new state TI TimeIntegration SSP state TI TimeIntegration SSPRKPIintegration unmeasured TI TimeIntegration VBDF state -TI mprans.GN_SW2DCV RKEV state -TI mprans.NCLS RKEV state -TI mprans.SW2DCV RKEV state +TI kernels.GN_SW2DCV RKEV state +TI kernels.NCLS RKEV state +TI kernels.SW2DCV RKEV state # CompatibleBackwardEuler: the compatible transport's carried storage M lives on TADR.LevelModel # (carriedStorage); a hot start reseeds it with the flow's m^n -TI mprans.TADR CompatibleBackwardEuler state -TI mprans.TADR RKEV state -TI mprans.VOF RKEV state -TI mprans.VOF3P RKEV state -TI mprans.VOS3P RKEV state +TI kernels.TADR CompatibleBackwardEuler state +TI kernels.TADR RKEV state +TI kernels.VOF RKEV state +TI kernels.VOF3P RKEV state +TI kernels.VOS3P RKEV state +# classes of the former proteus.richards, proteus.m_comp_co2, proteus.ADR (added when the kernels moved into one package, C49 R1: the +# test now walks all of proteus.kernels), and the three the gwvd port brought into the core modules +SC kernels.ADR ShockCapturing unmeasured +SG kernels.ADR SubgridError unmeasured +SO SplitOperator ISO_fixed_MinModelStep unmeasured +STEP StepControl Fixed_dt_controller_systemit unmeasured +TI TimeIntegration NonConservativeBackwardEuler state +TI kernels.Richards RKEV state +TI kernels.Richards ThetaScheme state +TI kernels.m_comp_co2 RKEV state +TI kernels.m_comp_co2 ThetaScheme state diff --git a/test/step_resource_growth_mpi.py b/test/step_resource_growth_mpi.py index 9a53d56459..a1d51b3241 100644 --- a/test/step_resource_growth_mpi.py +++ b/test/step_resource_growth_mpi.py @@ -76,7 +76,7 @@ def make_comms(n): if os.environ.get("LEAKY") == "1": def scatterDOFArray(self, a): - """main f392a159 (proteus/mprans/VOF.py:980 there): one ghosted vector per id(a), over a itself.""" + """main f392a159 (proteus/kernels/VOF.py:980 there): one ghosted vector per id(a), over a itself.""" if self.comm.size() == 1: return cache = self.__dict__.setdefault("_dofVecsById", {}) diff --git a/test/step_retry_mpi.py b/test/step_retry_mpi.py index c88ffe0757..3986f5a43a 100644 --- a/test/step_retry_mpi.py +++ b/test/step_retry_mpi.py @@ -41,7 +41,7 @@ def boundary_integral_gauges(pList, nList): the first, attached to the RANS2P/RANS3PF model; it writes boundary_integrals.csv.""" from proteus.Gauges import BoundaryIntegralGauges for p, n in zip(pList, nList): - if type(p.coefficients).__module__ in ("proteus.mprans.RANS2P", "proteus.mprans.RANS3PF"): + if type(p.coefficients).__module__ in ("proteus.kernels.RANS2P", "proteus.kernels.RANS3PF"): flags = [int(f) for f in os.environ["BIGAUGES"].split(",")] gauge = BoundaryIntegralGauges(tags=flags, moment_points={str(flags[0]): (0.1, 0.2, 0.0)}, fileName="boundary_integrals.csv") diff --git a/test/strong_dirichlet_poisson_mpi.py b/test/strong_dirichlet_poisson_mpi.py index fe1c99fa3e..f5e53e55f2 100644 --- a/test/strong_dirichlet_poisson_mpi.py +++ b/test/strong_dirichlet_poisson_mpi.py @@ -37,6 +37,14 @@ mo.parallelPartitioningType = MeshTools.MeshParallelPartitioningTypes.element mo.nLayersOfOverlapForParallel = 0 mo.genMesh = True +if os.environ.get("STORED_MESH"): + # read triangle's output from a directory instead of running the `triangle` on PATH (every build of it meshes the + # same .poly differently; see TRIANGLE_AUDIT_2026-11-21.md): sd_poisson.{node,ele,edge} are staged into the cwd by + # every rank (rank_staging: atomic, the same bytes, no collective; test_rank_staging forbids an in-place copy). + import rank_staging + for ext in ("node", "ele", "edge"): + rank_staging.copy(os.path.join(os.environ["STORED_MESH"], name + "." + ext), name + "." + ext) + mo.genMesh = False def uex(x): diff --git a/test/strong_dirichlet_stored_mesh/sd_poisson.edge b/test/strong_dirichlet_stored_mesh/sd_poisson.edge new file mode 100644 index 0000000000..a01baa9988 --- /dev/null +++ b/test/strong_dirichlet_stored_mesh/sd_poisson.edge @@ -0,0 +1,402 @@ +400 1 + 1 70 13 0 + 2 13 131 0 + 3 131 70 0 + 4 26 42 0 + 5 42 82 0 + 6 82 26 0 + 7 125 66 0 + 8 66 4 3 + 9 4 125 0 + 10 88 53 0 + 11 53 6 4 + 12 6 88 0 + 13 5 92 0 + 14 92 48 0 + 15 48 5 0 + 16 48 99 0 + 17 99 5 0 + 18 99 63 0 + 19 63 5 0 + 20 67 130 0 + 21 130 9 0 + 22 9 67 0 + 23 56 31 0 + 24 31 96 0 + 25 96 56 0 + 26 45 91 0 + 27 91 10 0 + 28 10 45 0 + 29 51 106 0 + 30 106 11 0 + 31 11 51 0 + 32 6 43 0 + 33 43 88 0 + 34 75 39 0 + 35 39 122 0 + 36 122 75 0 + 37 61 120 0 + 38 120 12 0 + 39 12 61 0 + 40 72 9 3 + 41 130 72 0 + 42 79 41 0 + 43 41 136 0 + 44 136 79 0 + 45 94 49 0 + 46 49 14 0 + 47 14 94 0 + 48 85 46 0 + 49 46 14 0 + 50 14 85 0 + 51 10 83 0 + 52 83 45 0 + 53 91 56 0 + 54 56 10 0 + 55 115 59 0 + 56 59 17 0 + 57 17 115 0 + 58 47 97 0 + 59 97 17 0 + 60 17 47 0 + 61 109 64 0 + 62 64 18 4 + 63 18 109 0 + 64 104 69 0 + 65 69 19 0 + 66 19 104 0 + 67 11 100 0 + 68 100 51 0 + 69 65 127 0 + 70 127 20 0 + 71 20 65 0 + 72 12 116 0 + 73 116 61 0 + 74 120 75 0 + 75 75 12 0 + 76 134 13 0 + 77 70 134 0 + 78 62 123 0 + 79 123 23 0 + 80 23 62 0 + 81 134 79 0 + 82 79 13 0 + 83 71 137 0 + 84 137 25 0 + 85 25 71 0 + 86 44 89 0 + 87 89 26 0 + 88 26 44 0 + 89 43 86 0 + 90 86 26 0 + 91 26 43 0 + 92 47 95 0 + 93 95 27 0 + 94 27 47 0 + 95 14 42 0 + 96 42 85 0 + 97 50 102 0 + 98 102 28 0 + 99 28 50 0 + 100 46 94 0 + 101 52 107 0 + 102 107 29 0 + 103 29 52 0 + 104 87 49 0 + 105 49 29 0 + 106 29 87 0 + 107 55 111 0 + 108 111 30 0 + 109 30 55 0 + 110 54 110 0 + 111 110 30 0 + 112 30 54 0 + 113 58 17 0 + 114 97 58 0 + 115 57 113 0 + 116 113 31 0 + 117 31 57 0 + 118 60 118 0 + 119 118 32 0 + 120 32 60 0 + 121 58 115 0 + 122 62 121 0 + 123 121 33 0 + 124 33 62 0 + 125 98 59 0 + 126 59 33 0 + 127 33 98 0 + 128 65 126 0 + 129 126 34 0 + 130 34 65 0 + 131 18 52 0 + 132 52 109 0 + 133 68 20 3 + 134 127 68 0 + 135 67 128 0 + 136 128 35 0 + 137 35 67 0 + 138 103 63 0 + 139 63 36 0 + 140 36 103 0 + 141 19 50 0 + 142 50 104 0 + 143 71 135 0 + 144 135 37 0 + 145 37 71 0 + 146 129 69 0 + 147 69 37 0 + 148 37 129 0 + 149 74 139 0 + 150 139 38 0 + 151 38 74 0 + 152 73 138 0 + 153 138 38 0 + 154 38 73 0 + 155 77 23 0 + 156 123 77 0 + 157 76 141 0 + 158 141 39 0 + 159 39 76 0 + 160 78 143 0 + 161 143 40 0 + 162 40 78 0 + 163 133 77 0 + 164 77 40 0 + 165 40 133 0 + 166 81 25 3 + 167 137 81 0 + 168 80 145 0 + 169 145 41 0 + 170 41 80 0 + 171 84 27 0 + 172 27 42 0 + 173 42 84 0 + 174 10 42 0 + 175 42 83 0 + 176 29 43 0 + 177 43 87 0 + 178 82 43 0 + 179 86 44 0 + 180 90 30 0 + 181 30 45 0 + 182 45 90 0 + 183 89 45 0 + 184 45 26 0 + 185 93 28 0 + 186 28 46 0 + 187 46 93 0 + 188 5 46 0 + 189 46 92 0 + 190 31 47 0 + 191 47 96 0 + 192 84 47 0 + 193 33 48 0 + 194 48 98 0 + 195 95 48 0 + 196 48 27 0 + 197 101 29 0 + 198 49 101 0 + 199 11 49 0 + 200 49 100 0 + 201 36 50 0 + 202 50 103 0 + 203 93 50 0 + 204 105 35 0 + 205 35 51 0 + 206 51 105 0 + 207 102 51 0 + 208 51 28 0 + 209 108 34 0 + 210 34 52 0 + 211 52 108 0 + 212 101 52 0 + 213 107 53 0 + 214 53 29 0 + 215 90 54 0 + 216 110 55 0 + 217 112 31 0 + 218 56 112 0 + 219 111 56 0 + 220 56 30 0 + 221 112 57 0 + 222 114 32 0 + 223 32 58 0 + 224 58 114 0 + 225 113 58 0 + 226 58 31 0 + 227 117 33 0 + 228 59 117 0 + 229 12 59 0 + 230 59 116 0 + 231 114 60 0 + 232 119 38 0 + 233 38 61 0 + 234 61 119 0 + 235 118 61 0 + 236 61 32 0 + 237 39 62 0 + 238 62 122 0 + 239 117 62 0 + 240 124 36 0 + 241 63 124 0 + 242 121 63 0 + 243 63 33 0 + 244 4 64 4 + 245 64 125 0 + 246 106 65 0 + 247 65 11 0 + 248 108 65 0 + 249 126 66 0 + 250 66 34 0 + 251 37 67 0 + 252 67 129 0 + 253 105 67 0 + 254 128 68 0 + 255 68 35 0 + 256 132 37 0 + 257 69 132 0 + 258 13 69 0 + 259 69 131 0 + 260 40 70 0 + 261 70 133 0 + 262 124 70 0 + 263 70 36 0 + 264 41 71 0 + 265 71 136 0 + 266 132 71 0 + 267 135 72 0 + 268 72 37 0 + 269 119 73 0 + 270 138 74 0 + 271 140 39 0 + 272 75 140 0 + 273 139 75 0 + 274 75 38 0 + 275 140 76 0 + 276 142 40 0 + 277 77 142 0 + 278 141 77 0 + 279 77 39 0 + 280 142 78 0 + 281 144 41 0 + 282 79 144 0 + 283 143 79 0 + 284 79 40 0 + 285 144 80 0 + 286 145 81 0 + 287 81 41 0 + 288 14 43 0 + 289 82 14 0 + 290 83 26 0 + 291 10 47 0 + 292 84 10 0 + 293 27 46 0 + 294 85 27 0 + 295 6 44 4 + 296 86 6 0 + 297 87 14 0 + 298 88 29 0 + 299 15 45 0 + 300 89 15 0 + 301 44 15 4 + 302 15 54 4 + 303 90 15 0 + 304 91 30 0 + 305 92 27 0 + 306 5 50 0 + 307 93 5 0 + 308 28 49 0 + 309 94 28 0 + 310 17 48 0 + 311 95 17 0 + 312 96 10 0 + 313 97 31 0 + 314 98 17 0 + 315 99 33 0 + 316 100 28 0 + 317 11 52 0 + 318 101 11 0 + 319 19 51 0 + 320 102 19 0 + 321 103 5 0 + 322 36 69 0 + 323 104 36 0 + 324 19 67 0 + 325 105 19 0 + 326 35 65 0 + 327 106 35 0 + 328 18 53 4 + 329 107 18 0 + 330 108 11 0 + 331 34 64 0 + 332 109 34 0 + 333 1 55 1 + 334 110 1 0 + 335 54 1 4 + 336 16 56 0 + 337 111 16 0 + 338 55 16 1 + 339 16 57 1 + 340 112 16 0 + 341 7 58 0 + 342 113 7 0 + 343 57 7 1 + 344 7 60 1 + 345 114 7 0 + 346 32 59 0 + 347 115 32 0 + 348 116 32 0 + 349 12 62 0 + 350 117 12 0 + 351 21 61 0 + 352 118 21 0 + 353 60 21 1 + 354 21 73 1 + 355 119 21 0 + 356 120 38 0 + 357 23 63 0 + 358 121 23 0 + 359 122 12 0 + 360 123 39 0 + 361 23 70 0 + 362 124 23 0 + 363 125 34 0 + 364 20 66 3 + 365 126 20 0 + 366 127 35 0 + 367 9 68 3 + 368 128 9 0 + 369 129 19 0 + 370 130 37 0 + 371 131 36 0 + 372 13 71 0 + 373 132 13 0 + 374 133 23 0 + 375 134 40 0 + 376 25 72 3 + 377 135 25 0 + 378 136 13 0 + 379 137 41 0 + 380 2 74 2 + 381 138 2 0 + 382 73 2 1 + 383 22 75 0 + 384 139 22 0 + 385 74 22 2 + 386 22 76 2 + 387 140 22 0 + 388 8 77 0 + 389 141 8 0 + 390 76 8 2 + 391 8 78 2 + 392 142 8 0 + 393 24 79 0 + 394 143 24 0 + 395 78 24 2 + 396 24 80 2 + 397 144 24 0 + 398 3 81 3 + 399 145 3 0 + 400 80 3 2 +# Generated by /home/cekees/proteus-envs/dev_pip/lib/python3.13/site-packages/petsc/bin/triangle -VApq30Dena0.00500000 -e sd_poisson.poly diff --git a/test/strong_dirichlet_stored_mesh/sd_poisson.ele b/test/strong_dirichlet_stored_mesh/sd_poisson.ele new file mode 100644 index 0000000000..d7a9409700 --- /dev/null +++ b/test/strong_dirichlet_stored_mesh/sd_poisson.ele @@ -0,0 +1,258 @@ +256 3 1 + 1 70 13 131 1 + 2 26 42 82 1 + 3 125 66 4 1 + 4 88 53 6 1 + 5 5 92 48 1 + 6 48 99 5 1 + 7 5 99 63 1 + 8 67 130 9 1 + 9 56 31 96 1 + 10 45 91 10 1 + 11 51 106 11 1 + 12 6 43 88 1 + 13 75 39 122 1 + 14 61 120 12 1 + 15 72 9 130 1 + 16 79 41 136 1 + 17 94 49 14 1 + 18 85 46 14 1 + 19 10 83 45 1 + 20 10 91 56 1 + 21 115 59 17 1 + 22 47 97 17 1 + 23 109 64 18 1 + 24 104 69 19 1 + 25 11 100 51 1 + 26 65 127 20 1 + 27 12 116 61 1 + 28 12 120 75 1 + 29 134 13 70 1 + 30 62 123 23 1 + 31 13 134 79 1 + 32 71 137 25 1 + 33 44 89 26 1 + 34 43 86 26 1 + 35 47 95 27 1 + 36 14 42 85 1 + 37 50 102 28 1 + 38 14 46 94 1 + 39 52 107 29 1 + 40 87 49 29 1 + 41 55 111 30 1 + 42 54 110 30 1 + 43 58 17 97 1 + 44 57 113 31 1 + 45 60 118 32 1 + 46 17 58 115 1 + 47 62 121 33 1 + 48 98 59 33 1 + 49 65 126 34 1 + 50 18 52 109 1 + 51 68 20 127 1 + 52 67 128 35 1 + 53 103 63 36 1 + 54 19 50 104 1 + 55 71 135 37 1 + 56 129 69 37 1 + 57 74 139 38 1 + 58 73 138 38 1 + 59 77 23 123 1 + 60 76 141 39 1 + 61 78 143 40 1 + 62 133 77 40 1 + 63 81 25 137 1 + 64 80 145 41 1 + 65 84 27 42 1 + 66 83 10 42 1 + 67 87 29 43 1 + 68 26 82 43 1 + 69 26 86 44 1 + 70 90 30 45 1 + 71 26 89 45 1 + 72 93 28 46 1 + 73 92 5 46 1 + 74 96 31 47 1 + 75 27 84 47 1 + 76 98 33 48 1 + 77 27 95 48 1 + 78 101 29 49 1 + 79 100 11 49 1 + 80 103 36 50 1 + 81 28 93 50 1 + 82 105 35 51 1 + 83 28 102 51 1 + 84 108 34 52 1 + 85 29 101 52 1 + 86 29 107 53 1 + 87 30 90 54 1 + 88 30 110 55 1 + 89 112 31 56 1 + 90 30 111 56 1 + 91 31 112 57 1 + 92 114 32 58 1 + 93 31 113 58 1 + 94 117 33 59 1 + 95 116 12 59 1 + 96 32 114 60 1 + 97 119 38 61 1 + 98 32 118 61 1 + 99 122 39 62 1 + 100 33 117 62 1 + 101 124 36 63 1 + 102 33 121 63 1 + 103 125 4 64 1 + 104 11 106 65 1 + 105 34 108 65 1 + 106 34 126 66 1 + 107 129 37 67 1 + 108 35 105 67 1 + 109 35 128 68 1 + 110 132 37 69 1 + 111 131 13 69 1 + 112 133 40 70 1 + 113 36 124 70 1 + 114 136 41 71 1 + 115 37 132 71 1 + 116 37 135 72 1 + 117 38 119 73 1 + 118 38 138 74 1 + 119 140 39 75 1 + 120 38 139 75 1 + 121 39 140 76 1 + 122 142 40 77 1 + 123 39 141 77 1 + 124 40 142 78 1 + 125 144 41 79 1 + 126 40 143 79 1 + 127 41 144 80 1 + 128 41 145 81 1 + 129 14 43 82 1 + 130 42 14 82 1 + 131 26 45 83 1 + 132 42 26 83 1 + 133 10 47 84 1 + 134 42 10 84 1 + 135 27 46 85 1 + 136 42 27 85 1 + 137 6 44 86 1 + 138 43 6 86 1 + 139 14 49 87 1 + 140 43 14 87 1 + 141 29 53 88 1 + 142 43 29 88 1 + 143 15 45 89 1 + 144 44 15 89 1 + 145 15 54 90 1 + 146 45 15 90 1 + 147 30 56 91 1 + 148 45 30 91 1 + 149 27 48 92 1 + 150 46 27 92 1 + 151 5 50 93 1 + 152 46 5 93 1 + 153 28 49 94 1 + 154 46 28 94 1 + 155 17 48 95 1 + 156 47 17 95 1 + 157 10 56 96 1 + 158 47 10 96 1 + 159 31 58 97 1 + 160 47 31 97 1 + 161 17 59 98 1 + 162 48 17 98 1 + 163 33 63 99 1 + 164 48 33 99 1 + 165 28 51 100 1 + 166 49 28 100 1 + 167 11 52 101 1 + 168 49 11 101 1 + 169 19 51 102 1 + 170 50 19 102 1 + 171 5 63 103 1 + 172 50 5 103 1 + 173 36 69 104 1 + 174 50 36 104 1 + 175 19 67 105 1 + 176 51 19 105 1 + 177 35 65 106 1 + 178 51 35 106 1 + 179 18 53 107 1 + 180 52 18 107 1 + 181 11 65 108 1 + 182 52 11 108 1 + 183 34 64 109 1 + 184 52 34 109 1 + 185 1 55 110 1 + 186 54 1 110 1 + 187 16 56 111 1 + 188 55 16 111 1 + 189 16 57 112 1 + 190 56 16 112 1 + 191 7 58 113 1 + 192 57 7 113 1 + 193 7 60 114 1 + 194 58 7 114 1 + 195 32 59 115 1 + 196 58 32 115 1 + 197 32 61 116 1 + 198 59 32 116 1 + 199 12 62 117 1 + 200 59 12 117 1 + 201 21 61 118 1 + 202 60 21 118 1 + 203 21 73 119 1 + 204 61 21 119 1 + 205 38 75 120 1 + 206 61 38 120 1 + 207 23 63 121 1 + 208 62 23 121 1 + 209 12 75 122 1 + 210 62 12 122 1 + 211 39 77 123 1 + 212 62 39 123 1 + 213 23 70 124 1 + 214 63 23 124 1 + 215 34 66 125 1 + 216 64 34 125 1 + 217 20 66 126 1 + 218 65 20 126 1 + 219 35 68 127 1 + 220 65 35 127 1 + 221 9 68 128 1 + 222 67 9 128 1 + 223 19 69 129 1 + 224 67 19 129 1 + 225 37 72 130 1 + 226 67 37 130 1 + 227 36 70 131 1 + 228 69 36 131 1 + 229 13 71 132 1 + 230 69 13 132 1 + 231 23 77 133 1 + 232 70 23 133 1 + 233 40 79 134 1 + 234 70 40 134 1 + 235 25 72 135 1 + 236 71 25 135 1 + 237 13 79 136 1 + 238 71 13 136 1 + 239 41 81 137 1 + 240 71 41 137 1 + 241 2 74 138 1 + 242 73 2 138 1 + 243 22 75 139 1 + 244 74 22 139 1 + 245 22 76 140 1 + 246 75 22 140 1 + 247 8 77 141 1 + 248 76 8 141 1 + 249 8 78 142 1 + 250 77 8 142 1 + 251 24 79 143 1 + 252 78 24 143 1 + 253 24 80 144 1 + 254 79 24 144 1 + 255 3 81 145 1 + 256 80 3 145 1 +# Generated by /home/cekees/proteus-envs/dev_pip/lib/python3.13/site-packages/petsc/bin/triangle -VApq30Dena0.00500000 -e sd_poisson.poly diff --git a/test/strong_dirichlet_stored_mesh/sd_poisson.node b/test/strong_dirichlet_stored_mesh/sd_poisson.node new file mode 100644 index 0000000000..99f88b0ff8 --- /dev/null +++ b/test/strong_dirichlet_stored_mesh/sd_poisson.node @@ -0,0 +1,147 @@ +145 2 0 1 + 1 0 0 1 + 2 1 0 1 + 3 1 1 3 + 4 0 1 3 + 5 0.5 0.5 0 + 6 0 0.5 4 + 7 0.5 0 1 + 8 1 0.5 2 + 9 0.5 1 3 + 10 0.25 0.25 0 + 11 0.25 0.75 0 + 12 0.75 0.25 0 + 13 0.75 0.75 0 + 14 0.25 0.5 0 + 15 0 0.25 4 + 16 0.25 0 1 + 17 0.5 0.25 0 + 18 0 0.75 4 + 19 0.5 0.75 0 + 20 0.25 1 3 + 21 0.75 0 1 + 22 1 0.25 2 + 23 0.75 0.5 0 + 24 1 0.75 2 + 25 0.75 1 3 + 26 0.125 0.375 0 + 27 0.375 0.375 0 + 28 0.375 0.625 0 + 29 0.125 0.625 0 + 30 0.125 0.125 0 + 31 0.375 0.125 0 + 32 0.625 0.125 0 + 33 0.625 0.375 0 + 34 0.125 0.875 0 + 35 0.375 0.875 0 + 36 0.625 0.625 0 + 37 0.625 0.875 0 + 38 0.875 0.125 0 + 39 0.875 0.375 0 + 40 0.875 0.625 0 + 41 0.875 0.875 0 + 42 0.25 0.375 0 + 43 0.125 0.5 0 + 44 0 0.375 4 + 45 0.125 0.25 0 + 46 0.375 0.5 0 + 47 0.375 0.25 0 + 48 0.5 0.375 0 + 49 0.25 0.625 0 + 50 0.5 0.625 0 + 51 0.375 0.75 0 + 52 0.125 0.75 0 + 53 0 0.625 4 + 54 0 0.125 4 + 55 0.125 0 1 + 56 0.25 0.125 0 + 57 0.375 0 1 + 58 0.5 0.125 0 + 59 0.625 0.25 0 + 60 0.625 0 1 + 61 0.75 0.125 0 + 62 0.75 0.375 0 + 63 0.625 0.5 0 + 64 0 0.875 4 + 65 0.25 0.875 0 + 66 0.125 1 3 + 67 0.5 0.875 0 + 68 0.375 1 3 + 69 0.625 0.75 0 + 70 0.75 0.625 0 + 71 0.75 0.875 0 + 72 0.625 1 3 + 73 0.875 0 1 + 74 1 0.125 2 + 75 0.875 0.25 0 + 76 1 0.375 2 + 77 0.875 0.5 0 + 78 1 0.625 2 + 79 0.875 0.75 0 + 80 1 0.875 2 + 81 0.875 1 3 + 82 0.1875 0.4375 0 + 83 0.1875 0.3125 0 + 84 0.3125 0.3125 0 + 85 0.3125 0.4375 0 + 86 0.0625 0.4375 0 + 87 0.1875 0.5625 0 + 88 0.0625 0.5625 0 + 89 0.0625 0.3125 0 + 90 0.0625 0.1875 0 + 91 0.1875 0.1875 0 + 92 0.4375 0.4375 0 + 93 0.4375 0.5625 0 + 94 0.3125 0.5625 0 + 95 0.4375 0.3125 0 + 96 0.3125 0.1875 0 + 97 0.4375 0.1875 0 + 98 0.5625 0.3125 0 + 99 0.5625 0.4375 0 + 100 0.3125 0.6875 0 + 101 0.1875 0.6875 0 + 102 0.4375 0.6875 0 + 103 0.5625 0.5625 0 + 104 0.5625 0.6875 0 + 105 0.4375 0.8125 0 + 106 0.3125 0.8125 0 + 107 0.0625 0.6875 0 + 108 0.1875 0.8125 0 + 109 0.0625 0.8125 0 + 110 0.0625 0.0625 0 + 111 0.1875 0.0625 0 + 112 0.3125 0.0625 0 + 113 0.4375 0.0625 0 + 114 0.5625 0.0625 0 + 115 0.5625 0.1875 0 + 116 0.6875 0.1875 0 + 117 0.6875 0.3125 0 + 118 0.6875 0.0625 0 + 119 0.8125 0.0625 0 + 120 0.8125 0.1875 0 + 121 0.6875 0.4375 0 + 122 0.8125 0.3125 0 + 123 0.8125 0.4375 0 + 124 0.6875 0.5625 0 + 125 0.0625 0.9375 0 + 126 0.1875 0.9375 0 + 127 0.3125 0.9375 0 + 128 0.4375 0.9375 0 + 129 0.5625 0.8125 0 + 130 0.5625 0.9375 0 + 131 0.6875 0.6875 0 + 132 0.6875 0.8125 0 + 133 0.8125 0.5625 0 + 134 0.8125 0.6875 0 + 135 0.6875 0.9375 0 + 136 0.8125 0.8125 0 + 137 0.8125 0.9375 0 + 138 0.9375 0.0625 0 + 139 0.9375 0.1875 0 + 140 0.9375 0.3125 0 + 141 0.9375 0.4375 0 + 142 0.9375 0.5625 0 + 143 0.9375 0.6875 0 + 144 0.9375 0.8125 0 + 145 0.9375 0.9375 0 +# Generated by /home/cekees/proteus-envs/dev_pip/lib/python3.13/site-packages/petsc/bin/triangle -VApq30Dena0.00500000 -e sd_poisson.poly diff --git a/test/surface_tension/rising_bubble_rans3p/ls_consrv_p.py b/test/surface_tension/rising_bubble_rans3p/ls_consrv_p.py index a4cdcaad31..793e5260b2 100644 --- a/test/surface_tension/rising_bubble_rans3p/ls_consrv_p.py +++ b/test/surface_tension/rising_bubble_rans3p/ls_consrv_p.py @@ -4,7 +4,7 @@ from .risingBubble import * except: from risingBubble import * -from proteus.mprans import MCorr3P +from proteus.kernels import MCorr3P LevelModelType = MCorr3P.LevelModel coefficients = MCorr3P.Coefficients(LS_model=LS_model, diff --git a/test/surface_tension/rising_bubble_rans3p/ls_p.py b/test/surface_tension/rising_bubble_rans3p/ls_p.py index 3d171ac20b..d782f104b3 100644 --- a/test/surface_tension/rising_bubble_rans3p/ls_p.py +++ b/test/surface_tension/rising_bubble_rans3p/ls_p.py @@ -4,7 +4,7 @@ from .risingBubble import * except: from risingBubble import * -from proteus.mprans import NCLS3P +from proteus.kernels import NCLS3P LevelModelType = NCLS3P.LevelModel coefficients = NCLS3P.Coefficients(V_model=V_model, diff --git a/test/surface_tension/rising_bubble_rans3p/pressureInitial_p.py b/test/surface_tension/rising_bubble_rans3p/pressureInitial_p.py index 529d791514..b2206bb3e2 100644 --- a/test/surface_tension/rising_bubble_rans3p/pressureInitial_p.py +++ b/test/surface_tension/rising_bubble_rans3p/pressureInitial_p.py @@ -5,7 +5,7 @@ from .risingBubble import * except: from risingBubble import * -from proteus.mprans import PresInit +from proteus.kernels import PresInit name = "pressureInitial" #LevelModelType = PresInit.LevelModel diff --git a/test/surface_tension/rising_bubble_rans3p/pressure_p.py b/test/surface_tension/rising_bubble_rans3p/pressure_p.py index d4bea1b986..76317b07fc 100644 --- a/test/surface_tension/rising_bubble_rans3p/pressure_p.py +++ b/test/surface_tension/rising_bubble_rans3p/pressure_p.py @@ -5,7 +5,7 @@ from .risingBubble import * except: from risingBubble import * -from proteus.mprans import Pres +from proteus.kernels import Pres name = "pressure" LevelModelType = Pres.LevelModel diff --git a/test/surface_tension/rising_bubble_rans3p/pressureincrement_p.py b/test/surface_tension/rising_bubble_rans3p/pressureincrement_p.py index b4adb3a3a1..294b7f189a 100644 --- a/test/surface_tension/rising_bubble_rans3p/pressureincrement_p.py +++ b/test/surface_tension/rising_bubble_rans3p/pressureincrement_p.py @@ -8,7 +8,7 @@ name = "pressureincrement" -from proteus.mprans import PresInc +from proteus.kernels import PresInc LevelModelType = PresInc.LevelModel coefficients=PresInc.Coefficients(rho_f_min = (1.0-1.0e-8)*rho_1, rho_s_min = (1.0-1.0e-8)*rho_s, diff --git a/test/surface_tension/rising_bubble_rans3p/redist_n.py b/test/surface_tension/rising_bubble_rans3p/redist_n.py index a98caa584a..cce8780758 100644 --- a/test/surface_tension/rising_bubble_rans3p/redist_n.py +++ b/test/surface_tension/rising_bubble_rans3p/redist_n.py @@ -5,7 +5,7 @@ except: from redist_p import * from risingBubble import * -from proteus.mprans import RDLS +from proteus.kernels import RDLS tolFac = 0.0 nl_atol_res = rd_nl_atol_res diff --git a/test/surface_tension/rising_bubble_rans3p/redist_p.py b/test/surface_tension/rising_bubble_rans3p/redist_p.py index 75b9c611f0..b34f00690f 100644 --- a/test/surface_tension/rising_bubble_rans3p/redist_p.py +++ b/test/surface_tension/rising_bubble_rans3p/redist_p.py @@ -5,7 +5,7 @@ from .risingBubble import * except: from risingBubble import * -from proteus.mprans import RDLS +from proteus.kernels import RDLS """ The redistancing equation in the sloshbox test problem. """ diff --git a/test/surface_tension/rising_bubble_rans3p/twp_navier_stokes_p.py b/test/surface_tension/rising_bubble_rans3p/twp_navier_stokes_p.py index 263be7ef44..6d6b186182 100644 --- a/test/surface_tension/rising_bubble_rans3p/twp_navier_stokes_p.py +++ b/test/surface_tension/rising_bubble_rans3p/twp_navier_stokes_p.py @@ -4,7 +4,7 @@ from .risingBubble import * except: from risingBubble import * -from proteus.mprans import RANS3PF +from proteus.kernels import RANS3PF if useOnlyVF: LS_model = None diff --git a/test/surface_tension/rising_bubble_rans3p/vof_p.py b/test/surface_tension/rising_bubble_rans3p/vof_p.py index 3e91ea3a48..4cb1ab3b72 100644 --- a/test/surface_tension/rising_bubble_rans3p/vof_p.py +++ b/test/surface_tension/rising_bubble_rans3p/vof_p.py @@ -5,7 +5,7 @@ from .risingBubble import * except: from risingBubble import * -from proteus.mprans import VOF3P +from proteus.kernels import VOF3P LevelModelType = VOF3P.LevelModel coefficients = VOF3P.Coefficients(LS_model=LS_model, diff --git a/test/sw2dcv_bathymetry_forms_mpi.py b/test/sw2dcv_bathymetry_forms_mpi.py index 5c5200c5f0..d4dbc09920 100644 --- a/test/sw2dcv_bathymetry_forms_mpi.py +++ b/test/sw2dcv_bathymetry_forms_mpi.py @@ -59,7 +59,7 @@ def node_file_xy(): + "\nmySWFlowProblem.bathymetry = " + _bathymetry + "\n") rank_staging.write("__init__.py", "") -from proteus.mprans import SW2DCV, GN_SW2DCV +from proteus.kernels import SW2DCV, GN_SW2DCV module = GN_SW2DCV if GN else SW2DCV _initializeMesh = module.Coefficients.initializeMesh def initializeMesh(self, mesh): diff --git a/test/sw2dcv_bathymetry_mpi.py b/test/sw2dcv_bathymetry_mpi.py index f3f8ae2e77..6ef8aaf19f 100644 --- a/test/sw2dcv_bathymetry_mpi.py +++ b/test/sw2dcv_bathymetry_mpi.py @@ -51,7 +51,7 @@ def wrapped(*args, **kwargs): return wrapped setattr(cpartitioning, name, wrap(getattr(cpartitioning, name))) -from proteus.mprans import SW2DCV, GN_SW2DCV +from proteus.kernels import SW2DCV, GN_SW2DCV module = GN_SW2DCV if GN else SW2DCV _initializeMesh = module.Coefficients.initializeMesh def initializeMesh(self, mesh): diff --git a/test/sw2dcv_partition_mpi.py b/test/sw2dcv_partition_mpi.py index 2b9f571537..160bc535a9 100644 --- a/test/sw2dcv_partition_mpi.py +++ b/test/sw2dcv_partition_mpi.py @@ -19,7 +19,7 @@ + "\nmySWFlowProblem.swe_parameters['LUMPED_MASS_MATRIX'] = %d\n" % (0 if os.environ.get("CONSISTENT") else 1)) rank_staging.write("__init__.py", "") -from proteus.mprans import SW2DCV +from proteus.kernels import SW2DCV _SCATTER_CALLS = [0] if os.environ.get("NOSCAT"): def _no_scatter(self, a): diff --git a/test/tadr_mixed_bc_mpi.py b/test/tadr_mixed_bc_mpi.py index 0af50306dc..12a914e73d 100644 --- a/test/tadr_mixed_bc_mpi.py +++ b/test/tadr_mixed_bc_mpi.py @@ -28,7 +28,7 @@ from proteus.NonlinearSolvers import Newton from proteus.TimeIntegration import BackwardEuler from proteus.StepControl import Min_dt_controller -from proteus.mprans import TADR +from proteus.kernels import TADR nx = int(os.environ.get("NN", "41")) D = float(os.environ.get("D", "0.05")) diff --git a/test/tadr_partition_mpi.py b/test/tadr_partition_mpi.py index 89133e4c68..d308611252 100644 --- a/test/tadr_partition_mpi.py +++ b/test/tadr_partition_mpi.py @@ -45,7 +45,7 @@ def partitionMesh(self, nLayersOfOverlap=1, parallelPartitioningType=MT.MeshPara nodeOwners=nodeOwners, elementOwners=elementOwners, nodeWeights=nodeWeights) MT.Mesh.partitionMesh = partitionMesh -from proteus.mprans import TADR +from proteus.kernels import TADR if os.environ.get("POROUS"): # a porosity that varies in space, so the nodal projection of it differs from dof to dof def _theta(x): @@ -103,7 +103,7 @@ def getResidual(self, u, r): TADR.LevelModel.getResidual = getResidual if os.environ.get("NOREDUCE"): # each rank normalizes the Taylor-Galerkin entropy viscosity by its own subdomain (a control) - from proteus.mprans import EntropyViscosity + from proteus.kernels import EntropyViscosity EntropyViscosity.reduce_numDiff = lambda *args: None if os.environ.get("OLDMAX"): TADR.RKEV.ownedMaxCFL = lambda self: self.cfl.max() diff --git a/test/test_archive_declared_fields.py b/test/test_archive_declared_fields.py index 250451350c..e0d287f08c 100644 --- a/test/test_archive_declared_fields.py +++ b/test/test_archive_declared_fields.py @@ -12,12 +12,12 @@ import numpy as np import pytest -pytest.importorskip("proteus.mprans.SW2DCV", reason="needs built extensions") +pytest.importorskip("proteus.kernels.SW2DCV", reason="needs built extensions") from proteus.ArchiveFields import (ArchiveField, ArchiveFieldError, # noqa: E402 archive_fields_for) from proteus.TransportCoefficients import TC_base # noqa: E402 -from proteus.mprans import CLSVOF, GN_SW2DCV, RANS2P, RANS3PF, SW2DCV # noqa: E402 +from proteus.kernels import CLSVOF, GN_SW2DCV, RANS2P, RANS3PF, SW2DCV # noqa: E402 N_DOF = 5 diff --git a/test/test_argsdict_values.py b/test/test_argsdict_values.py index 6776386309..a08e201e57 100644 --- a/test/test_argsdict_values.py +++ b/test/test_argsdict_values.py @@ -74,7 +74,7 @@ def _proteus_sources(): def test_scanner_catches_trailing_comma(): source = textwrap.dedent(""" - from proteus.mprans import cArgumentsDict + from proteus import cArgumentsDict argsDict = cArgumentsDict.ArgumentsDict() argsDict["ok_array"] = a argsDict["ok_scalar"] = 1.0 diff --git a/test/test_argsdict_widening.py b/test/test_argsdict_widening.py index ff16c1e5be..6d9a85e842 100644 --- a/test/test_argsdict_widening.py +++ b/test/test_argsdict_widening.py @@ -12,7 +12,7 @@ import numpy as np import pytest -from proteus.mprans import cArgumentsDict +from proteus import cArgumentsDict def make(**kw): diff --git a/test/test_bodydynamics.py b/test/test_bodydynamics.py index b5273c3beb..86faa14260 100644 --- a/test/test_bodydynamics.py +++ b/test/test_bodydynamics.py @@ -29,7 +29,7 @@ def remove_files(filenames): class TestAuxFunctions(unittest.TestCase): def testForwardEler(self): - from proteus.mprans.BodyDynamics import forward_euler + from proteus.mbd.BodyDynamics import forward_euler p0 = 5.0 v0 = 2.0 a = 0.5 @@ -41,7 +41,7 @@ def testForwardEler(self): self.assertTrue(v==v1) def testRungeKutta(self): - from proteus.mprans.BodyDynamics import runge_kutta + from proteus.mbd.BodyDynamics import runge_kutta u0 = 5.0 v0 = 2.0 dt = 0.01 @@ -84,7 +84,7 @@ def testRungeKutta(self): self.assertTrue(a==ac) def testEulerAngles(self): - from proteus.mprans.BodyDynamics import getEulerAngles + from proteus.mbd.BodyDynamics import getEulerAngles coords = np.array([ [1.,0.,0.], [0.,1.,0.], [0.,0.,1.] ]) @@ -117,8 +117,8 @@ class TestRigidBody(unittest.TestCase): def testCalculateInit(self): from proteus import Domain - from proteus.mprans import SpatialTools as st - from proteus.mprans import BodyDynamics as bd + from proteus import SpatialTools as st + from proteus.mbd import BodyDynamics as bd domain = Domain.PlanarStraightLineGraphDomain() pos = np.array([1.0, 1.0, 0.0]) rot = np.array([ [1.,0.,0.], [0.,1.,0.], [0.,0.,1.] ]) @@ -141,8 +141,8 @@ def testCalculateInit(self): def testStoreLastValues(self): from proteus import Domain - from proteus.mprans import SpatialTools as st - from proteus.mprans import BodyDynamics as bd + from proteus import SpatialTools as st + from proteus.mbd import BodyDynamics as bd domain = Domain.PlanarStraightLineGraphDomain() pos = np.array([1.0, 1.0, 0.0]) rot = np.array([ [1.,0.,0.], [0.,1.,0.], [0.,0.,1.] ]) @@ -195,8 +195,8 @@ def testStoreLastValues(self): def testGetInertia(self): from proteus import Domain from proteus import SpatialTools as st - from proteus.mprans import SpatialTools as mst - from proteus.mprans import BodyDynamics as bd + from proteus import SpatialTools as mst + from proteus.mbd import BodyDynamics as bd # 2d case domain2D = Domain.PlanarStraightLineGraphDomain() @@ -259,8 +259,8 @@ def testGetInertia(self): def testGetAcceleration(self): from proteus import Domain - from proteus.mprans import SpatialTools as st - from proteus.mprans import BodyDynamics as bd + from proteus import SpatialTools as st + from proteus.mbd import BodyDynamics as bd domain = Domain.PlanarStraightLineGraphDomain() pos = np.array([1.0, 1.0, 0.0]) rot = np.array([ [1.,0.,0.], [0.,1.,0.], [0.,0.,1.] ]) @@ -281,8 +281,8 @@ def testGetAcceleration(self): def testGetAngularAcceleration(self): from proteus import Domain - from proteus.mprans import SpatialTools as st - from proteus.mprans import BodyDynamics as bd + from proteus import SpatialTools as st + from proteus.mbd import BodyDynamics as bd domain = Domain.PlanarStraightLineGraphDomain() pos = np.array([1.0, 1.0, 0.0]) rot = np.array([ [1.,0.,0.], [0.,1.,0.], [0.,0.,1.] ]) @@ -304,8 +304,8 @@ def testGetAngularAcceleration(self): def testGetDisplacement(self): from proteus import Domain from proteus import SpatialTools as st - from proteus.mprans import SpatialTools as mst - from proteus.mprans import BodyDynamics as bd + from proteus import SpatialTools as mst + from proteus.mbd import BodyDynamics as bd # parameters domain2D = Domain.PlanarStraightLineGraphDomain() @@ -348,8 +348,8 @@ def testGetDisplacement(self): def testStep(self): from proteus import Domain from proteus import SpatialTools as st - from proteus.mprans import SpatialTools as mst - from proteus.mprans import BodyDynamics as bd + from proteus import SpatialTools as mst + from proteus.mbd import BodyDynamics as bd # parameters domain2D = Domain.PlanarStraightLineGraphDomain() @@ -390,8 +390,8 @@ def testStep(self): def _body3D(self, rotate=False): from proteus import Domain - from proteus.mprans import SpatialTools as mst - from proteus.mprans import BodyDynamics as bd + from proteus import SpatialTools as mst + from proteus.mbd import BodyDynamics as bd domain3D = Domain.PiecewiseLinearComplexDomain() dim = (0.3, 0.385, 0.4) caisson = mst.Cuboid(domain=domain3D, dim=dim, coords=[0., 0., 0.]) @@ -453,8 +453,8 @@ def testRecordFilenameFromShape(self): # def testSetRecordValues(self): # from proteus import Domain # from proteus import SpatialTools as st -# from proteus.mprans import SpatialTools as mst -# from proteus.mprans import BodyDynamics as bd +# from proteus import SpatialTools as mst +# from proteus.mbd import BodyDynamics as bd # filename='test', all_values=True @@ -464,8 +464,8 @@ class CaissonBody(unittest.TestCase): def testGetInertia(self): from proteus import Domain from proteus import SpatialTools as st - from proteus.mprans import SpatialTools as mst - from proteus.mprans import BodyDynamics as bd + from proteus import SpatialTools as mst + from proteus.mbd import BodyDynamics as bd # parameters domain2D = Domain.PlanarStraightLineGraphDomain() pos = np.array([1.0, 1.0, 0.0]) @@ -491,8 +491,8 @@ def testGetInertia(self): def testFrictionModule(self): from proteus import Domain from proteus import SpatialTools as st - from proteus.mprans import SpatialTools as mst - from proteus.mprans import BodyDynamics as bd + from proteus import SpatialTools as mst + from proteus.mbd import BodyDynamics as bd ######################### # 1st case # @@ -684,8 +684,8 @@ def testFrictionModule(self): def testOverturningModule(self): from proteus import Domain from proteus import SpatialTools as st - from proteus.mprans import SpatialTools as mst - from proteus.mprans import BodyDynamics as bd + from proteus import SpatialTools as mst + from proteus.mbd import BodyDynamics as bd # parameters domain2D = Domain.PlanarStraightLineGraphDomain() @@ -741,8 +741,8 @@ def testOverturningModule(self): class Paddle(unittest.TestCase): def testCalculate_init(self): from proteus import Domain - from proteus.mprans import SpatialTools as mst - from proteus.mprans.BodyDynamics import PaddleBody + from proteus import SpatialTools as mst + from proteus.mbd.BodyDynamics import PaddleBody domain2D = Domain.PlanarStraightLineGraphDomain() pos = np.array([2.0, 0.1 , 0.0]) dim = (0.3, 1.) @@ -754,7 +754,7 @@ def testCalculate_init(self): npt.assert_equal(PB.last_position,[pos[0],0.,0.]) npt.assert_equal(PB.rotation,np.eye(3)) npt.assert_equal(PB.last_rotation,np.eye(3)) - from proteus.mprans.BodyDynamics import getEulerAngles + from proteus.mbd.BodyDynamics import getEulerAngles npt.assert_equal(PB.rotation_euler,getEulerAngles(PB.rotation)) npt.assert_equal(PB.last_rotation_euler,getEulerAngles(PB.last_rotation)) npt.assert_equal(PB.cV_init,np.array([(1.85,-0.4), @@ -772,8 +772,8 @@ def testCalculate_init(self): def testPaddleMotion(self): from proteus import Domain - from proteus.mprans import SpatialTools as mst - from proteus.mprans.BodyDynamics import PaddleBody + from proteus import SpatialTools as mst + from proteus.mbd.BodyDynamics import PaddleBody domain2D = Domain.PlanarStraightLineGraphDomain() pos = np.array([2.0, 0.1 , 0.0]) dim = (0.3, 1.) diff --git a/test/test_boundaryconditions.py b/test/test_boundaryconditions.py index b9cef0079d..e23efdcdc9 100644 --- a/test/test_boundaryconditions.py +++ b/test/test_boundaryconditions.py @@ -16,7 +16,7 @@ from proteus import Comm, Profiling from proteus.Profiling import logEvent as log from proteus.BoundaryConditions import BC_Base, BoundaryCondition -from proteus.mprans.BoundaryConditions import BC_RANS +from proteus.BoundaryConditions import BC_RANS comm = Comm.init() @@ -851,7 +851,7 @@ def test_hydrostatic_pressure_outlet_with_depth(self): def test_wall_functions(self): from proteus import BoundaryConditions as bc - from proteus.mprans import BoundaryConditions as mbc + mbc = bc # the two-phase classes were merged into proteus.BoundaryConditions (C49 R1) # input ct = get_context() b_or = np.array([[0., -1., 0.]]) diff --git a/test/test_cython_class_attributes.py b/test/test_cython_class_attributes.py index bde1347220..267a92d16d 100644 --- a/test/test_cython_class_attributes.py +++ b/test/test_cython_class_attributes.py @@ -20,29 +20,29 @@ # modules that store compiled functions on classes (a scan of every proteus # module that imports, 2026-11-05) MODULES = [ - "proteus.ADR", + "proteus.kernels.ADR", "proteus.AuxiliaryVariables", "proteus.PostProcessingTools", "proteus.SubsurfaceTransportCoefficients", "proteus.TimeIntegration", "proteus.TransportCoefficients", "proteus.TwophaseDarcyCoefficients", - "proteus.m_comp_co2.m_comp_co2", - "proteus.richards.Richards", - "proteus.mprans.Dissipation", - "proteus.mprans.Kappa", - "proteus.mprans.MCorr", - "proteus.mprans.MCorr3P", - "proteus.mprans.NCLS", - "proteus.mprans.NCLS3P", - "proteus.mprans.RANS2P", - "proteus.mprans.RANS3PF", - "proteus.mprans.RANS3PSed", - "proteus.mprans.RDLS", - "proteus.mprans.TADR", - "proteus.mprans.VOF", - "proteus.mprans.VOF3P", - "proteus.mprans.VOS3P", + "proteus.kernels.m_comp_co2", + "proteus.kernels.Richards", + "proteus.kernels.Dissipation", + "proteus.kernels.Kappa", + "proteus.kernels.MCorr", + "proteus.kernels.MCorr3P", + "proteus.kernels.NCLS", + "proteus.kernels.NCLS3P", + "proteus.kernels.RANS2P", + "proteus.kernels.RANS3PF", + "proteus.kernels.RANS3PSed", + "proteus.kernels.RDLS", + "proteus.kernels.TADR", + "proteus.kernels.VOF", + "proteus.kernels.VOF3P", + "proteus.kernels.VOS3P", ] # none: every site is wrapped diff --git a/test/test_entropy_viscosity_reduce.py b/test/test_entropy_viscosity_reduce.py index f1cd8dbcd3..8583a80487 100644 --- a/test/test_entropy_viscosity_reduce.py +++ b/test/test_entropy_viscosity_reduce.py @@ -7,7 +7,7 @@ import numpy as np from mpi4py import MPI -from proteus.mprans import EntropyViscosity +from proteus.kernels import EntropyViscosity class _TwoRanks(object): diff --git a/test/test_gauges_ymf.py b/test/test_gauges_ymf.py index e89a080bf3..c3b6a41273 100644 --- a/test/test_gauges_ymf.py +++ b/test/test_gauges_ymf.py @@ -82,8 +82,8 @@ class _N(object): def test_each_gauge_goes_to_the_model_with_its_fields(): - pList = [_P("proteus.mprans.RANS3PF", ["u", "v"]), _P("proteus.mprans.Pres", ["p"]), - _P("proteus.mprans.CLSVOF", ["phi"])] + pList = [_P("proteus.kernels.RANS3PF", ["u", "v"]), _P("proteus.kernels.Pres", ["p"]), + _P("proteus.kernels.CLSVOF", ["phi"])] nList = [_N(), _N(), _N()] gauges = attach_ymf_gauges(DAMBREAK, pList, nList, fields={"φ": "phi"}, tags=TAGS) assert nList[0].auxiliaryVariables == [gauges[3]] diff --git a/test/test_gf_surface_degree.py b/test/test_gf_surface_degree.py index b3a397ec51..4aad3bd75b 100644 --- a/test/test_gf_surface_degree.py +++ b/test/test_gf_surface_degree.py @@ -92,7 +92,7 @@ def _model(useExact, nParticles, ndof): @pytest.mark.parametrize("useExact,nParticles,ndof,warned", [(True, 1, 6, True), (True, 1, 3, False), (False, 1, 6, False), (True, 0, 6, False)]) def test_rans2p_warns_once_for_exact_particles_with_a_quadratic_velocity(monkeypatch, useExact, nParticles, ndof, warned): - from proteus.mprans import RANS2P + from proteus.kernels import RANS2P messages = [] monkeypatch.setattr(RANS2P, 'logEvent', lambda msg, *a, **k: messages.append(msg)) model = _model(useExact, nParticles, ndof) diff --git a/test/test_hotstart_module_paths.py b/test/test_hotstart_module_paths.py new file mode 100644 index 0000000000..14ba576b73 --- /dev/null +++ b/test/test_hotstart_module_paths.py @@ -0,0 +1,41 @@ +"""A hot-start state written before the kernels moved (C49 R1) must still continue. + +The step policy a state carries holds class paths (``type(obj).__module__``). The kernel packages (proteus.mprans, +proteus.richards, proteus.m_comp_co2, proteus.elastoplastic) became proteus.kernels, so the same class reports a new +path; ``NS_base._normalize_archived_policy`` reads the old ones as the current ones. +""" +import pytest + +from proteus.NumericalSolution import NS_base, _current_module_path + + +@pytest.mark.parametrize("old, new", [ + ("proteus.mprans.NCLS.RKEV lag=True", "proteus.kernels.NCLS.RKEV lag=True"), + ("proteus.mprans.VOF.RKEV lag=None", "proteus.kernels.VOF.RKEV lag=None"), + ("proteus.richards.Richards.Coefficients order=2", "proteus.kernels.Richards.Coefficients order=2"), + ("proteus.m_comp_co2.m_comp_co2.X", "proteus.kernels.m_comp_co2.X"), + ("proteus.elastoplastic.ElastoPlastic.Y", "proteus.kernels.ElastoPlastic.Y"), + ("proteus.ADR.Coefficients", "proteus.kernels.ADR.Coefficients"), + # modules that left the kernel package go to their own homes, not to proteus.kernels + ("proteus.mprans.BodyDynamics.RigidBody", "proteus.mbd.BodyDynamics.RigidBody"), + ("proteus.mprans.MoveMeshMonitor.Coefficients", "proteus.MoveMeshMonitor.Coefficients"), + # a current path, another package, and a name that merely starts like a package are left alone + ("proteus.kernels.NCLS.RKEV lag=True", "proteus.kernels.NCLS.RKEV lag=True"), + ("proteus.TimeIntegration.BackwardEuler order=1", "proteus.TimeIntegration.BackwardEuler order=1"), + ("proteus.mprans_extra.X", "proteus.mprans_extra.X"), + ("proteus.ADRProblem.X", "proteus.ADRProblem.X"), +]) +def test_old_module_paths_read_as_the_current_ones(old, new): + assert _current_module_path(old) == new + + +def test_an_archived_policy_is_normalized_value_by_value(): + old = {"timeIntegration": "proteus.TimeIntegration.BackwardEuler order=1", + "stepController": "Min_dt_controller", + "shockCapturing": "proteus.mprans.NCLS.RKEV lag=True", + "stabilization": None, + "DT": 0.01, + "atol_u": {"0": 1e-8}} + now = NS_base._normalize_archived_policy(old) + assert now["shockCapturing"] == "proteus.kernels.NCLS.RKEV lag=True" + assert {k: v for k, v in now.items() if k != "shockCapturing"} == {k: v for k, v in old.items() if k != "shockCapturing"} diff --git a/test/test_index_type.py b/test/test_index_type.py index 73500f2efa..e7d2c4685c 100644 --- a/test/test_index_type.py +++ b/test/test_index_type.py @@ -212,7 +212,7 @@ def test_a_matrix_too_large_for_superlu_is_refused(): # --- ArgumentsDict: arrays go to the dict of their own dtype, nothing converts --- def test_arguments_dict_keeps_each_integer_width_in_its_own_dict(): - from proteus.mprans import cArgumentsDict + from proteus import cArgumentsDict ad = cArgumentsDict.ArgumentsDict() ad["i32"] = np.arange(3, dtype=np.int32) ad["i64"] = np.arange(3, dtype=np.int64) @@ -226,7 +226,7 @@ def test_arguments_dict_keeps_each_integer_width_in_its_own_dict(): def test_arguments_dict_int_scalars_that_do_not_fit_an_int_are_64_bit_only(): - from proteus.mprans import cArgumentsDict + from proteus import cArgumentsDict ad = cArgumentsDict.ArgumentsDict() ad["small"] = 7 ad["big"] = 2 ** 40 diff --git a/test/test_kernel_aliases.py b/test/test_kernel_aliases.py new file mode 100644 index 0000000000..7ac85f8f28 --- /dev/null +++ b/test/test_kernel_aliases.py @@ -0,0 +1,100 @@ +"""The old import paths of the kernels (C49 R1) are deprecated aliases of the new ones through 2.0.x. + +proteus.mprans, proteus.richards, proteus.m_comp_co2 and proteus.elastoplastic became proteus.kernels; a few modules of +proteus.mprans went to proteus, proteus.mbd (see proteus/_kernel_aliases.py). Each case runs in a fresh interpreter: +the alias is installed by the first import of an old package, and what the import order does is part of the check. +""" +import subprocess +import sys +import textwrap + +import pytest + +#: old module -> new module (the same object) +SAME = [ + ("proteus.mprans.RANS2P", "proteus.kernels.RANS2P"), + ("proteus.mprans.cRANS2P", "proteus.kernels.cRANS2P"), + ("proteus.mprans.VOF", "proteus.kernels.VOF"), + ("proteus.mprans.TADR", "proteus.kernels.TADR"), + ("proteus.mprans.SpatialTools", "proteus.SpatialTools"), + ("proteus.mprans.BoundaryConditions", "proteus.BoundaryConditions"), + ("proteus.mprans.BodyDynamics", "proteus.mbd.BodyDynamics"), + ("proteus.mprans.MoveMeshMonitor", "proteus.MoveMeshMonitor"), + ("proteus.mprans.cMoveMeshMonitor", "proteus.cMoveMeshMonitor"), + ("proteus.mprans.MeshSmoothing", "proteus.MeshSmoothing"), + ("proteus.mprans.cArgumentsDict", "proteus.cArgumentsDict"), + ("proteus.richards.Richards", "proteus.kernels.Richards"), + ("proteus.richards.cRichards", "proteus.kernels.cRichards"), + ("proteus.m_comp_co2.m_comp_co2", "proteus.kernels.m_comp_co2"), + ("proteus.m_comp_co2.cm_comp_co2", "proteus.kernels.cm_comp_co2"), + ("proteus.elastoplastic.ElastoPlastic", "proteus.kernels.ElastoPlastic"), + ("proteus.elastoplastic.cElastoPlastic", "proteus.kernels.cElastoPlastic"), + ("proteus.cADR", "proteus.kernels.cADR"), +] + + +def _run(code): + ran = subprocess.run([sys.executable, "-W", "always", "-c", textwrap.dedent(code)], capture_output=True, text=True, + timeout=300) + assert ran.returncode == 0, ran.stdout[-2000:] + ran.stderr[-3000:] + return ran.stderr + + +@pytest.mark.parametrize("old, new", SAME) +def test_an_old_path_is_the_module_of_the_new_one(old, new): + _run(""" + import importlib + old = importlib.import_module(%r) + new = importlib.import_module(%r) + assert old is new, (old, new) + assert old.__spec__.name == %r, old.__spec__.name + """ % (old, new, new)) + + +def test_from_imports_through_an_old_package_work_for_every_form_air_water_vv_and_the_decks_use(): + err = _run(""" + from proteus.mprans import RANS2P, cRANS2P, VOF, NCLS, RDLS, MCorr, SpatialTools, BoundaryConditions, BodyDynamics + from proteus.mprans.SpatialTools import Tank2D, Rectangle, assembleDomain + from proteus.mprans.BoundaryConditions import BC_RANS + from proteus.richards import Richards + from proteus.m_comp_co2 import m_comp_co2 + from proteus.elastoplastic import ElastoPlastic + import proteus.mprans + import proteus.kernels as k + assert RANS2P is k.RANS2P and Richards is k.Richards and m_comp_co2 is k.m_comp_co2 + assert proteus.mprans.NCLS is NCLS # a submodule as an attribute of the old package + assert Tank2D.__module__ == "proteus.SpatialTools" + assert BC_RANS.__mro__[1].__name__ == "BC_Base" + # a class reports its new module path + assert RANS2P.Coefficients.__module__ == "proteus.kernels.RANS2P" + """) + assert "proteus.mprans is deprecated" in err and "DeprecationWarning" in err + + +def test_a_star_import_of_an_old_package_gives_the_kernels(): + _run(""" + from proteus.mprans import * + import proteus.kernels as k + assert RANS2P is k.RANS2P and SpatialTools.Tank2D is not None and BodyDynamics.RigidBody is not None + """) + + +def test_the_removed_richards_adr_is_not_silently_the_top_level_adr(): + _run(""" + import importlib + for name in ("proteus.richards.ADR", "proteus.richards.cADR", "proteus.mprans.NoSuchModule", "proteus.gwvd"): + try: + importlib.import_module(name) + except ImportError: + continue + raise AssertionError(name + " imported") + """) + + +def test_importing_the_new_paths_warns_about_nothing(): + err = _run(""" + import proteus.kernels.RANS2P, proteus.kernels.cADR, proteus.SpatialTools, proteus.BoundaryConditions + import proteus.mbd.BodyDynamics, proteus.MoveMeshMonitor + from proteus import * + """) + assert "is deprecated" not in err, err diff --git a/test/test_mcorr3p_jacobian.py b/test/test_mcorr3p_jacobian.py index 5288e8f65a..99f05c282c 100644 --- a/test/test_mcorr3p_jacobian.py +++ b/test/test_mcorr3p_jacobian.py @@ -45,5 +45,5 @@ def test_lumped_option_is_a_bounded_approximation_of_the_jacobian(tmp_path): def test_consistent_assembly_is_the_default(tmp_path): - import proteus.mprans.MCorr3P as M + import proteus.kernels.MCorr3P as M assert M.Coefficients.__init__.__defaults__[-1] is False diff --git a/test/test_mprans_import_isolation.py b/test/test_mprans_import_isolation.py index 0eff562b94..92059aeb52 100644 --- a/test/test_mprans_import_isolation.py +++ b/test/test_mprans_import_isolation.py @@ -1,4 +1,4 @@ -"""Every proteus.mprans module imports in a fresh interpreter, on its own. +"""Every proteus.kernels module imports in a fresh interpreter, on its own. A module that does ``import proteus`` and then names proteus.StepControl, proteus.SubgridError, ... as attributes works only if something else imported @@ -31,7 +31,7 @@ def test_mprans_module_imports_alone(module): [_root] + [p for p in env.get("PYTHONPATH", "").split(os.pathsep) if p]) env.setdefault("FI_PROVIDER", "tcp") r = subprocess.run( - [sys.executable, "-c", "import proteus.mprans.%s" % module], + [sys.executable, "-c", "import proteus.kernels.%s" % module], capture_output=True, text=True, env=env, timeout=300) if r.returncode == 0: return @@ -40,5 +40,5 @@ def test_mprans_module_imports_alone(module): if m and not m.group(1).startswith("proteus"): # an optional third-party dependency (e.g. pychrono), not ours pytest.skip("optional dependency missing: " + m.group(1)) - pytest.fail("import proteus.mprans.%s in a fresh interpreter failed: %s\n%s" + pytest.fail("import proteus.kernels.%s in a fresh interpreter failed: %s\n%s" % (module, last, r.stderr[-2000:])) diff --git a/test/test_numerical_flux_unused_classes.py b/test/test_numerical_flux_unused_classes.py index dfd0d86ab9..e9e2b3b7f9 100644 --- a/test/test_numerical_flux_unused_classes.py +++ b/test/test_numerical_flux_unused_classes.py @@ -40,7 +40,7 @@ def test_a_class_in_use_is_not_refused(monkeypatch): def test_the_mprans_ncls_flux_subclass_is_not_refused(monkeypatch): """It subclasses HamiltonJacobi_DiagonalLesaintRaviart, which is refused, but by exact name: NCLS computes its exterior flux in its own kernel and runs in parallel.""" - from proteus.mprans import NCLS + from proteus.kernels import NCLS assert issubclass(NCLS.NumericalFlux, NumericalFlux.HamiltonJacobi_DiagonalLesaintRaviart) assert "NumericalFlux" not in NumericalFlux.UNUSED_FLUX_CLASSES_REFUSED_IN_PARALLEL monkeypatch.setattr(Comm, "get", lambda: _Comm(2)) diff --git a/test/test_rans2p_epsfact_solid.py b/test/test_rans2p_epsfact_solid.py index 8e15951734..02daf5725e 100644 --- a/test/test_rans2p_epsfact_solid.py +++ b/test/test_rans2p_epsfact_solid.py @@ -10,7 +10,7 @@ import numpy as np import pytest -from proteus.mprans import RANS2P, RANS2P_IB +from proteus.kernels import RANS2P, RANS2P_IB def test_epsFact_solid_warns_in_rans2p(): diff --git a/test/test_scatter_dof_array.py b/test/test_scatter_dof_array.py index 2d91509ad2..44712e404e 100644 --- a/test/test_scatter_dof_array.py +++ b/test/test_scatter_dof_array.py @@ -12,7 +12,7 @@ @pytest.mark.parametrize("name", MODELS) def test_models_use_the_shared_scatter(name): - model = importlib.import_module("proteus.mprans." + name).LevelModel + model = importlib.import_module("proteus.kernels." + name).LevelModel assert issubclass(model, OneLevelTransport) assert model.scatterDOFArray is OneLevelTransport.scatterDOFArray diff --git a/test/test_sedclosure.py b/test/test_sedclosure.py index dce1a74204..813f99814a 100644 --- a/test/test_sedclosure.py +++ b/test/test_sedclosure.py @@ -10,7 +10,7 @@ Profiling.logEvent("Testing SedClosure") class GlobalVariables(object): def __init__(self): - from proteus.mprans.SedClosure import HsuSedStress + from proteus.kernels.SedClosure import HsuSedStress self.C4e = 1. self.C3e = 1.2 self.eR = 0.8 @@ -734,7 +734,7 @@ def testPickleAndDeepcopy(self): def testKappaCoefficientsDeepcopy(self): """copy.deepcopy of a Kappa coefficients object that holds the closure.""" import copy - from proteus.mprans import Kappa + from proteus.kernels import Kappa gl = GlobalVariables() coef = Kappa.Coefficients(nd=2, closure=gl.sedSt) dup = copy.deepcopy(coef) diff --git a/test/test_spatialtools.py b/test/test_spatialtools.py index 26b8a080b7..c1f38042b7 100644 --- a/test/test_spatialtools.py +++ b/test/test_spatialtools.py @@ -17,14 +17,14 @@ Cuboid, CustomShape, assembleDomain) -from proteus.mprans.SpatialTools import (Rectangle as RectangleRANS, +from proteus.SpatialTools import (Rectangle as RectangleRANS, Cuboid as CuboidRANS, CustomShape as CustomShapeRANS, assembleDomain as assembleDomainRANS, Tank2D, Tank3D, ShapeSTL) -from proteus.mprans.BodyDynamics import RigidBody +from proteus.mbd.BodyDynamics import RigidBody import pytest comm = Comm.init() diff --git a/test/test_state_contract.py b/test/test_state_contract.py index dedd4b3e32..13d5317a9c 100644 --- a/test/test_state_contract.py +++ b/test/test_state_contract.py @@ -18,7 +18,7 @@ import pytest -import proteus.mprans +import proteus.kernels from proteus import ShockCapturing, SplitOperator, StepControl, SubgridError, TimeIntegration here = os.path.dirname(os.path.abspath(__file__)) @@ -32,9 +32,9 @@ def _modules(): yield from ("proteus.TimeIntegration", "proteus.ShockCapturing", "proteus.SubgridError", "proteus.StepControl", "proteus.SplitOperator") - for m in pkgutil.iter_modules(proteus.mprans.__path__): + for m in pkgutil.iter_modules(proteus.kernels.__path__): if not m.name.startswith("c"): # the compiled kernels are cNCLS, cVOF, ... - yield "proteus.mprans." + m.name + yield "proteus.kernels." + m.name def _classes(): @@ -97,7 +97,7 @@ def test_the_pressure_model_declares_its_state_through_the_coefficients_owner(): capturing, subgrid error or time integration object; the archive reads them as the ``coefficients`` owner.""" from proteus import NumericalSolution - from proteus.mprans import Pres + from proteus.kernels import Pres assert "coefficients" in NumericalSolution.NS_base.SOLVER_STATE_OWNERS assert "state" in vars(Pres.Coefficients) and "set_state" in vars(Pres.Coefficients) assert Pres.Coefficients().state() is None # not attached to a model: nothing to carry diff --git a/test/test_strong_dirichlet_authority.py b/test/test_strong_dirichlet_authority.py index 3adf793cac..edd2193fa8 100644 --- a/test/test_strong_dirichlet_authority.py +++ b/test/test_strong_dirichlet_authority.py @@ -79,3 +79,29 @@ def test_poisson_with_flag_selected_strong_dirichlet_dofs_gives_the_serial_answe parallel = _run(ranks, tmp_path, POISSON, **({"TRAP": 1} if trap else {})) for key in ("s", "s2"): numpy.testing.assert_allclose(parallel[key], serial[key], rtol=1e-9, atol=1e-12, err_msg=key) + + +STORED_MESH = os.path.join(HERE, "strong_dirichlet_stored_mesh") + + +@pytest.mark.skipif(MPIEXEC is None, reason="mpiexec not available") +@pytest.mark.parametrize("ranks", [2, 3, 4, 5, 6]) +def test_poisson_on_the_petsc_triangle_mesh_gives_the_serial_answer(ranks, tmp_path): + """The mesh the PETSc-built `triangle` (the fleet nightly's, first on PATH there) makes of the unit square at + he = 0.1 (256 elements, 145 nodes; conda-forge's triangle makes 312 and 178) is read from + strong_dirichlet_stored_mesh/, so this is the same on every machine. On it the corner node (0, 1) (flag 3, the + top face) is owned by a rank with no left-face element, and its left-face element is on another rank: the + authority was that other rank, and the owner never loaded the Dirichlet value (s = -146.306 against -140.990 on + 3 to 6 ranks, 1 and 2 ranks gave the serial answer). Fixed by handing the authority's point and flag to the ranks + that see the dof (LinearAlgebraTools.strongDirichletNonAuthorityDofs, DOFBoundaryConditions.adoptDOF).""" + _need_superlu_dist() + # The partition is pinned to the element order (-mat_partitioning_type current): with PETSc's default partitioner + # (the Mac's and the Linux runner's alike) the same mesh is cut elsewhere and the unfixed code gives the serial + # answer on 3, 4 and 6 ranks (CI of #340: the strict xfail XPASSed on linux-64), so without the pin this test + # would not guard the defect. Pinned, the corner (0, 1) is owned by rank 0 (top-face element only) and held by + # rank 1 (left-face element) on 3 ranks, on every machine. + pinned = {"STORED_MESH": STORED_MESH, "PETSC_OPTIONS": "-mat_partitioning_type current"} + serial = _run(1, tmp_path, POISSON, **pinned) + parallel = _run(ranks, tmp_path, POISSON, **pinned) + for key in ("s", "s2"): + numpy.testing.assert_allclose(parallel[key], serial[key], rtol=1e-9, atol=1e-12, err_msg=key) diff --git a/test/test_twophaseflow_partition_independence.py b/test/test_twophaseflow_partition_independence.py index a191341342..6e27bff154 100644 --- a/test/test_twophaseflow_partition_independence.py +++ b/test/test_twophaseflow_partition_independence.py @@ -36,7 +36,7 @@ closed tank the pressure is fixed only up to a constant, and serial and parallel fixed it differently (PresInc pinned dof 0 in serial and used the constant null space in parallel; PressureInitial took whatever its solver returned), so pressure gauges depended on the rank count. Since round 4 PresInc, Pres and PresInit are shifted to zero integral mean -when no Dirichlet condition fixes them (proteus.mprans.PressureNormalization), and the pressures agree as they are. +when no Dirichlet condition fixes them (proteus.kernels.PressureNormalization), and the pressures agree as they are. Retries: forcing one CLSVOF failure at the same call in serial and on 2 ranks gives the same answer on both (2.4e-7), so recovery is partition-correct; but the retried serial run differs from the unforced one by 16% in velocity at diff --git a/test/twophaseflow_partition_mpi.py b/test/twophaseflow_partition_mpi.py index fed43721e8..c74264ea03 100644 --- a/test/twophaseflow_partition_mpi.py +++ b/test/twophaseflow_partition_mpi.py @@ -29,7 +29,7 @@ def boundary_integral_gauges(pList, nList): the first, attached to the RANS2P/RANS3PF model; it writes boundary_integrals.csv.""" from proteus.Gauges import BoundaryIntegralGauges for p, n in zip(pList, nList): - if type(p.coefficients).__module__ in ("proteus.mprans.RANS2P", "proteus.mprans.RANS3PF"): + if type(p.coefficients).__module__ in ("proteus.kernels.RANS2P", "proteus.kernels.RANS3PF"): flags = [int(f) for f in os.environ["BIGAUGES"].split(",")] gauge = BoundaryIntegralGauges(tags=flags, moment_points={str(flags[0]): (0.1, 0.2, 0.0)}, fileName="boundary_integrals.csv") @@ -69,7 +69,7 @@ def init(self, so, pList, nList, *args, **kwargs): PETSc.Options().setValue(n.linear_solver_options_prefix + k, v) if os.environ.get("FIXNULLSPACE"): for p in pList: - if type(p.coefficients).__module__ == "proteus.mprans.PresInc": + if type(p.coefficients).__module__ == "proteus.kernels.PresInc": p.coefficients.fixNullSpace = True if os.environ.get("MAXITS"): for n in nList: diff --git a/test/vof_fct_partition_mpi.py b/test/vof_fct_partition_mpi.py index e05f93e168..7f6a7c8525 100644 --- a/test/vof_fct_partition_mpi.py +++ b/test/vof_fct_partition_mpi.py @@ -20,7 +20,7 @@ from proteus.FemTools import C0_AffineLinearOnSimplexWithNodalBasis from proteus.iproteus import opts import importlib -VOF = importlib.import_module("proteus.mprans." + os.environ.get("MODEL", "VOF")) +VOF = importlib.import_module("proteus.kernels." + os.environ.get("MODEL", "VOF")) from proteus.NonlinearSolvers import Newton, ExplicitLumpedMassMatrix, TwoStageNewton from proteus.LinearAlgebraTools import SparseMatrix from proteus.LinearSolvers import KSP_petsc4py @@ -123,7 +123,7 @@ def getResidual(self, u, r): VOF.LevelModel.getResidual = getResidual if os.environ.get("NOREDUCE"): # each rank normalizes the Taylor-Galerkin entropy viscosity by its own subdomain (a control) - from proteus.mprans import EntropyViscosity + from proteus.kernels import EntropyViscosity EntropyViscosity.reduce_numDiff = lambda *args: None if os.environ.get("OLDMAX"): VOF.RKEV.ownedMaxCFL = lambda self: self.cfl.max() diff --git a/test/vof_partition_mpi.py b/test/vof_partition_mpi.py index 42fbd85242..c617de71fd 100644 --- a/test/vof_partition_mpi.py +++ b/test/vof_partition_mpi.py @@ -27,7 +27,7 @@ from proteus.FemTools import C0_AffineLinearOnSimplexWithNodalBasis from proteus.iproteus import opts import importlib -VOF = importlib.import_module("proteus.mprans." + os.environ.get("MODEL", "VOF")) +VOF = importlib.import_module("proteus.kernels." + os.environ.get("MODEL", "VOF")) from proteus.NonlinearSolvers import Newton from proteus.LinearAlgebraTools import SparseMatrix from proteus.LinearSolvers import KSP_petsc4py diff --git a/test/vos_partition_mpi.py b/test/vos_partition_mpi.py index cc2c8c9ba8..bf60acd0c7 100644 --- a/test/vos_partition_mpi.py +++ b/test/vos_partition_mpi.py @@ -31,7 +31,7 @@ def partitionMesh(self, nLayersOfOverlap=1, parallelPartitioningType=MT.MeshPara nodeOwners=nodeOwners, elementOwners=elementOwners, nodeWeights=nodeWeights) MT.Mesh.partitionMesh = partitionMesh -from proteus.mprans import VOS3P +from proteus.kernels import VOS3P if os.environ.get("NOFIX"): VOS3P.LevelModel.scatterDOFArray = lambda self, a: None if os.environ.get("GHOSTCFL"):