| 48 | 
  | 
#include "applications/hydrodynamics/Ellipsoid.hpp" | 
| 49 | 
  | 
#include "applications/hydrodynamics/CompositeShape.hpp" | 
| 50 | 
  | 
#include "math/LU.hpp" | 
| 51 | 
+ | 
#include "utils/simError.h" | 
| 52 | 
  | 
namespace oopse { | 
| 53 | 
  | 
/** | 
| 54 | 
  | 
 * Reference: | 
| 58 | 
  | 
 */ | 
| 59 | 
  | 
 | 
| 60 | 
  | 
ApproximationModel::ApproximationModel(StuntDouble* sd, SimInfo* info): HydrodynamicsModel(sd, info){ | 
| 60 | 
– | 
/* | 
| 61 | 
– | 
    DynamicProperty::const_iterator iter; | 
| 61 | 
  | 
 | 
| 63 | 
– | 
    iter = extraParams.find("Viscosity"); | 
| 64 | 
– | 
    if (iter != extraParams.end()) { | 
| 65 | 
– | 
        boost::any param = iter->second; | 
| 66 | 
– | 
        viscosity = boost::any_cast<double>(param); | 
| 67 | 
– | 
    }else { | 
| 68 | 
– | 
        std::cout << "ApproximationModel Error\n" ; | 
| 69 | 
– | 
    } | 
| 70 | 
– | 
 | 
| 71 | 
– | 
    iter = extraParams.find("Temperature"); | 
| 72 | 
– | 
    if (iter != extraParams.end()) { | 
| 73 | 
– | 
        boost::any param = iter->second; | 
| 74 | 
– | 
        temperature = boost::any_cast<double>(param); | 
| 75 | 
– | 
    }else { | 
| 76 | 
– | 
        std::cout << "ApproximationModel Error\n" ; | 
| 77 | 
– | 
    }     | 
| 78 | 
– | 
*/ | 
| 62 | 
  | 
} | 
| 63 | 
  | 
 | 
| 64 | 
  | 
bool ApproximationModel::calcHydroProps(Spheric* spheric, double viscosity, double temperature) { | 
| 72 | 
  | 
    return internalCalcHydroProps(static_cast<Shape*>(compositeShape), viscosity, temperature); | 
| 73 | 
  | 
} | 
| 74 | 
  | 
 | 
| 75 | 
< | 
  | 
| 93 | 
< | 
bool ApproximationModel::internalCalcHydroProps(Shape* shape, double viscosity, double temperature) { | 
| 75 | 
> | 
void ApproximationModel::init() { | 
| 76 | 
  | 
    if (!createBeads(beads_)) { | 
| 77 | 
< | 
        std::cout << "can not create beads" << std::endl; | 
| 78 | 
< | 
        return false; | 
| 77 | 
> | 
      sprintf(painCave.errMsg, "ApproximationModel::init() : Can not create beads\n"); | 
| 78 | 
> | 
      painCave.isFatal = 1; | 
| 79 | 
> | 
      simError();         | 
| 80 | 
  | 
    } | 
| 81 | 
  | 
 | 
| 82 | 
+ | 
} | 
| 83 | 
+ | 
 | 
| 84 | 
+ | 
bool ApproximationModel::internalCalcHydroProps(Shape* shape, double viscosity, double temperature) { | 
| 85 | 
+ | 
 | 
| 86 | 
  | 
    bool ret = true; | 
| 87 | 
  | 
    HydroProps cr; | 
| 88 | 
  | 
    HydroProps cd; | 
| 111 | 
  | 
                Vector3d Rij = beads[i].pos - beads[j].pos; | 
| 112 | 
  | 
                double rij = Rij.length(); | 
| 113 | 
  | 
                double rij2 = rij * rij; | 
| 114 | 
< | 
                double sumSigma2OverRij2 = ((beads[i].radius*beads[i].radius) + (beads[i].radius*beads[i].radius)) / rij2;                 | 
| 114 | 
> | 
                double sumSigma2OverRij2 = ((beads[i].radius*beads[i].radius) + (beads[j].radius*beads[j].radius)) / rij2;                 | 
| 115 | 
  | 
                Mat3x3d tmpMat; | 
| 116 | 
  | 
                tmpMat = outProduct(Rij, Rij) / rij2; | 
| 117 | 
  | 
                double constant = 8.0 * NumericConstant::PI * viscosity * rij; | 
| 128 | 
  | 
 | 
| 129 | 
  | 
    //invert B Matrix | 
| 130 | 
  | 
    invertMatrix(B, C); | 
| 131 | 
< | 
 | 
| 131 | 
> | 
     | 
| 132 | 
  | 
    //prepare U Matrix relative to arbitrary origin O(0.0, 0.0, 0.0) | 
| 133 | 
  | 
    std::vector<Mat3x3d> U; | 
| 134 | 
  | 
    for (int i = 0; i < nbeads; ++i) { | 
| 274 | 
  | 
                Vector3d Rij = beads[i].pos - beads[j].pos; | 
| 275 | 
  | 
                double rij = Rij.length(); | 
| 276 | 
  | 
                double rij2 = rij * rij; | 
| 277 | 
< | 
                double sumSigma2OverRij2 = ((beads[i].radius*beads[i].radius) + (beads[i].radius*beads[i].radius)) / rij2;                 | 
| 277 | 
> | 
                double sumSigma2OverRij2 = ((beads[i].radius*beads[i].radius) + (beads[j].radius*beads[j].radius)) / rij2;                 | 
| 278 | 
  | 
                Mat3x3d tmpMat; | 
| 279 | 
  | 
                tmpMat = outProduct(Rij, Rij) / rij2; | 
| 280 | 
  | 
                double constant = 8.0 * NumericConstant::PI * viscosity * rij; | 
| 447 | 
  | 
       | 
| 448 | 
  | 
} | 
| 449 | 
  | 
 | 
| 450 | 
< | 
/* | 
| 450 | 
> | 
 | 
| 451 | 
  | 
void ApproximationModel::writeBeads(std::ostream& os) { | 
| 452 | 
  | 
    std::vector<BeadParam>::iterator iter; | 
| 453 | 
  | 
    os << beads_.size() << std::endl; | 
| 457 | 
  | 
    } | 
| 458 | 
  | 
 | 
| 459 | 
  | 
} | 
| 473 | 
– | 
*/ | 
| 460 | 
  | 
 | 
| 461 | 
  | 
 | 
| 462 | 
+ | 
 | 
| 463 | 
  | 
} |