aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorschnetter <schnetter@b83b3108-af97-48ba-8c81-9293ccf7f924>2009-09-28 18:13:48 +0000
committerschnetter <schnetter@b83b3108-af97-48ba-8c81-9293ccf7f924>2009-09-28 18:13:48 +0000
commit1198ef6e175f651646fb7989e8cdce06d424d684 (patch)
treea12b5980e3986e7f579db332a0e809c1f602c7a9 /src
parentbcf804124910ccb0643e23ee6f7be30a768a1486 (diff)
Move thorn TmunuBase from AEIThorns to CactusEinstein.
Thorn TmunuBase provides grid functions for the stress-energy tensor T_ab. This allows spacetime codes to be independent of hydrodynamics formulations, or other formulations contributing to the stress-energy tensor. TmunuBase is backwards compatible with the old CalcTmunu.inc mechanism. git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinBase/TmunuBase/trunk@2 b83b3108-af97-48ba-8c81-9293ccf7f924
Diffstat (limited to 'src')
-rw-r--r--src/CopyTmunu.F9044
-rw-r--r--src/SetStressEnergyState.F9020
-rw-r--r--src/SetTmunu.F64
-rw-r--r--src/TmunuBase_CalcTmunu.inc60
-rw-r--r--src/ZeroTmunu.F9025
-rw-r--r--src/make.code.defn7
6 files changed, 220 insertions, 0 deletions
diff --git a/src/CopyTmunu.F90 b/src/CopyTmunu.F90
new file mode 100644
index 0000000..dde5804
--- /dev/null
+++ b/src/CopyTmunu.F90
@@ -0,0 +1,44 @@
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+
+
+
+! Calculate the T2munu copy.
+! On input, T2munu contains the contribution to Tmunu that is calculated
+! via the CalcTmunu.inc mechanism, and Tmunu contains the complete stress
+! energy tensor.
+! On output, T2munu should contain the contribution to Tmunu that is
+! calculated via the AddToTmunu mechanism.
+! We just need to calculate the difference.
+
+subroutine TmunuBase_CopyTmunu (CCTK_ARGUMENTS)
+ implicit none
+ DECLARE_CCTK_ARGUMENTS
+ DECLARE_CCTK_PARAMETERS
+
+ if (support_old_CalcTmunu_mechanism == 0) then
+ call CCTK_WARN (0, "internal error")
+ end if
+
+ if (stress_energy_state == 0) then
+ call CCTK_WARN (1, "The stress energy tensor does not have storage")
+ return
+ end if
+
+ stress_energy_2_state = stress_energy_state
+
+ eT2tt = eTtt - eT2tt
+
+ eT2tx = eTtx - eT2tx
+ eT2ty = eTty - eT2ty
+ eT2tz = eTtz - eT2tz
+
+ eT2xx = eTxx - eT2xx
+ eT2xy = eTxy - eT2xy
+ eT2xz = eTxz - eT2xz
+ eT2yy = eTyy - eT2yy
+ eT2yz = eTyz - eT2yz
+ eT2zz = eTzz - eT2zz
+
+end subroutine TmunuBase_CopyTmunu
diff --git a/src/SetStressEnergyState.F90 b/src/SetStressEnergyState.F90
new file mode 100644
index 0000000..2418555
--- /dev/null
+++ b/src/SetStressEnergyState.F90
@@ -0,0 +1,20 @@
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+
+
+
+! Set the stress energy (storage) state grid scalar from the parameter.
+
+subroutine TmunuBase_SetStressEnergyState (CCTK_ARGUMENTS)
+ implicit none
+ DECLARE_CCTK_ARGUMENTS
+ DECLARE_CCTK_PARAMETERS
+
+ stress_energy_state = stress_energy_storage
+ if (support_old_CalcTmunu_mechanism /= 0) then
+ stress_energy_2_state = stress_energy_state
+ else
+ stress_energy_2_state = 0
+ end if
+end subroutine TmunuBase_SetStressEnergyState
diff --git a/src/SetTmunu.F b/src/SetTmunu.F
new file mode 100644
index 0000000..36dbd0d
--- /dev/null
+++ b/src/SetTmunu.F
@@ -0,0 +1,64 @@
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Functions.h"
+#include "cctk_Parameters.h"
+
+
+
+c Calculate the contribution to the stress energy tensor T_munu
+c which are calcualated via the CalcTmunu.inc mechanism.
+c Then make a copy of that into the T2munu variables.
+
+ subroutine TmunuBase_SetTmunu (CCTK_ARGUMENTS)
+ implicit none
+ DECLARE_CCTK_ARGUMENTS
+ DECLARE_CCTK_FUNCTIONS
+ DECLARE_CCTK_PARAMETERS
+
+#define TMUNUBASE_SETTMUNU
+
+#include "CactusEinstein/ADMMacros/src/macro/STRESSENERGY_declare.h"
+
+ integer i, j, k
+
+ do k = 1, cctk_lsh(3)
+ do j = 1, cctk_lsh(2)
+ do i = 1, cctk_lsh(1)
+
+#include "CactusEinstein/ADMMacros/src/macro/STRESSENERGY_guts.h"
+
+ eTtt(i,j,k) = Ttt
+
+ eTtx(i,j,k) = Ttx
+ eTty(i,j,k) = Tty
+ eTtz(i,j,k) = Ttz
+
+ eTxx(i,j,k) = Txx
+ eTxy(i,j,k) = Txy
+ eTxz(i,j,k) = Txz
+ eTyy(i,j,k) = Tyy
+ eTyz(i,j,k) = Tyz
+ eTzz(i,j,k) = Tzz
+
+#include "CactusEinstein/ADMMacros/src/macro/STRESSENERGY_undefine.h"
+
+ end do
+ end do
+ end do
+
+#undef TMUNUBASE_SETTMUNU
+
+ eT2tt = eTtt
+
+ eT2tx = eTtx
+ eT2ty = eTty
+ eT2tz = eTtz
+
+ eT2xx = eTxx
+ eT2xy = eTxy
+ eT2xz = eTxz
+ eT2yy = eTyy
+ eT2yz = eTyz
+ eT2zz = eTzz
+
+ end
diff --git a/src/TmunuBase_CalcTmunu.inc b/src/TmunuBase_CalcTmunu.inc
new file mode 100644
index 0000000..8cc9571
--- /dev/null
+++ b/src/TmunuBase_CalcTmunu.inc
@@ -0,0 +1,60 @@
+/* Add the contributions to T_munu that we gathered via the AddToTmunu
+ mechanism, using the CalcTmunu.inc mechanism. */
+
+
+
+/* Only add if we are not included from this thorn; otherwise we would
+ be adding to ourselves. */
+#ifndef TMUNUBASE_SETTMUNU
+
+#ifdef CCODE
+
+ if (* stress_energy_2_state)
+ {
+
+#ifndef NDEBUG
+ if ((ijk) < 0 || (ijk) >= cctk_lsh[0] * cctk_lsh[1] * cctk_lsh[2])
+ {
+ CCTK_WARN (0, "Illegal array index");
+ }
+#endif
+
+ Ttt += eT2tt[ijk];
+
+ Ttx += eT2tx[ijk];
+ Tty += eT2ty[ijk];
+ Ttz += eT2tz[ijk];
+
+ Txx += eT2xx[ijk];
+ Txy += eT2xy[ijk];
+ Txz += eT2xz[ijk];
+ Tyy += eT2yy[ijk];
+ Tyz += eT2yz[ijk];
+ Tzz += eT2zz[ijk];
+
+ }
+
+#endif
+
+#ifdef FCODE
+
+ if (stress_energy_2_state .ne. 0) then
+
+ Ttt = Ttt + eT2tt(i,j,k)
+
+ Ttx = Ttx + eT2tx(i,j,k)
+ Tty = Tty + eT2ty(i,j,k)
+ Ttz = Ttz + eT2tz(i,j,k)
+
+ Txx = Txx + eT2xx(i,j,k)
+ Txy = Txy + eT2xy(i,j,k)
+ Txz = Txz + eT2xz(i,j,k)
+ Tyy = Tyy + eT2yy(i,j,k)
+ Tyz = Tyz + eT2yz(i,j,k)
+ Tzz = Tzz + eT2zz(i,j,k)
+
+ end if
+
+#endif
+
+#endif /* ifndef TMUNUBASE_SETTMUNU */
diff --git a/src/ZeroTmunu.F90 b/src/ZeroTmunu.F90
new file mode 100644
index 0000000..c99b169
--- /dev/null
+++ b/src/ZeroTmunu.F90
@@ -0,0 +1,25 @@
+#include "cctk.h"
+#include "cctk_Arguments.h"
+
+
+
+! Initialise Tmunu to zero
+
+subroutine TmunuBase_ZeroTmunu (CCTK_ARGUMENTS)
+ implicit none
+ DECLARE_CCTK_ARGUMENTS
+
+ eTtt = 0
+
+ eTtx = 0
+ eTty = 0
+ eTtz = 0
+
+ eTxx = 0
+ eTxy = 0
+ eTxz = 0
+ eTyy = 0
+ eTyz = 0
+ eTzz = 0
+
+end subroutine TmunuBase_ZeroTmunu
diff --git a/src/make.code.defn b/src/make.code.defn
new file mode 100644
index 0000000..4f58c44
--- /dev/null
+++ b/src/make.code.defn
@@ -0,0 +1,7 @@
+# Main make.code.defn file for thorn TmunuBase
+
+# Source files in this directory
+SRCS = CopyTmunu.F90 SetStressEnergyState.F90 SetTmunu.F ZeroTmunu.F90
+
+# Subdirectories containing source files
+SUBDIRS =