3 #include <boost/foreach.hpp> 11 std::string testName = std::string(
"SimulationTest") + std::to_string(TDim) +
"D";
38 int NumActiveDimensions = 0;
39 int relevantDirection = 0;
40 for (
int i = 0; i < TDim; ++i)
42 assert((rN[i] == 1 || rN[i] == 16) &&
"Only 16 or 1 element(s) in each direction allowed for this test");
45 ++NumActiveDimensions;
46 relevantDirection = i;
49 assert(NumActiveDimensions == 1 &&
"Results are only valid for one dimensional flows");
52 Eigen::VectorXd PaperValues(17);
53 PaperValues[0] = 0.06;
54 PaperValues[1] = 0.097;
55 PaperValues[2] = 0.116;
56 PaperValues[3] = 0.129;
57 PaperValues[4] = 0.138;
58 PaperValues[5] = 0.146;
59 PaperValues[6] = 0.148;
60 PaperValues[7] = 0.151;
61 PaperValues[8] = 0.152;
62 PaperValues[9] = PaperValues[7];
63 PaperValues[10] = PaperValues[6];
64 PaperValues[11] = PaperValues[5];
65 PaperValues[12] = PaperValues[4];
66 PaperValues[13] = PaperValues[3];
67 PaperValues[14] = PaperValues[2];
68 PaperValues[15] = PaperValues[1];
69 PaperValues[16] = PaperValues[0];
71 typedef boost::ptr_map<int, NuTo::NodeBase>
NodeMap;
73 assert(rL[relevantDirection] == 0.16 &&
74 "The length in flow direction must be 0.16m for direct comparison with paper values");
78 double deltaL = rL[relevantDirection] / rN[relevantDirection];
79 unsigned int numMismatchingValues = 0;
82 const NodeMap& nodePtrMap = rS.NodeGetNodeMap();
83 BOOST_FOREACH (NodeMap::const_iterator::value_type it, nodePtrMap)
85 const NuTo::NodeBase* nodePtr = it.second;
88 if (nodePtr->GetNum(NuTo::Node::eDof::WATERVOLUMEFRACTION) < 1)
93 double relevantNodeCoord = nodePtr->Get(NuTo::Node::eDof::COORDINATES)[relevantDirection];
94 int relevantIndex =
static_cast<int>(std::round(relevantNodeCoord / deltaL));
96 double nodalWVF = nodePtr->Get(NuTo::Node::eDof::WATERVOLUMEFRACTION)[0];
97 double paperWVF = PaperValues[relevantIndex];
98 if (nodalWVF < paperWVF - tolerance || nodalWVF > paperWVF + tolerance)
100 ++numMismatchingValues;
103 if (numMismatchingValues > 0)
106 "One ore more calculated values exceeds the tolerance when compared to reference values");
118 void SimulationTest(std::vector<int> rN, std::vector<double> rL, std::array<bool, TDim> rBS,
119 std::map<NuTo::Node::eDof, NuTo::Interpolation::eTypeOrder> rDofIPTMap,
120 bool rTestInterpolationTypeCombi =
false)
122 std::string testName = SimulationTest_GetTestName<TDim>(rBS);
124 if (rTestInterpolationTypeCombi)
126 testName +=
"_TestInterpolationtypeCombi";
129 std::cout << std::endl
130 <<
"--------------------------------------------------------------------------" << std::endl
131 <<
"Start test: " << testName << std::endl
132 <<
"--------------------------------------------------------------------------" << std::endl;
134 NuTo::Structure S(TDim);
137 if (rTestInterpolationTypeCombi)
139 testName +=
"_TestInterpolationtypeCombi";
140 timeControl.
t_final = 1.0 * 1.0 * 1.0 * 60.0;
146 timeControl.
t_final = 293.0 * 24.0 * 60.0 * 60.0;
152 NuTo::NewmarkDirect TI(&S);
164 std::string
resultDir = std::string(
"./ConstitutiveLawMoistureTransport_") + testName;
166 SetupStructure<TDim>(S, testName);
167 auto SEC = SetupSection<TDim>(S);
169 auto meshInfo = NuTo::MeshGenerator::Grid(S, rL, rN);
171 for (
auto it : rDofIPTMap)
172 S.InterpolationTypeAdd(meshInfo.second, it.first, it.second);
174 S.ElementGroupSetSection(meshInfo.first, SEC);
177 SetupIntegrationType<TDim>(S, meshInfo.first);
179 S.ElementTotalConvertToInterpolationType();
183 auto LambdaGetBoundaryNodes = [rL, rBS](NuTo::NodeBase* rNodePtr) ->
bool {
185 if (rNodePtr->GetNum(NuTo::Node::eDof::COORDINATES) > 0)
187 double x = rNodePtr->Get(NuTo::Node::eDof::COORDINATES)[0];
188 if (rBS[0] && ((x >= 0.0 - Tol && x <= 0.0 + Tol) || (x >= rL[0] - Tol && x <= rL[0] + Tol)))
195 double y = rNodePtr->Get(NuTo::Node::eDof::COORDINATES)[1];
196 if (rBS[1] && ((y >= 0.0 - Tol && y <= 0.0 + Tol) || (y >= rL[1] - Tol && y <= rL[1] + Tol)))
203 double z = rNodePtr->Get(NuTo::Node::eDof::COORDINATES)[2];
204 if (rBS[2] && ((z >= 0.0 - Tol && z <= 0.0 + Tol) || (z >= rL[2] - Tol && z <= rL[2] + Tol)))
214 auto LambdaTimeDepBoundaryRH = [&MT, &timeControl](
double rTime) ->
double {
234 SetupConstrainedNodeBoundaryElements<TDim>(S, LambdaGetBoundaryNodes, LambdaTimeDepBoundaryRH);
237 S.NodeBuildGlobalDofs();
244 NuTo::Timer timer(testName +
" --- Timeintegration.Solve");
246 if (!rTestInterpolationTypeCombi)
248 CompareResultsToPaper<TDim>(S, rN, rL);
int ConstitutiveLawID
Definition: MoistureTransport_Setup.h:97
double BoundaryEnvironmentalRH
Definition: MoistureTransport_Setup.h:85
Base class for all exceptions thrown in NuTo.
Definition: Exception.h:9
void SetupVisualize(NuTo::Structure &rS)
Definition: MoistureTransport_Setup.h:376
resultDir
Definition: GradingCurveFileIO.py:67
std::string SimulationTest_GetTestName(std::array< bool, TDim > &rBS)
Determines the name of the test.
Definition: MoistureTransport_SimulationTest.h:9
prints the lifetime of a Timer object on destruction
Definition: Timer.h:11
void SetupMultiProcessor(NuTo::Structure &rS)
Definition: MoistureTransport_Setup.h:290
void SetParametersConstitutiveLaw()
Definition: MoistureTransport_Setup.h:119
void CompareResultsToPaper(NuTo::Structure &rS, std::vector< int > rN, std::vector< double > rL)
Definition: MoistureTransport_SimulationTest.h:36
constexpr double tolerance
Definition: NewtonRaphsonBenchmark.cpp:11
void SetupTimeIntegration(NuTo::NewmarkDirect &rTI, const TimeControl &rTC, const std::string &rResultDir)
Definition: MoistureTransport_Setup.h:358
double InitialRelativeHumidity
Definition: MoistureTransport_Setup.h:73
double delta_t
Definition: MoistureTransport_Setup.h:58
void ApplyInitialNodalValues()
Definition: MoistureTransport_Setup.h:157
void SimulationTest(std::vector< int > rN, std::vector< double > rL, std::array< bool, TDim > rBS, std::map< NuTo::Node::eDof, NuTo::Interpolation::eTypeOrder > rDofIPTMap, bool rTestInterpolationTypeCombi=false)
performs a simulation in the desired dimension
Definition: MoistureTransport_SimulationTest.h:118
double BC_TransitionTime
Definition: MoistureTransport_Setup.h:61
void SetupStaticData()
Definition: MoistureTransport_Setup.h:176
Definition: MoistureTransport_Setup.h:68
double t_final
Definition: MoistureTransport_Setup.h:60
double MassExchangeRate
–> Calculated from relative humidity
Definition: MoistureTransport_Setup.h:75
Definition: MoistureTransport_Setup.h:56
double DiffusionCoefficientRH
Definition: MoistureTransport_Setup.h:77
double t_write
Definition: MoistureTransport_Setup.h:59
boost::ptr_map< int, NuTo::NodeBase > NodeMap
Definition: MultipleConstitutiveLaws.cpp:53