CollapseModel.cpp

Go to the documentation of this file.
00001 #include "CollapseModel.h"
00002 #include "FatalException.h"
00003 #include "NumUtil.h"
00004 
00005 namespace gplib
00006   {
00007     void CollapseModel(ttranscribed &Thickness, ttranscribed &ParmValue)
00008       {
00009         std::vector<double> CollThick, CollValue;
00010         const unsigned int size = Thickness.size();
00011         if (size != ParmValue.size())
00012           throw FatalException(
00013               "Cannot collapse model with differing number of depths and parameter values !");
00014         unsigned int index = 0; //we need the loop index afterwards
00015         for (/* index initialized above*/; index < size - 1; ++index)
00016           {
00017             //if layer parameters are identical and combined layer thickness is less than 100km
00018             //the seismic code seems to have problems when the thickness of a single layer exceeds
00019             //this value
00020             if ((fcmp(ParmValue(index), ParmValue(index + 1),
00021                 std::numeric_limits<double>::epsilon()) == 0) && ((Thickness(index) + Thickness(index
00022                 + 1)) < 100.0))
00023               {
00024                 CollValue.push_back(ParmValue(index));
00025                 CollThick.push_back(Thickness(index) + Thickness(index + 1));
00026                 ++index; //skip the next layer
00027               }
00028             else //if layers are different
00029               {
00030                 CollThick.push_back(Thickness(index));
00031                 CollValue.push_back(ParmValue(index));
00032               }
00033           }
00034         if (index == size - 1) // if we didn't collapse the last layer
00035           {
00036             CollThick.push_back(Thickness(index));
00037             CollValue.push_back(ParmValue(index));
00038           }
00039         Thickness.resize(CollThick.size());
00040         ParmValue.resize(CollValue.size());
00041         copy(CollThick.begin(), CollThick.end(), Thickness.begin());
00042         copy(CollValue.begin(), CollValue.end(), ParmValue.begin());
00043       }
00044   }

Generated on Tue May 4 16:52:14 2010 for GPLIB++ by  doxygen 1.5.8