C++ scientific code snippet
I just show a little code snippet taken from our programming environment
void solve( Sfx::Discretization* aDiscretization)
{
// retrieve nodal variables
U_h& w_Uh = aDiscretization->Uh();
// extract component from nodal variables
std::valarray w_valA(w_Uh.size());
std::transform(w_Uh.begin(),w_Uh.end(),&w_valA[0],Sfx::GetA);
std::valarray w_valQ(w_Uh.size());
std::transform(w_Uh.begin(),w_Uh.end(),&w_valQ[0],Sfx::GetQ);
// retrieve the spatial discretization
GridLattice& w_Mesh1D = aDiscretization->spatialDiscretization();
// create scalar field (shall use the boost smart pointer mechanism)
scalarField w_A( std::string("A"),w_Mesh1D);
scalarField w_Q( std::string("Q"),w_Mesh1D);
// set values of the field
w_A.values(w_valA);
w_Q.values(w_valQ);
// apply boundary condition
BoundaryCondition* w_bndCnd = aDiscretization->gamma();
w_bndCnd->applyBC();
}
Leave a Reply
Want to join the discussion?Feel free to contribute!