[cig-commits] commit: Add a rotation to the initial condition.

Mercurial hg at geodynamics.org
Wed Mar 28 02:44:24 PDT 2012


changeset:   120:af86ee9240e2
user:        Walter Landry <wlandry at caltech.edu>
date:        Mon Mar 26 10:55:06 2012 -0700
files:       initial.cxx
description:
Add a rotation to the initial condition.


diff -r 488d465c637a -r af86ee9240e2 initial.cxx
--- a/initial.cxx	Sun Mar 25 20:21:23 2012 -0700
+++ b/initial.cxx	Mon Mar 26 10:55:06 2012 -0700
@@ -2,6 +2,7 @@
 #include "Model.hxx"
 #include "constants.hxx"
 #include "write_vtk.hxx"
+#include "FTensor.hpp"
 
 #include <cmath>
 #include <gsl/gsl_linalg.h>
@@ -50,12 +51,21 @@ void initial(const Model &model, double 
   gsl_vector_free(x);
   gsl_permutation_free(perm);
 
+
+  const double theta(0.1);
+  FTensor::Tensor2<double,2,2>
+    rot(std::cos(theta),-std::sin(theta),std::sin(theta),std::cos(theta));
+  const FTensor::Index<'a',2> a;
+  const FTensor::Index<'b',2> b;
+
   for(int i=0;i<Nx+1;++i)
     for(int j=0;j<Ny+1;++j)
       {
         if(i<Nx && j<Ny)
           {
-            double x((i+0.5)*h), y((j+0.5)*h), r2(x*x+y*y);
+            FTensor::Tensor1<double,2> coord((i+0.5)*h,(j+0.5)*h), xy;
+            xy(a)=rot(a,b)*coord(b);
+            double x(xy(0)), y(xy(1)), r2(x*x+y*y);
             switch(model)
               {
               case Model::inclusion:
@@ -103,7 +113,9 @@ void initial(const Model &model, double 
           }
         if(j<Ny)
           {
-            double x(i*h), y((j+0.5)*h), r2(x*x+y*y);
+            FTensor::Tensor1<double,2> coord(i*h,(j+0.5)*h), xy;
+            xy(a)=rot(a,b)*coord(b);
+            double x(xy(0)), y(xy(1)), r2(x*x+y*y);
             zx[i][j]=0;
             fx[i][j]=0;
             switch(model)
@@ -180,7 +192,9 @@ void initial(const Model &model, double 
 
         if(i<Nx)
           {
-            double x((i+0.5)*h), y(j*h), r2(x*x+y*y);
+            FTensor::Tensor1<double,2> coord((i+0.5)*h, j*h), xy;
+            xy(a)=rot(a,b)*coord(b);
+            double x(xy(0)), y(xy(1)), r2(x*x+y*y);
             zy[i][j]=0;
 
             switch(model)



More information about the CIG-COMMITS mailing list