13 #ifndef KRATOS_SHALLOW_WATER_UTILITIES_H_INCLUDED
14 #define KRATOS_SHALLOW_WATER_UTILITIES_H_INCLUDED
85 void ComputeFreeSurfaceElevation(
ModelPart& rModelPart);
87 void ComputeHeightFromFreeSurface(
ModelPart& rModelPart);
91 void ComputeSmoothVelocity(
ModelPart& rModelPart);
93 void ComputeMomentum(
ModelPart& rModelPart);
95 void ComputeLinearizedMomentum(
ModelPart& rModelPart);
97 template<
bool THistorical>
98 void ComputeFroude(
ModelPart& rModelPart,
const double Epsilon);
100 template<
bool THistorical>
101 void ComputeEnergy(
ModelPart& rModelPart);
105 void IdentifySolidBoundary(
ModelPart& rModelPart,
double SeaWaterLevel,
Flags SolidBoundaryFlag);
107 void FlagWetElements(
ModelPart& rModelPart,
Flags WetFlag,
double RelativeDryHeight = -1.0);
109 void ExtrapolateElementalFlagToNodes(
ModelPart& rModelPart,
Flags Flag);
113 template<
class TDataType,
class TVarType = Variable<TDataType>>
115 const TVarType& rVariable,
117 const double ElapsedTime,
118 const double SemiPeriod)
120 const double smooth = -std::expm1(-ElapsedTime / SemiPeriod);
124 TDataType increment = current -
initial;
125 current =
initial + smooth * increment;
129 template<
class TVarType>
133 rNode.FastGetSolutionStepValue(rVariable, 1) = rNode.FastGetSolutionStepValue(rVariable);
142 void SetMeshZCoordinateToZero(
ModelPart& rModelPart);
147 void SetMeshZ0CoordinateToZero(
ModelPart& rModelPart);
157 void OffsetMeshZCoordinate(
ModelPart& rModelPart,
const double Increment);
162 void SwapYZCoordinates(
ModelPart& rModelPart);
167 void SwapY0Z0Coordinates(
ModelPart& rModelPart);
181 std::swap(r_value[1], r_value[2]);
188 template<
class TContainerType>
191 block_for_each(rContainer, [&](
typename TContainerType::value_type& rEntity){
193 std::swap(r_value[1], r_value[2]);
200 template<
class TContainerType>
201 void OffsetIds(TContainerType& rContainer,
const double Offset)
203 block_for_each(rContainer, [&](
typename TContainerType::value_type& rEntity){
204 rEntity.SetId(rEntity.Id() + Offset);
211 template<
class TContainerType>
214 const std::size_t offset = rContainer.size();
215 OffsetIds(rContainer, offset);
221 template<
bool THistorical>
227 template<
bool THistorical>
228 double ComputeL2NormAABB(
237 template<
class TContainerType>
239 TContainerType& rContainer,
241 const double RelativeDryHeight = -1.0)
243 KRATOS_ERROR_IF_NOT(rProcessInfo.
Has(GRAVITY)) <<
"ShallowWaterUtilities::ComputeHydrostaticForces : GRAVITY is not defined in the ProcessInfo" << std::endl;
244 if (rContainer.size() > 0) {
245 const auto& r_prop = rContainer.begin()->GetProperties();
246 KRATOS_ERROR_IF_NOT(r_prop.Has(DENSITY)) <<
"ShallowWaterUtilities::ComputeHydrostaticForces : DENSITY is not defined in the Properties" << std::endl;
250 forces = block_for_each<SumReduction<array_1d<double,3>>>(
251 rContainer, [&](
typename TContainerType::value_type& rEntity){
253 if (RelativeDryHeight >= 0.0) {
254 if (IsWet(rEntity.GetGeometry(), RelativeDryHeight)) {
255 rEntity.Calculate(FORCE, local_force, rProcessInfo);
258 rEntity.Calculate(FORCE, local_force, rProcessInfo);
275 template<
bool THistorical>
278 bool IsWet(
const GeometryType& rGeometry,
const double RelativeDryHeight);
280 bool IsWet(
const GeometryType& rGeometry,
const double Height,
const double RelativeDryHeight);
282 bool IsWet(
const double Height,
const double DryHeight);
bool Has(const Variable< TDataType > &rThisVariable) const
Checks if the data container has a value associated with a given variable.
Definition: data_value_container.h:382
Geometry base class.
Definition: geometry.h:71
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:435
Point class.
Definition: point.h:59
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
This class is a wrapper of useful utilities for shallow water computations.
Definition: shallow_water_utilities.h:60
void OffsetIds(TContainerType &rContainer)
Offset the ids of the given container for visualization purpose in GiD.
Definition: shallow_water_utilities.h:212
void SwapYZComponents(const Variable< array_1d< double, 3 >> &rVariable, NodesContainerType &rNodes)
Swap the Y and Z components of a vector variable.
Definition: shallow_water_utilities.h:177
ModelPart::NodesContainerType NodesContainerType
Definition: shallow_water_utilities.h:69
Geometry< NodeType > GeometryType
Definition: shallow_water_utilities.h:67
void OffsetIds(TContainerType &rContainer, const double Offset)
Offset the ids of the given container for visualization purpose in GiD.
Definition: shallow_water_utilities.h:201
KRATOS_CLASS_POINTER_DEFINITION(ShallowWaterUtilities)
array_1d< double, 3 > ComputeHydrostaticForces(TContainerType &rContainer, const ProcessInfo &rProcessInfo, const double RelativeDryHeight=-1.0)
Compute the horizontal hydrostatic pressures.
Definition: shallow_water_utilities.h:238
void SmoothHistoricalVariable(const TVarType &rVariable, NodesContainerType &rNodes, const double ElapsedTime, const double SemiPeriod)
Definition: shallow_water_utilities.h:114
Node NodeType
Definition: shallow_water_utilities.h:65
void SwapYZComponentsNonHistorical(const Variable< array_1d< double, 3 >> &rVariable, TContainerType &rContainer)
Swap the Y and Z components of a vector variable.
Definition: shallow_water_utilities.h:189
void CopyVariableToPreviousTimeStep(ModelPart &rModelPart, const TVarType &rVariable)
Definition: shallow_water_utilities.h:130
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
array_1d< double, Dim > ComputeVelocity(const Element &rElement)
Definition: potential_flow_utilities.cpp:112
Parameters GetValue(Parameters &rParameters, const std::string &rEntry)
Definition: add_kratos_parameters_to_python.cpp:53
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
void block_for_each(TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
Execute a functor on all items of a range in parallel.
Definition: parallel_utilities.h:299
subroutine initial(STRESS, T, DSTRAN, DEPS, NTENS, NDI, NSHR)
Definition: TensorModule.f:377