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

[Core][Documentation] Adding documentation to DataValueContainer #11661

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 46 additions & 53 deletions kratos/containers/data_value_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,33 @@
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Pooyan Dadvand, Daniel Diez
// Main authors: Pooyan Dadvand
// Daniel Diez
//
//


// System includes


// External includes


// Project includes
#include "containers/data_value_container.h"


namespace Kratos
{
KRATOS_CREATE_LOCAL_FLAG(DataValueContainer, OVERWRITE_OLD_VALUES, 0);

KRATOS_CREATE_LOCAL_FLAG(DataValueContainer, OVERWRITE_OLD_VALUES, 0);

void DataValueContainer::Merge(
const DataValueContainer& rOther,
const Flags Options)
{
const bool overwrite_values = Options.Is(OVERWRITE_OLD_VALUES);
void DataValueContainer::Merge(
const DataValueContainer& rOther,
const Flags Options
)
{
const bool overwrite_values = Options.Is(OVERWRITE_OLD_VALUES);

if (overwrite_values) {
for (const_iterator i = rOther.mData.begin(); i != rOther.mData.end(); ++i) {
if (overwrite_values) {
for (const_iterator i = rOther.mData.begin(); i != rOther.mData.end(); ++i) {
bool variable_already_exist = false;
for (iterator j = mData.begin(); j != mData.end(); ++j) {
if (i->first == j->first) {
Expand All @@ -43,58 +39,55 @@ namespace Kratos
j->second = i->first->Clone(i->second);
}
}
if (!variable_already_exist) mData.push_back(ValueType(i->first, i->first->Clone(i->second)));
if (!variable_already_exist) {
mData.push_back(ValueType(i->first, i->first->Clone(i->second)));
}
}

else {
for (const_iterator i = rOther.mData.begin(); i != rOther.mData.end(); ++i) {
} else {
for (const_iterator i = rOther.mData.begin(); i != rOther.mData.end(); ++i) {
bool variable_already_exist = false;
for (iterator j = mData.begin(); j != mData.end(); ++j) {
if (i->first == j->first) {
variable_already_exist = true;
}
}
if (!variable_already_exist) mData.push_back(ValueType(i->first, i->first->Clone(i->second)));
if (!variable_already_exist) {
mData.push_back(ValueType(i->first, i->first->Clone(i->second)));
}
}
}
}

void DataValueContainer::save(Serializer& rSerializer) const
{
KRATOS_TRY

std::size_t size = mData.size();
rSerializer.save("Size", size);
for (std::size_t i = 0; i < size; i++)
{
rSerializer.save("Variable Name", mData[i].first->Name());
mData[i].first->Save(rSerializer, mData[i].second);
}
void DataValueContainer::save(Serializer& rSerializer) const
{
KRATOS_TRY

KRATOS_CATCH("")
std::size_t size = mData.size();
rSerializer.save("Size", size);
for (std::size_t i = 0; i < size; i++) {
rSerializer.save("Variable Name", mData[i].first->Name());
mData[i].first->Save(rSerializer, mData[i].second);
}

void DataValueContainer::load(Serializer& rSerializer)
{
KRATOS_TRY

std::size_t size;
rSerializer.load("Size", size);
mData.resize(size);
std::string name;
for (std::size_t i = 0; i < size; i++)
{
rSerializer.load("Variable Name", name);
mData[i].first = KratosComponents<VariableData>::pGet(name);
mData[i].first->Allocate(&(mData[i].second));
mData[i].first->Load(rSerializer, mData[i].second);
}
KRATOS_CATCH("")
}

KRATOS_CATCH("")
void DataValueContainer::load(Serializer& rSerializer)
{
KRATOS_TRY

std::size_t size;
rSerializer.load("Size", size);
mData.resize(size);
std::string name;
for (std::size_t i = 0; i < size; i++) {
rSerializer.load("Variable Name", name);
mData[i].first = KratosComponents<VariableData>::pGet(name);
mData[i].first->Allocate(&(mData[i].second));
mData[i].first->Load(rSerializer, mData[i].second);
}

KRATOS_CATCH("")
}

} // namespace Kratos.


} // namespace Kratos.
Loading