forked from Exawind/nalu-wind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Exawind#1 from mbkuhn/newcases_whfork
Sloshing Tank case
- Loading branch information
Showing
6 changed files
with
131 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC | ||
// (NTESS), National Renewable Energy Laboratory, University of Texas Austin, | ||
// Northwest Research Associates. Under the terms of Contract DE-NA0003525 | ||
// with NTESS, the U.S. Government retains certain rights in this software. | ||
// | ||
// This software is released under the BSD 3-clause license. See LICENSE file | ||
// for more details. | ||
// | ||
|
||
#ifndef SloshingTankVOFAuxFunction_h | ||
#define SloshingTankVOFAuxFunction_h | ||
|
||
#include <AuxFunction.h> | ||
|
||
#include <vector> | ||
|
||
namespace sierra { | ||
namespace nalu { | ||
|
||
class SloshingTankVOFAuxFunction : public AuxFunction | ||
{ | ||
public: | ||
SloshingTankVOFAuxFunction(const std::vector<double>& params); | ||
|
||
virtual ~SloshingTankVOFAuxFunction() {} | ||
|
||
using AuxFunction::do_evaluate; | ||
virtual void do_evaluate( | ||
const double* coords, | ||
const double time, | ||
const unsigned spatialDimension, | ||
const unsigned numPoints, | ||
double* fieldPtr, | ||
const unsigned fieldSize, | ||
const unsigned beginPos, | ||
const unsigned endPos) const; | ||
|
||
double water_level_; | ||
double amplitude_; | ||
double kappa_; | ||
double interface_thickness_; | ||
}; | ||
|
||
} // namespace nalu | ||
} // namespace sierra | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC | ||
// (NTESS), National Renewable Energy Laboratory, University of Texas Austin, | ||
// Northwest Research Associates. Under the terms of Contract DE-NA0003525 | ||
// with NTESS, the U.S. Government retains certain rights in this software. | ||
// | ||
// This software is released under the BSD 3-clause license. See LICENSE file | ||
// for more details. | ||
// | ||
|
||
#include <user_functions/SloshingTankVOFAuxFunction.h> | ||
#include <algorithm> | ||
|
||
// basic c++ | ||
#include <cmath> | ||
#include <vector> | ||
#include <stdexcept> | ||
#include <iostream> | ||
|
||
namespace sierra { | ||
namespace nalu { | ||
|
||
SloshingTankVOFAuxFunction::SloshingTankVOFAuxFunction( | ||
const std::vector<double>& params) | ||
: AuxFunction(0, 1), | ||
water_level_(0.), | ||
amplitude_(0.1), | ||
kappa_(0.25), | ||
interface_thickness_(0.1) | ||
{ | ||
// check size and populate | ||
if (params.size() != 4 && !params.empty()) | ||
throw std::runtime_error("Realm::setup_initial_conditions: " | ||
"sloshing_tank requires 4 params: water level, " | ||
"amplitude, kappa, and interface thickness"); | ||
if (!params.empty()) { | ||
water_level_ = params[0]; | ||
amplitude_ = params[1]; | ||
kappa_ = params[2]; | ||
interface_thickness_ = params[3]; | ||
} | ||
} | ||
|
||
void | ||
SloshingTankVOFAuxFunction::do_evaluate( | ||
const double* coords, | ||
const double /*time*/, | ||
const unsigned spatialDimension, | ||
const unsigned numPoints, | ||
double* fieldPtr, | ||
const unsigned fieldSize, | ||
const unsigned /*beginPos*/, | ||
const unsigned /*endPos*/) const | ||
{ | ||
for (unsigned p = 0; p < numPoints; ++p) { | ||
|
||
const double x = coords[0]; | ||
const double y = coords[1]; | ||
const double z = coords[2]; | ||
|
||
const double z0 = | ||
water_level_ + amplitude_ * std::exp(-kappa_ * (x * x + y * y)); | ||
fieldPtr[0] = | ||
-0.5 * (std::erf((z - z0) / interface_thickness_) + 1.0) + 1.0; | ||
|
||
fieldPtr += fieldSize; | ||
coords += spatialDimension; | ||
} | ||
} | ||
|
||
} // namespace nalu | ||
} // namespace sierra |