changed: put the voigt tensor helper functions in a shared source

they were duplicated in 3 source files
This commit is contained in:
Arne Morten Kvarving
2015-09-14 11:26:25 +02:00
parent 086a74d5ab
commit 2b396e0ccb
6 changed files with 113 additions and 118 deletions
+1 -41
View File
@@ -82,6 +82,7 @@
#include <opm/core/utility/MonotCubicInterpolator.hpp>
#include <opm/upscaling/SinglePhaseUpscaler.hpp>
#include <opm/upscaling/ParserAdditions.hpp>
#include <opm/upscaling/RelPermUtils.hpp>
#include <dune/common/version.hh>
#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
@@ -145,47 +146,6 @@ void usageandexit() {
exit(1);
}
// Assumes that permtensor_t use C ordering.
double getVoigtValue(const SinglePhaseUpscaler::permtensor_t& K, int voigt_idx)
{
assert(K.numRows() == 3 && K.numCols() == 3);
switch (voigt_idx) {
case 0: return K.data()[0];
case 1: return K.data()[4];
case 2: return K.data()[8];
case 3: return K.data()[5];
case 4: return K.data()[2];
case 5: return K.data()[1];
case 6: return K.data()[7];
case 7: return K.data()[6];
case 8: return K.data()[3];
default:
std::cout << "Voigt index out of bounds (only 0-8 allowed)" << std::endl;
throw std::exception();
}
}
// Assumes that permtensor_t use C ordering.
void setVoigtValue(SinglePhaseUpscaler::permtensor_t& K, int voigt_idx, double val)
{
assert(K.numRows() == 3 && K.numCols() == 3);
switch (voigt_idx) {
case 0: K.data()[0] = val; break;
case 1: K.data()[4] = val; break;
case 2: K.data()[8] = val; break;
case 3: K.data()[5] = val; break;
case 4: K.data()[2] = val; break;
case 5: K.data()[1] = val; break;
case 6: K.data()[7] = val; break;
case 7: K.data()[6] = val; break;
case 8: K.data()[3] = val; break;
default:
std::cout << "Voigt index out of bounds (only 0-8 allowed)" << std::endl;
throw std::exception();
}
}
int main(int varnum, char** vararg)
try
{