diff --git a/examples/advection/weak.py b/examples/advection/weak.py index c2e36fb9921aceeb966f93e95bb6347f287c49d3..77ce17bc54ed03e84da4f5761d0c251abeb52824 100644 --- a/examples/advection/weak.py +++ b/examples/advection/weak.py @@ -3,18 +3,23 @@ from __future__ import division, absolute_import __copyright__ = "Copyright (C) 2007 Andreas Kloeckner" __license__ = """ -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. """ import os diff --git a/unported-examples/advection/advection.py b/unported-examples/advection/advection.py index f145076bf8b4ad741574e64cbc15142ac426820d..a665ed34b44ead31e1b00b7caf12efb87fc71cae 100644 --- a/unported-examples/advection/advection.py +++ b/unported-examples/advection/advection.py @@ -1,18 +1,24 @@ -# Copyright (C) 2007 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - +__copyright__ = "Copyright (C) 2007 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" from __future__ import division from __future__ import absolute_import @@ -88,7 +94,7 @@ def main(write_output=True, flux_type_arg="upwind"): TimeConstantGivenFunction, \ TimeDependentGivenFunction from grudge.models.advection import StrongAdvectionOperator, WeakAdvectionOperator - op = WeakAdvectionOperator(v, + op = WeakAdvectionOperator(v, inflow_u=TimeDependentGivenFunction(u_analytic), flux_type=flux_type_arg) @@ -141,8 +147,8 @@ def main(write_output=True, flux_type_arg="upwind"): for step, t, dt in step_it: if step % 5 == 0 and write_output: visf = vis.make_file("fld-%04d" % step) - vis.add_data(visf, [ - ("u", discr.convert_volume(u, kind="numpy")), + vis.add_data(visf, [ + ("u", discr.convert_volume(u, kind="numpy")), ], time=t, step=step) visf.close() diff --git a/unported-examples/burgers/burgers.py b/unported-examples/burgers/burgers.py index 5c277e316141cd38e0e0905edf59c6edf9d6333f..14aef115be849e80b110cad98b9f15f46cb70294 100644 --- a/unported-examples/burgers/burgers.py +++ b/unported-examples/burgers/burgers.py @@ -1,17 +1,24 @@ -# Copyright (C) 2007 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +__copyright__ = "Copyright (C) 2007 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" from __future__ import division @@ -93,7 +100,7 @@ class OffCenterStationaryTestCase: -def main(write_output=True, flux_type_arg="upwind", +def main(write_output=True, flux_type_arg="upwind", #case = CenteredStationaryTestCase(), #case = OffCenterStationaryTestCase(), #case = OffCenterMigratingTestCase(), diff --git a/unported-examples/gas_dynamics/box-in-box.py b/unported-examples/gas_dynamics/box-in-box.py index 1e5bceb2e165b01bd74fca348cc6bd1a53cae6eb..2f757ae1c03e9bfb63241b83defd95a9af36abff 100644 --- a/unported-examples/gas_dynamics/box-in-box.py +++ b/unported-examples/gas_dynamics/box-in-box.py @@ -1,18 +1,24 @@ -# Copyright (C) 2008 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - +__copyright__ = "Copyright (C) 2008 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" from __future__ import division from __future__ import absolute_import diff --git a/unported-examples/gas_dynamics/euler/sine-wave.py b/unported-examples/gas_dynamics/euler/sine-wave.py index 451befdbe9613f733ace9324a8770ce8de0d295f..4337bbd56847b613311005cd3cd35bb909d15030 100644 --- a/unported-examples/gas_dynamics/euler/sine-wave.py +++ b/unported-examples/gas_dynamics/euler/sine-wave.py @@ -1,19 +1,24 @@ -# Copyright (C) 2008 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - +__copyright__ = "Copyright (C) 2008 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" from __future__ import division diff --git a/unported-examples/gas_dynamics/euler/vortex-adaptive-grid.py b/unported-examples/gas_dynamics/euler/vortex-adaptive-grid.py index ac2dde1a756405ef87a57f960946321e7e145893..a282ca14cbad60198951ac46cf0ff3f957e34721 100644 --- a/unported-examples/gas_dynamics/euler/vortex-adaptive-grid.py +++ b/unported-examples/gas_dynamics/euler/vortex-adaptive-grid.py @@ -1,18 +1,24 @@ -# Copyright (C) 2008 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - +__copyright__ = "Copyright (C) 2008 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" diff --git a/unported-examples/gas_dynamics/euler/vortex-sources.py b/unported-examples/gas_dynamics/euler/vortex-sources.py index b6f783a50f450d4b7bf1d3dca4f8b159a0c17714..47bb7ee1fec74558e7866f3f678e7afa1e7e5d46 100644 --- a/unported-examples/gas_dynamics/euler/vortex-sources.py +++ b/unported-examples/gas_dynamics/euler/vortex-sources.py @@ -1,18 +1,24 @@ -# Copyright (C) 2008 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +__copyright__ = "Copyright (C) 2008 Andreas Kloeckner" +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" @@ -90,7 +96,7 @@ class SourceTerms: x_rel = x_vec[0] - vortex_loc[0] y_rel = x_vec[1] - vortex_loc[1] - # sources written in terms of A=1.0 solution + # sources written in terms of A=1.0 solution # (standard isentropic vortex) from math import pi @@ -148,7 +154,7 @@ def main(write_output=True): gamma = 1.4 - # at A=1 we have case of isentropic vortex, source terms + # at A=1 we have case of isentropic vortex, source terms # arise for other values densityA = 2.0 @@ -191,7 +197,7 @@ def main(write_output=True): from grudge.mesh import BTAG_ALL op = GasDynamicsOperator(dimensions=2, - mu=0.0, prandtl=0.72, spec_gas_const=287.1, + mu=0.0, prandtl=0.72, spec_gas_const=287.1, equation_of_state=GammaLawEOS(vortex.gamma), bc_inflow=vortex, bc_outflow=vortex, bc_noslip=vortex, inflow_tag=BTAG_ALL, source=sources) diff --git a/unported-examples/gas_dynamics/euler/vortex.py b/unported-examples/gas_dynamics/euler/vortex.py index 9f9703f4d77f4c13dc07db0a52eb1ee36fd0ea5d..c94ba2e8d0cf245090c0832185a23d1925d43a65 100644 --- a/unported-examples/gas_dynamics/euler/vortex.py +++ b/unported-examples/gas_dynamics/euler/vortex.py @@ -1,19 +1,24 @@ -# Copyright (C) 2008 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - +__copyright__ = "Copyright (C) 2008 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" from __future__ import division diff --git a/unported-examples/gas_dynamics/gas_dynamics_initials.py b/unported-examples/gas_dynamics/gas_dynamics_initials.py index 05ab91a314415a80d8a30452e2d68c3e26d6d378..48057a865fda5698982602899ac3a6100926fb38 100644 --- a/unported-examples/gas_dynamics/gas_dynamics_initials.py +++ b/unported-examples/gas_dynamics/gas_dynamics_initials.py @@ -1,19 +1,24 @@ -# Copyright (C) 2008 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - +__copyright__ = "Copyright (C) 2008 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" from __future__ import division diff --git a/unported-examples/gas_dynamics/lbm-simple.py b/unported-examples/gas_dynamics/lbm-simple.py index 2d3496da340fbda01adeb33b6a59290b76b1c698..b6eb94c6980d613adcd1522254a0ad9fc802464c 100644 --- a/unported-examples/gas_dynamics/lbm-simple.py +++ b/unported-examples/gas_dynamics/lbm-simple.py @@ -1,17 +1,24 @@ -# Copyright (C) 2011 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +__copyright__ = "Copyright (C) 2011 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" @@ -123,7 +130,7 @@ def main(write_output=True, dtype=np.float32): rho = get_rho(f_bar) rho_u = get_rho_u(f_bar) vis.add_data(visf, - [ ("fbar%d" %i, + [ ("fbar%d" %i, discr.convert_volume(f_bar_i, "numpy")) for i, f_bar_i in enumerate(f_bar)]+ [ ("rho", discr.convert_volume(rho, "numpy")), diff --git a/unported-examples/gas_dynamics/naca.py b/unported-examples/gas_dynamics/naca.py index 26755345c34b58e1ed3dd7fdbfa5d61b8b180b91..85976cf54d8a23235f2059c6f2b0424486b01d40 100644 --- a/unported-examples/gas_dynamics/naca.py +++ b/unported-examples/gas_dynamics/naca.py @@ -1,19 +1,24 @@ -# Copyright (C) 2008 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +__copyright__ = "Copyright (C) 2008 Andreas Kloeckner" +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" from __future__ import division @@ -130,7 +135,7 @@ def main(): from grudge.models.gas_dynamics import GasDynamicsOperator, GammaLawEOS op = GasDynamicsOperator(dimensions=2, - equation_of_state=GammaLawEOS(uniform_flow.gamma), + equation_of_state=GammaLawEOS(uniform_flow.gamma), prandtl=uniform_flow.prandtl, spec_gas_const=uniform_flow.spec_gas_const, mu=uniform_flow.mu, bc_inflow=uniform_flow, bc_outflow=uniform_flow, bc_noslip=uniform_flow, @@ -223,7 +228,7 @@ def main(): model_stepper = LSRK4TimeStepper() next_dt = op.estimate_timestep(discr, - stepper=model_stepper, t=0, + stepper=model_stepper, t=0, max_eigenvalue=max_eigval[0]) for step, t, dt in step_it: diff --git a/unported-examples/gas_dynamics/navierstokes/shearflow.py b/unported-examples/gas_dynamics/navierstokes/shearflow.py index 58746ea716d5304f386fe6b2fe54970ea591e205..8cae369e924496238f4364887db5a54ba4a1a732 100644 --- a/unported-examples/gas_dynamics/navierstokes/shearflow.py +++ b/unported-examples/gas_dynamics/navierstokes/shearflow.py @@ -1,18 +1,24 @@ -# Copyright (C) 2008 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - +__copyright__ = "Copyright (C) 2008 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" diff --git a/unported-examples/gas_dynamics/square.py b/unported-examples/gas_dynamics/square.py index c24383b82131c73db9196ab13d7b1a8a2ac7ec03..2dd5ce2c7047941cc9be5c560770c67ccdc1045f 100644 --- a/unported-examples/gas_dynamics/square.py +++ b/unported-examples/gas_dynamics/square.py @@ -1,19 +1,24 @@ -# Copyright (C) 2008 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +__copyright__ = "Copyright (C) 2008 Andreas Kloeckner" +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" from __future__ import division @@ -239,7 +244,7 @@ def main(): model_stepper = LSRK4TimeStepper() next_dt = op.estimate_timestep(discr, - stepper=model_stepper, t=0, + stepper=model_stepper, t=0, max_eigenvalue=max_eigval[0]) for step, t, dt in step_it: diff --git a/unported-examples/gas_dynamics/wing.py b/unported-examples/gas_dynamics/wing.py index 968f32e6fbcfe4a85d3da530959867be199550df..618b3a9775c31160a587309ffa43072f23fb1bda 100644 --- a/unported-examples/gas_dynamics/wing.py +++ b/unported-examples/gas_dynamics/wing.py @@ -1,17 +1,25 @@ -# Copyright (C) 2008 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +__copyright__ = "Copyright (C) 2008 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + diff --git a/unported-examples/heat/heat.py b/unported-examples/heat/heat.py index b313f675dd5055c02affafd45f1c7d6e6ef96196..2d25d62d7ff6e74c3d144ff5949daa10ff635dbb 100644 --- a/unported-examples/heat/heat.py +++ b/unported-examples/heat/heat.py @@ -1,19 +1,27 @@ from __future__ import absolute_import from __future__ import print_function -# Copyright (C) 2007 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. + +__copyright__ = "Copyright (C) 2007 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" @@ -144,7 +152,7 @@ def main(write_output=True) : if step % 10 == 0 and write_output: visf = vis.make_file("fld-%04d" % step) vis.add_data(visf, [ - ("u", discr.convert_volume(u, kind="numpy")), + ("u", discr.convert_volume(u, kind="numpy")), ], time=t, step=step) visf.close() diff --git a/unported-examples/maxwell/dipole.py b/unported-examples/maxwell/dipole.py deleted file mode 100644 index 381d89ce589a32ef399c2c1a6d0fc0806a935744..0000000000000000000000000000000000000000 --- a/unported-examples/maxwell/dipole.py +++ /dev/null @@ -1,260 +0,0 @@ -# Copyright (C) 2007 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -# FIXME: This example doesn't quite do what it should any more. - - - - -from __future__ import division -from __future__ import absolute_import -from __future__ import print_function -import numpy -import numpy.linalg as la -from six.moves import range -from six.moves import zip - - - - -def main(write_output=True, allow_features=None): - from grudge.timestep import RK4TimeStepper - from grudge.mesh import make_ball_mesh, make_cylinder_mesh, make_box_mesh - from grudge.visualization import \ - VtkVisualizer, \ - SiloVisualizer, \ - get_rank_partition - from math import sqrt, pi - - from grudge.backends import guess_run_context - rcon = guess_run_context(allow_features) - - epsilon0 = 8.8541878176e-12 # C**2 / (N m**2) - mu0 = 4*pi*1e-7 # N/A**2. - epsilon = 1*epsilon0 - mu = 1*mu0 - - dims = 3 - - if rcon.is_head_rank: - if dims == 2: - from grudge.mesh import make_rect_mesh - mesh = make_rect_mesh( - a=(-10.5,-1.5), - b=(10.5,1.5), - max_area=0.1 - ) - elif dims == 3: - from grudge.mesh import make_box_mesh - mesh = make_box_mesh( - a=(-10.5,-1.5,-1.5), - b=(10.5,1.5,1.5), - max_volume=0.1) - - if rcon.is_head_rank: - mesh_data = rcon.distribute_mesh(mesh) - else: - mesh_data = rcon.receive_mesh() - - #for order in [1,2,3,4,5,6]: - discr = rcon.make_discretization(mesh_data, order=3) - - if write_output: - vis = VtkVisualizer(discr, rcon, "dipole") - - from analytic_solutions import DipoleFarField, SphericalFieldAdapter - from grudge.data import ITimeDependentGivenFunction - - sph_dipole = DipoleFarField( - q=1, #C - d=1/39, - omega=2*pi*1e8, - epsilon=epsilon0, - mu=mu0, - ) - cart_dipole = SphericalFieldAdapter(sph_dipole) - - class PointDipoleSource(ITimeDependentGivenFunction): - def __init__(self): - from pyrticle.tools import CInfinityShapeFunction - sf = CInfinityShapeFunction( - 0.1*sph_dipole.wavelength, - discr.dimensions) - self.num_sf = discr.interpolate_volume_function( - lambda x, el: sf(x)) - self.vol_0 = discr.volume_zeros() - - def volume_interpolant(self, t, discr): - from grudge.tools import make_obj_array - return make_obj_array([ - self.vol_0, - self.vol_0, - sph_dipole.source_modulation(t)*self.num_sf - ]) - - from grudge.mesh import BTAG_ALL, BTAG_NONE - if dims == 2: - from grudge.models.em import TMMaxwellOperator as MaxwellOperator - else: - from grudge.models.em import MaxwellOperator - - op = MaxwellOperator( - epsilon, mu, - flux_type=1, - pec_tag=BTAG_NONE, - absorb_tag=BTAG_ALL, - current=PointDipoleSource(), - ) - - fields = op.assemble_eh(discr=discr) - - if rcon.is_head_rank: - print("#elements=", len(mesh.elements)) - - stepper = RK4TimeStepper() - - # diagnostics setup --------------------------------------------------- - from pytools.log import LogManager, add_general_quantities, \ - add_simulation_quantities, add_run_info - - if write_output: - log_file_name = "dipole.dat" - else: - log_file_name = None - - logmgr = LogManager(log_file_name, "w", rcon.communicator) - add_run_info(logmgr) - add_general_quantities(logmgr) - add_simulation_quantities(logmgr) - discr.add_instrumentation(logmgr) - stepper.add_instrumentation(logmgr) - - from pytools.log import IntervalTimer - vis_timer = IntervalTimer("t_vis", "Time spent visualizing") - logmgr.add_quantity(vis_timer) - - from grudge.log import EMFieldGetter, add_em_quantities - field_getter = EMFieldGetter(discr, op, lambda: fields) - add_em_quantities(logmgr, op, field_getter) - - from pytools.log import PushLogQuantity - relerr_e_q = PushLogQuantity("relerr_e", "1", "Relative error in masked E-field") - relerr_h_q = PushLogQuantity("relerr_h", "1", "Relative error in masked H-field") - logmgr.add_quantity(relerr_e_q) - logmgr.add_quantity(relerr_h_q) - - logmgr.add_watches(["step.max", "t_sim.max", - ("W_field", "W_el+W_mag"), "t_step.max", - "relerr_e", "relerr_h"]) - - if write_output: - point_timeseries = [ - (open("b-x%d-vs-time.dat" % i, "w"), - open("b-x%d-vs-time-true.dat" % i, "w"), - discr.get_point_evaluator(numpy.array([i,0,0][:dims], - dtype=discr.default_scalar_type))) - for i in range(1,5) - ] - - # timestep loop ------------------------------------------------------- - mask = discr.interpolate_volume_function(sph_dipole.far_field_mask) - - def apply_mask(field): - from grudge.tools import log_shape - ls = log_shape(field) - result = discr.volume_empty(ls) - from pytools import indices_in_shape - for i in indices_in_shape(ls): - result[i] = mask * field[i] - - return result - - rhs = op.bind(discr) - - t = 0 - try: - from grudge.timestep import times_and_steps - step_it = times_and_steps( - final_time=1e-8, logmgr=logmgr, - max_dt_getter=lambda t: op.estimate_timestep(discr, - stepper=stepper, t=t, fields=fields)) - - for step, t, dt in step_it: - if write_output and step % 10 == 0: - sub_timer = vis_timer.start_sub_timer() - e, h = op.split_eh(fields) - sph_dipole.set_time(t) - true_e, true_h = op.split_eh( - discr.interpolate_volume_function(cart_dipole)) - visf = vis.make_file("dipole-%04d" % step) - - mask_e = apply_mask(e) - mask_h = apply_mask(h) - mask_true_e = apply_mask(true_e) - mask_true_h = apply_mask(true_h) - - from pyvisfile.silo import DB_VARTYPE_VECTOR - vis.add_data(visf, - [ - ("e", e), - ("h", h), - ("true_e", true_e), - ("true_h", true_h), - ("mask_e", mask_e), - ("mask_h", mask_h), - ("mask_true_e", mask_true_e), - ("mask_true_h", mask_true_h)], - time=t, step=step) - visf.close() - sub_timer.stop().submit() - - from grudge.tools import relative_error - relerr_e_q.push_value( - relative_error( - discr.norm(mask_e-mask_true_e), - discr.norm(mask_true_e))) - relerr_h_q.push_value( - relative_error( - discr.norm(mask_h-mask_true_h), - discr.norm(mask_true_h))) - - if write_output: - for outf_num, outf_true, evaluator in point_timeseries: - for outf, ev_h in zip([outf_num, outf_true], - [h, true_h]): - outf.write("%g\t%g\n" % (t, op.mu*evaluator(ev_h[1]))) - outf.flush() - - fields = stepper(fields, t, dt, rhs) - - finally: - if write_output: - vis.close() - - logmgr.save() - discr.close() - - - -if __name__ == "__main__": - main() - - - - -from pytools.test import mark_test -@mark_test.long -def test_run(): - main(write_output=False) diff --git a/unported-examples/maxwell/inhom-cavity.py b/unported-examples/maxwell/inhom-cavity.py deleted file mode 100644 index 60817af116b4de54146cf69017208f153a12618a..0000000000000000000000000000000000000000 --- a/unported-examples/maxwell/inhom-cavity.py +++ /dev/null @@ -1,266 +0,0 @@ -# Copyright (C) 2007 Andreas Kloeckner -# Adapted 2010 by David Powell -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -"""This example is for maxwell's equations in a 2D rectangular cavity -with inhomogeneous dielectric filling""" - -from __future__ import division -from __future__ import absolute_import -from __future__ import print_function -import numpy - -CAVITY_GEOMETRY = """ -// a rectangular cavity with a dielectric in one region - -lc = 10e-3; -height = 50e-3; -air_width = 100e-3; -dielectric_width = 50e-3; - -Point(1) = {0, 0, 0, lc}; -Point(2) = {air_width, 0, 0, lc}; -Point(3) = {air_width+dielectric_width, 0, 0, lc}; -Point(4) = {air_width+dielectric_width, height, 0, lc}; -Point(5) = {air_width, height, 0, lc}; -Point(6) = {0, height, 0, lc}; - -Line(1) = {1, 2}; -Line(2) = {2, 3}; -Line(3) = {3, 4}; -Line(4) = {4, 5}; -Line(5) = {5, 6}; -Line(6) = {6, 1}; -Line(7) = {2, 5}; - -Line Loop(1) = {1, 7, 5, 6}; -Line Loop(2) = {2, 3, 4, -7}; - -Plane Surface(1) = {1}; -Plane Surface(2) = {2}; - -Physical Surface("vacuum") = {1}; -Physical Surface("dielectric") = {2}; -""" - - -def main(write_output=True, allow_features=None, flux_type_arg=1, - bdry_flux_type_arg=None, extra_discr_args={}): - from math import sqrt, pi - from grudge.models.em import TEMaxwellOperator - - from grudge.backends import guess_run_context - rcon = guess_run_context(allow_features) - - epsilon0 = 8.8541878176e-12 # C**2 / (N m**2) - mu0 = 4*pi*1e-7 # N/A**2. - c = 1/sqrt(mu0*epsilon0) - - materials = {"vacuum" : (epsilon0, mu0), - "dielectric" : (2*epsilon0, mu0)} - - output_dir = "2d_cavity" - - import os - if not os.access(output_dir, os.F_OK): - os.makedirs(output_dir) - - # should no tag raise an error or default to free space? - def eps_val(x, el): - for key in list(materials.keys()): - if el in material_elements[key]: - return materials[key][0] - raise ValueError("Element does not belong to any material") - - def mu_val(x, el): - for key in list(materials.keys()): - if el in material_elements[key]: - return materials[key][1] - raise ValueError("Element does not belong to any material") - - # geometry of cavity - d = 100e-3 - a = 150e-3 - - # analytical frequency and transverse wavenumbers of resonance - f0 = 9.0335649907522321e8 - h = 2*pi*f0/c - l = -h*sqrt(2) - - # substitute the following and change materials for a homogeneous cavity - #h = pi/a - #l =-h - - def initial_val(discr): - # the initial solution for the TE_10-like mode - def initial_Hz(x, el): - from math import cos, sin - if el in material_elements["vacuum"]: - return h*cos(h*x[0]) - else: - return -l*sin(h*d)/sin(l*(a-d))*cos(l*(a-x[0])) - - from grudge.tools import make_obj_array - result_zero = discr.volume_zeros(kind="numpy", dtype=numpy.float64) - H_z = make_tdep_given(initial_Hz).volume_interpolant(0, discr) - return make_obj_array([result_zero, result_zero, H_z]) - - if rcon.is_head_rank: - from grudge.mesh.reader.gmsh import generate_gmsh - mesh = generate_gmsh(CAVITY_GEOMETRY, 2, force_dimension=2) - mesh_data = rcon.distribute_mesh(mesh) - else: - mesh_data = rcon.receive_mesh() - - # Work out which elements belong to each material - material_elements = {} - for key in list(materials.keys()): - material_elements[key] = set(mesh_data.tag_to_elements[key]) - - order = 3 - #extra_discr_args.setdefault("debug", []).append("cuda_no_plan") - #extra_discr_args.setdefault("debug", []).append("dump_optemplate_stages") - - from grudge.data import make_tdep_given - from grudge.mesh import BTAG_ALL - - op = TEMaxwellOperator(epsilon=make_tdep_given(eps_val), mu=make_tdep_given(mu_val), \ - flux_type=flux_type_arg, \ - bdry_flux_type=bdry_flux_type_arg, dimensions=2, pec_tag=BTAG_ALL) - # op = TEMaxwellOperator(epsilon=epsilon0, mu=mu0, - # flux_type=flux_type_arg, \ - # bdry_flux_type=bdry_flux_type_arg, dimensions=2, pec_tag=BTAG_ALL) - - discr = rcon.make_discretization(mesh_data, order=order, - tune_for=op.sym_operator(), - **extra_discr_args) - - # create the initial solution - fields = initial_val(discr) - - from grudge.visualization import VtkVisualizer - if write_output: - from os.path import join - vis = VtkVisualizer(discr, rcon, join(output_dir, "cav-%d" % order)) - - # monitor the solution at a point to find the resonant frequency - try: - point_getter = discr.get_point_evaluator(numpy.array([75e-3, 25e-3, 0])) #[0.25, 0.25, 0.25])) - except RuntimeError: - point_getter = None - - if rcon.is_head_rank: - print("---------------------------------------------") - print("order %d" % order) - print("---------------------------------------------") - print("#elements=", len(mesh.elements)) - - from grudge.timestep.runge_kutta import LSRK4TimeStepper - stepper = LSRK4TimeStepper(dtype=discr.default_scalar_type, rcon=rcon) - #from grudge.timestep.dumka3 import Dumka3TimeStepper - #stepper = Dumka3TimeStepper(3, dtype=discr.default_scalar_type, rcon=rcon) - - # diagnostics setup --------------------------------------------------- - from pytools.log import LogManager, add_general_quantities, \ - add_simulation_quantities, add_run_info - - if write_output: - from os.path import join - log_file_name = join(output_dir, "cavity-%d.dat" % order) - else: - log_file_name = None - - logmgr = LogManager(log_file_name, "w", rcon.communicator) - - add_run_info(logmgr) - add_general_quantities(logmgr) - add_simulation_quantities(logmgr) - discr.add_instrumentation(logmgr) - stepper.add_instrumentation(logmgr) - - from pytools.log import IntervalTimer - vis_timer = IntervalTimer("t_vis", "Time spent visualizing") - logmgr.add_quantity(vis_timer) - - #from grudge.log import EMFieldGetter, add_em_quantities - #field_getter = EMFieldGetter(discr, op, lambda: fields) - #add_em_quantities(logmgr, op, field_getter) - - logmgr.add_watches( - ["step.max", "t_sim.max", - #("W_field", "W_el+W_mag"), - "t_step.max"] - ) - - # timestep loop ------------------------------------------------------- - rhs = op.bind(discr) - final_time = 10e-9 - - if point_getter is not None: - from os.path import join - pointfile = open(join(output_dir, "point.txt"), "wt") - done_dt = False - try: - from grudge.timestep import times_and_steps - from os.path import join - step_it = times_and_steps( - final_time=final_time, logmgr=logmgr, - max_dt_getter=lambda t: op.estimate_timestep(discr, - stepper=stepper, t=t, fields=fields)) - - for step, t, dt in step_it: - if step % 10 == 0 and write_output: - sub_timer = vis_timer.start_sub_timer() - e, h = op.split_eh(fields) - visf = vis.make_file(join(output_dir, "cav-%d-%04d") % (order, step)) - vis.add_data(visf, - [ - ("e", - discr.convert_volume(e, kind="numpy")), - ("h", - discr.convert_volume(h, kind="numpy")),], - time=t, step=step - ) - visf.close() - sub_timer.stop().submit() - - fields = stepper(fields, t, dt, rhs) - if point_getter is not None: - val = point_getter(fields) - #print val - if not done_dt: - pointfile.write("#%g\n" % dt) - done_dt = True - pointfile.write("%g\n" %val[0]) - - finally: - if write_output: - vis.close() - - logmgr.close() - discr.close() - - if point_getter is not None: - pointfile.close() - - - - - - - -# entry point ----------------------------------------------------------------- -if __name__ == "__main__": - main(write_output=True) diff --git a/unported-examples/maxwell/maxwell-2d.py b/unported-examples/maxwell/maxwell-2d.py index ff4182ab0442f06bdce17297e6720c26810e37c2..4a869e1b72ea56237e640b32bbb755e7289c0d24 100644 --- a/unported-examples/maxwell/maxwell-2d.py +++ b/unported-examples/maxwell/maxwell-2d.py @@ -1,17 +1,25 @@ -# Copyright (C) 2007 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +__copyright__ = "Copyright (C) 2007 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + "Maxwell's equation example with fixed material coefficients" @@ -38,7 +46,7 @@ def main(write_output=True): import os if not os.access(output_dir, os.F_OK): os.makedirs(output_dir) - + from grudge.mesh.generator import make_disk_mesh mesh = make_disk_mesh(r=0.5, max_area=1e-3) @@ -105,7 +113,7 @@ def main(write_output=True): field_getter = EMFieldGetter(discr, op, lambda: fields) add_em_quantities(logmgr, op, field_getter) - logmgr.add_watches(["step.max", "t_sim.max", + logmgr.add_watches(["step.max", "t_sim.max", ("W_field", "W_el+W_mag"), "t_step.max"]) # timestep loop ------------------------------------------------------- diff --git a/unported-examples/poisson/helmholtz.py b/unported-examples/poisson/helmholtz.py index f203e84ca4bf709e3c96ed6a38cede01ea135b3c..1814e192265f3a95e623fdf5810ba750869fbe95 100644 --- a/unported-examples/poisson/helmholtz.py +++ b/unported-examples/poisson/helmholtz.py @@ -1,19 +1,24 @@ -# Copyright (C) 2007 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +__copyright__ = "Copyright (C) 2007 Andreas Kloeckner" +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" from __future__ import division @@ -67,7 +72,7 @@ def main(write_output=True): if dim == 2: if rcon.is_head_rank: from grudge.mesh.generator import make_disk_mesh - mesh = make_disk_mesh(r=0.5, + mesh = make_disk_mesh(r=0.5, boundary_tagger=dirichlet_boundary_tagger, max_area=1e-3) elif dim == 3: @@ -85,7 +90,7 @@ def main(write_output=True): else: mesh_data = rcon.receive_mesh() - discr = rcon.make_discretization(mesh_data, order=5, + discr = rcon.make_discretization(mesh_data, order=5, debug=[]) def dirichlet_bc(x, el): @@ -114,17 +119,17 @@ def main(write_output=True): k = 1 from grudge.mesh import BTAG_NONE, BTAG_ALL - op = HelmholtzOperator(k, discr.dimensions, + op = HelmholtzOperator(k, discr.dimensions, #diffusion_tensor=my_diff_tensor(), #dirichlet_tag="dirichlet", - #neumann_tag="neumann", + #neumann_tag="neumann", dirichlet_tag=BTAG_ALL, - neumann_tag=BTAG_NONE, + neumann_tag=BTAG_NONE, #dirichlet_tag=BTAG_ALL, - #neumann_tag=BTAG_NONE, + #neumann_tag=BTAG_NONE, #dirichlet_bc=GivenFunction(dirichlet_bc), dirichlet_bc=ConstantGivenFunction(0), @@ -138,8 +143,8 @@ def main(write_output=True): if False: from grudge.iterative import parallel_cg - u = -parallel_cg(rcon, -bound_op, - bound_op.prepare_rhs(discr.interpolate_volume_function(rhs_c)), + u = -parallel_cg(rcon, -bound_op, + bound_op.prepare_rhs(discr.interpolate_volume_function(rhs_c)), debug=20, tol=5e-4, dot=discr.nodewise_dot_product, x=discr.volume_zeros()) diff --git a/unported-examples/poisson/poisson.py b/unported-examples/poisson/poisson.py index 83fa7acb008afd19f0bbb0871cac094a06c519c3..58bb530ccb401d2ac1c09756750a9f7f096c1e26 100644 --- a/unported-examples/poisson/poisson.py +++ b/unported-examples/poisson/poisson.py @@ -1,19 +1,24 @@ -# Copyright (C) 2007 Andreas Kloeckner -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +__copyright__ = "Copyright (C) 2007 Andreas Kloeckner" +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" from __future__ import division @@ -62,7 +67,7 @@ def main(write_output=True): else: mesh_data = rcon.receive_mesh() - discr = rcon.make_discretization(mesh_data, order=5, + discr = rcon.make_discretization(mesh_data, order=5, debug=[]) def dirichlet_bc(x, el): @@ -86,17 +91,17 @@ def main(write_output=True): IPDGSecondDerivative, LDGSecondDerivative, \ StabilizedCentralSecondDerivative from grudge.mesh import BTAG_NONE, BTAG_ALL - op = PoissonOperator(discr.dimensions, + op = PoissonOperator(discr.dimensions, diffusion_tensor=my_diff_tensor(), #dirichlet_tag="dirichlet", - #neumann_tag="neumann", + #neumann_tag="neumann", dirichlet_tag=BTAG_ALL, - neumann_tag=BTAG_NONE, + neumann_tag=BTAG_NONE, #dirichlet_tag=BTAG_ALL, - #neumann_tag=BTAG_NONE, + #neumann_tag=BTAG_NONE, dirichlet_bc=GivenFunction(dirichlet_bc), neumann_bc=ConstantGivenFunction(-10), @@ -108,8 +113,8 @@ def main(write_output=True): bound_op = op.bind(discr) from grudge.iterative import parallel_cg - u = -parallel_cg(rcon, -bound_op, - bound_op.prepare_rhs(discr.interpolate_volume_function(rhs_c)), + u = -parallel_cg(rcon, -bound_op, + bound_op.prepare_rhs(discr.interpolate_volume_function(rhs_c)), debug=20, tol=5e-4, dot=discr.nodewise_dot_product, x=discr.volume_zeros())