13 #ifndef KRATOS_FLUX_LIMITER_H_INCLUDED
14 #define KRATOS_FLUX_LIMITER_H_INCLUDED
59 template<
class TLocalVectorType>
86 AddFluxLimiters(this->GetDefaultParameters());
94 AddFluxLimiters(ThisParameters);
101 mUnlimitedFlux = rOther.mUnlimitedFlux;
102 mAllowableIncrements = rOther.mAllowableIncrements;
122 return mUnlimitedFlux[iVar](rContributions, rNode, iNode);
126 return mAllowableIncrements[iVar](rNode);
144 virtual std::string
Info()
const
146 std::stringstream buffer;
147 buffer <<
"FluxLimiter" ;
152 virtual void PrintInfo(std::ostream& rOStream)
const {rOStream <<
"FluxLimiter";}
165 std::vector<std::function<AllowableIncrements(
const NodeType&)>> mAllowableIncrements;
176 void AddFluxLimiters(
Parameters ThisParameters) {
177 for (
auto var_name : ThisParameters[
"limiting_variables"].GetStringArray()) {
180 this->SetDoubleLimiter(r_var);
182 else if (KratosComponents<Variable<array_1d<double,3>>>::
Has(var_name)) {
183 const auto& r_var = KratosComponents<Variable<array_1d<double,3>>>::Get(var_name);
184 this->SetArrayLimiter(r_var);
189 virtual void SetDoubleLimiter(
const Variable<double>& rVariable)
191 if (rVariable == HEIGHT) {
192 mUnlimitedFlux.push_back(HeightUnlimitedFlux);
193 mAllowableIncrements.push_back(HeightAllowableIncrements);
194 }
else if (rVariable == FREE_SURFACE_ELEVATION) {
195 mUnlimitedFlux.push_back(FreeSurfaceUnlimitedFlux);
196 mAllowableIncrements.push_back(FreeSurfaceAllowableIncrements);
198 KRATOS_ERROR <<
"FluxLimiter: The limiter for the variable " << rVariable <<
" is undefined." << std::endl;
202 virtual void SetArrayLimiter(
const Variable<array_1d<double,3>>& rVariable)
204 if (rVariable == MOMENTUM) {
205 mUnlimitedFlux.push_back(FlowRateUnlimitedFlux);
206 mAllowableIncrements.push_back(FlowRateAllowableIncrements);
207 }
else if (rVariable == VELOCITY) {
208 mUnlimitedFlux.push_back(VelocityUnlimitedFlux);
209 mAllowableIncrements.push_back(VelocityAllowableIncrements);
211 KRATOS_ERROR <<
"FluxLimiter: The limiter for the variable " << rVariable <<
" is undefined." << std::endl;
215 static double HeightUnlimitedFlux(
const TLocalVectorType& rContributions,
const NodeType& rNode,
IndexType iNode)
217 return rContributions(3*iNode + 2);
220 static double FreeSurfaceUnlimitedFlux(
const TLocalVectorType& rContributions,
const NodeType& rNode,
IndexType iNode)
222 return rContributions(3*iNode + 2);
225 static double FlowRateUnlimitedFlux(
const TLocalVectorType& rContributions,
const NodeType& rNode,
IndexType iNode)
227 array_1d<double,3> flux;
228 flux[0] = rContributions(3*iNode);
229 flux[1] = rContributions(3*iNode + 1);
235 static double VelocityUnlimitedFlux(
const TLocalVectorType& rContributions,
const NodeType& rNode,
IndexType iNode)
237 array_1d<double,3> flux_q, flux_v;
238 flux_q[0] = rContributions(3*iNode);
239 flux_q[1] = rContributions(3*iNode + 1);
241 double flux_h = rContributions(3*iNode + 2);
244 const double next_h =
h + flux_h;
245 flux_v = flux_q / next_h -
v * flux_h / next_h;
249 static AllowableIncrements HeightAllowableIncrements(
const NodeType& rNode)
252 AllowableIncrements increments(0.0, 0.0);
253 const auto& neigh_nodes = rNode.
GetValue(NEIGHBOUR_NODES);
256 double delta_ij = neigh_nodes[
j].FastGetSolutionStepValue(HEIGHT) - h_i;
257 increments.max =
std::max(increments.max, delta_ij);
258 increments.min =
std::min(increments.min, delta_ij);
263 static AllowableIncrements FreeSurfaceAllowableIncrements(
const NodeType& rNode)
266 AllowableIncrements increments(0.0, 0.0);
267 const auto& neigh_nodes = rNode.
GetValue(NEIGHBOUR_NODES);
270 double delta_ij = neigh_nodes[
j].FastGetSolutionStepValue(FREE_SURFACE_ELEVATION) - h_i;
271 increments.max =
std::max(increments.max, delta_ij);
272 increments.min =
std::min(increments.min, delta_ij);
277 static AllowableIncrements FlowRateAllowableIncrements(
const NodeType& rNode)
281 AllowableIncrements increments(0.0, 0.0);
282 const auto& neigh_nodes = rNode.
GetValue(NEIGHBOUR_NODES);
286 const array_1d<double,3>& delta_ij = neigh_nodes[
j].FastGetSolutionStepValue(MOMENTUM) - q_i;
288 increments.max =
std::max(increments.max, proj_ij);
289 increments.min =
std::min(increments.min, proj_ij);
294 static AllowableIncrements VelocityAllowableIncrements(
const NodeType& rNode)
298 AllowableIncrements increments(0.0, 0.0);
299 const auto& neigh_nodes = rNode.
GetValue(NEIGHBOUR_NODES);
302 const array_1d<double,3>& delta_ij = neigh_nodes[
j].FastGetSolutionStepValue(VELOCITY) - v_i;
304 increments.max =
std::max(increments.max, proj_ij);
305 increments.min =
std::min(increments.min, proj_ij);
314 virtual Parameters GetDefaultParameters()
const
316 Parameters default_parameters = Parameters(R
"({
317 "limiting_variables" : ["HEIGHT"]
319 return default_parameters;
This is a helper class to separate the physics from the flux corrected scheme.
Definition: flux_limiter.h:61
GlobalPointersVector< Node > GlobalPointersVectorType
Definition: flux_limiter.h:76
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: flux_limiter.h:155
FluxLimiter(Parameters ThisParameters)
Constructor with parameters.
Definition: flux_limiter.h:92
virtual ~FluxLimiter()
Destructor.
Definition: flux_limiter.h:108
double ComputeUnlimitedFlux(const TLocalVectorType &rContributions, const NodeType &rNode, IndexType iNode, IndexType iVar)
Definition: flux_limiter.h:121
IndexType size()
Definition: flux_limiter.h:119
virtual std::string Info() const
Turn back information as a string.
Definition: flux_limiter.h:144
Node NodeType
Definition: flux_limiter.h:74
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: flux_limiter.h:152
AllowableIncrements ComputeAllowableIncrements(const NodeType &rNode, IndexType iVar)
Definition: flux_limiter.h:125
FluxLimiter(FluxLimiter const &rOther)
Copy constructor.
Definition: flux_limiter.h:100
FluxLimiter()
Default constructor.
Definition: flux_limiter.h:85
KRATOS_CLASS_POINTER_DEFINITION(FluxLimiter)
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
KratosComponents class encapsulates a lookup table for a family of classes in a generic way.
Definition: kratos_components.h:49
This class defines the node.
Definition: node.h:65
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:435
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: node.h:466
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
#define KRATOS_ERROR
Definition: exception.h:161
static double max(double a, double b)
Definition: GeometryFunctions.h:79
static double min(double a, double b)
Definition: GeometryFunctions.h:71
bool Has(const std::string &ModelerName)
Checks if the modeler is registered.
Definition: modeler_factory.cpp:24
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
v
Definition: generate_convection_diffusion_explicit_element.py:114
h
Definition: generate_droplet_dynamics.py:91
int j
Definition: quadrature.py:648
Definition: flux_limiter.h:68
double min
Definition: flux_limiter.h:70
AllowableIncrements(double NewMax, double NewMin)
Definition: flux_limiter.h:71
double max
Definition: flux_limiter.h:69