Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RANS] QSVMS Expansion Step 1 - Add Constitutive Law Support #7949

Merged
merged 11 commits into from
Dec 15, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Kratos
{

template<>
KRATOS_API(FLUID_DYNAMICS_APPLICATION)
void FluidCalculationUtilities::AssignValue(
const array_1d<double, 3>& rInput,
array_1d<double, 2>& rOutput)
Expand All @@ -38,6 +39,7 @@ void FluidCalculationUtilities::AssignValue(
}

template<>
KRATOS_API(FLUID_DYNAMICS_APPLICATION)
void FluidCalculationUtilities::UpdateValue(
const double& rInput,
double& rOutput)
Expand All @@ -46,6 +48,7 @@ void FluidCalculationUtilities::UpdateValue(
}

template<>
KRATOS_API(FLUID_DYNAMICS_APPLICATION)
void FluidCalculationUtilities::UpdateValue(
const array_1d<double, 3>& rInput,
array_1d<double, 2>& rOutput)
Expand All @@ -63,13 +66,13 @@ void FluidCalculationUtilities::UpdateValue(
}

// template instantiations
template void FluidCalculationUtilities::AssignValue<double>(const double&, double&);
template void FluidCalculationUtilities::AssignValue<array_1d<double, 3>>(const array_1d<double, 3>&, array_1d<double, 3>&);
template void FluidCalculationUtilities::AssignValue<Vector>(const Vector&, Vector&);
template void FluidCalculationUtilities::AssignValue<Matrix>(const Matrix&, Matrix&);
template KRATOS_API(FLUID_DYNAMICS_APPLICATION) void FluidCalculationUtilities::AssignValue<double>(const double&, double&);
template KRATOS_API(FLUID_DYNAMICS_APPLICATION) void FluidCalculationUtilities::AssignValue<array_1d<double, 3>>(const array_1d<double, 3>&, array_1d<double, 3>&);
template KRATOS_API(FLUID_DYNAMICS_APPLICATION) void FluidCalculationUtilities::AssignValue<Vector>(const Vector&, Vector&);
template KRATOS_API(FLUID_DYNAMICS_APPLICATION) void FluidCalculationUtilities::AssignValue<Matrix>(const Matrix&, Matrix&);

template void FluidCalculationUtilities::UpdateValue<array_1d<double, 3>>(const array_1d<double, 3>&, array_1d<double, 3>&);
template void FluidCalculationUtilities::UpdateValue<Vector>(const Vector&, Vector&);
template void FluidCalculationUtilities::UpdateValue<Matrix>(const Matrix&, Matrix&);
template KRATOS_API(FLUID_DYNAMICS_APPLICATION) void FluidCalculationUtilities::UpdateValue<array_1d<double, 3>>(const array_1d<double, 3>&, array_1d<double, 3>&);
template KRATOS_API(FLUID_DYNAMICS_APPLICATION) void FluidCalculationUtilities::UpdateValue<Vector>(const Vector&, Vector&);
template KRATOS_API(FLUID_DYNAMICS_APPLICATION) void FluidCalculationUtilities::UpdateValue<Matrix>(const Matrix&, Matrix&);

} // namespace Kratos
1 change: 1 addition & 0 deletions applications/RANSApplication/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ file(GLOB_RECURSE KRATOS_RANS_APPLICATION_CORE_UTILITIES
file(GLOB_RECURSE KRATOS_RANS_APPLICATION_CORE
${CMAKE_CURRENT_SOURCE_DIR}/custom_conditions/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_elements/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_constitutive/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_processes/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_strategies/*.cpp
)
Expand Down
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
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
Loading