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

Add an example for node connectivity from WALE #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions plugins/UFEM/src/UFEM/les/WALE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "common/Component.hpp"
#include "common/Builder.hpp"
#include "common/FindComponents.hpp"
#include "common/OptionT.hpp"
#include "common/OptionArray.hpp"
#include "common/PropertyList.hpp"
Expand Down Expand Up @@ -70,6 +71,9 @@ WALE::WALE(const std::string& name) :
.attach_trigger(boost::bind(&WALE::trigger_set_expression, this));

m_reset_viscosity = create_component<ProtoAction>("ResetViscosity");

m_node_connectivity = create_static_component<mesh::NodeConnectivity>("NodeConnectivity");
m_wale_op.op.m_node_connectivity = m_node_connectivity.get();

trigger_set_expression();
}
Expand Down Expand Up @@ -106,6 +110,11 @@ void WALE::on_regions_set()
m_node_valence->options().set("regions", options().option("regions").value());
}
m_reset_viscosity->options().set("regions", options().option("regions").value());
if(!m_loop_regions.empty())
{
mesh::Mesh& mesh = common::find_parent_component<mesh::Mesh>(*m_loop_regions.front());
m_node_connectivity->initialize(common::find_components_recursively_with_filter<mesh::Elements>(mesh, mesh::IsElementsVolume()));
}
}


Expand Down
17 changes: 17 additions & 0 deletions plugins/UFEM/src/UFEM/les/WALE.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../InitialConditions.hpp"

#include "LibUFEMLES.hpp"
#include "mesh/ConnectivityData.hpp"
#include "solver/actions/Proto/ProtoAction.hpp"
#include "solver/actions/Proto/Expression.hpp"

Expand Down Expand Up @@ -89,6 +90,20 @@ struct ComputeNuWALE
Sd.diagonal().array() -= grad_u2.trace()/3.;
const Real Sd_norm2 = Sd.squaredNorm();

const auto element_nodes = u.support().element_connectivity();
CFdebug << "looking up adjacent elements for element " << u.support().element_idx() << CFendl;
for(Uint node_idx : element_nodes)
{
CFdebug << "Elements next to node " << node_idx << ": ";
const Uint elements_begin = m_node_connectivity->node_first_elements()[node_idx];
const Uint elements_end = elements_begin + m_node_connectivity->node_element_counts()[node_idx];
for(Uint j = elements_begin; j != elements_end; ++j)
{
CFdebug << " " << m_node_connectivity->node_elements()[j].first << ", " << m_node_connectivity->node_elements()[j].second << " ";
}
CFdebug << CFendl;
}

// Compute the anisotropic cell size adjustment using the method of Scotti et al.
Real f = 1.;
if(use_anisotropic_correction)
Expand Down Expand Up @@ -147,6 +162,7 @@ struct ComputeNuWALE
// Model constant
Real cw;
bool use_anisotropic_correction;
mesh::NodeConnectivity* m_node_connectivity = nullptr;
};

}
Expand All @@ -171,6 +187,7 @@ class WALE : public solver::actions::Proto::ProtoAction
Handle<InitialConditions> m_initial_conditions;
Handle<common::Component> m_node_valence;
Handle<solver::actions::Proto::ProtoAction> m_reset_viscosity;
Handle<mesh::NodeConnectivity> m_node_connectivity;

/// The data stored by the WALE op terminal
solver::actions::Proto::MakeSFOp<detail::ComputeNuWALE>::stored_type m_wale_op;
Expand Down