-
Notifications
You must be signed in to change notification settings - Fork 250
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 #7949 from KratosMultiphysics/rans/qs_vms/add_cons…
…titutive_laws [RANS] QSVMS Expansion Step 1 - Add Constitutive Law Support
- Loading branch information
Showing
8 changed files
with
527 additions
and
7 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
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
119 changes: 119 additions & 0 deletions
119
applications/RANSApplication/custom_constitutive/rans_newtonian_2d_law.cpp
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,119 @@ | ||
// | / | | ||
// ' / __| _` | __| _ \ __| | ||
// . \ | ( | | ( |\__ ` | ||
// _|\_\_| \__,_|\__|\___/ ____/ | ||
// Multi-Physics | ||
// | ||
// License: BSD License | ||
// Kratos default license: kratos/license.txt | ||
// | ||
// Main authors: Suneth Warnakulasuriya | ||
// | ||
|
||
// System includes | ||
#include <iostream> | ||
|
||
// External includes | ||
|
||
// Project includes | ||
#include "includes/cfd_variables.h" | ||
#include "includes/checks.h" | ||
|
||
// Application includes | ||
#include "custom_utilities/fluid_calculation_utilities.h" | ||
|
||
// Include base h | ||
#include "custom_constitutive/rans_newtonian_2d_law.h" | ||
|
||
namespace Kratos | ||
{ | ||
//******************************CONSTRUCTOR******************************************* | ||
//************************************************************************************ | ||
|
||
RansNewtonian2DLaw::RansNewtonian2DLaw() : BaseType() | ||
{ | ||
} | ||
|
||
//******************************COPY CONSTRUCTOR************************************** | ||
//************************************************************************************ | ||
|
||
RansNewtonian2DLaw::RansNewtonian2DLaw(const RansNewtonian2DLaw& rOther) | ||
: BaseType(rOther) | ||
{ | ||
} | ||
|
||
//********************************CLONE*********************************************** | ||
//************************************************************************************ | ||
|
||
ConstitutiveLaw::Pointer RansNewtonian2DLaw::Clone() const | ||
{ | ||
return Kratos::make_shared<RansNewtonian2DLaw>(*this); | ||
} | ||
|
||
//*******************************DESTRUCTOR******************************************* | ||
//************************************************************************************ | ||
|
||
RansNewtonian2DLaw::~RansNewtonian2DLaw() | ||
{ | ||
} | ||
|
||
int RansNewtonian2DLaw::Check( | ||
const Properties& rMaterialProperties, | ||
const GeometryType& rElementGeometry, | ||
const ProcessInfo& rCurrentProcessInfo) | ||
{ | ||
KRATOS_TRY | ||
|
||
// Check viscosity value | ||
KRATOS_ERROR_IF(rMaterialProperties[DYNAMIC_VISCOSITY] <= 0.0) | ||
<< "Incorrect or missing DYNAMIC_VISCOSITY provided in material properties " | ||
"for RansNewtonian2DLaw: " | ||
<< rMaterialProperties[DYNAMIC_VISCOSITY] << std::endl; | ||
|
||
KRATOS_ERROR_IF(rMaterialProperties[DENSITY] <= 0.0) | ||
<< "Incorrect or missing DENSITY provided in material properties " | ||
"for RansNewtonian2DLaw: " | ||
<< rMaterialProperties[DENSITY] << std::endl; | ||
|
||
for (IndexType i = 0; i < rElementGeometry.PointsNumber(); ++i) { | ||
const auto& r_node = rElementGeometry[i]; | ||
|
||
KRATOS_CHECK_VARIABLE_IN_NODAL_DATA(TURBULENT_VISCOSITY, r_node); | ||
} | ||
|
||
return 0; | ||
|
||
KRATOS_CATCH(""); | ||
} | ||
|
||
std::string RansNewtonian2DLaw::Info() const | ||
{ | ||
return "RansNewtonian2DLaw"; | ||
} | ||
|
||
double RansNewtonian2DLaw::GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const | ||
{ | ||
const Properties& r_prop = rParameters.GetMaterialProperties(); | ||
|
||
const double mu = r_prop[DYNAMIC_VISCOSITY]; | ||
const double density = r_prop[DENSITY]; | ||
|
||
double turbulent_nu; | ||
FluidCalculationUtilities::EvaluateInPoint( | ||
rParameters.GetElementGeometry(), rParameters.GetShapeFunctionsValues(), | ||
std::tie(turbulent_nu, TURBULENT_VISCOSITY)); | ||
|
||
return mu + density * turbulent_nu; | ||
} | ||
|
||
void RansNewtonian2DLaw::save(Serializer& rSerializer) const | ||
{ | ||
KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, BaseType) | ||
} | ||
|
||
void RansNewtonian2DLaw::load(Serializer& rSerializer) | ||
{ | ||
KRATOS_SERIALIZE_LOAD_BASE_CLASS(rSerializer, BaseType) | ||
} | ||
|
||
} // Namespace Kratos |
132 changes: 132 additions & 0 deletions
132
applications/RANSApplication/custom_constitutive/rans_newtonian_2d_law.h
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,132 @@ | ||
// | / | | ||
// ' / __| _` | __| _ \ __| | ||
// . \ | ( | | ( |\__ ` | ||
// _|\_\_| \__,_|\__|\___/ ____/ | ||
// Multi-Physics | ||
// | ||
// License: BSD License | ||
// Kratos default license: kratos/license.txt | ||
// | ||
// Main authors: Suneth Warnakulasuriya | ||
// | ||
|
||
#if !defined(KRATOS_RANS_NEWTONIAN_LAW_2D_H_INCLUDED) | ||
#define KRATOS_RANS_NEWTONIAN_LAW_2D_H_INCLUDED | ||
|
||
// System includes | ||
|
||
// External includes | ||
|
||
// Project includes | ||
#include "custom_constitutive/newtonian_2d_law.h" | ||
|
||
namespace Kratos | ||
{ | ||
/** | ||
* @brief This class is extending Newtonian2DLaw in FluidDynamicsApplication | ||
* | ||
* This class is used to extend Newtonian2DLaw in FluidDynamicsApplication | ||
* to include turbulent viscosity from Bossinesq Hypothesis. | ||
* | ||
*/ | ||
class KRATOS_API(RANS_APPLICATION) RansNewtonian2DLaw : public Newtonian2DLaw | ||
{ | ||
public: | ||
///@name Type Definitions | ||
///@{ | ||
|
||
using BaseType = Newtonian2DLaw; | ||
|
||
///@} | ||
///@name Life Cycle | ||
///@{ | ||
|
||
/** | ||
* Counted pointer of Newtonian3DLaw | ||
*/ | ||
|
||
KRATOS_CLASS_POINTER_DEFINITION(RansNewtonian2DLaw); | ||
|
||
/** | ||
* Life Cycle | ||
*/ | ||
|
||
/** | ||
* Default constructor. | ||
*/ | ||
RansNewtonian2DLaw(); | ||
|
||
/** | ||
* Clone function (has to be implemented by any derived class) | ||
* @return a pointer to a new instance of this constitutive law | ||
*/ | ||
ConstitutiveLaw::Pointer Clone() const override; | ||
|
||
/** | ||
* Copy constructor. | ||
*/ | ||
RansNewtonian2DLaw(const RansNewtonian2DLaw& rOther); | ||
|
||
/** | ||
* Destructor. | ||
*/ | ||
~RansNewtonian2DLaw(); | ||
|
||
/** | ||
* Operations needed by the base class: | ||
*/ | ||
|
||
///@} | ||
///@name Operations | ||
///@{ | ||
|
||
/** | ||
* This function is designed to be called once to perform all the checks | ||
* needed on the input provided. Checks can be "expensive" as the function | ||
* is designed to catch user's errors. | ||
* @param rMaterialProperties | ||
* @param rElementGeometry | ||
* @param rCurrentProcessInfo | ||
* @return | ||
*/ | ||
int Check( | ||
const Properties& rMaterialProperties, | ||
const GeometryType& rElementGeometry, | ||
const ProcessInfo& rCurrentProcessInfo) override; | ||
|
||
///@} | ||
///@name Access | ||
///@{ | ||
|
||
/** | ||
* Input and output | ||
*/ | ||
/** | ||
* Turn back information as a string. | ||
*/ | ||
std::string Info() const override; | ||
|
||
///@} | ||
|
||
protected: | ||
///@name Protected Operations | ||
///@{ | ||
|
||
/// Get the effective viscosity (in dynamic units -- Pa s) for the fluid. | ||
double GetEffectiveViscosity(ConstitutiveLaw::Parameters& rParameters) const override; | ||
|
||
///@} | ||
private: | ||
///@name Serialization | ||
///@{ | ||
|
||
friend class Serializer; | ||
|
||
void save(Serializer& rSerializer) const override; | ||
|
||
void load(Serializer& rSerializer) override; | ||
|
||
///@} | ||
}; // Class RansNewtonian2DLaw | ||
} // namespace Kratos. | ||
#endif // KRATOS_RANS_NEWTONIAN_LAW_2D_H_INCLUDED defined |
Oops, something went wrong.